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 "eformshelper.hxx"
21 #include "formstrings.hxx"
22 #include "formresid.hrc"
23 #include "modulepcr.hxx"
24 #include "propeventtranslation.hxx"
25 #include "formbrowsertools.hxx"
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/form/FormComponentType.hpp>
29 #include <com/sun/star/xforms/XFormsUIHelper1.hpp>
30 #include <com/sun/star/xsd/DataTypeClass.hpp>
31 #include <com/sun/star/form/binding/XListEntrySink.hpp>
32 #include <tools/diagnose_ex.h>
33 #include <rtl/ustrbuf.hxx>
37 #include <o3tl/compat_functional.hxx>
44 using namespace ::com::sun::star
;
45 using namespace ::com::sun::star::uno
;
46 using namespace ::com::sun::star::beans
;
47 using namespace ::com::sun::star::container
;
48 using namespace ::com::sun::star::form::binding
;
49 using namespace ::com::sun::star::xsd
;
50 using namespace ::com::sun::star::lang
;
51 using namespace ::com::sun::star::form
;
54 //= file-local helpers
59 OUString
composeModelElementUIName( const OUString
& _rModelName
, const OUString
& _rElementName
)
61 OUStringBuffer aBuffer
;
62 aBuffer
.appendAscii( "[" );
63 aBuffer
.append( _rModelName
);
64 aBuffer
.appendAscii( "] " );
65 aBuffer
.append( _rElementName
);
66 return aBuffer
.makeStringAndClear();
74 EFormsHelper::EFormsHelper( ::osl::Mutex
& _rMutex
, const Reference
< XPropertySet
>& _rxControlModel
, const Reference
< frame::XModel
>& _rxContextDocument
)
75 :m_xControlModel( _rxControlModel
)
76 ,m_aPropertyListeners( _rMutex
)
78 OSL_ENSURE( _rxControlModel
.is(), "EFormsHelper::EFormsHelper: invalid control model!" );
79 m_xBindableControl
.set(_rxControlModel
, css::uno::UNO_QUERY
);
81 m_xDocument
.set(_rxContextDocument
, css::uno::UNO_QUERY
);
82 OSL_ENSURE( m_xDocument
.is(), "EFormsHelper::EFormsHelper: invalid document!" );
87 bool EFormsHelper::isEForm( const Reference
< frame::XModel
>& _rxContextDocument
)
91 Reference
< xforms::XFormsSupplier
> xDocument( _rxContextDocument
, UNO_QUERY
);
92 if ( !xDocument
.is() )
95 return xDocument
->getXForms().is();
97 catch( const Exception
& )
99 OSL_FAIL( "EFormsHelper::isEForm: caught an exception!" );
105 bool EFormsHelper::canBindToDataType( sal_Int32 _nDataType
) const
107 if ( !m_xBindableControl
.is() )
108 // cannot bind at all
111 // some types cannot be bound, independent from the control type
112 if ( ( DataTypeClass::hexBinary
== _nDataType
)
113 || ( DataTypeClass::base64Binary
== _nDataType
)
114 || ( DataTypeClass::QName
== _nDataType
)
115 || ( DataTypeClass::NOTATION
== _nDataType
)
122 // classify the control model
123 sal_Int16 nControlType
= FormComponentType::CONTROL
;
124 OSL_VERIFY( m_xControlModel
->getPropertyValue( PROPERTY_CLASSID
) >>= nControlType
);
127 sal_Int16 nNumericCompatibleTypes
[] = { DataTypeClass::DECIMAL
, DataTypeClass::FLOAT
, DataTypeClass::DOUBLE
, 0 };
128 sal_Int16 nDateCompatibleTypes
[] = { DataTypeClass::DATE
, 0 };
129 sal_Int16 nTimeCompatibleTypes
[] = { DataTypeClass::TIME
, 0 };
130 sal_Int16 nCheckboxCompatibleTypes
[] = { DataTypeClass::BOOLEAN
, DataTypeClass::STRING
, DataTypeClass::anyURI
, 0 };
131 sal_Int16 nRadiobuttonCompatibleTypes
[] = { DataTypeClass::STRING
, DataTypeClass::anyURI
, 0 };
132 sal_Int16 nFormattedCompatibleTypes
[] = { DataTypeClass::DECIMAL
, DataTypeClass::FLOAT
, DataTypeClass::DOUBLE
, DataTypeClass::DATETIME
, DataTypeClass::DATE
, DataTypeClass::TIME
, 0 };
134 sal_Int16
* pCompatibleTypes
= NULL
;
135 switch ( nControlType
)
137 case FormComponentType::SPINBUTTON
:
138 case FormComponentType::NUMERICFIELD
:
139 pCompatibleTypes
= nNumericCompatibleTypes
;
141 case FormComponentType::DATEFIELD
:
142 pCompatibleTypes
= nDateCompatibleTypes
;
144 case FormComponentType::TIMEFIELD
:
145 pCompatibleTypes
= nTimeCompatibleTypes
;
147 case FormComponentType::CHECKBOX
:
148 pCompatibleTypes
= nCheckboxCompatibleTypes
;
150 case FormComponentType::RADIOBUTTON
:
151 pCompatibleTypes
= nRadiobuttonCompatibleTypes
;
154 case FormComponentType::TEXTFIELD
:
156 // both the normal text field, and the formatted field, claim to be a TEXTFIELD
157 // need to distinguish by service name
158 Reference
< XServiceInfo
> xSI( m_xControlModel
, UNO_QUERY
);
159 OSL_ENSURE( xSI
.is(), "EFormsHelper::canBindToDataType: a control model which has no service info?" );
162 if ( xSI
->supportsService( SERVICE_COMPONENT_FORMATTEDFIELD
) )
164 pCompatibleTypes
= nFormattedCompatibleTypes
;
170 case FormComponentType::LISTBOX
:
171 case FormComponentType::COMBOBOX
:
172 // edit fields and list/combo boxes can be bound to anything
176 if ( !bCan
&& pCompatibleTypes
)
178 if ( _nDataType
== -1 )
180 // the control can be bound to at least one type, and exactly this is being asked for
185 while ( *pCompatibleTypes
&& !bCan
)
186 bCan
= ( *pCompatibleTypes
++ == _nDataType
);
190 catch( const Exception
& )
192 OSL_FAIL( "EFormsHelper::canBindToDataType: caught an exception!" );
199 bool EFormsHelper::isListEntrySink() const
204 Reference
< XListEntrySink
> xAsSink( m_xControlModel
, UNO_QUERY
);
207 catch( const Exception
& )
209 OSL_FAIL( "EFormsHelper::isListEntrySink: caught an exception!" );
215 void EFormsHelper::impl_switchBindingListening_throw( bool _bDoListening
, const Reference
< XPropertyChangeListener
>& _rxListener
)
217 Reference
< XPropertySet
> xBindingProps
;
218 if ( m_xBindableControl
.is() )
219 xBindingProps
.set(m_xBindableControl
->getValueBinding(), css::uno::UNO_QUERY
);
220 if ( !xBindingProps
.is() )
225 xBindingProps
->addPropertyChangeListener( OUString(), _rxListener
);
229 xBindingProps
->removePropertyChangeListener( OUString(), _rxListener
);
234 void EFormsHelper::registerBindingListener( const Reference
< XPropertyChangeListener
>& _rxBindingListener
)
236 if ( !_rxBindingListener
.is() )
238 impl_toggleBindingPropertyListening_throw( true, _rxBindingListener
);
242 void EFormsHelper::impl_toggleBindingPropertyListening_throw( bool _bDoListen
, const Reference
< XPropertyChangeListener
>& _rxConcreteListenerOrNull
)
246 ::std::unique_ptr
< ::cppu::OInterfaceIteratorHelper
> pListenerIterator
= m_aPropertyListeners
.createIterator();
247 while ( pListenerIterator
->hasMoreElements() )
249 PropertyEventTranslation
* pTranslator
= dynamic_cast< PropertyEventTranslation
* >( pListenerIterator
->next() );
250 OSL_ENSURE( pTranslator
, "EFormsHelper::impl_toggleBindingPropertyListening_throw: invalid listener element in my container!" );
254 Reference
< XPropertyChangeListener
> xEventSourceTranslator( pTranslator
);
255 if ( _rxConcreteListenerOrNull
.is() )
257 if ( pTranslator
->getDelegator() == _rxConcreteListenerOrNull
)
259 impl_switchBindingListening_throw( false, xEventSourceTranslator
);
260 m_aPropertyListeners
.removeListener( xEventSourceTranslator
);
266 impl_switchBindingListening_throw( false, xEventSourceTranslator
);
272 if ( _rxConcreteListenerOrNull
.is() )
274 Reference
< XPropertyChangeListener
> xEventSourceTranslator( new PropertyEventTranslation( _rxConcreteListenerOrNull
, m_xBindableControl
) );
275 m_aPropertyListeners
.addListener( xEventSourceTranslator
);
276 impl_switchBindingListening_throw( true, xEventSourceTranslator
);
280 ::std::unique_ptr
< ::cppu::OInterfaceIteratorHelper
> pListenerIterator
= m_aPropertyListeners
.createIterator();
281 while ( pListenerIterator
->hasMoreElements() )
283 Reference
< XPropertyChangeListener
> xListener( pListenerIterator
->next(), UNO_QUERY
);
284 impl_switchBindingListening_throw( true, xListener
);
291 void EFormsHelper::revokeBindingListener( const Reference
< XPropertyChangeListener
>& _rxBindingListener
)
293 impl_toggleBindingPropertyListening_throw( false, _rxBindingListener
);
297 void EFormsHelper::getFormModelNames( ::std::vector
< OUString
>& /* [out] */ _rModelNames
) const
299 if ( m_xDocument
.is() )
303 _rModelNames
.resize( 0 );
305 Reference
< XNameContainer
> xForms( m_xDocument
->getXForms() );
306 OSL_ENSURE( xForms
.is(), "EFormsHelper::getFormModelNames: invalid forms container!" );
309 Sequence
< OUString
> aModelNames
= xForms
->getElementNames();
310 _rModelNames
.resize( aModelNames
.getLength() );
311 ::std::copy( aModelNames
.getConstArray(), aModelNames
.getConstArray() + aModelNames
.getLength(),
316 catch( const Exception
& )
318 OSL_FAIL( "EFormsHelper::getFormModelNames: caught an exception!" );
324 void EFormsHelper::getBindingNames( const OUString
& _rModelName
, ::std::vector
< OUString
>& /* [out] */ _rBindingNames
) const
326 _rBindingNames
.resize( 0 );
329 Reference
< xforms::XModel
> xModel( getFormModelByName( _rModelName
) );
332 Reference
< XNameAccess
> xBindings( xModel
->getBindings(), UNO_QUERY
);
333 OSL_ENSURE( xBindings
.is(), "EFormsHelper::getBindingNames: invalid bindings container obtained from the model!" );
334 if ( xBindings
.is() )
336 Sequence
< OUString
> aNames
= xBindings
->getElementNames();
337 _rBindingNames
.resize( aNames
.getLength() );
338 ::std::copy( aNames
.getConstArray(), aNames
.getConstArray() + aNames
.getLength(), _rBindingNames
.begin() );
342 catch( const Exception
& )
344 OSL_FAIL( "EFormsHelper::getBindingNames: caught an exception!" );
349 Reference
< xforms::XModel
> EFormsHelper::getFormModelByName( const OUString
& _rModelName
) const
351 Reference
< xforms::XModel
> xReturn
;
354 Reference
< XNameContainer
> xForms( m_xDocument
->getXForms() );
355 OSL_ENSURE( xForms
.is(), "EFormsHelper::getFormModelByName: invalid forms container!" );
357 OSL_VERIFY( xForms
->getByName( _rModelName
) >>= xReturn
);
359 catch( const Exception
& )
361 OSL_FAIL( "EFormsHelper::getFormModelByName: caught an exception!" );
367 Reference
< xforms::XModel
> EFormsHelper::getCurrentFormModel() const
369 Reference
< xforms::XModel
> xModel
;
372 Reference
< XPropertySet
> xBinding( getCurrentBinding() );
375 OSL_VERIFY( xBinding
->getPropertyValue( PROPERTY_MODEL
) >>= xModel
);
378 catch( const Exception
& )
380 OSL_FAIL( "EFormsHelper::getCurrentFormModel: caught an exception!" );
386 OUString
EFormsHelper::getCurrentFormModelName() const
391 Reference
< xforms::XModel
> xFormsModel( getCurrentFormModel() );
392 if ( xFormsModel
.is() )
393 sModelName
= xFormsModel
->getID();
395 catch( const Exception
& )
397 OSL_FAIL( "EFormsHelper::getCurrentFormModel: caught an exception!" );
403 Reference
< XPropertySet
> EFormsHelper::getCurrentBinding() const
405 Reference
< XPropertySet
> xBinding
;
409 if ( m_xBindableControl
.is() )
410 xBinding
.set(m_xBindableControl
->getValueBinding(), css::uno::UNO_QUERY
);
412 catch( const Exception
& )
414 OSL_FAIL( "EFormsHelper::getCurrentBinding: caught an exception!" );
421 OUString
EFormsHelper::getCurrentBindingName() const
423 OUString sBindingName
;
426 Reference
< XPropertySet
> xBinding( getCurrentBinding() );
428 xBinding
->getPropertyValue( PROPERTY_BINDING_ID
) >>= sBindingName
;
430 catch( const Exception
& )
432 OSL_FAIL( "EFormsHelper::getCurrentBindingName: caught an exception!" );
438 Reference
< XListEntrySource
> EFormsHelper::getCurrentListSourceBinding() const
440 Reference
< XListEntrySource
> xReturn
;
443 Reference
< XListEntrySink
> xAsSink( m_xControlModel
, UNO_QUERY
);
444 OSL_ENSURE( xAsSink
.is(), "EFormsHelper::getCurrentListSourceBinding: you should have used isListEntrySink before!" );
446 xReturn
= xAsSink
->getListEntrySource();
448 catch( const Exception
& )
450 OSL_FAIL( "EFormsHelper::getCurrentListSourceBinding: caught an exception!" );
456 void EFormsHelper::setListSourceBinding( const Reference
< XListEntrySource
>& _rxListSource
)
460 Reference
< XListEntrySink
> xAsSink( m_xControlModel
, UNO_QUERY
);
461 OSL_ENSURE( xAsSink
.is(), "EFormsHelper::setListSourceBinding: you should have used isListEntrySink before!" );
463 xAsSink
->setListEntrySource( _rxListSource
);
465 catch( const Exception
& )
467 OSL_FAIL( "EFormsHelper::setListSourceBinding: caught an exception!" );
472 void EFormsHelper::setBinding( const Reference
< ::com::sun::star::beans::XPropertySet
>& _rxBinding
)
474 if ( !m_xBindableControl
.is() )
479 Reference
< XPropertySet
> xOldBinding( m_xBindableControl
->getValueBinding(), UNO_QUERY
);
481 Reference
< XValueBinding
> xBinding( _rxBinding
, UNO_QUERY
);
482 OSL_ENSURE( xBinding
.is() || !_rxBinding
.is(), "EFormsHelper::setBinding: invalid binding!" );
484 impl_toggleBindingPropertyListening_throw( false, NULL
);
485 m_xBindableControl
->setValueBinding( xBinding
);
486 impl_toggleBindingPropertyListening_throw( true, NULL
);
488 ::std::set
< OUString
> aSet
;
489 firePropertyChanges( xOldBinding
, _rxBinding
, aSet
);
491 catch( const Exception
& )
493 OSL_FAIL( "EFormsHelper::setBinding: caught an exception!" );
498 Reference
< XPropertySet
> EFormsHelper::getOrCreateBindingForModel( const OUString
& _rTargetModel
, const OUString
& _rBindingName
) const
500 OSL_ENSURE( !_rBindingName
.isEmpty(), "EFormsHelper::getOrCreateBindingForModel: invalid binding name!" );
501 return implGetOrCreateBinding( _rTargetModel
, _rBindingName
);
505 Reference
< XPropertySet
> EFormsHelper::implGetOrCreateBinding( const OUString
& _rTargetModel
, const OUString
& _rBindingName
) const
507 OSL_ENSURE( !( _rTargetModel
.isEmpty() && !_rBindingName
.isEmpty() ), "EFormsHelper::implGetOrCreateBinding: no model, but a binding name?" );
509 Reference
< XPropertySet
> xBinding
;
512 OUString
sTargetModel( _rTargetModel
);
513 // determine the model which the binding should belong to
514 if ( sTargetModel
.isEmpty() )
516 ::std::vector
< OUString
> aModelNames
;
517 getFormModelNames( aModelNames
);
518 if ( !aModelNames
.empty() )
519 sTargetModel
= *aModelNames
.begin();
520 OSL_ENSURE( !sTargetModel
.isEmpty(), "EFormsHelper::implGetOrCreateBinding: unable to obtain a default model!" );
522 Reference
< xforms::XModel
> xModel( getFormModelByName( sTargetModel
) );
523 Reference
< XNameAccess
> xBindingNames( xModel
.is() ? xModel
->getBindings() : Reference
< XSet
>(), UNO_QUERY
);
524 if ( xBindingNames
.is() )
526 // get or create the binding instance
527 if ( !_rBindingName
.isEmpty() )
529 if ( xBindingNames
->hasByName( _rBindingName
) )
530 OSL_VERIFY( xBindingNames
->getByName( _rBindingName
) >>= xBinding
);
533 xBinding
= xModel
->createBinding( );
536 xBinding
->setPropertyValue( PROPERTY_BINDING_ID
, makeAny( _rBindingName
) );
537 xModel
->getBindings()->insert( makeAny( xBinding
) );
543 xBinding
= xModel
->createBinding( );
546 // find a nice name for it
547 OUString
sBaseName(PcrRes(RID_STR_BINDING_UI_NAME
).toString());
550 sal_Int32 nNumber
= 1;
553 sNewName
= sBaseName
+ OUString::number( nNumber
++ );
555 while ( xBindingNames
->hasByName( sNewName
) );
556 Reference
< XNamed
> xName( xBinding
, UNO_QUERY_THROW
);
557 xName
->setName( sNewName
);
558 // and insert into the model
559 xModel
->getBindings()->insert( makeAny( xBinding
) );
564 catch( const Exception
& )
566 DBG_UNHANDLED_EXCEPTION();
576 struct PropertyBagInserter
: public ::std::unary_function
< Property
, void >
579 PropertyBag
& m_rProperties
;
582 PropertyBagInserter( PropertyBag
& rProperties
) : m_rProperties( rProperties
) { }
584 void operator()( const Property
& _rProp
)
586 m_rProperties
.insert( _rProp
);
591 Reference
< XPropertySetInfo
> collectPropertiesGetInfo( const Reference
< XPropertySet
>& _rxProps
, PropertyBag
& _rBag
)
593 Reference
< XPropertySetInfo
> xInfo
;
595 xInfo
= _rxProps
->getPropertySetInfo();
598 Sequence
< Property
> aProperties
= xInfo
->getProperties();
599 ::std::for_each( aProperties
.getConstArray(), aProperties
.getConstArray() + aProperties
.getLength(),
600 PropertyBagInserter( _rBag
)
608 OUString
EFormsHelper::getModelElementUIName( const EFormsHelper::ModelElementType _eType
, const Reference
< XPropertySet
>& _rxElement
)
613 // determine the model which the element belongs to
614 Reference
< xforms::XFormsUIHelper1
> xHelper
;
615 if ( _rxElement
.is() )
616 _rxElement
->getPropertyValue( PROPERTY_MODEL
) >>= xHelper
;
617 OSL_ENSURE( xHelper
.is(), "EFormsHelper::getModelElementUIName: invalid element or model!" );
620 OUString sElementName
= ( _eType
== Submission
) ? xHelper
->getSubmissionName( _rxElement
, sal_True
) : xHelper
->getBindingName( _rxElement
, sal_True
);
621 Reference
< xforms::XModel
> xModel( xHelper
, UNO_QUERY_THROW
);
622 sUIName
= composeModelElementUIName( xModel
->getID(), sElementName
);
625 catch( const Exception
& )
627 OSL_FAIL( "EFormsHelper::getModelElementUIName: caught an exception!" );
634 Reference
< XPropertySet
> EFormsHelper::getModelElementFromUIName( const EFormsHelper::ModelElementType _eType
, const OUString
& _rUIName
) const
636 const MapStringToPropertySet
& rMapUINameToElement( ( _eType
== Submission
) ? m_aSubmissionUINames
: m_aBindingUINames
);
637 MapStringToPropertySet::const_iterator pos
= rMapUINameToElement
.find( _rUIName
);
638 OSL_ENSURE( pos
!= rMapUINameToElement
.end(), "EFormsHelper::getModelElementFromUIName: didn't find it!" );
640 return ( pos
!= rMapUINameToElement
.end() ) ? pos
->second
: Reference
< XPropertySet
>();
644 void EFormsHelper::getAllElementUINames( const ModelElementType _eType
, ::std::vector
< OUString
>& /* [out] */ _rElementNames
, bool _bPrepentEmptyEntry
)
646 MapStringToPropertySet
& rMapUINameToElement( ( _eType
== Submission
) ? m_aSubmissionUINames
: m_aBindingUINames
);
647 rMapUINameToElement
.clear();
648 _rElementNames
.resize( 0 );
650 if ( _bPrepentEmptyEntry
)
651 rMapUINameToElement
[ OUString() ].clear();
655 // obtain the model names
656 ::std::vector
< OUString
> aModels
;
657 getFormModelNames( aModels
);
658 _rElementNames
.reserve( aModels
.size() * 2 ); // heuristics
660 // for every model, obtain the element
661 for ( ::std::vector
< OUString
>::const_iterator pModelName
= aModels
.begin();
662 pModelName
!= aModels
.end();
666 Reference
< xforms::XModel
> xModel
= getFormModelByName( *pModelName
);
667 OSL_ENSURE( xModel
.is(), "EFormsHelper::getAllElementUINames: inconsistency in the models!" );
668 Reference
< xforms::XFormsUIHelper1
> xHelper( xModel
, UNO_QUERY
);
670 Reference
< XIndexAccess
> xElements
;
672 xElements
.set(( _eType
== Submission
) ? xModel
->getSubmissions() : xModel
->getBindings(), css::uno::UNO_QUERY
);
673 if ( !xElements
.is() )
676 sal_Int32 nElementCount
= xElements
->getCount();
677 for ( sal_Int32 i
= 0; i
< nElementCount
; ++i
)
679 Reference
< XPropertySet
> xElement( xElements
->getByIndex( i
), UNO_QUERY
);
680 OSL_ENSURE( xElement
.is(), "EFormsHelper::getAllElementUINames: empty element!" );
681 if ( !xElement
.is() )
683 #if OSL_DEBUG_LEVEL > 0
685 Reference
< xforms::XModel
> xElementsModel
;
686 xElement
->getPropertyValue( PROPERTY_MODEL
) >>= xElementsModel
;
687 OSL_ENSURE( xElementsModel
== xModel
, "EFormsHelper::getAllElementUINames: inconsistency in the model-element relationship!" );
688 if ( !( xElementsModel
== xModel
) )
689 xElement
->setPropertyValue( PROPERTY_MODEL
, makeAny( xModel
) );
692 OUString sElementName
= ( _eType
== Submission
) ? xHelper
->getSubmissionName( xElement
, sal_True
) : xHelper
->getBindingName( xElement
, sal_True
);
693 OUString sUIName
= composeModelElementUIName( *pModelName
, sElementName
);
695 OSL_ENSURE( rMapUINameToElement
.find( sUIName
) == rMapUINameToElement
.end(), "EFormsHelper::getAllElementUINames: duplicate name!" );
696 rMapUINameToElement
.insert( MapStringToPropertySet::value_type( sUIName
, xElement
) );
700 catch( const Exception
& )
702 OSL_FAIL( "EFormsHelper::getAllElementUINames: caught an exception!" );
705 _rElementNames
.resize( rMapUINameToElement
.size() );
706 ::std::transform( rMapUINameToElement
.begin(), rMapUINameToElement
.end(), _rElementNames
.begin(), ::o3tl::select1st
< MapStringToPropertySet::value_type
>() );
710 void EFormsHelper::firePropertyChange( const OUString
& _rName
, const Any
& _rOldValue
, const Any
& _rNewValue
) const
712 if ( m_aPropertyListeners
.empty() )
715 if ( _rOldValue
== _rNewValue
)
720 PropertyChangeEvent aEvent
;
722 aEvent
.Source
= m_xBindableControl
.get();
723 aEvent
.PropertyName
= _rName
;
724 aEvent
.OldValue
= _rOldValue
;
725 aEvent
.NewValue
= _rNewValue
;
727 const_cast< EFormsHelper
* >( this )->m_aPropertyListeners
.notify( aEvent
, &XPropertyChangeListener::propertyChange
);
729 catch( const Exception
& )
731 OSL_FAIL( "EFormsHelper::firePropertyChange: caught an exception!" );
736 void EFormsHelper::firePropertyChanges( const Reference
< XPropertySet
>& _rxOldProps
, const Reference
< XPropertySet
>& _rxNewProps
, ::std::set
< OUString
>& _rFilter
) const
738 if ( m_aPropertyListeners
.empty() )
743 PropertyBag aProperties
;
744 Reference
< XPropertySetInfo
> xOldInfo
= collectPropertiesGetInfo( _rxOldProps
, aProperties
);
745 Reference
< XPropertySetInfo
> xNewInfo
= collectPropertiesGetInfo( _rxNewProps
, aProperties
);
747 for ( PropertyBag::const_iterator aProp
= aProperties
.begin();
748 aProp
!= aProperties
.end();
752 if ( _rFilter
.find( aProp
->Name
) != _rFilter
.end() )
755 Any
aOldValue( NULL
, aProp
->Type
);
756 if ( xOldInfo
.is() && xOldInfo
->hasPropertyByName( aProp
->Name
) )
757 aOldValue
= _rxOldProps
->getPropertyValue( aProp
->Name
);
759 Any
aNewValue( NULL
, aProp
->Type
);
760 if ( xNewInfo
.is() && xNewInfo
->hasPropertyByName( aProp
->Name
) )
761 aNewValue
= _rxNewProps
->getPropertyValue( aProp
->Name
);
763 firePropertyChange( aProp
->Name
, aOldValue
, aNewValue
);
766 catch( const Exception
& )
768 OSL_FAIL( "EFormsHelper::firePropertyChanges: caught an exception!" );
776 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */