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 
28cdf0e10cSrcweir #include <com/sun/star/awt/XVclContainerPeer.hpp>
29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyChangeListener.hpp>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
32cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
33cdf0e10cSrcweir #include <rtl/memory.h>
34cdf0e10cSrcweir #include <rtl/uuid.h>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <toolkit/controls/unocontrolcontainer.hxx>
37cdf0e10cSrcweir #include <toolkit/helper/property.hxx>
38cdf0e10cSrcweir #include <toolkit/helper/servicenames.hxx>
39cdf0e10cSrcweir #include <comphelper/sequence.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <tools/debug.hxx>
42cdf0e10cSrcweir #include <tools/list.hxx>
43cdf0e10cSrcweir #include <vcl/svapp.hxx>
44cdf0e10cSrcweir #include <vcl/window.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #include <limits>
47cdf0e10cSrcweir #include <map>
48cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir using namespace ::com::sun::star;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir extern WorkWindow* lcl_GetDefaultWindow();
53cdf0e10cSrcweir 
54cdf0e10cSrcweir //	----------------------------------------------------
55cdf0e10cSrcweir //	class UnoControlHolder
56cdf0e10cSrcweir //	----------------------------------------------------
57cdf0e10cSrcweir struct UnoControlHolder
58cdf0e10cSrcweir {
59cdf0e10cSrcweir 	uno::Reference< awt::XControl > mxControl;
60cdf0e10cSrcweir 	::rtl::OUString                 msName;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir public:
UnoControlHolderUnoControlHolder63cdf0e10cSrcweir 	UnoControlHolder( const ::rtl::OUString& rName, const uno::Reference< awt::XControl > & rControl )
64cdf0e10cSrcweir 	:	mxControl( rControl ),
65cdf0e10cSrcweir 		msName( rName )
66cdf0e10cSrcweir 	{
67cdf0e10cSrcweir 	}
68cdf0e10cSrcweir 
getNameUnoControlHolder69cdf0e10cSrcweir     inline const ::rtl::OUString&                   getName() const { return msName; }
getControlUnoControlHolder70cdf0e10cSrcweir     inline const uno::Reference< awt::XControl >&   getControl() const { return mxControl; }
71cdf0e10cSrcweir };
72cdf0e10cSrcweir 
73cdf0e10cSrcweir //DECLARE_LIST( UnoControlHolderList, UnoControlHolder* );
74cdf0e10cSrcweir 
75cdf0e10cSrcweir class UnoControlHolderList
76cdf0e10cSrcweir {
77cdf0e10cSrcweir public:
78cdf0e10cSrcweir     typedef sal_Int32                                       ControlIdentifier;
79cdf0e10cSrcweir private:
80cdf0e10cSrcweir     typedef ::boost::shared_ptr< UnoControlHolder >         ControlInfo;
81cdf0e10cSrcweir     typedef ::std::map< ControlIdentifier, ControlInfo >    ControlMap;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir private:
84cdf0e10cSrcweir     ControlMap  maControls;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir public:
87cdf0e10cSrcweir     UnoControlHolderList();
88cdf0e10cSrcweir     ~UnoControlHolderList();
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     /** adds a control with the given name to the list
91cdf0e10cSrcweir         @param _rxControl
92cdf0e10cSrcweir             the control to add. Must not be <NULL/>
93cdf0e10cSrcweir         @param _pBName
94cdf0e10cSrcweir             the name of the control, or <NULL/> if an automatic name should be generated
95cdf0e10cSrcweir         @return
96cdf0e10cSrcweir             the identifier of the newly added control
97cdf0e10cSrcweir     */
98cdf0e10cSrcweir     ControlIdentifier   addControl( const uno::Reference< awt::XControl >& _rxControl, const ::rtl::OUString* _pName );
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     /** returns the number of controls in the list
101cdf0e10cSrcweir     */
size() const102cdf0e10cSrcweir     inline size_t       size() const { return maControls.size(); }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     /** determines whether or not the list is empty
105cdf0e10cSrcweir     */
empty() const106cdf0e10cSrcweir     inline bool         empty() const { return maControls.empty(); }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     /** retrieves all controls currently in the list
109cdf0e10cSrcweir         @return
110cdf0e10cSrcweir             the number of controls in the list
111cdf0e10cSrcweir     */
112cdf0e10cSrcweir     size_t  getControls( uno::Sequence< uno::Reference< awt::XControl > >& _out_rControls ) const;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     /** retrieves all identifiers of all controls currently in the list
115cdf0e10cSrcweir         @return
116cdf0e10cSrcweir             the number of controls in the list
117cdf0e10cSrcweir     */
118cdf0e10cSrcweir     size_t  getIdentifiers( uno::Sequence< sal_Int32 >& _out_rIdentifiers ) const;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     /** returns the first control which is registered under the given name
121cdf0e10cSrcweir     */
122cdf0e10cSrcweir     uno::Reference< awt::XControl >
123cdf0e10cSrcweir             getControlForName( const ::rtl::OUString& _rName ) const;
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     /** returns the identifier which a control is registered for, or -1 if the control
126cdf0e10cSrcweir             isn't registered
127cdf0e10cSrcweir     */
128cdf0e10cSrcweir     ControlIdentifier
129cdf0e10cSrcweir             getControlIdentifier( const uno::Reference< awt::XControl >& _rxControl );
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     /** retrieves the control for a given id
132cdf0e10cSrcweir         @param _nIdentifier
133cdf0e10cSrcweir             the identifier for the control
134cdf0e10cSrcweir         @param _out_rxControl
135cdf0e10cSrcweir             takes the XControl upon successful return
136cdf0e10cSrcweir         @return
137cdf0e10cSrcweir             <TRUE/> if and only if a control with the given id is part of the list
138cdf0e10cSrcweir     */
139cdf0e10cSrcweir     bool    getControlForIdentifier( ControlIdentifier _nIdentifier, uno::Reference< awt::XControl >& _out_rxControl ) const;
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     /** removes a control from the list, given by id
142cdf0e10cSrcweir         @param _nId
143cdf0e10cSrcweir             The identifier of the control to remove.
144cdf0e10cSrcweir     */
145cdf0e10cSrcweir     void    removeControlById( ControlIdentifier _nId );
146cdf0e10cSrcweir 
147cdf0e10cSrcweir     /** replaces a control from the list with another one
148cdf0e10cSrcweir         @param _nId
149cdf0e10cSrcweir             The identifier of the control to replace
150cdf0e10cSrcweir         @param _rxNewControl
151cdf0e10cSrcweir             the new control to put into the list
152cdf0e10cSrcweir     */
153cdf0e10cSrcweir     void    replaceControlById( ControlIdentifier _nId, const uno::Reference< awt::XControl >& _rxNewControl );
154cdf0e10cSrcweir 
155cdf0e10cSrcweir private:
156cdf0e10cSrcweir     /** adds a control
157cdf0e10cSrcweir     @param _rxControl
158cdf0e10cSrcweir         the control to add to the container
159cdf0e10cSrcweir     @param _pName
160cdf0e10cSrcweir         pointer to the name of the control. Might be <NULL/>, in this case, a name is generated.
161cdf0e10cSrcweir     @return
162cdf0e10cSrcweir         the identifier of the newly inserted control
163cdf0e10cSrcweir     */
164cdf0e10cSrcweir     ControlIdentifier impl_addControl(
165cdf0e10cSrcweir         const uno::Reference< awt::XControl >& _rxControl,
166cdf0e10cSrcweir         const ::rtl::OUString*  _pName
167cdf0e10cSrcweir     );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir     /** finds a free identifier
170cdf0e10cSrcweir         @throw uno::RuntimeException
171cdf0e10cSrcweir             if no free identifier can be found
172cdf0e10cSrcweir     */
173cdf0e10cSrcweir     ControlIdentifier impl_getFreeIdentifier_throw();
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     /** finds a free name
176cdf0e10cSrcweir         @throw uno::RuntimeException
177cdf0e10cSrcweir             if no free name can be found
178cdf0e10cSrcweir     */
179cdf0e10cSrcweir     ::rtl::OUString impl_getFreeName_throw();
180cdf0e10cSrcweir };
181cdf0e10cSrcweir 
182cdf0e10cSrcweir //------------------------------------------------------------------------
UnoControlHolderList()183cdf0e10cSrcweir UnoControlHolderList::UnoControlHolderList()
184cdf0e10cSrcweir {
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir //------------------------------------------------------------------------
~UnoControlHolderList()188cdf0e10cSrcweir UnoControlHolderList::~UnoControlHolderList()
189cdf0e10cSrcweir {
190cdf0e10cSrcweir }
191cdf0e10cSrcweir 
192cdf0e10cSrcweir //------------------------------------------------------------------------
addControl(const uno::Reference<awt::XControl> & _rxControl,const::rtl::OUString * _pName)193cdf0e10cSrcweir UnoControlHolderList::ControlIdentifier UnoControlHolderList::addControl( const uno::Reference< awt::XControl >& _rxControl, const ::rtl::OUString* _pName )
194cdf0e10cSrcweir {
195cdf0e10cSrcweir     return impl_addControl( _rxControl, _pName );
196cdf0e10cSrcweir }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir //------------------------------------------------------------------------
getControls(uno::Sequence<uno::Reference<awt::XControl>> & _out_rControls) const199cdf0e10cSrcweir size_t UnoControlHolderList::getControls( uno::Sequence< uno::Reference< awt::XControl > >& _out_rControls ) const
200cdf0e10cSrcweir {
201cdf0e10cSrcweir     _out_rControls.realloc( maControls.size() );
202cdf0e10cSrcweir     uno::Reference< awt::XControl >* pControls = _out_rControls.getArray();
203cdf0e10cSrcweir     for (   ControlMap::const_iterator loop = maControls.begin();
204cdf0e10cSrcweir             loop != maControls.end();
205cdf0e10cSrcweir             ++loop, ++pControls
206cdf0e10cSrcweir         )
207cdf0e10cSrcweir         *pControls = loop->second->getControl();
208cdf0e10cSrcweir     return maControls.size();
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir //------------------------------------------------------------------------
getIdentifiers(uno::Sequence<sal_Int32> & _out_rIdentifiers) const212cdf0e10cSrcweir size_t UnoControlHolderList::getIdentifiers( uno::Sequence< sal_Int32 >& _out_rIdentifiers ) const
213cdf0e10cSrcweir {
214cdf0e10cSrcweir     _out_rIdentifiers.realloc( maControls.size() );
215cdf0e10cSrcweir     sal_Int32* pIndentifiers = _out_rIdentifiers.getArray();
216cdf0e10cSrcweir     for (   ControlMap::const_iterator loop = maControls.begin();
217cdf0e10cSrcweir             loop != maControls.end();
218cdf0e10cSrcweir             ++loop, ++pIndentifiers
219cdf0e10cSrcweir         )
220cdf0e10cSrcweir         *pIndentifiers = loop->first;
221cdf0e10cSrcweir     return maControls.size();
222cdf0e10cSrcweir }
223cdf0e10cSrcweir 
224cdf0e10cSrcweir //------------------------------------------------------------------------
getControlForName(const::rtl::OUString & _rName) const225cdf0e10cSrcweir uno::Reference< awt::XControl > UnoControlHolderList::getControlForName( const ::rtl::OUString& _rName ) const
226cdf0e10cSrcweir {
227cdf0e10cSrcweir     for (   ControlMap::const_iterator loop = maControls.begin();
228cdf0e10cSrcweir             loop != maControls.end();
229cdf0e10cSrcweir             ++loop
230cdf0e10cSrcweir         )
231cdf0e10cSrcweir         if ( loop->second->getName() == _rName )
232cdf0e10cSrcweir             return loop->second->getControl();
233cdf0e10cSrcweir     return uno::Reference< awt::XControl >();
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
236cdf0e10cSrcweir //------------------------------------------------------------------------
getControlIdentifier(const uno::Reference<awt::XControl> & _rxControl)237cdf0e10cSrcweir UnoControlHolderList::ControlIdentifier UnoControlHolderList::getControlIdentifier( const uno::Reference< awt::XControl >& _rxControl )
238cdf0e10cSrcweir {
239cdf0e10cSrcweir     for (   ControlMap::iterator loop = maControls.begin();
240cdf0e10cSrcweir             loop != maControls.end();
241cdf0e10cSrcweir             ++loop
242cdf0e10cSrcweir         )
243cdf0e10cSrcweir     {
244cdf0e10cSrcweir         if ( loop->second->getControl().get() == _rxControl.get() )
245cdf0e10cSrcweir             return loop->first;
246cdf0e10cSrcweir     }
247cdf0e10cSrcweir     return -1;
248cdf0e10cSrcweir }
249cdf0e10cSrcweir 
250cdf0e10cSrcweir //------------------------------------------------------------------------
getControlForIdentifier(UnoControlHolderList::ControlIdentifier _nIdentifier,uno::Reference<awt::XControl> & _out_rxControl) const251cdf0e10cSrcweir bool UnoControlHolderList::getControlForIdentifier( UnoControlHolderList::ControlIdentifier _nIdentifier, uno::Reference< awt::XControl >& _out_rxControl ) const
252cdf0e10cSrcweir {
253cdf0e10cSrcweir     ControlMap::const_iterator pos = maControls.find( _nIdentifier );
254cdf0e10cSrcweir     if ( pos == maControls.end() )
255cdf0e10cSrcweir         return false;
256cdf0e10cSrcweir     _out_rxControl = pos->second->getControl();
257cdf0e10cSrcweir     return true;
258cdf0e10cSrcweir }
259cdf0e10cSrcweir 
260cdf0e10cSrcweir //------------------------------------------------------------------------
removeControlById(UnoControlHolderList::ControlIdentifier _nId)261cdf0e10cSrcweir void UnoControlHolderList::removeControlById( UnoControlHolderList::ControlIdentifier _nId )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir     ControlMap::iterator pos = maControls.find( _nId );
264cdf0e10cSrcweir     DBG_ASSERT( pos != maControls.end(), "UnoControlHolderList::removeControlById: invalid id!" );
265cdf0e10cSrcweir     if ( pos == maControls.end() )
266cdf0e10cSrcweir         return;
267cdf0e10cSrcweir 
268cdf0e10cSrcweir     maControls.erase( pos );
269cdf0e10cSrcweir }
270cdf0e10cSrcweir 
271cdf0e10cSrcweir //------------------------------------------------------------------------
replaceControlById(ControlIdentifier _nId,const uno::Reference<awt::XControl> & _rxNewControl)272cdf0e10cSrcweir void UnoControlHolderList::replaceControlById( ControlIdentifier _nId, const uno::Reference< awt::XControl >& _rxNewControl )
273cdf0e10cSrcweir {
274cdf0e10cSrcweir     DBG_ASSERT( _rxNewControl.is(), "UnoControlHolderList::replaceControlById: invalid new control!" );
275cdf0e10cSrcweir 
276cdf0e10cSrcweir     ControlMap::iterator pos = maControls.find( _nId );
277cdf0e10cSrcweir     DBG_ASSERT( pos != maControls.end(), "UnoControlHolderList::replaceControlById: invalid id!" );
278cdf0e10cSrcweir     if ( pos == maControls.end() )
279cdf0e10cSrcweir         return;
280cdf0e10cSrcweir 
281cdf0e10cSrcweir     pos->second.reset( new UnoControlHolder( pos->second->getName(), _rxNewControl ) );
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir //------------------------------------------------------------------------
impl_addControl(const uno::Reference<awt::XControl> & _rxControl,const::rtl::OUString * _pName)285cdf0e10cSrcweir UnoControlHolderList::ControlIdentifier UnoControlHolderList::impl_addControl( const uno::Reference< awt::XControl >& _rxControl, const ::rtl::OUString* _pName )
286cdf0e10cSrcweir {
287cdf0e10cSrcweir     DBG_ASSERT( _rxControl.is(), "UnoControlHolderList::impl_addControl: invalid control!" );
288cdf0e10cSrcweir 
289cdf0e10cSrcweir     ::rtl::OUString sName = _pName ? *_pName : impl_getFreeName_throw();
290cdf0e10cSrcweir     sal_Int32 nId = impl_getFreeIdentifier_throw();
291cdf0e10cSrcweir 
292cdf0e10cSrcweir     maControls[ nId ] = ControlInfo( new UnoControlHolder( sName, _rxControl ) );
293cdf0e10cSrcweir     return nId;
294cdf0e10cSrcweir }
295cdf0e10cSrcweir 
296cdf0e10cSrcweir //------------------------------------------------------------------------
impl_getFreeIdentifier_throw()297cdf0e10cSrcweir UnoControlHolderList::ControlIdentifier UnoControlHolderList::impl_getFreeIdentifier_throw()
298cdf0e10cSrcweir {
299cdf0e10cSrcweir     for ( ControlIdentifier candidateId = 0; candidateId < ::std::numeric_limits< ControlIdentifier >::max(); ++candidateId )
300cdf0e10cSrcweir     {
301cdf0e10cSrcweir         ControlMap::const_iterator existent = maControls.find( candidateId );
302cdf0e10cSrcweir         if ( existent == maControls.end() )
303cdf0e10cSrcweir             return candidateId;
304cdf0e10cSrcweir     }
305cdf0e10cSrcweir     throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "out of identifiers" ) ), NULL );
306cdf0e10cSrcweir }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir //------------------------------------------------------------------------
impl_getFreeName_throw()309cdf0e10cSrcweir ::rtl::OUString UnoControlHolderList::impl_getFreeName_throw()
310cdf0e10cSrcweir {
311cdf0e10cSrcweir     ::rtl::OUString name( RTL_CONSTASCII_USTRINGPARAM( "control_" ) );
312cdf0e10cSrcweir     for ( ControlIdentifier candidateId = 0; candidateId < ::std::numeric_limits< ControlIdentifier >::max(); ++candidateId )
313cdf0e10cSrcweir     {
314cdf0e10cSrcweir         ::rtl::OUString candidateName( name + ::rtl::OUString::valueOf( candidateId ) );
315cdf0e10cSrcweir         ControlMap::const_iterator loop = maControls.begin();
316cdf0e10cSrcweir         for ( ; loop != maControls.end(); ++loop )
317cdf0e10cSrcweir         {
318cdf0e10cSrcweir             if ( loop->second->getName() == candidateName )
319cdf0e10cSrcweir                 break;
320cdf0e10cSrcweir         }
321cdf0e10cSrcweir         if ( loop == maControls.end() )
322cdf0e10cSrcweir             return candidateName;
323cdf0e10cSrcweir     }
324cdf0e10cSrcweir     throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "out of identifiers" ) ), NULL );
325cdf0e10cSrcweir }
326cdf0e10cSrcweir //	----------------------------------------------------
327cdf0e10cSrcweir //	Function to set the controls' visibility according
328cdf0e10cSrcweir //	to the dialog's "Step" property
329cdf0e10cSrcweir //	----------------------------------------------------
implUpdateVisibility(sal_Int32 nDialogStep,uno::Reference<awt::XControlContainer> xControlContainer)330cdf0e10cSrcweir void implUpdateVisibility
331cdf0e10cSrcweir (
332cdf0e10cSrcweir 	sal_Int32 nDialogStep,
333cdf0e10cSrcweir 	uno::Reference< awt::XControlContainer > xControlContainer
334cdf0e10cSrcweir )
335cdf0e10cSrcweir {
336cdf0e10cSrcweir 	uno::Sequence< uno::Reference< awt::XControl > >
337cdf0e10cSrcweir 		aCtrls = xControlContainer->getControls();
338cdf0e10cSrcweir 	const uno::Reference< awt::XControl >* pCtrls = aCtrls.getConstArray();
339cdf0e10cSrcweir 	sal_uInt32 nCtrls = aCtrls.getLength();
340cdf0e10cSrcweir 	sal_Bool bCompleteVisible = (nDialogStep == 0);
341cdf0e10cSrcweir 	for( sal_uInt32 n = 0; n < nCtrls; n++ )
342cdf0e10cSrcweir 	{
343cdf0e10cSrcweir 		uno::Reference< awt::XControl > xControl = pCtrls[ n ];
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 		sal_Bool bVisible = bCompleteVisible;
346cdf0e10cSrcweir 		if( !bVisible )
347cdf0e10cSrcweir 		{
348cdf0e10cSrcweir 			uno::Reference< awt::XControlModel > xModel( xControl->getModel() );
349cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xPSet
350cdf0e10cSrcweir 				( xModel, uno::UNO_QUERY );
351cdf0e10cSrcweir 			uno::Reference< beans::XPropertySetInfo >
352cdf0e10cSrcweir 				xInfo = xPSet->getPropertySetInfo();
353cdf0e10cSrcweir 			::rtl::OUString aPropName(RTL_CONSTASCII_USTRINGPARAM( "Step" ) );
354cdf0e10cSrcweir 			sal_Int32 nControlStep = 0;
355cdf0e10cSrcweir 			if ( xInfo->hasPropertyByName( aPropName ) )
356cdf0e10cSrcweir 			{
357cdf0e10cSrcweir 				uno::Any aVal = xPSet->getPropertyValue( aPropName );
358cdf0e10cSrcweir 				aVal >>= nControlStep;
359cdf0e10cSrcweir 			}
360cdf0e10cSrcweir 			bVisible = (nControlStep == 0) || (nControlStep == nDialogStep);
361cdf0e10cSrcweir 		}
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 		uno::Reference< awt::XWindow> xWindow
364cdf0e10cSrcweir 			( xControl, uno::UNO_QUERY );
365cdf0e10cSrcweir 		if( xWindow.is() )
366cdf0e10cSrcweir 			xWindow->setVisible( bVisible );
367cdf0e10cSrcweir 	}
368cdf0e10cSrcweir }
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 
371cdf0e10cSrcweir //	----------------------------------------------------
372cdf0e10cSrcweir //	class DialogStepChangedListener
373cdf0e10cSrcweir //	----------------------------------------------------
374cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1< beans::XPropertyChangeListener > PropertyChangeListenerHelper;
375cdf0e10cSrcweir 
376cdf0e10cSrcweir class DialogStepChangedListener: public PropertyChangeListenerHelper
377cdf0e10cSrcweir {
378cdf0e10cSrcweir private:
379cdf0e10cSrcweir 	uno::Reference< awt::XControlContainer > mxControlContainer;
380cdf0e10cSrcweir 
381cdf0e10cSrcweir public:
DialogStepChangedListener(uno::Reference<awt::XControlContainer> xControlContainer)382cdf0e10cSrcweir 	DialogStepChangedListener( uno::Reference< awt::XControlContainer > xControlContainer )
383cdf0e10cSrcweir 		: mxControlContainer( xControlContainer ) {}
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 	// XEventListener
386cdf0e10cSrcweir 	virtual void SAL_CALL disposing( const	lang::EventObject& Source ) throw( uno::RuntimeException);
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 	// XPropertyChangeListener
389cdf0e10cSrcweir 	virtual void SAL_CALL propertyChange( const  beans::PropertyChangeEvent& evt ) throw( uno::RuntimeException);
390cdf0e10cSrcweir 
391cdf0e10cSrcweir };
392cdf0e10cSrcweir 
disposing(const lang::EventObject &)393cdf0e10cSrcweir void SAL_CALL DialogStepChangedListener::disposing( const  lang::EventObject& /*_rSource*/)
394cdf0e10cSrcweir 	throw( uno::RuntimeException)
395cdf0e10cSrcweir {
396cdf0e10cSrcweir 	mxControlContainer.clear();
397cdf0e10cSrcweir }
398cdf0e10cSrcweir 
propertyChange(const beans::PropertyChangeEvent & evt)399cdf0e10cSrcweir void SAL_CALL DialogStepChangedListener::propertyChange( const	beans::PropertyChangeEvent& evt )
400cdf0e10cSrcweir 	throw( uno::RuntimeException)
401cdf0e10cSrcweir {
402cdf0e10cSrcweir 	// evt.PropertyName HAS to be "Step" because we only use the listener for that
403cdf0e10cSrcweir 	sal_Int32 nDialogStep = 0;
404cdf0e10cSrcweir 	evt.NewValue >>= nDialogStep;
405cdf0e10cSrcweir 	implUpdateVisibility( nDialogStep, mxControlContainer );
406cdf0e10cSrcweir }
407cdf0e10cSrcweir 
408cdf0e10cSrcweir //	----------------------------------------------------
409cdf0e10cSrcweir //	class UnoControlContainer
410cdf0e10cSrcweir //	----------------------------------------------------
UnoControlContainer(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & i_factory)411cdf0e10cSrcweir UnoControlContainer::UnoControlContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory )
412cdf0e10cSrcweir     :UnoControlContainer_Base( i_factory )
413cdf0e10cSrcweir     ,maCListeners( *this )
414cdf0e10cSrcweir {
415cdf0e10cSrcweir 	mpControls = new UnoControlHolderList;
416cdf0e10cSrcweir }
417cdf0e10cSrcweir 
UnoControlContainer(const uno::Reference<lang::XMultiServiceFactory> & i_factory,const uno::Reference<awt::XWindowPeer> & xP)418cdf0e10cSrcweir UnoControlContainer::UnoControlContainer( const uno::Reference< lang::XMultiServiceFactory >& i_factory, const uno::Reference< awt::XWindowPeer >& xP )
419cdf0e10cSrcweir 	:UnoControlContainer_Base( i_factory )
420cdf0e10cSrcweir     ,maCListeners( *this )
421cdf0e10cSrcweir {
422cdf0e10cSrcweir 	setPeer( xP );
423cdf0e10cSrcweir 	mbDisposePeer = sal_False;
424cdf0e10cSrcweir 	mpControls = new UnoControlHolderList;
425cdf0e10cSrcweir }
426cdf0e10cSrcweir 
~UnoControlContainer()427cdf0e10cSrcweir UnoControlContainer::~UnoControlContainer()
428cdf0e10cSrcweir {
429cdf0e10cSrcweir     DELETEZ( mpControls );
430cdf0e10cSrcweir }
431cdf0e10cSrcweir 
ImplActivateTabControllers()432cdf0e10cSrcweir void UnoControlContainer::ImplActivateTabControllers()
433cdf0e10cSrcweir {
434cdf0e10cSrcweir 	sal_uInt32 nCount = maTabControllers.getLength();
435cdf0e10cSrcweir 	for ( sal_uInt32 n = 0; n < nCount; n++ )
436cdf0e10cSrcweir 	{
437cdf0e10cSrcweir 		maTabControllers.getArray()[n]->setContainer( this );
438cdf0e10cSrcweir 		maTabControllers.getArray()[n]->activateTabOrder();
439cdf0e10cSrcweir 	}
440cdf0e10cSrcweir }
441cdf0e10cSrcweir 
442cdf0e10cSrcweir // lang::XComponent
dispose()443cdf0e10cSrcweir void UnoControlContainer::dispose(	) throw(uno::RuntimeException)
444cdf0e10cSrcweir {
445cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
446cdf0e10cSrcweir 
447cdf0e10cSrcweir 	lang::EventObject aDisposeEvent;
448cdf0e10cSrcweir 	aDisposeEvent.Source = static_cast< uno::XAggregation* >( this );
449cdf0e10cSrcweir 
450cdf0e10cSrcweir     // DG: zuerst der Welt mitteilen, dass der Container wegfliegt. Dieses ist um einiges
451cdf0e10cSrcweir 	// schneller wenn die Welt sowohl an den Controls als auch am Container horcht
452cdf0e10cSrcweir 	maDisposeListeners.disposeAndClear( aDisposeEvent );
453cdf0e10cSrcweir 	maCListeners.disposeAndClear( aDisposeEvent );
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 	uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls();
457cdf0e10cSrcweir 	uno::Reference< awt::XControl >* pCtrls = aCtrls.getArray();
458cdf0e10cSrcweir 	uno::Reference< awt::XControl >* pCtrlsEnd = pCtrls + aCtrls.getLength();
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 	for( ; pCtrls < pCtrlsEnd; ++pCtrls )
461cdf0e10cSrcweir 	{
462cdf0e10cSrcweir 		removingControl( *pCtrls );
463cdf0e10cSrcweir 		// Control wegwerfen
464cdf0e10cSrcweir 		(*pCtrls)->dispose();
465cdf0e10cSrcweir 	}
466cdf0e10cSrcweir 
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 	// alle Strukturen entfernen
469cdf0e10cSrcweir     DELETEZ( mpControls );
470cdf0e10cSrcweir     mpControls = new UnoControlHolderList;
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 	UnoControlBase::dispose();
473cdf0e10cSrcweir }
474cdf0e10cSrcweir 
475cdf0e10cSrcweir // lang::XEventListener
disposing(const lang::EventObject & _rEvt)476cdf0e10cSrcweir void UnoControlContainer::disposing( const lang::EventObject& _rEvt ) throw(uno::RuntimeException)
477cdf0e10cSrcweir {
478cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
479cdf0e10cSrcweir 
480cdf0e10cSrcweir 	uno::Reference< awt::XControl >  xControl( _rEvt.Source, uno::UNO_QUERY );
481cdf0e10cSrcweir 	if ( xControl.is() )
482cdf0e10cSrcweir 		removeControl( xControl );
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 	UnoControlBase::disposing( _rEvt );
485cdf0e10cSrcweir }
486cdf0e10cSrcweir 
487cdf0e10cSrcweir // container::XContainer
addContainerListener(const uno::Reference<container::XContainerListener> & rxListener)488cdf0e10cSrcweir void UnoControlContainer::addContainerListener( const uno::Reference< container::XContainerListener >& rxListener ) throw(uno::RuntimeException)
489cdf0e10cSrcweir {
490cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
491cdf0e10cSrcweir 
492cdf0e10cSrcweir 	maCListeners.addInterface( rxListener );
493cdf0e10cSrcweir }
494cdf0e10cSrcweir 
removeContainerListener(const uno::Reference<container::XContainerListener> & rxListener)495cdf0e10cSrcweir void UnoControlContainer::removeContainerListener( const uno::Reference< container::XContainerListener >& rxListener ) throw(uno::RuntimeException)
496cdf0e10cSrcweir {
497cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 	maCListeners.removeInterface( rxListener );
500cdf0e10cSrcweir }
501cdf0e10cSrcweir 
502cdf0e10cSrcweir 
insert(const uno::Any & _rElement)503cdf0e10cSrcweir ::sal_Int32 SAL_CALL UnoControlContainer::insert( const uno::Any& _rElement ) throw (lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
504cdf0e10cSrcweir {
505cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
506cdf0e10cSrcweir 
507cdf0e10cSrcweir     uno::Reference< awt::XControl > xControl;
508cdf0e10cSrcweir     if ( !( _rElement >>= xControl ) || !xControl.is() )
509cdf0e10cSrcweir         throw lang::IllegalArgumentException(
510cdf0e10cSrcweir             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Elements must support the XControl interface." ) ),
511cdf0e10cSrcweir             *this,
512cdf0e10cSrcweir             1
513cdf0e10cSrcweir         );
514cdf0e10cSrcweir 
515cdf0e10cSrcweir     return impl_addControl( xControl, NULL );
516cdf0e10cSrcweir }
517cdf0e10cSrcweir 
removeByIdentifier(::sal_Int32 _nIdentifier)518cdf0e10cSrcweir void SAL_CALL UnoControlContainer::removeByIdentifier( ::sal_Int32 _nIdentifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
519cdf0e10cSrcweir {
520cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
521cdf0e10cSrcweir 
522cdf0e10cSrcweir     uno::Reference< awt::XControl > xControl;
523cdf0e10cSrcweir     if ( !mpControls->getControlForIdentifier( _nIdentifier, xControl ) )
524cdf0e10cSrcweir         throw container::NoSuchElementException(
525cdf0e10cSrcweir             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "There is no element with the given identifier." ) ),
526cdf0e10cSrcweir             *this
527cdf0e10cSrcweir         );
528cdf0e10cSrcweir 
529cdf0e10cSrcweir     impl_removeControl( _nIdentifier, xControl, NULL );
530cdf0e10cSrcweir }
531cdf0e10cSrcweir 
replaceByIdentifer(::sal_Int32 _nIdentifier,const uno::Any & _rElement)532cdf0e10cSrcweir void SAL_CALL UnoControlContainer::replaceByIdentifer( ::sal_Int32 _nIdentifier, const uno::Any& _rElement ) throw (lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
533cdf0e10cSrcweir {
534cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
535cdf0e10cSrcweir 
536cdf0e10cSrcweir     uno::Reference< awt::XControl > xExistentControl;
537cdf0e10cSrcweir     if ( !mpControls->getControlForIdentifier( _nIdentifier, xExistentControl ) )
538cdf0e10cSrcweir         throw container::NoSuchElementException(
539cdf0e10cSrcweir             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "There is no element with the given identifier." ) ),
540cdf0e10cSrcweir             *this
541cdf0e10cSrcweir         );
542cdf0e10cSrcweir 
543cdf0e10cSrcweir     uno::Reference< awt::XControl > xNewControl;
544cdf0e10cSrcweir     if ( !( _rElement >>= xNewControl ) )
545cdf0e10cSrcweir         throw lang::IllegalArgumentException(
546cdf0e10cSrcweir             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Elements must support the XControl interface." ) ),
547cdf0e10cSrcweir             *this,
548cdf0e10cSrcweir             1
549cdf0e10cSrcweir         );
550cdf0e10cSrcweir 
551cdf0e10cSrcweir     removingControl( xExistentControl );
552cdf0e10cSrcweir 
553cdf0e10cSrcweir     mpControls->replaceControlById( _nIdentifier, xNewControl );
554cdf0e10cSrcweir 
555cdf0e10cSrcweir     addingControl( xNewControl );
556cdf0e10cSrcweir 
557cdf0e10cSrcweir     impl_createControlPeerIfNecessary( xNewControl );
558cdf0e10cSrcweir 
559cdf0e10cSrcweir     if ( maCListeners.getLength() )
560cdf0e10cSrcweir 	{
561cdf0e10cSrcweir 		container::ContainerEvent aEvent;
562cdf0e10cSrcweir 		aEvent.Source = *this;
563cdf0e10cSrcweir         aEvent.Accessor <<= _nIdentifier;
564cdf0e10cSrcweir 		aEvent.Element <<= xNewControl;
565cdf0e10cSrcweir         aEvent.ReplacedElement <<= xExistentControl;
566cdf0e10cSrcweir 		maCListeners.elementReplaced( aEvent );
567cdf0e10cSrcweir 	}
568cdf0e10cSrcweir }
569cdf0e10cSrcweir 
getByIdentifier(::sal_Int32 _nIdentifier)570cdf0e10cSrcweir uno::Any SAL_CALL UnoControlContainer::getByIdentifier( ::sal_Int32 _nIdentifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
571cdf0e10cSrcweir {
572cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
573cdf0e10cSrcweir 
574cdf0e10cSrcweir     uno::Reference< awt::XControl > xControl;
575cdf0e10cSrcweir     if ( !mpControls->getControlForIdentifier( _nIdentifier, xControl ) )
576cdf0e10cSrcweir         throw container::NoSuchElementException();
577cdf0e10cSrcweir     return uno::makeAny( xControl );
578cdf0e10cSrcweir }
579cdf0e10cSrcweir 
getIdentifiers()580cdf0e10cSrcweir uno::Sequence< ::sal_Int32 > SAL_CALL UnoControlContainer::getIdentifiers(  ) throw (uno::RuntimeException)
581cdf0e10cSrcweir {
582cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
583cdf0e10cSrcweir 
584cdf0e10cSrcweir     uno::Sequence< ::sal_Int32 > aIdentifiers;
585cdf0e10cSrcweir     mpControls->getIdentifiers( aIdentifiers );
586cdf0e10cSrcweir     return aIdentifiers;
587cdf0e10cSrcweir }
588cdf0e10cSrcweir 
589cdf0e10cSrcweir // container::XElementAccess
getElementType()590cdf0e10cSrcweir uno::Type SAL_CALL UnoControlContainer::getElementType(  ) throw (uno::RuntimeException)
591cdf0e10cSrcweir {
592cdf0e10cSrcweir     return awt::XControlModel::static_type();
593cdf0e10cSrcweir }
594cdf0e10cSrcweir 
hasElements()595cdf0e10cSrcweir ::sal_Bool SAL_CALL UnoControlContainer::hasElements(  ) throw (uno::RuntimeException)
596cdf0e10cSrcweir {
597cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
598cdf0e10cSrcweir     return !mpControls->empty();
599cdf0e10cSrcweir }
600cdf0e10cSrcweir 
601cdf0e10cSrcweir // awt::XControlContainer
setStatusText(const::rtl::OUString & rStatusText)602cdf0e10cSrcweir void UnoControlContainer::setStatusText( const ::rtl::OUString& rStatusText ) throw(uno::RuntimeException)
603cdf0e10cSrcweir {
604cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 	// In der Parenthierarchie nach unten gehen
607cdf0e10cSrcweir 	uno::Reference< awt::XControlContainer >  xContainer( mxContext, uno::UNO_QUERY );
608cdf0e10cSrcweir 	if( xContainer.is() )
609cdf0e10cSrcweir 		xContainer->setStatusText( rStatusText );
610cdf0e10cSrcweir }
611cdf0e10cSrcweir 
getControls()612cdf0e10cSrcweir uno::Sequence< uno::Reference< awt::XControl > > UnoControlContainer::getControls(  ) throw(uno::RuntimeException)
613cdf0e10cSrcweir {
614cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
615cdf0e10cSrcweir     uno::Sequence< uno::Reference< awt::XControl > > aControls;
616cdf0e10cSrcweir     mpControls->getControls( aControls );
617cdf0e10cSrcweir     return aControls;
618cdf0e10cSrcweir }
619cdf0e10cSrcweir 
getControl(const::rtl::OUString & rName)620cdf0e10cSrcweir uno::Reference< awt::XControl > UnoControlContainer::getControl( const ::rtl::OUString& rName ) throw(uno::RuntimeException)
621cdf0e10cSrcweir {
622cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
623cdf0e10cSrcweir     return mpControls->getControlForName( rName );
624cdf0e10cSrcweir }
625cdf0e10cSrcweir 
addingControl(const uno::Reference<awt::XControl> & _rxControl)626cdf0e10cSrcweir void UnoControlContainer::addingControl( const uno::Reference< awt::XControl >& _rxControl )
627cdf0e10cSrcweir {
628cdf0e10cSrcweir 	if ( _rxControl.is() )
629cdf0e10cSrcweir 	{
630cdf0e10cSrcweir 		uno::Reference< uno::XInterface > xThis;
631cdf0e10cSrcweir 		OWeakAggObject::queryInterface( ::getCppuType( static_cast< uno::Reference< uno::XInterface >* >( NULL ) ) ) >>= xThis;
632cdf0e10cSrcweir 
633cdf0e10cSrcweir 		_rxControl->setContext( xThis );
634cdf0e10cSrcweir 		_rxControl->addEventListener( this );
635cdf0e10cSrcweir 	}
636cdf0e10cSrcweir }
637cdf0e10cSrcweir 
impl_createControlPeerIfNecessary(const uno::Reference<awt::XControl> & _rxControl)638cdf0e10cSrcweir void UnoControlContainer::impl_createControlPeerIfNecessary( const uno::Reference< awt::XControl >& _rxControl )
639cdf0e10cSrcweir {
640cdf0e10cSrcweir     OSL_PRECOND( _rxControl.is(), "UnoControlContainer::impl_createControlPeerIfNecessary: invalid control, this will crash!" );
641cdf0e10cSrcweir 
642cdf0e10cSrcweir     // if the container already has a peer, then also create a peer for the control
643cdf0e10cSrcweir     uno::Reference< awt::XWindowPeer > xMyPeer( getPeer() );
644cdf0e10cSrcweir 
645cdf0e10cSrcweir     if( xMyPeer.is() )
646cdf0e10cSrcweir 	{
647cdf0e10cSrcweir         _rxControl->createPeer( NULL, xMyPeer );
648cdf0e10cSrcweir 		ImplActivateTabControllers();
649cdf0e10cSrcweir 	}
650cdf0e10cSrcweir 
651cdf0e10cSrcweir }
652cdf0e10cSrcweir 
impl_addControl(const uno::Reference<awt::XControl> & _rxControl,const::rtl::OUString * _pName)653cdf0e10cSrcweir sal_Int32 UnoControlContainer::impl_addControl( const uno::Reference< awt::XControl >& _rxControl, const ::rtl::OUString* _pName )
654cdf0e10cSrcweir {
655cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
656cdf0e10cSrcweir     UnoControlHolderList::ControlIdentifier id = mpControls->addControl( _rxControl, _pName );
657cdf0e10cSrcweir 
658cdf0e10cSrcweir     addingControl( _rxControl );
659cdf0e10cSrcweir 
660cdf0e10cSrcweir     impl_createControlPeerIfNecessary( _rxControl );
661cdf0e10cSrcweir 
662cdf0e10cSrcweir 	if ( maCListeners.getLength() )
663cdf0e10cSrcweir 	{
664cdf0e10cSrcweir 		container::ContainerEvent aEvent;
665cdf0e10cSrcweir 		aEvent.Source = *this;
666cdf0e10cSrcweir         _pName ? ( aEvent.Accessor <<= *_pName ) : ( aEvent.Accessor <<= (sal_Int32)id );
667cdf0e10cSrcweir 		aEvent.Element <<= _rxControl;
668cdf0e10cSrcweir 		maCListeners.elementInserted( aEvent );
669cdf0e10cSrcweir 	}
670cdf0e10cSrcweir 
671cdf0e10cSrcweir     return id;
672cdf0e10cSrcweir }
673cdf0e10cSrcweir 
addControl(const::rtl::OUString & rName,const uno::Reference<awt::XControl> & rControl)674cdf0e10cSrcweir void UnoControlContainer::addControl( const ::rtl::OUString& rName, const uno::Reference< awt::XControl >& rControl ) throw(uno::RuntimeException)
675cdf0e10cSrcweir {
676cdf0e10cSrcweir 	if ( rControl.is() )
677cdf0e10cSrcweir         impl_addControl( rControl, &rName );
678cdf0e10cSrcweir }
679cdf0e10cSrcweir 
removingControl(const uno::Reference<awt::XControl> & _rxControl)680cdf0e10cSrcweir void UnoControlContainer::removingControl( const uno::Reference< awt::XControl >& _rxControl )
681cdf0e10cSrcweir {
682cdf0e10cSrcweir 	if ( _rxControl.is() )
683cdf0e10cSrcweir 	{
684cdf0e10cSrcweir 		_rxControl->removeEventListener( this );
685cdf0e10cSrcweir 		_rxControl->setContext( NULL );
686cdf0e10cSrcweir 	}
687cdf0e10cSrcweir }
688cdf0e10cSrcweir 
impl_removeControl(sal_Int32 _nId,const uno::Reference<awt::XControl> & _rxControl,const::rtl::OUString * _pNameAccessor)689cdf0e10cSrcweir void UnoControlContainer::impl_removeControl( sal_Int32 _nId, const uno::Reference< awt::XControl >& _rxControl, const ::rtl::OUString* _pNameAccessor )
690cdf0e10cSrcweir {
691cdf0e10cSrcweir #ifdef DBG_UTIL
692cdf0e10cSrcweir     {
693cdf0e10cSrcweir         uno::Reference< awt::XControl > xControl;
694cdf0e10cSrcweir         bool bHas = mpControls->getControlForIdentifier( _nId, xControl );
695cdf0e10cSrcweir         DBG_ASSERT( bHas && xControl == _rxControl, "UnoControlContainer::impl_removeControl: inconsistency in the parameters!" );
696cdf0e10cSrcweir     }
697cdf0e10cSrcweir #endif
698cdf0e10cSrcweir 	removingControl( _rxControl );
699cdf0e10cSrcweir 
700cdf0e10cSrcweir     mpControls->removeControlById( _nId );
701cdf0e10cSrcweir 
702cdf0e10cSrcweir     if ( maCListeners.getLength() )
703cdf0e10cSrcweir 	{
704cdf0e10cSrcweir 		container::ContainerEvent aEvent;
705cdf0e10cSrcweir 		aEvent.Source = *this;
706cdf0e10cSrcweir         _pNameAccessor ? ( aEvent.Accessor <<= *_pNameAccessor ) : ( aEvent.Accessor <<= _nId );
707cdf0e10cSrcweir 		aEvent.Element <<= _rxControl;
708cdf0e10cSrcweir 		maCListeners.elementRemoved( aEvent );
709cdf0e10cSrcweir 	}
710cdf0e10cSrcweir }
711cdf0e10cSrcweir 
removeControl(const uno::Reference<awt::XControl> & _rxControl)712cdf0e10cSrcweir void UnoControlContainer::removeControl( const uno::Reference< awt::XControl >& _rxControl ) throw(uno::RuntimeException)
713cdf0e10cSrcweir {
714cdf0e10cSrcweir 	if ( _rxControl.is() )
715cdf0e10cSrcweir 	{
716cdf0e10cSrcweir 		::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
717cdf0e10cSrcweir 
718cdf0e10cSrcweir         UnoControlHolderList::ControlIdentifier id = mpControls->getControlIdentifier( _rxControl );
719cdf0e10cSrcweir         if ( id != -1 )
720cdf0e10cSrcweir             impl_removeControl( id, _rxControl, NULL );
721cdf0e10cSrcweir 	}
722cdf0e10cSrcweir }
723cdf0e10cSrcweir 
724cdf0e10cSrcweir 
725cdf0e10cSrcweir 
726cdf0e10cSrcweir // awt::XUnoControlContainer
setTabControllers(const uno::Sequence<uno::Reference<awt::XTabController>> & TabControllers)727cdf0e10cSrcweir void UnoControlContainer::setTabControllers( const uno::Sequence< uno::Reference< awt::XTabController > >& TabControllers ) throw(uno::RuntimeException)
728cdf0e10cSrcweir {
729cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
730cdf0e10cSrcweir 
731cdf0e10cSrcweir 	maTabControllers = TabControllers;
732cdf0e10cSrcweir }
733cdf0e10cSrcweir 
getTabControllers()734cdf0e10cSrcweir uno::Sequence< uno::Reference< awt::XTabController > > UnoControlContainer::getTabControllers(  ) throw(uno::RuntimeException)
735cdf0e10cSrcweir {
736cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
737cdf0e10cSrcweir 
738cdf0e10cSrcweir 	return maTabControllers;
739cdf0e10cSrcweir }
740cdf0e10cSrcweir 
addTabController(const uno::Reference<awt::XTabController> & TabController)741cdf0e10cSrcweir void UnoControlContainer::addTabController( const uno::Reference< awt::XTabController >& TabController ) throw(uno::RuntimeException)
742cdf0e10cSrcweir {
743cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
744cdf0e10cSrcweir 
745cdf0e10cSrcweir 	sal_uInt32 nCount = maTabControllers.getLength();
746cdf0e10cSrcweir 	maTabControllers.realloc( nCount + 1 );
747cdf0e10cSrcweir 	maTabControllers[ nCount ] = TabController;
748cdf0e10cSrcweir }
749cdf0e10cSrcweir 
removeTabController(const uno::Reference<awt::XTabController> & TabController)750cdf0e10cSrcweir void UnoControlContainer::removeTabController( const uno::Reference< awt::XTabController >& TabController ) throw(uno::RuntimeException)
751cdf0e10cSrcweir {
752cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
753cdf0e10cSrcweir 
754cdf0e10cSrcweir 	sal_uInt32 nCount = maTabControllers.getLength();
755cdf0e10cSrcweir 	const uno::Reference< awt::XTabController >* pLoop = maTabControllers.getConstArray();
756cdf0e10cSrcweir 	for ( sal_uInt32 n = 0; n < nCount; ++n, ++pLoop )
757cdf0e10cSrcweir 	{
758cdf0e10cSrcweir 		if( pLoop->get() == TabController.get() )
759cdf0e10cSrcweir 		{
760cdf0e10cSrcweir 			::comphelper::removeElementAt( maTabControllers, n );
761cdf0e10cSrcweir 			break;
762cdf0e10cSrcweir 		}
763cdf0e10cSrcweir 	}
764cdf0e10cSrcweir }
765cdf0e10cSrcweir 
766cdf0e10cSrcweir // awt::XControl
createPeer(const uno::Reference<awt::XToolkit> & rxToolkit,const uno::Reference<awt::XWindowPeer> & rParent)767cdf0e10cSrcweir void UnoControlContainer::createPeer( const uno::Reference< awt::XToolkit >& rxToolkit, const uno::Reference< awt::XWindowPeer >& rParent ) throw(uno::RuntimeException)
768cdf0e10cSrcweir {
769cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
770cdf0e10cSrcweir 
771cdf0e10cSrcweir 	if( !getPeer().is() )
772cdf0e10cSrcweir 	{
773cdf0e10cSrcweir 		sal_Bool bVis = maComponentInfos.bVisible;
774cdf0e10cSrcweir 		if( bVis )
775cdf0e10cSrcweir 			UnoControl::setVisible( sal_False );
776cdf0e10cSrcweir 		// eigenes Peer erzeugen
777cdf0e10cSrcweir 		UnoControl::createPeer( rxToolkit, rParent );
778cdf0e10cSrcweir 
779cdf0e10cSrcweir 		// alle Peers der Childs erzeugen
780cdf0e10cSrcweir 		if ( !mbCreatingCompatiblePeer )
781cdf0e10cSrcweir 		{
782cdf0e10cSrcweir 			// Evaluate "Step" property
783cdf0e10cSrcweir 			uno::Reference< awt::XControlModel > xModel( getModel() );
784cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xPSet
785cdf0e10cSrcweir 				( xModel, uno::UNO_QUERY );
786cdf0e10cSrcweir 			uno::Reference< beans::XPropertySetInfo >
787cdf0e10cSrcweir 				xInfo = xPSet->getPropertySetInfo();
788cdf0e10cSrcweir 			::rtl::OUString aPropName(RTL_CONSTASCII_USTRINGPARAM( "Step" ) );
789cdf0e10cSrcweir 			if ( xInfo->hasPropertyByName( aPropName ) )
790cdf0e10cSrcweir 			{
791cdf0e10cSrcweir 				::com::sun::star::uno::Any aVal = xPSet->getPropertyValue( aPropName );
792cdf0e10cSrcweir 				sal_Int32 nDialogStep = 0;
793cdf0e10cSrcweir 				aVal >>= nDialogStep;
794cdf0e10cSrcweir 				uno::Reference< awt::XControlContainer > xContainer =
795cdf0e10cSrcweir 					SAL_STATIC_CAST( awt::XControlContainer*, this );
796cdf0e10cSrcweir 				implUpdateVisibility( nDialogStep, xContainer );
797cdf0e10cSrcweir 
798cdf0e10cSrcweir 				uno::Reference< beans::XPropertyChangeListener > xListener =
799cdf0e10cSrcweir 					SAL_STATIC_CAST( beans::XPropertyChangeListener*,
800cdf0e10cSrcweir 						new DialogStepChangedListener( xContainer ) );
801cdf0e10cSrcweir 				xPSet->addPropertyChangeListener( aPropName, xListener );
802cdf0e10cSrcweir 			}
803cdf0e10cSrcweir 
804cdf0e10cSrcweir 			uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls();
805cdf0e10cSrcweir 			sal_uInt32 nCtrls = aCtrls.getLength();
806cdf0e10cSrcweir 			for( sal_uInt32 n = 0; n < nCtrls; n++ )
807cdf0e10cSrcweir 				aCtrls.getArray()[n]->createPeer( rxToolkit, getPeer() );
808cdf0e10cSrcweir 
809cdf0e10cSrcweir 			uno::Reference< awt::XVclContainerPeer >  xC( getPeer(), uno::UNO_QUERY );
810cdf0e10cSrcweir             OSL_ENSURE(xC.is(),"Peer isn't valid. Please check!");
811cdf0e10cSrcweir 
812cdf0e10cSrcweir 			xC->enableDialogControl( sal_True );
813cdf0e10cSrcweir 			ImplActivateTabControllers();
814cdf0e10cSrcweir 		}
815cdf0e10cSrcweir 
816cdf0e10cSrcweir 		if( bVis && !isDesignMode() )
817cdf0e10cSrcweir 			UnoControl::setVisible( sal_True );
818cdf0e10cSrcweir 	}
819cdf0e10cSrcweir }
820cdf0e10cSrcweir 
821cdf0e10cSrcweir 
822cdf0e10cSrcweir // awt::XWindow
setVisible(sal_Bool bVisible)823cdf0e10cSrcweir void UnoControlContainer::setVisible( sal_Bool bVisible ) throw(uno::RuntimeException)
824cdf0e10cSrcweir {
825cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
826cdf0e10cSrcweir 
827cdf0e10cSrcweir 	UnoControl::setVisible( bVisible );
828cdf0e10cSrcweir 	if( !mxContext.is() && bVisible )
829cdf0e10cSrcweir 		// Es ist ein TopWindow, also automatisch anzeigen
830cdf0e10cSrcweir 		createPeer( uno::Reference< awt::XToolkit > (), uno::Reference< awt::XWindowPeer > () );
831cdf0e10cSrcweir }
832cdf0e10cSrcweir 
833cdf0e10cSrcweir 
834cdf0e10cSrcweir 
835