34#include <com/sun/star/beans/PropertyAttribute.hpp>
35#include <com/sun/star/lang/NullPointerException.hpp>
36#include <com/sun/star/xsd/WhiteSpaceTreatment.hpp>
37#include <com/sun/star/xsd/DataTypeClass.hpp>
38#include <com/sun/star/inspection/PropertyControlType.hpp>
39#include <com/sun/star/beans/Optional.hpp>
40#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
41#include <com/sun/star/inspection/PropertyLineElement.hpp>
64 using ::com::sun::star::beans::PropertyAttribute::MAYBEVOID;
82 return "com.sun.star.comp.extensions.XSDValidationPropertyHandler";
88 return{
"com.sun.star.form.inspection.XSDValidationPropertyHandler" };
94 ::osl::MutexGuard aGuard(
m_aMutex );
97 OSL_ENSURE(
m_pHelper,
"XSDValidationPropertyHandler::getPropertyValue: inconsistency!");
112 if ( pType.is() && pType->hasFacet( _rPropertyName ) )
113 aReturn = pType->getFacet( _rPropertyName );
124 ::osl::MutexGuard aGuard(
m_aMutex );
127 OSL_ENSURE(
m_pHelper,
"XSDValidationPropertyHandler::getPropertyValue: inconsistency!");
133 OSL_VERIFY( _rValue >>= sTypeName );
134 m_pHelper->setValidatingDataTypeByName( sTypeName );
142 OSL_FAIL(
"XSDValidationPropertyHandler::setPropertyValue: you're trying to set a type facet, without a current type!" );
146 pType->setFacet( _rPropertyName, _rValue );
156 DBG_ASSERT( xDocument.is(),
"XSDValidationPropertyHandler::onNewComponent: no document!" );
170 bool bAllowBinding =
m_pHelper->canBindToAnyDataType();
219 ::osl::MutexGuard aGuard(
m_aMutex );
221 std::vector< OUString > aSuperfluous;
231 bool bAllowBinding =
m_pHelper->canBindToAnyDataType();
254 ::osl::MutexGuard aGuard(
m_aMutex );
255 std::vector< OUString > aInterestedInActuations;
267 void showPropertyUI(
const Reference< XObjectInspectorUI >& _rxInspectorUI,
const OUString& _rPropertyName,
bool _bShow )
270 _rxInspectorUI->showPropertyUI( _rPropertyName );
272 _rxInspectorUI->hidePropertyUI( _rPropertyName );
278 const Reference< XPropertyControlFactory >& _rxControlFactory )
280 ::osl::MutexGuard aGuard(
m_aMutex );
281 if ( !_rxControlFactory.is() )
282 throw NullPointerException();
288 LineDescriptor aDescriptor;
290 aDescriptor.IndentLevel = 1;
293 sal_Int16 nControlType = PropertyControlType::TextField;
294 std::vector< OUString > aListEntries;
295 Optional< double > aMinValue(
false, 0 );
296 Optional< double > aMaxValue(
false, 0 );
301 nControlType = PropertyControlType::ListBox;
307 aDescriptor.HasPrimaryButton = aDescriptor.HasSecondaryButton =
true;
308 aDescriptor.PrimaryButtonImageURL =
"private:graphicrepository/extensions/res/buttonplus.png";
309 aDescriptor.SecondaryButtonImageURL =
"private:graphicrepository/extensions/res/buttonminus.png";
314 nControlType = PropertyControlType::ListBox;
320 nControlType = PropertyControlType::TextField;
326 nControlType = PropertyControlType::NumericField;
331 nControlType = PropertyControlType::NumericField;
339 nControlType = PropertyControlType::NumericField;
345 sal_Int16 nTypeClass = xDataType.is() ? xDataType->classify() : DataTypeClass::STRING;
347 aMinValue.IsPresent = aMaxValue.IsPresent =
true;
348 aMinValue.Value = DataTypeClass::gYear == nTypeClass ? 0 : 1;
349 aMaxValue.Value = std::numeric_limits< sal_Int32 >::max();
350 if ( DataTypeClass::gMonth == nTypeClass )
351 aMaxValue.Value = 12;
352 else if ( DataTypeClass::gDay == nTypeClass )
353 aMaxValue.Value = 31;
361 nControlType = PropertyControlType::NumericField;
369 nControlType = PropertyControlType::DateField;
376 nControlType = PropertyControlType::TimeField;
383 nControlType = PropertyControlType::DateTimeField;
387 OSL_FAIL(
"XSDValidationPropertyHandler::describePropertyLine: cannot handle this property!" );
391 switch ( nControlType )
393 case PropertyControlType::ListBox:
396 case PropertyControlType::NumericField:
400 aDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType,
false );
404 aDescriptor.Category =
"Data";
405 aDescriptor.DisplayName =
m_pInfoService->getPropertyTranslation( nPropId );
414 if ( !_rxInspectorUI.is() )
415 throw NullPointerException();
417 ::osl::MutexGuard aGuard(
m_aMutex );
418 OSL_ENSURE(
m_pHelper,
"XSDValidationPropertyHandler::onInteractivePropertySelection: we "
419 "don't have any SupportedProperties!");
421 return InteractiveSelectionResult_Cancelled;
431 OUString sNewDataTypeName;
435 return InteractiveSelectionResult_Success;
444 OSL_FAIL(
"XSDValidationPropertyHandler::onInteractivePropertySelection: unexpected property to build a dedicated UI!" );
447 return InteractiveSelectionResult_Cancelled;
453 ::osl::MutexGuard aGuard(
m_aMutex );
456 m_pHelper->registerBindingListener( _rxListener );
462 ::osl::MutexGuard aGuard(
m_aMutex );
464 m_pHelper->revokeBindingListener( _rxListener );
473 "XSDValidationPropertyHandler::implPrepareCloneDataCurrentType: this will crash!");
478 OSL_FAIL(
"XSDValidationPropertyHandler::implPrepareCloneDataCurrentType: invalid current data type!" );
482 std::vector< OUString > aExistentNames;
483 m_pHelper->getAvailableDataTypeNames( aExistentNames );
497 "XSDValidationPropertyHandler::implDoCloneCurrentDataType: this will crash!");
503 if ( !
m_pHelper->cloneDataType( pType, _rNewName ) )
506 m_pHelper->setValidatingDataTypeByName( _rNewName );
513 "XSDValidationPropertyHandler::implPrepareRemoveCurrentDataType: this will crash!");
518 OSL_FAIL(
"XSDValidationPropertyHandler::implPrepareRemoveCurrentDataType: invalid current data type!" );
523 OUString sConfirmation(
PcrRes( RID_STR_CONFIRM_DELETE_DATA_TYPE ) );
524 sConfirmation = sConfirmation.replaceFirst(
"#type#", pType->getName() );
527 VclMessageType::Question, VclButtonsType::YesNo,
529 return xQueryBox->run() ==
RET_YES;
535 "XSDValidationPropertyHandler::implDoRemoveCurrentDataType: this will crash!");
545 m_pHelper->setValidatingDataTypeByName(
m_pHelper->getBasicTypeNameForClass( pType->classify() ) );
547 m_pHelper->removeDataTypeFromRepository( pType->getName() );
555 if ( !_rxInspectorUI.is() )
556 throw NullPointerException();
558 ::osl::MutexGuard aGuard(
m_aMutex );
564 switch ( nActuatingPropId )
571 bool bIsBasicType = xDataType.is() && xDataType->isBasicType();
572 _rxInspectorUI->enablePropertyUIElements(
PROPERTY_XSD_DATA_TYPE, PropertyLineElement::PrimaryButton, xDataType.is() );
573 _rxInspectorUI->enablePropertyUIElements(
PROPERTY_XSD_DATA_TYPE, PropertyLineElement::SecondaryButton, xDataType.is() && !bIsBasicType );
577 OUString aFacets[] = {
604 const OUString* pLoop =
nullptr;
605 for (
i = 0, pLoop = aFacets;
610 showPropertyUI( _rxInspectorUI, *pLoop, xDataType.is() && xDataType->hasFacet( *pLoop ) );
611 _rxInspectorUI->enablePropertyUI( *pLoop, !bIsBasicType );
620 OUString sOldModelName; _rOldValue >>= sOldModelName;
621 OUString sNewModelName; _rNewValue >>= sNewModelName;
622 OUString sDataType =
m_pHelper->getValidatingDataTypeName();
623 m_pHelper->copyDataType( sOldModelName, sNewModelName, sDataType );
626 if ( !_bFirstTimeInit )
632 OSL_FAIL(
"XSDValidationPropertyHandler::actuatingPropertyChanged: cannot handle this property!" );
638 if ( !_bFirstTimeInit &&
m_pHelper->isInspectingFormattedField() )
639 m_pHelper->findDefaultFormatForIntrospectee();
647 "XSDValidationPropertyHandler::implGetAvailableDataTypeNames: this will crash!");
649 std::vector< OUString > aAllTypes;
650 m_pHelper->getAvailableDataTypeNames( aAllTypes );
652 _rNames.reserve( aAllTypes.size() );
655 for (
auto const& dataType : aAllTypes)
658 if ( pType.is() &&
m_pHelper->canBindToDataType( pType->classify() ) )
659 _rNames.push_back(dataType);
666extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
668 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any>
const&)
PropertiesInfo aProperties
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
mutable::osl::Mutex m_aMutex
static OUString getHelpURL(std::u16string_view)
PropertyHandler implementation which additionally supports XServiceInfo.
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...
static css::uno::Reference< css::inspection::XPropertyControl > createNumericControl(const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory, sal_Int16 _nDigits, const css::beans::Optional< double > &_rMinValue, const css::beans::Optional< double > &_rMaxValue)
creates an <member scope="css::inspection">PropertyControlType::NumericField</member>-type control an...
void addInt16PropertyDescription(std::vector< css::beans::Property > &_rProperties, const OUString &_rPropertyName, sal_Int16 _nAttribs=0) const
adds a description for the given int16 property to the given property vector
std::unique_ptr< OPropertyInfoService > m_pInfoService
access to property meta data
void addDoublePropertyDescription(std::vector< css::beans::Property > &_rProperties, const OUString &_rPropertyName, sal_Int16 _nAttribs) const
adds a description for the given double property to the given property vector
void addDatePropertyDescription(std::vector< css::beans::Property > &_rProperties, const OUString &_rPropertyName, sal_Int16 _nAttribs) const
adds a description for the given date property to the given property vector
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
void addTimePropertyDescription(std::vector< css::beans::Property > &_rProperties, const OUString &_rPropertyName, sal_Int16 _nAttribs) const
adds a description for the given time property to the given property vector
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...
PropertyId impl_getPropertyId_throwUnknownProperty(const OUString &_rPropertyName) const
retrieves the property id for a given property name
void addDateTimePropertyDescription(std::vector< css::beans::Property > &_rProperties, const OUString &_rPropertyName, sal_Int16 _nAttribs) const
adds a description for the given DateTime property to the given property vector
virtual void SAL_CALL removePropertyChangeListener(const css::uno::Reference< css::beans::XPropertyChangeListener > &_rxListener) override
void addInt32PropertyDescription(std::vector< css::beans::Property > &_rProperties, const OUString &_rPropertyName, sal_Int16 _nAttribs=0) const
adds a description for the given int32 property to the given property vector
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...
virtual OUString SAL_CALL getImplementationName() override
virtual void onNewComponent() override
called when XPropertyHandler::inspect has been called, and we thus have a new component to inspect
void implGetAvailableDataTypeNames(std::vector< OUString > &_rNames) const
retrieves the names of the data types which our introspectee can be validated against
virtual css::uno::Sequence< OUString > SAL_CALL getSupersededProperties() override
XSDValidationPropertyHandler(const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
bool implPrepareCloneDataCurrentType(OUString &_rNewName)
virtual void SAL_CALL addPropertyChangeListener(const css::uno::Reference< css::beans::XPropertyChangeListener > &_rxListener) override
bool implPrepareRemoveCurrentDataType()
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &_rPropertyName) override
virtual void SAL_CALL actuatingPropertyChanged(const OUString &_rActuatingPropertyName, const css::uno::Any &_rNewValue, const css::uno::Any &_rOldValue, const css::uno::Reference< css::inspection::XObjectInspectorUI > &_rxInspectorUI, sal_Bool) override
virtual void SAL_CALL removePropertyChangeListener(const css::uno::Reference< css::beans::XPropertyChangeListener > &_rxListener) override
virtual css::uno::Sequence< css::beans::Property > doDescribeSupportedProperties() const override
virtual css::uno::Sequence< OUString > SAL_CALL getActuatingProperties() override
void implDoCloneCurrentDataType(const OUString &_rNewName)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::inspection::LineDescriptor SAL_CALL describePropertyLine(const OUString &_rPropertyName, const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory) override
bool implDoRemoveCurrentDataType()
std::unique_ptr< XSDValidationHelper > m_pHelper
virtual css::inspection::InteractiveSelectionResult SAL_CALL onInteractivePropertySelection(const OUString &_rPropertyName, sal_Bool _bPrimary, css::uno::Any &_rData, const css::uno::Reference< css::inspection::XObjectInspectorUI > &_rxInspectorUI) override
virtual ~XSDValidationPropertyHandler() override
virtual void SAL_CALL setPropertyValue(const OUString &_rPropertyName, const css::uno::Any &_rValue) override
#define DBG_ASSERT(sCon, aError)
#define SAL_N_ELEMENTS(arr)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
a property handler for any virtual string properties
OUString PcrRes(TranslateId aId)
constexpr OUStringLiteral UID_PROP_ADD_DATA_TYPE
constexpr OUStringLiteral UID_PROP_REMOVE_DATA_TYPE
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * extensions_propctrlr_XSDValidationPropertyHandler_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)