From f82487c95052f810d3b2fb325fe7d7ba28d3b241 Mon Sep 17 00:00:00 2001 From: Vladimir Glazounov Date: Tue, 14 Mar 2006 10:33:39 +0000 Subject: INTEGRATION: CWS pbrwuno (1.3.88); FILE MERGED 2006/03/10 11:32:29 fs 1.3.88.19: help ids 2006/03/10 09:43:46 fs 1.3.88.18: proper enum types 2006/02/15 07:25:55 fs 1.3.88.17: don't access &(*foo.begin()) of empty STL containers 2005/11/02 11:43:47 fs 1.3.88.16: #i10000# exception specifications 2005/10/25 07:13:15 fs 1.3.88.15: #i53095# knitting lose ends (amongst others, make the handlers available as service) 2005/10/19 08:48:43 fs 1.3.88.14: protect agains multiple inspection (more precise: properly deal with it) 2005/10/17 14:09:39 fs 1.3.88.13: #i53095# some cleanup of remaining TODOs 2005/10/17 13:19:03 fs 1.3.88.12: #i53095# proper listener administration: allow multiple listeners per handler 2005/10/17 08:58:20 fs 1.3.88.11: some mutex locking 2005/10/14 12:43:50 fs 1.3.88.10: #i53095# properly care for MAYBEVOID properties and AMBIGUOUS property values 2005/10/13 13:01:11 fs 1.3.88.9: #i53095# introduce an XObjectInspector/Model 2005/10/11 13:29:53 fs 1.3.88.8: #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:12:16 fs 1.3.88.7: RESYNC: (1.3-1.4); FILE MERGED 2005/09/05 07:41:55 fs 1.3.88.6: #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:35 fs 1.3.88.5: #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/16 05:39:07 fs 1.3.88.4: #i53095# completely moved the handling of actuating properties into dedicated handlers 2005/08/12 16:30:16 fs 1.3.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:48 fs 1.3.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:08 fs 1.3.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 --- extensions/source/propctrlr/submissionhandler.cxx | 266 ++++++++++++++-------- 1 file changed, 165 insertions(+), 101 deletions(-) (limited to 'extensions/source/propctrlr/submissionhandler.cxx') diff --git a/extensions/source/propctrlr/submissionhandler.cxx b/extensions/source/propctrlr/submissionhandler.cxx index 6162552f5..251bf5c7c 100644 --- a/extensions/source/propctrlr/submissionhandler.cxx +++ b/extensions/source/propctrlr/submissionhandler.cxx @@ -4,9 +4,9 @@ * * $RCSfile: submissionhandler.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: rt $ $Date: 2005-09-08 20:30:01 $ + * last change: $Author: vg $ $Date: 2006-03-14 11:33:39 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -42,14 +42,8 @@ #ifndef _EXTENSIONS_FORMSCTRLR_FORMSTRINGS_HXX_ #include "formstrings.hxx" #endif -#ifndef _EXTENSIONS_PROPCTRLR_LINEDESCRIPTOR_HXX_ -#include "linedescriptor.hxx" -#endif -#ifndef EXTENSIONS_SOURCE_PROPCTRLR_STRINGREPRESENTATION_HXX -#include "stringrepresentation.hxx" -#endif -#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPBROWSERUI_HXX -#include "propbrowserui.hxx" +#ifndef EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX +#include "handlerhelper.hxx" #endif /** === begin UNO includes === **/ @@ -65,6 +59,9 @@ #ifndef _COM_SUN_STAR_FORM_SUBMISSION_XSUBMISSIONSUPPLIER_HPP_ #include #endif +#ifndef _COM_SUN_STAR_INSPECTION_XOBJECTINSPECTORUI_HPP_ +#include +#endif /** === end UNO includes === **/ #ifndef _TOOLS_DEBUG_HXX @@ -74,6 +71,12 @@ #include #endif +//------------------------------------------------------------------------ +extern "C" void SAL_CALL createRegistryInfo_SubmissionPropertyHandler() +{ + ::pcr::SubmissionPropertyHandler::registerImplementation(); +} + //........................................................................ namespace pcr { @@ -88,16 +91,17 @@ namespace pcr using namespace ::com::sun::star::form; using namespace ::com::sun::star::xforms; using namespace ::com::sun::star::container; + using namespace ::com::sun::star::inspection; //==================================================================== //= SubmissionHelper //==================================================================== //-------------------------------------------------------------------- - SubmissionHelper::SubmissionHelper( const Reference< XPropertySet >& _rxIntrospectee, const Reference< frame::XModel >& _rxContextDocument ) - :EFormsHelper( _rxIntrospectee, _rxContextDocument ) + SubmissionHelper::SubmissionHelper( ::osl::Mutex& _rMutex, const Reference< XPropertySet >& _rxIntrospectee, const Reference< frame::XModel >& _rxContextDocument ) + :EFormsHelper( _rMutex, _rxIntrospectee, _rxContextDocument ) { OSL_ENSURE( canTriggerSubmissions( _rxIntrospectee, _rxContextDocument ), - "SubmissionHelper::SubmissionPropertyHandler: you should not have instantiated me!" ); + "SubmissionHelper::SubmissionHelper: you should not have instantiated me!" ); } //-------------------------------------------------------------------- @@ -123,44 +127,54 @@ namespace pcr //==================================================================== //= SubmissionPropertyHandler //==================================================================== + DBG_NAME( SubmissionPropertyHandler ) //-------------------------------------------------------------------- - SubmissionPropertyHandler::SubmissionPropertyHandler( const Reference< XPropertySet >& _rxIntrospectee, - const Reference< frame::XModel >& _rxContextDocument, const Reference< XTypeConverter >& _rxTypeConverter ) - :PropertyHandler ( _rxIntrospectee, _rxTypeConverter ) - ,OPropertyChangeListener( m_aMutex ) + SubmissionPropertyHandler::SubmissionPropertyHandler( const Reference< XComponentContext >& _rxContext ) + :EditPropertyHandler_Base( _rxContext ) + ,OPropertyChangeListener( m_aMutex ) + ,m_pPropChangeMultiplexer( NULL ) { - if ( SubmissionHelper::canTriggerSubmissions( m_xIntrospectee, _rxContextDocument ) ) - { - m_pHelper.reset( new SubmissionHelper( m_xIntrospectee, _rxContextDocument ) ); - - OPropertyChangeMultiplexer* pMultiplexer = new OPropertyChangeMultiplexer( this, _rxIntrospectee ); - pMultiplexer->addProperty( PROPERTY_BUTTONTYPE ); - // this does not delete the object, since our base class holds it alive - } + DBG_CTOR( SubmissionPropertyHandler, NULL ); } //-------------------------------------------------------------------- SubmissionPropertyHandler::~SubmissionPropertyHandler( ) { disposeAdapter(); + DBG_DTOR( SubmissionPropertyHandler, NULL ); } //-------------------------------------------------------------------- - Any SAL_CALL SubmissionPropertyHandler::getPropertyValue( PropertyId _nPropId, bool _bLazy ) const + ::rtl::OUString SAL_CALL SubmissionPropertyHandler::getImplementationName_static( ) throw (RuntimeException) { - Any aReturn; + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.SubmissionPropertyHandler" ) ); + } - OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::getPropertyValue: we have no SupportedProperties!" ); - if ( !m_pHelper.get() ) - return aReturn; + //-------------------------------------------------------------------- + Sequence< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException) + { + Sequence< ::rtl::OUString > aSupported( 1 ); + aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.SubmissionPropertyHandler" ) ); + return aSupported; + } + //-------------------------------------------------------------------- + Any SAL_CALL SubmissionPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) ); + + OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::getPropertyValue: inconsistency!" ); + // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties + + Any aReturn; try { - switch ( _nPropId ) + switch ( nPropId ) { case PROPERTY_ID_SUBMISSION_ID: { - Reference< submission::XSubmissionSupplier > xSubmissionSupp( m_xIntrospectee, UNO_QUERY ); + Reference< submission::XSubmissionSupplier > xSubmissionSupp( m_xComponent, UNO_QUERY ); OSL_ENSURE( xSubmissionSupp.is(), "SubmissionPropertyHandler::getPropertyValue: this should never happen ..." ); // this handler is not intended for components which are no XSubmissionSupplier Reference< submission::XSubmission > xSubmission; @@ -173,7 +187,7 @@ namespace pcr case PROPERTY_ID_XFORMS_BUTTONTYPE: { FormButtonType eType = FormButtonType_PUSH; - OSL_VERIFY( m_xIntrospectee->getPropertyValue( PROPERTY_BUTTONTYPE ) >>= eType ); + OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_BUTTONTYPE ) >>= eType ); if ( ( eType != FormButtonType_PUSH ) && ( eType != FormButtonType_SUBMIT ) ) eType = FormButtonType_PUSH; aReturn <<= eType; @@ -182,6 +196,7 @@ namespace pcr default: DBG_ERROR( "SubmissionPropertyHandler::getPropertyValue: cannot handle this property!" ); + break; } } catch( const Exception& ) @@ -193,31 +208,36 @@ namespace pcr } //-------------------------------------------------------------------- - void SAL_CALL SubmissionPropertyHandler::setPropertyValue( PropertyId _nPropId, const Any& _rValue ) + void SAL_CALL SubmissionPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException) { - OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::setPropertyValue: we have no SupportedProperties!" ); - if ( !m_pHelper.get() ) - return; + ::osl::MutexGuard aGuard( m_aMutex ); + PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) ); + + OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::setPropertyValue: inconsistency!" ); + // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties try { - switch ( _nPropId ) + switch ( nPropId ) { case PROPERTY_ID_SUBMISSION_ID: { Reference< submission::XSubmission > xSubmission; OSL_VERIFY( _rValue >>= xSubmission ); - Reference< submission::XSubmissionSupplier > xSubmissionSupp( m_xIntrospectee, UNO_QUERY ); + Reference< submission::XSubmissionSupplier > xSubmissionSupp( m_xComponent, UNO_QUERY ); OSL_ENSURE( xSubmissionSupp.is(), "SubmissionPropertyHandler::setPropertyValue: this should never happen ..." ); // this handler is not intended for components which are no XSubmissionSupplier if ( xSubmissionSupp.is() ) + { xSubmissionSupp->setSubmission( xSubmission ); + impl_setContextDocumentModified_nothrow(); + } } break; case PROPERTY_ID_XFORMS_BUTTONTYPE: - m_xIntrospectee->setPropertyValue( PROPERTY_BUTTONTYPE, _rValue ); + m_xComponent->setPropertyValue( PROPERTY_BUTTONTYPE, _rValue ); break; default: @@ -231,23 +251,25 @@ namespace pcr } //-------------------------------------------------------------------- - ::std::vector< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getActuatingProperties( ) const + Sequence< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getActuatingProperties( ) throw (RuntimeException) { + ::osl::MutexGuard aGuard( m_aMutex ); if ( !m_pHelper.get() ) - return ::std::vector< ::rtl::OUString >(); + return Sequence< ::rtl::OUString >(); - ::std::vector< ::rtl::OUString > aReturn( 1 ); + Sequence< ::rtl::OUString > aReturn( 1 ); aReturn[ 0 ] = PROPERTY_XFORMS_BUTTONTYPE; return aReturn; } //-------------------------------------------------------------------- - ::std::vector< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getSupersededProperties( ) const + Sequence< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getSupersededProperties( ) throw (RuntimeException) { + ::osl::MutexGuard aGuard( m_aMutex ); if ( !m_pHelper.get() ) - return ::std::vector< ::rtl::OUString >(); + return Sequence< ::rtl::OUString >(); - ::std::vector< ::rtl::OUString > aReturn( 3 ); + Sequence< ::rtl::OUString > aReturn( 3 ); aReturn[ 0 ] = PROPERTY_TARGET_URL; aReturn[ 1 ] = PROPERTY_TARGET_FRAME; aReturn[ 2 ] = PROPERTY_BUTTONTYPE; @@ -255,68 +277,103 @@ namespace pcr } //-------------------------------------------------------------------- - ::std::vector< Property > SAL_CALL SubmissionPropertyHandler::implDescribeSupportedProperties() const + void SubmissionPropertyHandler::onNewComponent() { - ::std::vector< Property > aProperties; - if ( m_pHelper.get() ) + if ( m_pPropChangeMultiplexer ) { - implAddPropertyDescription( aProperties, PROPERTY_SUBMISSION_ID, ::getCppuType( static_cast< Reference< submission::XSubmission > * >( NULL ) ) ); - implAddPropertyDescription( aProperties, PROPERTY_XFORMS_BUTTONTYPE, ::getCppuType( static_cast< FormButtonType* >( NULL ) ) ); + m_pPropChangeMultiplexer->dispose(); + m_pPropChangeMultiplexer->release(); + m_pPropChangeMultiplexer = NULL; + } + + EditPropertyHandler_Base::onNewComponent(); + + Reference< frame::XModel > xDocument( impl_getContextDocument_nothrow() ); + DBG_ASSERT( xDocument.is(), "SubmissionPropertyHandler::onNewComponent: no document!" ); + + m_pHelper.reset( NULL ); + + if ( SubmissionHelper::canTriggerSubmissions( m_xComponent, xDocument ) ) + { + m_pHelper.reset( new SubmissionHelper( m_aMutex, m_xComponent, xDocument ) ); + + m_pPropChangeMultiplexer = new OPropertyChangeMultiplexer( this, m_xComponent ); + m_pPropChangeMultiplexer->acquire(); + m_pPropChangeMultiplexer->addProperty( PROPERTY_BUTTONTYPE ); } - return aProperties; } //-------------------------------------------------------------------- - bool SAL_CALL SubmissionPropertyHandler::supportsUIDescriptor( PropertyId _nPropId ) const + Sequence< Property > SAL_CALL SubmissionPropertyHandler::doDescribeSupportedProperties() const { - return true; + ::std::vector< Property > aProperties; + if ( m_pHelper.get() ) + { + implAddPropertyDescription( aProperties, PROPERTY_SUBMISSION_ID, ::getCppuType( static_cast< Reference< submission::XSubmission > * >( NULL ) ) ); + implAddPropertyDescription( aProperties, PROPERTY_XFORMS_BUTTONTYPE, ::getCppuType( static_cast< FormButtonType* >( NULL ) ) ); + } + if ( aProperties.empty() ) + return Sequence< Property >(); + return Sequence< Property >( &(*aProperties.begin()), aProperties.size() ); } //-------------------------------------------------------------------- - void SAL_CALL SubmissionPropertyHandler::describePropertyUI( PropertyId _nPropId, PropertyUIDescriptor& /* [out] */ _rDescriptor ) const + void SAL_CALL SubmissionPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName, + LineDescriptor& /* [out] */ _rDescriptor, const Reference< XPropertyControlFactory >& _rxControlFactory ) + throw (UnknownPropertyException, NullPointerException, RuntimeException) { - OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::describePropertyUI: we have no SupportedProperties!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !_rxControlFactory.is() ) + throw NullPointerException(); if ( !m_pHelper.get() ) - return; + RuntimeException(); - switch ( _nPropId ) + ::std::vector< ::rtl::OUString > aListEntries; + PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) ); + switch ( nPropId ) { case PROPERTY_ID_SUBMISSION_ID: - _rDescriptor.eControlType = BCT_LISTBOX; - const_cast< SubmissionHelper* >( m_pHelper.get() )->getAllElementUINames( EFormsHelper::Submission, _rDescriptor.aListValues, false ); + const_cast< SubmissionHelper* >( m_pHelper.get() )->getAllElementUINames( EFormsHelper::Submission, aListEntries, false ); break; case PROPERTY_ID_XFORMS_BUTTONTYPE: { - _rDescriptor.eControlType = BCT_LISTBOX; // available options are nearly the same as for the "normal" button type, but only the // first two options - ::std::vector< String > aAllValues( m_pInfoService->getPropertyEnumRepresentations( PROPERTY_ID_BUTTONTYPE ) ); - _rDescriptor.aListValues.resize( 2 ); - _rDescriptor.aListValues[ 0 ] = aAllValues[ 0 ]; - _rDescriptor.aListValues[ 1 ] = aAllValues[ 1 ]; + aListEntries = m_pInfoService->getPropertyEnumRepresentations( PROPERTY_ID_BUTTONTYPE ); + aListEntries.resize( 2 ); } break; default: - OSL_ENSURE( sal_False, "SubmissionPropertyHandler::describePropertyUI: cannot handle this id!" ); + OSL_ENSURE( sal_False, "SubmissionPropertyHandler::describePropertyLine: cannot handle this id!" ); + return; } + + _rDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False ); + _rDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId ); + _rDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "General" ) ); + _rDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) ); } //-------------------------------------------------------------------- - void SAL_CALL SubmissionPropertyHandler::actuatingPropertyChanged( PropertyId _nActuatingPropId, const Any& _rNewValue, const Any& _rOldValue, IPropertyBrowserUI* _pUpdater, bool ) + void SAL_CALL SubmissionPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& _rOldValue, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (NullPointerException, RuntimeException) { - OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::actuatingPropertyChanged: we have no ActuatingProperties!" ); - if ( !m_pHelper.get() ) - return; + if ( !_rxInspectorUI.is() ) + throw NullPointerException(); - switch ( _nActuatingPropId ) + ::osl::MutexGuard aGuard( m_aMutex ); + PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) ); + OSL_PRECOND( m_pHelper.get(), "SubmissionPropertyHandler::actuatingPropertyChanged: inconsistentcy!" ); + // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties + + switch ( nActuatingPropId ) { case PROPERTY_ID_XFORMS_BUTTONTYPE: { FormButtonType eType = FormButtonType_PUSH; OSL_VERIFY( _rNewValue >>= eType ); - _pUpdater->enablePropertyUI( PROPERTY_SUBMISSION_ID, eType == FormButtonType_SUBMIT ); + _rxInspectorUI->enablePropertyUI( PROPERTY_SUBMISSION_ID, eType == FormButtonType_SUBMIT ); } break; @@ -326,75 +383,82 @@ namespace pcr } //-------------------------------------------------------------------- - void SAL_CALL SubmissionPropertyHandler::initializePropertyUI( PropertyId _nPropId, IPropertyBrowserUI* _pUpdater ) + Any SAL_CALL SubmissionPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException) { - OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::initializePropertyUI: we have no SupportedProperties!" ); - // nothing to do - } + ::osl::MutexGuard aGuard( m_aMutex ); + Any aPropertyValue; - //-------------------------------------------------------------------- - Any SAL_CALL SubmissionPropertyHandler::getPropertyValueFromStringRep( PropertyId _nPropId, const ::rtl::OUString& _rStringRep ) const - { - Any aReturn; - - OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::getPropertyValueFromStringRep: we have no SupportedProperties!" ); + OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::convertToPropertyValue: we have no SupportedProperties!" ); if ( !m_pHelper.get() ) - return aReturn; + return aPropertyValue; - switch ( _nPropId ) + ::rtl::OUString sControlValue; + OSL_VERIFY( _rControlValue >>= sControlValue ); + + PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) ); + switch ( nPropId ) { case PROPERTY_ID_SUBMISSION_ID: { - Reference< XSubmission > xSubmission( m_pHelper->getModelElementFromUIName( EFormsHelper::Submission, _rStringRep ), UNO_QUERY ); - aReturn <<= xSubmission; + Reference< XSubmission > xSubmission( m_pHelper->getModelElementFromUIName( EFormsHelper::Submission, sControlValue ), UNO_QUERY ); + aPropertyValue <<= xSubmission; } break; case PROPERTY_ID_XFORMS_BUTTONTYPE: { - StringRepresentation aConversionHelper( m_xTypeConverter ); - aReturn = aConversionHelper.getPropertyValueFromStringRep( _rStringRep, ::getCppuType( static_cast< FormButtonType* >( NULL ) ), PROPERTY_ID_BUTTONTYPE, m_pInfoService.get() ); + ::rtl::Reference< IPropertyEnumRepresentation > aEnumConversion( + new DefaultEnumRepresentation( *m_pInfoService, ::getCppuType( static_cast< FormButtonType* >( NULL ) ), PROPERTY_ID_BUTTONTYPE ) ); + // TODO/UNOize: make aEnumConversion a member? + aEnumConversion->getValueFromDescription( sControlValue, aPropertyValue ); } break; default: - OSL_ENSURE( sal_False, "SubmissionPropertyHandler::getPropertyValueFromStringRep: cannot handle this id!" ); + OSL_ENSURE( sal_False, "SubmissionPropertyHandler::convertToPropertyValue: cannot handle this id!" ); } - return aReturn; + return aPropertyValue; } //-------------------------------------------------------------------- - ::rtl::OUString SAL_CALL SubmissionPropertyHandler::getStringRepFromPropertyValue( PropertyId _nPropId, const Any& _rValue ) const + Any SAL_CALL SubmissionPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException) { - ::rtl::OUString sReturn; + ::osl::MutexGuard aGuard( m_aMutex ); + Any aControlValue; - OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::getStringRepFromPropertyValue: we have no SupportedProperties!" ); + OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::convertToControlValue: we have no SupportedProperties!" ); if ( !m_pHelper.get() ) - return sReturn; + return aControlValue; + + OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING, + "SubmissionPropertyHandler::convertToControlValue: all our controls should use strings for value exchange!" ); - switch ( _nPropId ) + PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) ); + switch ( nPropId ) { case PROPERTY_ID_SUBMISSION_ID: { - Reference< XPropertySet > xSubmission( _rValue, UNO_QUERY ); + Reference< XPropertySet > xSubmission( _rPropertyValue, UNO_QUERY ); if ( xSubmission.is() ) - sReturn = m_pHelper->getModelElementUIName( EFormsHelper::Submission, xSubmission ); + aControlValue <<= m_pHelper->getModelElementUIName( EFormsHelper::Submission, xSubmission ); } break; case PROPERTY_ID_XFORMS_BUTTONTYPE: { - StringRepresentation aConversionHelper( m_xTypeConverter ); - sReturn = aConversionHelper.getStringRepFromPropertyValue( _rValue, PROPERTY_ID_BUTTONTYPE, m_pInfoService.get() ); + ::rtl::Reference< IPropertyEnumRepresentation > aEnumConversion( + new DefaultEnumRepresentation( *m_pInfoService, _rPropertyValue.getValueType(), PROPERTY_ID_BUTTONTYPE ) ); + // TODO/UNOize: make aEnumConversion a member? + aControlValue <<= aEnumConversion->getDescriptionForValue( _rPropertyValue ); } break; default: - OSL_ENSURE( sal_False, "SubmissionPropertyHandler::getStringRepFromPropertyValue: cannot handle this id!" ); + OSL_ENSURE( sal_False, "SubmissionPropertyHandler::convertToControlValue: cannot handle this id!" ); } - return sReturn; + return aControlValue; } //-------------------------------------------------------------------- -- cgit v1.2.3