1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _TOOLKIT_CONTROLS_UNOCONTROLCONTAINER_HXX_ 29*cdf0e10cSrcweir #define _TOOLKIT_CONTROLS_UNOCONTROLCONTAINER_HXX_ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <com/sun/star/awt/XControlContainer.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/awt/XUnoControlContainer.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/container/XIdentifierContainer.hpp> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <toolkit/controls/unocontrol.hxx> 38*cdf0e10cSrcweir #include <toolkit/controls/unocontrolbase.hxx> 39*cdf0e10cSrcweir #include <toolkit/helper/macros.hxx> 40*cdf0e10cSrcweir #include <toolkit/helper/servicenames.hxx> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include <cppuhelper/implbase4.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir class UnoControlHolderList; 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir // ---------------------------------------------------- 47*cdf0e10cSrcweir // class UnoControlContainer 48*cdf0e10cSrcweir // ---------------------------------------------------- 49*cdf0e10cSrcweir typedef ::cppu::AggImplInheritanceHelper4 < UnoControlBase 50*cdf0e10cSrcweir , ::com::sun::star::awt::XUnoControlContainer 51*cdf0e10cSrcweir , ::com::sun::star::awt::XControlContainer 52*cdf0e10cSrcweir , ::com::sun::star::container::XContainer 53*cdf0e10cSrcweir , ::com::sun::star::container::XIdentifierContainer 54*cdf0e10cSrcweir > UnoControlContainer_Base; 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir class UnoControlContainer : public UnoControlContainer_Base 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir private: 59*cdf0e10cSrcweir UnoControlHolderList* mpControls; 60*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController > > maTabControllers; 61*cdf0e10cSrcweir ContainerListenerMultiplexer maCListeners; 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir protected: 64*cdf0e10cSrcweir void ImplActivateTabControllers(); 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir public: 67*cdf0e10cSrcweir UnoControlContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); 68*cdf0e10cSrcweir UnoControlContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory, 69*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xPeer ); 70*cdf0e10cSrcweir ~UnoControlContainer(); 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir // ::com::sun::star::lang::XComponent 74*cdf0e10cSrcweir void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir // ::com::sun::star::lang::XEventListener 77*cdf0e10cSrcweir void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir // ::com::sun::star::container::XContainer 80*cdf0e10cSrcweir void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); 81*cdf0e10cSrcweir void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir // ::com::sun::star::container::XIdentifierContainer 84*cdf0e10cSrcweir 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); 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir // ::com::sun::star::container::XIdentifierReplace 87*cdf0e10cSrcweir virtual void SAL_CALL removeByIdentifier( ::sal_Int32 Identifier ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 88*cdf0e10cSrcweir 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); 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir // ::com::sun::star::container::XIdentifierAccess 91*cdf0e10cSrcweir 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); 92*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getIdentifiers( ) throw (::com::sun::star::uno::RuntimeException); 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir // ::com::sun::star::container::XElementAccess 95*cdf0e10cSrcweir virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException); 96*cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException); 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir // ::com::sun::star::awt::XControlContainer 99*cdf0e10cSrcweir void SAL_CALL setStatusText( const ::rtl::OUString& StatusText ) throw(::com::sun::star::uno::RuntimeException); 100*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > > SAL_CALL getControls( ) throw(::com::sun::star::uno::RuntimeException); 101*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL getControl( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException); 102*cdf0e10cSrcweir 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); 103*cdf0e10cSrcweir void SAL_CALL removeControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& Control ) throw(::com::sun::star::uno::RuntimeException); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir // ::com::sun::star::awt::XUnoControlContainer 106*cdf0e10cSrcweir 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); 107*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController > > SAL_CALL getTabControllers( ) throw(::com::sun::star::uno::RuntimeException); 108*cdf0e10cSrcweir void SAL_CALL addTabController( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController >& TabController ) throw(::com::sun::star::uno::RuntimeException); 109*cdf0e10cSrcweir void SAL_CALL removeTabController( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController >& TabController ) throw(::com::sun::star::uno::RuntimeException); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir // ::com::sun::star::awt::XControl 112*cdf0e10cSrcweir 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); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir // ::com::sun::star::awt::XWindow 115*cdf0e10cSrcweir void SAL_CALL setVisible( sal_Bool Visible ) throw(::com::sun::star::uno::RuntimeException); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir DECLIMPL_SERVICEINFO_DERIVED( UnoControlContainer, UnoControlBase, szServiceName2_UnoControlContainer ) 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir protected: 120*cdf0e10cSrcweir virtual void removingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ); 121*cdf0e10cSrcweir virtual void addingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir private: 124*cdf0e10cSrcweir /** adds the control to the container, does necessary notifications, and the like 125*cdf0e10cSrcweir @param _rxControl 126*cdf0e10cSrcweir the control to add. Must not be <NULL/> 127*cdf0e10cSrcweir @param _pName 128*cdf0e10cSrcweir Pointer to a name for the control. Might be <NULL/>, in this case an auotmatic name is generated 129*cdf0e10cSrcweir @return 130*cdf0e10cSrcweir the ID of the newly added control 131*cdf0e10cSrcweir */ 132*cdf0e10cSrcweir sal_Int32 impl_addControl( 133*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl, 134*cdf0e10cSrcweir const ::rtl::OUString* _pName = NULL 135*cdf0e10cSrcweir ); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir /** removes the given control from the container, including necessary notifications and the like 138*cdf0e10cSrcweir @param _nId 139*cdf0e10cSrcweir the ID of the control to remove 140*cdf0e10cSrcweir @param _rxControl 141*cdf0e10cSrcweir the control itself. Must be the one which is stored under the given ID. This parameter could also be 142*cdf0e10cSrcweir obtained inside the method, but callers usually have obtained it, anyway. 143*cdf0e10cSrcweir @param _pNameAccessor 144*cdf0e10cSrcweir the name which the control was registered for. Might be <NULL/>, in this case 145*cdf0e10cSrcweir container event broadcasts use the ID as accessor. 146*cdf0e10cSrcweir */ 147*cdf0e10cSrcweir void impl_removeControl( 148*cdf0e10cSrcweir sal_Int32 _nId, 149*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl, 150*cdf0e10cSrcweir const ::rtl::OUString* _pNameAccessor 151*cdf0e10cSrcweir ); 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir /** ensures that the given control has a peer, if necessary and possible 154*cdf0e10cSrcweir @param _rxControl 155*cdf0e10cSrcweir an ->XControl which has just been inserted into the container. Must not be <NULL/>. 156*cdf0e10cSrcweir @precond 157*cdf0e10cSrcweir our mutex is locked 158*cdf0e10cSrcweir */ 159*cdf0e10cSrcweir void impl_createControlPeerIfNecessary( 160*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl 161*cdf0e10cSrcweir ); 162*cdf0e10cSrcweir }; 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir #endif // _TOOLKIT_CONTROLS_UNOCONTROLCONTAINER_HXX_ 167*cdf0e10cSrcweir 168