1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef TOOLKIT_TABPAGE_CONTAINER_HXX 29 #define TOOLKIT_TABPAGE_CONTAINER_HXX 30 31 #include <com/sun/star/awt/tab/XTabPageContainer.hpp> 32 #include <com/sun/star/awt/tab/XTabPageContainerModel.hpp> 33 #include <com/sun/star/awt/tab/XTabPageContainerListener.hpp> 34 #include <com/sun/star/awt/tab/XTabPage.hpp> 35 #include <com/sun/star/awt/tab/XTabPageModel.hpp> 36 #include <toolkit/controls/unocontrolbase.hxx> 37 #include <toolkit/controls/unocontrolmodel.hxx> 38 #include <toolkit/helper/servicenames.hxx> 39 #include <cppuhelper/implbase1.hxx> 40 #include <comphelper/sequence.hxx> 41 #include <toolkit/controls/controlmodelcontainerbase.hxx> 42 #include <toolkit/controls/unocontrolmodel.hxx> 43 #include <toolkit/helper/listenermultiplexer.hxx> 44 45 using namespace ::com::sun::star::uno; 46 //using namespace ::com::sun::star::awt; 47 using namespace ::com::sun::star::lang; 48 using namespace ::com::sun::star::beans; 49 using namespace ::com::sun::star::container; 50 51 // ------------------------------------------------------------------ 52 // class ::com::sun::star::awt::tab::UnoControlTabPageContainerModel 53 // ------------------------------------------------------------------ 54 typedef ::cppu::AggImplInheritanceHelper1 < UnoControlModel 55 , ::com::sun::star::awt::tab::XTabPageContainerModel 56 > UnoControlTabPageContainerModel_Base; 57 class UnoControlTabPageContainerModel : public UnoControlTabPageContainerModel_Base 58 { 59 private: 60 std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageModel > > m_aTabPageVector; 61 ContainerListenerMultiplexer maContainerListeners; 62 protected: 63 ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; 64 ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 65 // ::com::sun::star::beans::XMultiPropertySet 66 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 67 68 public: 69 UnoControlTabPageContainerModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); 70 UnoControlTabPageContainerModel( const UnoControlTabPageContainerModel& rModel ) : UnoControlTabPageContainerModel_Base( rModel ),maContainerListeners( *this ) {;} 71 72 UnoControlModel* Clone() const { return new UnoControlTabPageContainerModel( *this ); } 73 74 // ::com::sun::star::io::XPersistObject 75 ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); 76 77 // ::com::sun::star::lang::XServiceInfo 78 DECLIMPL_SERVICEINFO_DERIVED( UnoControlTabPageContainerModel, UnoControlModel, szServiceName_UnoControlTabPageContainerModel ) 79 80 // XTabPageContainerModel 81 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageModel > SAL_CALL createTabPage( ::sal_Int16 TabPageID ) throw (::com::sun::star::uno::RuntimeException); 82 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageModel > SAL_CALL loadTabPage( ::sal_Int16 TabPageID, const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::uno::RuntimeException); 83 84 // XIndexContainer 85 virtual void SAL_CALL insertByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) 86 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 87 virtual void SAL_CALL removeByIndex( sal_Int32 Index ) 88 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 89 90 // XIndexReplace 91 virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) 92 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 93 94 // XIndexAccess 95 virtual sal_Int32 SAL_CALL getCount() throw (::com::sun::star::uno::RuntimeException); 96 97 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) 98 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 99 100 // XElementAccess 101 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw (::com::sun::star::uno::RuntimeException); 102 virtual sal_Bool SAL_CALL hasElements() throw (::com::sun::star::uno::RuntimeException); 103 104 // ::com::sun::star::container::XContainer 105 void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); 106 void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); 107 }; 108 // =================================================================== 109 // = UnoControlTabPageContainer 110 // =================================================================== 111 typedef ::cppu::AggImplInheritanceHelper1 < ControlContainerBase 112 , ::com::sun::star::awt::tab::XTabPageContainer 113 > UnoControlTabPageContainer_Base; 114 class UnoControlTabPageContainer : public UnoControlTabPageContainer_Base 115 { 116 public: 117 UnoControlTabPageContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); 118 ::rtl::OUString GetComponentServiceName(); 119 120 // ::com::sun::star::lang::XComponent 121 void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); 122 123 // ::com::sun::star::awt::XControl 124 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); 125 126 // ::com::sun::star::awt::tab::XTabPageContainer 127 virtual ::sal_Int16 SAL_CALL getActiveTabPageID() throw (::com::sun::star::uno::RuntimeException); 128 virtual void SAL_CALL setActiveTabPageID( ::sal_Int16 _activetabpageid ) throw (::com::sun::star::uno::RuntimeException); 129 virtual ::sal_Int16 SAL_CALL getTabPageCount( ) throw (::com::sun::star::uno::RuntimeException); 130 virtual ::sal_Bool SAL_CALL isTabPageActive( ::sal_Int16 tabPageIndex ) throw (::com::sun::star::uno::RuntimeException); 131 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL getTabPage( ::sal_Int16 tabPageIndex ) throw (::com::sun::star::uno::RuntimeException); 132 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL getTabPageByID( ::sal_Int16 tabPageID ) throw (::com::sun::star::uno::RuntimeException); 133 virtual void SAL_CALL addTabPageContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (::com::sun::star::uno::RuntimeException); 134 virtual void SAL_CALL removeTabPageContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (::com::sun::star::uno::RuntimeException); 135 136 virtual 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); 137 // ::com::sun::star::lang::XServiceInfo 138 DECLIMPL_SERVICEINFO_DERIVED( UnoControlTabPageContainer, UnoControlBase, szServiceName_UnoControlTabPageContainer ) 139 140 // using UnoControl::getPeer; 141 protected: 142 virtual void updateFromModel(); 143 private: 144 TabPageListenerMultiplexer m_aTabPageListeners; 145 sal_Int16 m_nActiveTabPageId; 146 }; 147 148 #endif // _TOOLKIT_TABPAGE_CONTAINER_HXX 149