1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_extensions.hxx"
26 #include "eformspropertyhandler.hxx"
27 #include "formstrings.hxx"
28 #include "formmetadata.hxx"
29 #include "propctrlr.hrc"
30 #include "formbrowsertools.hxx"
31 #include "eformshelper.hxx"
32 #include "handlerhelper.hxx"
33
34 /** === begin UNO includes === **/
35 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
36 #include <com/sun/star/inspection/PropertyControlType.hpp>
37 #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
38 /** === end UNO includes === **/
39 #include <tools/debug.hxx>
40
41 #include <functional>
42
43 //------------------------------------------------------------------------
createRegistryInfo_EFormsPropertyHandler()44 extern "C" void SAL_CALL createRegistryInfo_EFormsPropertyHandler()
45 {
46 ::pcr::EFormsPropertyHandler::registerImplementation();
47 }
48
49 //........................................................................
50 namespace pcr
51 {
52 //........................................................................
53
54 using namespace ::com::sun::star;
55 using namespace ::com::sun::star::uno;
56 using namespace ::com::sun::star::lang;
57 using namespace ::com::sun::star::beans;
58 using namespace ::com::sun::star::xforms;
59 using namespace ::com::sun::star::script;
60 using namespace ::com::sun::star::ui::dialogs;
61 using namespace ::com::sun::star::form::binding;
62 using namespace ::com::sun::star::inspection;
63
64 //====================================================================
65 //= EFormsPropertyHandler
66 //====================================================================
DBG_NAME(EFormsPropertyHandler)67 DBG_NAME( EFormsPropertyHandler )
68 //--------------------------------------------------------------------
69 EFormsPropertyHandler::EFormsPropertyHandler( const Reference< XComponentContext >& _rxContext )
70 :EFormsPropertyHandler_Base( _rxContext )
71 ,m_bSimulatingModelChange( false )
72 {
73 DBG_CTOR( EFormsPropertyHandler, NULL );
74 }
75
76 //--------------------------------------------------------------------
~EFormsPropertyHandler()77 EFormsPropertyHandler::~EFormsPropertyHandler( )
78 {
79 DBG_DTOR( EFormsPropertyHandler, NULL );
80 }
81
82 //--------------------------------------------------------------------
getImplementationName_static()83 ::rtl::OUString SAL_CALL EFormsPropertyHandler::getImplementationName_static( )
84 {
85 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.EFormsPropertyHandler" ) );
86 }
87
88 //--------------------------------------------------------------------
getSupportedServiceNames_static()89 Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getSupportedServiceNames_static( )
90 {
91 Sequence< ::rtl::OUString > aSupported( 1 );
92 aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.XMLFormsPropertyHandler" ) );
93 return aSupported;
94 }
95
96 //--------------------------------------------------------------------
getModelNamePropertyValue() const97 ::rtl::OUString EFormsPropertyHandler::getModelNamePropertyValue() const
98 {
99 ::rtl::OUString sModelName = m_pHelper->getCurrentFormModelName();
100 if ( !sModelName.getLength() )
101 sModelName = m_sBindingLessModelName;
102 return sModelName;
103 }
104
105 //--------------------------------------------------------------------
getPropertyValue(const::rtl::OUString & _rPropertyName)106 Any SAL_CALL EFormsPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName )
107 {
108 ::osl::MutexGuard aGuard( m_aMutex );
109 PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
110
111 OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::getPropertyValue: we don't have any SupportedProperties!" );
112 // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
113
114 Any aReturn;
115 try
116 {
117 switch ( nPropId )
118 {
119 case PROPERTY_ID_LIST_BINDING:
120 aReturn <<= m_pHelper->getCurrentListSourceBinding();
121 break;
122
123 case PROPERTY_ID_XML_DATA_MODEL:
124 aReturn <<= getModelNamePropertyValue();
125 break;
126
127 case PROPERTY_ID_BINDING_NAME:
128 aReturn <<= m_pHelper->getCurrentBindingName();
129 break;
130
131 case PROPERTY_ID_BIND_EXPRESSION:
132 case PROPERTY_ID_XSD_CONSTRAINT:
133 case PROPERTY_ID_XSD_CALCULATION:
134 case PROPERTY_ID_XSD_REQUIRED:
135 case PROPERTY_ID_XSD_RELEVANT:
136 case PROPERTY_ID_XSD_READONLY:
137 {
138 Reference< XPropertySet > xBindingProps( m_pHelper->getCurrentBinding() );
139 if ( xBindingProps.is() )
140 {
141 aReturn = xBindingProps->getPropertyValue( _rPropertyName );
142 DBG_ASSERT( aReturn.getValueType().equals( ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ) ),
143 "EFormsPropertyHandler::getPropertyValue: invalid BindingExpression value type!" );
144 }
145 else
146 aReturn <<= ::rtl::OUString();
147 }
148 break;
149
150 default:
151 DBG_ERROR( "EFormsPropertyHandler::getPropertyValue: cannot handle this property!" );
152 break;
153 }
154 }
155 catch( const Exception& )
156 {
157 #if OSL_DEBUG_LEVEL > 0
158 ::rtl::OString sMessage( "EFormsPropertyHandler::getPropertyValue: caught an exception!" );
159 sMessage += "\n(have been asked for the \"";
160 sMessage += ::rtl::OString( _rPropertyName.getStr(), _rPropertyName.getLength(), RTL_TEXTENCODING_ASCII_US );
161 sMessage += "\" property.)";
162 OSL_ENSURE( sal_False, sMessage.getStr() );
163 #endif
164 }
165 return aReturn;
166 }
167
168 //--------------------------------------------------------------------
setPropertyValue(const::rtl::OUString & _rPropertyName,const Any & _rValue)169 void SAL_CALL EFormsPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue )
170 {
171 ::osl::MutexGuard aGuard( m_aMutex );
172 PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
173
174 OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::setPropertyValue: we don't have any SupportedProperties!" );
175 // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
176
177 try
178 {
179 Any aOldValue = getPropertyValue( _rPropertyName );
180
181 switch ( nPropId )
182 {
183 case PROPERTY_ID_LIST_BINDING:
184 {
185 Reference< XListEntrySource > xSource;
186 OSL_VERIFY( _rValue >>= xSource );
187 m_pHelper->setListSourceBinding( xSource );
188 }
189 break;
190
191 case PROPERTY_ID_XML_DATA_MODEL:
192 {
193 OSL_VERIFY( _rValue >>= m_sBindingLessModelName );
194
195 // if the model changed, reset the binding to NULL
196 if ( m_pHelper->getCurrentFormModelName() != m_sBindingLessModelName )
197 {
198 ::rtl::OUString sOldBindingName = m_pHelper->getCurrentBindingName();
199 m_pHelper->setBinding( NULL );
200 firePropertyChange( PROPERTY_BINDING_NAME, PROPERTY_ID_BINDING_NAME,
201 makeAny( sOldBindingName ), makeAny( ::rtl::OUString() ) );
202 }
203 }
204 break;
205
206 case PROPERTY_ID_BINDING_NAME:
207 {
208 ::rtl::OUString sNewBindingName;
209 OSL_VERIFY( _rValue >>= sNewBindingName );
210
211 bool bPreviouslyEmptyModel = !m_pHelper->getCurrentFormModel().is();
212
213 Reference< XPropertySet > xNewBinding;
214 if ( sNewBindingName.getLength() )
215 // obtain the binding with this name, for the current model
216 xNewBinding = m_pHelper->getOrCreateBindingForModel( getModelNamePropertyValue(), sNewBindingName );
217
218 m_pHelper->setBinding( xNewBinding );
219
220 if ( bPreviouslyEmptyModel )
221 { // simulate a property change for the model property
222 // This is because we "simulate" the Model property by remembering the
223 // value ourself. Other instances might, however, not know this value,
224 // but prefer to retrieve it somewhere else - e.g. from the EFormsHelper
225 //
226 // The really correct solution would be if *all* property handlers
227 // obtain a "current property value" for *all* properties from a central
228 // instance. Then, handler A could ask it for the value of property
229 // X, and this request would be re-routed to handler B, which ultimately
230 // knows the current value.
231 // However, there's no such mechanism in place currently.
232 m_bSimulatingModelChange = true;
233 firePropertyChange( PROPERTY_XML_DATA_MODEL, PROPERTY_ID_XML_DATA_MODEL,
234 makeAny( ::rtl::OUString() ), makeAny( getModelNamePropertyValue() ) );
235 m_bSimulatingModelChange = false;
236 }
237 }
238 break;
239
240 case PROPERTY_ID_BIND_EXPRESSION:
241 {
242 Reference< XPropertySet > xBinding( m_pHelper->getCurrentBinding() );
243 OSL_ENSURE( xBinding.is(), "You should not reach this without an active binding!" );
244 if ( xBinding.is() )
245 xBinding->setPropertyValue( PROPERTY_BIND_EXPRESSION, _rValue );
246 }
247 break;
248
249 case PROPERTY_ID_XSD_REQUIRED:
250 case PROPERTY_ID_XSD_RELEVANT:
251 case PROPERTY_ID_XSD_READONLY:
252 case PROPERTY_ID_XSD_CONSTRAINT:
253 case PROPERTY_ID_XSD_CALCULATION:
254 {
255 Reference< XPropertySet > xBindingProps( m_pHelper->getCurrentBinding() );
256 DBG_ASSERT( xBindingProps.is(), "EFormsPropertyHandler::setPropertyValue: how can I set a property if there's no binding?" );
257 if ( xBindingProps.is() )
258 {
259 DBG_ASSERT( _rValue.getValueType().equals( ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ) ),
260 "EFormsPropertyHandler::setPropertyValue: invalid value type!" );
261 xBindingProps->setPropertyValue( _rPropertyName, _rValue );
262 }
263 }
264 break;
265
266 default:
267 DBG_ERROR( "EFormsPropertyHandler::setPropertyValue: cannot handle this property!" );
268 break;
269 }
270
271 impl_setContextDocumentModified_nothrow();
272
273 Any aNewValue( getPropertyValue( _rPropertyName ) );
274 firePropertyChange( _rPropertyName, nPropId, aOldValue, aNewValue );
275 }
276 catch( const Exception& )
277 {
278 OSL_ENSURE( sal_False, "EFormsPropertyHandler::setPropertyValue: caught an exception!" );
279 }
280 }
281
282 //--------------------------------------------------------------------
onNewComponent()283 void EFormsPropertyHandler::onNewComponent()
284 {
285 EFormsPropertyHandler_Base::onNewComponent();
286
287 Reference< frame::XModel > xDocument( impl_getContextDocument_nothrow() );
288 DBG_ASSERT( xDocument.is(), "EFormsPropertyHandler::onNewComponent: no document!" );
289 if ( EFormsHelper::isEForm( xDocument ) )
290 m_pHelper.reset( new EFormsHelper( m_aMutex, m_xComponent, xDocument ) );
291 else
292 m_pHelper.reset();
293 }
294
295 //--------------------------------------------------------------------
doDescribeSupportedProperties() const296 Sequence< Property > SAL_CALL EFormsPropertyHandler::doDescribeSupportedProperties() const
297 {
298 ::std::vector< Property > aProperties;
299
300 if ( m_pHelper.get() )
301 {
302 if ( m_pHelper->canBindToAnyDataType() )
303 {
304 aProperties.reserve( 7 );
305 addStringPropertyDescription( aProperties, PROPERTY_XML_DATA_MODEL );
306 addStringPropertyDescription( aProperties, PROPERTY_BINDING_NAME );
307 addStringPropertyDescription( aProperties, PROPERTY_BIND_EXPRESSION );
308 addStringPropertyDescription( aProperties, PROPERTY_XSD_REQUIRED );
309 addStringPropertyDescription( aProperties, PROPERTY_XSD_RELEVANT );
310 addStringPropertyDescription( aProperties, PROPERTY_XSD_READONLY );
311 addStringPropertyDescription( aProperties, PROPERTY_XSD_CONSTRAINT );
312 addStringPropertyDescription( aProperties, PROPERTY_XSD_CALCULATION );
313 }
314 if ( m_pHelper->isListEntrySink() )
315 {
316 implAddPropertyDescription( aProperties, PROPERTY_LIST_BINDING,
317 ::getCppuType( static_cast< Reference< XListEntrySource > * >( NULL ) ) );
318 }
319 }
320
321 if ( aProperties.empty() )
322 return Sequence< Property >();
323 return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
324 }
325
326 //--------------------------------------------------------------------
convertToPropertyValue(const::rtl::OUString & _rPropertyName,const Any & _rControlValue)327 Any SAL_CALL EFormsPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue )
328 {
329 ::osl::MutexGuard aGuard( m_aMutex );
330 Any aReturn;
331
332 OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::convertToPropertyValue: we have no SupportedProperties!" );
333 if ( !m_pHelper.get() )
334 return aReturn;
335
336 PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
337
338 ::rtl::OUString sControlValue;
339 switch ( nPropId )
340 {
341 case PROPERTY_ID_LIST_BINDING:
342 {
343 OSL_VERIFY( _rControlValue >>= sControlValue );
344 Reference< XListEntrySource > xListSource( m_pHelper->getModelElementFromUIName( EFormsHelper::Binding, sControlValue ), UNO_QUERY );
345 OSL_ENSURE( xListSource.is() || !m_pHelper->getModelElementFromUIName( EFormsHelper::Binding, sControlValue ).is(),
346 "EFormsPropertyHandler::convertToPropertyValue: there's a binding which is no ListEntrySource!" );
347 aReturn <<= xListSource;
348 }
349 break;
350
351 default:
352 aReturn = EFormsPropertyHandler_Base::convertToPropertyValue( _rPropertyName, _rControlValue );
353 break;
354 }
355
356 return aReturn;
357 }
358
359 //--------------------------------------------------------------------
convertToControlValue(const::rtl::OUString & _rPropertyName,const Any & _rPropertyValue,const Type & _rControlValueType)360 Any SAL_CALL EFormsPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType )
361 {
362 ::osl::MutexGuard aGuard( m_aMutex );
363 Any aReturn;
364
365 OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::convertToControlValue: we have no SupportedProperties!" );
366 if ( !m_pHelper.get() )
367 return aReturn;
368
369 PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
370
371 OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING,
372 "EFormsPropertyHandler::convertToControlValue: all our controls should use strings for value exchange!" );
373
374 switch ( nPropId )
375 {
376 case PROPERTY_ID_LIST_BINDING:
377 {
378 Reference< XPropertySet > xListSourceBinding( _rPropertyValue, UNO_QUERY );
379 if ( xListSourceBinding.is() )
380 aReturn <<= m_pHelper->getModelElementUIName( EFormsHelper::Binding, xListSourceBinding );
381 }
382 break;
383
384 default:
385 aReturn = EFormsPropertyHandler_Base::convertToControlValue( _rPropertyName, _rPropertyValue, _rControlValueType );
386 break;
387 }
388
389 return aReturn;
390 }
391
392 //--------------------------------------------------------------------
getActuatingProperties()393 Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getActuatingProperties( )
394 {
395 ::osl::MutexGuard aGuard( m_aMutex );
396 if ( !m_pHelper.get() )
397 return Sequence< ::rtl::OUString >();
398
399 ::std::vector< ::rtl::OUString > aInterestedInActuations( 2 );
400 aInterestedInActuations[ 0 ] = PROPERTY_XML_DATA_MODEL;
401 aInterestedInActuations[ 1 ] = PROPERTY_BINDING_NAME;
402 return Sequence< ::rtl::OUString >( &(*aInterestedInActuations.begin()), aInterestedInActuations.size() );
403 }
404
405 //--------------------------------------------------------------------
getSupersededProperties()406 Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getSupersededProperties( )
407 {
408 ::osl::MutexGuard aGuard( m_aMutex );
409 if ( !m_pHelper.get() )
410 return Sequence< ::rtl::OUString >();
411
412 Sequence< ::rtl::OUString > aReturn( 1 );
413 aReturn[ 0 ] = PROPERTY_INPUT_REQUIRED;
414 return aReturn;
415 }
416
417 //--------------------------------------------------------------------
describePropertyLine(const::rtl::OUString & _rPropertyName,const Reference<XPropertyControlFactory> & _rxControlFactory)418 LineDescriptor SAL_CALL EFormsPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
419 const Reference< XPropertyControlFactory >& _rxControlFactory )
420 {
421 ::osl::MutexGuard aGuard( m_aMutex );
422 if ( !_rxControlFactory.is() )
423 throw NullPointerException();
424 if ( !m_pHelper.get() )
425 throw RuntimeException();
426
427 LineDescriptor aDescriptor;
428 sal_Int16 nControlType = PropertyControlType::TextField;
429 ::std::vector< ::rtl::OUString > aListEntries;
430 PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
431 switch ( nPropId )
432 {
433 case PROPERTY_ID_LIST_BINDING:
434 nControlType = PropertyControlType::ListBox;
435 const_cast< EFormsHelper* >( m_pHelper.get() )->getAllElementUINames( EFormsHelper::Binding, aListEntries, true );
436 break;
437
438 case PROPERTY_ID_XML_DATA_MODEL:
439 nControlType = PropertyControlType::ListBox;
440 m_pHelper->getFormModelNames( aListEntries );
441 break;
442
443 case PROPERTY_ID_BINDING_NAME:
444 {
445 nControlType = PropertyControlType::ComboBox;
446 ::rtl::OUString sCurrentModel( getModelNamePropertyValue() );
447 if ( sCurrentModel.getLength() )
448 m_pHelper->getBindingNames( sCurrentModel, aListEntries );
449 }
450 break;
451
452 case PROPERTY_ID_BIND_EXPRESSION: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_BIND_EXPRESSION); break;
453 case PROPERTY_ID_XSD_REQUIRED: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_REQUIRED); break;
454 case PROPERTY_ID_XSD_RELEVANT: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_RELEVANT); break;
455 case PROPERTY_ID_XSD_READONLY: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_READONLY); break;
456 case PROPERTY_ID_XSD_CONSTRAINT: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_CONSTRAINT); break;
457 case PROPERTY_ID_XSD_CALCULATION: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_CALCULATION); break;
458
459 default:
460 DBG_ERROR( "EFormsPropertyHandler::describePropertyLine: cannot handle this property!" );
461 break;
462 }
463
464 switch ( nControlType )
465 {
466 case PropertyControlType::ListBox:
467 aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_True );
468 break;
469 case PropertyControlType::ComboBox:
470 aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl( _rxControlFactory, aListEntries, sal_False, sal_True );
471 break;
472 default:
473 aDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, sal_False );
474 break;
475 }
476
477 aDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId );
478 aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) );
479 aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
480 return aDescriptor;
481 }
482
483 //--------------------------------------------------------------------
onInteractivePropertySelection(const::rtl::OUString & _rPropertyName,sal_Bool,Any & _rData,const Reference<XObjectInspectorUI> & _rxInspectorUI)484 InteractiveSelectionResult SAL_CALL EFormsPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool /*_bPrimary*/, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI )
485 {
486 if ( !_rxInspectorUI.is() )
487 throw NullPointerException();
488
489 ::osl::MutexGuard aGuard( m_aMutex );
490 OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::onInteractivePropertySelection: we do not have any SupportedProperties!" );
491 if ( !m_pHelper.get() )
492 return InteractiveSelectionResult_Cancelled;
493
494 PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
495 (void)nPropId;
496 OSL_ENSURE( ( PROPERTY_ID_BINDING_NAME == nPropId )
497 || ( PROPERTY_ID_BIND_EXPRESSION == nPropId )
498 || ( PROPERTY_ID_XSD_REQUIRED == nPropId )
499 || ( PROPERTY_ID_XSD_RELEVANT == nPropId )
500 || ( PROPERTY_ID_XSD_READONLY == nPropId )
501 || ( PROPERTY_ID_XSD_CONSTRAINT == nPropId )
502 || ( PROPERTY_ID_XSD_CALCULATION == nPropId ), "EFormsPropertyHandler::onInteractivePropertySelection: unexpected!" );
503
504 try
505 {
506 Reference< XExecutableDialog > xDialog;
507 m_aContext.createComponent( "com.sun.star.xforms.ui.dialogs.AddCondition", xDialog );
508 Reference< XPropertySet > xDialogProps( xDialog, UNO_QUERY_THROW );
509
510 // the model for the dialog to work with
511 Reference< xforms::XModel > xModel( m_pHelper->getCurrentFormModel() );
512 // the binding for the dialog to work with
513 Reference< XPropertySet > xBinding( m_pHelper->getCurrentBinding() );
514 // the aspect of the binding which the dialog should modify
515 ::rtl::OUString sFacetName( _rPropertyName );
516
517 OSL_ENSURE( xModel.is() && xBinding.is() && sFacetName.getLength(),
518 "EFormsPropertyHandler::onInteractivePropertySelection: something is missing for the dialog initialization!" );
519 if ( !( xModel.is() && xBinding.is() && sFacetName.getLength() ) )
520 return InteractiveSelectionResult_Cancelled;
521
522 xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormModel" ) ), makeAny( xModel ) );
523 xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Binding" ) ), makeAny( xBinding ) );
524 xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FacetName" ) ), makeAny( sFacetName ) );
525
526 if ( !xDialog->execute() )
527 // cancelled
528 return InteractiveSelectionResult_Cancelled;
529
530 _rData = xDialogProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConditionValue" ) ) );
531 return InteractiveSelectionResult_ObtainedValue;
532 }
533 catch( const Exception& )
534 {
535 OSL_ENSURE( sal_False, "EFormsPropertyHandler::onInteractivePropertySelection: caught an exception!" );
536 }
537
538 // something went wrong here ...(but has been asserted already)
539 return InteractiveSelectionResult_Cancelled;
540 }
541
542 //--------------------------------------------------------------------
addPropertyChangeListener(const Reference<XPropertyChangeListener> & _rxListener)543 void SAL_CALL EFormsPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener )
544 {
545 ::osl::MutexGuard aGuard( m_aMutex );
546 EFormsPropertyHandler_Base::addPropertyChangeListener( _rxListener );
547 if ( m_pHelper.get() )
548 m_pHelper->registerBindingListener( _rxListener );
549 }
550
551 //--------------------------------------------------------------------
removePropertyChangeListener(const Reference<XPropertyChangeListener> & _rxListener)552 void SAL_CALL EFormsPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener )
553 {
554 ::osl::MutexGuard aGuard( m_aMutex );
555 if ( m_pHelper.get() )
556 m_pHelper->revokeBindingListener( _rxListener );
557 EFormsPropertyHandler_Base::removePropertyChangeListener( _rxListener );
558 }
559
560 //--------------------------------------------------------------------
actuatingPropertyChanged(const::rtl::OUString & _rActuatingPropertyName,const Any & _rNewValue,const Any &,const Reference<XObjectInspectorUI> & _rxInspectorUI,sal_Bool)561 void SAL_CALL EFormsPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool )
562 {
563 if ( !_rxInspectorUI.is() )
564 throw NullPointerException();
565
566 ::osl::MutexGuard aGuard( m_aMutex );
567 PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
568 OSL_PRECOND( m_pHelper.get(), "EFormsPropertyHandler::actuatingPropertyChanged: inconsistentcy!" );
569 // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
570
571 DBG_ASSERT( _rxInspectorUI.is(), "EFormsPropertyHandler::actuatingPropertyChanged: invalid callback!" );
572 if ( !_rxInspectorUI.is() )
573 return;
574
575 switch ( nActuatingPropId )
576 {
577 case PROPERTY_ID_XML_DATA_MODEL:
578 {
579 if ( m_bSimulatingModelChange )
580 break;
581 ::rtl::OUString sDataModelName;
582 OSL_VERIFY( _rNewValue >>= sDataModelName );
583 sal_Bool bBoundToSomeModel = 0 != sDataModelName.getLength();
584 _rxInspectorUI->rebuildPropertyUI( PROPERTY_BINDING_NAME );
585 _rxInspectorUI->enablePropertyUI( PROPERTY_BINDING_NAME, bBoundToSomeModel );
586 }
587 // NO break
588
589 case PROPERTY_ID_BINDING_NAME:
590 {
591 sal_Bool bHaveABinding = ( m_pHelper->getCurrentBindingName().getLength() > 0 );
592 _rxInspectorUI->enablePropertyUI( PROPERTY_BIND_EXPRESSION, bHaveABinding );
593 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_REQUIRED, bHaveABinding );
594 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_RELEVANT, bHaveABinding );
595 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_READONLY, bHaveABinding );
596 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_CONSTRAINT, bHaveABinding );
597 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_CALCULATION, bHaveABinding );
598 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_DATA_TYPE, bHaveABinding );
599 }
600 break;
601
602 default:
603 DBG_ERROR( "EFormsPropertyHandler::actuatingPropertyChanged: cannot handle this property!" );
604 break;
605 }
606 }
607
608 //........................................................................
609 } // namespace pcr
610 //........................................................................
611