xref: /AOO41X/main/extensions/source/propctrlr/eformspropertyhandler.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
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"
37 
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>
44 
45 #include <functional>
46 
47 //------------------------------------------------------------------------
48 extern "C" void SAL_CALL createRegistryInfo_EFormsPropertyHandler()
49 {
50     ::pcr::EFormsPropertyHandler::registerImplementation();
51 }
52 
53 //........................................................................
54 namespace pcr
55 {
56 //........................................................................
57 
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;
67 
68 	//====================================================================
69 	//= EFormsPropertyHandler
70 	//====================================================================
71     DBG_NAME( EFormsPropertyHandler )
72 	//--------------------------------------------------------------------
73     EFormsPropertyHandler::EFormsPropertyHandler( const Reference< XComponentContext >& _rxContext )
74         :EFormsPropertyHandler_Base( _rxContext )
75         ,m_bSimulatingModelChange( false )
76     {
77         DBG_CTOR( EFormsPropertyHandler, NULL );
78     }
79 
80 	//--------------------------------------------------------------------
81     EFormsPropertyHandler::~EFormsPropertyHandler( )
82     {
83         DBG_DTOR( EFormsPropertyHandler, NULL );
84     }
85 
86     //--------------------------------------------------------------------
87     ::rtl::OUString SAL_CALL EFormsPropertyHandler::getImplementationName_static(  ) throw (RuntimeException)
88     {
89         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.EFormsPropertyHandler" ) );
90     }
91 
92     //--------------------------------------------------------------------
93     Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getSupportedServiceNames_static(  ) throw (RuntimeException)
94     {
95         Sequence< ::rtl::OUString > aSupported( 1 );
96         aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.XMLFormsPropertyHandler" ) );
97         return aSupported;
98     }
99 
100     //--------------------------------------------------------------------
101     ::rtl::OUString EFormsPropertyHandler::getModelNamePropertyValue() const
102     {
103         ::rtl::OUString sModelName = m_pHelper->getCurrentFormModelName();
104         if ( !sModelName.getLength() )
105             sModelName = m_sBindingLessModelName;
106         return sModelName;
107     }
108 
109     //--------------------------------------------------------------------
110     Any SAL_CALL EFormsPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
111     {
112         ::osl::MutexGuard aGuard( m_aMutex );
113         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
114 
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
117 
118         Any aReturn;
119         try
120         {
121             switch ( nPropId )
122             {
123             case PROPERTY_ID_LIST_BINDING:
124                 aReturn <<= m_pHelper->getCurrentListSourceBinding();
125                 break;
126 
127             case PROPERTY_ID_XML_DATA_MODEL:
128                 aReturn <<= getModelNamePropertyValue();
129                 break;
130 
131             case PROPERTY_ID_BINDING_NAME:
132                 aReturn <<= m_pHelper->getCurrentBindingName();
133                 break;
134 
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:
141             {
142                 Reference< XPropertySet > xBindingProps( m_pHelper->getCurrentBinding() );
143                 if ( xBindingProps.is() )
144                 {
145                     aReturn = xBindingProps->getPropertyValue( _rPropertyName );
146                     DBG_ASSERT( aReturn.getValueType().equals( ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ) ),
147                         "EFormsPropertyHandler::getPropertyValue: invalid BindingExpression value type!" );
148                 }
149                 else
150                     aReturn <<= ::rtl::OUString();
151             }
152             break;
153 
154             default:
155                 DBG_ERROR( "EFormsPropertyHandler::getPropertyValue: cannot handle this property!" );
156                 break;
157             }
158         }
159         catch( const Exception& )
160         {
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
168         }
169         return aReturn;
170     }
171 
172     //--------------------------------------------------------------------
173     void SAL_CALL EFormsPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
174     {
175         ::osl::MutexGuard aGuard( m_aMutex );
176         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
177 
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
180 
181         try
182         {
183             Any aOldValue = getPropertyValue( _rPropertyName );
184 
185             switch ( nPropId )
186             {
187             case PROPERTY_ID_LIST_BINDING:
188             {
189                 Reference< XListEntrySource > xSource;
190                 OSL_VERIFY( _rValue >>= xSource );
191                 m_pHelper->setListSourceBinding( xSource );
192             }
193             break;
194 
195             case PROPERTY_ID_XML_DATA_MODEL:
196             {
197                 OSL_VERIFY( _rValue >>= m_sBindingLessModelName );
198 
199                 // if the model changed, reset the binding to NULL
200                 if ( m_pHelper->getCurrentFormModelName() != m_sBindingLessModelName )
201                 {
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() ) );
206                 }
207             }
208             break;
209 
210             case PROPERTY_ID_BINDING_NAME:
211             {
212                 ::rtl::OUString sNewBindingName;
213                 OSL_VERIFY( _rValue >>= sNewBindingName );
214 
215                 bool bPreviouslyEmptyModel = !m_pHelper->getCurrentFormModel().is();
216 
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 );
221 
222                 m_pHelper->setBinding( xNewBinding );
223 
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
229                     //
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;
240                 }
241             }
242             break;
243 
244             case PROPERTY_ID_BIND_EXPRESSION:
245             {
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 );
250             }
251             break;
252 
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:
258             {
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() )
262                 {
263                     DBG_ASSERT( _rValue.getValueType().equals( ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ) ),
264                         "EFormsPropertyHandler::setPropertyValue: invalid value type!" );
265                     xBindingProps->setPropertyValue( _rPropertyName, _rValue );
266                 }
267             }
268             break;
269 
270             default:
271                 DBG_ERROR( "EFormsPropertyHandler::setPropertyValue: cannot handle this property!" );
272                 break;
273             }
274 
275             impl_setContextDocumentModified_nothrow();
276 
277             Any aNewValue( getPropertyValue( _rPropertyName ) );
278             firePropertyChange( _rPropertyName, nPropId, aOldValue, aNewValue );
279         }
280         catch( const Exception& )
281         {
282         	OSL_ENSURE( sal_False, "EFormsPropertyHandler::setPropertyValue: caught an exception!" );
283         }
284     }
285 
286     //--------------------------------------------------------------------
287     void EFormsPropertyHandler::onNewComponent()
288     {
289         EFormsPropertyHandler_Base::onNewComponent();
290 
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 );
297     }
298 
299     //--------------------------------------------------------------------
300     Sequence< Property > SAL_CALL EFormsPropertyHandler::doDescribeSupportedProperties() const
301     {
302         ::std::vector< Property > aProperties;
303 
304         if ( m_pHelper.get() )
305         {
306             if ( m_pHelper->canBindToAnyDataType() )
307             {
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 );
317             }
318             if ( m_pHelper->isListEntrySink() )
319             {
320                 implAddPropertyDescription( aProperties, PROPERTY_LIST_BINDING,
321                     ::getCppuType( static_cast< Reference< XListEntrySource > * >( NULL ) ) );
322             }
323         }
324 
325         if ( aProperties.empty() )
326             return Sequence< Property >();
327         return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
328     }
329 
330     //--------------------------------------------------------------------
331     Any SAL_CALL EFormsPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
332     {
333         ::osl::MutexGuard aGuard( m_aMutex );
334         Any aReturn;
335 
336         OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::convertToPropertyValue: we have no SupportedProperties!" );
337         if ( !m_pHelper.get() )
338             return aReturn;
339 
340         PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
341 
342         ::rtl::OUString sControlValue;
343         switch ( nPropId )
344         {
345         case PROPERTY_ID_LIST_BINDING:
346         {
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;
352         }
353         break;
354 
355         default:
356             aReturn = EFormsPropertyHandler_Base::convertToPropertyValue( _rPropertyName, _rControlValue );
357             break;
358         }
359 
360         return aReturn;
361     }
362 
363     //--------------------------------------------------------------------
364     Any SAL_CALL EFormsPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
365     {
366         ::osl::MutexGuard aGuard( m_aMutex );
367         Any aReturn;
368 
369         OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::convertToControlValue: we have no SupportedProperties!" );
370         if ( !m_pHelper.get() )
371             return aReturn;
372 
373         PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
374 
375         OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING,
376             "EFormsPropertyHandler::convertToControlValue: all our controls should use strings for value exchange!" );
377 
378         switch ( nPropId )
379         {
380         case PROPERTY_ID_LIST_BINDING:
381         {
382             Reference< XPropertySet > xListSourceBinding( _rPropertyValue, UNO_QUERY );
383             if ( xListSourceBinding.is() )
384                 aReturn <<= m_pHelper->getModelElementUIName( EFormsHelper::Binding, xListSourceBinding );
385         }
386         break;
387 
388         default:
389             aReturn = EFormsPropertyHandler_Base::convertToControlValue( _rPropertyName, _rPropertyValue, _rControlValueType );
390             break;
391         }
392 
393         return aReturn;
394     }
395 
396     //--------------------------------------------------------------------
397     Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
398     {
399         ::osl::MutexGuard aGuard( m_aMutex );
400         if ( !m_pHelper.get() )
401             return Sequence< ::rtl::OUString >();
402 
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() );
407     }
408 
409     //--------------------------------------------------------------------
410     Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
411     {
412         ::osl::MutexGuard aGuard( m_aMutex );
413         if ( !m_pHelper.get() )
414             return Sequence< ::rtl::OUString >();
415 
416         Sequence< ::rtl::OUString > aReturn( 1 );
417         aReturn[ 0 ] = PROPERTY_INPUT_REQUIRED;
418         return aReturn;
419     }
420 
421     //--------------------------------------------------------------------
422     LineDescriptor SAL_CALL EFormsPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
423         const Reference< XPropertyControlFactory >& _rxControlFactory )
424         throw (UnknownPropertyException, NullPointerException, RuntimeException)
425     {
426         ::osl::MutexGuard aGuard( m_aMutex );
427         if ( !_rxControlFactory.is() )
428             throw NullPointerException();
429         if ( !m_pHelper.get() )
430             throw RuntimeException();
431 
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 )
437         {
438         case PROPERTY_ID_LIST_BINDING:
439             nControlType = PropertyControlType::ListBox;
440             const_cast< EFormsHelper* >( m_pHelper.get() )->getAllElementUINames( EFormsHelper::Binding, aListEntries, true );
441             break;
442 
443         case PROPERTY_ID_XML_DATA_MODEL:
444             nControlType = PropertyControlType::ListBox;
445             m_pHelper->getFormModelNames( aListEntries );
446             break;
447 
448         case PROPERTY_ID_BINDING_NAME:
449         {
450             nControlType = PropertyControlType::ComboBox;
451             ::rtl::OUString sCurrentModel( getModelNamePropertyValue() );
452             if ( sCurrentModel.getLength() )
453                 m_pHelper->getBindingNames( sCurrentModel, aListEntries );
454         }
455         break;
456 
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;
463 
464         default:
465             DBG_ERROR( "EFormsPropertyHandler::describePropertyLine: cannot handle this property!" );
466             break;
467         }
468 
469         switch ( nControlType )
470         {
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;
480         }
481 
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;
486     }
487 
488     //--------------------------------------------------------------------
489     InteractiveSelectionResult SAL_CALL EFormsPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool /*_bPrimary*/, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
490     {
491         if ( !_rxInspectorUI.is() )
492             throw NullPointerException();
493 
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;
498 
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!" );
508 
509         try
510         {
511             Reference< XExecutableDialog > xDialog;
512             m_aContext.createComponent( "com.sun.star.xforms.ui.dialogs.AddCondition", xDialog );
513             Reference< XPropertySet > xDialogProps( xDialog, UNO_QUERY_THROW );
514 
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 );
521 
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;
526 
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 ) );
530 
531             if ( !xDialog->execute() )
532                 // cancelled
533                 return InteractiveSelectionResult_Cancelled;
534 
535             _rData = xDialogProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConditionValue" ) ) );
536             return InteractiveSelectionResult_ObtainedValue;
537         }
538         catch( const Exception& )
539         {
540         	OSL_ENSURE( sal_False, "EFormsPropertyHandler::onInteractivePropertySelection: caught an exception!" );
541         }
542 
543         // something went wrong here ...(but has been asserted already)
544         return InteractiveSelectionResult_Cancelled;
545     }
546 
547     //--------------------------------------------------------------------
548     void SAL_CALL EFormsPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
549     {
550         ::osl::MutexGuard aGuard( m_aMutex );
551         EFormsPropertyHandler_Base::addPropertyChangeListener( _rxListener );
552         if ( m_pHelper.get() )
553             m_pHelper->registerBindingListener( _rxListener );
554     }
555 
556     //--------------------------------------------------------------------
557     void SAL_CALL EFormsPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
558     {
559         ::osl::MutexGuard aGuard( m_aMutex );
560         if ( m_pHelper.get() )
561             m_pHelper->revokeBindingListener( _rxListener );
562         EFormsPropertyHandler_Base::removePropertyChangeListener( _rxListener );
563     }
564 
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)
567     {
568         if ( !_rxInspectorUI.is() )
569             throw NullPointerException();
570 
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
575 
576         DBG_ASSERT( _rxInspectorUI.is(), "EFormsPropertyHandler::actuatingPropertyChanged: invalid callback!" );
577         if ( !_rxInspectorUI.is() )
578             return;
579 
580         switch ( nActuatingPropId )
581         {
582         case PROPERTY_ID_XML_DATA_MODEL:
583         {
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 );
591         }
592         // NO break
593 
594         case PROPERTY_ID_BINDING_NAME:
595         {
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 );
604         }
605         break;
606 
607         default:
608             DBG_ERROR( "EFormsPropertyHandler::actuatingPropertyChanged: cannot handle this property!" );
609             break;
610         }
611     }
612 
613 //........................................................................
614 } // namespace pcr
615 //........................................................................
616 
617