1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "composeduiupdate.hxx"
22 #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
23 #include <com/sun/star/lang/DisposedException.hpp>
24 #include <com/sun/star/lang/NullPointerException.hpp>
25 #include <com/sun/star/inspection/PropertyLineElement.hpp>
26 #include <osl/mutex.hxx>
27 #include <rtl/ref.hxx>
28 #include <cppuhelper/implbase.hxx>
37 using ::com::sun::star::lang::DisposedException
;
38 using ::com::sun::star::lang::NullPointerException
;
39 using ::com::sun::star::inspection::XPropertyHandler
;
40 using ::com::sun::star::uno::Reference
;
41 using ::com::sun::star::inspection::XObjectInspectorUI
;
42 using ::com::sun::star::inspection::XPropertyControl
;
43 using ::com::sun::star::inspection::XPropertyControlObserver
;
45 namespace PropertyLineElement
= ::com::sun::star::inspection::PropertyLineElement
;
51 bool operator()( const Reference
< XPropertyHandler
>& lhs
, const Reference
< XPropertyHandler
>& rhs
) const
53 return lhs
.get() < rhs
.get();
58 typedef std::set
< OUString
> StringBag
;
59 typedef std::map
< sal_Int16
, StringBag
> MapIntToStringBag
;
63 // callbacks for CachedInspectorUI
65 typedef void (ComposedPropertyUIUpdate::*FNotifySingleUIChange
)();
67 typedef ::cppu::WeakImplHelper
< css::inspection::XObjectInspectorUI
68 > CachedInspectorUI_Base
;
69 struct CachedInspectorUI
: public CachedInspectorUI_Base
72 ::osl::Mutex m_aMutex
;
74 ComposedPropertyUIUpdate
&
76 FNotifySingleUIChange m_pUIChangeNotification
;
78 // enablePropertyUI cache
79 StringBag aEnabledProperties
;
80 StringBag aDisabledProperties
;
82 // show/hidePropertyUI cache
83 StringBag aShownProperties
;
84 StringBag aHiddenProperties
;
86 // rebuildPropertyUI cache
87 StringBag aRebuiltProperties
;
90 StringBag aShownCategories
;
91 StringBag aHiddenCategories
;
93 // enablePropertyUIElements cache
94 MapIntToStringBag aEnabledElements
;
95 MapIntToStringBag aDisabledElements
;
98 typedef StringBag
& (CachedInspectorUI::*FGetStringBag
)();
100 // enablePropertyUI cache
101 StringBag
& getEnabledProperties() { return aEnabledProperties
; }
102 StringBag
& getDisabledProperties() { return aDisabledProperties
; }
104 // show/hidePropertyUI cache
105 StringBag
& getShownProperties() { return aShownProperties
; }
106 StringBag
& getHiddenProperties() { return aHiddenProperties
; }
108 // rebuildPropertyUI cache
109 StringBag
& getRebuiltProperties() { return aRebuiltProperties
; }
111 // showCategory cache
112 StringBag
& getShownCategories() { return aShownCategories
; }
113 StringBag
& getHiddenCategories() { return aHiddenCategories
; }
115 // enablePropertyUIElements
116 StringBag
& getEnabledInputControls() { return aEnabledElements
[ PropertyLineElement::InputControl
]; }
117 StringBag
& getDisabledInputControls() { return aDisabledElements
[ PropertyLineElement::InputControl
]; }
118 StringBag
& getEnabledPrimaryButtons() { return aEnabledElements
[ PropertyLineElement::PrimaryButton
]; }
119 StringBag
& getDisabledPrimaryButtons() { return aDisabledElements
[ PropertyLineElement::PrimaryButton
]; }
120 StringBag
& getEnabledSecondaryButtons() { return aEnabledElements
[ PropertyLineElement::SecondaryButton
]; }
121 StringBag
& getDisabledSecondaryButtons() { return aDisabledElements
[ PropertyLineElement::SecondaryButton
]; }
124 CachedInspectorUI( ComposedPropertyUIUpdate
& _rMaster
, FNotifySingleUIChange _pUIChangeNotification
);
125 CachedInspectorUI(const CachedInspectorUI
&) = delete;
126 CachedInspectorUI
& operator=(const CachedInspectorUI
&) = delete;
128 /// disposes the instance
131 // XObjectInspectorUI overridables
132 virtual void SAL_CALL
enablePropertyUI( const OUString
& _rPropertyName
, sal_Bool _bEnable
) override
;
133 virtual void SAL_CALL
enablePropertyUIElements( const OUString
& _rPropertyName
, ::sal_Int16 _nElements
, sal_Bool _bEnable
) override
;
134 virtual void SAL_CALL
rebuildPropertyUI( const OUString
& _rPropertyName
) override
;
135 virtual void SAL_CALL
showPropertyUI( const OUString
& _rPropertyName
) override
;
136 virtual void SAL_CALL
hidePropertyUI( const OUString
& _rPropertyName
) override
;
137 virtual void SAL_CALL
showCategory( const OUString
& _rCategory
, sal_Bool _bShow
) override
;
138 virtual Reference
< XPropertyControl
> SAL_CALL
getPropertyControl( const OUString
& _rPropertyName
) override
;
139 virtual void SAL_CALL
registerControlObserver( const Reference
< XPropertyControlObserver
>& Observer
) override
;
140 virtual void SAL_CALL
revokeControlObserver( const Reference
< XPropertyControlObserver
>& Observer
) override
;
141 virtual void SAL_CALL
setHelpSectionText( const OUString
& HelpText
) override
;
144 virtual ~CachedInspectorUI() override
;
146 /// throws an exception if the component is already disposed
147 void checkDisposed() const;
150 void impl_markElementEnabledOrDisabled( const OUString
& _rPropertyName
, sal_Int16 _nElementIdOrZero
, bool _bEnable
);
152 /** calls <member>m_pUIChangeNotification</member> at <member>m_rMaster</member>
154 void impl_notifySingleUIChange() const;
158 friend class MethodGuard
;
159 class MethodGuard
: public ::osl::MutexGuard
162 explicit MethodGuard( CachedInspectorUI
& rInstance
)
163 : ::osl::MutexGuard( rInstance
.m_aMutex
)
165 rInstance
.checkDisposed();
171 CachedInspectorUI::CachedInspectorUI( ComposedPropertyUIUpdate
& _rMaster
, FNotifySingleUIChange _pUIChangeNotification
)
172 :m_bDisposed( false )
173 ,m_rMaster( _rMaster
)
174 ,m_pUIChangeNotification( _pUIChangeNotification
)
179 CachedInspectorUI::~CachedInspectorUI()
184 void CachedInspectorUI::dispose()
186 ::osl::MutexGuard
aGuard( m_aMutex
);
189 clearContainer( aEnabledProperties
);
190 clearContainer( aDisabledProperties
);
191 clearContainer( aRebuiltProperties
);
192 clearContainer( aShownProperties
);
193 clearContainer( aHiddenProperties
);
194 clearContainer( aShownCategories
);
195 clearContainer( aHiddenCategories
);
196 clearContainer( aEnabledElements
);
197 clearContainer( aDisabledElements
);
201 void CachedInspectorUI::checkDisposed() const
204 throw DisposedException();
210 void lcl_markStringKeyPositiveOrNegative( const OUString
& _rKeyName
, StringBag
& _rPositives
, StringBag
& _rNegatives
, bool _bMarkPositive
)
212 if ( _bMarkPositive
)
214 _rPositives
.insert( _rKeyName
);
215 // if the same key has been remember as in the "negative" list before, clear this information, since it's overruled
216 _rNegatives
.erase( _rKeyName
);
219 _rNegatives
.insert( _rKeyName
);
224 void CachedInspectorUI::enablePropertyUI( const OUString
& _rPropertyName
, sal_Bool _bEnable
)
226 MethodGuard
aGuard( *this );
227 if ( !m_rMaster
.shouldContinuePropertyHandling( _rPropertyName
) )
230 lcl_markStringKeyPositiveOrNegative( _rPropertyName
, aEnabledProperties
, aDisabledProperties
, _bEnable
);
231 impl_notifySingleUIChange();
235 void CachedInspectorUI::impl_markElementEnabledOrDisabled( const OUString
& _rPropertyName
, sal_Int16 _nElementIdOrZero
, bool _bEnable
)
237 if ( _nElementIdOrZero
== 0 )
240 lcl_markStringKeyPositiveOrNegative(
242 aEnabledElements
[ _nElementIdOrZero
],
243 aDisabledElements
[ _nElementIdOrZero
],
249 void CachedInspectorUI::impl_notifySingleUIChange() const
251 (m_rMaster
.*m_pUIChangeNotification
)();
255 void CachedInspectorUI::enablePropertyUIElements( const OUString
& _rPropertyName
, sal_Int16 _nElements
, sal_Bool _bEnable
)
257 MethodGuard
aGuard( *this );
258 if ( !m_rMaster
.shouldContinuePropertyHandling( _rPropertyName
) )
261 impl_markElementEnabledOrDisabled( _rPropertyName
, _nElements
& PropertyLineElement::InputControl
, _bEnable
);
262 impl_markElementEnabledOrDisabled( _rPropertyName
, _nElements
& PropertyLineElement::PrimaryButton
, _bEnable
);
263 impl_markElementEnabledOrDisabled( _rPropertyName
, _nElements
& PropertyLineElement::SecondaryButton
, _bEnable
);
265 impl_notifySingleUIChange();
269 void CachedInspectorUI::rebuildPropertyUI( const OUString
& _rPropertyName
)
271 MethodGuard
aGuard( *this );
272 if ( !m_rMaster
.shouldContinuePropertyHandling( _rPropertyName
) )
275 aRebuiltProperties
.insert( _rPropertyName
);
277 impl_notifySingleUIChange();
281 void CachedInspectorUI::showPropertyUI( const OUString
& _rPropertyName
)
283 MethodGuard
aGuard( *this );
284 if ( !m_rMaster
.shouldContinuePropertyHandling( _rPropertyName
) )
287 aShownProperties
.insert( _rPropertyName
);
288 // if the same category has been hidden before, clear this information, since it's overruled
289 aHiddenProperties
.erase( _rPropertyName
);
291 impl_notifySingleUIChange();
295 void CachedInspectorUI::hidePropertyUI( const OUString
& _rPropertyName
)
297 MethodGuard
aGuard( *this );
298 if ( !m_rMaster
.shouldContinuePropertyHandling( _rPropertyName
) )
301 aHiddenProperties
.insert( _rPropertyName
);
302 impl_notifySingleUIChange();
306 void CachedInspectorUI::showCategory( const OUString
& _rCategory
, sal_Bool _bShow
)
308 MethodGuard
aGuard( *this );
310 lcl_markStringKeyPositiveOrNegative( _rCategory
, aShownCategories
, aHiddenCategories
, _bShow
);
311 impl_notifySingleUIChange();
315 Reference
< XPropertyControl
> SAL_CALL
CachedInspectorUI::getPropertyControl( const OUString
& _rPropertyName
)
317 MethodGuard
aGuard( *this );
318 if ( !m_rMaster
.shouldContinuePropertyHandling( _rPropertyName
) )
319 return Reference
< XPropertyControl
>();
321 return m_rMaster
.getDelegatorUI()->getPropertyControl( _rPropertyName
);
325 void SAL_CALL
CachedInspectorUI::registerControlObserver( const Reference
< XPropertyControlObserver
>& Observer
)
327 OSL_FAIL( "CachedInspectorUI::registerControlObserver: not expected to be called!" );
328 // CachedInspectorUI is used as context for the controls, and we don't expect them to
329 // register listeners themself
330 m_rMaster
.getDelegatorUI()->registerControlObserver( Observer
);
334 void SAL_CALL
CachedInspectorUI::revokeControlObserver( const Reference
< XPropertyControlObserver
>& Observer
)
336 OSL_FAIL( "CachedInspectorUI::revokeControlObserver: not expected to be called!" );
337 // CachedInspectorUI is used as context for the controls, and we don't expect them to
338 // register listeners themself
339 m_rMaster
.getDelegatorUI()->revokeControlObserver( Observer
);
343 void SAL_CALL
CachedInspectorUI::setHelpSectionText( const OUString
& HelpText
)
345 m_rMaster
.getDelegatorUI()->setHelpSectionText( HelpText
);
351 typedef std::map
< Reference
< XPropertyHandler
>
352 , ::rtl::Reference
< CachedInspectorUI
>
354 > ImplMapHandlerToUI
;
355 struct MapHandlerToUI
357 ImplMapHandlerToUI aHandlers
;
360 ComposedPropertyUIUpdate::ComposedPropertyUIUpdate( const Reference
< XObjectInspectorUI
>& _rxDelegatorUI
,
361 IPropertyExistenceCheck
* _pPropertyCheck
)
362 :m_pCollectedUIs( new MapHandlerToUI
)
363 ,m_xDelegatorUI( _rxDelegatorUI
)
364 ,m_nSuspendCounter( 0 )
365 ,m_pPropertyCheck( _pPropertyCheck
)
367 if ( !m_xDelegatorUI
.is() )
368 throw NullPointerException();
372 ComposedPropertyUIUpdate::~ComposedPropertyUIUpdate( )
377 Reference
< XObjectInspectorUI
> ComposedPropertyUIUpdate::getUIForPropertyHandler( const Reference
< XPropertyHandler
>& _rxHandler
)
379 impl_checkDisposed();
381 ::rtl::Reference
< CachedInspectorUI
>& rUI
= m_pCollectedUIs
->aHandlers
[ _rxHandler
];
383 rUI
= new CachedInspectorUI( *this, &ComposedPropertyUIUpdate::callback_inspectorUIChanged_throw
);
391 // an STL-compatible structure which collects strings from a CachedInspectorUI instances
392 struct StringBagCollector
396 CachedInspectorUI::FGetStringBag m_pGetter
;
399 StringBagCollector( StringBag
& _rBag
, CachedInspectorUI::FGetStringBag _pGetter
) :m_rBag( _rBag
), m_pGetter( _pGetter
) { }
401 void operator()( const ImplMapHandlerToUI::value_type
& _rUI
)
403 StringBag
& rBag( ((_rUI
.second
.get())->*m_pGetter
)() );
404 m_rBag
.insert( rBag
.begin(), rBag
.end() );
407 static void collectAll( StringBag
& _rAll
, const ImplMapHandlerToUI
& _rMap
, CachedInspectorUI::FGetStringBag _pGetter
)
409 std::for_each( _rMap
.begin(), _rMap
.end(), StringBagCollector( _rAll
, _pGetter
) );
414 // an STL-compatible structure which cleans a certain string bag in a CachedInspectorUI instances
415 struct StringBagClearer
418 CachedInspectorUI::FGetStringBag m_pGetter
;
421 explicit StringBagClearer( CachedInspectorUI::FGetStringBag _pGetter
) :m_pGetter( _pGetter
) { }
423 void operator()( const ImplMapHandlerToUI::value_type
& _rUI
)
425 clearContainer( ((_rUI
.second
.get())->*m_pGetter
)() );
428 static void clearAll( const ImplMapHandlerToUI
& _rMap
, CachedInspectorUI::FGetStringBag _pGetter
)
430 std::for_each( _rMap
.begin(), _rMap
.end(), StringBagClearer( _pGetter
) );
434 // a typedef for a ->XObjectInspectorUI member function taking a string
435 typedef void ( SAL_CALL
XObjectInspectorUI::*FPropertyUISetter
)( const OUString
& );
438 // an STL-compatible struct which calls a certain member method (taking a string) at a
439 // given ->XObjectInspectorUI instance
440 struct PropertyUIOperator
443 Reference
< XObjectInspectorUI
> m_xUpdater
;
444 FPropertyUISetter m_pSetter
;
447 PropertyUIOperator( const Reference
< XObjectInspectorUI
>& _rxInspectorUI
, FPropertyUISetter _pSetter
)
448 :m_xUpdater( _rxInspectorUI
)
449 ,m_pSetter( _pSetter
)
453 void operator()( const OUString
& _rPropertyName
)
455 ((m_xUpdater
.get())->*m_pSetter
)( _rPropertyName
);
458 static void forEach( const StringBag
& _rProperties
, const Reference
< XObjectInspectorUI
>& _rxDelegatorUI
, FPropertyUISetter _pSetter
)
460 std::for_each( _rProperties
.begin(), _rProperties
.end(), PropertyUIOperator( _rxDelegatorUI
, _pSetter
) );
465 // an interface which encapsulates access to a single aspect of the ->XObjectInspectorUI,
466 // where this aspect is given by a string key, and has a boolean value.
467 class IStringKeyBooleanUIUpdate
470 virtual void updateUIForKey( const OUString
& _rKey
, bool _bFlag
) const = 0;
472 virtual ~IStringKeyBooleanUIUpdate() { }
476 // FPropertyUIFlagSetter
478 /** an implementation of the ->IStringKeyBooleanUIUpdate interface which,
479 for a fixed ->XObjectInspectorUI instance and a fixed UI element (->PropertyLineElement),
480 updates this element for a given property with a given boolean flag
481 (->XObjectInspectorUI::enablePropertyUIElements)
483 class EnablePropertyUIElement
: public IStringKeyBooleanUIUpdate
486 Reference
< XObjectInspectorUI
> m_xUIUpdate
;
487 sal_Int16 m_nElement
;
490 EnablePropertyUIElement( const Reference
< XObjectInspectorUI
>& _rxUIUpdate
, sal_Int16 _nElement
)
491 :m_xUIUpdate( _rxUIUpdate
)
492 ,m_nElement( _nElement
)
495 // IStringKeyBooleanUIUpdate
496 virtual void updateUIForKey( const OUString
& _rKey
, bool _bFlag
) const override
;
500 void EnablePropertyUIElement::updateUIForKey( const OUString
& _rKey
, bool _bFlag
) const
502 m_xUIUpdate
->enablePropertyUIElements( _rKey
, m_nElement
, _bFlag
);
506 // a ->XObjectInspectorUI method taking a string and a boolean
507 typedef void ( SAL_CALL
XObjectInspectorUI::*FPropertyUIFlagSetter
)( const OUString
&, sal_Bool
);
510 // an implementation of the ->IStringKeyBooleanUIUpdate interface which calls
511 // am arbitrary ->XObjectInspectorUI method taking a string and a boolean flag
512 class DefaultStringKeyBooleanUIUpdate
: public IStringKeyBooleanUIUpdate
515 Reference
< XObjectInspectorUI
> m_xUIUpdate
;
516 FPropertyUIFlagSetter m_pSetter
;
519 DefaultStringKeyBooleanUIUpdate( const Reference
< XObjectInspectorUI
>& _rxUIUpdate
, FPropertyUIFlagSetter _pSetter
);
520 // IStringKeyBooleanUIUpdate
521 virtual void updateUIForKey( const OUString
& _rKey
, bool _bFlag
) const override
;
525 DefaultStringKeyBooleanUIUpdate::DefaultStringKeyBooleanUIUpdate( const Reference
< XObjectInspectorUI
>& _rxUIUpdate
, FPropertyUIFlagSetter _pSetter
)
526 :m_xUIUpdate( _rxUIUpdate
)
527 ,m_pSetter( _pSetter
)
532 void DefaultStringKeyBooleanUIUpdate::updateUIForKey( const OUString
& _rKey
, bool _bFlag
) const
534 ((m_xUIUpdate
.get())->*m_pSetter
)( _rKey
, _bFlag
);
538 // an STL-compatible structure which applies a ->IStringKeyBooleanUIUpdate::updateUIForKey
539 // operation with a fixed boolean value, for a given string value
540 struct BooleanUIAspectUpdate
543 const IStringKeyBooleanUIUpdate
& m_rUpdater
;
547 BooleanUIAspectUpdate( const IStringKeyBooleanUIUpdate
& _rUpdater
, bool _bFlag
)
548 :m_rUpdater( _rUpdater
)
553 void operator()( const OUString
& _rPropertyName
)
555 m_rUpdater
.updateUIForKey( _rPropertyName
, m_bFlag
);
558 static void forEach( const StringBag
& _rProperties
, const IStringKeyBooleanUIUpdate
& _rUpdater
, bool _bFlag
)
560 std::for_each( _rProperties
.begin(), _rProperties
.end(), BooleanUIAspectUpdate( _rUpdater
, _bFlag
) );
565 // BooleanUIAspectUpdate
567 // an STL-compatible structure subtracting a given string from a fixed ->StringBag
568 struct StringBagComplement
571 StringBag
& m_rMinuend
;
574 explicit StringBagComplement( StringBag
& _rMinuend
) :m_rMinuend( _rMinuend
) { }
576 void operator()( const OUString
& _rPropertyToSubtract
)
578 m_rMinuend
.erase( _rPropertyToSubtract
);
581 static void subtract( StringBag
& _rMinuend
, const StringBag
& _rSubtrahend
)
583 std::for_each( _rSubtrahend
.begin(), _rSubtrahend
.end(), StringBagComplement( _rMinuend
) );
588 // BooleanUIAspectUpdate
590 void lcl_fireUIStateFlag(
591 const IStringKeyBooleanUIUpdate
& _rUIUpdate
,
592 const ImplMapHandlerToUI
& _rHandlerUIs
,
593 CachedInspectorUI::FGetStringBag _pGetPositives
,
594 CachedInspectorUI::FGetStringBag _pGetNegatives
597 // all strings which are in the "positive" list of one handler
598 StringBag aAllPositives
;
599 StringBagCollector::collectAll( aAllPositives
, _rHandlerUIs
, _pGetPositives
);
601 // all strings which are in the "negative" list of one handler
602 StringBag aAllNegatives
;
603 StringBagCollector::collectAll( aAllNegatives
, _rHandlerUIs
, _pGetNegatives
);
605 // propagate the "negative" flags to the delegator UI
606 BooleanUIAspectUpdate::forEach( aAllNegatives
, _rUIUpdate
, false );
608 // propagate the "positive" flags to the delegator UI, for all elements where _no_
609 // "negative" flag exists
610 StringBagComplement::subtract( aAllPositives
, aAllNegatives
);
611 BooleanUIAspectUpdate::forEach( aAllPositives
, _rUIUpdate
, true );
613 // the "positive" request can be cleared no, only negative requests
614 // (such as "disable a property" or "hide a category") need to be preserved for the next round
615 StringBagClearer::clearAll( _rHandlerUIs
, _pGetPositives
);
620 void ComposedPropertyUIUpdate::impl_fireEnablePropertyUI_throw()
623 DefaultStringKeyBooleanUIUpdate( m_xDelegatorUI
, &XObjectInspectorUI::enablePropertyUI
),
624 m_pCollectedUIs
->aHandlers
,
625 &CachedInspectorUI::getEnabledProperties
,
626 &CachedInspectorUI::getDisabledProperties
631 void ComposedPropertyUIUpdate::impl_fireRebuildPropertyUI_throw()
633 // collect all properties for which a rebuild request has been made
634 StringBag aAllRebuilt
;
635 StringBagCollector::collectAll( aAllRebuilt
, m_pCollectedUIs
->aHandlers
, &CachedInspectorUI::getRebuiltProperties
);
637 // rebuild all those properties
638 PropertyUIOperator::forEach( aAllRebuilt
, m_xDelegatorUI
, &XObjectInspectorUI::rebuildPropertyUI
);
640 // clear the "properties to rebuild" at all handlers, since the request has been fulfilled now.
641 StringBagClearer::clearAll( m_pCollectedUIs
->aHandlers
, &CachedInspectorUI::getRebuiltProperties
);
645 void ComposedPropertyUIUpdate::impl_fireShowHidePropertyUI_throw()
647 // all properties which have been shown by at least one handler
649 StringBagCollector::collectAll( aAllShown
, m_pCollectedUIs
->aHandlers
, &CachedInspectorUI::getShownProperties
);
650 // all properties which have been hidden by at least one handler
651 StringBag aAllHidden
;
652 StringBagCollector::collectAll( aAllHidden
, m_pCollectedUIs
->aHandlers
, &CachedInspectorUI::getHiddenProperties
);
654 // hide properties as necessary
655 PropertyUIOperator::forEach( aAllHidden
, m_xDelegatorUI
, &XObjectInspectorUI::hidePropertyUI
);
657 // for those properties which are hidden, ignore all "show" requests which other handlers might have had
658 StringBagComplement::subtract( aAllShown
, aAllHidden
);
661 PropertyUIOperator::forEach( aAllShown
, m_xDelegatorUI
, &XObjectInspectorUI::showPropertyUI
);
665 void ComposedPropertyUIUpdate::impl_fireShowCategory_throw()
668 DefaultStringKeyBooleanUIUpdate( m_xDelegatorUI
, &XObjectInspectorUI::showCategory
),
669 m_pCollectedUIs
->aHandlers
,
670 &CachedInspectorUI::getShownCategories
,
671 &CachedInspectorUI::getHiddenCategories
676 void ComposedPropertyUIUpdate::impl_fireEnablePropertyUIElements_throw()
679 EnablePropertyUIElement( m_xDelegatorUI
, PropertyLineElement::InputControl
),
680 m_pCollectedUIs
->aHandlers
,
681 &CachedInspectorUI::getEnabledInputControls
,
682 &CachedInspectorUI::getDisabledInputControls
686 EnablePropertyUIElement( m_xDelegatorUI
, PropertyLineElement::PrimaryButton
),
687 m_pCollectedUIs
->aHandlers
,
688 &CachedInspectorUI::getEnabledPrimaryButtons
,
689 &CachedInspectorUI::getDisabledPrimaryButtons
693 EnablePropertyUIElement( m_xDelegatorUI
, PropertyLineElement::SecondaryButton
),
694 m_pCollectedUIs
->aHandlers
,
695 &CachedInspectorUI::getEnabledSecondaryButtons
,
696 &CachedInspectorUI::getDisabledSecondaryButtons
701 void ComposedPropertyUIUpdate::impl_fireAll_throw()
703 OSL_PRECOND( !impl_isDisposed(), "ComposedPropertyUIUpdate::impl_fireAll_throw: already disposed, this will crash!" );
705 impl_fireEnablePropertyUI_throw();
706 impl_fireShowHidePropertyUI_throw();
707 impl_fireRebuildPropertyUI_throw();
708 impl_fireShowCategory_throw();
709 impl_fireEnablePropertyUIElements_throw();
713 void ComposedPropertyUIUpdate::suspendAutoFire()
715 impl_checkDisposed();
716 osl_atomic_increment( &m_nSuspendCounter
);
720 void ComposedPropertyUIUpdate::resumeAutoFire()
722 impl_checkDisposed();
723 if ( 0 == osl_atomic_decrement( &m_nSuspendCounter
) )
724 impl_fireAll_throw();
728 void ComposedPropertyUIUpdate::impl_checkDisposed() const
730 if ( impl_isDisposed() )
731 throw DisposedException();
735 void ComposedPropertyUIUpdate::callback_inspectorUIChanged_throw()
737 if ( 0 == m_nSuspendCounter
)
738 impl_fireAll_throw();
742 Reference
< XObjectInspectorUI
> const & ComposedPropertyUIUpdate::getDelegatorUI() const
744 impl_checkDisposed();
745 return m_xDelegatorUI
;
749 void ComposedPropertyUIUpdate::dispose()
751 if ( impl_isDisposed() )
754 OSL_ENSURE( m_nSuspendCounter
== 0, "ComposedPropertyUIUpdate::dispose: still suspended, the changes will be lost!" );
756 for (auto const& singleUI
: m_pCollectedUIs
->aHandlers
)
758 singleUI
.second
->dispose();
760 m_pCollectedUIs
.reset();
761 m_xDelegatorUI
.set( nullptr );
765 bool ComposedPropertyUIUpdate::shouldContinuePropertyHandling( const OUString
& _rName
) const
767 if ( !m_pPropertyCheck
)
769 if ( m_pPropertyCheck
->hasPropertyByName( _rName
) )
778 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */