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 .
21 #include "eformshelper.hxx"
22 #include "formstrings.hxx"
23 #include <strings.hrc>
24 #include "modulepcr.hxx"
25 #include "propeventtranslation.hxx"
26 #include "formbrowsertools.hxx"
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/form/FormComponentType.hpp>
30 #include <com/sun/star/xforms/XFormsUIHelper1.hpp>
31 #include <com/sun/star/xsd/DataTypeClass.hpp>
32 #include <com/sun/star/form/binding/XListEntrySink.hpp>
33 #include <tools/diagnose_ex.h>
34 #include <rtl/ustrbuf.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( const OUString
& _rModelName
, const OUString
& _rElementName
)
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 OSL_FAIL( "EFormsHelper::isEForm: caught an exception!" );
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 OSL_FAIL( "EFormsHelper::canBindToDataType: caught an exception!" );
196 bool EFormsHelper::isListEntrySink() const
201 Reference
< XListEntrySink
> xAsSink( m_xControlModel
, UNO_QUERY
);
204 catch( const Exception
& )
206 OSL_FAIL( "EFormsHelper::isListEntrySink: caught an exception!" );
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 std::unique_ptr
< ::comphelper::OInterfaceIteratorHelper2
> pListenerIterator
= m_aPropertyListeners
.createIterator();
244 while ( pListenerIterator
->hasMoreElements() )
246 PropertyEventTranslation
* pTranslator
= dynamic_cast< PropertyEventTranslation
* >( pListenerIterator
->next() );
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
.removeListener( xEventSourceTranslator
);
263 impl_switchBindingListening_throw( false, xEventSourceTranslator
);
269 if ( _rxConcreteListenerOrNull
.is() )
271 Reference
< XPropertyChangeListener
> xEventSourceTranslator( new PropertyEventTranslation( _rxConcreteListenerOrNull
, m_xBindableControl
) );
272 m_aPropertyListeners
.addListener( xEventSourceTranslator
);
273 impl_switchBindingListening_throw( true, xEventSourceTranslator
);
277 std::unique_ptr
< ::comphelper::OInterfaceIteratorHelper2
> pListenerIterator
= m_aPropertyListeners
.createIterator();
278 while ( pListenerIterator
->hasMoreElements() )
280 Reference
< XPropertyChangeListener
> xListener( pListenerIterator
->next(), UNO_QUERY
);
281 impl_switchBindingListening_throw( true, xListener
);
288 void EFormsHelper::revokeBindingListener( const Reference
< XPropertyChangeListener
>& _rxBindingListener
)
290 impl_toggleBindingPropertyListening_throw( false, _rxBindingListener
);
294 void EFormsHelper::getFormModelNames( std::vector
< OUString
>& /* [out] */ _rModelNames
) const
296 if ( m_xDocument
.is() )
300 _rModelNames
.resize( 0 );
302 Reference
< XNameContainer
> xForms( m_xDocument
->getXForms() );
303 OSL_ENSURE( xForms
.is(), "EFormsHelper::getFormModelNames: invalid forms container!" );
306 Sequence
< OUString
> aModelNames
= xForms
->getElementNames();
307 _rModelNames
.resize( aModelNames
.getLength() );
308 std::copy( aModelNames
.begin(), aModelNames
.end(), _rModelNames
.begin() );
311 catch( const Exception
& )
313 OSL_FAIL( "EFormsHelper::getFormModelNames: caught an exception!" );
319 void EFormsHelper::getBindingNames( const OUString
& _rModelName
, std::vector
< OUString
>& /* [out] */ _rBindingNames
) const
321 _rBindingNames
.resize( 0 );
324 Reference
< xforms::XModel
> xModel( getFormModelByName( _rModelName
) );
327 Reference
< XNameAccess
> xBindings( xModel
->getBindings(), UNO_QUERY
);
328 OSL_ENSURE( xBindings
.is(), "EFormsHelper::getBindingNames: invalid bindings container obtained from the model!" );
329 if ( xBindings
.is() )
331 Sequence
< OUString
> aNames
= xBindings
->getElementNames();
332 _rBindingNames
.resize( aNames
.getLength() );
333 std::copy( aNames
.begin(), aNames
.end(), _rBindingNames
.begin() );
337 catch( const Exception
& )
339 OSL_FAIL( "EFormsHelper::getBindingNames: caught an exception!" );
344 Reference
< xforms::XModel
> EFormsHelper::getFormModelByName( const OUString
& _rModelName
) const
346 Reference
< xforms::XModel
> xReturn
;
349 Reference
< XNameContainer
> xForms( m_xDocument
->getXForms() );
350 OSL_ENSURE( xForms
.is(), "EFormsHelper::getFormModelByName: invalid forms container!" );
352 OSL_VERIFY( xForms
->getByName( _rModelName
) >>= xReturn
);
354 catch( const Exception
& )
356 OSL_FAIL( "EFormsHelper::getFormModelByName: caught an exception!" );
362 Reference
< xforms::XModel
> EFormsHelper::getCurrentFormModel() const
364 Reference
< xforms::XModel
> xModel
;
367 Reference
< XPropertySet
> xBinding( getCurrentBinding() );
370 OSL_VERIFY( xBinding
->getPropertyValue( PROPERTY_MODEL
) >>= xModel
);
373 catch( const Exception
& )
375 OSL_FAIL( "EFormsHelper::getCurrentFormModel: caught an exception!" );
381 OUString
EFormsHelper::getCurrentFormModelName() const
386 Reference
< xforms::XModel
> xFormsModel( getCurrentFormModel() );
387 if ( xFormsModel
.is() )
388 sModelName
= xFormsModel
->getID();
390 catch( const Exception
& )
392 OSL_FAIL( "EFormsHelper::getCurrentFormModel: caught an exception!" );
398 Reference
< XPropertySet
> EFormsHelper::getCurrentBinding() const
400 Reference
< XPropertySet
> xBinding
;
404 if ( m_xBindableControl
.is() )
405 xBinding
.set(m_xBindableControl
->getValueBinding(), css::uno::UNO_QUERY
);
407 catch( const Exception
& )
409 OSL_FAIL( "EFormsHelper::getCurrentBinding: caught an exception!" );
416 OUString
EFormsHelper::getCurrentBindingName() const
418 OUString sBindingName
;
421 Reference
< XPropertySet
> xBinding( getCurrentBinding() );
423 xBinding
->getPropertyValue( PROPERTY_BINDING_ID
) >>= sBindingName
;
425 catch( const Exception
& )
427 OSL_FAIL( "EFormsHelper::getCurrentBindingName: caught an exception!" );
433 Reference
< XListEntrySource
> EFormsHelper::getCurrentListSourceBinding() const
435 Reference
< XListEntrySource
> xReturn
;
438 Reference
< XListEntrySink
> xAsSink( m_xControlModel
, UNO_QUERY
);
439 OSL_ENSURE( xAsSink
.is(), "EFormsHelper::getCurrentListSourceBinding: you should have used isListEntrySink before!" );
441 xReturn
= xAsSink
->getListEntrySource();
443 catch( const Exception
& )
445 OSL_FAIL( "EFormsHelper::getCurrentListSourceBinding: caught an exception!" );
451 void EFormsHelper::setListSourceBinding( const Reference
< XListEntrySource
>& _rxListSource
)
455 Reference
< XListEntrySink
> xAsSink( m_xControlModel
, UNO_QUERY
);
456 OSL_ENSURE( xAsSink
.is(), "EFormsHelper::setListSourceBinding: you should have used isListEntrySink before!" );
458 xAsSink
->setListEntrySource( _rxListSource
);
460 catch( const Exception
& )
462 OSL_FAIL( "EFormsHelper::setListSourceBinding: caught an exception!" );
467 void EFormsHelper::setBinding( const Reference
< css::beans::XPropertySet
>& _rxBinding
)
469 if ( !m_xBindableControl
.is() )
474 Reference
< XPropertySet
> xOldBinding( m_xBindableControl
->getValueBinding(), UNO_QUERY
);
476 Reference
< XValueBinding
> xBinding( _rxBinding
, UNO_QUERY
);
477 OSL_ENSURE( xBinding
.is() || !_rxBinding
.is(), "EFormsHelper::setBinding: invalid binding!" );
479 impl_toggleBindingPropertyListening_throw( false, nullptr );
480 m_xBindableControl
->setValueBinding( xBinding
);
481 impl_toggleBindingPropertyListening_throw( true, nullptr );
483 std::set
< OUString
> aSet
;
484 firePropertyChanges( xOldBinding
, _rxBinding
, aSet
);
486 catch( const Exception
& )
488 OSL_FAIL( "EFormsHelper::setBinding: caught an exception!" );
493 Reference
< XPropertySet
> EFormsHelper::getOrCreateBindingForModel( const OUString
& _rTargetModel
, const OUString
& _rBindingName
) const
495 OSL_ENSURE( !_rBindingName
.isEmpty(), "EFormsHelper::getOrCreateBindingForModel: invalid binding name!" );
496 return implGetOrCreateBinding( _rTargetModel
, _rBindingName
);
500 Reference
< XPropertySet
> EFormsHelper::implGetOrCreateBinding( const OUString
& _rTargetModel
, const OUString
& _rBindingName
) const
502 OSL_ENSURE( !( _rTargetModel
.isEmpty() && !_rBindingName
.isEmpty() ), "EFormsHelper::implGetOrCreateBinding: no model, but a binding name?" );
504 Reference
< XPropertySet
> xBinding
;
507 OUString
sTargetModel( _rTargetModel
);
508 // determine the model which the binding should belong to
509 if ( sTargetModel
.isEmpty() )
511 std::vector
< OUString
> aModelNames
;
512 getFormModelNames( aModelNames
);
513 if ( !aModelNames
.empty() )
514 sTargetModel
= *aModelNames
.begin();
515 OSL_ENSURE( !sTargetModel
.isEmpty(), "EFormsHelper::implGetOrCreateBinding: unable to obtain a default model!" );
517 Reference
< xforms::XModel
> xModel( getFormModelByName( sTargetModel
) );
518 Reference
< XNameAccess
> xBindingNames( xModel
.is() ? xModel
->getBindings() : Reference
< XSet
>(), UNO_QUERY
);
519 if ( xBindingNames
.is() )
521 // get or create the binding instance
522 if ( !_rBindingName
.isEmpty() )
524 if ( xBindingNames
->hasByName( _rBindingName
) )
525 OSL_VERIFY( xBindingNames
->getByName( _rBindingName
) >>= xBinding
);
528 xBinding
= xModel
->createBinding( );
531 xBinding
->setPropertyValue( PROPERTY_BINDING_ID
, makeAny( _rBindingName
) );
532 xModel
->getBindings()->insert( makeAny( xBinding
) );
538 xBinding
= xModel
->createBinding( );
541 // find a nice name for it
542 OUString
sBaseName(PcrRes(RID_STR_BINDING_NAME
));
545 sal_Int32 nNumber
= 1;
548 sNewName
= sBaseName
+ OUString::number( nNumber
++ );
550 while ( xBindingNames
->hasByName( sNewName
) );
551 Reference
< XNamed
> xName( xBinding
, UNO_QUERY_THROW
);
552 xName
->setName( sNewName
);
553 // and insert into the model
554 xModel
->getBindings()->insert( makeAny( xBinding
) );
559 catch( const Exception
& )
561 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
571 struct PropertyBagInserter
574 PropertyBag
& m_rProperties
;
577 explicit PropertyBagInserter( PropertyBag
& rProperties
) : m_rProperties( rProperties
) { }
579 void operator()( const Property
& _rProp
)
581 m_rProperties
.insert( _rProp
);
586 Reference
< XPropertySetInfo
> collectPropertiesGetInfo( const Reference
< XPropertySet
>& _rxProps
, PropertyBag
& _rBag
)
588 Reference
< XPropertySetInfo
> xInfo
;
590 xInfo
= _rxProps
->getPropertySetInfo();
593 Sequence
< Property
> aProperties
= xInfo
->getProperties();
594 std::for_each( aProperties
.begin(), aProperties
.end(),
595 PropertyBagInserter( _rBag
)
603 OUString
EFormsHelper::getModelElementUIName( const EFormsHelper::ModelElementType _eType
, const Reference
< XPropertySet
>& _rxElement
)
608 // determine the model which the element belongs to
609 Reference
< xforms::XFormsUIHelper1
> xHelper
;
610 if ( _rxElement
.is() )
611 _rxElement
->getPropertyValue( PROPERTY_MODEL
) >>= xHelper
;
612 OSL_ENSURE( xHelper
.is(), "EFormsHelper::getModelElementUIName: invalid element or model!" );
615 OUString sElementName
= ( _eType
== Submission
) ? xHelper
->getSubmissionName( _rxElement
, true ) : xHelper
->getBindingName( _rxElement
, true );
616 Reference
< xforms::XModel
> xModel( xHelper
, UNO_QUERY_THROW
);
617 sUIName
= composeModelElementUIName( xModel
->getID(), sElementName
);
620 catch( const Exception
& )
622 OSL_FAIL( "EFormsHelper::getModelElementUIName: caught an exception!" );
629 Reference
< XPropertySet
> EFormsHelper::getModelElementFromUIName( const EFormsHelper::ModelElementType _eType
, const OUString
& _rUIName
) const
631 const MapStringToPropertySet
& rMapUINameToElement( ( _eType
== Submission
) ? m_aSubmissionUINames
: m_aBindingUINames
);
632 MapStringToPropertySet::const_iterator pos
= rMapUINameToElement
.find( _rUIName
);
633 OSL_ENSURE( pos
!= rMapUINameToElement
.end(), "EFormsHelper::getModelElementFromUIName: didn't find it!" );
635 return ( pos
!= rMapUINameToElement
.end() ) ? pos
->second
: Reference
< XPropertySet
>();
639 void EFormsHelper::getAllElementUINames( const ModelElementType _eType
, std::vector
< OUString
>& /* [out] */ _rElementNames
, bool _bPrepentEmptyEntry
)
641 MapStringToPropertySet
& rMapUINameToElement( ( _eType
== Submission
) ? m_aSubmissionUINames
: m_aBindingUINames
);
642 rMapUINameToElement
.clear();
643 _rElementNames
.resize( 0 );
645 if ( _bPrepentEmptyEntry
)
646 rMapUINameToElement
[ OUString() ].clear();
650 // obtain the model names
651 std::vector
< OUString
> aModels
;
652 getFormModelNames( aModels
);
653 _rElementNames
.reserve( aModels
.size() * 2 ); // heuristics
655 // for every model, obtain the element
656 for (auto const& modelName
: aModels
)
658 Reference
< xforms::XModel
> xModel
= getFormModelByName(modelName
);
659 OSL_ENSURE( xModel
.is(), "EFormsHelper::getAllElementUINames: inconsistency in the models!" );
660 Reference
< xforms::XFormsUIHelper1
> xHelper( xModel
, UNO_QUERY
);
662 Reference
< XIndexAccess
> xElements
;
664 xElements
.set(( _eType
== Submission
) ? xModel
->getSubmissions() : xModel
->getBindings(), css::uno::UNO_QUERY
);
665 if ( !xElements
.is() )
668 sal_Int32 nElementCount
= xElements
->getCount();
669 for ( sal_Int32 i
= 0; i
< nElementCount
; ++i
)
671 Reference
< XPropertySet
> xElement( xElements
->getByIndex( i
), UNO_QUERY
);
672 OSL_ENSURE( xElement
.is(), "EFormsHelper::getAllElementUINames: empty element!" );
673 if ( !xElement
.is() )
675 #if OSL_DEBUG_LEVEL > 0
677 Reference
< xforms::XModel
> xElementsModel
;
678 xElement
->getPropertyValue( PROPERTY_MODEL
) >>= xElementsModel
;
679 OSL_ENSURE( xElementsModel
== xModel
, "EFormsHelper::getAllElementUINames: inconsistency in the model-element relationship!" );
680 if ( xElementsModel
!= xModel
)
681 xElement
->setPropertyValue( PROPERTY_MODEL
, makeAny( xModel
) );
684 OUString sElementName
= ( _eType
== Submission
) ? xHelper
->getSubmissionName( xElement
, true ) : xHelper
->getBindingName( xElement
, true );
685 OUString sUIName
= composeModelElementUIName( modelName
, sElementName
);
687 OSL_ENSURE( rMapUINameToElement
.find( sUIName
) == rMapUINameToElement
.end(), "EFormsHelper::getAllElementUINames: duplicate name!" );
688 rMapUINameToElement
.emplace( sUIName
, xElement
);
692 catch( const Exception
& )
694 OSL_FAIL( "EFormsHelper::getAllElementUINames: caught an exception!" );
697 _rElementNames
.resize( rMapUINameToElement
.size() );
698 std::transform( rMapUINameToElement
.begin(), rMapUINameToElement
.end(), _rElementNames
.begin(),
699 ::o3tl::select1st
< MapStringToPropertySet::value_type
>() );
703 void EFormsHelper::firePropertyChange( const OUString
& _rName
, const Any
& _rOldValue
, const Any
& _rNewValue
) const
705 if ( m_aPropertyListeners
.empty() )
708 if ( _rOldValue
== _rNewValue
)
713 PropertyChangeEvent aEvent
;
715 aEvent
.Source
= m_xBindableControl
.get();
716 aEvent
.PropertyName
= _rName
;
717 aEvent
.OldValue
= _rOldValue
;
718 aEvent
.NewValue
= _rNewValue
;
720 const_cast< EFormsHelper
* >( this )->m_aPropertyListeners
.notify( aEvent
, &XPropertyChangeListener::propertyChange
);
722 catch( const Exception
& )
724 OSL_FAIL( "EFormsHelper::firePropertyChange: caught an exception!" );
729 void EFormsHelper::firePropertyChanges( const Reference
< XPropertySet
>& _rxOldProps
, const Reference
< XPropertySet
>& _rxNewProps
, std::set
< OUString
>& _rFilter
) const
731 if ( m_aPropertyListeners
.empty() )
736 PropertyBag aProperties
;
737 Reference
< XPropertySetInfo
> xOldInfo
= collectPropertiesGetInfo( _rxOldProps
, aProperties
);
738 Reference
< XPropertySetInfo
> xNewInfo
= collectPropertiesGetInfo( _rxNewProps
, aProperties
);
740 for (auto const& property
: aProperties
)
742 if ( _rFilter
.find( property
.Name
) != _rFilter
.end() )
745 Any
aOldValue( nullptr, property
.Type
);
746 if ( xOldInfo
.is() && xOldInfo
->hasPropertyByName( property
.Name
) )
747 aOldValue
= _rxOldProps
->getPropertyValue( property
.Name
);
749 Any
aNewValue( nullptr, property
.Type
);
750 if ( xNewInfo
.is() && xNewInfo
->hasPropertyByName( property
.Name
) )
751 aNewValue
= _rxNewProps
->getPropertyValue( property
.Name
);
753 firePropertyChange( property
.Name
, aOldValue
, aNewValue
);
756 catch( const Exception
& )
758 OSL_FAIL( "EFormsHelper::firePropertyChanges: caught an exception!" );
766 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */