summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2006-03-14 10:29:46 +0000
committerVladimir Glazounov <vg@openoffice.org>2006-03-14 10:29:46 +0000
commit69e3b64bbdf6a692236d1be1c298a62235840944 (patch)
treea232863a74394d75372a8ef49e76afd282be5e28 /extensions
parent879473de578e3221fc50321c71bf1bfb70dd3947 (diff)
INTEGRATION: CWS pbrwuno (1.4.88); FILE MERGED
2006/03/09 14:14:29 fs 1.4.88.15: #i62967# no UnknownPropertyExceptions at the XObjectInspectorUI anymore 2005/11/02 12:17:19 fs 1.4.88.14: #i10000# exception specifications 2005/11/02 11:43:44 fs 1.4.88.13: #i10000# exception specifications 2005/10/31 11:13:08 fs 1.4.88.12: teach the ComposedPropertyUIUpdate to handle missing properties 2005/10/25 07:13:14 fs 1.4.88.11: #i53095# knitting lose ends (amongst others, make the handlers available as service) 2005/10/17 14:09:35 fs 1.4.88.10: #i53095# some cleanup of remaining TODOs 2005/10/17 08:58:18 fs 1.4.88.9: some mutex locking 2005/10/13 13:01:09 fs 1.4.88.8: #i53095# introduce an XObjectInspector/Model 2005/10/11 13:29:39 fs 1.4.88.7: #i53095# phase 3: introduced XPropertyHandler and XObjectInspectorUI same open issues as in previous phase (plus probably some more, since not everything is tested, yet :-\) 2005/10/05 07:06:45 fs 1.4.88.6: RESYNC: (1.4-1.5); FILE MERGED 2005/09/05 07:41:53 fs 1.4.88.5: #i53095# phase 3, part 1: introduced XPropertyControl and relatives, describing one control in the ObjectInspector, responsible for one property known issues: - rebuildPropertyUI can cause problems now: If the user clicks into the control for property A, which causes property B to be committed, which causes the UI for property A to be rebuilt, then this will crash currently. Reason: rebuildPropertyUI now synchronously replaces the VCL-Window of the rebuilt control, which is exactly the one which is still in some MouseButtonDown-handler. possible solutions: - see if rebuiltPropertyUI can be obsoleted - handlers should be able to just obtain the XPropertyControl from the PropertyUI, and re-initialize the control. Shouldn't they?` - make one of the steps in the chain (mouse-click, handler-call, rebuildPropertyUI-callback) asynchronous. 2005/08/18 12:44:33 fs 1.4.88.4: #i53095#, phase 2 moved (nearly) all property handling to dedicated handlers, the controller is now simply managing a set of handlers open issues for making the property browser completely generic: - target page for a property - at the moment, the pbrw uses form-specific knowledge - relative position of properties. Again, the pbrw uses the OPropertyInfoService which is not generic - isComposeable for a given property. Also OPropertyInfoService-dependent ATM - help ids of pages and the pbrw as a whole. They're hard-coded at the moment other open issues: everything in the code which is tagged with TOD/UNOize. Those are items which do not immediately hinder phase 3 (real UNOization, i.e. definition of new UNO interfaces for the handlers, the controller, and so on), but need to be addressed in phase 4 (knit lose ends) 2005/08/12 16:30:14 fs 1.4.88.3: - more fine-grained control in the IPropertyBrowserUI which elements to enable or disable - moved designing the SQL command into a dedicated handler - some more reactions on actuating properties move to dedicated handlers - *nearly* completed implementation of the "composed browser UI", which collects and combines UI change requests (IPropertyBrowserUI) (still missing: proper auto-firing) 2005/08/10 15:41:47 fs 1.4.88.2: #i53095# get rid of nearly all [1] the implementations in OPropertyBrowserController::Clicked, and move them to a FormComponentHandler [1] still to migrate: - browsing for events (needs a dedicated event property handler) - handling for clicking the button of the Command property - this is kind of asynchronous, and IPropertyHandler is not yet prepared for this 2005/08/09 14:00:05 fs 1.4.88.1: #i53095# phase 1: - don't use strings to transver values between controls and introspectee, but Anys - first version of a dedicated property handler for form-component-related properties (not yet completed) known regressions over previous phase: - handlers for events not yet implemented, thus some assertions - click handlers for form-component-related properties do not yet work, thus the browse buttons mostly do not work
Diffstat (limited to 'extensions')
-rw-r--r--extensions/source/propctrlr/propertycomposer.cxx630
1 files changed, 276 insertions, 354 deletions
diff --git a/extensions/source/propctrlr/propertycomposer.cxx b/extensions/source/propctrlr/propertycomposer.cxx
index 264702a434e0..8dc3563d019a 100644
--- a/extensions/source/propctrlr/propertycomposer.cxx
+++ b/extensions/source/propctrlr/propertycomposer.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: propertycomposer.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: rt $ $Date: 2005-09-08 20:23:48 $
+ * last change: $Author: vg $ $Date: 2006-03-14 11:29:46 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -35,17 +35,14 @@
#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
#include "propertycomposer.hxx"
#endif
-#ifndef _EXTENSIONS_FORMSCTRLR_FORMBROWSERTOOLS_HXX_
-#include "formbrowsertools.hxx"
-#endif
-#ifndef _EXTENSIONS_PROPCTRLR_FORMMETADATA_HXX_
-#include "formmetadata.hxx"
-#endif
-#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPBROWSERUI_HXX
-#include "propbrowserui.hxx"
-#endif
/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_LANG_NULLPOINTEREXCEPTION_HPP_
+#include <com/sun/star/lang/NullPointerException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
/** === end UNO includes === **/
#ifndef _OSL_DIAGNOSE_H_
@@ -54,7 +51,6 @@
#include <functional>
#include <algorithm>
-#include <set>
#include <map>
//........................................................................
@@ -64,248 +60,40 @@ namespace pcr
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::inspection;
//====================================================================
//= helper
//====================================================================
namespace
{
- typedef ::std::set< Property, LessPropertyByHandle > PropertyBag;
-
- //----------------------------------------------------------------
- /** STL-compatible operator which detrmines whether a given <type>IPropertyHandler</type>
- supports an UI descriptor for a given property
- */
- struct SupportsUIDescriptor : public ::std::unary_function< ::rtl::Reference< IPropertyHandler >, bool >
- {
- PropertyId nId;
- SupportsUIDescriptor( PropertyId _nId ) : nId( _nId ) { }
- bool operator()( const ::rtl::Reference< IPropertyHandler >& _rHandler )
- {
- return _rHandler->supportsUIDescriptor( nId );
- }
- };
-
//----------------------------------------------------------------
- /** STL-compatible operator which determines whether a given <type>IPropertyHandler</type>
- supports a given property
- */
- struct SupportsProperty : public ::std::unary_function< ::rtl::Reference< IPropertyHandler >, bool >
+ struct SetPropertyValue : public ::std::unary_function< Reference< XPropertyHandler >, void >
{
- PropertyId nId;
- SupportsProperty( PropertyId _nId ) : nId( _nId ) { }
- bool operator()( const ::rtl::Reference< IPropertyHandler >& _rHandler )
+ ::rtl::OUString sPropertyName;
+ const Any& rValue;
+ SetPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) : sPropertyName( _rPropertyName ), rValue( _rValue ) { }
+ void operator()( const Reference< XPropertyHandler >& _rHandler )
{
- const ::std::vector< Property > aSupported( _rHandler->getSupportedProperties( ) );
- return aSupported.end() != ::std::find_if( aSupported.begin(), aSupported.end(), FindPropertyByHandle( nId ) );
- }
- };
-
- //----------------------------------------------------------------
- struct SetPropertyValue : public ::std::unary_function< ::rtl::Reference< IPropertyHandler >, void >
- {
- PropertyId nId;
- const Any& rValue;
- SetPropertyValue( PropertyId _nId, const Any& _rValue ) : nId( _nId ), rValue( _rValue ) { }
- void operator()( const ::rtl::Reference< IPropertyHandler >& _rHandler )
- {
- _rHandler->setPropertyValue( nId, rValue );
+ _rHandler->setPropertyValue( sPropertyName, rValue );
}
};
//----------------------------------------------------------------
template < class BagType >
- void putIntoBag( const ::std::vector< typename BagType::value_type >& _rArray, BagType& /* [out] */ _rBag )
+ void putIntoBag( const Sequence< typename BagType::value_type >& _rArray, BagType& /* [out] */ _rBag )
{
- ::std::copy( _rArray.begin(), _rArray.end(),
+ ::std::copy( _rArray.getConstArray(), _rArray.getConstArray() + _rArray.getLength(),
::std::insert_iterator< BagType >( _rBag, _rBag.begin() ) );
}
//----------------------------------------------------------------
template < class BagType >
- void copyBagToArray( const BagType& /* [out] */ _rBag, ::std::vector< typename BagType::value_type >& _rArray )
+ void copyBagToArray( const BagType& /* [out] */ _rBag, Sequence< typename BagType::value_type >& _rArray )
{
- _rArray.resize( _rBag.size() );
- ::std::copy( _rBag.begin(), _rBag.end(), _rArray.begin() );
- }
-
- //================================================================
- //= ComposedPropertyUIUpdate
- //================================================================
- class ComposedPropertyUIUpdate : public IPropertyBrowserUI
- {
- private:
- typedef ::std::map< ::rtl::OUString, bool > MapStringToBool;
- typedef ::std::map< ::rtl::OUString, ::std::pair< bool, bool > > MapStringToBoolPair;
- typedef ::std::set< ::rtl::OUString > StringBag;
- typedef ::std::map< EPropertyCategory, bool > MapCategoryToBool;
-
- private:
- IPropertyBrowserUI* m_pMasterUpdater;
- MapStringToBool m_aEnabledProperties;
- MapStringToBoolPair m_EnabledButtons;
- StringBag m_aRebuiltProperties;
- MapStringToBool m_aShownProperties;
- StringBag m_aHiddenProperties;
- MapCategoryToBool m_aShownCategories;
-
- public:
- ComposedPropertyUIUpdate( IPropertyBrowserUI* _pMasterUpdater );
- ~ComposedPropertyUIUpdate();
-
- // IPropertyBrowserUI overridables
- virtual void enablePropertyUI( const ::rtl::OUString& _rPropertyName, bool _bEnable );
- virtual void enablePropertyButtons( const ::rtl::OUString& _rPropertyName, bool _bEnablePrimary, bool _bEnableSecondary );
- virtual void rebuildPropertyUI( const ::rtl::OUString& _rPropertyName );
- virtual void showPropertyUI( const ::rtl::OUString& _rPropertyName, bool _bRefreshIfExistent );
- virtual void hidePropertyUI( const ::rtl::OUString& _rPropertyName );
- virtual void showCategory( EPropertyCategory _eCategory, bool _bShow );
-
- private:
- ComposedPropertyUIUpdate(); // never implemented
- };
-
- //----------------------------------------------------------------
- ComposedPropertyUIUpdate::ComposedPropertyUIUpdate( IPropertyBrowserUI* _pMasterUpdater )
- :m_pMasterUpdater( _pMasterUpdater )
- {
- OSL_ENSURE( m_pMasterUpdater, "ComposedPropertyUIUpdate::ComposedPropertyUIUpdate: whom should I forward this to?" );
- }
-
- //----------------------------------------------------------------
- ComposedPropertyUIUpdate::~ComposedPropertyUIUpdate( )
- {
- if ( m_pMasterUpdater )
- {
- // forward the collected requests to the master updater
- // --- enablePropertyUI
- for ( MapStringToBool::const_iterator loop = m_aEnabledProperties.begin();
- loop != m_aEnabledProperties.end();
- ++loop
- )
- {
- m_pMasterUpdater->enablePropertyUI( loop->first, loop->second );
- }
- // --- enablePropertyButtons
- for ( MapStringToBoolPair::const_iterator loop = m_EnabledButtons.begin();
- loop != m_EnabledButtons.end();
- ++loop
- )
- {
- m_pMasterUpdater->enablePropertyButtons( loop->first, loop->second.first, loop->second.second );
- }
- // --- rebuildPropertyUI
- for ( StringBag::const_iterator loop = m_aRebuiltProperties.begin();
- loop != m_aRebuiltProperties.end();
- ++loop
- )
- {
- m_pMasterUpdater->rebuildPropertyUI( *loop );
- }
- // --- showPropertyUI
- for ( MapStringToBool::const_iterator loop = m_aShownProperties.begin();
- loop != m_aShownProperties.end();
- ++loop
- )
- {
- if ( m_aHiddenProperties.find( loop->first ) == m_aHiddenProperties.end() )
- m_pMasterUpdater->showPropertyUI( loop->first, loop->second );
- }
- // --- hidePropertyUI
- for ( StringBag::const_iterator loop = m_aHiddenProperties.begin();
- loop != m_aHiddenProperties.end();
- ++loop
- )
- {
- m_pMasterUpdater->hidePropertyUI( *loop );
- }
- // --- showCategory
- for ( MapCategoryToBool::const_iterator loop = m_aShownCategories.begin();
- loop != m_aShownCategories.end();
- ++loop
- )
- {
- m_pMasterUpdater->showCategory( loop->first, loop->second );
- }
- }
- }
-
- //----------------------------------------------------------------
- void ComposedPropertyUIUpdate::enablePropertyUI( const ::rtl::OUString& _rPropertyName, bool _bEnable )
- {
- MapStringToBool::iterator aPos = m_aEnabledProperties.find( _rPropertyName );
- if ( aPos == m_aEnabledProperties.end() )
- {
- // encountered this property for the first time -> only remember the flag for now
- m_aEnabledProperties[ _rPropertyName ] = _bEnable;
- }
- else
- {
- // already encountered this property before. The property is enabled if and only if
- // *all* of our callees say it should be.
- aPos->second &= _bEnable;
- }
- }
-
- //----------------------------------------------------------------
- void ComposedPropertyUIUpdate::enablePropertyButtons( const ::rtl::OUString& _rPropertyName, bool _bEnablePrimary, bool _bEnableSecondary )
- {
- MapStringToBoolPair::iterator aPos = m_EnabledButtons.find( _rPropertyName );
- if ( aPos == m_EnabledButtons.end() )
- {
- m_EnabledButtons[ _rPropertyName ] = MapStringToBoolPair::mapped_type( _bEnablePrimary, _bEnableSecondary );
- }
- else
- {
- aPos->second.first &= _bEnablePrimary;
- aPos->second.second &= _bEnableSecondary;
- }
- }
-
- //----------------------------------------------------------------
- void ComposedPropertyUIUpdate::rebuildPropertyUI( const ::rtl::OUString& _rPropertyName )
- {
- m_aRebuiltProperties.insert( _rPropertyName );
- }
-
- //----------------------------------------------------------------
- void ComposedPropertyUIUpdate::showPropertyUI( const ::rtl::OUString& _rPropertyName, bool _bRefreshIfExistent )
- {
- MapStringToBool::iterator aPos = m_aShownProperties.find( _rPropertyName );
- if ( aPos == m_aShownProperties.end() )
- {
- // encountered this property for the first time -> only remember the flag for now
- m_aShownProperties[ _rPropertyName ] = _bRefreshIfExistent;
- }
- else
- {
- // already encountered this property before. The UI needs to be refreshed if at least one of
- // our callees says so
- aPos->second |= _bRefreshIfExistent;
- }
- }
-
- //----------------------------------------------------------------
- void ComposedPropertyUIUpdate::hidePropertyUI( const ::rtl::OUString& _rPropertyName )
- {
- m_aHiddenProperties.insert( _rPropertyName );
- }
-
- //----------------------------------------------------------------
- void ComposedPropertyUIUpdate::showCategory( EPropertyCategory _eCategory, bool _bShow )
- {
- MapCategoryToBool::iterator aPos = m_aShownCategories.find( _eCategory );
- if ( aPos == m_aShownCategories.end() )
- {
- // encountered this category for the first time -> only remember the flag for now
- m_aShownCategories[ _eCategory ] = _bShow;
- }
- else
- {
- // already encountered this category before. The category must be shown if *all*
- // of our callees say so
- aPos->second &= _bShow;
- }
+ _rArray.realloc( _rBag.size() );
+ ::std::copy( _rBag.begin(), _rBag.end(), _rArray.getArray() );
}
}
@@ -319,85 +107,86 @@ namespace pcr
// of supported properties per handler). Shouldn't we cache this? So that it is O( log k )?
//--------------------------------------------------------------------
- PropertyComposer::PropertyComposer( const ::std::vector< ::rtl::Reference< IPropertyHandler > >& _rSlaveHandlers )
- :m_aSlaveHandlers( _rSlaveHandlers )
- ,m_pInfoService ( new OPropertyInfoService )
- ,m_refCount ( 0 )
+ PropertyComposer::PropertyComposer( const ::std::vector< Reference< XPropertyHandler > >& _rSlaveHandlers )
+ :PropertyComposer_Base ( m_aMutex )
+ ,m_aSlaveHandlers ( _rSlaveHandlers )
+ ,m_aPropertyListeners ( m_aMutex )
+ ,m_bSupportedPropertiesAreKnown ( false )
{
-#if OSL_DEBUG_LEVEL > 0
- for ( HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
- loop != m_aSlaveHandlers.end();
- ++loop
- )
+ if ( m_aSlaveHandlers.empty() )
+ throw IllegalArgumentException();
+
+ osl_incrementInterlockedCount( &m_refCount );
{
- OSL_ENSURE( loop->is(), "PropertyComposer::PropertyComposer: invalid slave handler (NULL)!" );
+ Reference< XPropertyChangeListener > xMeMyselfAndI( this );
+ for ( HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ if ( !loop->is() )
+ throw NullPointerException();
+ (*loop)->addPropertyChangeListener( xMeMyselfAndI );
+ }
}
-#endif
- OSL_ENSURE( !m_aSlaveHandlers.empty(), "PropertyComposer::PropertyComposer: handler array must not be empty! This will crash!" );
+ osl_decrementInterlockedCount( &m_refCount );
}
//--------------------------------------------------------------------
- oslInterlockedCount SAL_CALL PropertyComposer::acquire()
+ void SAL_CALL PropertyComposer::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException)
{
- return osl_incrementInterlockedCount( &m_refCount );
- }
+ MethodGuard aGuard( *this );
- //--------------------------------------------------------------------
- oslInterlockedCount SAL_CALL PropertyComposer::release()
- {
- if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
+ for ( HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
{
- delete this;
- return 0;
+ (*loop)->inspect( _rxIntrospectee );
}
- return m_refCount;
- }
-
- //--------------------------------------------------------------------
- bool SAL_CALL PropertyComposer::supportsUIDescriptor( PropertyId _nPropId ) const
- {
- // if at least one of our slaves does, we do, too
- return m_aSlaveHandlers.end() != ::std::find_if( m_aSlaveHandlers.begin(), m_aSlaveHandlers.end(), SupportsUIDescriptor( _nPropId ) );
}
//--------------------------------------------------------------------
- Any SAL_CALL PropertyComposer::getPropertyValue( PropertyId _nPropId, bool _bLazy ) const
+ Any SAL_CALL PropertyComposer::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
{
- return m_aSlaveHandlers.empty() ? Any() : m_aSlaveHandlers[0]->getPropertyValue( _nPropId, _bLazy );
+ MethodGuard aGuard( *this );
+ return m_aSlaveHandlers[0]->getPropertyValue( _rPropertyName );
}
//--------------------------------------------------------------------
- void SAL_CALL PropertyComposer::setPropertyValue( PropertyId _nPropId, const Any& _rValue )
+ void SAL_CALL PropertyComposer::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
{
- ::std::for_each( m_aSlaveHandlers.begin(), m_aSlaveHandlers.end(), SetPropertyValue( _nPropId, _rValue ) );
+ MethodGuard aGuard( *this );
+ ::std::for_each( m_aSlaveHandlers.begin(), m_aSlaveHandlers.end(), SetPropertyValue( _rPropertyName, _rValue ) );
}
//--------------------------------------------------------------------
- Any SAL_CALL PropertyComposer::getPropertyValueFromStringRep( PropertyId _nPropId, const ::rtl::OUString& _rStringRep ) const
+ Any SAL_CALL PropertyComposer::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
{
- return m_aSlaveHandlers.empty() ? Any() : m_aSlaveHandlers[0]->getPropertyValueFromStringRep( _nPropId, _rStringRep );
+ MethodGuard aGuard( *this );
+ return m_aSlaveHandlers[0]->convertToPropertyValue( _rPropertyName, _rControlValue );
}
//--------------------------------------------------------------------
- ::rtl::OUString SAL_CALL PropertyComposer::getStringRepFromPropertyValue( PropertyId _nPropId, const Any& _rValue ) const
+ Any SAL_CALL PropertyComposer::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
{
- return m_aSlaveHandlers.empty() ? ::rtl::OUString() : m_aSlaveHandlers[0]->getStringRepFromPropertyValue( _nPropId, _rValue );
+ MethodGuard aGuard( *this );
+ return m_aSlaveHandlers[0]->convertToControlValue( _rPropertyName, _rPropertyValue, _rControlValueType );
}
//--------------------------------------------------------------------
- PropertyState SAL_CALL PropertyComposer::getPropertyState( PropertyId _nPropId ) const
+ PropertyState SAL_CALL PropertyComposer::getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
{
- if ( m_aSlaveHandlers.empty() )
- return PropertyState_DIRECT_VALUE;
+ MethodGuard aGuard( *this );
// assume DIRECT for the moment. This will stay this way if *all* slaves
// tell the property has DIRECT state, and if *all* values equal
PropertyState eState = PropertyState_DIRECT_VALUE;
// check the master state
- ::rtl::Reference< IPropertyHandler > pPrimary( *m_aSlaveHandlers.begin() );
- Any aPrimaryValue = pPrimary->getPropertyValue( _nPropId );
- eState = pPrimary->getPropertyState( _nPropId );
+ Reference< XPropertyHandler > xPrimary( *m_aSlaveHandlers.begin() );
+ Any aPrimaryValue = xPrimary->getPropertyValue( _rPropertyName );
+ eState = xPrimary->getPropertyState( _rPropertyName );
// loop through the secondary sets
PropertyState eSecondaryState = PropertyState_DIRECT_VALUE;
@@ -407,10 +196,10 @@ namespace pcr
)
{
// the secondary state
- eSecondaryState = (*loop)->getPropertyState( _nPropId );
+ eSecondaryState = (*loop)->getPropertyState( _rPropertyName );
// the secondary value
- Any aSecondaryValue( (*loop)->getPropertyValue( _nPropId ) );
+ Any aSecondaryValue( (*loop)->getPropertyValue( _rPropertyName ) );
if ( ( PropertyState_AMBIGUOUS_VALUE == eSecondaryState ) // secondary is ambiguous
|| ( aPrimaryValue != aSecondaryValue ) // unequal values
@@ -425,60 +214,82 @@ namespace pcr
}
//--------------------------------------------------------------------
- void SAL_CALL PropertyComposer::startAllPropertyChangeListening( const Reference< XPropertyChangeListener >& _rxListener )
+ void SAL_CALL PropertyComposer::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
{
- // TODO: place your code here
+ MethodGuard aGuard( *this );
+ m_aPropertyListeners.addListener( _rxListener );
}
//--------------------------------------------------------------------
- void SAL_CALL PropertyComposer::stopAllPropertyChangeListening( )
+ void SAL_CALL PropertyComposer::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
{
- // TODO: place your code here
+ MethodGuard aGuard( *this );
+ m_aPropertyListeners.removeListener( _rxListener );
}
//--------------------------------------------------------------------
- ::std::vector< Property > SAL_CALL PropertyComposer::getSupportedProperties() const
+ Sequence< Property > SAL_CALL PropertyComposer::getSupportedProperties() throw (RuntimeException)
{
- OSL_ENSURE( !m_aSlaveHandlers.empty(), "PropertyComposer::getSupportedProperties: too less handlers!" );
- if ( m_aSlaveHandlers.empty() )
- return ::std::vector< Property >();
+ MethodGuard aGuard( *this );
- // we support a property if and only if all of our slaves support it
+ if ( !m_bSupportedPropertiesAreKnown )
+ {
+ // we support a property if and only if all of our slaves support it
- // initially, use all the properties of an arbitrary handler (we take the first one)
- PropertyBag aCadidatesForSupported;
- putIntoBag( (*m_aSlaveHandlers.begin())->getSupportedProperties(), aCadidatesForSupported );
+ // initially, use all the properties of an arbitrary handler (we take the first one)
+ putIntoBag( (*m_aSlaveHandlers.begin())->getSupportedProperties(), m_aSupportedProperties );
- // now intersect with the properties of *all* other handlers
- for ( HandlerArray::const_iterator loop = ( m_aSlaveHandlers.begin() + 1 );
- loop != m_aSlaveHandlers.end();
- ++loop
- )
- {
- PropertyBag aThisRound;
- putIntoBag( (*loop)->getSupportedProperties(), aThisRound );
+ // now intersect with the properties of *all* other handlers
+ for ( HandlerArray::const_iterator loop = ( m_aSlaveHandlers.begin() + 1 );
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ // the properties supported by the current handler
+ PropertyBag aThisRound;
+ putIntoBag( (*loop)->getSupportedProperties(), aThisRound );
- PropertyBag aIntersection;
- ::std::set_intersection( aThisRound.begin(), aThisRound.end(), aCadidatesForSupported.begin(), aCadidatesForSupported.end(),
- ::std::insert_iterator< PropertyBag >( aIntersection, aIntersection.begin() ), LessPropertyByHandle() );
+ // the intersection of those properties with all we already have
+ PropertyBag aIntersection;
+ ::std::set_intersection( aThisRound.begin(), aThisRound.end(), m_aSupportedProperties.begin(), m_aSupportedProperties.end(),
+ ::std::insert_iterator< PropertyBag >( aIntersection, aIntersection.begin() ), PropertyLessByName() );
- aCadidatesForSupported = aIntersection;
- if ( aCadidatesForSupported.empty() )
- break;
+ m_aSupportedProperties.swap( aIntersection );
+ if ( m_aSupportedProperties.empty() )
+ break;
+ }
+
+ // remove those properties which are not composable
+ for ( PropertyBag::iterator check = m_aSupportedProperties.begin();
+ check != m_aSupportedProperties.end();
+ )
+ {
+ sal_Bool bIsComposable = isComposable( check->Name );
+ if ( !bIsComposable )
+ {
+ PropertyBag::iterator next = check; ++next;
+ m_aSupportedProperties.erase( check );
+ check = next;
+ }
+ else
+ ++check;
+ }
+
+ m_bSupportedPropertiesAreKnown = true;
}
- ::std::vector< Property > aSurvived;
- copyBagToArray( aCadidatesForSupported, aSurvived );
+ Sequence< Property > aSurvived;
+ copyBagToArray( m_aSupportedProperties, aSurvived );
return aSurvived;
}
//--------------------------------------------------------------------
- void uniteStringArrays( const PropertyComposer::HandlerArray& _rHandlers, ::std::vector< ::rtl::OUString > (SAL_CALL IPropertyHandler::*pGetter)( void ) const,
- ::std::vector< ::rtl::OUString >& /* [out] */ _rUnion )
+ void uniteStringArrays( const PropertyComposer::HandlerArray& _rHandlers, Sequence< ::rtl::OUString > (SAL_CALL XPropertyHandler::*pGetter)( void ),
+ Sequence< ::rtl::OUString >& /* [out] */ _rUnion )
{
::std::set< ::rtl::OUString > aUnitedBag;
- ::std::vector< ::rtl::OUString > aThisRound;
+ Sequence< ::rtl::OUString > aThisRound;
for ( PropertyComposer::HandlerArray::const_iterator loop = _rHandlers.begin();
loop != _rHandlers.end();
++loop
@@ -492,96 +303,207 @@ namespace pcr
}
//--------------------------------------------------------------------
- ::std::vector< ::rtl::OUString > SAL_CALL PropertyComposer::getSupersededProperties( ) const
+ Sequence< ::rtl::OUString > SAL_CALL PropertyComposer::getSupersededProperties( ) throw (RuntimeException)
{
+ MethodGuard aGuard( *this );
+
// we supersede those properties which are superseded by at least one of our slaves
- ::std::vector< ::rtl::OUString > aSuperseded;
- uniteStringArrays( m_aSlaveHandlers, &IPropertyHandler::getSupersededProperties, aSuperseded );
+ Sequence< ::rtl::OUString > aSuperseded;
+ uniteStringArrays( m_aSlaveHandlers, &XPropertyHandler::getSupersededProperties, aSuperseded );
return aSuperseded;
}
//--------------------------------------------------------------------
- ::std::vector< ::rtl::OUString > SAL_CALL PropertyComposer::getActuatingProperties( ) const
+ Sequence< ::rtl::OUString > SAL_CALL PropertyComposer::getActuatingProperties( ) throw (RuntimeException)
{
+ MethodGuard aGuard( *this );
+
// we're interested in those properties which at least one handler wants to have
- ::std::vector< ::rtl::OUString > aActuating;
- uniteStringArrays( m_aSlaveHandlers, &IPropertyHandler::getActuatingProperties, aActuating );
+ Sequence< ::rtl::OUString > aActuating;
+ uniteStringArrays( m_aSlaveHandlers, &XPropertyHandler::getActuatingProperties, aActuating );
return aActuating;
}
//--------------------------------------------------------------------
- void SAL_CALL PropertyComposer::describePropertyUI( PropertyId _nPropId, PropertyUIDescriptor& /* [out] */ _rDescriptor ) const
+ void SAL_CALL PropertyComposer::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ LineDescriptor& /* [out] */ _rDescriptor, const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
{
- if ( !m_aSlaveHandlers.empty() )
- m_aSlaveHandlers[0]->describePropertyUI( _nPropId, _rDescriptor );
+ MethodGuard aGuard( *this );
+ m_aSlaveHandlers[0]->describePropertyLine( _rPropertyName, _rDescriptor, _rxControlFactory );
}
//--------------------------------------------------------------------
- void SAL_CALL PropertyComposer::initializePropertyUI( PropertyId _nPropId, IPropertyBrowserUI* _pUpdater )
+ ::sal_Bool SAL_CALL PropertyComposer::isComposable( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
{
- if ( !m_aSlaveHandlers.empty() )
- {
- ComposedPropertyUIUpdate aComposedUpdate( _pUpdater );
+ MethodGuard aGuard( *this );
+ return m_aSlaveHandlers[0]->isComposable( _rPropertyName );
+ }
- for ( HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
- loop != m_aSlaveHandlers.end();
- ++loop
- )
- (*loop)->initializePropertyUI( _nPropId, &aComposedUpdate );
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL PropertyComposer::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ MethodGuard aGuard( *this );
+
+ impl_ensureUIRequestComposer( _rxInspectorUI );
+ ComposedUIAutoFireGuard aAutoFireGuard( *m_pUIRequestComposer );
+
+ // ask the first of the handlers
+ InteractiveSelectionResult eResult = (*m_aSlaveHandlers.begin())->onInteractivePropertySelection(
+ _rPropertyName,
+ _bPrimary,
+ _rData,
+ m_pUIRequestComposer->getUIForPropertyHandler( *m_aSlaveHandlers.begin() )
+ );
+
+ switch ( eResult )
+ {
+ case InteractiveSelectionResult_Cancelled:
+ // fine
+ break;
+ case InteractiveSelectionResult_Success:
+ case InteractiveSelectionResult_Pending:
+ OSL_ENSURE( false, "PropertyComposer::onInteractivePropertySelection: not chance to forward the new value to the other handlers!" );
+ // This means that we cannot know the new property value, which either has already been set
+ // at the first component ("Success"), or will be set later on once the asynchronous input
+ // is finished ("Pending"). So, we also cannot forward this new property value to the other
+ // handlers.
+ // We would need to be a listener at the property at the first component, but even this wouldn't
+ // be sufficient, since the property handler is free to change *any* property during a dedicated
+ // property UI.
+ eResult = InteractiveSelectionResult_Cancelled;
+ break;
+ case InteractiveSelectionResult_ObtainedValue:
+ // OK. Our own caller will pass this as setPropertyValue, and we will then pass it to
+ // all slave handlers
+ break;
}
+
+ return eResult;
}
//--------------------------------------------------------------------
- bool SAL_CALL PropertyComposer::requestUserInputOnButtonClick( PropertyId _nPropId, bool _bPrimary, Any& _rData )
+ void PropertyComposer::impl_ensureUIRequestComposer( const Reference< XObjectInspectorUI >& _rxInspectorUI )
{
- if ( m_aSlaveHandlers.empty() )
- return false;
+ OSL_ENSURE( !m_pUIRequestComposer.get() || m_pUIRequestComposer->getDelegatorUI().get() == _rxInspectorUI.get(),
+ "PropertyComposer::impl_ensureUIRequestComposer: somebody's changing the horse in the mid of the race!" );
- // just ask the first of the handlers
- return (*m_aSlaveHandlers.begin())->requestUserInputOnButtonClick( _nPropId, _bPrimary, _rData );
+ if ( !m_pUIRequestComposer.get() )
+ m_pUIRequestComposer.reset( new ComposedPropertyUIUpdate( _rxInspectorUI, this ) );
}
//--------------------------------------------------------------------
- void SAL_CALL PropertyComposer::executeButtonClick( PropertyId _nPropId, bool _bPrimary, const Any& _rData, IPropertyBrowserUI* _pUpdater )
+ void SAL_CALL PropertyComposer::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& _rOldValue, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (NullPointerException, RuntimeException)
{
- if ( !m_aSlaveHandlers.empty() )
- {
- ComposedPropertyUIUpdate aComposedUpdate( _pUpdater );
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
- for ( HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
- loop != m_aSlaveHandlers.end();
- ++loop
+ MethodGuard aGuard( *this );
+
+ impl_ensureUIRequestComposer( _rxInspectorUI );
+ ComposedUIAutoFireGuard aAutoFireGuard( *m_pUIRequestComposer );
+
+ // ask all handlers which expressed interest in this particular property, and "compose" their
+ // commands for the UIUpdater
+ for ( HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ // TODO: make this cheaper (cache it?)
+ const StlSyntaxSequence< ::rtl::OUString > aThisHandlersActuatingProps = (*loop)->getActuatingProperties();
+ for ( StlSyntaxSequence< ::rtl::OUString >::const_iterator loopProps = aThisHandlersActuatingProps.begin();
+ loopProps != aThisHandlersActuatingProps.end();
+ ++loopProps
)
- (*loop)->executeButtonClick( _nPropId, _bPrimary, _rData, &aComposedUpdate );
+ {
+ if ( *loopProps == _rActuatingPropertyName )
+ {
+ (*loop)->actuatingPropertyChanged( _rActuatingPropertyName, _rNewValue, _rOldValue,
+ m_pUIRequestComposer->getUIForPropertyHandler( *loop ),
+ _bFirstTimeInit );
+ break;
+ }
+ }
}
}
//--------------------------------------------------------------------
- void SAL_CALL PropertyComposer::actuatingPropertyChanged( PropertyId _nActuatingPropId, const Any& _rNewValue, const Any& _rOldValue, IPropertyBrowserUI* _pUpdater, bool _bFirstTimeInit )
+ IMPLEMENT_FORWARD_XCOMPONENT( PropertyComposer, PropertyComposer_Base )
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::disposing()
{
- // ask all handlers which expressed interest in this particular property, and "compose" their
- // commands for the UIUpdater
- ComposedPropertyUIUpdate aComposedUpdate( _pUpdater );
+ MethodGuard aGuard( *this );
- for ( HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
+ // dispose our slave handlers
+ for ( PropertyComposer::HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
loop != m_aSlaveHandlers.end();
++loop
)
{
- // TODO: make this cheaper (cache it?)
- const ::std::vector< ::rtl::OUString > aThisHandlersActuatingProps = (*loop)->getActuatingProperties();
- for ( ::std::vector< ::rtl::OUString >::const_iterator loopProps = aThisHandlersActuatingProps.begin();
- loopProps != aThisHandlersActuatingProps.end();
- ++loopProps
- )
+ (*loop)->removePropertyChangeListener( this );
+ (*loop)->dispose();
+ }
+
+ clearContainer( m_aSlaveHandlers );
+
+ if ( m_pUIRequestComposer.get() )
+ m_pUIRequestComposer->dispose();
+ m_pUIRequestComposer.reset( NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
+ {
+ PropertyChangeEvent aTranslatedEvent( evt );
+ aTranslatedEvent.NewValue = getPropertyValue( evt.PropertyName );
+ m_aPropertyListeners.notify( aTranslatedEvent, &XPropertyChangeListener::propertyChange );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::disposing( const EventObject& Source ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ m_aPropertyListeners.disposing( Source );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL PropertyComposer::suspend( sal_Bool _bSuspend ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ for ( PropertyComposer::HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ if ( !(*loop)->suspend( _bSuspend ) )
{
- if ( m_pInfoService->getPropertyId( *loopProps ) == _nActuatingPropId )
+ if ( _bSuspend && ( loop != m_aSlaveHandlers.begin() ) )
{
- (*loop)->actuatingPropertyChanged( _nActuatingPropId, _rNewValue, _rOldValue, &aComposedUpdate, _bFirstTimeInit );
- break;
+ // if we tried to suspend, but one of the slave handlers vetoed,
+ // re-activate the handlers which actually did *not* veto
+ // the suspension
+ do
+ {
+ --loop;
+ (*loop)->suspend( sal_False );
+ }
+ while ( loop != m_aSlaveHandlers.begin() );
}
+ return false;
}
}
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL PropertyComposer::hasPropertyByName( const ::rtl::OUString& _rName ) throw (RuntimeException)
+ {
+ return impl_isSupportedProperty_nothrow( _rName );
}
//........................................................................