1*b0724fc6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b0724fc6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b0724fc6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b0724fc6SAndrew Rist  * distributed with this work for additional information
6*b0724fc6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b0724fc6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b0724fc6SAndrew Rist  * "License"); you may not use this file except in compliance
9*b0724fc6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b0724fc6SAndrew Rist  *
11*b0724fc6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b0724fc6SAndrew Rist  *
13*b0724fc6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b0724fc6SAndrew Rist  * software distributed under the License is distributed on an
15*b0724fc6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b0724fc6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b0724fc6SAndrew Rist  * specific language governing permissions and limitations
18*b0724fc6SAndrew Rist  * under the License.
19*b0724fc6SAndrew Rist  *
20*b0724fc6SAndrew Rist  *************************************************************/
21*b0724fc6SAndrew Rist 
22*b0724fc6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_toolkit.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <toolkit/controls/geometrycontrolmodel.hxx>
28cdf0e10cSrcweir #include <toolkit/controls/tabpagecontainer.hxx>
29cdf0e10cSrcweir #include <toolkit/controls/tabpagemodel.hxx>
30cdf0e10cSrcweir #include <toolkit/helper/property.hxx>
31cdf0e10cSrcweir #include <toolkit/helper/unopropertyarrayhelper.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <com/sun/star/awt/XControlModel.hpp>
34cdf0e10cSrcweir #include <com/sun/star/awt/XVclWindowPeer.hpp>
35cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
38cdf0e10cSrcweir #include <osl/diagnose.h>
39cdf0e10cSrcweir #include <tools/diagnose_ex.h>
40cdf0e10cSrcweir #include <vcl/svapp.hxx>
41cdf0e10cSrcweir #include <vos/mutex.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir using ::rtl::OUString;
44cdf0e10cSrcweir using namespace ::com::sun::star;
45cdf0e10cSrcweir using namespace ::com::sun::star::uno;
46cdf0e10cSrcweir using namespace ::com::sun::star::lang;
47cdf0e10cSrcweir using namespace ::com::sun::star::beans;
48cdf0e10cSrcweir using namespace ::com::sun::star::container;
49cdf0e10cSrcweir using namespace ::com::sun::star::view;
50cdf0e10cSrcweir using ::com::sun::star::awt::tab::XTabPageModel;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #define WRONG_TYPE_EXCEPTION "Type must be ::com::sun::star::awt::tab::XTabPageModel!"
53cdf0e10cSrcweir //	----------------------------------------------------
54cdf0e10cSrcweir //	class UnoControlTabPageContainerModel
55cdf0e10cSrcweir //	----------------------------------------------------
UnoControlTabPageContainerModel(const Reference<XMultiServiceFactory> & i_factory)56cdf0e10cSrcweir UnoControlTabPageContainerModel::UnoControlTabPageContainerModel( const Reference< XMultiServiceFactory >& i_factory )
57cdf0e10cSrcweir     :UnoControlTabPageContainerModel_Base( i_factory )
58cdf0e10cSrcweir     ,maContainerListeners( *this )
59cdf0e10cSrcweir {
60cdf0e10cSrcweir     ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
61cdf0e10cSrcweir     ImplRegisterProperty( BASEPROPERTY_BORDER );
62cdf0e10cSrcweir     ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
63cdf0e10cSrcweir     ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
64cdf0e10cSrcweir     ImplRegisterProperty( BASEPROPERTY_ENABLED );
65cdf0e10cSrcweir     ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
66cdf0e10cSrcweir     ImplRegisterProperty( BASEPROPERTY_HELPURL );
67cdf0e10cSrcweir     ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
68cdf0e10cSrcweir     ImplRegisterProperty( BASEPROPERTY_TEXT );
69cdf0e10cSrcweir }
70cdf0e10cSrcweir 
getServiceName()71cdf0e10cSrcweir ::rtl::OUString UnoControlTabPageContainerModel::getServiceName() throw(RuntimeException)
72cdf0e10cSrcweir {
73cdf0e10cSrcweir     return ::rtl::OUString::createFromAscii( szServiceName_UnoControlTabPageContainerModel );
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
ImplGetDefaultValue(sal_uInt16 nPropId) const76cdf0e10cSrcweir uno::Any UnoControlTabPageContainerModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
77cdf0e10cSrcweir {
78cdf0e10cSrcweir     switch(nPropId)
79cdf0e10cSrcweir     {
80cdf0e10cSrcweir         case BASEPROPERTY_DEFAULTCONTROL:
81cdf0e10cSrcweir             return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlTabPageContainer ) );
82cdf0e10cSrcweir         case BASEPROPERTY_BORDER:
83cdf0e10cSrcweir             return uno::makeAny((sal_Int16) 0);              // No Border
84cdf0e10cSrcweir         default:
85cdf0e10cSrcweir             return UnoControlModel::ImplGetDefaultValue( nPropId );
86cdf0e10cSrcweir     }
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
getInfoHelper()89cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& UnoControlTabPageContainerModel::getInfoHelper()
90cdf0e10cSrcweir {
91cdf0e10cSrcweir     static UnoPropertyArrayHelper* pHelper = NULL;
92cdf0e10cSrcweir     if ( !pHelper )
93cdf0e10cSrcweir     {
94cdf0e10cSrcweir         com::sun::star::uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
95cdf0e10cSrcweir         pHelper = new UnoPropertyArrayHelper( aIDs );
96cdf0e10cSrcweir     }
97cdf0e10cSrcweir     return *pHelper;
98cdf0e10cSrcweir }
getPropertySetInfo()99cdf0e10cSrcweir Reference< ::com::sun::star::beans::XPropertySetInfo > UnoControlTabPageContainerModel::getPropertySetInfo(  ) throw(RuntimeException)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     static Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
102cdf0e10cSrcweir     return xInfo;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir namespace
106cdf0e10cSrcweir {
lcl_createTabPageModel(::comphelper::ComponentContext const & i_context,Sequence<Any> const & i_initArguments,Reference<XPropertySet> const & i_parentModel)107cdf0e10cSrcweir     Reference< XTabPageModel > lcl_createTabPageModel( ::comphelper::ComponentContext const & i_context,
108cdf0e10cSrcweir         Sequence< Any > const & i_initArguments, Reference< XPropertySet > const & i_parentModel )
109cdf0e10cSrcweir     {
110cdf0e10cSrcweir         try
111cdf0e10cSrcweir         {
112cdf0e10cSrcweir             Reference< XPropertySet > const xParentDelegator( i_parentModel, UNO_QUERY_THROW );
113cdf0e10cSrcweir             Reference< XPropertySetInfo > const xPSI( xParentDelegator->getPropertySetInfo() );
114cdf0e10cSrcweir             bool const isGeometryControlModel = xPSI.is() && xPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ) );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir             Reference< XInterface > xInstance;
117cdf0e10cSrcweir             if ( isGeometryControlModel )
118cdf0e10cSrcweir                 xInstance = *( new OGeometryControlModel< UnoControlTabPageModel >( i_context.getLegacyServiceFactory() ) );
119cdf0e10cSrcweir             else
120cdf0e10cSrcweir                 xInstance = *( new UnoControlTabPageModel( i_context.getLegacyServiceFactory() ) );
121cdf0e10cSrcweir 
122cdf0e10cSrcweir             Reference< XTabPageModel > const xTabPageModel( xInstance, UNO_QUERY_THROW );
123cdf0e10cSrcweir             Reference< XInitialization > const xInit( xTabPageModel, UNO_QUERY_THROW );
124cdf0e10cSrcweir             xInit->initialize( i_initArguments );
125cdf0e10cSrcweir 
126cdf0e10cSrcweir             return xTabPageModel;
127cdf0e10cSrcweir         }
128cdf0e10cSrcweir         catch( const RuntimeException& )
129cdf0e10cSrcweir         {
130cdf0e10cSrcweir             throw;
131cdf0e10cSrcweir         }
132cdf0e10cSrcweir         catch( const Exception& )
133cdf0e10cSrcweir         {
134cdf0e10cSrcweir     	    DBG_UNHANDLED_EXCEPTION();
135cdf0e10cSrcweir         }
136cdf0e10cSrcweir         return NULL;
137cdf0e10cSrcweir     }
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
createTabPage(::sal_Int16 i_tabPageID)140cdf0e10cSrcweir Reference< XTabPageModel > SAL_CALL UnoControlTabPageContainerModel::createTabPage( ::sal_Int16 i_tabPageID ) throw (RuntimeException)
141cdf0e10cSrcweir {
142cdf0e10cSrcweir     Sequence< Any > aInitArgs(1);
143cdf0e10cSrcweir     aInitArgs[0] <<= i_tabPageID;
144cdf0e10cSrcweir     return lcl_createTabPageModel( maContext, aInitArgs, this );
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
loadTabPage(::sal_Int16 i_tabPageID,const::rtl::OUString & i_resourceURL)147cdf0e10cSrcweir Reference< XTabPageModel > SAL_CALL UnoControlTabPageContainerModel::loadTabPage( ::sal_Int16 i_tabPageID, const ::rtl::OUString& i_resourceURL ) throw (RuntimeException)
148cdf0e10cSrcweir {
149cdf0e10cSrcweir     Sequence< Any > aInitArgs(2);
150cdf0e10cSrcweir     aInitArgs[0] <<= i_tabPageID;
151cdf0e10cSrcweir     aInitArgs[1] <<= i_resourceURL;
152cdf0e10cSrcweir     return lcl_createTabPageModel( maContext, aInitArgs, this );
153cdf0e10cSrcweir }
154cdf0e10cSrcweir 
insertByIndex(::sal_Int32 nIndex,const com::sun::star::uno::Any & aElement)155cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainerModel::insertByIndex( ::sal_Int32 nIndex, const com::sun::star::uno::Any& aElement) throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException)
156cdf0e10cSrcweir {
157cdf0e10cSrcweir     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
158cdf0e10cSrcweir     uno::Reference < XTabPageModel > xTabPageModel;
159cdf0e10cSrcweir     if(aElement >>= xTabPageModel)
160cdf0e10cSrcweir     {
161cdf0e10cSrcweir         if ( sal_Int32( m_aTabPageVector.size()) ==nIndex )
162cdf0e10cSrcweir             m_aTabPageVector.push_back( xTabPageModel );
163cdf0e10cSrcweir         else if ( sal_Int32( m_aTabPageVector.size()) > nIndex )
164cdf0e10cSrcweir         {
165cdf0e10cSrcweir             std::vector< uno::Reference< XTabPageModel > >::iterator aIter = m_aTabPageVector.begin();
166cdf0e10cSrcweir             aIter += nIndex;
167cdf0e10cSrcweir             m_aTabPageVector.insert( aIter, xTabPageModel );
168cdf0e10cSrcweir         }
169cdf0e10cSrcweir         else
170cdf0e10cSrcweir             throw IndexOutOfBoundsException( ::rtl::OUString(), (OWeakObject *)this );
171cdf0e10cSrcweir         ContainerEvent aEvent;
172cdf0e10cSrcweir         aEvent.Source = *this;
173cdf0e10cSrcweir         aEvent.Element <<= aElement;
174cdf0e10cSrcweir         aEvent.Accessor <<= ::rtl::OUString::valueOf(nIndex);
175cdf0e10cSrcweir         maContainerListeners.elementInserted( aEvent );
176cdf0e10cSrcweir     }
177cdf0e10cSrcweir     else
178cdf0e10cSrcweir         throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( WRONG_TYPE_EXCEPTION )),
179cdf0e10cSrcweir             (OWeakObject *)this, 2 );
180cdf0e10cSrcweir }
181cdf0e10cSrcweir // -----------------------------------------------------------------------------
removeByIndex(::sal_Int32)182cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainerModel::removeByIndex( ::sal_Int32 /*Index*/ ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
183cdf0e10cSrcweir {
184cdf0e10cSrcweir }
185cdf0e10cSrcweir // XIndexReplace
replaceByIndex(::sal_Int32,const uno::Any &)186cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainerModel::replaceByIndex( ::sal_Int32 /*Index*/, const uno::Any& /*Element*/ ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
187cdf0e10cSrcweir {
188cdf0e10cSrcweir }
189cdf0e10cSrcweir // -----------------------------------------------------------------------------
190cdf0e10cSrcweir // XIndexAccess
getCount()191cdf0e10cSrcweir ::sal_Int32 SAL_CALL UnoControlTabPageContainerModel::getCount(  ) throw (uno::RuntimeException)
192cdf0e10cSrcweir {
193cdf0e10cSrcweir     ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
194cdf0e10cSrcweir     return sal_Int32( m_aTabPageVector.size());
195cdf0e10cSrcweir }
196cdf0e10cSrcweir // -----------------------------------------------------------------------------
getByIndex(::sal_Int32 nIndex)197cdf0e10cSrcweir uno::Any SAL_CALL UnoControlTabPageContainerModel::getByIndex( ::sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
198cdf0e10cSrcweir {
199cdf0e10cSrcweir     ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
200cdf0e10cSrcweir     if ( nIndex < 0 || nIndex > sal_Int32(m_aTabPageVector.size()) )
201cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
202cdf0e10cSrcweir     return uno::makeAny(m_aTabPageVector[nIndex]);
203cdf0e10cSrcweir }
204cdf0e10cSrcweir // -----------------------------------------------------------------------------
205cdf0e10cSrcweir // XElementAccess
getElementType()206cdf0e10cSrcweir uno::Type SAL_CALL UnoControlTabPageContainerModel::getElementType(  ) throw (uno::RuntimeException)
207cdf0e10cSrcweir {
208cdf0e10cSrcweir     return ::getCppuType(static_cast<  Reference< com::sun::star::awt::XControlModel>* >(NULL));
209cdf0e10cSrcweir }
210cdf0e10cSrcweir // -----------------------------------------------------------------------------
hasElements()211cdf0e10cSrcweir ::sal_Bool SAL_CALL UnoControlTabPageContainerModel::hasElements(  ) throw (uno::RuntimeException)
212cdf0e10cSrcweir {
213cdf0e10cSrcweir     ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
214cdf0e10cSrcweir     return !m_aTabPageVector.empty();
215cdf0e10cSrcweir }
216cdf0e10cSrcweir // XContainer
addContainerListener(const Reference<XContainerListener> & l)217cdf0e10cSrcweir void UnoControlTabPageContainerModel::addContainerListener( const Reference< XContainerListener >& l ) throw(RuntimeException)
218cdf0e10cSrcweir {
219cdf0e10cSrcweir     maContainerListeners.addInterface( l );
220cdf0e10cSrcweir }
221cdf0e10cSrcweir 
removeContainerListener(const Reference<XContainerListener> & l)222cdf0e10cSrcweir void UnoControlTabPageContainerModel::removeContainerListener( const Reference< XContainerListener >& l ) throw(RuntimeException)
223cdf0e10cSrcweir {
224cdf0e10cSrcweir     maContainerListeners.removeInterface( l );
225cdf0e10cSrcweir }
226cdf0e10cSrcweir 
227cdf0e10cSrcweir //	----------------------------------------------------
228cdf0e10cSrcweir //	class UnoControlTabPageContainer
229cdf0e10cSrcweir //	----------------------------------------------------
UnoControlTabPageContainer(const Reference<XMultiServiceFactory> & i_factory)230cdf0e10cSrcweir UnoControlTabPageContainer::UnoControlTabPageContainer( const Reference< XMultiServiceFactory >& i_factory )
231cdf0e10cSrcweir     :UnoControlTabPageContainer_Base( i_factory )
232cdf0e10cSrcweir     ,m_aTabPageListeners( *this )
233cdf0e10cSrcweir {
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
GetComponentServiceName()236cdf0e10cSrcweir OUString UnoControlTabPageContainer::GetComponentServiceName()
237cdf0e10cSrcweir {
238cdf0e10cSrcweir     return OUString::createFromAscii( "TabPageContainer" );
239cdf0e10cSrcweir }
240cdf0e10cSrcweir 
dispose()241cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainer::dispose(  ) throw(RuntimeException)
242cdf0e10cSrcweir {
243cdf0e10cSrcweir     lang::EventObject aEvt;
244cdf0e10cSrcweir     aEvt.Source = (::cppu::OWeakObject*)this;
245cdf0e10cSrcweir     m_aTabPageListeners.disposeAndClear( aEvt );
246cdf0e10cSrcweir     UnoControl::dispose();
247cdf0e10cSrcweir }
248cdf0e10cSrcweir 
createPeer(const uno::Reference<awt::XToolkit> & rxToolkit,const uno::Reference<awt::XWindowPeer> & rParentPeer)249cdf0e10cSrcweir void UnoControlTabPageContainer::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
250cdf0e10cSrcweir {
251cdf0e10cSrcweir     UnoControlBase::createPeer( rxToolkit, rParentPeer );
252cdf0e10cSrcweir 
253cdf0e10cSrcweir     Reference< XTabPageContainer >  xTPContainer( getPeer(), UNO_QUERY_THROW );
254cdf0e10cSrcweir     if ( m_aTabPageListeners.getLength() )
255cdf0e10cSrcweir         xTPContainer->addTabPageContainerListener(&m_aTabPageListeners);
256cdf0e10cSrcweir }
257cdf0e10cSrcweir 
258cdf0e10cSrcweir // -------------------------------------------------------------------
259cdf0e10cSrcweir // XTabPageContainer
260cdf0e10cSrcweir 
getActiveTabPageID()261cdf0e10cSrcweir ::sal_Int16 SAL_CALL UnoControlTabPageContainer::getActiveTabPageID() throw (RuntimeException)
262cdf0e10cSrcweir {
263cdf0e10cSrcweir     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
264cdf0e10cSrcweir     Reference< XTabPageContainer >  xTPContainer( getPeer(), UNO_QUERY_THROW );
265cdf0e10cSrcweir     return xTPContainer->getActiveTabPageID();
266cdf0e10cSrcweir }
setActiveTabPageID(::sal_Int16 _activetabpageid)267cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainer::setActiveTabPageID( ::sal_Int16 _activetabpageid ) throw (RuntimeException)
268cdf0e10cSrcweir {
269cdf0e10cSrcweir     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
270cdf0e10cSrcweir     Reference< XTabPageContainer >  xTPContainer( getPeer(), UNO_QUERY_THROW );
271cdf0e10cSrcweir     xTPContainer->setActiveTabPageID(_activetabpageid);
272cdf0e10cSrcweir }
getTabPageCount()273cdf0e10cSrcweir ::sal_Int16 SAL_CALL UnoControlTabPageContainer::getTabPageCount(  ) throw (RuntimeException)
274cdf0e10cSrcweir {
275cdf0e10cSrcweir     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
276cdf0e10cSrcweir     Reference< XTabPageContainer >  xTPContainer( getPeer(), UNO_QUERY_THROW );
277cdf0e10cSrcweir     return xTPContainer->getTabPageCount();
278cdf0e10cSrcweir }
isTabPageActive(::sal_Int16 tabPageIndex)279cdf0e10cSrcweir ::sal_Bool SAL_CALL UnoControlTabPageContainer::isTabPageActive( ::sal_Int16 tabPageIndex ) throw (RuntimeException)
280cdf0e10cSrcweir {
281cdf0e10cSrcweir     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
282cdf0e10cSrcweir     Reference< XTabPageContainer >  xTPContainer( getPeer(), UNO_QUERY_THROW );
283cdf0e10cSrcweir     return xTPContainer->isTabPageActive(tabPageIndex);
284cdf0e10cSrcweir }
getTabPage(::sal_Int16 tabPageIndex)285cdf0e10cSrcweir Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL UnoControlTabPageContainer::getTabPage( ::sal_Int16 tabPageIndex ) throw (RuntimeException)
286cdf0e10cSrcweir {
287cdf0e10cSrcweir     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
288cdf0e10cSrcweir     Reference< XTabPageContainer >  xTPContainer( getPeer(), UNO_QUERY_THROW );
289cdf0e10cSrcweir     return xTPContainer->getTabPage(tabPageIndex);
290cdf0e10cSrcweir }
getTabPageByID(::sal_Int16 tabPageID)291cdf0e10cSrcweir Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL UnoControlTabPageContainer::getTabPageByID( ::sal_Int16 tabPageID ) throw (RuntimeException)
292cdf0e10cSrcweir {
293cdf0e10cSrcweir     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
294cdf0e10cSrcweir     Reference< XTabPageContainer >  xTPContainer( getPeer(), UNO_QUERY_THROW );
295cdf0e10cSrcweir     return xTPContainer->getTabPageByID(tabPageID);
296cdf0e10cSrcweir }
addTabPageContainerListener(const Reference<::com::sun::star::awt::tab::XTabPageContainerListener> & listener)297cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainer::addTabPageContainerListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException)
298cdf0e10cSrcweir {
299cdf0e10cSrcweir     m_aTabPageListeners.addInterface( listener );
300cdf0e10cSrcweir     if( getPeer().is() && m_aTabPageListeners.getLength() == 1 )
301cdf0e10cSrcweir     {
302cdf0e10cSrcweir         uno::Reference < awt::tab::XTabPageContainer >  xTabPageContainer( getPeer(), uno::UNO_QUERY );
303cdf0e10cSrcweir         xTabPageContainer->addTabPageContainerListener( &m_aTabPageListeners );
304cdf0e10cSrcweir     }
305cdf0e10cSrcweir }
removeTabPageContainerListener(const Reference<::com::sun::star::awt::tab::XTabPageContainerListener> & listener)306cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainer::removeTabPageContainerListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException)
307cdf0e10cSrcweir {
308cdf0e10cSrcweir     if( getPeer().is() && m_aTabPageListeners.getLength() == 1 )
309cdf0e10cSrcweir     {
310cdf0e10cSrcweir         uno::Reference < awt::tab::XTabPageContainer >  xTabPageContainer( getPeer(), uno::UNO_QUERY );
311cdf0e10cSrcweir         xTabPageContainer->addTabPageContainerListener( &m_aTabPageListeners );
312cdf0e10cSrcweir     }
313cdf0e10cSrcweir     m_aTabPageListeners.removeInterface( listener );
314cdf0e10cSrcweir }
315cdf0e10cSrcweir 
updateFromModel()316cdf0e10cSrcweir void UnoControlTabPageContainer::updateFromModel()
317cdf0e10cSrcweir {
318cdf0e10cSrcweir     UnoControlTabPageContainer_Base::updateFromModel();
319cdf0e10cSrcweir     Reference< XContainerListener > xContainerListener( getPeer(), UNO_QUERY );
320cdf0e10cSrcweir     ENSURE_OR_RETURN_VOID( xContainerListener.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
321cdf0e10cSrcweir 
322cdf0e10cSrcweir     ContainerEvent aEvent;
323cdf0e10cSrcweir     aEvent.Source = getModel();
324cdf0e10cSrcweir     Sequence< Reference< XControl > > aControls = getControls();
325cdf0e10cSrcweir     const Reference< XControl >* pCtrls = aControls.getConstArray();
326cdf0e10cSrcweir     const Reference< XControl >* pCtrlsEnd = pCtrls + aControls.getLength();
327cdf0e10cSrcweir 
328cdf0e10cSrcweir     for ( ; pCtrls < pCtrlsEnd; ++pCtrls )
329cdf0e10cSrcweir     {
330cdf0e10cSrcweir         aEvent.Element <<= *pCtrls;
331cdf0e10cSrcweir         xContainerListener->elementInserted( aEvent );
332cdf0e10cSrcweir     }
333cdf0e10cSrcweir }
addControl(const::rtl::OUString & Name,const Reference<::com::sun::star::awt::XControl> & Control)334cdf0e10cSrcweir void SAL_CALL UnoControlTabPageContainer::addControl( const ::rtl::OUString& Name, const Reference< ::com::sun::star::awt::XControl >& Control ) throw (RuntimeException)
335cdf0e10cSrcweir {
336cdf0e10cSrcweir     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
337cdf0e10cSrcweir     ControlContainerBase::addControl(Name,Control);
338cdf0e10cSrcweir     Reference< XContainerListener > xContainerListener( getPeer(), UNO_QUERY );
339cdf0e10cSrcweir     ContainerEvent aEvent;
340cdf0e10cSrcweir     aEvent.Source = getModel();
341cdf0e10cSrcweir     aEvent.Element <<= Control;
342cdf0e10cSrcweir     xContainerListener->elementInserted( aEvent );
343cdf0e10cSrcweir }
344cdf0e10cSrcweir 
345