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