150e6b072SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 350e6b072SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 450e6b072SAndrew Rist * or more contributor license agreements. See the NOTICE file 550e6b072SAndrew Rist * distributed with this work for additional information 650e6b072SAndrew Rist * regarding copyright ownership. The ASF licenses this file 750e6b072SAndrew Rist * to you under the Apache License, Version 2.0 (the 850e6b072SAndrew Rist * "License"); you may not use this file except in compliance 950e6b072SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 1150e6b072SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 1350e6b072SAndrew Rist * Unless required by applicable law or agreed to in writing, 1450e6b072SAndrew Rist * software distributed under the License is distributed on an 1550e6b072SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1650e6b072SAndrew Rist * KIND, either express or implied. See the License for the 1750e6b072SAndrew Rist * specific language governing permissions and limitations 1850e6b072SAndrew Rist * under the License. 19cdf0e10cSrcweir * 2050e6b072SAndrew Rist *************************************************************/ 2150e6b072SAndrew Rist 2250e6b072SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _TOOLKIT_CONTROLS_UNOCONTROLCONTAINER_HXX_ 25cdf0e10cSrcweir #define _TOOLKIT_CONTROLS_UNOCONTROLCONTAINER_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <com/sun/star/awt/XControlContainer.hpp> 29cdf0e10cSrcweir #include <com/sun/star/awt/XUnoControlContainer.hpp> 30cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp> 31cdf0e10cSrcweir #include <com/sun/star/container/XIdentifierContainer.hpp> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <toolkit/controls/unocontrol.hxx> 34cdf0e10cSrcweir #include <toolkit/controls/unocontrolbase.hxx> 35cdf0e10cSrcweir #include <toolkit/helper/macros.hxx> 36cdf0e10cSrcweir #include <toolkit/helper/servicenames.hxx> 37cdf0e10cSrcweir 38cdf0e10cSrcweir #include <cppuhelper/implbase4.hxx> 39cdf0e10cSrcweir 40cdf0e10cSrcweir class UnoControlHolderList; 41cdf0e10cSrcweir 42cdf0e10cSrcweir // ---------------------------------------------------- 43cdf0e10cSrcweir // class UnoControlContainer 44cdf0e10cSrcweir // ---------------------------------------------------- 45cdf0e10cSrcweir typedef ::cppu::AggImplInheritanceHelper4 < UnoControlBase 46cdf0e10cSrcweir , ::com::sun::star::awt::XUnoControlContainer 47cdf0e10cSrcweir , ::com::sun::star::awt::XControlContainer 48cdf0e10cSrcweir , ::com::sun::star::container::XContainer 49cdf0e10cSrcweir , ::com::sun::star::container::XIdentifierContainer 50cdf0e10cSrcweir > UnoControlContainer_Base; 51cdf0e10cSrcweir 52cdf0e10cSrcweir class UnoControlContainer : public UnoControlContainer_Base 53cdf0e10cSrcweir { 54cdf0e10cSrcweir private: 55cdf0e10cSrcweir UnoControlHolderList* mpControls; 56cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController > > maTabControllers; 57cdf0e10cSrcweir ContainerListenerMultiplexer maCListeners; 58cdf0e10cSrcweir 59cdf0e10cSrcweir protected: 60cdf0e10cSrcweir void ImplActivateTabControllers(); 61cdf0e10cSrcweir 62cdf0e10cSrcweir public: 63cdf0e10cSrcweir UnoControlContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); 64cdf0e10cSrcweir UnoControlContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory, 65cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xPeer ); 66cdf0e10cSrcweir ~UnoControlContainer(); 67cdf0e10cSrcweir 68cdf0e10cSrcweir 69cdf0e10cSrcweir // ::com::sun::star::lang::XComponent 70cdf0e10cSrcweir void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); 71cdf0e10cSrcweir 72cdf0e10cSrcweir // ::com::sun::star::lang::XEventListener 73cdf0e10cSrcweir void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); 74cdf0e10cSrcweir 75cdf0e10cSrcweir // ::com::sun::star::container::XContainer 76cdf0e10cSrcweir void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); 77cdf0e10cSrcweir void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); 78cdf0e10cSrcweir 79cdf0e10cSrcweir // ::com::sun::star::container::XIdentifierContainer 80cdf0e10cSrcweir virtual ::sal_Int32 SAL_CALL insert( const ::com::sun::star::uno::Any& aElement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 81cdf0e10cSrcweir 82cdf0e10cSrcweir // ::com::sun::star::container::XIdentifierReplace 83cdf0e10cSrcweir virtual void SAL_CALL removeByIdentifier( ::sal_Int32 Identifier ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 84cdf0e10cSrcweir virtual void SAL_CALL replaceByIdentifer( ::sal_Int32 Identifier, const ::com::sun::star::uno::Any& aElement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 85cdf0e10cSrcweir 86cdf0e10cSrcweir // ::com::sun::star::container::XIdentifierAccess 87cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getByIdentifier( ::sal_Int32 Identifierr ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 88cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getIdentifiers( ) throw (::com::sun::star::uno::RuntimeException); 89cdf0e10cSrcweir 90cdf0e10cSrcweir // ::com::sun::star::container::XElementAccess 91cdf0e10cSrcweir virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException); 92cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException); 93cdf0e10cSrcweir 94cdf0e10cSrcweir // ::com::sun::star::awt::XControlContainer 95cdf0e10cSrcweir void SAL_CALL setStatusText( const ::rtl::OUString& StatusText ) throw(::com::sun::star::uno::RuntimeException); 96cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > > SAL_CALL getControls( ) throw(::com::sun::star::uno::RuntimeException); 97cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL getControl( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException); 98cdf0e10cSrcweir void SAL_CALL addControl( const ::rtl::OUString& Name, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& Control ) throw(::com::sun::star::uno::RuntimeException); 99cdf0e10cSrcweir void SAL_CALL removeControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& Control ) throw(::com::sun::star::uno::RuntimeException); 100cdf0e10cSrcweir 101cdf0e10cSrcweir // ::com::sun::star::awt::XUnoControlContainer 102cdf0e10cSrcweir void SAL_CALL setTabControllers( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController > >& TabControllers ) throw(::com::sun::star::uno::RuntimeException); 103cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController > > SAL_CALL getTabControllers( ) throw(::com::sun::star::uno::RuntimeException); 104cdf0e10cSrcweir void SAL_CALL addTabController( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController >& TabController ) throw(::com::sun::star::uno::RuntimeException); 105cdf0e10cSrcweir void SAL_CALL removeTabController( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController >& TabController ) throw(::com::sun::star::uno::RuntimeException); 106cdf0e10cSrcweir 107cdf0e10cSrcweir // ::com::sun::star::awt::XControl 108cdf0e10cSrcweir void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& Toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent ) throw(::com::sun::star::uno::RuntimeException); 109cdf0e10cSrcweir 110cdf0e10cSrcweir // ::com::sun::star::awt::XWindow 111cdf0e10cSrcweir void SAL_CALL setVisible( sal_Bool Visible ) throw(::com::sun::star::uno::RuntimeException); 112cdf0e10cSrcweir 113cdf0e10cSrcweir DECLIMPL_SERVICEINFO_DERIVED( UnoControlContainer, UnoControlBase, szServiceName2_UnoControlContainer ) 114cdf0e10cSrcweir 115cdf0e10cSrcweir protected: 116cdf0e10cSrcweir virtual void removingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ); 117cdf0e10cSrcweir virtual void addingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ); 118cdf0e10cSrcweir 119cdf0e10cSrcweir private: 120cdf0e10cSrcweir /** adds the control to the container, does necessary notifications, and the like 121cdf0e10cSrcweir @param _rxControl 122cdf0e10cSrcweir the control to add. Must not be <NULL/> 123cdf0e10cSrcweir @param _pName 124*54f9d3bdSJohn Bampton Pointer to a name for the control. Might be <NULL/>, in this case an automatic name is generated 125cdf0e10cSrcweir @return 126cdf0e10cSrcweir the ID of the newly added control 127cdf0e10cSrcweir */ 128cdf0e10cSrcweir sal_Int32 impl_addControl( 129cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl, 130cdf0e10cSrcweir const ::rtl::OUString* _pName = NULL 131cdf0e10cSrcweir ); 132cdf0e10cSrcweir 133cdf0e10cSrcweir /** removes the given control from the container, including necessary notifications and the like 134cdf0e10cSrcweir @param _nId 135cdf0e10cSrcweir the ID of the control to remove 136cdf0e10cSrcweir @param _rxControl 137cdf0e10cSrcweir the control itself. Must be the one which is stored under the given ID. This parameter could also be 138cdf0e10cSrcweir obtained inside the method, but callers usually have obtained it, anyway. 139cdf0e10cSrcweir @param _pNameAccessor 140cdf0e10cSrcweir the name which the control was registered for. Might be <NULL/>, in this case 141cdf0e10cSrcweir container event broadcasts use the ID as accessor. 142cdf0e10cSrcweir */ 143cdf0e10cSrcweir void impl_removeControl( 144cdf0e10cSrcweir sal_Int32 _nId, 145cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl, 146cdf0e10cSrcweir const ::rtl::OUString* _pNameAccessor 147cdf0e10cSrcweir ); 148cdf0e10cSrcweir 149cdf0e10cSrcweir /** ensures that the given control has a peer, if necessary and possible 150cdf0e10cSrcweir @param _rxControl 151cdf0e10cSrcweir an ->XControl which has just been inserted into the container. Must not be <NULL/>. 152cdf0e10cSrcweir @precond 153cdf0e10cSrcweir our mutex is locked 154cdf0e10cSrcweir */ 155cdf0e10cSrcweir void impl_createControlPeerIfNecessary( 156cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl 157cdf0e10cSrcweir ); 158cdf0e10cSrcweir }; 159cdf0e10cSrcweir 160cdf0e10cSrcweir 161cdf0e10cSrcweir 162cdf0e10cSrcweir #endif // _TOOLKIT_CONTROLS_UNOCONTROLCONTAINER_HXX_ 163