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( ) throw (RuntimeException)
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( ) throw (RuntimeException)
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 ) throw (UnknownPropertyException, RuntimeException)
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 ) throw (UnknownPropertyException, RuntimeException)
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 ) throw (UnknownPropertyException, RuntimeException)
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 ) throw (UnknownPropertyException, RuntimeException)
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( ) throw (RuntimeException)
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( ) throw (RuntimeException)
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 throw (UnknownPropertyException, NullPointerException, RuntimeException)
421 {
422 ::osl::MutexGuard aGuard( m_aMutex );
423 if ( !_rxControlFactory.is() )
424 throw NullPointerException();
425 if ( !m_pHelper.get() )
426 throw RuntimeException();
427
428 LineDescriptor aDescriptor;
429 sal_Int16 nControlType = PropertyControlType::TextField;
430 ::std::vector< ::rtl::OUString > aListEntries;
431 PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
432 switch ( nPropId )
433 {
434 case PROPERTY_ID_LIST_BINDING:
435 nControlType = PropertyControlType::ListBox;
436 const_cast< EFormsHelper* >( m_pHelper.get() )->getAllElementUINames( EFormsHelper::Binding, aListEntries, true );
437 break;
438
439 case PROPERTY_ID_XML_DATA_MODEL:
440 nControlType = PropertyControlType::ListBox;
441 m_pHelper->getFormModelNames( aListEntries );
442 break;
443
444 case PROPERTY_ID_BINDING_NAME:
445 {
446 nControlType = PropertyControlType::ComboBox;
447 ::rtl::OUString sCurrentModel( getModelNamePropertyValue() );
448 if ( sCurrentModel.getLength() )
449 m_pHelper->getBindingNames( sCurrentModel, aListEntries );
450 }
451 break;
452
453 case PROPERTY_ID_BIND_EXPRESSION: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_BIND_EXPRESSION); break;
454 case PROPERTY_ID_XSD_REQUIRED: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_REQUIRED); break;
455 case PROPERTY_ID_XSD_RELEVANT: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_RELEVANT); break;
456 case PROPERTY_ID_XSD_READONLY: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_READONLY); break;
457 case PROPERTY_ID_XSD_CONSTRAINT: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_CONSTRAINT); break;
458 case PROPERTY_ID_XSD_CALCULATION: aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_DLG_XSD_CALCULATION); break;
459
460 default:
461 DBG_ERROR( "EFormsPropertyHandler::describePropertyLine: cannot handle this property!" );
462 break;
463 }
464
465 switch ( nControlType )
466 {
467 case PropertyControlType::ListBox:
468 aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_True );
469 break;
470 case PropertyControlType::ComboBox:
471 aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl( _rxControlFactory, aListEntries, sal_False, sal_True );
472 break;
473 default:
474 aDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, sal_False );
475 break;
476 }
477
478 aDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId );
479 aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) );
480 aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
481 return aDescriptor;
482 }
483
484 //--------------------------------------------------------------------
onInteractivePropertySelection(const::rtl::OUString & _rPropertyName,sal_Bool,Any & _rData,const Reference<XObjectInspectorUI> & _rxInspectorUI)485 InteractiveSelectionResult SAL_CALL EFormsPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool /*_bPrimary*/, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
486 {
487 if ( !_rxInspectorUI.is() )
488 throw NullPointerException();
489
490 ::osl::MutexGuard aGuard( m_aMutex );
491 OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::onInteractivePropertySelection: we do not have any SupportedProperties!" );
492 if ( !m_pHelper.get() )
493 return InteractiveSelectionResult_Cancelled;
494
495 PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
496 (void)nPropId;
497 OSL_ENSURE( ( PROPERTY_ID_BINDING_NAME == nPropId )
498 || ( PROPERTY_ID_BIND_EXPRESSION == nPropId )
499 || ( PROPERTY_ID_XSD_REQUIRED == nPropId )
500 || ( PROPERTY_ID_XSD_RELEVANT == nPropId )
501 || ( PROPERTY_ID_XSD_READONLY == nPropId )
502 || ( PROPERTY_ID_XSD_CONSTRAINT == nPropId )
503 || ( PROPERTY_ID_XSD_CALCULATION == nPropId ), "EFormsPropertyHandler::onInteractivePropertySelection: unexpected!" );
504
505 try
506 {
507 Reference< XExecutableDialog > xDialog;
508 m_aContext.createComponent( "com.sun.star.xforms.ui.dialogs.AddCondition", xDialog );
509 Reference< XPropertySet > xDialogProps( xDialog, UNO_QUERY_THROW );
510
511 // the model for the dialog to work with
512 Reference< xforms::XModel > xModel( m_pHelper->getCurrentFormModel() );
513 // the binding for the dialog to work with
514 Reference< XPropertySet > xBinding( m_pHelper->getCurrentBinding() );
515 // the aspect of the binding which the dialog should modify
516 ::rtl::OUString sFacetName( _rPropertyName );
517
518 OSL_ENSURE( xModel.is() && xBinding.is() && sFacetName.getLength(),
519 "EFormsPropertyHandler::onInteractivePropertySelection: something is missing for the dialog initialization!" );
520 if ( !( xModel.is() && xBinding.is() && sFacetName.getLength() ) )
521 return InteractiveSelectionResult_Cancelled;
522
523 xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormModel" ) ), makeAny( xModel ) );
524 xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Binding" ) ), makeAny( xBinding ) );
525 xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FacetName" ) ), makeAny( sFacetName ) );
526
527 if ( !xDialog->execute() )
528 // cancelled
529 return InteractiveSelectionResult_Cancelled;
530
531 _rData = xDialogProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConditionValue" ) ) );
532 return InteractiveSelectionResult_ObtainedValue;
533 }
534 catch( const Exception& )
535 {
536 OSL_ENSURE( sal_False, "EFormsPropertyHandler::onInteractivePropertySelection: caught an exception!" );
537 }
538
539 // something went wrong here ...(but has been asserted already)
540 return InteractiveSelectionResult_Cancelled;
541 }
542
543 //--------------------------------------------------------------------
addPropertyChangeListener(const Reference<XPropertyChangeListener> & _rxListener)544 void SAL_CALL EFormsPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
545 {
546 ::osl::MutexGuard aGuard( m_aMutex );
547 EFormsPropertyHandler_Base::addPropertyChangeListener( _rxListener );
548 if ( m_pHelper.get() )
549 m_pHelper->registerBindingListener( _rxListener );
550 }
551
552 //--------------------------------------------------------------------
removePropertyChangeListener(const Reference<XPropertyChangeListener> & _rxListener)553 void SAL_CALL EFormsPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
554 {
555 ::osl::MutexGuard aGuard( m_aMutex );
556 if ( m_pHelper.get() )
557 m_pHelper->revokeBindingListener( _rxListener );
558 EFormsPropertyHandler_Base::removePropertyChangeListener( _rxListener );
559 }
560
561 //--------------------------------------------------------------------
actuatingPropertyChanged(const::rtl::OUString & _rActuatingPropertyName,const Any & _rNewValue,const Any &,const Reference<XObjectInspectorUI> & _rxInspectorUI,sal_Bool)562 void SAL_CALL EFormsPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (NullPointerException, RuntimeException)
563 {
564 if ( !_rxInspectorUI.is() )
565 throw NullPointerException();
566
567 ::osl::MutexGuard aGuard( m_aMutex );
568 PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
569 OSL_PRECOND( m_pHelper.get(), "EFormsPropertyHandler::actuatingPropertyChanged: inconsistentcy!" );
570 // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
571
572 DBG_ASSERT( _rxInspectorUI.is(), "EFormsPropertyHandler::actuatingPropertyChanged: invalid callback!" );
573 if ( !_rxInspectorUI.is() )
574 return;
575
576 switch ( nActuatingPropId )
577 {
578 case PROPERTY_ID_XML_DATA_MODEL:
579 {
580 if ( m_bSimulatingModelChange )
581 break;
582 ::rtl::OUString sDataModelName;
583 OSL_VERIFY( _rNewValue >>= sDataModelName );
584 sal_Bool bBoundToSomeModel = 0 != sDataModelName.getLength();
585 _rxInspectorUI->rebuildPropertyUI( PROPERTY_BINDING_NAME );
586 _rxInspectorUI->enablePropertyUI( PROPERTY_BINDING_NAME, bBoundToSomeModel );
587 }
588 // NO break
589
590 case PROPERTY_ID_BINDING_NAME:
591 {
592 sal_Bool bHaveABinding = ( m_pHelper->getCurrentBindingName().getLength() > 0 );
593 _rxInspectorUI->enablePropertyUI( PROPERTY_BIND_EXPRESSION, bHaveABinding );
594 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_REQUIRED, bHaveABinding );
595 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_RELEVANT, bHaveABinding );
596 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_READONLY, bHaveABinding );
597 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_CONSTRAINT, bHaveABinding );
598 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_CALCULATION, bHaveABinding );
599 _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_DATA_TYPE, bHaveABinding );
600 }
601 break;
602
603 default:
604 DBG_ERROR( "EFormsPropertyHandler::actuatingPropertyChanged: cannot handle this property!" );
605 break;
606 }
607 }
608
609 //........................................................................
610 } // namespace pcr
611 //........................................................................
612
613