1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef TOOLKIT_TABPAGE_CONTAINER_HXX 25 #define TOOLKIT_TABPAGE_CONTAINER_HXX 26 27 #include <com/sun/star/awt/tab/XTabPageContainer.hpp> 28 #include <com/sun/star/awt/tab/XTabPageContainerModel.hpp> 29 #include <com/sun/star/awt/tab/XTabPageContainerListener.hpp> 30 #include <com/sun/star/awt/tab/XTabPage.hpp> 31 #include <com/sun/star/awt/tab/XTabPageModel.hpp> 32 #include <toolkit/controls/unocontrolbase.hxx> 33 #include <toolkit/controls/unocontrolmodel.hxx> 34 #include <toolkit/helper/servicenames.hxx> 35 #include <cppuhelper/implbase1.hxx> 36 #include <comphelper/sequence.hxx> 37 #include <toolkit/controls/controlmodelcontainerbase.hxx> 38 #include <toolkit/controls/unocontrolmodel.hxx> 39 #include <toolkit/helper/listenermultiplexer.hxx> 40 41 using namespace ::com::sun::star::uno; 42 //using namespace ::com::sun::star::awt; 43 using namespace ::com::sun::star::lang; 44 using namespace ::com::sun::star::beans; 45 using namespace ::com::sun::star::container; 46 47 // ------------------------------------------------------------------ 48 // class ::com::sun::star::awt::tab::UnoControlTabPageContainerModel 49 // ------------------------------------------------------------------ 50 typedef ::cppu::AggImplInheritanceHelper1 < UnoControlModel 51 , ::com::sun::star::awt::tab::XTabPageContainerModel 52 > UnoControlTabPageContainerModel_Base; 53 class UnoControlTabPageContainerModel : public UnoControlTabPageContainerModel_Base 54 { 55 private: 56 std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageModel > > m_aTabPageVector; 57 ContainerListenerMultiplexer maContainerListeners; 58 protected: 59 ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; 60 ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 61 // ::com::sun::star::beans::XMultiPropertySet 62 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ); 63 64 public: 65 UnoControlTabPageContainerModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlTabPageContainerModel(const UnoControlTabPageContainerModel & rModel)66 UnoControlTabPageContainerModel( const UnoControlTabPageContainerModel& rModel ) : UnoControlTabPageContainerModel_Base( rModel ),maContainerListeners( *this ) {;} 67 Clone() const68 UnoControlModel* Clone() const { return new UnoControlTabPageContainerModel( *this ); } 69 70 // ::com::sun::star::io::XPersistObject 71 ::rtl::OUString SAL_CALL getServiceName(); 72 73 // ::com::sun::star::lang::XServiceInfo 74 DECLIMPL_SERVICEINFO_DERIVED( UnoControlTabPageContainerModel, UnoControlModel, szServiceName_UnoControlTabPageContainerModel ) 75 76 // XTabPageContainerModel 77 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageModel > SAL_CALL createTabPage( ::sal_Int16 TabPageID ); 78 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageModel > SAL_CALL loadTabPage( ::sal_Int16 TabPageID, const ::rtl::OUString& ResourceURL ); 79 80 // XIndexContainer 81 virtual void SAL_CALL insertByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ); 82 virtual void SAL_CALL removeByIndex( sal_Int32 Index ); 83 84 // XIndexReplace 85 virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ); 86 87 // XIndexAccess 88 virtual sal_Int32 SAL_CALL getCount(); 89 90 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ); 91 92 // XElementAccess 93 virtual ::com::sun::star::uno::Type SAL_CALL getElementType(); 94 virtual sal_Bool SAL_CALL hasElements(); 95 96 // ::com::sun::star::container::XContainer 97 void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ); 98 void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ); 99 }; 100 // =================================================================== 101 // = UnoControlTabPageContainer 102 // =================================================================== 103 typedef ::cppu::AggImplInheritanceHelper1 < ControlContainerBase 104 , ::com::sun::star::awt::tab::XTabPageContainer 105 > UnoControlTabPageContainer_Base; 106 class UnoControlTabPageContainer : public UnoControlTabPageContainer_Base 107 { 108 public: 109 UnoControlTabPageContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); 110 ::rtl::OUString GetComponentServiceName(); 111 112 // ::com::sun::star::lang::XComponent 113 void SAL_CALL dispose( ); 114 115 // ::com::sun::star::awt::XControl 116 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 ); 117 118 // ::com::sun::star::awt::tab::XTabPageContainer 119 virtual ::sal_Int16 SAL_CALL getActiveTabPageID(); 120 virtual void SAL_CALL setActiveTabPageID( ::sal_Int16 _activetabpageid ); 121 virtual ::sal_Int16 SAL_CALL getTabPageCount( ); 122 virtual ::sal_Bool SAL_CALL isTabPageActive( ::sal_Int16 tabPageIndex ); 123 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL getTabPage( ::sal_Int16 tabPageIndex ); 124 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL getTabPageByID( ::sal_Int16 tabPageID ); 125 virtual void SAL_CALL addTabPageContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ); 126 virtual void SAL_CALL removeTabPageContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ); 127 128 virtual void SAL_CALL addControl( const ::rtl::OUString& Name, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& Control ); 129 // ::com::sun::star::lang::XServiceInfo 130 DECLIMPL_SERVICEINFO_DERIVED( UnoControlTabPageContainer, UnoControlBase, szServiceName_UnoControlTabPageContainer ) 131 132 // using UnoControl::getPeer; 133 protected: 134 virtual void updateFromModel(); 135 private: 136 TabPageListenerMultiplexer m_aTabPageListeners; 137 sal_Int16 m_nActiveTabPageId; 138 }; 139 140 #endif // _TOOLKIT_TABPAGE_CONTAINER_HXX 141