LibreOffice Module toolkit (master) 1
unocontrolcontainer.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <com/sun/star/awt/XVclContainerPeer.hpp>
21#include <com/sun/star/beans/XPropertySet.hpp>
22#include <com/sun/star/beans/XPropertyChangeListener.hpp>
23#include <com/sun/star/container/NoSuchElementException.hpp>
24#include <com/sun/star/uno/XComponentContext.hpp>
25
27
30
31#include <tools/debug.hxx>
32
33#include <limits>
34#include <map>
35#include <memory>
36#include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
37#include <utility>
38
39using namespace ::com::sun::star;
40
41
42
43namespace {
44
45struct UnoControlHolder
46{
47 uno::Reference< awt::XControl > mxControl;
48 OUString msName;
49
50public:
51 UnoControlHolder( OUString aName, uno::Reference< awt::XControl > xControl )
52 : mxControl(std::move( xControl )),
53 msName(std::move( aName ))
54 {
55 }
56
57 const OUString& getName() const { return msName; }
58 const uno::Reference< awt::XControl >& getControl() const { return mxControl; }
59};
60
61}
62
64{
65public:
66 typedef sal_Int32 ControlIdentifier;
67private:
68 typedef std::shared_ptr< UnoControlHolder > ControlInfo;
69 typedef ::std::map< ControlIdentifier, ControlInfo > ControlMap;
70
71private:
73
74public:
76
85 ControlIdentifier addControl( const uno::Reference< awt::XControl >& _rxControl, const OUString* _pName );
86
89 bool empty() const { return maControls.empty(); }
90
93 void getControls( uno::Sequence< uno::Reference< awt::XControl > >& _out_rControls ) const;
94
97 void getIdentifiers( uno::Sequence< sal_Int32 >& _out_rIdentifiers ) const;
98
101 uno::Reference< awt::XControl >
102 getControlForName( const OUString& _rName ) const;
103
108 getControlIdentifier( const uno::Reference< awt::XControl >& _rxControl );
109
118 bool getControlForIdentifier( ControlIdentifier _nIdentifier, uno::Reference< awt::XControl >& _out_rxControl ) const;
119
125
132 void replaceControlById( ControlIdentifier _nId, const uno::Reference< awt::XControl >& _rxNewControl );
133
134private:
144 const uno::Reference< awt::XControl >& _rxControl,
145 const OUString* _pName
146 );
147
153
158 OUString impl_getFreeName_throw();
159};
160
161
163{
164}
165
166
167UnoControlHolderList::ControlIdentifier UnoControlHolderList::addControl( const uno::Reference< awt::XControl >& _rxControl, const OUString* _pName )
168{
169 return impl_addControl( _rxControl, _pName );
170}
171
172
173void UnoControlHolderList::getControls( uno::Sequence< uno::Reference< awt::XControl > >& _out_rControls ) const
174{
175 _out_rControls.realloc( maControls.size() );
176 uno::Reference< awt::XControl >* pControls = _out_rControls.getArray();
177 for (const auto& rEntry : maControls)
178 {
179 *pControls = rEntry.second->getControl();
180 ++pControls;
181 }
182}
183
184
185void UnoControlHolderList::getIdentifiers( uno::Sequence< sal_Int32 >& _out_rIdentifiers ) const
186{
187 _out_rIdentifiers.realloc( maControls.size() );
188 sal_Int32* pIdentifiers = _out_rIdentifiers.getArray();
189 for (const auto& rEntry : maControls)
190 {
191 *pIdentifiers = rEntry.first;
192 ++pIdentifiers;
193 }
194}
195
196
197uno::Reference< awt::XControl > UnoControlHolderList::getControlForName( const OUString& _rName ) const
198{
199 auto loop = std::find_if(maControls.begin(), maControls.end(),
200 [&_rName](const ControlMap::value_type& rEntry) { return rEntry.second->getName() == _rName; });
201 if (loop != maControls.end())
202 return loop->second->getControl();
203 return uno::Reference< awt::XControl >();
204}
205
206
208{
209 auto loop = std::find_if(maControls.begin(), maControls.end(),
210 [&_rxControl](const ControlMap::value_type& rEntry) { return rEntry.second->getControl().get() == _rxControl.get(); });
211 if (loop != maControls.end())
212 return loop->first;
213 return -1;
214}
215
216
217bool UnoControlHolderList::getControlForIdentifier( UnoControlHolderList::ControlIdentifier _nIdentifier, uno::Reference< awt::XControl >& _out_rxControl ) const
218{
219 ControlMap::const_iterator pos = maControls.find( _nIdentifier );
220 if ( pos == maControls.end() )
221 return false;
222 _out_rxControl = pos->second->getControl();
223 return true;
224}
225
226
228{
229 ControlMap::iterator pos = maControls.find( _nId );
230 DBG_ASSERT( pos != maControls.end(), "UnoControlHolderList::removeControlById: invalid id!" );
231 if ( pos == maControls.end() )
232 return;
233
234 maControls.erase( pos );
235}
236
237
238void UnoControlHolderList::replaceControlById( ControlIdentifier _nId, const uno::Reference< awt::XControl >& _rxNewControl )
239{
240 DBG_ASSERT( _rxNewControl.is(), "UnoControlHolderList::replaceControlById: invalid new control!" );
241
242 ControlMap::iterator pos = maControls.find( _nId );
243 DBG_ASSERT( pos != maControls.end(), "UnoControlHolderList::replaceControlById: invalid id!" );
244 if ( pos == maControls.end() )
245 return;
246
247 pos->second = std::make_shared<UnoControlHolder>( pos->second->getName(), _rxNewControl );
248}
249
250
251UnoControlHolderList::ControlIdentifier UnoControlHolderList::impl_addControl( const uno::Reference< awt::XControl >& _rxControl, const OUString* _pName )
252{
253 DBG_ASSERT( _rxControl.is(), "UnoControlHolderList::impl_addControl: invalid control!" );
254
255 OUString sName = _pName ? *_pName : impl_getFreeName_throw();
256 sal_Int32 nId = impl_getFreeIdentifier_throw();
257
258 maControls[ nId ] = std::make_shared<UnoControlHolder>( sName, _rxControl );
259 return nId;
260}
261
262
264{
265 for ( ControlIdentifier candidateId = 0; candidateId < ::std::numeric_limits< ControlIdentifier >::max(); ++candidateId )
266 {
267 ControlMap::const_iterator existent = maControls.find( candidateId );
268 if ( existent == maControls.end() )
269 return candidateId;
270 }
271 throw uno::RuntimeException("out of identifiers" );
272}
273
274
276{
277 for ( ControlIdentifier candidateId = 0; candidateId < ::std::numeric_limits< ControlIdentifier >::max(); ++candidateId )
278 {
279 OUString candidateName( "control_" + OUString::number( candidateId ) );
280 if ( std::none_of(maControls.begin(), maControls.end(),
281 [&candidateName](const ControlMap::value_type& rEntry) { return rEntry.second->getName() == candidateName; }) )
282 return candidateName;
283 }
284 throw uno::RuntimeException("out of identifiers" );
285}
286
287// Function to set the controls' visibility according
288// to the dialog's "Step" property
289
291(
292 sal_Int32 nDialogStep,
293 const uno::Reference< awt::XControlContainer >& xControlContainer
294)
295{
296 const uno::Sequence< uno::Reference< awt::XControl > >
297 aCtrls = xControlContainer->getControls();
298 bool bCompleteVisible = (nDialogStep == 0);
299 for( const uno::Reference< awt::XControl >& xControl : aCtrls )
300 {
301 bool bVisible = bCompleteVisible;
302 if( !bVisible )
303 {
304 uno::Reference< awt::XControlModel > xModel( xControl->getModel() );
305 uno::Reference< beans::XPropertySet > xPSet
306 ( xModel, uno::UNO_QUERY );
307 uno::Reference< beans::XPropertySetInfo >
308 xInfo = xPSet->getPropertySetInfo();
309 OUString aPropName( "Step" );
310 sal_Int32 nControlStep = 0;
311 if ( xInfo->hasPropertyByName( aPropName ) )
312 {
313 uno::Any aVal = xPSet->getPropertyValue( aPropName );
314 aVal >>= nControlStep;
315 }
316 bVisible = (nControlStep == 0) || (nControlStep == nDialogStep);
317 }
318
319 uno::Reference< awt::XWindow> xWindow
320 ( xControl, uno::UNO_QUERY );
321 if( xWindow.is() )
322 xWindow->setVisible( bVisible );
323 }
324}
325
326
327
328typedef ::cppu::WeakImplHelper< beans::XPropertyChangeListener > PropertyChangeListenerHelper;
329
330namespace {
331
332class DialogStepChangedListener: public PropertyChangeListenerHelper
333{
334private:
335 uno::Reference< awt::XControlContainer > mxControlContainer;
336
337public:
338 explicit DialogStepChangedListener( uno::Reference< awt::XControlContainer > xControlContainer )
339 : mxControlContainer(std::move( xControlContainer )) {}
340
341 // XEventListener
342 virtual void SAL_CALL disposing( const lang::EventObject& Source ) override;
343
344 // XPropertyChangeListener
345 virtual void SAL_CALL propertyChange( const beans::PropertyChangeEvent& evt ) override;
346
347};
348
349}
350
351void SAL_CALL DialogStepChangedListener::disposing( const lang::EventObject& /*_rSource*/)
352{
353 mxControlContainer.clear();
354}
355
356void SAL_CALL DialogStepChangedListener::propertyChange( const beans::PropertyChangeEvent& evt )
357{
358 // evt.PropertyName HAS to be "Step" because we only use the listener for that
359 sal_Int32 nDialogStep = 0;
360 evt.NewValue >>= nDialogStep;
361 implUpdateVisibility( nDialogStep, mxControlContainer );
362}
363
364
365
367 :maCListeners( *this )
368{
370}
371
372UnoControlContainer::UnoControlContainer(const uno::Reference< awt::XVclWindowPeer >& xP )
373 :maCListeners( *this )
374{
375 setPeer( xP );
376 mbDisposePeer = false;
378}
379
381{
382}
383
385{
386 for ( auto& rTabController : asNonConstRange(maTabControllers) )
387 {
388 rTabController->setContainer( this );
389 rTabController->activateTabOrder();
390 }
391}
392
393// lang::XComponent
395{
396 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
397
398 lang::EventObject aDisposeEvent;
399 aDisposeEvent.Source = static_cast< uno::XAggregation* >( this );
400
401 // Notify listeners about disposal of this Container (This is much faster if they
402 // listen on the controls and the container).
403 maDisposeListeners.disposeAndClear( aDisposeEvent );
404 maCListeners.disposeAndClear( aDisposeEvent );
405
406
407 const uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls();
408
409 for( uno::Reference< awt::XControl > const & control : aCtrls )
410 {
411 removingControl( control );
412 // Delete control
413 control->dispose();
414 }
415
416
417 // Delete all structures
419
421}
422
423// lang::XEventListener
424void UnoControlContainer::disposing( const lang::EventObject& _rEvt )
425{
426 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
427
428 uno::Reference< awt::XControl > xControl( _rEvt.Source, uno::UNO_QUERY );
429 if ( xControl.is() )
430 removeControl( xControl );
431
433}
434
435// container::XContainer
436void UnoControlContainer::addContainerListener( const uno::Reference< container::XContainerListener >& rxListener )
437{
438 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
439
440 maCListeners.addInterface( rxListener );
441}
442
443void UnoControlContainer::removeContainerListener( const uno::Reference< container::XContainerListener >& rxListener )
444{
445 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
446
447 maCListeners.removeInterface( rxListener );
448}
449
450
451::sal_Int32 SAL_CALL UnoControlContainer::insert( const uno::Any& _rElement )
452{
453 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
454
455 uno::Reference< awt::XControl > xControl;
456 if ( !( _rElement >>= xControl ) || !xControl.is() )
457 throw lang::IllegalArgumentException(
458 "Elements must support the XControl interface.",
459 *this,
460 1
461 );
462
463 return impl_addControl( xControl );
464}
465
466void SAL_CALL UnoControlContainer::removeByIdentifier( ::sal_Int32 _nIdentifier )
467{
468 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
469
470 uno::Reference< awt::XControl > xControl;
471 if ( !mpControls->getControlForIdentifier( _nIdentifier, xControl ) )
472 throw container::NoSuchElementException(
473 "There is no element with the given identifier.",
474 *this
475 );
476
477 impl_removeControl( _nIdentifier, xControl );
478}
479
480void SAL_CALL UnoControlContainer::replaceByIdentifer( ::sal_Int32 _nIdentifier, const uno::Any& _rElement )
481{
482 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
483
484 uno::Reference< awt::XControl > xExistentControl;
485 if ( !mpControls->getControlForIdentifier( _nIdentifier, xExistentControl ) )
486 throw container::NoSuchElementException(
487 "There is no element with the given identifier.",
488 *this
489 );
490
491 uno::Reference< awt::XControl > xNewControl;
492 if ( !( _rElement >>= xNewControl ) )
493 throw lang::IllegalArgumentException(
494 "Elements must support the XControl interface.",
495 *this,
496 1
497 );
498
499 removingControl( xExistentControl );
500
501 mpControls->replaceControlById( _nIdentifier, xNewControl );
502
503 addingControl( xNewControl );
504
506
507 if ( maCListeners.getLength() )
508 {
509 container::ContainerEvent aEvent;
510 aEvent.Source = *this;
511 aEvent.Accessor <<= _nIdentifier;
512 aEvent.Element <<= xNewControl;
513 aEvent.ReplacedElement <<= xExistentControl;
514 maCListeners.elementReplaced( aEvent );
515 }
516}
517
518uno::Any SAL_CALL UnoControlContainer::getByIdentifier( ::sal_Int32 _nIdentifier )
519{
520 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
521
522 uno::Reference< awt::XControl > xControl;
523 if ( !mpControls->getControlForIdentifier( _nIdentifier, xControl ) )
524 throw container::NoSuchElementException();
525 return uno::Any( xControl );
526}
527
528uno::Sequence< ::sal_Int32 > SAL_CALL UnoControlContainer::getIdentifiers( )
529{
530 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
531
532 uno::Sequence< ::sal_Int32 > aIdentifiers;
533 mpControls->getIdentifiers( aIdentifiers );
534 return aIdentifiers;
535}
536
537// container::XElementAccess
539{
541}
542
544{
545 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
546 return !mpControls->empty();
547}
548
549// awt::XControlContainer
550void UnoControlContainer::setStatusText( const OUString& rStatusText )
551{
552 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
553
554 // Descend the parent hierarchy
555 uno::Reference< awt::XControlContainer > xContainer( mxContext, uno::UNO_QUERY );
556 if( xContainer.is() )
557 xContainer->setStatusText( rStatusText );
558}
559
560uno::Sequence< uno::Reference< awt::XControl > > UnoControlContainer::getControls( )
561{
562 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
563 uno::Sequence< uno::Reference< awt::XControl > > aControls;
564 mpControls->getControls( aControls );
565 return aControls;
566}
567
568uno::Reference< awt::XControl > UnoControlContainer::getControl( const OUString& rName )
569{
570 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
571 return mpControls->getControlForName( rName );
572}
573
574void UnoControlContainer::addingControl( const uno::Reference< awt::XControl >& _rxControl )
575{
576 if ( _rxControl.is() )
577 {
578 uno::Reference< uno::XInterface > xThis;
579 OWeakAggObject::queryInterface( cppu::UnoType<uno::XInterface>::get() ) >>= xThis;
580
581 _rxControl->setContext( xThis );
582 _rxControl->addEventListener( this );
583 }
584}
585
586void UnoControlContainer::impl_createControlPeerIfNecessary( const uno::Reference< awt::XControl >& _rxControl )
587{
588 OSL_PRECOND( _rxControl.is(), "UnoControlContainer::impl_createControlPeerIfNecessary: invalid control, this will crash!" );
589
590 // if the container already has a peer, then also create a peer for the control
591 uno::Reference< awt::XWindowPeer > xMyPeer( getPeer() );
592
593 if( xMyPeer.is() )
594 {
595 _rxControl->createPeer( nullptr, xMyPeer );
597 }
598
599}
600
601sal_Int32 UnoControlContainer::impl_addControl( const uno::Reference< awt::XControl >& _rxControl, const OUString* _pName )
602{
603 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
604 UnoControlHolderList::ControlIdentifier id = mpControls->addControl( _rxControl, _pName );
605
606 addingControl( _rxControl );
607
609
610 if ( maCListeners.getLength() )
611 {
612 container::ContainerEvent aEvent;
613 aEvent.Source = *this;
614 if (_pName)
615 aEvent.Accessor <<= *_pName;
616 else
617 aEvent.Accessor <<= static_cast<sal_Int32>(id);
618 aEvent.Element <<= _rxControl;
619 maCListeners.elementInserted( aEvent );
620 }
621
622 return id;
623}
624
625void UnoControlContainer::addControl( const OUString& rName, const uno::Reference< awt::XControl >& rControl )
626{
627 if ( rControl.is() )
628 impl_addControl( rControl, &rName );
629}
630
631void UnoControlContainer::removingControl( const uno::Reference< awt::XControl >& _rxControl )
632{
633 if ( _rxControl.is() )
634 {
635 _rxControl->removeEventListener( this );
636 _rxControl->setContext( nullptr );
637 }
638}
639
640void UnoControlContainer::impl_removeControl( sal_Int32 _nId, const uno::Reference< awt::XControl >& _rxControl )
641{
642#ifdef DBG_UTIL
643 {
644 uno::Reference< awt::XControl > xControl;
645 bool bHas = mpControls->getControlForIdentifier( _nId, xControl );
646 DBG_ASSERT( bHas && xControl == _rxControl, "UnoControlContainer::impl_removeControl: inconsistency in the parameters!" );
647 }
648#endif
649 removingControl( _rxControl );
650
651 mpControls->removeControlById( _nId );
652
653 if ( maCListeners.getLength() )
654 {
655 container::ContainerEvent aEvent;
656 aEvent.Source = *this;
657 aEvent.Accessor <<= _nId;
658 aEvent.Element <<= _rxControl;
659 maCListeners.elementRemoved( aEvent );
660 }
661}
662
663void UnoControlContainer::removeControl( const uno::Reference< awt::XControl >& _rxControl )
664{
665 if ( _rxControl.is() )
666 {
667 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
668
669 UnoControlHolderList::ControlIdentifier id = mpControls->getControlIdentifier( _rxControl );
670 if ( id != -1 )
671 impl_removeControl( id, _rxControl );
672 }
673}
674
675
676// awt::XUnoControlContainer
677void UnoControlContainer::setTabControllers( const uno::Sequence< uno::Reference< awt::XTabController > >& TabControllers )
678{
679 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
680
681 maTabControllers = TabControllers;
682}
683
684uno::Sequence< uno::Reference< awt::XTabController > > UnoControlContainer::getTabControllers( )
685{
686 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
687
688 return maTabControllers;
689}
690
691void UnoControlContainer::addTabController( const uno::Reference< awt::XTabController >& TabController )
692{
693 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
694
695 sal_uInt32 nCount = maTabControllers.getLength();
696 maTabControllers.realloc( nCount + 1 );
697 maTabControllers.getArray()[ nCount ] = TabController;
698}
699
700void UnoControlContainer::removeTabController( const uno::Reference< awt::XTabController >& TabController )
701{
702 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
703
704 auto pTabController = std::find_if(std::cbegin(maTabControllers), std::cend(maTabControllers),
705 [&TabController](const uno::Reference< awt::XTabController >& rTabController) {
706 return rTabController.get() == TabController.get(); });
707 if (pTabController != std::cend(maTabControllers))
708 {
709 auto n = static_cast<sal_Int32>(std::distance(std::cbegin(maTabControllers), pTabController));
710 ::comphelper::removeElementAt( maTabControllers, n );
711 }
712}
713
714// awt::XControl
715void UnoControlContainer::createPeer( const uno::Reference< awt::XToolkit >& rxToolkit, const uno::Reference< awt::XWindowPeer >& rParent )
716{
717 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
718
719 if( getPeer().is() )
720 return;
721
722 bool bVis = maComponentInfos.bVisible;
723 if( bVis )
724 UnoControl::setVisible( false );
725
726 // Create a new peer
727 UnoControl::createPeer( rxToolkit, rParent );
728
729 // Create all children's peers
730 if ( !mbCreatingCompatiblePeer )
731 {
732 // Evaluate "Step" property
733 uno::Reference< awt::XControlModel > xModel( getModel() );
734 uno::Reference< beans::XPropertySet > xPSet
735 ( xModel, uno::UNO_QUERY );
736 uno::Reference< beans::XPropertySetInfo >
737 xInfo = xPSet->getPropertySetInfo();
738 OUString aPropName( "Step" );
739 if ( xInfo->hasPropertyByName( aPropName ) )
740 {
741 css::uno::Any aVal = xPSet->getPropertyValue( aPropName );
742 sal_Int32 nDialogStep = 0;
743 aVal >>= nDialogStep;
744 uno::Reference< awt::XControlContainer > xContainer =
745 static_cast< awt::XControlContainer* >(this);
746 implUpdateVisibility( nDialogStep, xContainer );
747
748 uno::Reference< beans::XPropertyChangeListener > xListener =
749 new DialogStepChangedListener(xContainer);
750 xPSet->addPropertyChangeListener( aPropName, xListener );
751 }
752
753 uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls();
754 for( auto& rCtrl : asNonConstRange(aCtrls) )
755 rCtrl->createPeer( rxToolkit, getPeer() );
756
757 uno::Reference< awt::XVclContainerPeer > xC( getPeer(), uno::UNO_QUERY );
758 if ( xC.is() )
759 xC->enableDialogControl( true );
761 }
762
763 if( bVis && !isDesignMode() )
765}
766
767
768// awt::XWindow
770{
771 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
772
774 if( !mxContext.is() && bVisible )
775 // This is a Topwindow, thus show it automatically
776 createPeer( uno::Reference< awt::XToolkit > (), uno::Reference< awt::XWindowPeer > () );
777}
778
780{
781 return "stardiv.Toolkit.UnoControlContainer";
782}
783
785{
787 s.realloc(s.getLength() + 2);
788 auto ps = s.getArray();
789 ps[s.getLength() - 2] = "com.sun.star.awt.UnoControlContainer";
790 ps[s.getLength() - 1] = "stardiv.vcl.control.ControlContainer";
791 return s;
792}
793
794void UnoControlContainer::PrepareWindowDescriptor( css::awt::WindowDescriptor& rDesc )
795{
796 // HACK due to the fact that we can't really use VSCROLL & HSCROLL
797 // for Dialog ( css::awt::VclWindowPeerAttribute::VSCROLL
798 // has the same value as
799 // css::awt::WindowAttribute::NODECORATION )
800 // For convenience in the PropBrowse using HSCROLL and VSCROLL ensures
801 // the Correct text. We exchange them here and the control knows
802 // about this hack ( it sucks badly I know )
803 if ( rDesc.WindowAttributes & css::awt::VclWindowPeerAttribute::VSCROLL )
804 {
805 rDesc.WindowAttributes &= ~css::awt::VclWindowPeerAttribute::VSCROLL;
806 rDesc.WindowAttributes |= css::awt::VclWindowPeerAttribute::AUTOVSCROLL;
807 }
808 if ( rDesc.WindowAttributes & css::awt::VclWindowPeerAttribute::HSCROLL )
809 {
810 rDesc.WindowAttributes &= ~css::awt::VclWindowPeerAttribute::HSCROLL;
811 rDesc.WindowAttributes |= css::awt::VclWindowPeerAttribute::AUTOHSCROLL;
812 }
813}
814
815extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
817 css::uno::XComponentContext *,
818 css::uno::Sequence<css::uno::Any> const &)
819{
820 return cppu::acquire(new UnoControlContainer());
821}
822
823/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
virtual sal_Bool SAL_CALL hasElements() override
void SAL_CALL removeTabController(const css::uno::Reference< css::awt::XTabController > &TabController) override
virtual ~UnoControlContainer() override
virtual void PrepareWindowDescriptor(css::awt::WindowDescriptor &rDesc) override
void SAL_CALL addTabController(const css::uno::Reference< css::awt::XTabController > &TabController) override
void impl_removeControl(sal_Int32 _nId, const css::uno::Reference< css::awt::XControl > &_rxControl)
removes the given control from the container, including necessary notifications and the like
void SAL_CALL createPeer(const css::uno::Reference< css::awt::XToolkit > &Toolkit, const css::uno::Reference< css::awt::XWindowPeer > &Parent) override
OUString SAL_CALL getImplementationName() override
void SAL_CALL setTabControllers(const css::uno::Sequence< css::uno::Reference< css::awt::XTabController > > &TabControllers) override
css::uno::Sequence< css::uno::Reference< css::awt::XControl > > SAL_CALL getControls() override
virtual ::sal_Int32 SAL_CALL insert(const css::uno::Any &aElement) override
virtual void SAL_CALL removeByIdentifier(::sal_Int32 Identifier) override
void SAL_CALL setVisible(sal_Bool Visible) override
void SAL_CALL removeContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
css::uno::Sequence< css::uno::Reference< css::awt::XTabController > > SAL_CALL getTabControllers() override
virtual void addingControl(const css::uno::Reference< css::awt::XControl > &_rxControl)
virtual void impl_createControlPeerIfNecessary(const css::uno::Reference< css::awt::XControl > &_rxControl)
ensures that the given control has a peer, if necessary and possible
void SAL_CALL setStatusText(const OUString &StatusText) override
virtual void SAL_CALL replaceByIdentifer(::sal_Int32 Identifier, const css::uno::Any &aElement) override
css::uno::Sequence< css::uno::Reference< css::awt::XTabController > > maTabControllers
void SAL_CALL addControl(const OUString &Name, const css::uno::Reference< css::awt::XControl > &Control) override
std::unique_ptr< UnoControlHolderList > mpControls
virtual css::uno::Sequence< ::sal_Int32 > SAL_CALL getIdentifiers() override
css::uno::Reference< css::awt::XControl > SAL_CALL getControl(const OUString &aName) override
virtual css::uno::Type SAL_CALL getElementType() override
void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual css::uno::Any SAL_CALL getByIdentifier(::sal_Int32 Identifierr) override
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
void SAL_CALL addContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
void SAL_CALL removeControl(const css::uno::Reference< css::awt::XControl > &Control) override
ContainerListenerMultiplexer maCListeners
sal_Int32 impl_addControl(const css::uno::Reference< css::awt::XControl > &_rxControl, const OUString *_pName=nullptr)
adds the control to the container, does necessary notifications, and the like
virtual void removingControl(const css::uno::Reference< css::awt::XControl > &_rxControl)
void SAL_CALL dispose() override
bool empty() const
determines whether or not the list is empty
ControlIdentifier impl_addControl(const uno::Reference< awt::XControl > &_rxControl, const OUString *_pName)
adds a control
::std::map< ControlIdentifier, ControlInfo > ControlMap
ControlIdentifier addControl(const uno::Reference< awt::XControl > &_rxControl, const OUString *_pName)
adds a control with the given name to the list
void removeControlById(ControlIdentifier _nId)
removes a control from the list, given by id
ControlIdentifier getControlIdentifier(const uno::Reference< awt::XControl > &_rxControl)
returns the identifier which a control is registered for, or -1 if the control isn't registered
OUString impl_getFreeName_throw()
finds a free name
uno::Reference< awt::XControl > getControlForName(const OUString &_rName) const
returns the first control which is registered under the given name
bool getControlForIdentifier(ControlIdentifier _nIdentifier, uno::Reference< awt::XControl > &_out_rxControl) const
retrieves the control for a given id
ControlIdentifier impl_getFreeIdentifier_throw()
finds a free identifier
void replaceControlById(ControlIdentifier _nId, const uno::Reference< awt::XControl > &_rxNewControl)
replaces a control from the list with another one
std::shared_ptr< UnoControlHolder > ControlInfo
void getControls(uno::Sequence< uno::Reference< awt::XControl > > &_out_rControls) const
retrieves all controls currently in the list
void getIdentifiers(uno::Sequence< sal_Int32 > &_out_rIdentifiers) const
retrieves all identifiers of all controls currently in the list
void SAL_CALL dispose() override
Definition: unocontrol.cxx:346
void SAL_CALL setVisible(sal_Bool Visible) override
Definition: unocontrol.cxx:769
void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: unocontrol.cxx:654
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
void SAL_CALL createPeer(const css::uno::Reference< css::awt::XToolkit > &Toolkit, const css::uno::Reference< css::awt::XWindowPeer > &Parent) override
css::uno::Type const & get()
int nCount
#define DBG_ASSERT(sCon, aError)
uno::Reference< uno::XComponentContext > mxContext
OUString sName
OUString aName
sal_Int64 n
::cppu::WeakImplHelper< css::beans::XPropertyChangeListener > PropertyChangeListenerHelper
OUString aPropName
sal_Int16 nId
Reference< XModel > xModel
OUString msName
bool bVisible
unsigned char sal_Bool
::cppu::WeakImplHelper< beans::XPropertyChangeListener > PropertyChangeListenerHelper
static void implUpdateVisibility(sal_Int32 nDialogStep, const uno::Reference< awt::XControlContainer > &xControlContainer)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * stardiv_Toolkit_UnoControlContainer_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
size_t pos