27#include <com/sun/star/lang/NullPointerException.hpp>
28#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
29#include <com/sun/star/inspection/PropertyControlType.hpp>
30#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
47 using namespace ::com::sun::star::form::binding;
56 ,m_bSimulatingModelChange( false )
68 return "com.sun.star.comp.extensions.EFormsPropertyHandler";
74 return {
"com.sun.star.form.inspection.XMLFormsPropertyHandler" };
80 OUString sModelName =
m_pHelper->getCurrentFormModelName();
81 if ( sModelName.isEmpty() )
89 ::osl::MutexGuard aGuard(
m_aMutex );
94 "EFormsPropertyHandler::getPropertyValue: we don't have any SupportedProperties!");
103 aReturn <<=
m_pHelper->getCurrentListSourceBinding();
111 aReturn <<=
m_pHelper->getCurrentBindingName();
121 Reference< XPropertySet > xBindingProps(
m_pHelper->getCurrentBinding() );
122 if ( xBindingProps.is() )
124 aReturn = xBindingProps->getPropertyValue( _rPropertyName );
126 "EFormsPropertyHandler::getPropertyValue: invalid BindingExpression value type!" );
129 aReturn <<= OUString();
134 OSL_FAIL(
"EFormsPropertyHandler::getPropertyValue: cannot handle this property!" );
140 TOOLS_WARN_EXCEPTION(
"extensions.propctrlr",
"EFormsPropertyHandler::getPropertyValue: caught exception!"
141 "(have been asked for the \"" <<_rPropertyName <<
"\" property.)");
149 ::osl::MutexGuard aGuard(
m_aMutex );
154 "EFormsPropertyHandler::setPropertyValue: we don't have any SupportedProperties!");
165 Reference< XListEntrySource > xSource;
166 OSL_VERIFY( _rValue >>= xSource );
167 m_pHelper->setListSourceBinding( xSource );
178 OUString sOldBindingName =
m_pHelper->getCurrentBindingName();
181 Any( sOldBindingName ),
Any( OUString() ) );
188 OUString sNewBindingName;
189 OSL_VERIFY( _rValue >>= sNewBindingName );
191 bool bPreviouslyEmptyModel = !
m_pHelper->getCurrentFormModel().is();
193 Reference< XPropertySet > xNewBinding;
194 if ( !sNewBindingName.isEmpty() )
200 if ( bPreviouslyEmptyModel )
222 Reference< XPropertySet > xBinding(
m_pHelper->getCurrentBinding() );
223 OSL_ENSURE( xBinding.is(),
"You should not reach this without an active binding!" );
235 Reference< XPropertySet > xBindingProps(
m_pHelper->getCurrentBinding() );
236 DBG_ASSERT( xBindingProps.is(),
"EFormsPropertyHandler::setPropertyValue: how can I set a property if there's no binding?" );
237 if ( xBindingProps.is() )
240 "EFormsPropertyHandler::setPropertyValue: invalid value type!" );
241 xBindingProps->setPropertyValue( _rPropertyName, _rValue );
247 OSL_FAIL(
"EFormsPropertyHandler::setPropertyValue: cannot handle this property!" );
268 DBG_ASSERT( xDocument.is(),
"EFormsPropertyHandler::onNewComponent: no document!" );
302 return Sequence< Property >();
309 ::osl::MutexGuard aGuard(
m_aMutex );
314 "EFormsPropertyHandler::convertToPropertyValue: we have no SupportedProperties!");
320 OUString sControlValue;
325 OSL_VERIFY( _rControlValue >>= sControlValue );
328 "EFormsPropertyHandler::convertToPropertyValue: there's a binding which is no ListEntrySource!" );
329 aReturn <<= xListSource;
344 ::osl::MutexGuard aGuard(
m_aMutex );
348 "EFormsPropertyHandler::convertToControlValue: we have no SupportedProperties!");
354 OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING,
355 "EFormsPropertyHandler::convertToControlValue: all our controls should use strings for value exchange!" );
361 Reference< XPropertySet > xListSourceBinding( _rPropertyValue, UNO_QUERY );
362 if ( xListSourceBinding.is() )
378 ::osl::MutexGuard aGuard(
m_aMutex );
380 return Sequence< OUString >();
382 std::vector< OUString > aInterestedInActuations( 2 );
391 ::osl::MutexGuard aGuard(
m_aMutex );
393 return Sequence< OUString >();
400 const Reference< XPropertyControlFactory >& _rxControlFactory )
402 ::osl::MutexGuard aGuard(
m_aMutex );
403 if ( !_rxControlFactory.is() )
404 throw NullPointerException();
408 LineDescriptor aDescriptor;
409 sal_Int16 nControlType = PropertyControlType::TextField;
410 std::vector< OUString > aListEntries;
415 nControlType = PropertyControlType::ListBox;
420 nControlType = PropertyControlType::ListBox;
421 m_pHelper->getFormModelNames( aListEntries );
426 nControlType = PropertyControlType::ComboBox;
428 if ( !sCurrentModel.isEmpty() )
429 m_pHelper->getBindingNames( sCurrentModel, aListEntries );
441 OSL_FAIL(
"EFormsPropertyHandler::describePropertyLine: cannot handle this property!" );
445 switch ( nControlType )
447 case PropertyControlType::ListBox:
450 case PropertyControlType::ComboBox:
454 aDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType,
false );
458 aDescriptor.DisplayName =
m_pInfoService->getPropertyTranslation( nPropId );
459 aDescriptor.Category =
"Data";
466 if ( !_rxInspectorUI.is() )
467 throw NullPointerException();
469 ::osl::MutexGuard aGuard(
m_aMutex );
470 OSL_ENSURE(
m_pHelper,
"EFormsPropertyHandler::onInteractivePropertySelection: we do not "
471 "have any SupportedProperties!");
473 return InteractiveSelectionResult_Cancelled;
486 Reference< XExecutableDialog > xDialog;
487 xDialog.set(
m_xContext->getServiceManager()->createInstanceWithContext(
"com.sun.star.xforms.ui.dialogs.AddCondition",
m_xContext ), UNO_QUERY );
488 Reference< XPropertySet > xDialogProps( xDialog, UNO_QUERY_THROW );
491 Reference< xforms::XModel >
xModel(
m_pHelper->getCurrentFormModel() );
493 Reference< XPropertySet > xBinding(
m_pHelper->getCurrentBinding() );
495 const OUString& sFacetName( _rPropertyName );
497 OSL_ENSURE(
xModel.is() && xBinding.is() && !sFacetName.isEmpty(),
498 "EFormsPropertyHandler::onInteractivePropertySelection: something is missing for the dialog initialization!" );
499 if ( !
xModel.is() || !xBinding.is() || sFacetName.isEmpty() )
500 return InteractiveSelectionResult_Cancelled;
502 xDialogProps->setPropertyValue(
"FormModel",
Any(
xModel ) );
503 xDialogProps->setPropertyValue(
"Binding",
Any( xBinding ) );
504 xDialogProps->setPropertyValue(
"FacetName",
Any( sFacetName ) );
506 if ( !xDialog->execute() )
508 return InteractiveSelectionResult_Cancelled;
510 _rData = xDialogProps->getPropertyValue(
"ConditionValue");
511 return InteractiveSelectionResult_ObtainedValue;
515 TOOLS_WARN_EXCEPTION(
"extensions.propctrlr",
"EFormsPropertyHandler::onInteractivePropertySelection" );
519 return InteractiveSelectionResult_Cancelled;
525 ::osl::MutexGuard aGuard(
m_aMutex );
528 m_pHelper->registerBindingListener( _rxListener );
534 ::osl::MutexGuard aGuard(
m_aMutex );
536 m_pHelper->revokeBindingListener( _rxListener );
543 if ( !_rxInspectorUI.is() )
544 throw NullPointerException();
546 ::osl::MutexGuard aGuard(
m_aMutex );
548 OSL_PRECOND(
m_pHelper,
"EFormsPropertyHandler::actuatingPropertyChanged: inconsistency!");
551 DBG_ASSERT( _rxInspectorUI.is(),
"EFormsPropertyHandler::actuatingPropertyChanged: invalid callback!" );
552 if ( !_rxInspectorUI.is() )
555 switch ( nActuatingPropId )
561 OUString sDataModelName;
562 OSL_VERIFY( _rNewValue >>= sDataModelName );
563 bool bBoundToSomeModel = !sDataModelName.isEmpty();
571 bool bHaveABinding = !
m_pHelper->getCurrentBindingName().isEmpty();
583 OSL_FAIL(
"EFormsPropertyHandler::actuatingPropertyChanged: cannot handle this property!" );
591extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
593 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any>
const&)
PropertiesInfo aProperties
mutable::osl::Mutex m_aMutex
static OUString getHelpURL(std::u16string_view)
PropertyHandler implementation which additionally supports XServiceInfo.
static css::uno::Reference< css::inspection::XPropertyControl > createComboBoxControl(const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory, std::vector< OUString > &&_rInitialListEntries, bool _bSorted)
creates an <member scope="css::inspection">PropertyControlType::ComboBox</member>-type control and fi...
static css::uno::Reference< css::inspection::XPropertyControl > createListBoxControl(const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory, std::vector< OUString > &&_rInitialListEntries, bool _bReadOnlyControl, bool _bSorted)
creates an <member scope="css::inspection">PropertyControlType::ListBox</member>-type control and fil...
std::unique_ptr< OPropertyInfoService > m_pInfoService
access to property meta data
css::uno::Reference< css::uno::XComponentContext > m_xContext
the context in which the instance was created
virtual void onNewComponent()
called when XPropertyHandler::inspect has been called, and we thus have a new component to inspect
virtual void SAL_CALL addPropertyChangeListener(const css::uno::Reference< css::beans::XPropertyChangeListener > &_rxListener) override
virtual css::uno::Any SAL_CALL convertToPropertyValue(const OUString &_rPropertyName, const css::uno::Any &_rControlValue) override
void addStringPropertyDescription(std::vector< css::beans::Property > &_rProperties, const OUString &_rPropertyName) const
adds a description for the given string property to the given property vector Most probably to be cal...
void firePropertyChange(const OUString &_rPropName, PropertyId _nPropId, const css::uno::Any &_rOldValue, const css::uno::Any &_rNewValue)
fires the change in a property value to our listener (if any)
virtual css::uno::Any SAL_CALL convertToControlValue(const OUString &_rPropertyName, const css::uno::Any &_rPropertyValue, const css::uno::Type &_rControlValueType) override
PropertyId impl_getPropertyId_throwUnknownProperty(const OUString &_rPropertyName) const
retrieves the property id for a given property name
virtual void SAL_CALL removePropertyChangeListener(const css::uno::Reference< css::beans::XPropertyChangeListener > &_rxListener) override
css::uno::Reference< css::beans::XPropertySet > m_xComponent
the component we're inspecting
PropertyId impl_getPropertyId_throwRuntime(const OUString &_rPropertyName) const
retrieves the property id for a given property name
void impl_setContextDocumentModified_nothrow() const
marks the context document as modified
css::uno::Reference< css::frame::XModel > impl_getContextDocument_nothrow() const
returns the value of the ContextDocument property in the ComponentContext which was used to create th...
void implAddPropertyDescription(std::vector< css::beans::Property > &_rProperties, const OUString &_rPropertyName, const css::uno::Type &_rType, sal_Int16 _nAttribs=0) const
adds a Property, given by name only, to a given vector of Properties
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
a property handler for any virtual string properties
constexpr OUStringLiteral UID_PROP_DLG_XSD_RELEVANT
constexpr OUStringLiteral UID_PROP_DLG_XSD_READONLY
constexpr OUStringLiteral UID_PROP_DLG_XSD_CALCULATION
constexpr OUStringLiteral UID_PROP_DLG_BIND_EXPRESSION
constexpr OUStringLiteral UID_PROP_DLG_XSD_REQUIRED
constexpr OUStringLiteral UID_PROP_DLG_XSD_CONSTRAINT
Reference< XModel > xModel