bump product version to 6.1.0.2
[LibreOffice.git] / toolkit / source / controls / unocontrolcontainer.cxx
blobbe64fb6eee17fc73bb9a40016001c60511ad14b5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/awt/XVclContainerPeer.hpp>
21 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
22 #include <com/sun/star/container/NoSuchElementException.hpp>
23 #include <com/sun/star/uno/XComponentContext.hpp>
25 #include <cppuhelper/typeprovider.hxx>
26 #include <cppuhelper/implbase.hxx>
27 #include <rtl/uuid.h>
29 #include <toolkit/controls/unocontrolcontainer.hxx>
30 #include <toolkit/helper/property.hxx>
31 #include <toolkit/helper/servicenames.hxx>
32 #include <comphelper/sequence.hxx>
34 #include <tools/debug.hxx>
35 #include <vcl/svapp.hxx>
36 #include <vcl/window.hxx>
38 #include <limits>
39 #include <map>
40 #include <memory>
41 #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
43 using namespace ::com::sun::star;
46 // class UnoControlHolder
48 struct UnoControlHolder
50 uno::Reference< awt::XControl > mxControl;
51 OUString msName;
53 public:
54 UnoControlHolder( const OUString& rName, const uno::Reference< awt::XControl > & rControl )
55 : mxControl( rControl ),
56 msName( rName )
60 const OUString& getName() const { return msName; }
61 const uno::Reference< awt::XControl >& getControl() const { return mxControl; }
64 class UnoControlHolderList
66 public:
67 typedef sal_Int32 ControlIdentifier;
68 private:
69 typedef std::shared_ptr< UnoControlHolder > ControlInfo;
70 typedef ::std::map< ControlIdentifier, ControlInfo > ControlMap;
72 private:
73 ControlMap maControls;
75 public:
76 UnoControlHolderList();
78 /** adds a control with the given name to the list
79 @param _rxControl
80 the control to add. Must not be <NULL/>
81 @param _pBName
82 the name of the control, or <NULL/> if an automatic name should be generated
83 @return
84 the identifier of the newly added control
86 ControlIdentifier addControl( const uno::Reference< awt::XControl >& _rxControl, const OUString* _pName );
88 /** determines whether or not the list is empty
90 bool empty() const { return maControls.empty(); }
92 /** retrieves all controls currently in the list
94 void getControls( uno::Sequence< uno::Reference< awt::XControl > >& _out_rControls ) const;
96 /** retrieves all identifiers of all controls currently in the list
98 void getIdentifiers( uno::Sequence< sal_Int32 >& _out_rIdentifiers ) const;
100 /** returns the first control which is registered under the given name
102 uno::Reference< awt::XControl >
103 getControlForName( const OUString& _rName ) const;
105 /** returns the identifier which a control is registered for, or -1 if the control
106 isn't registered
108 ControlIdentifier
109 getControlIdentifier( const uno::Reference< awt::XControl >& _rxControl );
111 /** retrieves the control for a given id
112 @param _nIdentifier
113 the identifier for the control
114 @param _out_rxControl
115 takes the XControl upon successful return
116 @return
117 <TRUE/> if and only if a control with the given id is part of the list
119 bool getControlForIdentifier( ControlIdentifier _nIdentifier, uno::Reference< awt::XControl >& _out_rxControl ) const;
121 /** removes a control from the list, given by id
122 @param _nId
123 The identifier of the control to remove.
125 void removeControlById( ControlIdentifier _nId );
127 /** replaces a control from the list with another one
128 @param _nId
129 The identifier of the control to replace
130 @param _rxNewControl
131 the new control to put into the list
133 void replaceControlById( ControlIdentifier _nId, const uno::Reference< awt::XControl >& _rxNewControl );
135 private:
136 /** adds a control
137 @param _rxControl
138 the control to add to the container
139 @param _pName
140 pointer to the name of the control. Might be <NULL/>, in this case, a name is generated.
141 @return
142 the identifier of the newly inserted control
144 ControlIdentifier impl_addControl(
145 const uno::Reference< awt::XControl >& _rxControl,
146 const OUString* _pName
149 /** finds a free identifier
150 @throw uno::RuntimeException
151 if no free identifier can be found
153 ControlIdentifier impl_getFreeIdentifier_throw();
155 /** finds a free name
156 @throw uno::RuntimeException
157 if no free name can be found
159 OUString impl_getFreeName_throw();
163 UnoControlHolderList::UnoControlHolderList()
168 UnoControlHolderList::ControlIdentifier UnoControlHolderList::addControl( const uno::Reference< awt::XControl >& _rxControl, const OUString* _pName )
170 return impl_addControl( _rxControl, _pName );
174 void UnoControlHolderList::getControls( uno::Sequence< uno::Reference< awt::XControl > >& _out_rControls ) const
176 _out_rControls.realloc( maControls.size() );
177 uno::Reference< awt::XControl >* pControls = _out_rControls.getArray();
178 for ( ControlMap::const_iterator loop = maControls.begin();
179 loop != maControls.end();
180 ++loop, ++pControls
182 *pControls = loop->second->getControl();
186 void UnoControlHolderList::getIdentifiers( uno::Sequence< sal_Int32 >& _out_rIdentifiers ) const
188 _out_rIdentifiers.realloc( maControls.size() );
189 sal_Int32* pIndentifiers = _out_rIdentifiers.getArray();
190 for ( ControlMap::const_iterator loop = maControls.begin();
191 loop != maControls.end();
192 ++loop, ++pIndentifiers
194 *pIndentifiers = loop->first;
198 uno::Reference< awt::XControl > UnoControlHolderList::getControlForName( const OUString& _rName ) const
200 for ( ControlMap::const_iterator loop = maControls.begin();
201 loop != maControls.end();
202 ++loop
204 if ( loop->second->getName() == _rName )
205 return loop->second->getControl();
206 return uno::Reference< awt::XControl >();
210 UnoControlHolderList::ControlIdentifier UnoControlHolderList::getControlIdentifier( const uno::Reference< awt::XControl >& _rxControl )
212 for ( ControlMap::iterator loop = maControls.begin();
213 loop != maControls.end();
214 ++loop
217 if ( loop->second->getControl().get() == _rxControl.get() )
218 return loop->first;
220 return -1;
224 bool UnoControlHolderList::getControlForIdentifier( UnoControlHolderList::ControlIdentifier _nIdentifier, uno::Reference< awt::XControl >& _out_rxControl ) const
226 ControlMap::const_iterator pos = maControls.find( _nIdentifier );
227 if ( pos == maControls.end() )
228 return false;
229 _out_rxControl = pos->second->getControl();
230 return true;
234 void UnoControlHolderList::removeControlById( UnoControlHolderList::ControlIdentifier _nId )
236 ControlMap::iterator pos = maControls.find( _nId );
237 DBG_ASSERT( pos != maControls.end(), "UnoControlHolderList::removeControlById: invalid id!" );
238 if ( pos == maControls.end() )
239 return;
241 maControls.erase( pos );
245 void UnoControlHolderList::replaceControlById( ControlIdentifier _nId, const uno::Reference< awt::XControl >& _rxNewControl )
247 DBG_ASSERT( _rxNewControl.is(), "UnoControlHolderList::replaceControlById: invalid new control!" );
249 ControlMap::iterator pos = maControls.find( _nId );
250 DBG_ASSERT( pos != maControls.end(), "UnoControlHolderList::replaceControlById: invalid id!" );
251 if ( pos == maControls.end() )
252 return;
254 pos->second.reset( new UnoControlHolder( pos->second->getName(), _rxNewControl ) );
258 UnoControlHolderList::ControlIdentifier UnoControlHolderList::impl_addControl( const uno::Reference< awt::XControl >& _rxControl, const OUString* _pName )
260 DBG_ASSERT( _rxControl.is(), "UnoControlHolderList::impl_addControl: invalid control!" );
262 OUString sName = _pName ? *_pName : impl_getFreeName_throw();
263 sal_Int32 nId = impl_getFreeIdentifier_throw();
265 maControls[ nId ] = std::make_shared<UnoControlHolder>( sName, _rxControl );
266 return nId;
270 UnoControlHolderList::ControlIdentifier UnoControlHolderList::impl_getFreeIdentifier_throw()
272 for ( ControlIdentifier candidateId = 0; candidateId < ::std::numeric_limits< ControlIdentifier >::max(); ++candidateId )
274 ControlMap::const_iterator existent = maControls.find( candidateId );
275 if ( existent == maControls.end() )
276 return candidateId;
278 throw uno::RuntimeException("out of identifiers" );
282 OUString UnoControlHolderList::impl_getFreeName_throw()
284 for ( ControlIdentifier candidateId = 0; candidateId < ::std::numeric_limits< ControlIdentifier >::max(); ++candidateId )
286 OUString candidateName( "control_" + OUString::number( candidateId ) );
287 ControlMap::const_iterator loop = maControls.begin();
288 for ( ; loop != maControls.end(); ++loop )
290 if ( loop->second->getName() == candidateName )
291 break;
293 if ( loop == maControls.end() )
294 return candidateName;
296 throw uno::RuntimeException("out of identifiers" );
299 // Function to set the controls' visibility according
300 // to the dialog's "Step" property
302 void implUpdateVisibility
304 sal_Int32 nDialogStep,
305 const uno::Reference< awt::XControlContainer >& xControlContainer
308 uno::Sequence< uno::Reference< awt::XControl > >
309 aCtrls = xControlContainer->getControls();
310 const uno::Reference< awt::XControl >* pCtrls = aCtrls.getConstArray();
311 sal_uInt32 nCtrls = aCtrls.getLength();
312 bool bCompleteVisible = (nDialogStep == 0);
313 for( sal_uInt32 n = 0; n < nCtrls; n++ )
315 uno::Reference< awt::XControl > xControl = pCtrls[ n ];
317 bool bVisible = bCompleteVisible;
318 if( !bVisible )
320 uno::Reference< awt::XControlModel > xModel( xControl->getModel() );
321 uno::Reference< beans::XPropertySet > xPSet
322 ( xModel, uno::UNO_QUERY );
323 uno::Reference< beans::XPropertySetInfo >
324 xInfo = xPSet->getPropertySetInfo();
325 OUString aPropName( "Step" );
326 sal_Int32 nControlStep = 0;
327 if ( xInfo->hasPropertyByName( aPropName ) )
329 uno::Any aVal = xPSet->getPropertyValue( aPropName );
330 aVal >>= nControlStep;
332 bVisible = (nControlStep == 0) || (nControlStep == nDialogStep);
335 uno::Reference< awt::XWindow> xWindow
336 ( xControl, uno::UNO_QUERY );
337 if( xWindow.is() )
338 xWindow->setVisible( bVisible );
343 // class DialogStepChangedListener
345 typedef ::cppu::WeakImplHelper< beans::XPropertyChangeListener > PropertyChangeListenerHelper;
347 class DialogStepChangedListener: public PropertyChangeListenerHelper
349 private:
350 uno::Reference< awt::XControlContainer > mxControlContainer;
352 public:
353 explicit DialogStepChangedListener( uno::Reference< awt::XControlContainer > const & xControlContainer )
354 : mxControlContainer( xControlContainer ) {}
356 // XEventListener
357 virtual void SAL_CALL disposing( const lang::EventObject& Source ) override;
359 // XPropertyChangeListener
360 virtual void SAL_CALL propertyChange( const beans::PropertyChangeEvent& evt ) override;
364 void SAL_CALL DialogStepChangedListener::disposing( const lang::EventObject& /*_rSource*/)
366 mxControlContainer.clear();
369 void SAL_CALL DialogStepChangedListener::propertyChange( const beans::PropertyChangeEvent& evt )
371 // evt.PropertyName HAS to be "Step" because we only use the listener for that
372 sal_Int32 nDialogStep = 0;
373 evt.NewValue >>= nDialogStep;
374 implUpdateVisibility( nDialogStep, mxControlContainer );
378 // class UnoControlContainer
380 UnoControlContainer::UnoControlContainer()
381 :UnoControlContainer_Base()
382 ,maCListeners( *this )
384 mpControls.reset(new UnoControlHolderList);
387 UnoControlContainer::UnoControlContainer(const uno::Reference< awt::XWindowPeer >& xP )
388 :UnoControlContainer_Base()
389 ,maCListeners( *this )
391 setPeer( xP );
392 mbDisposePeer = false;
393 mpControls.reset(new UnoControlHolderList);
396 UnoControlContainer::~UnoControlContainer()
400 void UnoControlContainer::ImplActivateTabControllers()
402 sal_uInt32 nCount = maTabControllers.getLength();
403 for ( sal_uInt32 n = 0; n < nCount; n++ )
405 maTabControllers.getArray()[n]->setContainer( this );
406 maTabControllers.getArray()[n]->activateTabOrder();
410 // lang::XComponent
411 void UnoControlContainer::dispose( )
413 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
415 lang::EventObject aDisposeEvent;
416 aDisposeEvent.Source = static_cast< uno::XAggregation* >( this );
418 // Notify listeners about disposal of this Container (This is much faster if they
419 // listen on the controls and the container).
420 maDisposeListeners.disposeAndClear( aDisposeEvent );
421 maCListeners.disposeAndClear( aDisposeEvent );
424 uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls();
426 for( uno::Reference< awt::XControl > const & control : aCtrls )
428 removingControl( control );
429 // Delete control
430 control->dispose();
434 // Delete all structures
435 mpControls.reset(new UnoControlHolderList);
437 UnoControlBase::dispose();
440 // lang::XEventListener
441 void UnoControlContainer::disposing( const lang::EventObject& _rEvt )
443 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
445 uno::Reference< awt::XControl > xControl( _rEvt.Source, uno::UNO_QUERY );
446 if ( xControl.is() )
447 removeControl( xControl );
449 UnoControlBase::disposing( _rEvt );
452 // container::XContainer
453 void UnoControlContainer::addContainerListener( const uno::Reference< container::XContainerListener >& rxListener )
455 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
457 maCListeners.addInterface( rxListener );
460 void UnoControlContainer::removeContainerListener( const uno::Reference< container::XContainerListener >& rxListener )
462 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
464 maCListeners.removeInterface( rxListener );
468 ::sal_Int32 SAL_CALL UnoControlContainer::insert( const uno::Any& _rElement )
470 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
472 uno::Reference< awt::XControl > xControl;
473 if ( !( _rElement >>= xControl ) || !xControl.is() )
474 throw lang::IllegalArgumentException(
475 "Elements must support the XControl interface.",
476 *this,
480 return impl_addControl( xControl );
483 void SAL_CALL UnoControlContainer::removeByIdentifier( ::sal_Int32 _nIdentifier )
485 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
487 uno::Reference< awt::XControl > xControl;
488 if ( !mpControls->getControlForIdentifier( _nIdentifier, xControl ) )
489 throw container::NoSuchElementException(
490 "There is no element with the given identifier.",
491 *this
494 impl_removeControl( _nIdentifier, xControl );
497 void SAL_CALL UnoControlContainer::replaceByIdentifer( ::sal_Int32 _nIdentifier, const uno::Any& _rElement )
499 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
501 uno::Reference< awt::XControl > xExistentControl;
502 if ( !mpControls->getControlForIdentifier( _nIdentifier, xExistentControl ) )
503 throw container::NoSuchElementException(
504 "There is no element with the given identifier.",
505 *this
508 uno::Reference< awt::XControl > xNewControl;
509 if ( !( _rElement >>= xNewControl ) )
510 throw lang::IllegalArgumentException(
511 "Elements must support the XControl interface.",
512 *this,
516 removingControl( xExistentControl );
518 mpControls->replaceControlById( _nIdentifier, xNewControl );
520 addingControl( xNewControl );
522 impl_createControlPeerIfNecessary( xNewControl );
524 if ( maCListeners.getLength() )
526 container::ContainerEvent aEvent;
527 aEvent.Source = *this;
528 aEvent.Accessor <<= _nIdentifier;
529 aEvent.Element <<= xNewControl;
530 aEvent.ReplacedElement <<= xExistentControl;
531 maCListeners.elementReplaced( aEvent );
535 uno::Any SAL_CALL UnoControlContainer::getByIdentifier( ::sal_Int32 _nIdentifier )
537 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
539 uno::Reference< awt::XControl > xControl;
540 if ( !mpControls->getControlForIdentifier( _nIdentifier, xControl ) )
541 throw container::NoSuchElementException();
542 return uno::makeAny( xControl );
545 uno::Sequence< ::sal_Int32 > SAL_CALL UnoControlContainer::getIdentifiers( )
547 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
549 uno::Sequence< ::sal_Int32 > aIdentifiers;
550 mpControls->getIdentifiers( aIdentifiers );
551 return aIdentifiers;
554 // container::XElementAccess
555 uno::Type SAL_CALL UnoControlContainer::getElementType( )
557 return cppu::UnoType<awt::XControlModel>::get();
560 sal_Bool SAL_CALL UnoControlContainer::hasElements( )
562 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
563 return !mpControls->empty();
566 // awt::XControlContainer
567 void UnoControlContainer::setStatusText( const OUString& rStatusText )
569 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
571 // Descend the parent hierarchy
572 uno::Reference< awt::XControlContainer > xContainer( mxContext, uno::UNO_QUERY );
573 if( xContainer.is() )
574 xContainer->setStatusText( rStatusText );
577 uno::Sequence< uno::Reference< awt::XControl > > UnoControlContainer::getControls( )
579 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
580 uno::Sequence< uno::Reference< awt::XControl > > aControls;
581 mpControls->getControls( aControls );
582 return aControls;
585 uno::Reference< awt::XControl > UnoControlContainer::getControl( const OUString& rName )
587 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
588 return mpControls->getControlForName( rName );
591 void UnoControlContainer::addingControl( const uno::Reference< awt::XControl >& _rxControl )
593 if ( _rxControl.is() )
595 uno::Reference< uno::XInterface > xThis;
596 OWeakAggObject::queryInterface( cppu::UnoType<uno::XInterface>::get() ) >>= xThis;
598 _rxControl->setContext( xThis );
599 _rxControl->addEventListener( this );
603 void UnoControlContainer::impl_createControlPeerIfNecessary( const uno::Reference< awt::XControl >& _rxControl )
605 OSL_PRECOND( _rxControl.is(), "UnoControlContainer::impl_createControlPeerIfNecessary: invalid control, this will crash!" );
607 // if the container already has a peer, then also create a peer for the control
608 uno::Reference< awt::XWindowPeer > xMyPeer( getPeer() );
610 if( xMyPeer.is() )
612 _rxControl->createPeer( nullptr, xMyPeer );
613 ImplActivateTabControllers();
618 sal_Int32 UnoControlContainer::impl_addControl( const uno::Reference< awt::XControl >& _rxControl, const OUString* _pName )
620 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
621 UnoControlHolderList::ControlIdentifier id = mpControls->addControl( _rxControl, _pName );
623 addingControl( _rxControl );
625 impl_createControlPeerIfNecessary( _rxControl );
627 if ( maCListeners.getLength() )
629 container::ContainerEvent aEvent;
630 aEvent.Source = *this;
631 _pName ? ( aEvent.Accessor <<= *_pName ) : ( aEvent.Accessor <<= static_cast<sal_Int32>(id) );
632 aEvent.Element <<= _rxControl;
633 maCListeners.elementInserted( aEvent );
636 return id;
639 void UnoControlContainer::addControl( const OUString& rName, const uno::Reference< awt::XControl >& rControl )
641 if ( rControl.is() )
642 impl_addControl( rControl, &rName );
645 void UnoControlContainer::removingControl( const uno::Reference< awt::XControl >& _rxControl )
647 if ( _rxControl.is() )
649 _rxControl->removeEventListener( this );
650 _rxControl->setContext( nullptr );
654 void UnoControlContainer::impl_removeControl( sal_Int32 _nId, const uno::Reference< awt::XControl >& _rxControl )
656 #ifdef DBG_UTIL
658 uno::Reference< awt::XControl > xControl;
659 bool bHas = mpControls->getControlForIdentifier( _nId, xControl );
660 DBG_ASSERT( bHas && xControl == _rxControl, "UnoControlContainer::impl_removeControl: inconsistency in the parameters!" );
662 #endif
663 removingControl( _rxControl );
665 mpControls->removeControlById( _nId );
667 if ( maCListeners.getLength() )
669 container::ContainerEvent aEvent;
670 aEvent.Source = *this;
671 aEvent.Accessor <<= _nId;
672 aEvent.Element <<= _rxControl;
673 maCListeners.elementRemoved( aEvent );
677 void UnoControlContainer::removeControl( const uno::Reference< awt::XControl >& _rxControl )
679 if ( _rxControl.is() )
681 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
683 UnoControlHolderList::ControlIdentifier id = mpControls->getControlIdentifier( _rxControl );
684 if ( id != -1 )
685 impl_removeControl( id, _rxControl );
690 // awt::XUnoControlContainer
691 void UnoControlContainer::setTabControllers( const uno::Sequence< uno::Reference< awt::XTabController > >& TabControllers )
693 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
695 maTabControllers = TabControllers;
698 uno::Sequence< uno::Reference< awt::XTabController > > UnoControlContainer::getTabControllers( )
700 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
702 return maTabControllers;
705 void UnoControlContainer::addTabController( const uno::Reference< awt::XTabController >& TabController )
707 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
709 sal_uInt32 nCount = maTabControllers.getLength();
710 maTabControllers.realloc( nCount + 1 );
711 maTabControllers[ nCount ] = TabController;
714 void UnoControlContainer::removeTabController( const uno::Reference< awt::XTabController >& TabController )
716 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
718 sal_uInt32 nCount = maTabControllers.getLength();
719 const uno::Reference< awt::XTabController >* pLoop = maTabControllers.getConstArray();
720 for ( sal_uInt32 n = 0; n < nCount; ++n, ++pLoop )
722 if( pLoop->get() == TabController.get() )
724 ::comphelper::removeElementAt( maTabControllers, n );
725 break;
730 // awt::XControl
731 void UnoControlContainer::createPeer( const uno::Reference< awt::XToolkit >& rxToolkit, const uno::Reference< awt::XWindowPeer >& rParent )
733 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
735 if( !getPeer().is() )
737 bool bVis = maComponentInfos.bVisible;
738 if( bVis )
739 UnoControl::setVisible( false );
741 // Create a new peer
742 UnoControl::createPeer( rxToolkit, rParent );
744 // Create all children's peers
745 if ( !mbCreatingCompatiblePeer )
747 // Evaluate "Step" property
748 uno::Reference< awt::XControlModel > xModel( getModel() );
749 uno::Reference< beans::XPropertySet > xPSet
750 ( xModel, uno::UNO_QUERY );
751 uno::Reference< beans::XPropertySetInfo >
752 xInfo = xPSet->getPropertySetInfo();
753 OUString aPropName( "Step" );
754 if ( xInfo->hasPropertyByName( aPropName ) )
756 css::uno::Any aVal = xPSet->getPropertyValue( aPropName );
757 sal_Int32 nDialogStep = 0;
758 aVal >>= nDialogStep;
759 uno::Reference< awt::XControlContainer > xContainer =
760 static_cast< awt::XControlContainer* >(this);
761 implUpdateVisibility( nDialogStep, xContainer );
763 uno::Reference< beans::XPropertyChangeListener > xListener =
764 static_cast< beans::XPropertyChangeListener* >(
765 new DialogStepChangedListener( xContainer ) );
766 xPSet->addPropertyChangeListener( aPropName, xListener );
769 uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls();
770 sal_uInt32 nCtrls = aCtrls.getLength();
771 for( sal_uInt32 n = 0; n < nCtrls; n++ )
772 aCtrls.getArray()[n]->createPeer( rxToolkit, getPeer() );
774 uno::Reference< awt::XVclContainerPeer > xC( getPeer(), uno::UNO_QUERY );
775 if ( xC.is() )
776 xC->enableDialogControl( true );
777 ImplActivateTabControllers();
780 if( bVis && !isDesignMode() )
781 UnoControl::setVisible( true );
786 // awt::XWindow
787 void UnoControlContainer::setVisible( sal_Bool bVisible )
789 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
791 UnoControl::setVisible( bVisible );
792 if( !mxContext.is() && bVisible )
793 // This is a Topwindow, thus show it automatically
794 createPeer( uno::Reference< awt::XToolkit > (), uno::Reference< awt::XWindowPeer > () );
797 OUString UnoControlContainer::getImplementationName()
799 return OUString("stardiv.Toolkit.UnoControlContainer");
802 css::uno::Sequence<OUString> UnoControlContainer::getSupportedServiceNames()
804 auto s(UnoControlBase::getSupportedServiceNames());
805 s.realloc(s.getLength() + 2);
806 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlContainer";
807 s[s.getLength() - 1] = "stardiv.vcl.control.ControlContainer";
808 return s;
811 void UnoControlContainer::PrepareWindowDescriptor( css::awt::WindowDescriptor& rDesc )
813 // HACK due to the fact that we can't really use VSCROLL & HSCROLL
814 // for Dialog ( css::awt::VclWindowPeerAttribute::VSCROLL
815 // has the same value as
816 // css::awt::WindowAttribute::NODECORATION )
817 // For convenience in the PropBrowse using HSCROLL and VSCROLL ensures
818 // the Correct text. We exchange them here and the control knows
819 // about this hack ( it sucks badly I know )
820 if ( rDesc.WindowAttributes & css::awt::VclWindowPeerAttribute::VSCROLL )
822 rDesc.WindowAttributes &= ~css::awt::VclWindowPeerAttribute::VSCROLL;
823 rDesc.WindowAttributes |= css::awt::VclWindowPeerAttribute::AUTOVSCROLL;
825 if ( rDesc.WindowAttributes & css::awt::VclWindowPeerAttribute::HSCROLL )
827 rDesc.WindowAttributes &= ~css::awt::VclWindowPeerAttribute::HSCROLL;
828 rDesc.WindowAttributes |= css::awt::VclWindowPeerAttribute::AUTOHSCROLL;
832 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
833 stardiv_Toolkit_UnoControlContainer_get_implementation(
834 css::uno::XComponentContext *,
835 css::uno::Sequence<css::uno::Any> const &)
837 return cppu::acquire(new UnoControlContainer());
840 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */