1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <string_view>
22 #include "eformshelper.hxx"
23 #include "formstrings.hxx"
24 #include <strings.hrc>
25 #include "modulepcr.hxx"
26 #include "propeventtranslation.hxx"
27 #include "formbrowsertools.hxx"
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/form/FormComponentType.hpp>
31 #include <com/sun/star/xforms/XFormsUIHelper1.hpp>
32 #include <com/sun/star/xsd/DataTypeClass.hpp>
33 #include <com/sun/star/form/binding/XListEntrySink.hpp>
34 #include <comphelper/diagnose_ex.hxx>
37 #include <o3tl/functional.hxx>
43 using namespace ::com::sun::star
;
44 using namespace ::com::sun::star::uno
;
45 using namespace ::com::sun::star::beans
;
46 using namespace ::com::sun::star::container
;
47 using namespace ::com::sun::star::form::binding
;
48 using namespace ::com::sun::star::xsd
;
49 using namespace ::com::sun::star::lang
;
50 using namespace ::com::sun::star::form
;
53 //= file-local helpers
58 OUString
composeModelElementUIName( std::u16string_view _rModelName
, std::u16string_view _rElementName
)
60 OUString a
= OUString::Concat("[")
71 EFormsHelper::EFormsHelper( ::osl::Mutex
& _rMutex
, const Reference
< XPropertySet
>& _rxControlModel
, const Reference
< frame::XModel
>& _rxContextDocument
)
72 :m_xControlModel( _rxControlModel
)
73 ,m_aPropertyListeners( _rMutex
)
75 OSL_ENSURE( _rxControlModel
.is(), "EFormsHelper::EFormsHelper: invalid control model!" );
76 m_xBindableControl
.set(_rxControlModel
, css::uno::UNO_QUERY
);
78 m_xDocument
.set(_rxContextDocument
, css::uno::UNO_QUERY
);
79 OSL_ENSURE( m_xDocument
.is(), "EFormsHelper::EFormsHelper: invalid document!" );
84 bool EFormsHelper::isEForm( const Reference
< frame::XModel
>& _rxContextDocument
)
88 Reference
< xforms::XFormsSupplier
> xDocument( _rxContextDocument
, UNO_QUERY
);
89 if ( !xDocument
.is() )
92 return xDocument
->getXForms().is();
94 catch( const Exception
& )
96 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::isEForm" );
102 bool EFormsHelper::canBindToDataType( sal_Int32 _nDataType
) const
104 if ( !m_xBindableControl
.is() )
105 // cannot bind at all
108 // some types cannot be bound, independent from the control type
109 if ( ( DataTypeClass::hexBinary
== _nDataType
)
110 || ( DataTypeClass::base64Binary
== _nDataType
)
111 || ( DataTypeClass::QName
== _nDataType
)
112 || ( DataTypeClass::NOTATION
== _nDataType
)
119 // classify the control model
120 sal_Int16 nControlType
= FormComponentType::CONTROL
;
121 OSL_VERIFY( m_xControlModel
->getPropertyValue( PROPERTY_CLASSID
) >>= nControlType
);
124 sal_Int16
const nNumericCompatibleTypes
[] = { DataTypeClass::DECIMAL
, DataTypeClass::FLOAT
, DataTypeClass::DOUBLE
, 0 };
125 sal_Int16
const nDateCompatibleTypes
[] = { DataTypeClass::DATE
, 0 };
126 sal_Int16
const nTimeCompatibleTypes
[] = { DataTypeClass::TIME
, 0 };
127 sal_Int16
const nCheckboxCompatibleTypes
[] = { DataTypeClass::BOOLEAN
, DataTypeClass::STRING
, DataTypeClass::anyURI
, 0 };
128 sal_Int16
const nRadiobuttonCompatibleTypes
[] = { DataTypeClass::STRING
, DataTypeClass::anyURI
, 0 };
129 sal_Int16
const nFormattedCompatibleTypes
[] = { DataTypeClass::DECIMAL
, DataTypeClass::FLOAT
, DataTypeClass::DOUBLE
, DataTypeClass::DATETIME
, DataTypeClass::DATE
, DataTypeClass::TIME
, 0 };
131 sal_Int16
const * pCompatibleTypes
= nullptr;
132 switch ( nControlType
)
134 case FormComponentType::SPINBUTTON
:
135 case FormComponentType::NUMERICFIELD
:
136 pCompatibleTypes
= nNumericCompatibleTypes
;
138 case FormComponentType::DATEFIELD
:
139 pCompatibleTypes
= nDateCompatibleTypes
;
141 case FormComponentType::TIMEFIELD
:
142 pCompatibleTypes
= nTimeCompatibleTypes
;
144 case FormComponentType::CHECKBOX
:
145 pCompatibleTypes
= nCheckboxCompatibleTypes
;
147 case FormComponentType::RADIOBUTTON
:
148 pCompatibleTypes
= nRadiobuttonCompatibleTypes
;
151 case FormComponentType::TEXTFIELD
:
153 // both the normal text field, and the formatted field, claim to be a TEXTFIELD
154 // need to distinguish by service name
155 Reference
< XServiceInfo
> xSI( m_xControlModel
, UNO_QUERY
);
156 OSL_ENSURE( xSI
.is(), "EFormsHelper::canBindToDataType: a control model which has no service info?" );
159 if ( xSI
->supportsService( SERVICE_COMPONENT_FORMATTEDFIELD
) )
161 pCompatibleTypes
= nFormattedCompatibleTypes
;
167 case FormComponentType::LISTBOX
:
168 case FormComponentType::COMBOBOX
:
169 // edit fields and list/combo boxes can be bound to anything
173 if ( !bCan
&& pCompatibleTypes
)
175 if ( _nDataType
== -1 )
177 // the control can be bound to at least one type, and exactly this is being asked for
182 while ( *pCompatibleTypes
&& !bCan
)
183 bCan
= ( *pCompatibleTypes
++ == _nDataType
);
187 catch( const Exception
& )
189 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::canBindToDataType" );
196 bool EFormsHelper::isListEntrySink() const
201 Reference
< XListEntrySink
> xAsSink( m_xControlModel
, UNO_QUERY
);
204 catch( const Exception
& )
206 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::isListEntrySink" );
212 void EFormsHelper::impl_switchBindingListening_throw( bool _bDoListening
, const Reference
< XPropertyChangeListener
>& _rxListener
)
214 Reference
< XPropertySet
> xBindingProps
;
215 if ( m_xBindableControl
.is() )
216 xBindingProps
.set(m_xBindableControl
->getValueBinding(), css::uno::UNO_QUERY
);
217 if ( !xBindingProps
.is() )
222 xBindingProps
->addPropertyChangeListener( OUString(), _rxListener
);
226 xBindingProps
->removePropertyChangeListener( OUString(), _rxListener
);
231 void EFormsHelper::registerBindingListener( const Reference
< XPropertyChangeListener
>& _rxBindingListener
)
233 if ( !_rxBindingListener
.is() )
235 impl_toggleBindingPropertyListening_throw( true, _rxBindingListener
);
239 void EFormsHelper::impl_toggleBindingPropertyListening_throw( bool _bDoListen
, const Reference
< XPropertyChangeListener
>& _rxConcreteListenerOrNull
)
243 ::comphelper::OInterfaceIteratorHelper3
aListenerIterator(m_aPropertyListeners
);
244 while ( aListenerIterator
.hasMoreElements() )
246 PropertyEventTranslation
* pTranslator
= dynamic_cast< PropertyEventTranslation
* >( aListenerIterator
.next().get() );
247 OSL_ENSURE( pTranslator
, "EFormsHelper::impl_toggleBindingPropertyListening_throw: invalid listener element in my container!" );
251 Reference
< XPropertyChangeListener
> xEventSourceTranslator( pTranslator
);
252 if ( _rxConcreteListenerOrNull
.is() )
254 if ( pTranslator
->getDelegator() == _rxConcreteListenerOrNull
)
256 impl_switchBindingListening_throw( false, xEventSourceTranslator
);
257 m_aPropertyListeners
.removeInterface( xEventSourceTranslator
);
263 impl_switchBindingListening_throw( false, xEventSourceTranslator
);
269 if ( _rxConcreteListenerOrNull
.is() )
271 Reference
< XPropertyChangeListener
> xEventSourceTranslator( new PropertyEventTranslation( _rxConcreteListenerOrNull
, m_xBindableControl
) );
272 m_aPropertyListeners
.addInterface( xEventSourceTranslator
);
273 impl_switchBindingListening_throw( true, xEventSourceTranslator
);
277 ::comphelper::OInterfaceIteratorHelper3
aListenerIterator(m_aPropertyListeners
);
278 while ( aListenerIterator
.hasMoreElements() )
279 impl_switchBindingListening_throw( true, aListenerIterator
.next() );
285 void EFormsHelper::revokeBindingListener( const Reference
< XPropertyChangeListener
>& _rxBindingListener
)
287 impl_toggleBindingPropertyListening_throw( false, _rxBindingListener
);
291 void EFormsHelper::getFormModelNames( std::vector
< OUString
>& /* [out] */ _rModelNames
) const
293 if ( !m_xDocument
.is() )
298 _rModelNames
.resize( 0 );
300 Reference
< XNameContainer
> xForms( m_xDocument
->getXForms() );
301 OSL_ENSURE( xForms
.is(), "EFormsHelper::getFormModelNames: invalid forms container!" );
304 const Sequence
< OUString
> aModelNames
= xForms
->getElementNames();
305 _rModelNames
.resize( aModelNames
.getLength() );
306 std::copy( aModelNames
.begin(), aModelNames
.end(), _rModelNames
.begin() );
309 catch( const Exception
& )
311 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::getFormModelNames" );
316 void EFormsHelper::getBindingNames( const OUString
& _rModelName
, std::vector
< OUString
>& /* [out] */ _rBindingNames
) const
318 _rBindingNames
.resize( 0 );
321 Reference
< xforms::XModel
> xModel( getFormModelByName( _rModelName
) );
324 Reference
< XNameAccess
> xBindings( xModel
->getBindings(), UNO_QUERY
);
325 OSL_ENSURE( xBindings
.is(), "EFormsHelper::getBindingNames: invalid bindings container obtained from the model!" );
326 if ( xBindings
.is() )
328 const Sequence
< OUString
> aNames
= xBindings
->getElementNames();
329 _rBindingNames
.resize( aNames
.getLength() );
330 std::copy( aNames
.begin(), aNames
.end(), _rBindingNames
.begin() );
334 catch( const Exception
& )
336 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::getBindingNames" );
341 Reference
< xforms::XModel
> EFormsHelper::getFormModelByName( const OUString
& _rModelName
) const
343 Reference
< xforms::XModel
> xReturn
;
346 Reference
< XNameContainer
> xForms( m_xDocument
->getXForms() );
347 OSL_ENSURE( xForms
.is(), "EFormsHelper::getFormModelByName: invalid forms container!" );
349 OSL_VERIFY( xForms
->getByName( _rModelName
) >>= xReturn
);
351 catch( const Exception
& )
353 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::getFormModelByName" );
359 Reference
< xforms::XModel
> EFormsHelper::getCurrentFormModel() const
361 Reference
< xforms::XModel
> xModel
;
364 Reference
< XPropertySet
> xBinding( getCurrentBinding() );
367 OSL_VERIFY( xBinding
->getPropertyValue( PROPERTY_MODEL
) >>= xModel
);
370 catch( const Exception
& )
372 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::getCurrentFormModel" );
377 OUString
EFormsHelper::getCurrentFormModelName() const
382 Reference
< xforms::XModel
> xFormsModel( getCurrentFormModel() );
383 if ( xFormsModel
.is() )
384 sModelName
= xFormsModel
->getID();
386 catch( const Exception
& )
388 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::getCurrentFormModel" );
393 Reference
< XPropertySet
> EFormsHelper::getCurrentBinding() const
395 Reference
< XPropertySet
> xBinding
;
399 if ( m_xBindableControl
.is() )
400 xBinding
.set(m_xBindableControl
->getValueBinding(), css::uno::UNO_QUERY
);
402 catch( const Exception
& )
404 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::getCurrentBinding" );
410 OUString
EFormsHelper::getCurrentBindingName() const
412 OUString sBindingName
;
415 Reference
< XPropertySet
> xBinding( getCurrentBinding() );
417 xBinding
->getPropertyValue( PROPERTY_BINDING_ID
) >>= sBindingName
;
419 catch( const Exception
& )
421 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::getCurrentBindingName" );
427 Reference
< XListEntrySource
> EFormsHelper::getCurrentListSourceBinding() const
431 Reference
< XListEntrySink
> xAsSink( m_xControlModel
, UNO_QUERY
);
432 OSL_ENSURE( xAsSink
.is(), "EFormsHelper::getCurrentListSourceBinding: you should have used isListEntrySink before!" );
434 return xAsSink
->getListEntrySource();
436 catch( const Exception
& )
438 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::getCurrentListSourceBinding" );
440 return Reference
<XListEntrySource
>();
444 void EFormsHelper::setListSourceBinding( const Reference
< XListEntrySource
>& _rxListSource
)
448 Reference
< XListEntrySink
> xAsSink( m_xControlModel
, UNO_QUERY
);
449 OSL_ENSURE( xAsSink
.is(), "EFormsHelper::setListSourceBinding: you should have used isListEntrySink before!" );
451 xAsSink
->setListEntrySource( _rxListSource
);
453 catch( const Exception
& )
455 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::setListSourceBinding" );
459 void EFormsHelper::setBinding( const Reference
< css::beans::XPropertySet
>& _rxBinding
)
461 if ( !m_xBindableControl
.is() )
466 Reference
< XPropertySet
> xOldBinding( m_xBindableControl
->getValueBinding(), UNO_QUERY
);
468 Reference
< XValueBinding
> xBinding( _rxBinding
, UNO_QUERY
);
469 OSL_ENSURE( xBinding
.is() || !_rxBinding
.is(), "EFormsHelper::setBinding: invalid binding!" );
471 impl_toggleBindingPropertyListening_throw( false, nullptr );
472 m_xBindableControl
->setValueBinding( xBinding
);
473 impl_toggleBindingPropertyListening_throw( true, nullptr );
475 std::set
< OUString
> aSet
;
476 firePropertyChanges( xOldBinding
, _rxBinding
, aSet
);
478 catch( const Exception
& )
480 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::setBinding" );
485 Reference
< XPropertySet
> EFormsHelper::getOrCreateBindingForModel( const OUString
& _rTargetModel
, const OUString
& _rBindingName
) const
487 OSL_ENSURE( !_rBindingName
.isEmpty(), "EFormsHelper::getOrCreateBindingForModel: invalid binding name!" );
488 return implGetOrCreateBinding( _rTargetModel
, _rBindingName
);
492 Reference
< XPropertySet
> EFormsHelper::implGetOrCreateBinding( const OUString
& _rTargetModel
, const OUString
& _rBindingName
) const
494 OSL_ENSURE( !( _rTargetModel
.isEmpty() && !_rBindingName
.isEmpty() ), "EFormsHelper::implGetOrCreateBinding: no model, but a binding name?" );
496 Reference
< XPropertySet
> xBinding
;
499 OUString
sTargetModel( _rTargetModel
);
500 // determine the model which the binding should belong to
501 if ( sTargetModel
.isEmpty() )
503 std::vector
< OUString
> aModelNames
;
504 getFormModelNames( aModelNames
);
505 if ( !aModelNames
.empty() )
506 sTargetModel
= *aModelNames
.begin();
507 OSL_ENSURE( !sTargetModel
.isEmpty(), "EFormsHelper::implGetOrCreateBinding: unable to obtain a default model!" );
509 Reference
< xforms::XModel
> xModel( getFormModelByName( sTargetModel
) );
510 Reference
< XNameAccess
> xBindingNames( xModel
.is() ? xModel
->getBindings() : Reference
< XSet
>(), UNO_QUERY
);
511 if ( xBindingNames
.is() )
513 // get or create the binding instance
514 if ( !_rBindingName
.isEmpty() )
516 if ( xBindingNames
->hasByName( _rBindingName
) )
517 OSL_VERIFY( xBindingNames
->getByName( _rBindingName
) >>= xBinding
);
520 xBinding
= xModel
->createBinding( );
523 xBinding
->setPropertyValue( PROPERTY_BINDING_ID
, Any( _rBindingName
) );
524 xModel
->getBindings()->insert( Any( xBinding
) );
530 xBinding
= xModel
->createBinding( );
533 // find a nice name for it
534 OUString
sBaseName(PcrRes(RID_STR_BINDING_NAME
) + " ");
536 sal_Int32 nNumber
= 1;
539 sNewName
= sBaseName
+ OUString::number( nNumber
++ );
541 while ( xBindingNames
->hasByName( sNewName
) );
542 Reference
< XNamed
> xName( xBinding
, UNO_QUERY_THROW
);
543 xName
->setName( sNewName
);
544 // and insert into the model
545 xModel
->getBindings()->insert( Any( xBinding
) );
550 catch( const Exception
& )
552 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
562 struct PropertyBagInserter
565 PropertyBag
& m_rProperties
;
568 explicit PropertyBagInserter( PropertyBag
& rProperties
) : m_rProperties( rProperties
) { }
570 void operator()( const Property
& _rProp
)
572 m_rProperties
.insert( _rProp
);
577 Reference
< XPropertySetInfo
> collectPropertiesGetInfo( const Reference
< XPropertySet
>& _rxProps
, PropertyBag
& _rBag
)
579 Reference
< XPropertySetInfo
> xInfo
;
581 xInfo
= _rxProps
->getPropertySetInfo();
584 const Sequence
< Property
> aProperties
= xInfo
->getProperties();
585 std::for_each( aProperties
.begin(), aProperties
.end(),
586 PropertyBagInserter( _rBag
)
594 OUString
EFormsHelper::getModelElementUIName( const EFormsHelper::ModelElementType _eType
, const Reference
< XPropertySet
>& _rxElement
)
599 // determine the model which the element belongs to
600 Reference
< xforms::XFormsUIHelper1
> xHelper
;
601 if ( _rxElement
.is() )
602 _rxElement
->getPropertyValue( PROPERTY_MODEL
) >>= xHelper
;
603 OSL_ENSURE( xHelper
.is(), "EFormsHelper::getModelElementUIName: invalid element or model!" );
606 OUString sElementName
= ( _eType
== Submission
) ? xHelper
->getSubmissionName( _rxElement
, true ) : xHelper
->getBindingName( _rxElement
, true );
607 Reference
< xforms::XModel
> xModel( xHelper
, UNO_QUERY_THROW
);
608 sUIName
= composeModelElementUIName( xModel
->getID(), sElementName
);
611 catch( const Exception
& )
613 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::getModelElementUIName" );
620 Reference
< XPropertySet
> EFormsHelper::getModelElementFromUIName( const EFormsHelper::ModelElementType _eType
, const OUString
& _rUIName
) const
622 const MapStringToPropertySet
& rMapUINameToElement( ( _eType
== Submission
) ? m_aSubmissionUINames
: m_aBindingUINames
);
623 MapStringToPropertySet::const_iterator pos
= rMapUINameToElement
.find( _rUIName
);
624 OSL_ENSURE( pos
!= rMapUINameToElement
.end(), "EFormsHelper::getModelElementFromUIName: didn't find it!" );
626 return ( pos
!= rMapUINameToElement
.end() ) ? pos
->second
: Reference
< XPropertySet
>();
630 void EFormsHelper::getAllElementUINames( const ModelElementType _eType
, std::vector
< OUString
>& /* [out] */ _rElementNames
, bool _bPrepentEmptyEntry
)
632 MapStringToPropertySet
& rMapUINameToElement( ( _eType
== Submission
) ? m_aSubmissionUINames
: m_aBindingUINames
);
633 rMapUINameToElement
.clear();
634 _rElementNames
.resize( 0 );
636 if ( _bPrepentEmptyEntry
)
637 rMapUINameToElement
[ OUString() ].clear();
641 // obtain the model names
642 std::vector
< OUString
> aModels
;
643 getFormModelNames( aModels
);
644 _rElementNames
.reserve( aModels
.size() * 2 ); // heuristics
646 // for every model, obtain the element
647 for (auto const& modelName
: aModels
)
649 Reference
< xforms::XModel
> xModel
= getFormModelByName(modelName
);
650 OSL_ENSURE( xModel
.is(), "EFormsHelper::getAllElementUINames: inconsistency in the models!" );
651 Reference
< xforms::XFormsUIHelper1
> xHelper( xModel
, UNO_QUERY
);
653 Reference
< XIndexAccess
> xElements
;
655 xElements
.set(( _eType
== Submission
) ? xModel
->getSubmissions() : xModel
->getBindings(), css::uno::UNO_QUERY
);
656 if ( !xElements
.is() )
659 sal_Int32 nElementCount
= xElements
->getCount();
660 for ( sal_Int32 i
= 0; i
< nElementCount
; ++i
)
662 Reference
< XPropertySet
> xElement( xElements
->getByIndex( i
), UNO_QUERY
);
663 OSL_ENSURE( xElement
.is(), "EFormsHelper::getAllElementUINames: empty element!" );
664 if ( !xElement
.is() )
666 #if OSL_DEBUG_LEVEL > 0
668 Reference
< xforms::XModel
> xElementsModel
;
669 xElement
->getPropertyValue( PROPERTY_MODEL
) >>= xElementsModel
;
670 OSL_ENSURE( xElementsModel
== xModel
, "EFormsHelper::getAllElementUINames: inconsistency in the model-element relationship!" );
671 if ( xElementsModel
!= xModel
)
672 xElement
->setPropertyValue( PROPERTY_MODEL
, Any( xModel
) );
675 OUString sElementName
= ( _eType
== Submission
) ? xHelper
->getSubmissionName( xElement
, true ) : xHelper
->getBindingName( xElement
, true );
676 OUString sUIName
= composeModelElementUIName( modelName
, sElementName
);
678 OSL_ENSURE( rMapUINameToElement
.find( sUIName
) == rMapUINameToElement
.end(), "EFormsHelper::getAllElementUINames: duplicate name!" );
679 rMapUINameToElement
.emplace( sUIName
, xElement
);
683 catch( const Exception
& )
685 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::getAllElementUINames" );
688 _rElementNames
.resize( rMapUINameToElement
.size() );
689 std::transform( rMapUINameToElement
.begin(), rMapUINameToElement
.end(), _rElementNames
.begin(),
690 ::o3tl::select1st
< MapStringToPropertySet::value_type
>() );
694 void EFormsHelper::firePropertyChange( const OUString
& _rName
, const Any
& _rOldValue
, const Any
& _rNewValue
) const
696 if ( m_aPropertyListeners
.getLength() == 0 )
699 if ( _rOldValue
== _rNewValue
)
704 PropertyChangeEvent aEvent
;
706 aEvent
.Source
= m_xBindableControl
.get();
707 aEvent
.PropertyName
= _rName
;
708 aEvent
.OldValue
= _rOldValue
;
709 aEvent
.NewValue
= _rNewValue
;
711 const_cast< EFormsHelper
* >( this )->m_aPropertyListeners
.notifyEach( &XPropertyChangeListener::propertyChange
, aEvent
);
713 catch( const Exception
& )
715 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::firePropertyChange" );
720 void EFormsHelper::firePropertyChanges( const Reference
< XPropertySet
>& _rxOldProps
, const Reference
< XPropertySet
>& _rxNewProps
, std::set
< OUString
>& _rFilter
) const
722 if ( m_aPropertyListeners
.getLength() == 0 )
727 PropertyBag aProperties
;
728 Reference
< XPropertySetInfo
> xOldInfo
= collectPropertiesGetInfo( _rxOldProps
, aProperties
);
729 Reference
< XPropertySetInfo
> xNewInfo
= collectPropertiesGetInfo( _rxNewProps
, aProperties
);
731 for (auto const& property
: aProperties
)
733 if ( _rFilter
.find( property
.Name
) != _rFilter
.end() )
736 Any
aOldValue( nullptr, property
.Type
);
737 if ( xOldInfo
.is() && xOldInfo
->hasPropertyByName( property
.Name
) )
738 aOldValue
= _rxOldProps
->getPropertyValue( property
.Name
);
740 Any
aNewValue( nullptr, property
.Type
);
741 if ( xNewInfo
.is() && xNewInfo
->hasPropertyByName( property
.Name
) )
742 aNewValue
= _rxNewProps
->getPropertyValue( property
.Name
);
744 firePropertyChange( property
.Name
, aOldValue
, aNewValue
);
747 catch( const Exception
& )
749 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "EFormsHelper::firePropertyChanges" );
757 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */