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 <boost/noncopyable.hpp>
23 #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
24 #include <com/sun/star/lang/DisposedException.hpp>
25 #include <com/sun/star/inspection/PropertyLineElement.hpp>
26 #include <osl/mutex.hxx>
27 #include <rtl/ref.hxx>
36 using ::com::sun::star::uno::Exception
;
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::uno::RuntimeException
;
44 using ::com::sun::star::lang::NoSupportException
;
45 using ::com::sun::star::inspection::XPropertyControlObserver
;
47 namespace PropertyLineElement
= ::com::sun::star::inspection::PropertyLineElement
;
51 struct HandlerLess
: public ::std::binary_function
< Reference
< XPropertyHandler
>
52 , Reference
< XPropertyHandler
>
56 bool operator()( const Reference
< XPropertyHandler
>& lhs
, const Reference
< XPropertyHandler
>& rhs
) const
58 return lhs
.get() < rhs
.get();
63 typedef ::std::set
< OUString
> StringBag
;
64 typedef ::std::map
< sal_Int16
, StringBag
> MapIntToStringBag
;
68 // callbacks for CachedInspectorUI
70 typedef void (ComposedPropertyUIUpdate::*FNotifySingleUIChange
)();
72 typedef ::cppu::WeakImplHelper1
< ::com::sun::star::inspection::XObjectInspectorUI
73 > CachedInspectorUI_Base
;
74 struct CachedInspectorUI
:
75 public CachedInspectorUI_Base
, private boost::noncopyable
78 ::osl::Mutex m_aMutex
;
80 ComposedPropertyUIUpdate
&
82 FNotifySingleUIChange m_pUIChangeNotification
;
84 // enablePropertyUI cache
85 StringBag aEnabledProperties
;
86 StringBag aDisabledProperties
;
88 // show/hidePropertyUI cache
89 StringBag aShownProperties
;
90 StringBag aHiddenProperties
;
92 // rebuildPropertyUI cache
93 StringBag aRebuiltProperties
;
96 StringBag aShownCategories
;
97 StringBag aHiddenCategories
;
99 // enablePropertyUIElements cache
100 MapIntToStringBag aEnabledElements
;
101 MapIntToStringBag aDisabledElements
;
104 typedef StringBag
& (CachedInspectorUI::*FGetStringBag
)();
106 // enablePropertyUI cache
107 StringBag
& getEnabledProperties() { return aEnabledProperties
; }
108 StringBag
& getDisabledProperties() { return aDisabledProperties
; }
110 // show/hidePropertyUI cache
111 StringBag
& getShownProperties() { return aShownProperties
; }
112 StringBag
& getHiddenProperties() { return aHiddenProperties
; }
114 // rebuildPropertyUI cache
115 StringBag
& getRebuiltProperties() { return aRebuiltProperties
; }
117 // showCategory cache
118 StringBag
& getShownCategories() { return aShownCategories
; }
119 StringBag
& getHiddenCategories() { return aHiddenCategories
; }
121 // enablePropertyUIElements
122 StringBag
& getEnabledInputControls() { return aEnabledElements
[ PropertyLineElement::InputControl
]; }
123 StringBag
& getDisabledInputControls() { return aDisabledElements
[ PropertyLineElement::InputControl
]; }
124 StringBag
& getEnabledPrimaryButtons() { return aEnabledElements
[ PropertyLineElement::PrimaryButton
]; }
125 StringBag
& getDisabledPrimaryButtons() { return aDisabledElements
[ PropertyLineElement::PrimaryButton
]; }
126 StringBag
& getEnabledSecondaryButtons() { return aEnabledElements
[ PropertyLineElement::SecondaryButton
]; }
127 StringBag
& getDisabledSecondaryButtons() { return aDisabledElements
[ PropertyLineElement::SecondaryButton
]; }
130 CachedInspectorUI( ComposedPropertyUIUpdate
& _rMaster
, FNotifySingleUIChange _pUIChangeNotification
);
132 /// disposes the instance
135 // XObjectInspectorUI overridables
136 virtual void SAL_CALL
enablePropertyUI( const OUString
& _rPropertyName
, sal_Bool _bEnable
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
137 virtual void SAL_CALL
enablePropertyUIElements( const OUString
& _rPropertyName
, ::sal_Int16 _nElements
, sal_Bool _bEnable
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
138 virtual void SAL_CALL
rebuildPropertyUI( const OUString
& _rPropertyName
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
139 virtual void SAL_CALL
showPropertyUI( const OUString
& _rPropertyName
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
140 virtual void SAL_CALL
hidePropertyUI( const OUString
& _rPropertyName
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
141 virtual void SAL_CALL
showCategory( const OUString
& _rCategory
, sal_Bool _bShow
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
142 virtual Reference
< XPropertyControl
> SAL_CALL
getPropertyControl( const OUString
& _rPropertyName
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
143 virtual void SAL_CALL
registerControlObserver( const Reference
< XPropertyControlObserver
>& Observer
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
144 virtual void SAL_CALL
revokeControlObserver( const Reference
< XPropertyControlObserver
>& Observer
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
145 virtual void SAL_CALL
setHelpSectionText( const OUString
& _HelpText
) throw (NoSupportException
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
147 // UNOCompatibleNonUNOReference overridables
148 virtual void SAL_CALL
acquire() throw() SAL_OVERRIDE
;
149 virtual void SAL_CALL
release() throw() SAL_OVERRIDE
;
152 virtual ~CachedInspectorUI();
154 /// determines whether the instance is already disposed
155 inline bool isDisposed() const { return m_bDisposed
; }
157 /// throws an exception if the component is already disposed
158 void checkDisposed() const;
161 void impl_markElementEnabledOrDisabled( const OUString
& _rPropertyName
, sal_Int16 _nElementIdOrZero
, bool _bEnable
);
163 /** calls <member>m_pUIChangeNotification</member> at <member>m_rMaster</member>
165 void impl_notifySingleUIChange() const;
169 friend class MethodGuard
;
170 class MethodGuard
: public ::osl::MutexGuard
173 MethodGuard( CachedInspectorUI
& rInstance
)
174 : ::osl::MutexGuard( rInstance
.m_aMutex
)
176 rInstance
.checkDisposed();
182 CachedInspectorUI::CachedInspectorUI( ComposedPropertyUIUpdate
& _rMaster
, FNotifySingleUIChange _pUIChangeNotification
)
183 :m_bDisposed( false )
184 ,m_rMaster( _rMaster
)
185 ,m_pUIChangeNotification( _pUIChangeNotification
)
190 CachedInspectorUI::~CachedInspectorUI()
195 void CachedInspectorUI::dispose()
197 ::osl::MutexGuard
aGuard( m_aMutex
);
200 clearContainer( aEnabledProperties
);
201 clearContainer( aDisabledProperties
);
202 clearContainer( aRebuiltProperties
);
203 clearContainer( aShownProperties
);
204 clearContainer( aHiddenProperties
);
205 clearContainer( aShownCategories
);
206 clearContainer( aHiddenCategories
);
207 clearContainer( aEnabledElements
);
208 clearContainer( aDisabledElements
);
212 void SAL_CALL
CachedInspectorUI::acquire() throw()
214 osl_atomic_increment( &m_refCount
);
218 void SAL_CALL
CachedInspectorUI::release() throw()
220 if ( 0 == osl_atomic_decrement( &m_refCount
) )
226 void CachedInspectorUI::checkDisposed() const
229 throw DisposedException();
235 void lcl_markStringKeyPositiveOrNegative( const OUString
& _rKeyName
, StringBag
& _rPositives
, StringBag
& _rNegatives
, bool _bMarkPositive
)
237 if ( _bMarkPositive
)
239 _rPositives
.insert( _rKeyName
);
240 // if the same key has been remember as in the "negative" list before, clear this information, since it's overruled
241 _rNegatives
.erase( _rKeyName
);
244 _rNegatives
.insert( _rKeyName
);
249 void CachedInspectorUI::enablePropertyUI( const OUString
& _rPropertyName
, sal_Bool _bEnable
) throw (RuntimeException
, std::exception
)
251 MethodGuard
aGuard( *this );
252 if ( !m_rMaster
.shouldContinuePropertyHandling( _rPropertyName
) )
255 lcl_markStringKeyPositiveOrNegative( _rPropertyName
, aEnabledProperties
, aDisabledProperties
, _bEnable
);
256 impl_notifySingleUIChange();
260 void CachedInspectorUI::impl_markElementEnabledOrDisabled( const OUString
& _rPropertyName
, sal_Int16 _nElementIdOrZero
, bool _bEnable
)
262 if ( _nElementIdOrZero
== 0 )
265 lcl_markStringKeyPositiveOrNegative(
267 aEnabledElements
[ _nElementIdOrZero
],
268 aDisabledElements
[ _nElementIdOrZero
],
274 void CachedInspectorUI::impl_notifySingleUIChange() const
276 (m_rMaster
.*m_pUIChangeNotification
)();
280 void CachedInspectorUI::enablePropertyUIElements( const OUString
& _rPropertyName
, sal_Int16 _nElements
, sal_Bool _bEnable
) throw (RuntimeException
, std::exception
)
282 MethodGuard
aGuard( *this );
283 if ( !m_rMaster
.shouldContinuePropertyHandling( _rPropertyName
) )
286 impl_markElementEnabledOrDisabled( _rPropertyName
, _nElements
& PropertyLineElement::InputControl
, _bEnable
);
287 impl_markElementEnabledOrDisabled( _rPropertyName
, _nElements
& PropertyLineElement::PrimaryButton
, _bEnable
);
288 impl_markElementEnabledOrDisabled( _rPropertyName
, _nElements
& PropertyLineElement::SecondaryButton
, _bEnable
);
290 impl_notifySingleUIChange();
294 void CachedInspectorUI::rebuildPropertyUI( const OUString
& _rPropertyName
) throw (RuntimeException
, std::exception
)
296 MethodGuard
aGuard( *this );
297 if ( !m_rMaster
.shouldContinuePropertyHandling( _rPropertyName
) )
300 aRebuiltProperties
.insert( _rPropertyName
);
302 impl_notifySingleUIChange();
306 void CachedInspectorUI::showPropertyUI( const OUString
& _rPropertyName
) throw (RuntimeException
, std::exception
)
308 MethodGuard
aGuard( *this );
309 if ( !m_rMaster
.shouldContinuePropertyHandling( _rPropertyName
) )
312 aShownProperties
.insert( _rPropertyName
);
313 // if the same category has been hidden before, clear this information, since it's overruled
314 aHiddenProperties
.erase( _rPropertyName
);
316 impl_notifySingleUIChange();
320 void CachedInspectorUI::hidePropertyUI( const OUString
& _rPropertyName
) throw (RuntimeException
, std::exception
)
322 MethodGuard
aGuard( *this );
323 if ( !m_rMaster
.shouldContinuePropertyHandling( _rPropertyName
) )
326 aHiddenProperties
.insert( _rPropertyName
);
327 impl_notifySingleUIChange();
331 void CachedInspectorUI::showCategory( const OUString
& _rCategory
, sal_Bool _bShow
) throw (RuntimeException
, std::exception
)
333 MethodGuard
aGuard( *this );
335 lcl_markStringKeyPositiveOrNegative( _rCategory
, aShownCategories
, aHiddenCategories
, _bShow
);
336 impl_notifySingleUIChange();
340 Reference
< XPropertyControl
> SAL_CALL
CachedInspectorUI::getPropertyControl( const OUString
& _rPropertyName
) throw (RuntimeException
, std::exception
)
342 MethodGuard
aGuard( *this );
343 if ( !m_rMaster
.shouldContinuePropertyHandling( _rPropertyName
) )
344 return Reference
< XPropertyControl
>();
346 return m_rMaster
.getDelegatorUI()->getPropertyControl( _rPropertyName
);
350 void SAL_CALL
CachedInspectorUI::registerControlObserver( const Reference
< XPropertyControlObserver
>& _Observer
) throw (RuntimeException
, std::exception
)
352 OSL_FAIL( "CachedInspectorUI::registerControlObserver: not expected to be called!" );
353 // CachedInspectorUI is used as context for the controls, and we don't expect them to
354 // register listeners themself
355 m_rMaster
.getDelegatorUI()->registerControlObserver( _Observer
);
359 void SAL_CALL
CachedInspectorUI::revokeControlObserver( const Reference
< XPropertyControlObserver
>& _Observer
) throw (RuntimeException
, std::exception
)
361 OSL_FAIL( "CachedInspectorUI::revokeControlObserver: not expected to be called!" );
362 // CachedInspectorUI is used as context for the controls, and we don't expect them to
363 // register listeners themself
364 m_rMaster
.getDelegatorUI()->revokeControlObserver( _Observer
);
368 void SAL_CALL
CachedInspectorUI::setHelpSectionText( const OUString
& _HelpText
) throw (NoSupportException
, RuntimeException
, std::exception
)
370 m_rMaster
.getDelegatorUI()->setHelpSectionText( _HelpText
);
376 typedef ::std::map
< Reference
< XPropertyHandler
>
377 , ::rtl::Reference
< CachedInspectorUI
>
379 > ImplMapHandlerToUI
;
380 struct MapHandlerToUI
382 ImplMapHandlerToUI aHandlers
;
385 ComposedPropertyUIUpdate::ComposedPropertyUIUpdate( const Reference
< XObjectInspectorUI
>& _rxDelegatorUI
,
386 IPropertyExistenceCheck
* _pPropertyCheck
)
387 :m_pCollectedUIs( new MapHandlerToUI
)
388 ,m_xDelegatorUI( _rxDelegatorUI
)
389 ,m_nSuspendCounter( 0 )
390 ,m_pPropertyCheck( _pPropertyCheck
)
392 if ( !m_xDelegatorUI
.is() )
393 throw NullPointerException();
397 ComposedPropertyUIUpdate::~ComposedPropertyUIUpdate( )
402 Reference
< XObjectInspectorUI
> ComposedPropertyUIUpdate::getUIForPropertyHandler( const Reference
< XPropertyHandler
>& _rxHandler
)
404 impl_checkDisposed();
406 ::rtl::Reference
< CachedInspectorUI
>& rUI
= m_pCollectedUIs
->aHandlers
[ _rxHandler
];
408 rUI
= new CachedInspectorUI( *this, &ComposedPropertyUIUpdate::callback_inspectorUIChanged_throw
);
416 // an STL-compatible structure which collects strings from a CachedInspectorUI instances
417 struct StringBagCollector
: public ::std::unary_function
< ImplMapHandlerToUI::value_type
, void >
421 CachedInspectorUI::FGetStringBag m_pGetter
;
424 StringBagCollector( StringBag
& _rBag
, CachedInspectorUI::FGetStringBag _pGetter
) :m_rBag( _rBag
), m_pGetter( _pGetter
) { }
426 void operator()( const ImplMapHandlerToUI::value_type
& _rUI
)
428 StringBag
& rBag( ((_rUI
.second
.get())->*m_pGetter
)() );
429 m_rBag
.insert( rBag
.begin(), rBag
.end() );
432 static void collectAll( StringBag
& _rAll
, const ImplMapHandlerToUI
& _rMap
, CachedInspectorUI::FGetStringBag _pGetter
)
434 ::std::for_each( _rMap
.begin(), _rMap
.end(), StringBagCollector( _rAll
, _pGetter
) );
439 // an STL-compatible structure which cleans a certain string bag in a CachedInspectorUI instances
440 struct StringBagClearer
: public ::std::unary_function
< ImplMapHandlerToUI::value_type
, void >
443 CachedInspectorUI::FGetStringBag m_pGetter
;
446 StringBagClearer( CachedInspectorUI::FGetStringBag _pGetter
) :m_pGetter( _pGetter
) { }
448 void operator()( const ImplMapHandlerToUI::value_type
& _rUI
)
450 clearContainer( ((_rUI
.second
.get())->*m_pGetter
)() );
453 static void clearAll( const ImplMapHandlerToUI
& _rMap
, CachedInspectorUI::FGetStringBag _pGetter
)
455 ::std::for_each( _rMap
.begin(), _rMap
.end(), StringBagClearer( _pGetter
) );
459 // a typedef for a ->XObjectInspectorUI member function taking a string
460 typedef void ( SAL_CALL
XObjectInspectorUI::*FPropertyUISetter
)( const OUString
& );
463 // an STL-compatible struct which calls a certain member method (taking a string) at a
464 // given ->XObjectInspectorUI instance
465 struct PropertyUIOperator
: public ::std::unary_function
< OUString
, void >
468 Reference
< XObjectInspectorUI
> m_xUpdater
;
469 FPropertyUISetter m_pSetter
;
472 PropertyUIOperator( const Reference
< XObjectInspectorUI
>& _rxInspectorUI
, FPropertyUISetter _pSetter
)
473 :m_xUpdater( _rxInspectorUI
)
474 ,m_pSetter( _pSetter
)
478 void operator()( const OUString
& _rPropertyName
)
480 ((m_xUpdater
.get())->*m_pSetter
)( _rPropertyName
);
483 static void forEach( const StringBag
& _rProperties
, const Reference
< XObjectInspectorUI
>& _rxDelegatorUI
, FPropertyUISetter _pSetter
)
485 ::std::for_each( _rProperties
.begin(), _rProperties
.end(), PropertyUIOperator( _rxDelegatorUI
, _pSetter
) );
490 // an interface which encapsulates access to a single aspect of the ->XObjectInspectorUI,
491 // where this aspect is given by a string key, and has a boolean value.
492 class IStringKeyBooleanUIUpdate
495 virtual void updateUIForKey( const OUString
& _rKey
, bool _bFlag
) const = 0;
497 virtual ~IStringKeyBooleanUIUpdate() { }
501 // FPropertyUIFlagSetter
503 /** an implementation of the ->IStringKeyBooleanUIUpdate interface which,
504 for a fixed ->XObjectInspectorUI instance and a fixed UI element (->PropertyLineElement),
505 updates this element for a given property with a given boolean flag
506 (->XObjectInspectorUI::enablePropertyUIElements)
508 class EnablePropertyUIElement
: public IStringKeyBooleanUIUpdate
511 Reference
< XObjectInspectorUI
> m_xUIUpdate
;
512 sal_Int16 m_nElement
;
515 EnablePropertyUIElement( const Reference
< XObjectInspectorUI
>& _rxUIUpdate
, sal_Int16 _nElement
)
516 :m_xUIUpdate( _rxUIUpdate
)
517 ,m_nElement( _nElement
)
520 // IStringKeyBooleanUIUpdate
521 virtual void updateUIForKey( const OUString
& _rKey
, bool _bFlag
) const SAL_OVERRIDE
;
525 void EnablePropertyUIElement::updateUIForKey( const OUString
& _rKey
, bool _bFlag
) const
527 m_xUIUpdate
->enablePropertyUIElements( _rKey
, m_nElement
, _bFlag
);
531 // a ->XObjectInspectorUI method taking a string and a boolean
532 typedef void ( SAL_CALL
XObjectInspectorUI::*FPropertyUIFlagSetter
)( const OUString
&, sal_Bool
);
535 // an implementaiton of the ->IStringKeyBooleanUIUpdate interface which calls
536 // am arbitrary ->XObjectInspectorUI method taking a string and a boolean flag
537 class DefaultStringKeyBooleanUIUpdate
: public IStringKeyBooleanUIUpdate
540 Reference
< XObjectInspectorUI
> m_xUIUpdate
;
541 FPropertyUIFlagSetter m_pSetter
;
544 DefaultStringKeyBooleanUIUpdate( const Reference
< XObjectInspectorUI
>& _rxUIUpdate
, FPropertyUIFlagSetter _pSetter
);
545 // IStringKeyBooleanUIUpdate
546 virtual void updateUIForKey( const OUString
& _rKey
, bool _bFlag
) const SAL_OVERRIDE
;
550 DefaultStringKeyBooleanUIUpdate::DefaultStringKeyBooleanUIUpdate( const Reference
< XObjectInspectorUI
>& _rxUIUpdate
, FPropertyUIFlagSetter _pSetter
)
551 :m_xUIUpdate( _rxUIUpdate
)
552 ,m_pSetter( _pSetter
)
557 void DefaultStringKeyBooleanUIUpdate::updateUIForKey( const OUString
& _rKey
, bool _bFlag
) const
559 ((m_xUIUpdate
.get())->*m_pSetter
)( _rKey
, _bFlag
);
563 // an STL-compatible structure which applies a ->IStringKeyBooleanUIUpdate::updateUIForKey
564 // operation with a fixed boolean value, for a given string value
565 struct BooleanUIAspectUpdate
: public ::std::unary_function
< OUString
, void >
568 const IStringKeyBooleanUIUpdate
& m_rUpdater
;
572 BooleanUIAspectUpdate( const IStringKeyBooleanUIUpdate
& _rUpdater
, bool _bFlag
)
573 :m_rUpdater( _rUpdater
)
578 void operator()( const OUString
& _rPropertyName
)
580 m_rUpdater
.updateUIForKey( _rPropertyName
, m_bFlag
);
583 static void forEach( const StringBag
& _rProperties
, const IStringKeyBooleanUIUpdate
& _rUpdater
, bool _bFlag
)
585 ::std::for_each( _rProperties
.begin(), _rProperties
.end(), BooleanUIAspectUpdate( _rUpdater
, _bFlag
) );
590 // BooleanUIAspectUpdate
592 // an STL-compatible structure subtracting a given string from a fixed ->StringBag
593 struct StringBagComplement
: public ::std::unary_function
< OUString
, void >
596 StringBag
& m_rMinuend
;
599 StringBagComplement( StringBag
& _rMinuend
) :m_rMinuend( _rMinuend
) { }
601 void operator()( const OUString
& _rPropertyToSubtract
)
603 m_rMinuend
.erase( _rPropertyToSubtract
);
606 static void subtract( StringBag
& _rMinuend
, const StringBag
& _rSubtrahend
)
608 ::std::for_each( _rSubtrahend
.begin(), _rSubtrahend
.end(), StringBagComplement( _rMinuend
) );
613 // BooleanUIAspectUpdate
615 void lcl_fireUIStateFlag(
616 const IStringKeyBooleanUIUpdate
& _rUIUpdate
,
617 const ImplMapHandlerToUI
& _rHandlerUIs
,
618 CachedInspectorUI::FGetStringBag _pGetPositives
,
619 CachedInspectorUI::FGetStringBag _pGetNegatives
622 // all strings which are in the "positive" list of one handler
623 StringBag aAllPositives
;
624 StringBagCollector::collectAll( aAllPositives
, _rHandlerUIs
, _pGetPositives
);
626 // all strings which are in the "negative" list of one handler
627 StringBag aAllNegatives
;
628 StringBagCollector::collectAll( aAllNegatives
, _rHandlerUIs
, _pGetNegatives
);
630 // propagate the "negative" flags to the delegator UI
631 BooleanUIAspectUpdate::forEach( aAllNegatives
, _rUIUpdate
, false );
633 // propagate the "positive" flags to the delegator UI, for all elements where _no_
634 // "negative" flag exists
635 StringBagComplement::subtract( aAllPositives
, aAllNegatives
);
636 BooleanUIAspectUpdate::forEach( aAllPositives
, _rUIUpdate
, true );
638 // the "positive" request can be cleared no, only negative requests
639 // (such as "disable a property" or "hide a category") need to be preserved for the next round
640 StringBagClearer::clearAll( _rHandlerUIs
, _pGetPositives
);
645 void ComposedPropertyUIUpdate::impl_fireEnablePropertyUI_throw()
648 DefaultStringKeyBooleanUIUpdate( m_xDelegatorUI
, &XObjectInspectorUI::enablePropertyUI
),
649 m_pCollectedUIs
->aHandlers
,
650 &CachedInspectorUI::getEnabledProperties
,
651 &CachedInspectorUI::getDisabledProperties
656 void ComposedPropertyUIUpdate::impl_fireRebuildPropertyUI_throw()
658 // collect all properties for which a rebuild request has been made
659 StringBag aAllRebuilt
;
660 StringBagCollector::collectAll( aAllRebuilt
, m_pCollectedUIs
->aHandlers
, &CachedInspectorUI::getRebuiltProperties
);
662 // rebuild all those properties
663 PropertyUIOperator::forEach( aAllRebuilt
, m_xDelegatorUI
, &XObjectInspectorUI::rebuildPropertyUI
);
665 // clear the "properties to rebuild" at all handlers, since the request has been fulfilled now.
666 StringBagClearer::clearAll( m_pCollectedUIs
->aHandlers
, &CachedInspectorUI::getRebuiltProperties
);
670 void ComposedPropertyUIUpdate::impl_fireShowHidePropertyUI_throw()
672 // all properties which have been shown by at least one handler
674 StringBagCollector::collectAll( aAllShown
, m_pCollectedUIs
->aHandlers
, &CachedInspectorUI::getShownProperties
);
675 // all properties which have been hidden by at least one handler
676 StringBag aAllHidden
;
677 StringBagCollector::collectAll( aAllHidden
, m_pCollectedUIs
->aHandlers
, &CachedInspectorUI::getHiddenProperties
);
679 // hide properties as necessary
680 PropertyUIOperator::forEach( aAllHidden
, m_xDelegatorUI
, &XObjectInspectorUI::hidePropertyUI
);
682 // for those properties which are hidden, ignore all "show" requests which other handlers might have had
683 StringBagComplement::subtract( aAllShown
, aAllHidden
);
686 PropertyUIOperator::forEach( aAllShown
, m_xDelegatorUI
, &XObjectInspectorUI::showPropertyUI
);
690 void ComposedPropertyUIUpdate::impl_fireShowCategory_throw()
693 DefaultStringKeyBooleanUIUpdate( m_xDelegatorUI
, &XObjectInspectorUI::showCategory
),
694 m_pCollectedUIs
->aHandlers
,
695 &CachedInspectorUI::getShownCategories
,
696 &CachedInspectorUI::getHiddenCategories
701 void ComposedPropertyUIUpdate::impl_fireEnablePropertyUIElements_throw()
704 EnablePropertyUIElement( m_xDelegatorUI
, PropertyLineElement::InputControl
),
705 m_pCollectedUIs
->aHandlers
,
706 &CachedInspectorUI::getEnabledInputControls
,
707 &CachedInspectorUI::getDisabledInputControls
711 EnablePropertyUIElement( m_xDelegatorUI
, PropertyLineElement::PrimaryButton
),
712 m_pCollectedUIs
->aHandlers
,
713 &CachedInspectorUI::getEnabledPrimaryButtons
,
714 &CachedInspectorUI::getDisabledPrimaryButtons
718 EnablePropertyUIElement( m_xDelegatorUI
, PropertyLineElement::SecondaryButton
),
719 m_pCollectedUIs
->aHandlers
,
720 &CachedInspectorUI::getEnabledSecondaryButtons
,
721 &CachedInspectorUI::getDisabledSecondaryButtons
726 void ComposedPropertyUIUpdate::impl_fireAll_throw()
728 OSL_PRECOND( !impl_isDisposed(), "ComposedPropertyUIUpdate::impl_fireAll_throw: already disposed, this will crash!" );
730 impl_fireEnablePropertyUI_throw();
731 impl_fireShowHidePropertyUI_throw();
732 impl_fireRebuildPropertyUI_throw();
733 impl_fireShowCategory_throw();
734 impl_fireEnablePropertyUIElements_throw();
738 void SAL_CALL
ComposedPropertyUIUpdate::suspendAutoFire()
740 impl_checkDisposed();
741 osl_atomic_increment( &m_nSuspendCounter
);
745 void SAL_CALL
ComposedPropertyUIUpdate::resumeAutoFire()
747 impl_checkDisposed();
748 if ( 0 == osl_atomic_decrement( &m_nSuspendCounter
) )
749 impl_fireAll_throw();
753 void ComposedPropertyUIUpdate::impl_checkDisposed() const
755 if ( impl_isDisposed() )
756 throw DisposedException();
760 void ComposedPropertyUIUpdate::callback_inspectorUIChanged_throw()
762 if ( 0 == m_nSuspendCounter
)
763 impl_fireAll_throw();
767 Reference
< XObjectInspectorUI
> ComposedPropertyUIUpdate::getDelegatorUI() const
769 impl_checkDisposed();
770 return m_xDelegatorUI
;
774 void SAL_CALL
ComposedPropertyUIUpdate::dispose()
776 if ( impl_isDisposed() )
779 OSL_ENSURE( m_nSuspendCounter
== 0, "ComposedPropertyUIUpdate::dispose: still suspended, the changes will be lost!" );
781 for ( ImplMapHandlerToUI::const_iterator singleUI
= m_pCollectedUIs
->aHandlers
.begin();
782 singleUI
!= m_pCollectedUIs
->aHandlers
.end();
786 singleUI
->second
->dispose();
788 m_pCollectedUIs
.reset();
789 m_xDelegatorUI
.set( NULL
);
793 bool ComposedPropertyUIUpdate::shouldContinuePropertyHandling( const OUString
& _rName
) const
795 if ( !m_pPropertyCheck
)
797 if ( m_pPropertyCheck
->hasPropertyByName( _rName
) )
806 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */