masterfix DEV300: #i10000# build fix
[LibreOffice.git] / extensions / source / propctrlr / eformspropertyhandler.cxx
blobe2d57aaee57e63cb83ff8bcff8163a41ab1cf869
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include "eformspropertyhandler.hxx"
31 #include "formstrings.hxx"
32 #include "formmetadata.hxx"
33 #include "propctrlr.hrc"
34 #include "formbrowsertools.hxx"
35 #include "eformshelper.hxx"
36 #include "handlerhelper.hxx"
38 /** === begin UNO includes === **/
39 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
40 #include <com/sun/star/inspection/PropertyControlType.hpp>
41 #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
42 /** === end UNO includes === **/
43 #include <tools/debug.hxx>
45 #include <functional>
47 //------------------------------------------------------------------------
48 extern "C" void SAL_CALL createRegistryInfo_EFormsPropertyHandler()
50 ::pcr::EFormsPropertyHandler::registerImplementation();
53 //........................................................................
54 namespace pcr
56 //........................................................................
58 using namespace ::com::sun::star;
59 using namespace ::com::sun::star::uno;
60 using namespace ::com::sun::star::lang;
61 using namespace ::com::sun::star::beans;
62 using namespace ::com::sun::star::xforms;
63 using namespace ::com::sun::star::script;
64 using namespace ::com::sun::star::ui::dialogs;
65 using namespace ::com::sun::star::form::binding;
66 using namespace ::com::sun::star::inspection;
68 //====================================================================
69 //= EFormsPropertyHandler
70 //====================================================================
71 DBG_NAME( EFormsPropertyHandler )
72 //--------------------------------------------------------------------
73 EFormsPropertyHandler::EFormsPropertyHandler( const Reference< XComponentContext >& _rxContext )
74 :EFormsPropertyHandler_Base( _rxContext )
75 ,m_bSimulatingModelChange( false )
77 DBG_CTOR( EFormsPropertyHandler, NULL );
80 //--------------------------------------------------------------------
81 EFormsPropertyHandler::~EFormsPropertyHandler( )
83 DBG_DTOR( EFormsPropertyHandler, NULL );
86 //--------------------------------------------------------------------
87 ::rtl::OUString SAL_CALL EFormsPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
89 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.EFormsPropertyHandler" ) );
92 //--------------------------------------------------------------------
93 Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
95 Sequence< ::rtl::OUString > aSupported( 1 );
96 aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.XMLFormsPropertyHandler" ) );
97 return aSupported;
100 //--------------------------------------------------------------------
101 ::rtl::OUString EFormsPropertyHandler::getModelNamePropertyValue() const
103 ::rtl::OUString sModelName = m_pHelper->getCurrentFormModelName();
104 if ( !sModelName.getLength() )
105 sModelName = m_sBindingLessModelName;
106 return sModelName;
109 //--------------------------------------------------------------------
110 Any SAL_CALL EFormsPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
112 ::osl::MutexGuard aGuard( m_aMutex );
113 PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
115 OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::getPropertyValue: we don't have any SupportedProperties!" );
116 // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
118 Any aReturn;
121 switch ( nPropId )
123 case PROPERTY_ID_LIST_BINDING:
124 aReturn <<= m_pHelper->getCurrentListSourceBinding();
125 break;
127 case PROPERTY_ID_XML_DATA_MODEL:
128 aReturn <<= getModelNamePropertyValue();
129 break;
131 case PROPERTY_ID_BINDING_NAME:
132 aReturn <<= m_pHelper->getCurrentBindingName();
133 break;
135 case PROPERTY_ID_BIND_EXPRESSION:
136 case PROPERTY_ID_XSD_CONSTRAINT:
137 case PROPERTY_ID_XSD_CALCULATION:
138 case PROPERTY_ID_XSD_REQUIRED:
139 case PROPERTY_ID_XSD_RELEVANT:
140 case PROPERTY_ID_XSD_READONLY:
142 Reference< XPropertySet > xBindingProps( m_pHelper->getCurrentBinding() );
143 if ( xBindingProps.is() )
145 aReturn = xBindingProps->getPropertyValue( _rPropertyName );
146 DBG_ASSERT( aReturn.getValueType().equals( ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ) ),
147 "EFormsPropertyHandler::getPropertyValue: invalid BindingExpression value type!" );
149 else
150 aReturn <<= ::rtl::OUString();
152 break;
154 default:
155 DBG_ERROR( "EFormsPropertyHandler::getPropertyValue: cannot handle this property!" );
156 break;
159 catch( const Exception& )
161 #if OSL_DEBUG_LEVEL > 0
162 ::rtl::OString sMessage( "EFormsPropertyHandler::getPropertyValue: caught an exception!" );
163 sMessage += "\n(have been asked for the \"";
164 sMessage += ::rtl::OString( _rPropertyName.getStr(), _rPropertyName.getLength(), RTL_TEXTENCODING_ASCII_US );
165 sMessage += "\" property.)";
166 OSL_ENSURE( sal_False, sMessage.getStr() );
167 #endif
169 return aReturn;
172 //--------------------------------------------------------------------
173 void SAL_CALL EFormsPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
175 ::osl::MutexGuard aGuard( m_aMutex );
176 PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
178 OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::setPropertyValue: we don't have any SupportedProperties!" );
179 // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
183 Any aOldValue = getPropertyValue( _rPropertyName );
185 switch ( nPropId )
187 case PROPERTY_ID_LIST_BINDING:
189 Reference< XListEntrySource > xSource;
190 OSL_VERIFY( _rValue >>= xSource );
191 m_pHelper->setListSourceBinding( xSource );
193 break;
195 case PROPERTY_ID_XML_DATA_MODEL:
197 OSL_VERIFY( _rValue >>= m_sBindingLessModelName );
199 // if the model changed, reset the binding to NULL
200 if ( m_pHelper->getCurrentFormModelName() != m_sBindingLessModelName )
202 ::rtl::OUString sOldBindingName = m_pHelper->getCurrentBindingName();
203 m_pHelper->setBinding( NULL );
204 firePropertyChange( PROPERTY_BINDING_NAME, PROPERTY_ID_BINDING_NAME,
205 makeAny( sOldBindingName ), makeAny( ::rtl::OUString() ) );
208 break;
210 case PROPERTY_ID_BINDING_NAME:
212 ::rtl::OUString sNewBindingName;
213 OSL_VERIFY( _rValue >>= sNewBindingName );
215 bool bPreviouslyEmptyModel = !m_pHelper->getCurrentFormModel().is();
217 Reference< XPropertySet > xNewBinding;
218 if ( sNewBindingName.getLength() )
219 // obtain the binding with this name, for the current model
220 xNewBinding = m_pHelper->getOrCreateBindingForModel( getModelNamePropertyValue(), sNewBindingName );
222 m_pHelper->setBinding( xNewBinding );
224 if ( bPreviouslyEmptyModel )
225 { // simulate a property change for the model property
226 // This is because we "simulate" the Model property by remembering the
227 // value ourself. Other instances might, however, not know this value,
228 // but prefer to retrieve it somewhere else - e.g. from the EFormsHelper
230 // The really correct solution would be if *all* property handlers
231 // obtain a "current property value" for *all* properties from a central
232 // instance. Then, handler A could ask it for the value of property
233 // X, and this request would be re-routed to handler B, which ultimately
234 // knows the current value.
235 // However, there's no such mechanism in place currently.
236 m_bSimulatingModelChange = true;
237 firePropertyChange( PROPERTY_XML_DATA_MODEL, PROPERTY_ID_XML_DATA_MODEL,
238 makeAny( ::rtl::OUString() ), makeAny( getModelNamePropertyValue() ) );
239 m_bSimulatingModelChange = false;
242 break;
244 case PROPERTY_ID_BIND_EXPRESSION:
246 Reference< XPropertySet > xBinding( m_pHelper->getCurrentBinding() );
247 OSL_ENSURE( xBinding.is(), "You should not reach this without an active binding!" );
248 if ( xBinding.is() )
249 xBinding->setPropertyValue( PROPERTY_BIND_EXPRESSION, _rValue );
251 break;
253 case PROPERTY_ID_XSD_REQUIRED:
254 case PROPERTY_ID_XSD_RELEVANT:
255 case PROPERTY_ID_XSD_READONLY:
256 case PROPERTY_ID_XSD_CONSTRAINT:
257 case PROPERTY_ID_XSD_CALCULATION:
259 Reference< XPropertySet > xBindingProps( m_pHelper->getCurrentBinding() );
260 DBG_ASSERT( xBindingProps.is(), "EFormsPropertyHandler::setPropertyValue: how can I set a property if there's no binding?" );
261 if ( xBindingProps.is() )
263 DBG_ASSERT( _rValue.getValueType().equals( ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ) ),
264 "EFormsPropertyHandler::setPropertyValue: invalid value type!" );
265 xBindingProps->setPropertyValue( _rPropertyName, _rValue );
268 break;
270 default:
271 DBG_ERROR( "EFormsPropertyHandler::setPropertyValue: cannot handle this property!" );
272 break;
275 impl_setContextDocumentModified_nothrow();
277 Any aNewValue( getPropertyValue( _rPropertyName ) );
278 firePropertyChange( _rPropertyName, nPropId, aOldValue, aNewValue );
280 catch( const Exception& )
282 OSL_ENSURE( sal_False, "EFormsPropertyHandler::setPropertyValue: caught an exception!" );
286 //--------------------------------------------------------------------
287 void EFormsPropertyHandler::onNewComponent()
289 EFormsPropertyHandler_Base::onNewComponent();
291 Reference< frame::XModel > xDocument( impl_getContextDocument_nothrow() );
292 DBG_ASSERT( xDocument.is(), "EFormsPropertyHandler::onNewComponent: no document!" );
293 if ( EFormsHelper::isEForm( xDocument ) )
294 m_pHelper.reset( new EFormsHelper( m_aMutex, m_xComponent, xDocument ) );
295 else
296 m_pHelper.reset( NULL );
299 //--------------------------------------------------------------------
300 Sequence< Property > SAL_CALL EFormsPropertyHandler::doDescribeSupportedProperties() const
302 ::std::vector< Property > aProperties;
304 if ( m_pHelper.get() )
306 if ( m_pHelper->canBindToAnyDataType() )
308 aProperties.reserve( 7 );
309 addStringPropertyDescription( aProperties, PROPERTY_XML_DATA_MODEL );
310 addStringPropertyDescription( aProperties, PROPERTY_BINDING_NAME );
311 addStringPropertyDescription( aProperties, PROPERTY_BIND_EXPRESSION );
312 addStringPropertyDescription( aProperties, PROPERTY_XSD_REQUIRED );
313 addStringPropertyDescription( aProperties, PROPERTY_XSD_RELEVANT );
314 addStringPropertyDescription( aProperties, PROPERTY_XSD_READONLY );
315 addStringPropertyDescription( aProperties, PROPERTY_XSD_CONSTRAINT );
316 addStringPropertyDescription( aProperties, PROPERTY_XSD_CALCULATION );
318 if ( m_pHelper->isListEntrySink() )
320 implAddPropertyDescription( aProperties, PROPERTY_LIST_BINDING,
321 ::getCppuType( static_cast< Reference< XListEntrySource > * >( NULL ) ) );
325 if ( aProperties.empty() )
326 return Sequence< Property >();
327 return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
330 //--------------------------------------------------------------------
331 Any SAL_CALL EFormsPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
333 ::osl::MutexGuard aGuard( m_aMutex );
334 Any aReturn;
336 OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::convertToPropertyValue: we have no SupportedProperties!" );
337 if ( !m_pHelper.get() )
338 return aReturn;
340 PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
342 ::rtl::OUString sControlValue;
343 switch ( nPropId )
345 case PROPERTY_ID_LIST_BINDING:
347 OSL_VERIFY( _rControlValue >>= sControlValue );
348 Reference< XListEntrySource > xListSource( m_pHelper->getModelElementFromUIName( EFormsHelper::Binding, sControlValue ), UNO_QUERY );
349 OSL_ENSURE( xListSource.is() || !m_pHelper->getModelElementFromUIName( EFormsHelper::Binding, sControlValue ).is(),
350 "EFormsPropertyHandler::convertToPropertyValue: there's a binding which is no ListEntrySource!" );
351 aReturn <<= xListSource;
353 break;
355 default:
356 aReturn = EFormsPropertyHandler_Base::convertToPropertyValue( _rPropertyName, _rControlValue );
357 break;
360 return aReturn;
363 //--------------------------------------------------------------------
364 Any SAL_CALL EFormsPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
366 ::osl::MutexGuard aGuard( m_aMutex );
367 Any aReturn;
369 OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::convertToControlValue: we have no SupportedProperties!" );
370 if ( !m_pHelper.get() )
371 return aReturn;
373 PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
375 OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING,
376 "EFormsPropertyHandler::convertToControlValue: all our controls should use strings for value exchange!" );
378 switch ( nPropId )
380 case PROPERTY_ID_LIST_BINDING:
382 Reference< XPropertySet > xListSourceBinding( _rPropertyValue, UNO_QUERY );
383 if ( xListSourceBinding.is() )
384 aReturn <<= m_pHelper->getModelElementUIName( EFormsHelper::Binding, xListSourceBinding );
386 break;
388 default:
389 aReturn = EFormsPropertyHandler_Base::convertToControlValue( _rPropertyName, _rPropertyValue, _rControlValueType );
390 break;
393 return aReturn;
396 //--------------------------------------------------------------------
397 Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
399 ::osl::MutexGuard aGuard( m_aMutex );
400 if ( !m_pHelper.get() )
401 return Sequence< ::rtl::OUString >();
403 ::std::vector< ::rtl::OUString > aInterestedInActuations( 2 );
404 aInterestedInActuations[ 0 ] = PROPERTY_XML_DATA_MODEL;
405 aInterestedInActuations[ 1 ] = PROPERTY_BINDING_NAME;
406 return Sequence< ::rtl::OUString >( &(*aInterestedInActuations.begin()), aInterestedInActuations.size() );
409 //--------------------------------------------------------------------
410 Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
412 ::osl::MutexGuard aGuard( m_aMutex );
413 if ( !m_pHelper.get() )
414 return Sequence< ::rtl::OUString >();
416 Sequence< ::rtl::OUString > aReturn( 1 );
417 aReturn[ 0 ] = PROPERTY_INPUT_REQUIRED;
418 return aReturn;
421 //--------------------------------------------------------------------
422 LineDescriptor SAL_CALL EFormsPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
423 const Reference< XPropertyControlFactory >& _rxControlFactory )
424 throw (UnknownPropertyException, NullPointerException, RuntimeException)
426 ::osl::MutexGuard aGuard( m_aMutex );
427 if ( !_rxControlFactory.is() )
428 throw NullPointerException();
429 if ( !m_pHelper.get() )
430 throw RuntimeException();
432 LineDescriptor aDescriptor;
433 sal_Int16 nControlType = PropertyControlType::TextField;
434 ::std::vector< ::rtl::OUString > aListEntries;
435 PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
436 switch ( nPropId )
438 case PROPERTY_ID_LIST_BINDING:
439 nControlType = PropertyControlType::ListBox;
440 const_cast< EFormsHelper* >( m_pHelper.get() )->getAllElementUINames( EFormsHelper::Binding, aListEntries, true );
441 break;
443 case PROPERTY_ID_XML_DATA_MODEL:
444 nControlType = PropertyControlType::ListBox;
445 m_pHelper->getFormModelNames( aListEntries );
446 break;
448 case PROPERTY_ID_BINDING_NAME:
450 nControlType = PropertyControlType::ComboBox;
451 ::rtl::OUString sCurrentModel( getModelNamePropertyValue() );
452 if ( sCurrentModel.getLength() )
453 m_pHelper->getBindingNames( sCurrentModel, aListEntries );
455 break;
457 case PROPERTY_ID_BIND_EXPRESSION: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_BIND_EXPRESSION); break;
458 case PROPERTY_ID_XSD_REQUIRED: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_REQUIRED); break;
459 case PROPERTY_ID_XSD_RELEVANT: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_RELEVANT); break;
460 case PROPERTY_ID_XSD_READONLY: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_READONLY); break;
461 case PROPERTY_ID_XSD_CONSTRAINT: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_CONSTRAINT); break;
462 case PROPERTY_ID_XSD_CALCULATION: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_CALCULATION); break;
464 default:
465 DBG_ERROR( "EFormsPropertyHandler::describePropertyLine: cannot handle this property!" );
466 break;
469 switch ( nControlType )
471 case PropertyControlType::ListBox:
472 aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_True );
473 break;
474 case PropertyControlType::ComboBox:
475 aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl( _rxControlFactory, aListEntries, sal_False, sal_True );
476 break;
477 default:
478 aDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, sal_False );
479 break;
482 aDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId );
483 aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) );
484 aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
485 return aDescriptor;
488 //--------------------------------------------------------------------
489 InteractiveSelectionResult SAL_CALL EFormsPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool /*_bPrimary*/, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
491 if ( !_rxInspectorUI.is() )
492 throw NullPointerException();
494 ::osl::MutexGuard aGuard( m_aMutex );
495 OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::onInteractivePropertySelection: we do not have any SupportedProperties!" );
496 if ( !m_pHelper.get() )
497 return InteractiveSelectionResult_Cancelled;
499 PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
500 (void)nPropId;
501 OSL_ENSURE( ( PROPERTY_ID_BINDING_NAME == nPropId )
502 || ( PROPERTY_ID_BIND_EXPRESSION == nPropId )
503 || ( PROPERTY_ID_XSD_REQUIRED == nPropId )
504 || ( PROPERTY_ID_XSD_RELEVANT == nPropId )
505 || ( PROPERTY_ID_XSD_READONLY == nPropId )
506 || ( PROPERTY_ID_XSD_CONSTRAINT == nPropId )
507 || ( PROPERTY_ID_XSD_CALCULATION == nPropId ), "EFormsPropertyHandler::onInteractivePropertySelection: unexpected!" );
511 Reference< XExecutableDialog > xDialog;
512 m_aContext.createComponent( "com.sun.star.xforms.ui.dialogs.AddCondition", xDialog );
513 Reference< XPropertySet > xDialogProps( xDialog, UNO_QUERY_THROW );
515 // the model for the dialog to work with
516 Reference< xforms::XModel > xModel( m_pHelper->getCurrentFormModel() );
517 // the binding for the dialog to work with
518 Reference< XPropertySet > xBinding( m_pHelper->getCurrentBinding() );
519 // the aspect of the binding which the dialog should modify
520 ::rtl::OUString sFacetName( _rPropertyName );
522 OSL_ENSURE( xModel.is() && xBinding.is() && sFacetName.getLength(),
523 "EFormsPropertyHandler::onInteractivePropertySelection: something is missing for the dialog initialization!" );
524 if ( !( xModel.is() && xBinding.is() && sFacetName.getLength() ) )
525 return InteractiveSelectionResult_Cancelled;
527 xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormModel" ) ), makeAny( xModel ) );
528 xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Binding" ) ), makeAny( xBinding ) );
529 xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FacetName" ) ), makeAny( sFacetName ) );
531 if ( !xDialog->execute() )
532 // cancelled
533 return InteractiveSelectionResult_Cancelled;
535 _rData = xDialogProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConditionValue" ) ) );
536 return InteractiveSelectionResult_ObtainedValue;
538 catch( const Exception& )
540 OSL_ENSURE( sal_False, "EFormsPropertyHandler::onInteractivePropertySelection: caught an exception!" );
543 // something went wrong here ...(but has been asserted already)
544 return InteractiveSelectionResult_Cancelled;
547 //--------------------------------------------------------------------
548 void SAL_CALL EFormsPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
550 ::osl::MutexGuard aGuard( m_aMutex );
551 EFormsPropertyHandler_Base::addPropertyChangeListener( _rxListener );
552 if ( m_pHelper.get() )
553 m_pHelper->registerBindingListener( _rxListener );
556 //--------------------------------------------------------------------
557 void SAL_CALL EFormsPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
559 ::osl::MutexGuard aGuard( m_aMutex );
560 if ( m_pHelper.get() )
561 m_pHelper->revokeBindingListener( _rxListener );
562 EFormsPropertyHandler_Base::removePropertyChangeListener( _rxListener );
565 //--------------------------------------------------------------------
566 void SAL_CALL EFormsPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (NullPointerException, RuntimeException)
568 if ( !_rxInspectorUI.is() )
569 throw NullPointerException();
571 ::osl::MutexGuard aGuard( m_aMutex );
572 PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
573 OSL_PRECOND( m_pHelper.get(), "EFormsPropertyHandler::actuatingPropertyChanged: inconsistentcy!" );
574 // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
576 DBG_ASSERT( _rxInspectorUI.is(), "EFormsPropertyHandler::actuatingPropertyChanged: invalid callback!" );
577 if ( !_rxInspectorUI.is() )
578 return;
580 switch ( nActuatingPropId )
582 case PROPERTY_ID_XML_DATA_MODEL:
584 if ( m_bSimulatingModelChange )
585 break;
586 ::rtl::OUString sDataModelName;
587 OSL_VERIFY( _rNewValue >>= sDataModelName );
588 sal_Bool bBoundToSomeModel = 0 != sDataModelName.getLength();
589 _rxInspectorUI->rebuildPropertyUI( PROPERTY_BINDING_NAME );
590 _rxInspectorUI->enablePropertyUI( PROPERTY_BINDING_NAME, bBoundToSomeModel );
592 // NO break
594 case PROPERTY_ID_BINDING_NAME:
596 sal_Bool bHaveABinding = ( m_pHelper->getCurrentBindingName().getLength() > 0 );
597 _rxInspectorUI->enablePropertyUI( PROPERTY_BIND_EXPRESSION, bHaveABinding );
598 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_REQUIRED, bHaveABinding );
599 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_RELEVANT, bHaveABinding );
600 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_READONLY, bHaveABinding );
601 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_CONSTRAINT, bHaveABinding );
602 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_CALCULATION, bHaveABinding );
603 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_DATA_TYPE, bHaveABinding );
605 break;
607 default:
608 DBG_ERROR( "EFormsPropertyHandler::actuatingPropertyChanged: cannot handle this property!" );
609 break;
613 //........................................................................
614 } // namespace pcr
615 //........................................................................