1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_extensions.hxx" 30*cdf0e10cSrcweir #include "composeduiupdate.hxx" 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir /** === begin UNO includes === **/ 33*cdf0e10cSrcweir #include <com/sun/star/inspection/XObjectInspectorUI.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/inspection/PropertyLineElement.hpp> 36*cdf0e10cSrcweir /** === end UNO includes === **/ 37*cdf0e10cSrcweir #include <osl/mutex.hxx> 38*cdf0e10cSrcweir #include <rtl/ref.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <algorithm> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir //........................................................................ 43*cdf0e10cSrcweir namespace pcr 44*cdf0e10cSrcweir { 45*cdf0e10cSrcweir //........................................................................ 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir /** === begin UNO using === **/ 48*cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 49*cdf0e10cSrcweir using ::com::sun::star::lang::DisposedException; 50*cdf0e10cSrcweir using ::com::sun::star::lang::NullPointerException; 51*cdf0e10cSrcweir using ::com::sun::star::inspection::XPropertyHandler; 52*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 53*cdf0e10cSrcweir using ::com::sun::star::inspection::XObjectInspectorUI; 54*cdf0e10cSrcweir using ::com::sun::star::inspection::XPropertyControl; 55*cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 56*cdf0e10cSrcweir using ::com::sun::star::lang::NoSupportException; 57*cdf0e10cSrcweir using ::com::sun::star::inspection::XPropertyControlObserver; 58*cdf0e10cSrcweir /** === end UNO using === **/ 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir namespace PropertyLineElement = ::com::sun::star::inspection::PropertyLineElement; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir //==================================================================== 63*cdf0e10cSrcweir //= helper 64*cdf0e10cSrcweir //==================================================================== 65*cdf0e10cSrcweir namespace 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir struct HandlerLess : public ::std::binary_function < Reference< XPropertyHandler > 68*cdf0e10cSrcweir , Reference< XPropertyHandler > 69*cdf0e10cSrcweir , bool 70*cdf0e10cSrcweir > 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir bool operator()( const Reference< XPropertyHandler >& lhs, const Reference< XPropertyHandler >& rhs) const 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir return lhs.get() < rhs.get(); 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir }; 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir //================================================================ 79*cdf0e10cSrcweir typedef ::std::set< ::rtl::OUString > StringBag; 80*cdf0e10cSrcweir typedef ::std::map< sal_Int16, StringBag > MapIntToStringBag; 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir //==================================================================== 84*cdf0e10cSrcweir //= callbacks for CachedInspectorUI 85*cdf0e10cSrcweir //==================================================================== 86*cdf0e10cSrcweir typedef void (ComposedPropertyUIUpdate::*FNotifySingleUIChange)(); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir //==================================================================== 89*cdf0e10cSrcweir //= CachedInspectorUI 90*cdf0e10cSrcweir //==================================================================== 91*cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1 < ::com::sun::star::inspection::XObjectInspectorUI 92*cdf0e10cSrcweir > CachedInspectorUI_Base; 93*cdf0e10cSrcweir struct CachedInspectorUI : public CachedInspectorUI_Base 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir private: 96*cdf0e10cSrcweir ::osl::Mutex m_aMutex; 97*cdf0e10cSrcweir oslInterlockedCount m_refCount; 98*cdf0e10cSrcweir bool m_bDisposed; 99*cdf0e10cSrcweir ComposedPropertyUIUpdate& 100*cdf0e10cSrcweir m_rMaster; 101*cdf0e10cSrcweir FNotifySingleUIChange m_pUIChangeNotification; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir // enablePropertyUI cache 104*cdf0e10cSrcweir StringBag aEnabledProperties; 105*cdf0e10cSrcweir StringBag aDisabledProperties; 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir // show/hidePropertyUI cache 108*cdf0e10cSrcweir StringBag aShownProperties; 109*cdf0e10cSrcweir StringBag aHiddenProperties; 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir // rebuildPropertyUI cache 112*cdf0e10cSrcweir StringBag aRebuiltProperties; 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir // showCategory cache 115*cdf0e10cSrcweir StringBag aShownCategories; 116*cdf0e10cSrcweir StringBag aHiddenCategories; 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir // enablePropertyUIElements cache 119*cdf0e10cSrcweir MapIntToStringBag aEnabledElements; 120*cdf0e10cSrcweir MapIntToStringBag aDisabledElements; 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir public: 123*cdf0e10cSrcweir typedef StringBag& (CachedInspectorUI::*FGetStringBag)(); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir // enablePropertyUI cache 126*cdf0e10cSrcweir StringBag& getEnabledProperties() { return aEnabledProperties; } 127*cdf0e10cSrcweir StringBag& getDisabledProperties() { return aDisabledProperties; } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir // show/hidePropertyUI cache 130*cdf0e10cSrcweir StringBag& getShownProperties() { return aShownProperties; } 131*cdf0e10cSrcweir StringBag& getHiddenProperties() { return aHiddenProperties; } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir // rebuildPropertyUI cache 134*cdf0e10cSrcweir StringBag& getRebuiltProperties() { return aRebuiltProperties; } 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir // showCategory cache 137*cdf0e10cSrcweir StringBag& getShownCategories() { return aShownCategories; } 138*cdf0e10cSrcweir StringBag& getHiddenCategories() { return aHiddenCategories; } 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir // enablePropertyUIElements 141*cdf0e10cSrcweir StringBag& getEnabledInputControls() { return aEnabledElements[ PropertyLineElement::InputControl ]; } 142*cdf0e10cSrcweir StringBag& getDisabledInputControls() { return aDisabledElements[ PropertyLineElement::InputControl ]; } 143*cdf0e10cSrcweir StringBag& getEnabledPrimaryButtons() { return aEnabledElements[ PropertyLineElement::PrimaryButton ]; } 144*cdf0e10cSrcweir StringBag& getDisabledPrimaryButtons() { return aDisabledElements[ PropertyLineElement::PrimaryButton ]; } 145*cdf0e10cSrcweir StringBag& getEnabledSecondaryButtons() { return aEnabledElements[ PropertyLineElement::SecondaryButton ]; } 146*cdf0e10cSrcweir StringBag& getDisabledSecondaryButtons() { return aDisabledElements[ PropertyLineElement::SecondaryButton ]; } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir public: 149*cdf0e10cSrcweir CachedInspectorUI( ComposedPropertyUIUpdate& _rMaster, FNotifySingleUIChange _pUIChangeNotification ); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir /// disposes the instance 152*cdf0e10cSrcweir void dispose(); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir // XObjectInspectorUI overridables 155*cdf0e10cSrcweir virtual void SAL_CALL enablePropertyUI( const ::rtl::OUString& _rPropertyName, ::sal_Bool _bEnable ) throw (RuntimeException); 156*cdf0e10cSrcweir virtual void SAL_CALL enablePropertyUIElements( const ::rtl::OUString& _rPropertyName, ::sal_Int16 _nElements, ::sal_Bool _bEnable ) throw (RuntimeException); 157*cdf0e10cSrcweir virtual void SAL_CALL rebuildPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException); 158*cdf0e10cSrcweir virtual void SAL_CALL showPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException); 159*cdf0e10cSrcweir virtual void SAL_CALL hidePropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException); 160*cdf0e10cSrcweir virtual void SAL_CALL showCategory( const ::rtl::OUString& _rCategory, ::sal_Bool _bShow ) throw (RuntimeException); 161*cdf0e10cSrcweir virtual Reference< XPropertyControl > SAL_CALL getPropertyControl( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException); 162*cdf0e10cSrcweir virtual void SAL_CALL registerControlObserver( const Reference< XPropertyControlObserver >& Observer ) throw (RuntimeException); 163*cdf0e10cSrcweir virtual void SAL_CALL revokeControlObserver( const Reference< XPropertyControlObserver >& Observer ) throw (RuntimeException); 164*cdf0e10cSrcweir virtual void SAL_CALL setHelpSectionText( const ::rtl::OUString& _HelpText ) throw (NoSupportException, RuntimeException); 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir // UNOCompatibleNonUNOReference overridables 167*cdf0e10cSrcweir virtual void SAL_CALL acquire() throw(); 168*cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir protected: 171*cdf0e10cSrcweir ~CachedInspectorUI(); 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir /// determines whether the instance is already disposed 174*cdf0e10cSrcweir inline bool isDisposed() const { return m_bDisposed; } 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir /// throws an exception if the component is already disposed 177*cdf0e10cSrcweir void checkDisposed() const; 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir private: 180*cdf0e10cSrcweir void impl_markElementEnabledOrDisabled( const ::rtl::OUString& _rPropertyName, sal_Int16 _nElementIdOrZero, sal_Bool _bEnable ); 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir /** calls <member>m_pUIChangeNotification</member> at <member>m_rMaster</member> 183*cdf0e10cSrcweir */ 184*cdf0e10cSrcweir void impl_notifySingleUIChange() const; 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir private: 187*cdf0e10cSrcweir CachedInspectorUI( const CachedInspectorUI& ); // never implemented 188*cdf0e10cSrcweir CachedInspectorUI& operator=( const CachedInspectorUI& ); // never implemented 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir private: 191*cdf0e10cSrcweir class MethodGuard; 192*cdf0e10cSrcweir friend class MethodGuard; 193*cdf0e10cSrcweir class MethodGuard : public ::osl::MutexGuard 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir public: 196*cdf0e10cSrcweir MethodGuard( CachedInspectorUI& rInstance ) 197*cdf0e10cSrcweir : ::osl::MutexGuard( rInstance.m_aMutex ) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir rInstance.checkDisposed(); 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir }; 202*cdf0e10cSrcweir }; 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir //---------------------------------------------------------------- 205*cdf0e10cSrcweir CachedInspectorUI::CachedInspectorUI( ComposedPropertyUIUpdate& _rMaster, FNotifySingleUIChange _pUIChangeNotification ) 206*cdf0e10cSrcweir :m_refCount( 0 ) 207*cdf0e10cSrcweir ,m_bDisposed( false ) 208*cdf0e10cSrcweir ,m_rMaster( _rMaster ) 209*cdf0e10cSrcweir ,m_pUIChangeNotification( _pUIChangeNotification ) 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir //---------------------------------------------------------------- 214*cdf0e10cSrcweir CachedInspectorUI::~CachedInspectorUI() 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir //---------------------------------------------------------------- 219*cdf0e10cSrcweir void CachedInspectorUI::dispose() 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 222*cdf0e10cSrcweir m_bDisposed = true; 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir clearContainer( aEnabledProperties ); 225*cdf0e10cSrcweir clearContainer( aDisabledProperties ); 226*cdf0e10cSrcweir clearContainer( aRebuiltProperties ); 227*cdf0e10cSrcweir clearContainer( aShownProperties ); 228*cdf0e10cSrcweir clearContainer( aHiddenProperties ); 229*cdf0e10cSrcweir clearContainer( aShownCategories ); 230*cdf0e10cSrcweir clearContainer( aHiddenCategories ); 231*cdf0e10cSrcweir clearContainer( aEnabledElements ); 232*cdf0e10cSrcweir clearContainer( aDisabledElements ); 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir //---------------------------------------------------------------- 236*cdf0e10cSrcweir void SAL_CALL CachedInspectorUI::acquire() throw() 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir //---------------------------------------------------------------- 242*cdf0e10cSrcweir void SAL_CALL CachedInspectorUI::release() throw() 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir if ( 0 == osl_decrementInterlockedCount( &m_refCount ) ) 245*cdf0e10cSrcweir delete this; 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir //---------------------------------------------------------------- 250*cdf0e10cSrcweir void CachedInspectorUI::checkDisposed() const 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir if ( isDisposed() ) 253*cdf0e10cSrcweir throw DisposedException(); 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir //---------------------------------------------------------------- 257*cdf0e10cSrcweir namespace 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir void lcl_markStringKeyPositiveOrNegative( const ::rtl::OUString& _rKeyName, StringBag& _rPositives, StringBag& _rNegatives, sal_Bool _bMarkPositive ) 260*cdf0e10cSrcweir { 261*cdf0e10cSrcweir if ( _bMarkPositive ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir _rPositives.insert( _rKeyName ); 264*cdf0e10cSrcweir // if the same key has been remember as in the "negative" list before, clear this information, since it's overruled 265*cdf0e10cSrcweir _rNegatives.erase( _rKeyName ); 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir else 268*cdf0e10cSrcweir _rNegatives.insert( _rKeyName ); 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir //---------------------------------------------------------------- 273*cdf0e10cSrcweir void CachedInspectorUI::enablePropertyUI( const ::rtl::OUString& _rPropertyName, sal_Bool _bEnable ) throw (RuntimeException) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir MethodGuard aGuard( *this ); 276*cdf0e10cSrcweir if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) ) 277*cdf0e10cSrcweir return; 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir lcl_markStringKeyPositiveOrNegative( _rPropertyName, aEnabledProperties, aDisabledProperties, _bEnable ); 280*cdf0e10cSrcweir impl_notifySingleUIChange(); 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir //---------------------------------------------------------------- 284*cdf0e10cSrcweir void CachedInspectorUI::impl_markElementEnabledOrDisabled( const ::rtl::OUString& _rPropertyName, sal_Int16 _nElementIdOrZero, sal_Bool _bEnable ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir if ( _nElementIdOrZero == 0 ) 287*cdf0e10cSrcweir return; 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir lcl_markStringKeyPositiveOrNegative( 290*cdf0e10cSrcweir _rPropertyName, 291*cdf0e10cSrcweir aEnabledElements[ _nElementIdOrZero ], 292*cdf0e10cSrcweir aDisabledElements[ _nElementIdOrZero ], 293*cdf0e10cSrcweir _bEnable 294*cdf0e10cSrcweir ); 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir //---------------------------------------------------------------- 298*cdf0e10cSrcweir void CachedInspectorUI::impl_notifySingleUIChange() const 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir (m_rMaster.*m_pUIChangeNotification)(); 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir //---------------------------------------------------------------- 304*cdf0e10cSrcweir void CachedInspectorUI::enablePropertyUIElements( const ::rtl::OUString& _rPropertyName, sal_Int16 _nElements, sal_Bool _bEnable ) throw (RuntimeException) 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir MethodGuard aGuard( *this ); 307*cdf0e10cSrcweir if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) ) 308*cdf0e10cSrcweir return; 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir impl_markElementEnabledOrDisabled( _rPropertyName, _nElements & PropertyLineElement::InputControl, _bEnable ); 311*cdf0e10cSrcweir impl_markElementEnabledOrDisabled( _rPropertyName, _nElements & PropertyLineElement::PrimaryButton, _bEnable ); 312*cdf0e10cSrcweir impl_markElementEnabledOrDisabled( _rPropertyName, _nElements & PropertyLineElement::SecondaryButton, _bEnable ); 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir impl_notifySingleUIChange(); 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir //---------------------------------------------------------------- 318*cdf0e10cSrcweir void CachedInspectorUI::rebuildPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException) 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir MethodGuard aGuard( *this ); 321*cdf0e10cSrcweir if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) ) 322*cdf0e10cSrcweir return; 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir aRebuiltProperties.insert( _rPropertyName ); 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir impl_notifySingleUIChange(); 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir //---------------------------------------------------------------- 330*cdf0e10cSrcweir void CachedInspectorUI::showPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir MethodGuard aGuard( *this ); 333*cdf0e10cSrcweir if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) ) 334*cdf0e10cSrcweir return; 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir aShownProperties.insert( _rPropertyName ); 337*cdf0e10cSrcweir // if the same category has been hidden before, clear this information, since it's overruled 338*cdf0e10cSrcweir aHiddenProperties.erase( _rPropertyName ); 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir impl_notifySingleUIChange(); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir //---------------------------------------------------------------- 344*cdf0e10cSrcweir void CachedInspectorUI::hidePropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir MethodGuard aGuard( *this ); 347*cdf0e10cSrcweir if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) ) 348*cdf0e10cSrcweir return; 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir aHiddenProperties.insert( _rPropertyName ); 351*cdf0e10cSrcweir impl_notifySingleUIChange(); 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir //---------------------------------------------------------------- 355*cdf0e10cSrcweir void CachedInspectorUI::showCategory( const ::rtl::OUString& _rCategory, sal_Bool _bShow ) throw (RuntimeException) 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir MethodGuard aGuard( *this ); 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir lcl_markStringKeyPositiveOrNegative( _rCategory, aShownCategories, aHiddenCategories, _bShow ); 360*cdf0e10cSrcweir impl_notifySingleUIChange(); 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir //---------------------------------------------------------------- 364*cdf0e10cSrcweir Reference< XPropertyControl > SAL_CALL CachedInspectorUI::getPropertyControl( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException) 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir MethodGuard aGuard( *this ); 367*cdf0e10cSrcweir if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) ) 368*cdf0e10cSrcweir return Reference< XPropertyControl >(); 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir return m_rMaster.getDelegatorUI()->getPropertyControl( _rPropertyName ); 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir //-------------------------------------------------------------------- 374*cdf0e10cSrcweir void SAL_CALL CachedInspectorUI::registerControlObserver( const Reference< XPropertyControlObserver >& _Observer ) throw (RuntimeException) 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir OSL_ENSURE( false, "CachedInspectorUI::registerControlObserver: not expected to be called!" ); 377*cdf0e10cSrcweir // CachedInspectorUI is used as context for the controls, and we don't expect them to 378*cdf0e10cSrcweir // register listeners themself 379*cdf0e10cSrcweir m_rMaster.getDelegatorUI()->registerControlObserver( _Observer ); 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir //-------------------------------------------------------------------- 383*cdf0e10cSrcweir void SAL_CALL CachedInspectorUI::revokeControlObserver( const Reference< XPropertyControlObserver >& _Observer ) throw (RuntimeException) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir OSL_ENSURE( false, "CachedInspectorUI::revokeControlObserver: not expected to be called!" ); 386*cdf0e10cSrcweir // CachedInspectorUI is used as context for the controls, and we don't expect them to 387*cdf0e10cSrcweir // register listeners themself 388*cdf0e10cSrcweir m_rMaster.getDelegatorUI()->revokeControlObserver( _Observer ); 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir //---------------------------------------------------------------- 392*cdf0e10cSrcweir void SAL_CALL CachedInspectorUI::setHelpSectionText( const ::rtl::OUString& _HelpText ) throw (NoSupportException, RuntimeException) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir m_rMaster.getDelegatorUI()->setHelpSectionText( _HelpText ); 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir //==================================================================== 398*cdf0e10cSrcweir //= HandlerMap 399*cdf0e10cSrcweir //==================================================================== 400*cdf0e10cSrcweir typedef ::std::map < Reference< XPropertyHandler > 401*cdf0e10cSrcweir , ::rtl::Reference< CachedInspectorUI > 402*cdf0e10cSrcweir , HandlerLess 403*cdf0e10cSrcweir > ImplMapHandlerToUI; 404*cdf0e10cSrcweir struct MapHandlerToUI 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir ImplMapHandlerToUI aHandlers; 407*cdf0e10cSrcweir }; 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir //==================================================================== 410*cdf0e10cSrcweir //= ComposedPropertyUIUpdate 411*cdf0e10cSrcweir //==================================================================== 412*cdf0e10cSrcweir //---------------------------------------------------------------- 413*cdf0e10cSrcweir ComposedPropertyUIUpdate::ComposedPropertyUIUpdate( const Reference< XObjectInspectorUI >& _rxDelegatorUI, 414*cdf0e10cSrcweir IPropertyExistenceCheck* _pPropertyCheck ) 415*cdf0e10cSrcweir :m_pCollectedUIs( new MapHandlerToUI ) 416*cdf0e10cSrcweir ,m_xDelegatorUI( _rxDelegatorUI ) 417*cdf0e10cSrcweir ,m_nSuspendCounter( 0 ) 418*cdf0e10cSrcweir ,m_pPropertyCheck( _pPropertyCheck ) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir if ( !m_xDelegatorUI.is() ) 421*cdf0e10cSrcweir throw NullPointerException(); 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir //---------------------------------------------------------------- 425*cdf0e10cSrcweir ComposedPropertyUIUpdate::~ComposedPropertyUIUpdate( ) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir //---------------------------------------------------------------- 430*cdf0e10cSrcweir Reference< XObjectInspectorUI > ComposedPropertyUIUpdate::getUIForPropertyHandler( const Reference< XPropertyHandler >& _rxHandler ) 431*cdf0e10cSrcweir { 432*cdf0e10cSrcweir impl_checkDisposed(); 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir ::rtl::Reference< CachedInspectorUI >& rUI = m_pCollectedUIs->aHandlers[ _rxHandler ]; 435*cdf0e10cSrcweir if ( !rUI.is() ) 436*cdf0e10cSrcweir rUI = new CachedInspectorUI( *this, &ComposedPropertyUIUpdate::callback_inspectorUIChanged_throw ); 437*cdf0e10cSrcweir return rUI.get(); 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir //---------------------------------------------------------------- 441*cdf0e10cSrcweir namespace 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir //============================================================ 444*cdf0e10cSrcweir //= StringBagCollector 445*cdf0e10cSrcweir //============================================================ 446*cdf0e10cSrcweir /** an STL-compatible structure which collects strings from a CachedInspectorUI instances 447*cdf0e10cSrcweir */ 448*cdf0e10cSrcweir struct StringBagCollector : public ::std::unary_function< ImplMapHandlerToUI::value_type, void > 449*cdf0e10cSrcweir { 450*cdf0e10cSrcweir private: 451*cdf0e10cSrcweir StringBag& m_rBag; 452*cdf0e10cSrcweir CachedInspectorUI::FGetStringBag m_pGetter; 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir public: 455*cdf0e10cSrcweir StringBagCollector( StringBag& _rBag, CachedInspectorUI::FGetStringBag _pGetter ) :m_rBag( _rBag ), m_pGetter( _pGetter ) { } 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir void operator()( const ImplMapHandlerToUI::value_type& _rUI ) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir StringBag& rBag( ((_rUI.second.get())->*m_pGetter)() ); 460*cdf0e10cSrcweir m_rBag.insert( rBag.begin(), rBag.end() ); 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir static void collectAll( StringBag& _rAll, const ImplMapHandlerToUI& _rMap, CachedInspectorUI::FGetStringBag _pGetter ) 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir ::std::for_each( _rMap.begin(), _rMap.end(), StringBagCollector( _rAll, _pGetter ) ); 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir }; 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir //============================================================ 470*cdf0e10cSrcweir //= StringBagClearer 471*cdf0e10cSrcweir //============================================================ 472*cdf0e10cSrcweir /** an STL-compatible structure which cleans a certain string bag in a CachedInspectorUI instances 473*cdf0e10cSrcweir */ 474*cdf0e10cSrcweir struct StringBagClearer : public ::std::unary_function< ImplMapHandlerToUI::value_type, void > 475*cdf0e10cSrcweir { 476*cdf0e10cSrcweir private: 477*cdf0e10cSrcweir CachedInspectorUI::FGetStringBag m_pGetter; 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir public: 480*cdf0e10cSrcweir StringBagClearer( CachedInspectorUI::FGetStringBag _pGetter ) :m_pGetter( _pGetter ) { } 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir void operator()( const ImplMapHandlerToUI::value_type& _rUI ) 483*cdf0e10cSrcweir { 484*cdf0e10cSrcweir clearContainer( ((_rUI.second.get())->*m_pGetter)() ); 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir static void clearAll( const ImplMapHandlerToUI& _rMap, CachedInspectorUI::FGetStringBag _pGetter ) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir ::std::for_each( _rMap.begin(), _rMap.end(), StringBagClearer( _pGetter ) ); 490*cdf0e10cSrcweir } 491*cdf0e10cSrcweir }; 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir //============================================================ 494*cdf0e10cSrcweir //= FPropertyUISetter 495*cdf0e10cSrcweir //============================================================ 496*cdf0e10cSrcweir /** a typedef for a ->XObjectInspectorUI member function taking a string 497*cdf0e10cSrcweir */ 498*cdf0e10cSrcweir typedef void ( SAL_CALL XObjectInspectorUI::*FPropertyUISetter )( const ::rtl::OUString& ); 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir //============================================================ 501*cdf0e10cSrcweir //= PropertyUIOperator 502*cdf0e10cSrcweir //============================================================ 503*cdf0e10cSrcweir /** an STL-compatible struct which calls a certain member method (taking a string) at a 504*cdf0e10cSrcweir given ->XObjectInspectorUI instance 505*cdf0e10cSrcweir */ 506*cdf0e10cSrcweir struct PropertyUIOperator : public ::std::unary_function< ::rtl::OUString, void > 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir private: 509*cdf0e10cSrcweir Reference< XObjectInspectorUI > m_xUpdater; 510*cdf0e10cSrcweir FPropertyUISetter m_pSetter; 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir public: 513*cdf0e10cSrcweir PropertyUIOperator( const Reference< XObjectInspectorUI >& _rxInspectorUI, FPropertyUISetter _pSetter ) 514*cdf0e10cSrcweir :m_xUpdater( _rxInspectorUI ) 515*cdf0e10cSrcweir ,m_pSetter( _pSetter ) 516*cdf0e10cSrcweir { 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir void operator()( const ::rtl::OUString& _rPropertyName ) 520*cdf0e10cSrcweir { 521*cdf0e10cSrcweir ((m_xUpdater.get())->*m_pSetter)( _rPropertyName ); 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir static void forEach( const StringBag& _rProperties, const Reference< XObjectInspectorUI >& _rxDelegatorUI, FPropertyUISetter _pSetter ) 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir ::std::for_each( _rProperties.begin(), _rProperties.end(), PropertyUIOperator( _rxDelegatorUI, _pSetter ) ); 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir }; 529*cdf0e10cSrcweir 530*cdf0e10cSrcweir //============================================================ 531*cdf0e10cSrcweir //= IStringKeyBooleanUIUpdate 532*cdf0e10cSrcweir //============================================================ 533*cdf0e10cSrcweir /** an interface which encapsulates access to a single aspect of the ->XObjectInspectorUI, 534*cdf0e10cSrcweir where this aspect is given by a string key, and has a boolean value. 535*cdf0e10cSrcweir */ 536*cdf0e10cSrcweir class IStringKeyBooleanUIUpdate 537*cdf0e10cSrcweir { 538*cdf0e10cSrcweir public: 539*cdf0e10cSrcweir virtual void updateUIForKey( const ::rtl::OUString& _rKey, sal_Bool _bFlag ) const = 0; 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir virtual ~IStringKeyBooleanUIUpdate() { } 542*cdf0e10cSrcweir }; 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir //============================================================ 545*cdf0e10cSrcweir //= FPropertyUIFlagSetter 546*cdf0e10cSrcweir //============================================================ 547*cdf0e10cSrcweir /** an implementation of the ->IStringKeyBooleanUIUpdate interface which, 548*cdf0e10cSrcweir for a fixed ->XObjectInspectorUI instance and a fixed UI element (->PropertyLineElement), 549*cdf0e10cSrcweir updates this element for a given property with a given boolean flag 550*cdf0e10cSrcweir (->XObjectInspectorUI::enablePropertyUIElements) 551*cdf0e10cSrcweir */ 552*cdf0e10cSrcweir class EnablePropertyUIElement : public IStringKeyBooleanUIUpdate 553*cdf0e10cSrcweir { 554*cdf0e10cSrcweir private: 555*cdf0e10cSrcweir Reference< XObjectInspectorUI > m_xUIUpdate; 556*cdf0e10cSrcweir sal_Int16 m_nElement; 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir public: 559*cdf0e10cSrcweir EnablePropertyUIElement( const Reference< XObjectInspectorUI >& _rxUIUpdate, sal_Int16 _nElement ) 560*cdf0e10cSrcweir :m_xUIUpdate( _rxUIUpdate ) 561*cdf0e10cSrcweir ,m_nElement( _nElement ) 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir // IStringKeyBooleanUIUpdate 565*cdf0e10cSrcweir virtual void updateUIForKey( const ::rtl::OUString& _rKey, sal_Bool _bFlag ) const; 566*cdf0e10cSrcweir }; 567*cdf0e10cSrcweir 568*cdf0e10cSrcweir //............................................................ 569*cdf0e10cSrcweir void EnablePropertyUIElement::updateUIForKey( const ::rtl::OUString& _rKey, sal_Bool _bFlag ) const 570*cdf0e10cSrcweir { 571*cdf0e10cSrcweir m_xUIUpdate->enablePropertyUIElements( _rKey, m_nElement, _bFlag ); 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir //============================================================ 575*cdf0e10cSrcweir //= FPropertyUIFlagSetter 576*cdf0e10cSrcweir //============================================================ 577*cdf0e10cSrcweir /** a ->XObjectInspectorUI method taking a string and a boolean 578*cdf0e10cSrcweir */ 579*cdf0e10cSrcweir typedef void ( SAL_CALL XObjectInspectorUI::*FPropertyUIFlagSetter )( const ::rtl::OUString&, sal_Bool ); 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir //============================================================ 582*cdf0e10cSrcweir //= DefaultStringKeyBooleanUIUpdate 583*cdf0e10cSrcweir //============================================================ 584*cdf0e10cSrcweir /** an implementaiton of the ->IStringKeyBooleanUIUpdate interface which calls 585*cdf0e10cSrcweir am arbitrary ->XObjectInspectorUI method taking a string and a boolean flag 586*cdf0e10cSrcweir */ 587*cdf0e10cSrcweir class DefaultStringKeyBooleanUIUpdate : public IStringKeyBooleanUIUpdate 588*cdf0e10cSrcweir { 589*cdf0e10cSrcweir private: 590*cdf0e10cSrcweir Reference< XObjectInspectorUI > m_xUIUpdate; 591*cdf0e10cSrcweir FPropertyUIFlagSetter m_pSetter; 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir public: 594*cdf0e10cSrcweir DefaultStringKeyBooleanUIUpdate( const Reference< XObjectInspectorUI >& _rxUIUpdate, FPropertyUIFlagSetter _pSetter ); 595*cdf0e10cSrcweir // IStringKeyBooleanUIUpdate 596*cdf0e10cSrcweir virtual void updateUIForKey( const ::rtl::OUString& _rKey, sal_Bool _bFlag ) const; 597*cdf0e10cSrcweir }; 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir //............................................................ 600*cdf0e10cSrcweir DefaultStringKeyBooleanUIUpdate::DefaultStringKeyBooleanUIUpdate( const Reference< XObjectInspectorUI >& _rxUIUpdate, FPropertyUIFlagSetter _pSetter ) 601*cdf0e10cSrcweir :m_xUIUpdate( _rxUIUpdate ) 602*cdf0e10cSrcweir ,m_pSetter( _pSetter ) 603*cdf0e10cSrcweir { 604*cdf0e10cSrcweir } 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir //............................................................ 607*cdf0e10cSrcweir void DefaultStringKeyBooleanUIUpdate::updateUIForKey( const ::rtl::OUString& _rKey, sal_Bool _bFlag ) const 608*cdf0e10cSrcweir { 609*cdf0e10cSrcweir ((m_xUIUpdate.get())->*m_pSetter)( _rKey, _bFlag ); 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir //============================================================ 613*cdf0e10cSrcweir //= BooleanUIAspectUpdate 614*cdf0e10cSrcweir //============================================================ 615*cdf0e10cSrcweir /** an STL-compatible structure which applies a ->IStringKeyBooleanUIUpdate::updateUIForKey 616*cdf0e10cSrcweir operation with a fixed boolean value, for a given string value 617*cdf0e10cSrcweir */ 618*cdf0e10cSrcweir struct BooleanUIAspectUpdate : public ::std::unary_function< ::rtl::OUString, void > 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir private: 621*cdf0e10cSrcweir const IStringKeyBooleanUIUpdate& m_rUpdater; 622*cdf0e10cSrcweir sal_Bool m_bFlag; 623*cdf0e10cSrcweir 624*cdf0e10cSrcweir public: 625*cdf0e10cSrcweir BooleanUIAspectUpdate( const IStringKeyBooleanUIUpdate& _rUpdater, sal_Bool _bFlag ) 626*cdf0e10cSrcweir :m_rUpdater( _rUpdater ) 627*cdf0e10cSrcweir ,m_bFlag( _bFlag ) 628*cdf0e10cSrcweir { 629*cdf0e10cSrcweir } 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir void operator()( const ::rtl::OUString& _rPropertyName ) 632*cdf0e10cSrcweir { 633*cdf0e10cSrcweir m_rUpdater.updateUIForKey( _rPropertyName, m_bFlag ); 634*cdf0e10cSrcweir } 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir static void forEach( const StringBag& _rProperties, const IStringKeyBooleanUIUpdate& _rUpdater, sal_Bool _bFlag ) 637*cdf0e10cSrcweir { 638*cdf0e10cSrcweir ::std::for_each( _rProperties.begin(), _rProperties.end(), BooleanUIAspectUpdate( _rUpdater, _bFlag ) ); 639*cdf0e10cSrcweir } 640*cdf0e10cSrcweir }; 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir //============================================================ 643*cdf0e10cSrcweir //= BooleanUIAspectUpdate 644*cdf0e10cSrcweir //============================================================ 645*cdf0e10cSrcweir /** an STL-compatible structure subtracting a given string from a fixed ->StringBag 646*cdf0e10cSrcweir */ 647*cdf0e10cSrcweir struct StringBagComplement : public ::std::unary_function< ::rtl::OUString, void > 648*cdf0e10cSrcweir { 649*cdf0e10cSrcweir private: 650*cdf0e10cSrcweir StringBag& m_rMinuend; 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir public: 653*cdf0e10cSrcweir StringBagComplement( StringBag& _rMinuend ) :m_rMinuend( _rMinuend ) { } 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir void operator()( const ::rtl::OUString& _rPropertyToSubtract ) 656*cdf0e10cSrcweir { 657*cdf0e10cSrcweir m_rMinuend.erase( _rPropertyToSubtract ); 658*cdf0e10cSrcweir } 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir static void subtract( StringBag& _rMinuend, const StringBag& _rSubtrahend ) 661*cdf0e10cSrcweir { 662*cdf0e10cSrcweir ::std::for_each( _rSubtrahend.begin(), _rSubtrahend.end(), StringBagComplement( _rMinuend ) ); 663*cdf0e10cSrcweir } 664*cdf0e10cSrcweir }; 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir //============================================================ 667*cdf0e10cSrcweir //= BooleanUIAspectUpdate 668*cdf0e10cSrcweir //============================================================ 669*cdf0e10cSrcweir void lcl_fireUIStateFlag( 670*cdf0e10cSrcweir const IStringKeyBooleanUIUpdate& _rUIUpdate, 671*cdf0e10cSrcweir const ImplMapHandlerToUI& _rHandlerUIs, 672*cdf0e10cSrcweir CachedInspectorUI::FGetStringBag _pGetPositives, 673*cdf0e10cSrcweir CachedInspectorUI::FGetStringBag _pGetNegatives 674*cdf0e10cSrcweir ) 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir // all strings which are in the "positive" list of one handler 677*cdf0e10cSrcweir StringBag aAllPositives; 678*cdf0e10cSrcweir StringBagCollector::collectAll( aAllPositives, _rHandlerUIs, _pGetPositives ); 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir // all strings which are in the "negative" list of one handler 681*cdf0e10cSrcweir StringBag aAllNegatives; 682*cdf0e10cSrcweir StringBagCollector::collectAll( aAllNegatives, _rHandlerUIs, _pGetNegatives ); 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir // propagate the "negative" flags to the delegator UI 685*cdf0e10cSrcweir BooleanUIAspectUpdate::forEach( aAllNegatives, _rUIUpdate, sal_False ); 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir // propagate the "positive" flags to the delegator UI, for all elements where _no_ 688*cdf0e10cSrcweir // "negative" flag exists 689*cdf0e10cSrcweir StringBagComplement::subtract( aAllPositives, aAllNegatives ); 690*cdf0e10cSrcweir BooleanUIAspectUpdate::forEach( aAllPositives, _rUIUpdate, sal_True ); 691*cdf0e10cSrcweir 692*cdf0e10cSrcweir // the "positive" request can be cleared no, only negative requests 693*cdf0e10cSrcweir // (such as "disable a property" or "hide a category") need to be preserved for the next round 694*cdf0e10cSrcweir StringBagClearer::clearAll( _rHandlerUIs, _pGetPositives ); 695*cdf0e10cSrcweir } 696*cdf0e10cSrcweir } 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir //---------------------------------------------------------------- 699*cdf0e10cSrcweir void ComposedPropertyUIUpdate::impl_fireEnablePropertyUI_throw() 700*cdf0e10cSrcweir { 701*cdf0e10cSrcweir lcl_fireUIStateFlag( 702*cdf0e10cSrcweir DefaultStringKeyBooleanUIUpdate( m_xDelegatorUI, &XObjectInspectorUI::enablePropertyUI ), 703*cdf0e10cSrcweir m_pCollectedUIs->aHandlers, 704*cdf0e10cSrcweir &CachedInspectorUI::getEnabledProperties, 705*cdf0e10cSrcweir &CachedInspectorUI::getDisabledProperties 706*cdf0e10cSrcweir ); 707*cdf0e10cSrcweir } 708*cdf0e10cSrcweir 709*cdf0e10cSrcweir //---------------------------------------------------------------- 710*cdf0e10cSrcweir void ComposedPropertyUIUpdate::impl_fireRebuildPropertyUI_throw() 711*cdf0e10cSrcweir { 712*cdf0e10cSrcweir // collect all properties for which a rebuild request has been made 713*cdf0e10cSrcweir StringBag aAllRebuilt; 714*cdf0e10cSrcweir StringBagCollector::collectAll( aAllRebuilt, m_pCollectedUIs->aHandlers, &CachedInspectorUI::getRebuiltProperties ); 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir // rebuild all those properties 717*cdf0e10cSrcweir PropertyUIOperator::forEach( aAllRebuilt, m_xDelegatorUI, &XObjectInspectorUI::rebuildPropertyUI ); 718*cdf0e10cSrcweir 719*cdf0e10cSrcweir // clear the "properties to rebuild" at all handlers, since the request has been fulfilled now. 720*cdf0e10cSrcweir StringBagClearer::clearAll( m_pCollectedUIs->aHandlers, &CachedInspectorUI::getRebuiltProperties ); 721*cdf0e10cSrcweir } 722*cdf0e10cSrcweir 723*cdf0e10cSrcweir //---------------------------------------------------------------- 724*cdf0e10cSrcweir void ComposedPropertyUIUpdate::impl_fireShowHidePropertyUI_throw() 725*cdf0e10cSrcweir { 726*cdf0e10cSrcweir // all properties which have been shown by at least one handler 727*cdf0e10cSrcweir StringBag aAllShown; 728*cdf0e10cSrcweir StringBagCollector::collectAll( aAllShown, m_pCollectedUIs->aHandlers, &CachedInspectorUI::getShownProperties ); 729*cdf0e10cSrcweir // all properties which have been hidden by at least one handler 730*cdf0e10cSrcweir StringBag aAllHidden; 731*cdf0e10cSrcweir StringBagCollector::collectAll( aAllHidden, m_pCollectedUIs->aHandlers, &CachedInspectorUI::getHiddenProperties ); 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir // hide properties as necessary 734*cdf0e10cSrcweir PropertyUIOperator::forEach( aAllHidden, m_xDelegatorUI, &XObjectInspectorUI::hidePropertyUI ); 735*cdf0e10cSrcweir 736*cdf0e10cSrcweir // for those properties which are hidden, ignore all "show" requests which other handlers might have had 737*cdf0e10cSrcweir StringBagComplement::subtract( aAllShown, aAllHidden ); 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir // show properties 740*cdf0e10cSrcweir PropertyUIOperator::forEach( aAllShown, m_xDelegatorUI, &XObjectInspectorUI::showPropertyUI ); 741*cdf0e10cSrcweir } 742*cdf0e10cSrcweir 743*cdf0e10cSrcweir //---------------------------------------------------------------- 744*cdf0e10cSrcweir void ComposedPropertyUIUpdate::impl_fireShowCategory_throw() 745*cdf0e10cSrcweir { 746*cdf0e10cSrcweir lcl_fireUIStateFlag( 747*cdf0e10cSrcweir DefaultStringKeyBooleanUIUpdate( m_xDelegatorUI, &XObjectInspectorUI::showCategory ), 748*cdf0e10cSrcweir m_pCollectedUIs->aHandlers, 749*cdf0e10cSrcweir &CachedInspectorUI::getShownCategories, 750*cdf0e10cSrcweir &CachedInspectorUI::getHiddenCategories 751*cdf0e10cSrcweir ); 752*cdf0e10cSrcweir } 753*cdf0e10cSrcweir 754*cdf0e10cSrcweir //---------------------------------------------------------------- 755*cdf0e10cSrcweir void ComposedPropertyUIUpdate::impl_fireEnablePropertyUIElements_throw() 756*cdf0e10cSrcweir { 757*cdf0e10cSrcweir lcl_fireUIStateFlag( 758*cdf0e10cSrcweir EnablePropertyUIElement( m_xDelegatorUI, PropertyLineElement::InputControl ), 759*cdf0e10cSrcweir m_pCollectedUIs->aHandlers, 760*cdf0e10cSrcweir &CachedInspectorUI::getEnabledInputControls, 761*cdf0e10cSrcweir &CachedInspectorUI::getDisabledInputControls 762*cdf0e10cSrcweir ); 763*cdf0e10cSrcweir 764*cdf0e10cSrcweir lcl_fireUIStateFlag( 765*cdf0e10cSrcweir EnablePropertyUIElement( m_xDelegatorUI, PropertyLineElement::PrimaryButton ), 766*cdf0e10cSrcweir m_pCollectedUIs->aHandlers, 767*cdf0e10cSrcweir &CachedInspectorUI::getEnabledPrimaryButtons, 768*cdf0e10cSrcweir &CachedInspectorUI::getDisabledPrimaryButtons 769*cdf0e10cSrcweir ); 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir lcl_fireUIStateFlag( 772*cdf0e10cSrcweir EnablePropertyUIElement( m_xDelegatorUI, PropertyLineElement::SecondaryButton ), 773*cdf0e10cSrcweir m_pCollectedUIs->aHandlers, 774*cdf0e10cSrcweir &CachedInspectorUI::getEnabledSecondaryButtons, 775*cdf0e10cSrcweir &CachedInspectorUI::getDisabledSecondaryButtons 776*cdf0e10cSrcweir ); 777*cdf0e10cSrcweir } 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir //-------------------------------------------------------------------- 780*cdf0e10cSrcweir void ComposedPropertyUIUpdate::impl_fireAll_throw() 781*cdf0e10cSrcweir { 782*cdf0e10cSrcweir OSL_PRECOND( !impl_isDisposed(), "ComposedPropertyUIUpdate::impl_fireAll_throw: already disposed, this will crash!" ); 783*cdf0e10cSrcweir 784*cdf0e10cSrcweir impl_fireEnablePropertyUI_throw(); 785*cdf0e10cSrcweir impl_fireShowHidePropertyUI_throw(); 786*cdf0e10cSrcweir impl_fireRebuildPropertyUI_throw(); 787*cdf0e10cSrcweir impl_fireShowCategory_throw(); 788*cdf0e10cSrcweir impl_fireEnablePropertyUIElements_throw(); 789*cdf0e10cSrcweir } 790*cdf0e10cSrcweir 791*cdf0e10cSrcweir //-------------------------------------------------------------------- 792*cdf0e10cSrcweir void SAL_CALL ComposedPropertyUIUpdate::suspendAutoFire() 793*cdf0e10cSrcweir { 794*cdf0e10cSrcweir impl_checkDisposed(); 795*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_nSuspendCounter ); 796*cdf0e10cSrcweir } 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir //-------------------------------------------------------------------- 799*cdf0e10cSrcweir void SAL_CALL ComposedPropertyUIUpdate::resumeAutoFire() 800*cdf0e10cSrcweir { 801*cdf0e10cSrcweir impl_checkDisposed(); 802*cdf0e10cSrcweir if ( 0 == osl_decrementInterlockedCount( &m_nSuspendCounter ) ) 803*cdf0e10cSrcweir impl_fireAll_throw(); 804*cdf0e10cSrcweir } 805*cdf0e10cSrcweir 806*cdf0e10cSrcweir //---------------------------------------------------------------- 807*cdf0e10cSrcweir void ComposedPropertyUIUpdate::impl_checkDisposed() const 808*cdf0e10cSrcweir { 809*cdf0e10cSrcweir if ( impl_isDisposed() ) 810*cdf0e10cSrcweir throw DisposedException(); 811*cdf0e10cSrcweir } 812*cdf0e10cSrcweir 813*cdf0e10cSrcweir //---------------------------------------------------------------- 814*cdf0e10cSrcweir void ComposedPropertyUIUpdate::callback_inspectorUIChanged_throw() 815*cdf0e10cSrcweir { 816*cdf0e10cSrcweir if ( 0 == m_nSuspendCounter ) 817*cdf0e10cSrcweir impl_fireAll_throw(); 818*cdf0e10cSrcweir } 819*cdf0e10cSrcweir 820*cdf0e10cSrcweir //---------------------------------------------------------------- 821*cdf0e10cSrcweir Reference< XObjectInspectorUI > ComposedPropertyUIUpdate::getDelegatorUI() const 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir impl_checkDisposed(); 824*cdf0e10cSrcweir return m_xDelegatorUI; 825*cdf0e10cSrcweir } 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir //---------------------------------------------------------------- 828*cdf0e10cSrcweir void SAL_CALL ComposedPropertyUIUpdate::dispose() 829*cdf0e10cSrcweir { 830*cdf0e10cSrcweir if ( impl_isDisposed() ) 831*cdf0e10cSrcweir return; 832*cdf0e10cSrcweir 833*cdf0e10cSrcweir OSL_ENSURE( m_nSuspendCounter == 0, "ComposedPropertyUIUpdate::dispose: still suspended, the changes will be lost!" ); 834*cdf0e10cSrcweir 835*cdf0e10cSrcweir for ( ImplMapHandlerToUI::const_iterator singleUI = m_pCollectedUIs->aHandlers.begin(); 836*cdf0e10cSrcweir singleUI != m_pCollectedUIs->aHandlers.end(); 837*cdf0e10cSrcweir ++singleUI 838*cdf0e10cSrcweir ) 839*cdf0e10cSrcweir { 840*cdf0e10cSrcweir singleUI->second->dispose(); 841*cdf0e10cSrcweir } 842*cdf0e10cSrcweir m_pCollectedUIs.reset( NULL ); 843*cdf0e10cSrcweir m_xDelegatorUI.set( NULL ); 844*cdf0e10cSrcweir } 845*cdf0e10cSrcweir 846*cdf0e10cSrcweir //---------------------------------------------------------------- 847*cdf0e10cSrcweir bool ComposedPropertyUIUpdate::shouldContinuePropertyHandling( const ::rtl::OUString& _rName ) const 848*cdf0e10cSrcweir { 849*cdf0e10cSrcweir if ( !m_pPropertyCheck ) 850*cdf0e10cSrcweir return true; 851*cdf0e10cSrcweir if ( m_pPropertyCheck->hasPropertyByName( _rName ) ) 852*cdf0e10cSrcweir return true; 853*cdf0e10cSrcweir return false; 854*cdf0e10cSrcweir } 855*cdf0e10cSrcweir 856*cdf0e10cSrcweir //........................................................................ 857*cdf0e10cSrcweir } // namespace pcr 858*cdf0e10cSrcweir //........................................................................ 859*cdf0e10cSrcweir 860