diff options
Diffstat (limited to 'forms/source')
145 files changed, 3694 insertions, 2982 deletions
diff --git a/forms/source/component/Button.cxx b/forms/source/component/Button.cxx index a52a423398cf..58a6627119ed 100644 --- a/forms/source/component/Button.cxx +++ b/forms/source/component/Button.cxx @@ -23,13 +23,15 @@ #include <services.hxx> #include <com/sun/star/awt/XVclWindowPeer.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <comphelper/streamsection.hxx> #include <comphelper/basicio.hxx> #include <comphelper/property.hxx> #include <o3tl/any.hxx> -#include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> +#include <comphelper/diagnose_ex.hxx> #include <tools/debug.hxx> #include <tools/urlobj.hxx> #include <vcl/svapp.hxx> @@ -43,7 +45,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; using namespace ::com::sun::star::awt; using namespace ::com::sun::star::io; @@ -101,18 +102,27 @@ OButtonModel::~OButtonModel() void OButtonModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 6, OClickableImageBaseModel ) - DECL_PROP1( BUTTONTYPE, FormButtonType, BOUND ); - DECL_PROP1( DEFAULT_STATE, sal_Int16, BOUND ); - DECL_PROP1( DISPATCHURLINTERNAL, sal_Bool, BOUND ); - DECL_PROP1( TARGET_URL, OUString, BOUND ); - DECL_PROP1( TARGET_FRAME, OUString, BOUND ); - DECL_PROP1( TABINDEX, sal_Int16, BOUND ); - END_DESCRIBE_PROPERTIES(); + OClickableImageBaseModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 6); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_BUTTONTYPE, PROPERTY_ID_BUTTONTYPE, cppu::UnoType<FormButtonType>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_DEFAULT_STATE, PROPERTY_ID_DEFAULT_STATE, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_DISPATCHURLINTERNAL, PROPERTY_ID_DISPATCHURLINTERNAL, cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TARGET_URL, PROPERTY_ID_TARGET_URL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TARGET_FRAME, PROPERTY_ID_TARGET_FRAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } -IMPLEMENT_DEFAULT_CLONING( OButtonModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL OButtonModel::createClone() +{ + rtl::Reference<OButtonModel> pClone = new OButtonModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} + // XServiceInfo @@ -451,7 +461,7 @@ IMPL_LINK_NOARG(OButtonControl, OnClick, void*, void) if (FormButtonType_PUSH == *o3tl::doAccess<FormButtonType>(xSet->getPropertyValue(PROPERTY_BUTTONTYPE))) { // notify the action listeners for a push button - ::comphelper::OInterfaceIteratorHelper2 aIter(m_aActionListeners); + ::comphelper::OInterfaceIteratorHelper3 aIter(m_aActionListeners); ActionEvent aEvt(static_cast<XWeak*>(this), m_aActionCommand); while(aIter.hasMoreElements() ) { @@ -460,7 +470,7 @@ IMPL_LINK_NOARG(OButtonControl, OnClick, void*, void) // to get notified try { - static_cast< XActionListener* >( aIter.next() )->actionPerformed(aEvt); + aIter.next()->actionPerformed(aEvt); } #ifdef DBG_UTIL catch( const RuntimeException& ) @@ -642,10 +652,11 @@ void SAL_CALL OButtonControl::propertyChange( const PropertyChangeEvent& _rEvent namespace { - bool isFormControllerURL( const OUString& _rURL ) + bool isFormControllerURL( std::u16string_view _rURL ) { - return ( _rURL.getLength() > RTL_CONSTASCII_LENGTH( ".uno:FormController/" ) ) - && ( _rURL.startsWith( ".uno:FormController/" ) ); + static constexpr std::u16string_view PREFIX = u".uno:FormController/"; + return ( _rURL.size() > PREFIX.size() ) + && ( o3tl::starts_with(_rURL, PREFIX ) ); } } @@ -705,7 +716,7 @@ void OButtonControl::featureStateChanged( sal_Int16 _nFeatureId, bool _bEnabled // enable or disable our peer, according to the new state Reference< XVclWindowPeer > xPeer( getPeer(), UNO_QUERY ); if ( xPeer.is() ) - xPeer->setProperty( PROPERTY_ENABLED, makeAny( m_bEnabledByPropertyValue && _bEnabled ) ); + xPeer->setProperty( PROPERTY_ENABLED, Any( m_bEnabledByPropertyValue && _bEnabled ) ); // if we're disabled according to our model's property, then // we don't care for the feature state, but *are* disabled. // If the model's property states that we're enabled, then we *do* diff --git a/forms/source/component/Button.hxx b/forms/source/component/Button.hxx index fa77e4abd3a7..7ccaf7d8adee 100644 --- a/forms/source/component/Button.hxx +++ b/forms/source/component/Button.hxx @@ -45,7 +45,14 @@ class OButtonModel :public OClickableImageBaseModel ,public OButtonModel_Base { public: - DECLARE_DEFAULT_LEAF_XTOR( OButtonModel ); + OButtonModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OButtonModel( + const OButtonModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OButtonModel() override; // UNO DECLARE_UNO3_AGG_DEFAULTS( OButtonModel, OClickableImageBaseModel ) diff --git a/forms/source/component/CheckBox.cxx b/forms/source/component/CheckBox.cxx index c91c903e0df5..ff3f2058ffcc 100644 --- a/forms/source/component/CheckBox.cxx +++ b/forms/source/component/CheckBox.cxx @@ -21,6 +21,8 @@ #include <property.hxx> #include <services.hxx> #include <comphelper/basicio.hxx> +#include <tools/debug.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> namespace frm @@ -29,13 +31,9 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; -using namespace ::com::sun::star::awt; using namespace ::com::sun::star::io; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; -using namespace ::com::sun::star::form::binding; OCheckBoxControl::OCheckBoxControl(const Reference<XComponentContext>& _rxFactory) :OBoundControl(_rxFactory, VCL_CONTROL_CHECKBOX) @@ -59,7 +57,7 @@ css::uno::Sequence<OUString> SAL_CALL OCheckBoxControl::getSupportedServiceNames OCheckBoxModel::OCheckBoxModel(const Reference<XComponentContext>& _rxFactory) :OReferenceValueComponent( _rxFactory, VCL_CONTROLMODEL_CHECKBOX, FRM_SUN_CONTROL_CHECKBOX ) - // use the old control name for compytibility reasons + // use the old control name for compatibility reasons { m_nClassId = FormComponentType::CHECKBOX; @@ -78,7 +76,13 @@ OCheckBoxModel::~OCheckBoxModel() } -IMPLEMENT_DEFAULT_CLONING( OCheckBoxModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL OCheckBoxModel::createClone() +{ + rtl::Reference<OCheckBoxModel> pClone = new OCheckBoxModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} + // XServiceInfo @@ -109,9 +113,12 @@ css::uno::Sequence<OUString> SAL_CALL OCheckBoxModel::getSupportedServiceNames() void OCheckBoxModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 1, OReferenceValueComponent ) - DECL_PROP1(TABINDEX, sal_Int16, BOUND); - END_DESCRIBE_PROPERTIES(); + OReferenceValueComponent::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 1); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } @@ -227,39 +234,39 @@ Any OCheckBoxModel::translateDbColumnToControlValue() bool OCheckBoxModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) { OSL_PRECOND( m_xColumnUpdate.is(), "OCheckBoxModel::commitControlValueToDbColumn: not bound!" ); - if ( m_xColumnUpdate.is() ) + if ( !m_xColumnUpdate ) + return true; + + Any aControlValue( m_xAggregateSet->getPropertyValue( PROPERTY_STATE ) ); + try { - Any aControlValue( m_xAggregateSet->getPropertyValue( PROPERTY_STATE ) ); - try + sal_Int16 nValue = TRISTATE_INDET; + aControlValue >>= nValue; + switch (nValue) { - sal_Int16 nValue = TRISTATE_INDET; - aControlValue >>= nValue; - switch (nValue) - { - case TRISTATE_INDET: - m_xColumnUpdate->updateNull(); - break; - case TRISTATE_TRUE: - if (DbUseBool()) - m_xColumnUpdate->updateBoolean( true ); - else - m_xColumnUpdate->updateString( getReferenceValue() ); - break; - case TRISTATE_FALSE: - if (DbUseBool()) - m_xColumnUpdate->updateBoolean( false ); - else - m_xColumnUpdate->updateString( getNoCheckReferenceValue() ); - break; - default: - OSL_FAIL("OCheckBoxModel::commitControlValueToDbColumn: invalid value !"); - } - } - catch(const Exception&) - { - OSL_FAIL("OCheckBoxModel::commitControlValueToDbColumn: could not commit !"); + case TRISTATE_INDET: + m_xColumnUpdate->updateNull(); + break; + case TRISTATE_TRUE: + if (DbUseBool()) + m_xColumnUpdate->updateBoolean( true ); + else + m_xColumnUpdate->updateString( getReferenceValue() ); + break; + case TRISTATE_FALSE: + if (DbUseBool()) + m_xColumnUpdate->updateBoolean( false ); + else + m_xColumnUpdate->updateString( getNoCheckReferenceValue() ); + break; + default: + OSL_FAIL("OCheckBoxModel::commitControlValueToDbColumn: invalid value !"); } } + catch(const Exception&) + { + OSL_FAIL("OCheckBoxModel::commitControlValueToDbColumn: could not commit !"); + } return true; } diff --git a/forms/source/component/CheckBox.hxx b/forms/source/component/CheckBox.hxx index 7f4ab7103153..8023e7446cf5 100644 --- a/forms/source/component/CheckBox.hxx +++ b/forms/source/component/CheckBox.hxx @@ -30,7 +30,14 @@ class OCheckBoxModel final : public OReferenceValueComponent bool DbUseBool(); public: - DECLARE_DEFAULT_LEAF_XTOR( OCheckBoxModel ); + OCheckBoxModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OCheckBoxModel( + const OCheckBoxModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OCheckBoxModel() override; // XServiceInfo OUString SAL_CALL getImplementationName() override diff --git a/forms/source/component/Columns.cxx b/forms/source/component/Columns.cxx index b92b99768912..1ba457d567a7 100644 --- a/forms/source/component/Columns.cxx +++ b/forms/source/component/Columns.cxx @@ -21,6 +21,7 @@ #include <property.hxx> #include <componenttools.hxx> #include "findpos.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/io/XPersistObject.hpp> #include <com/sun/star/io/XMarkableStream.hpp> #include <com/sun/star/form/XFormComponent.hpp> @@ -35,6 +36,7 @@ #include <services.hxx> #include <tools/debug.hxx> #include <o3tl/sorted_vector.hxx> +#include <utility> namespace frm @@ -44,7 +46,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; -using namespace ::com::sun::star::awt; using namespace ::com::sun::star::io; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; @@ -81,8 +82,8 @@ const css::uno::Sequence<OUString>& getColumnTypes() sal_Int32 getColumnTypeByModelName(const OUString& aModelName) { - static const OUStringLiteral aModelPrefix (u"com.sun.star.form.component."); - static const OUStringLiteral aCompatibleModelPrefix (u"stardiv.one.form.component."); + static constexpr OUString aModelPrefix (u"com.sun.star.form.component."_ustr); + static constexpr OUString aCompatibleModelPrefix (u"stardiv.one.form.component."_ustr); sal_Int32 nTypeId = -1; if (aModelName == FRM_COMPONENT_EDIT) @@ -185,11 +186,11 @@ Any SAL_CALL OGridColumn::queryAggregation( const Type& _rType ) } -OGridColumn::OGridColumn( const Reference<XComponentContext>& _rContext, const OUString& _sModelName ) +OGridColumn::OGridColumn( const Reference<XComponentContext>& _rContext, OUString _sModelName ) :OGridColumn_BASE(m_aMutex) ,OPropertySetAggregationHelper(OGridColumn_BASE::rBHelper) - ,m_aHidden( makeAny( false ) ) - ,m_aModelName(_sModelName) + ,m_aHidden( Any( false ) ) + ,m_aModelName(std::move(_sModelName)) { // Create the UnoControlModel @@ -345,11 +346,12 @@ void OGridColumn::setOwnProperties(Sequence<Property>& aDescriptor) { aDescriptor.realloc(5); Property* pProperties = aDescriptor.getArray(); - DECL_PROP1(LABEL, OUString, BOUND); - DECL_PROP3(WIDTH, sal_Int32, BOUND, MAYBEVOID, MAYBEDEFAULT); - DECL_PROP3(ALIGN, sal_Int16, BOUND, MAYBEVOID, MAYBEDEFAULT); - DECL_BOOL_PROP2(HIDDEN, BOUND, MAYBEDEFAULT); - DECL_PROP1(COLUMNSERVICENAME, OUString, READONLY); + *pProperties++ = css::beans::Property(PROPERTY_LABEL, PROPERTY_ID_LABEL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_WIDTH, PROPERTY_ID_WIDTH, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_ALIGN, PROPERTY_ID_ALIGN, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_HIDDEN, PROPERTY_ID_HIDDEN, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_COLUMNSERVICENAME, PROPERTY_ID_COLUMNSERVICENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY); } // Reference<XPropertySet> @@ -441,7 +443,7 @@ Any OGridColumn::getPropertyDefaultByHandle( sal_Int32 nHandle ) const case PROPERTY_ID_ALIGN: return Any(); case PROPERTY_ID_HIDDEN: - return makeAny(false); + return Any(false); default: return OPropertySetAggregationHelper::getPropertyDefaultByHandle(nHandle); } @@ -552,18 +554,345 @@ void OGridColumn::read(const Reference<XObjectInputStream>& _rxInStream) } } +TextFieldColumn::TextFieldColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext) + :OGridColumn(_rContext, FRM_SUN_COMPONENT_TEXTFIELD) +{ +} +TextFieldColumn::TextFieldColumn(const TextFieldColumn* _pCloneFrom) + :OGridColumn( _pCloneFrom ) +{ +} +css::uno::Reference< css::beans::XPropertySetInfo> TextFieldColumn::getPropertySetInfo() +{ + css::uno::Reference< css::beans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} +::cppu::IPropertyArrayHelper& TextFieldColumn::getInfoHelper() +{ + return *getArrayHelper(); +} +void TextFieldColumn::fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const +{ + if (m_xAggregateSet.is()) + { + _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); + clearAggregateProperties(_rAggregateProps, false); + setOwnProperties(_rProps); + } +} +rtl::Reference<OGridColumn> TextFieldColumn::createCloneColumn() const +{ + return new TextFieldColumn(this); +} + +PatternFieldColumn::PatternFieldColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext) + :OGridColumn(_rContext, FRM_SUN_COMPONENT_PATTERNFIELD) +{ +} +PatternFieldColumn::PatternFieldColumn(const PatternFieldColumn* _pCloneFrom) + :OGridColumn( _pCloneFrom ) +{ +} +css::uno::Reference< css::beans::XPropertySetInfo> PatternFieldColumn::getPropertySetInfo() +{ + css::uno::Reference< css::beans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} +::cppu::IPropertyArrayHelper& PatternFieldColumn::getInfoHelper() +{ + return *getArrayHelper(); +} +void PatternFieldColumn::fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const +{ + if (m_xAggregateSet.is()) + { + _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); + clearAggregateProperties(_rAggregateProps, false); + setOwnProperties(_rProps); + } +} +rtl::Reference<OGridColumn> PatternFieldColumn::createCloneColumn() const +{ + return new PatternFieldColumn(this); +} + +DateFieldColumn::DateFieldColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext) + :OGridColumn(_rContext, FRM_SUN_COMPONENT_DATEFIELD) +{ +} +DateFieldColumn::DateFieldColumn(const DateFieldColumn* _pCloneFrom) + :OGridColumn( _pCloneFrom ) +{ +} +css::uno::Reference< css::beans::XPropertySetInfo> DateFieldColumn::getPropertySetInfo() +{ + css::uno::Reference< css::beans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} +::cppu::IPropertyArrayHelper& DateFieldColumn::getInfoHelper() +{ + return *getArrayHelper(); +} +void DateFieldColumn::fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const +{ + if (m_xAggregateSet.is()) + { + _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); + clearAggregateProperties(_rAggregateProps, true); + setOwnProperties(_rProps); + } +} +rtl::Reference<OGridColumn> DateFieldColumn::createCloneColumn() const +{ + return new DateFieldColumn(this); +} -IMPL_COLUMN(TextFieldColumn, FRM_SUN_COMPONENT_TEXTFIELD, false); -IMPL_COLUMN(PatternFieldColumn, FRM_SUN_COMPONENT_PATTERNFIELD, false); -IMPL_COLUMN(DateFieldColumn, FRM_SUN_COMPONENT_DATEFIELD, true); -IMPL_COLUMN(TimeFieldColumn, FRM_SUN_COMPONENT_TIMEFIELD, false); -IMPL_COLUMN(NumericFieldColumn, FRM_SUN_COMPONENT_NUMERICFIELD, false); -IMPL_COLUMN(CurrencyFieldColumn, FRM_SUN_COMPONENT_CURRENCYFIELD, false); -IMPL_COLUMN(CheckBoxColumn, FRM_SUN_COMPONENT_CHECKBOX, false); -IMPL_COLUMN(ComboBoxColumn, FRM_SUN_COMPONENT_COMBOBOX, false); -IMPL_COLUMN(ListBoxColumn, FRM_SUN_COMPONENT_LISTBOX, false); -IMPL_COLUMN(FormattedFieldColumn, FRM_SUN_COMPONENT_FORMATTEDFIELD, false); +TimeFieldColumn::TimeFieldColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext) + :OGridColumn(_rContext, FRM_SUN_COMPONENT_TIMEFIELD) +{ +} +TimeFieldColumn::TimeFieldColumn(const TimeFieldColumn* _pCloneFrom) + :OGridColumn( _pCloneFrom ) +{ +} +css::uno::Reference< css::beans::XPropertySetInfo> TimeFieldColumn::getPropertySetInfo() +{ + css::uno::Reference< css::beans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} +::cppu::IPropertyArrayHelper& TimeFieldColumn::getInfoHelper() +{ + return *getArrayHelper(); +} +void TimeFieldColumn::fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const +{ + if (m_xAggregateSet.is()) + { + _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); + clearAggregateProperties(_rAggregateProps, false); + setOwnProperties(_rProps); + } +} +rtl::Reference<OGridColumn> TimeFieldColumn::createCloneColumn() const +{ + return new TimeFieldColumn(this); +} + +NumericFieldColumn::NumericFieldColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext) + :OGridColumn(_rContext, FRM_SUN_COMPONENT_NUMERICFIELD) +{ +} +NumericFieldColumn::NumericFieldColumn(const NumericFieldColumn* _pCloneFrom) + :OGridColumn( _pCloneFrom ) +{ +} +css::uno::Reference< css::beans::XPropertySetInfo> NumericFieldColumn::getPropertySetInfo() +{ + css::uno::Reference< css::beans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} +::cppu::IPropertyArrayHelper& NumericFieldColumn::getInfoHelper() +{ + return *getArrayHelper(); +} +void NumericFieldColumn::fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const +{ + if (m_xAggregateSet.is()) + { + _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); + clearAggregateProperties(_rAggregateProps, false); + setOwnProperties(_rProps); + } +} +rtl::Reference<OGridColumn> NumericFieldColumn::createCloneColumn() const +{ + return new NumericFieldColumn(this); +} +CurrencyFieldColumn::CurrencyFieldColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext) + :OGridColumn(_rContext, FRM_SUN_COMPONENT_CURRENCYFIELD) +{ +} +CurrencyFieldColumn::CurrencyFieldColumn(const CurrencyFieldColumn* _pCloneFrom) + :OGridColumn( _pCloneFrom ) +{ +} +css::uno::Reference< css::beans::XPropertySetInfo> CurrencyFieldColumn::getPropertySetInfo() +{ + css::uno::Reference< css::beans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} +::cppu::IPropertyArrayHelper& CurrencyFieldColumn::getInfoHelper() +{ + return *getArrayHelper(); +} +void CurrencyFieldColumn::fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const +{ + if (m_xAggregateSet.is()) + { + _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); + clearAggregateProperties(_rAggregateProps, false); + setOwnProperties(_rProps); + } +} +rtl::Reference<OGridColumn> CurrencyFieldColumn::createCloneColumn() const +{ + return new CurrencyFieldColumn(this); +} + +CheckBoxColumn::CheckBoxColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext) + :OGridColumn(_rContext, FRM_SUN_COMPONENT_CHECKBOX) +{ +} +CheckBoxColumn::CheckBoxColumn(const CheckBoxColumn* _pCloneFrom) + :OGridColumn( _pCloneFrom ) +{ +} +css::uno::Reference< css::beans::XPropertySetInfo> CheckBoxColumn::getPropertySetInfo() +{ + css::uno::Reference< css::beans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} +::cppu::IPropertyArrayHelper& CheckBoxColumn::getInfoHelper() +{ + return *getArrayHelper(); +} +void CheckBoxColumn::fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const +{ + if (m_xAggregateSet.is()) + { + _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); + clearAggregateProperties(_rAggregateProps, false); + setOwnProperties(_rProps); + } +} +rtl::Reference<OGridColumn> CheckBoxColumn::createCloneColumn() const +{ + return new CheckBoxColumn(this); +} + +ComboBoxColumn::ComboBoxColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext) + :OGridColumn(_rContext, FRM_SUN_COMPONENT_COMBOBOX) +{ +} +ComboBoxColumn::ComboBoxColumn(const ComboBoxColumn* _pCloneFrom) + :OGridColumn( _pCloneFrom ) +{ +} +css::uno::Reference< css::beans::XPropertySetInfo> ComboBoxColumn::getPropertySetInfo() +{ + css::uno::Reference< css::beans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} +::cppu::IPropertyArrayHelper& ComboBoxColumn::getInfoHelper() +{ + return *getArrayHelper(); +} +void ComboBoxColumn::fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const +{ + if (m_xAggregateSet.is()) + { + _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); + clearAggregateProperties(_rAggregateProps, false); + setOwnProperties(_rProps); + } +} +rtl::Reference<OGridColumn> ComboBoxColumn::createCloneColumn() const +{ + return new ComboBoxColumn(this); +} + +ListBoxColumn::ListBoxColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext) + :OGridColumn(_rContext, FRM_SUN_COMPONENT_LISTBOX) +{ +} +ListBoxColumn::ListBoxColumn(const ListBoxColumn* _pCloneFrom) + :OGridColumn( _pCloneFrom ) +{ +} +css::uno::Reference< css::beans::XPropertySetInfo> ListBoxColumn::getPropertySetInfo() +{ + css::uno::Reference< css::beans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} +::cppu::IPropertyArrayHelper& ListBoxColumn::getInfoHelper() +{ + return *getArrayHelper(); +} +void ListBoxColumn::fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const +{ + if (m_xAggregateSet.is()) + { + _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); + clearAggregateProperties(_rAggregateProps, false); + setOwnProperties(_rProps); + } +} +rtl::Reference<OGridColumn> ListBoxColumn::createCloneColumn() const +{ + return new ListBoxColumn(this); +} + +FormattedFieldColumn::FormattedFieldColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext) + :OGridColumn(_rContext, FRM_SUN_COMPONENT_FORMATTEDFIELD) +{ +} +FormattedFieldColumn::FormattedFieldColumn(const FormattedFieldColumn* _pCloneFrom) + :OGridColumn( _pCloneFrom ) +{ +} +css::uno::Reference< css::beans::XPropertySetInfo> FormattedFieldColumn::getPropertySetInfo() +{ + css::uno::Reference< css::beans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} +::cppu::IPropertyArrayHelper& FormattedFieldColumn::getInfoHelper() +{ + return *getArrayHelper(); +} +void FormattedFieldColumn::fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const +{ + if (m_xAggregateSet.is()) + { + _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); + clearAggregateProperties(_rAggregateProps, false); + setOwnProperties(_rProps); + } +} +rtl::Reference<OGridColumn> FormattedFieldColumn::createCloneColumn() const +{ + return new FormattedFieldColumn(this); +} } // namespace frm diff --git a/forms/source/component/Columns.hxx b/forms/source/component/Columns.hxx index 2f2bb3e846be..6c12197b90a5 100644 --- a/forms/source/component/Columns.hxx +++ b/forms/source/component/Columns.hxx @@ -60,7 +60,7 @@ class OGridColumn :public ::cppu::BaseMutex // [properties] public: - OGridColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext, const OUString& _sModelName); + OGridColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext, OUString _sModelName); explicit OGridColumn(const OGridColumn* _pOriginal ); virtual ~OGridColumn() override; @@ -110,62 +110,6 @@ protected: virtual rtl::Reference<OGridColumn> createCloneColumn() const = 0; }; -#define DECL_COLUMN(ClassName) \ -class ClassName \ - :public OGridColumn \ - ,public OAggregationArrayUsageHelper< ClassName > \ -{ \ -public: \ - explicit ClassName(const css::uno::Reference<css::uno::XComponentContext>& _rContext ); \ - explicit ClassName(const ClassName* _pCloneFrom); \ - \ - virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; \ - virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; \ - \ - virtual void fillProperties( \ - css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, \ - css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps \ - ) const override; \ - \ - virtual rtl::Reference<OGridColumn> createCloneColumn() const override; \ -}; - - -#define IMPL_COLUMN(ClassName, Model, bAllowDropDown) \ - ClassName::ClassName( const css::uno::Reference<css::uno::XComponentContext>& _rContext ) \ - :OGridColumn(_rContext, Model) \ -{ \ -} \ -ClassName::ClassName( const ClassName* _pCloneFrom ) \ - :OGridColumn( _pCloneFrom ) \ -{ \ -} \ -css::uno::Reference< css::beans::XPropertySetInfo> ClassName::getPropertySetInfo() \ -{ \ - css::uno::Reference< css::beans::XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); \ - return xInfo; \ -} \ -::cppu::IPropertyArrayHelper& ClassName::getInfoHelper() \ -{ \ - return *getArrayHelper(); \ -} \ -void ClassName::fillProperties( \ - css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, \ - css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps \ - ) const \ -{ \ - if (m_xAggregateSet.is()) \ - { \ - _rAggregateProps = m_xAggregateSet->getPropertySetInfo()->getProperties(); \ - clearAggregateProperties(_rAggregateProps, bAllowDropDown); \ - setOwnProperties(_rProps); \ - } \ -} \ -rtl::Reference<OGridColumn> ClassName::createCloneColumn() const \ -{ \ - return new ClassName( this ); \ -} \ - \ // column type ids #define TYPE_CHECKBOX 0 #define TYPE_COMBOBOX 1 @@ -183,16 +127,195 @@ const css::uno::Sequence<OUString>& getColumnTypes(); sal_Int32 getColumnTypeByModelName(const OUString& aModelName); // Columns -DECL_COLUMN(TextFieldColumn) -DECL_COLUMN(PatternFieldColumn) -DECL_COLUMN(DateFieldColumn) -DECL_COLUMN(TimeFieldColumn) -DECL_COLUMN(NumericFieldColumn) -DECL_COLUMN(CurrencyFieldColumn) -DECL_COLUMN(CheckBoxColumn) -DECL_COLUMN(ComboBoxColumn) -DECL_COLUMN(ListBoxColumn) -DECL_COLUMN(FormattedFieldColumn) +class TextFieldColumn + :public OGridColumn + ,public OAggregationArrayUsageHelper< TextFieldColumn > +{ +public: + explicit TextFieldColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext ); + explicit TextFieldColumn(const TextFieldColumn* _pCloneFrom); + + virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + virtual void fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const override; + + virtual rtl::Reference<OGridColumn> createCloneColumn() const override; +}; + +class PatternFieldColumn + :public OGridColumn + ,public OAggregationArrayUsageHelper< PatternFieldColumn > +{ +public: + explicit PatternFieldColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext ); + explicit PatternFieldColumn(const PatternFieldColumn* _pCloneFrom); + + virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + virtual void fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const override; + + virtual rtl::Reference<OGridColumn> createCloneColumn() const override; +}; + +class DateFieldColumn + :public OGridColumn + ,public OAggregationArrayUsageHelper< DateFieldColumn > +{ +public: + explicit DateFieldColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext ); + explicit DateFieldColumn(const DateFieldColumn* _pCloneFrom); + + virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + virtual void fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const override; + + virtual rtl::Reference<OGridColumn> createCloneColumn() const override; +}; + +class TimeFieldColumn + :public OGridColumn + ,public OAggregationArrayUsageHelper< TimeFieldColumn > +{ +public: + explicit TimeFieldColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext ); + explicit TimeFieldColumn(const TimeFieldColumn* _pCloneFrom); + + virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + virtual void fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const override; + + virtual rtl::Reference<OGridColumn> createCloneColumn() const override; +}; + +class NumericFieldColumn + :public OGridColumn + ,public OAggregationArrayUsageHelper< NumericFieldColumn > +{ +public: + explicit NumericFieldColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext ); + explicit NumericFieldColumn(const NumericFieldColumn* _pCloneFrom); + + virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + virtual void fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const override; + + virtual rtl::Reference<OGridColumn> createCloneColumn() const override; +}; + +class CurrencyFieldColumn + :public OGridColumn + ,public OAggregationArrayUsageHelper< CurrencyFieldColumn > +{ +public: + explicit CurrencyFieldColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext ); + explicit CurrencyFieldColumn(const CurrencyFieldColumn* _pCloneFrom); + + virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + virtual void fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const override; + + virtual rtl::Reference<OGridColumn> createCloneColumn() const override; +}; + +class CheckBoxColumn + :public OGridColumn + ,public OAggregationArrayUsageHelper< CheckBoxColumn > +{ +public: + explicit CheckBoxColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext ); + explicit CheckBoxColumn(const CheckBoxColumn* _pCloneFrom); + + virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + virtual void fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const override; + + virtual rtl::Reference<OGridColumn> createCloneColumn() const override; +}; + +class ComboBoxColumn + :public OGridColumn + ,public OAggregationArrayUsageHelper< ComboBoxColumn > +{ +public: + explicit ComboBoxColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext ); + explicit ComboBoxColumn(const ComboBoxColumn* _pCloneFrom); + + virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + virtual void fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const override; + + virtual rtl::Reference<OGridColumn> createCloneColumn() const override; +}; + +class ListBoxColumn + :public OGridColumn + ,public OAggregationArrayUsageHelper< ListBoxColumn > +{ +public: + explicit ListBoxColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext ); + explicit ListBoxColumn(const ListBoxColumn* _pCloneFrom); + + virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + virtual void fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const override; + + virtual rtl::Reference<OGridColumn> createCloneColumn() const override; +}; + +class FormattedFieldColumn + :public OGridColumn + ,public OAggregationArrayUsageHelper< FormattedFieldColumn > +{ +public: + explicit FormattedFieldColumn(const css::uno::Reference<css::uno::XComponentContext>& _rContext ); + explicit FormattedFieldColumn(const FormattedFieldColumn* _pCloneFrom); + + virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + virtual void fillProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps, + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const override; + + virtual rtl::Reference<OGridColumn> createCloneColumn() const override; +}; } // namespace frm diff --git a/forms/source/component/ComboBox.cxx b/forms/source/component/ComboBox.cxx index fe3260070d68..4bd7c8e998de 100644 --- a/forms/source/component/ComboBox.cxx +++ b/forms/source/component/ComboBox.cxx @@ -26,6 +26,7 @@ #include <strings.hrc> #include "BaseListBox.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/sdbc/XRowSet.hpp> #include <com/sun/star/container/XIndexAccess.hpp> @@ -34,9 +35,8 @@ #include <comphelper/basicio.hxx> #include <comphelper/property.hxx> #include <connectivity/dbtools.hxx> -#include <rtl/ustrbuf.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <unotools/sharedunocomponent.hxx> #include <limits.h> @@ -53,11 +53,9 @@ using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; -using namespace ::com::sun::star::awt; using namespace ::com::sun::star::io; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; -using namespace ::com::sun::star::form::binding; Sequence<Type> OComboBoxModel::_getTypes() @@ -144,7 +142,12 @@ OComboBoxModel::~OComboBoxModel() // XCloneable -IMPLEMENT_DEFAULT_CLONING( OComboBoxModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL OComboBoxModel::createClone() +{ + rtl::Reference<OComboBoxModel> pClone = new OComboBoxModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} void OComboBoxModel::disposing() @@ -291,15 +294,19 @@ sal_Bool OComboBoxModel::convertFastPropertyValue( void OComboBoxModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 7, OBoundControlModel ) - DECL_PROP1(TABINDEX, sal_Int16, BOUND); - DECL_PROP1(LISTSOURCETYPE, ListSourceType, BOUND); - DECL_PROP1(LISTSOURCE, OUString, BOUND); - DECL_BOOL_PROP1(EMPTY_IS_NULL, BOUND); - DECL_PROP1(DEFAULT_TEXT, OUString, BOUND); - DECL_PROP1(STRINGITEMLIST, Sequence< OUString >,BOUND); - DECL_PROP1(TYPEDITEMLIST, Sequence< Any >, OPTIONAL); - END_DESCRIBE_PROPERTIES(); + OBoundControlModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 7); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_LISTSOURCETYPE, PROPERTY_ID_LISTSOURCETYPE, cppu::UnoType<ListSourceType>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_LISTSOURCE, PROPERTY_ID_LISTSOURCE, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_EMPTY_IS_NULL, PROPERTY_ID_EMPTY_IS_NULL, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_DEFAULT_TEXT, PROPERTY_ID_DEFAULT_TEXT, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_STRINGITEMLIST, PROPERTY_ID_STRINGITEMLIST, cppu::UnoType<Sequence< OUString >>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TYPEDITEMLIST, PROPERTY_ID_TYPEDITEMLIST, cppu::UnoType<Sequence< Any >>::get(), css::beans::PropertyAttribute::OPTIONAL); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } @@ -404,7 +411,7 @@ void SAL_CALL OComboBoxModel::read(const Reference<css::io::XObjectInputStream>& m_aListSource.clear(); css::uno::Sequence<OUString> aListSource; _rxInStream >> aListSource; - for (const OUString& rToken : std::as_const(aListSource)) + for (const OUString& rToken : aListSource) m_aListSource += rToken; } @@ -435,8 +442,8 @@ void SAL_CALL OComboBoxModel::read(const Reference<css::io::XObjectInputStream>& && !hasExternalListSource() ) { - setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( css::uno::Sequence<OUString>() ) ); - setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, makeAny( css::uno::Sequence<css::uno::Any>() ) ); + setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, Any( css::uno::Sequence<OUString>() ) ); + setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, Any( css::uno::Sequence<css::uno::Any>() ) ); } if (nVersion > 0x0004) @@ -575,7 +582,7 @@ void OComboBoxModel::loadData( bool _bForce ) } catch(const SQLException& eSQL) { - onError(eSQL, FRM_RES_STRING(RID_BASELISTBOX_ERROR_FILLLIST)); + onError(eSQL, ResourceManager::loadString(RID_BASELISTBOX_ERROR_FILLLIST)); return; } catch( const Exception& ) @@ -643,7 +650,7 @@ void OComboBoxModel::loadData( bool _bForce ) } catch(const SQLException& eSQL) { - onError(eSQL, FRM_RES_STRING(RID_BASELISTBOX_ERROR_FILLLIST)); + onError(eSQL, ResourceManager::loadString(RID_BASELISTBOX_ERROR_FILLLIST)); return; } catch( const Exception& ) @@ -653,9 +660,9 @@ void OComboBoxModel::loadData( bool _bForce ) } // Set String-Sequence at ListBox - setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( comphelper::containerToSequence(aStringList) ) ); + setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, Any( comphelper::containerToSequence(aStringList) ) ); // Reset TypedItemList, no matching data. - setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, makeAny( css::uno::Sequence<css::uno::Any>() ) ); + setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, Any( css::uno::Sequence<css::uno::Any>() ) ); } @@ -678,7 +685,7 @@ void OComboBoxModel::onDisconnectedDbColumn() // reset the string item list if ( !hasExternalListSource() ) - setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( m_aDesignModeStringItems ) ); + setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, Any( m_aDesignModeStringItems ) ); m_aListRowSet.dispose(); } @@ -746,29 +753,29 @@ bool OComboBoxModel::commitControlValueToDbColumn( bool _bPostReset ) bool bAddToList = bModified && !_bPostReset; // (only if this is not the "commit" triggered by a "reset") - if ( bAddToList ) + if ( !bAddToList ) + return true; + + css::uno::Sequence<OUString> aStringItemList; + if ( !(getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aStringItemList) ) + return true; + + bool bFound = false; + for (const OUString& rStringItem : aStringItemList) { - css::uno::Sequence<OUString> aStringItemList; - if ( getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aStringItemList ) - { - bool bFound = false; - for (const OUString& rStringItem : std::as_const(aStringItemList)) - { - if ( (bFound = rStringItem == sNewValue) ) - break; - } + if ( (bFound = rStringItem == sNewValue) ) + break; + } - // not found -> add - if (!bFound) - { - sal_Int32 nOldLen = aStringItemList.getLength(); - aStringItemList.realloc( nOldLen + 1 ); - aStringItemList[ nOldLen ] = sNewValue; + // not found -> add + if (!bFound) + { + sal_Int32 nOldLen = aStringItemList.getLength(); + aStringItemList.realloc( nOldLen + 1 ); + aStringItemList.getArray()[ nOldLen ] = sNewValue; - setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( aStringItemList ) ); - setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, makeAny( css::uno::Sequence<css::uno::Any>() ) ); - } - } + setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, Any( aStringItemList ) ); + setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, Any( css::uno::Sequence<css::uno::Any>() ) ); } return true; @@ -799,14 +806,14 @@ Any OComboBoxModel::translateDbColumnToControlValue() else m_aLastKnownValue.clear(); - return m_aLastKnownValue.hasValue() ? m_aLastKnownValue : makeAny( OUString() ); + return m_aLastKnownValue.hasValue() ? m_aLastKnownValue : Any( OUString() ); // (m_aLastKnownValue is allowed to be VOID, the control value isn't) } Any OComboBoxModel::getDefaultForReset() const { - return makeAny( m_aDefaultText ); + return Any( m_aDefaultText ); } @@ -814,8 +821,8 @@ void OComboBoxModel::stringItemListChanged( ControlModelLock& /*_rInstanceLock*/ { if ( m_xAggregateSet.is() ) { - m_xAggregateSet->setPropertyValue( PROPERTY_STRINGITEMLIST, makeAny( comphelper::containerToSequence(getStringItemList()) ) ); - m_xAggregateSet->setPropertyValue( PROPERTY_TYPEDITEMLIST, makeAny( getTypedItemList()) ) ; + m_xAggregateSet->setPropertyValue( PROPERTY_STRINGITEMLIST, Any( comphelper::containerToSequence(getStringItemList()) ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_TYPEDITEMLIST, Any( getTypedItemList()) ) ; } } diff --git a/forms/source/component/ComboBox.hxx b/forms/source/component/ComboBox.hxx index 7b88717cc5c3..ed2360144225 100644 --- a/forms/source/component/ComboBox.hxx +++ b/forms/source/component/ComboBox.hxx @@ -54,7 +54,14 @@ class OComboBoxModel final virtual css::uno::Sequence< css::uno::Type> _getTypes() override; public: - DECLARE_DEFAULT_LEAF_XTOR( OComboBoxModel ); + OComboBoxModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OComboBoxModel( + const OComboBoxModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OComboBoxModel() override; virtual void SAL_CALL disposing() override; diff --git a/forms/source/component/Currency.cxx b/forms/source/component/Currency.cxx index 925e23cde6fa..edd86eeabd8a 100644 --- a/forms/source/component/Currency.cxx +++ b/forms/source/component/Currency.cxx @@ -23,7 +23,9 @@ #include <unotools/localedatawrapper.hxx> #include <unotools/syslocale.hxx> #include <comphelper/types.hxx> -#include <tools/diagnose_ex.h> +#include <tools/debug.hxx> +#include <comphelper/diagnose_ex.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> @@ -34,11 +36,7 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::io; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; OCurrencyControl::OCurrencyControl(const Reference<XComponentContext>& _rxFactory) @@ -94,8 +92,8 @@ void OCurrencyModel::implConstruct() } if (!sCurrencySymbol.isEmpty()) { - m_xAggregateSet->setPropertyValue(PROPERTY_CURRENCYSYMBOL, makeAny(sCurrencySymbol)); - m_xAggregateSet->setPropertyValue(PROPERTY_CURRSYM_POSITION, makeAny(bPrependCurrencySymbol)); + m_xAggregateSet->setPropertyValue(PROPERTY_CURRENCYSYMBOL, Any(sCurrencySymbol)); + m_xAggregateSet->setPropertyValue(PROPERTY_CURRSYM_POSITION, Any(bPrependCurrencySymbol)); } } catch(const Exception&) @@ -130,7 +128,13 @@ OCurrencyModel::~OCurrencyModel() // XCloneable -IMPLEMENT_DEFAULT_CLONING( OCurrencyModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL OCurrencyModel::createClone() +{ + rtl::Reference<OCurrencyModel> pClone = new OCurrencyModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} + // XServiceInfo @@ -156,13 +160,16 @@ css::uno::Sequence<OUString> SAL_CALL OCurrencyModel::getSupportedServiceNames() void OCurrencyModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 2, OEditBaseModel ) + OEditBaseModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 2); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; // Set Value to transient // ModifyPropertyAttributes(_rAggregateProps, PROPERTY_VALUE, PropertyAttribute::TRANSIENT, 0); - DECL_PROP3(DEFAULT_VALUE, double, BOUND, MAYBEDEFAULT, MAYBEVOID); - DECL_PROP1(TABINDEX, sal_Int16, BOUND); - END_DESCRIBE_PROPERTIES(); + *pProperties++ = css::beans::Property(PROPERTY_DEFAULT_VALUE, PROPERTY_ID_DEFAULT_VALUE, cppu::UnoType<double>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT | css::beans::PropertyAttribute::MAYBEVOID); + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } diff --git a/forms/source/component/Currency.hxx b/forms/source/component/Currency.hxx index 1deca259533f..f77f711f090a 100644 --- a/forms/source/component/Currency.hxx +++ b/forms/source/component/Currency.hxx @@ -31,7 +31,14 @@ class OCurrencyModel final css::uno::Any m_aSaveValue; public: - DECLARE_DEFAULT_LEAF_XTOR( OCurrencyModel ); + OCurrencyModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OCurrencyModel( + const OCurrencyModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OCurrencyModel() override; // css::lang::XServiceInfo OUString SAL_CALL getImplementationName() override diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 7411abf90351..4bad0608b5bc 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -29,9 +29,11 @@ #include "GroupManager.hxx" #include <property.hxx> #include <services.hxx> +#include <comphelper/propertyvalue.hxx> #include <com/sun/star/awt/XControlContainer.hpp> #include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/DataSelectionType.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/form/TabulatorCycle.hpp> @@ -67,7 +69,7 @@ #include <svl/inettype.hxx> #include <tools/datetime.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <tools/inetmsg.hxx> #include <tools/inetstrm.hxx> #include <tools/urlobj.hxx> @@ -229,7 +231,7 @@ ODatabaseForm::ODatabaseForm(const Reference<XComponentContext>& _rxContext) ,m_aRowSetApproveListeners(m_aMutex) ,m_aSubmitListeners(m_aMutex) ,m_aErrorListeners(m_aMutex) - ,m_aResetListeners( *this, m_aMutex ) + ,m_aResetListeners(m_aMutex) ,m_aPropertyBagHelper( *this ) ,m_aParameterManager( m_aMutex, _rxContext ) ,m_aFilterManager() @@ -263,7 +265,7 @@ ODatabaseForm::ODatabaseForm( const ODatabaseForm& _cloneSource ) ,m_aRowSetApproveListeners( m_aMutex ) ,m_aSubmitListeners( m_aMutex ) ,m_aErrorListeners( m_aMutex ) - ,m_aResetListeners( *this, m_aMutex ) + ,m_aResetListeners( m_aMutex ) ,m_aPropertyBagHelper( *this ) ,m_aParameterManager( m_aMutex, _cloneSource.m_xContext ) ,m_aFilterManager() @@ -435,9 +437,7 @@ OUString ODatabaseForm::GetDataEncoded(bool _bURLEncoded,const Reference<XContro Encode( aName ); Encode( aValue ); - aResult.append(aName); - aResult.append('='); - aResult.append(aValue); + aResult.append(aName + "=" + aValue); if (pSuccObj < aSuccObjList.end() - 1) { @@ -496,7 +496,7 @@ Sequence<sal_Int8> ODatabaseForm::GetDataMultiPartEncoded(const Reference<XContr } pBuf.reset(); - aMemStream.Flush(); + aMemStream.FlushBuffer(); aMemStream.Seek( 0 ); void const * pData = aMemStream.GetData(); sal_Int32 nLen = aMemStream.TellEnd(); @@ -903,9 +903,9 @@ void ODatabaseForm::Encode( OUString& rString ) short nLo = static_cast<sal_Int16>(nCharCode) - (nHi*16); if( nHi > 9 ) nHi += int('A')-10; else nHi += int('0'); if( nLo > 9 ) nLo += int('A')-10; else nLo += int('0'); - aResult.append('%'); - aResult.append(static_cast<sal_Unicode>(nHi)); - aResult.append(static_cast<sal_Unicode>(nLo)); + aResult.append("%" + + OUStringChar(static_cast<sal_Unicode>(nHi)) + + OUStringChar(static_cast<sal_Unicode>(nLo)) ); } } } @@ -938,11 +938,11 @@ void ODatabaseForm::InsertTextPart( INetMIMEMessage& rParent, std::u16string_vie pChild->SetContentTransferEncoding("8bit"); // Body - SvMemoryStream* pStream = new SvMemoryStream; + std::unique_ptr<SvMemoryStream> pStream(new SvMemoryStream); pStream->WriteLine( OUStringToOString(rData, rtl_getTextEncodingFromMimeCharset(pBestMatchingEncoding)) ); - pStream->Flush(); + pStream->FlushBuffer(); pStream->Seek( 0 ); - pChild->SetDocumentLB( new SvLockBytes(pStream, true) ); + pChild->SetDocumentLB( std::move(pStream) ); rParent.AttachChild( std::move(pChild) ); } @@ -1001,7 +1001,7 @@ void ODatabaseForm::InsertFilePart( INetMIMEMessage& rParent, std::u16string_vie // Body - pChild->SetDocumentLB( new SvLockBytes(pStream.release(), true) ); + pChild->SetDocumentLB( std::move(pStream) ); rParent.AttachChild( std::move(pChild) ); } @@ -1019,7 +1019,7 @@ void ODatabaseForm::onError( const SQLException& _rException, const OUString& _r if ( !m_aErrorListeners.getLength() ) return; - SQLErrorEvent aEvent( *this, makeAny( prependErrorInfo( _rException, *this, _rContextDescription ) ) ); + SQLErrorEvent aEvent( *this, Any( prependErrorInfo( _rException, *this, _rContextDescription ) ) ); onError( aEvent ); } @@ -1033,32 +1033,31 @@ void ODatabaseForm::updateParameterInfo() bool ODatabaseForm::hasValidParent() const { // do we have to fill the parameters again? - if (m_bSubForm) + if (!m_bSubForm) + return true; + Reference<XResultSet> xResultSet(m_xParent, UNO_QUERY); + if (!xResultSet.is()) { - Reference<XResultSet> xResultSet(m_xParent, UNO_QUERY); - if (!xResultSet.is()) - { - OSL_FAIL("ODatabaseForm::hasValidParent() : no parent resultset !"); - return false; - } - try - { - Reference< XPropertySet > xSet( m_xParent, UNO_QUERY ); - Reference< XLoadable > xLoad( m_xParent, UNO_QUERY ); - if ( xLoad->isLoaded() - && ( xResultSet->isBeforeFirst() - || xResultSet->isAfterLast() - || getBOOL( xSet->getPropertyValue( PROPERTY_ISNEW ) ) - ) + OSL_FAIL("ODatabaseForm::hasValidParent() : no parent resultset !"); + return false; + } + try + { + Reference< XPropertySet > xSet( m_xParent, UNO_QUERY ); + Reference< XLoadable > xLoad( m_xParent, UNO_QUERY ); + if ( xLoad->isLoaded() + && ( xResultSet->isBeforeFirst() + || xResultSet->isAfterLast() + || getBOOL( xSet->getPropertyValue( PROPERTY_ISNEW ) ) ) - // the parent form is loaded and on a "virtual" row -> not valid - return false; - } - catch(const Exception&) - { - // parent could be forwardonly? + ) + // the parent form is loaded and on a "virtual" row -> not valid return false; - } + } + catch(const Exception&) + { + // parent could be forwardonly? + return false; } return true; } @@ -1126,15 +1125,15 @@ bool ODatabaseForm::executeRowSet(::osl::ResettableMutexGuard& _rClearForNotifie // switch to "insert only" mode saveInsertOnlyState( ); - m_xAggregateSet->setPropertyValue( PROPERTY_INSERTONLY, makeAny( true ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_INSERTONLY, Any( true ) ); } else if (m_bAllowInsert || m_bAllowUpdate || m_bAllowDelete) nConcurrency = ResultSetConcurrency::UPDATABLE; else nConcurrency = ResultSetConcurrency::READ_ONLY; - m_xAggregateSet->setPropertyValue( PROPERTY_RESULTSET_CONCURRENCY, makeAny( nConcurrency ) ); - m_xAggregateSet->setPropertyValue( PROPERTY_RESULTSET_TYPE, makeAny( sal_Int32(ResultSetType::SCROLL_SENSITIVE) ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_RESULTSET_CONCURRENCY, Any( nConcurrency ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_RESULTSET_TYPE, Any( sal_Int32(ResultSetType::SCROLL_SENSITIVE) ) ); bool bSuccess = false; try @@ -1151,7 +1150,7 @@ bool ODatabaseForm::executeRowSet(::osl::ResettableMutexGuard& _rClearForNotifie if (!m_sCurrentErrorContext.isEmpty()) onError(eDb, m_sCurrentErrorContext); else - onError(eDb, FRM_RES_STRING(RID_STR_READERROR)); + onError(eDb, ResourceManager::loadString(RID_STR_READERROR)); _rClearForNotifies.reset(); restoreInsertOnlyState( ); @@ -1193,7 +1192,7 @@ bool ODatabaseForm::executeRowSet(::osl::ResettableMutexGuard& _rClearForNotifie if (!m_sCurrentErrorContext.isEmpty()) onError(eDB, m_sCurrentErrorContext); else - onError(eDB, FRM_RES_STRING(RID_STR_READERROR)); + onError(eDB, ResourceManager::loadString(RID_STR_READERROR)); _rClearForNotifies.reset(); bSuccess = false; } @@ -1220,7 +1219,7 @@ void ODatabaseForm::disposing() EventObject aEvt(static_cast<XWeak*>(this)); m_aLoadListeners.disposeAndClear(aEvt); m_aRowSetApproveListeners.disposeAndClear(aEvt); - m_aResetListeners.disposing(); + m_aResetListeners.disposeAndClear(aEvt); m_aSubmitListeners.disposeAndClear(aEvt); m_aErrorListeners.disposeAndClear(aEvt); @@ -1290,36 +1289,44 @@ void ODatabaseForm::describeFixedAndAggregateProperties( RemoveProperty( _rAggregateProps, PROPERTY_HAVINGCLAUSE ); RemoveProperty( _rAggregateProps, PROPERTY_APPLYFILTER ); - DECL_IFACE_PROP4( ACTIVE_CONNECTION,XConnection, BOUND, TRANSIENT, MAYBEVOID, CONSTRAINED); - DECL_BOOL_PROP2 ( APPLYFILTER, BOUND, MAYBEDEFAULT ); - DECL_PROP1 ( NAME, OUString, BOUND ); - DECL_PROP1 ( MASTERFIELDS, Sequence< OUString >, BOUND ); - DECL_PROP1 ( DETAILFIELDS, Sequence< OUString >, BOUND ); - DECL_PROP2 ( DATASOURCE, OUString, BOUND, CONSTRAINED ); - DECL_PROP3 ( CYCLE, TabulatorCycle, BOUND, MAYBEVOID, MAYBEDEFAULT ); - DECL_PROP2 ( FILTER, OUString, BOUND, MAYBEDEFAULT ); - DECL_PROP2 ( HAVINGCLAUSE, OUString, BOUND, MAYBEDEFAULT ); - DECL_BOOL_PROP2 ( INSERTONLY, BOUND, MAYBEDEFAULT ); - DECL_PROP1 ( NAVIGATION, NavigationBarMode, BOUND ); - DECL_BOOL_PROP1 ( ALLOWADDITIONS, BOUND ); - DECL_BOOL_PROP1 ( ALLOWEDITS, BOUND ); - DECL_BOOL_PROP1 ( ALLOWDELETIONS, BOUND ); - DECL_PROP2 ( PRIVILEGES, sal_Int32, TRANSIENT, READONLY ); - DECL_PROP1 ( TARGET_URL, OUString, BOUND ); - DECL_PROP1 ( TARGET_FRAME, OUString, BOUND ); - DECL_PROP1 ( SUBMIT_METHOD, FormSubmitMethod, BOUND ); - DECL_PROP1 ( SUBMIT_ENCODING, FormSubmitEncoding, BOUND ); - DECL_BOOL_PROP3 ( DYNAMIC_CONTROL_BORDER, BOUND, MAYBEVOID, MAYBEDEFAULT ); - DECL_PROP3 ( CONTROL_BORDER_COLOR_FOCUS, sal_Int32, BOUND, MAYBEVOID, MAYBEDEFAULT ); - DECL_PROP3 ( CONTROL_BORDER_COLOR_MOUSE, sal_Int32, BOUND, MAYBEVOID, MAYBEDEFAULT ); - DECL_PROP3 ( CONTROL_BORDER_COLOR_INVALID, sal_Int32, BOUND, MAYBEVOID, MAYBEDEFAULT ); - END_DESCRIBE_PROPERTIES(); + *pProperties++ = css::beans::Property(PROPERTY_ACTIVE_CONNECTION, PROPERTY_ID_ACTIVE_CONNECTION, cppu::UnoType<XConnection>::get(), + css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::TRANSIENT | + css::beans::PropertyAttribute::MAYBEVOID | PropertyAttribute::CONSTRAINED); + *pProperties++ = css::beans::Property(PROPERTY_APPLYFILTER, PROPERTY_ID_APPLYFILTER, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_NAME, PROPERTY_ID_NAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_MASTERFIELDS, PROPERTY_ID_MASTERFIELDS, cppu::UnoType<Sequence< OUString >>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_DETAILFIELDS, PROPERTY_ID_DETAILFIELDS, cppu::UnoType<Sequence< OUString >>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_DATASOURCE, PROPERTY_ID_DATASOURCE, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::CONSTRAINED); + *pProperties++ = css::beans::Property(PROPERTY_CYCLE, PROPERTY_ID_CYCLE, cppu::UnoType<TabulatorCycle>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FILTER, PROPERTY_ID_FILTER, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_HAVINGCLAUSE, PROPERTY_ID_HAVINGCLAUSE, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_INSERTONLY, PROPERTY_ID_INSERTONLY, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_NAVIGATION, PROPERTY_ID_NAVIGATION, cppu::UnoType<NavigationBarMode>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_ALLOWADDITIONS, PROPERTY_ID_ALLOWADDITIONS, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_ALLOWEDITS, PROPERTY_ID_ALLOWEDITS, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_ALLOWDELETIONS, PROPERTY_ID_ALLOWDELETIONS, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_PRIVILEGES, PROPERTY_ID_PRIVILEGES, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY); + *pProperties++ = css::beans::Property(PROPERTY_TARGET_URL, PROPERTY_ID_TARGET_URL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TARGET_FRAME, PROPERTY_ID_TARGET_FRAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_SUBMIT_METHOD, PROPERTY_ID_SUBMIT_METHOD, cppu::UnoType<FormSubmitMethod>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_SUBMIT_ENCODING, PROPERTY_ID_SUBMIT_ENCODING, cppu::UnoType<FormSubmitEncoding>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_DYNAMIC_CONTROL_BORDER, PROPERTY_ID_DYNAMIC_CONTROL_BORDER, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID | css::beans::PropertyAttribute::MAYBEDEFAULT ); + *pProperties++ = css::beans::Property(PROPERTY_CONTROL_BORDER_COLOR_FOCUS, PROPERTY_ID_CONTROL_BORDER_COLOR_FOCUS, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_CONTROL_BORDER_COLOR_MOUSE, PROPERTY_ID_CONTROL_BORDER_COLOR_MOUSE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_CONTROL_BORDER_COLOR_INVALID, PROPERTY_ID_CONTROL_BORDER_COLOR_INVALID, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID | css::beans::PropertyAttribute::MAYBEDEFAULT); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } Reference< XMultiPropertySet > ODatabaseForm::getPropertiesInterface() { - return Reference< XMultiPropertySet >( *this, UNO_QUERY ); + return this; } @@ -1607,7 +1614,7 @@ void ODatabaseForm::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const A if ( m_aIgnoreResult.hasValue() ) m_aIgnoreResult <<= m_bInsertOnly; else - m_xAggregateSet->setPropertyValue( PROPERTY_INSERTONLY, makeAny( m_bInsertOnly ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_INSERTONLY, Any( m_bInsertOnly ) ); break; case PROPERTY_ID_FILTER: @@ -1885,7 +1892,7 @@ void SAL_CALL ODatabaseForm::reset() return; } - if ( !m_aResetListeners.empty() ) + if ( m_aResetListeners.getLength() ) { ::osl::MutexGuard aResetGuard(m_aResetSafety); ++m_nResetsPending; @@ -1913,8 +1920,13 @@ void SAL_CALL ODatabaseForm::reset() void ODatabaseForm::reset_impl(bool _bApproveByListeners) { if ( _bApproveByListeners ) - if ( !m_aResetListeners.approveReset() ) - return; + { + ::comphelper::OInterfaceIteratorHelper3 aIter(m_aResetListeners); + EventObject aEvent(*this); + while (aIter.hasMoreElements()) + if (!aIter.next()->approveReset(aEvent)) + return; + } ::osl::ResettableMutexGuard aResetGuard(m_aResetSafety); // do we have a database connected form and stay on the insert row @@ -1941,7 +1953,7 @@ void ODatabaseForm::reset_impl(bool _bApproveByListeners) if ( xColProps.is() ) xPSI = xColProps->getPropertySetInfo( ); - static constexpr OUStringLiteral PROPERTY_CONTROLDEFAULT = u"ControlDefault"; + static constexpr OUString PROPERTY_CONTROLDEFAULT = u"ControlDefault"_ustr; if ( xPSI.is() && xPSI->hasPropertyByName( PROPERTY_CONTROLDEFAULT ) ) { Any aDefault = xColProps->getPropertyValue( PROPERTY_CONTROLDEFAULT ); @@ -2018,7 +2030,8 @@ void ODatabaseForm::reset_impl(bool _bApproveByListeners) aResetGuard.clear(); { - m_aResetListeners.resetted(); + css::lang::EventObject aEvent( *this ); + m_aResetListeners.notifyEach(&css::form::XResetListener::resetted, aEvent); } aResetGuard.reset(); @@ -2033,13 +2046,13 @@ void ODatabaseForm::reset_impl(bool _bApproveByListeners) void SAL_CALL ODatabaseForm::addResetListener(const Reference<XResetListener>& _rListener) { - m_aResetListeners.addTypedListener( _rListener ); + m_aResetListeners.addInterface( _rListener ); } void SAL_CALL ODatabaseForm::removeResetListener(const Reference<XResetListener>& _rListener) { - m_aResetListeners.removeTypedListener( _rListener ); + m_aResetListeners.removeInterface( _rListener ); } @@ -2089,9 +2102,6 @@ static void lcl_dispatch(const Reference< XFrame >& xFrame,const Reference<XURLT if (!xDisp.is()) return; - Sequence<PropertyValue> aArgs(2); - aArgs.getArray()[0].Name = "Referer"; - aArgs.getArray()[0].Value <<= aReferer; // build a sequence from the to-be-submitted string OString a8BitData(OUStringToOString(aData, _eEncoding)); @@ -2099,8 +2109,11 @@ static void lcl_dispatch(const Reference< XFrame >& xFrame,const Reference<XURLT Sequence< sal_Int8 > aPostData(reinterpret_cast<const sal_Int8*>(a8BitData.getStr()), a8BitData.getLength()); Reference< XInputStream > xPostData = new SequenceInputStream(aPostData); - aArgs.getArray()[1].Name = "PostData"; - aArgs.getArray()[1].Value <<= xPostData; + Sequence<PropertyValue> aArgs + { + comphelper::makePropertyValue("Referer", aReferer), + comphelper::makePropertyValue("PostData", xPostData) + }; xDisp->dispatch(aURL, aArgs); } @@ -2108,12 +2121,12 @@ static void lcl_dispatch(const Reference< XFrame >& xFrame,const Reference<XURLT void ODatabaseForm::submit_impl(const Reference<XControl>& Control, const css::awt::MouseEvent& MouseEvt) { - ::comphelper::OInterfaceIteratorHelper2 aIter(m_aSubmitListeners); + ::comphelper::OInterfaceIteratorHelper3 aIter(m_aSubmitListeners); EventObject aEvt(static_cast<XWeak*>(this)); bool bCanceled = false; while (aIter.hasMoreElements() && !bCanceled) { - if (!static_cast<XSubmitListener*>(aIter.next())->approveSubmit(aEvt)) + if (!aIter.next()->approveSubmit(aEvt)) bCanceled = true; } @@ -2179,9 +2192,7 @@ void ODatabaseForm::submit_impl(const Reference<XControl>& Control, const css::a if (xDisp.is()) { - Sequence<PropertyValue> aArgs(1); - aArgs.getArray()->Name = "Referer"; - aArgs.getArray()->Value <<= aReferer; + Sequence<PropertyValue> aArgs { comphelper::makePropertyValue("Referer", aReferer) }; xDisp->dispatch(aURL, aArgs); } } @@ -2212,17 +2223,15 @@ void ODatabaseForm::submit_impl(const Reference<XControl>& Control, const css::a if (!aData.hasElements()) return; - Sequence<PropertyValue> aArgs(3); - aArgs.getArray()[0].Name = "Referer"; - aArgs.getArray()[0].Value <<= aReferer; - aArgs.getArray()[1].Name = "ContentType"; - aArgs.getArray()[1].Value <<= aContentType; - // build a sequence from the to-be-submitted string Reference< XInputStream > xPostData = new SequenceInputStream(aData); - aArgs.getArray()[2].Name = "PostData"; - aArgs.getArray()[2].Value <<= xPostData; + Sequence<PropertyValue> aArgs + { + comphelper::makePropertyValue("Referer", aReferer), + comphelper::makePropertyValue("ContentType", aContentType), + comphelper::makePropertyValue("PostData", xPostData) + }; xDisp->dispatch(aURL, aArgs); } @@ -2354,7 +2363,7 @@ void SAL_CALL ODatabaseForm::setParent(const css::uno::Reference<css::uno::XInte bool bIsEmbedded = ::dbtools::isEmbeddedInDatabase( Parent, xOuterConnection ); if ( bIsEmbedded ) - xAggregateProperties->setPropertyValue( PROPERTY_DATASOURCE, makeAny( OUString() ) ); + xAggregateProperties->setPropertyValue( PROPERTY_DATASOURCE, Any( OUString() ) ); } @@ -2405,7 +2414,7 @@ void SAL_CALL ODatabaseForm::setControlModels(const Sequence<Reference<XControlM { Reference<XPropertySet> xSet(xComp, UNO_QUERY); if (xSet.is() && hasProperty(PROPERTY_TABINDEX, xSet)) - xSet->setPropertyValue( PROPERTY_TABINDEX, makeAny(nTabIndex++) ); + xSet->setPropertyValue( PROPERTY_TABINDEX, Any(nTabIndex++) ); break; } } @@ -2444,7 +2453,7 @@ void SAL_CALL ODatabaseForm::setGroup( const Sequence<Reference<XControlModel> > if (sGroupName.isEmpty()) xSet->getPropertyValue(PROPERTY_NAME) >>= sGroupName; else - xSet->setPropertyValue(PROPERTY_NAME, makeAny(sGroupName)); + xSet->setPropertyValue(PROPERTY_NAME, Any(sGroupName)); } } @@ -2667,7 +2676,7 @@ void ODatabaseForm::doShareConnection( const Reference< XPropertySet >& _rxParen // forward the connection to our own aggregate m_bForwardingConnection = true; - m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xParentConn ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, Any( xParentConn ) ); m_bForwardingConnection = false; m_bSharingConnection = true; @@ -2709,7 +2718,7 @@ void ODatabaseForm::stopSharingConnection( ) // reset the property xSharedConn.clear(); m_bForwardingConnection = true; - m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xSharedConn ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, Any( xSharedConn ) ); m_bForwardingConnection = false; // reset the flag @@ -2744,7 +2753,7 @@ bool ODatabaseForm::implEnsureConnection() Reference< XConnection > xOuterConnection; if ( ::dbtools::isEmbeddedInDatabase( getParent(), xOuterConnection ) ) { - m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xOuterConnection ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, Any( xOuterConnection ) ); return xOuterConnection.is(); } @@ -2787,7 +2796,7 @@ bool ODatabaseForm::implEnsureConnection() } catch(const SQLException& eDB) { - onError(eDB, FRM_RES_STRING(RID_STR_CONNECTERROR)); + onError(eDB, ResourceManager::loadString(RID_STR_CONNECTERROR)); } catch(const Exception&) { @@ -2818,7 +2827,7 @@ void ODatabaseForm::load_impl(bool bCausedByParentForm, bool bMoveToFirst, const // a database form always uses caching // we use starting fetchsize with at least 10 rows if (bConnected) - m_xAggregateSet->setPropertyValue(PROPERTY_FETCHSIZE, makeAny(sal_Int32(40))); + m_xAggregateSet->setPropertyValue(PROPERTY_FETCHSIZE, Any(sal_Int32(40))); // if we're loaded as sub form we got a "rowSetChanged" from the parent rowset _before_ we got the "loaded" // so we don't need to execute the statement again, this was already done @@ -2828,7 +2837,7 @@ void ODatabaseForm::load_impl(bool bCausedByParentForm, bool bMoveToFirst, const bool bSuccess = false; if (bExecute) { - m_sCurrentErrorContext = FRM_RES_STRING(RID_ERR_LOADING_FORM); + m_sCurrentErrorContext = ResourceManager::loadString(RID_ERR_LOADING_FORM); bSuccess = executeRowSet(aGuard, bMoveToFirst, _rxCompletionHandler); } @@ -2916,12 +2925,8 @@ void ODatabaseForm::reload_impl(bool bMoveToFirst, const Reference< XInteraction // the approval is done by the aggregate if (!m_aRowSetApproveListeners.getLength()) { - ::comphelper::OInterfaceIteratorHelper2 aIter(m_aLoadListeners); aGuard.clear(); - - while (aIter.hasMoreElements()) - static_cast<XLoadListener*>(aIter.next())->reloading(aEvent); - + m_aLoadListeners.notifyEach( &XLoadListener::reloading, aEvent); aGuard.reset(); } } @@ -2929,7 +2934,7 @@ void ODatabaseForm::reload_impl(bool bMoveToFirst, const Reference< XInteraction bool bSuccess = true; try { - m_sCurrentErrorContext = FRM_RES_STRING(RID_ERR_REFRESHING_FORM); + m_sCurrentErrorContext = ResourceManager::loadString(RID_ERR_REFRESHING_FORM); bSuccess = executeRowSet(aGuard, bMoveToFirst, _rxCompletionHandler); } catch(const SQLException&) @@ -2939,10 +2944,8 @@ void ODatabaseForm::reload_impl(bool bMoveToFirst, const Reference< XInteraction if (bSuccess) { - ::comphelper::OInterfaceIteratorHelper2 aIter(m_aLoadListeners); aGuard.clear(); - while (aIter.hasMoreElements()) - static_cast<XLoadListener*>(aIter.next())->reloaded(aEvent); + m_aLoadListeners.notifyEach( &XLoadListener::reloaded, aEvent); // if we are on the insert row, we have to reset all controls // to set the default values @@ -3019,14 +3022,11 @@ void SAL_CALL ODatabaseForm::rowSetChanged(const EventObject& /*event*/) bool ODatabaseForm::impl_approveRowChange_throw( const EventObject& _rEvent, const bool _bAllowSQLException, ::osl::ClearableMutexGuard& _rGuard ) { - ::comphelper::OInterfaceIteratorHelper2 aIter( m_aRowSetApproveListeners ); + ::comphelper::OInterfaceIteratorHelper3 aIter( m_aRowSetApproveListeners ); _rGuard.clear(); while ( aIter.hasMoreElements() ) { - Reference< XRowSetApproveListener > xListener( static_cast< XRowSetApproveListener* >( aIter.next() ) ); - if ( !xListener.is() ) - continue; - + Reference< XRowSetApproveListener > xListener( aIter.next() ); try { if ( !xListener->approveRowSetChange( _rEvent ) ) @@ -3064,13 +3064,10 @@ sal_Bool SAL_CALL ODatabaseForm::approveCursorMove(const EventObject& event) // Our aggregate doesn't have any ApproveRowSetListeners (expect ourself), as we re-routed the queryInterface // for XRowSetApproveBroadcaster-interface. // So we have to multiplex this approve request. - ::comphelper::OInterfaceIteratorHelper2 aIter( m_aRowSetApproveListeners ); + ::comphelper::OInterfaceIteratorHelper3 aIter( m_aRowSetApproveListeners ); while ( aIter.hasMoreElements() ) { - Reference< XRowSetApproveListener > xListener( static_cast< XRowSetApproveListener* >( aIter.next() ) ); - if ( !xListener.is() ) - continue; - + Reference< XRowSetApproveListener > xListener( aIter.next() ); try { if ( !xListener->approveCursorMove( event ) ) @@ -3108,38 +3105,34 @@ sal_Bool SAL_CALL ODatabaseForm::approveCursorMove(const EventObject& event) sal_Bool SAL_CALL ODatabaseForm::approveRowChange(const RowChangeEvent& event) { // is our aggregate calling? - if (event.Source == css::uno::Reference<css::uno::XInterface>(static_cast<XWeak*>(this))) + if (event.Source != css::uno::Reference<css::uno::XInterface>(static_cast<XWeak*>(this))) + return true; + + // Our aggregate doesn't have any ApproveRowSetListeners (expect ourself), as we re-routed the queryInterface + // for XRowSetApproveBroadcaster-interface. + // So we have to multiplex this approve request. + ::comphelper::OInterfaceIteratorHelper3 aIter( m_aRowSetApproveListeners ); + while ( aIter.hasMoreElements() ) { - // Our aggregate doesn't have any ApproveRowSetListeners (expect ourself), as we re-routed the queryInterface - // for XRowSetApproveBroadcaster-interface. - // So we have to multiplex this approve request. - ::comphelper::OInterfaceIteratorHelper2 aIter( m_aRowSetApproveListeners ); - while ( aIter.hasMoreElements() ) + Reference< XRowSetApproveListener > xListener( aIter.next() ); + try { - Reference< XRowSetApproveListener > xListener( static_cast< XRowSetApproveListener* >( aIter.next() ) ); - if ( !xListener.is() ) - continue; - - try - { - if ( !xListener->approveRowChange( event ) ) - return false; - } - catch (const DisposedException& e) - { - if ( e.Context == xListener ) - aIter.remove(); - } - catch (const RuntimeException&) - { - throw; - } - catch (const Exception&) - { - DBG_UNHANDLED_EXCEPTION("forms.component"); - } + if ( !xListener->approveRowChange( event ) ) + return false; + } + catch (const DisposedException& e) + { + if ( e.Context == xListener ) + aIter.remove(); + } + catch (const RuntimeException&) + { + throw; + } + catch (const Exception&) + { + DBG_UNHANDLED_EXCEPTION("forms.component"); } - return true; } return true; } @@ -3424,7 +3417,7 @@ void SAL_CALL ODatabaseForm::insertRow() } catch(const SQLException& eDb) { - onError(eDb, FRM_RES_STRING(RID_STR_ERR_INSERTRECORD)); + onError(eDb, ResourceManager::loadString(RID_STR_ERR_INSERTRECORD)); throw; } } @@ -3444,7 +3437,7 @@ void SAL_CALL ODatabaseForm::updateRow() } catch(const SQLException& eDb) { - onError(eDb, FRM_RES_STRING(RID_STR_ERR_UPDATERECORD)); + onError(eDb, ResourceManager::loadString(RID_STR_ERR_UPDATERECORD)); throw; } } @@ -3464,7 +3457,7 @@ void SAL_CALL ODatabaseForm::deleteRow() } catch(const SQLException& eDb) { - onError(eDb, FRM_RES_STRING(RID_STR_ERR_DELETERECORD)); + onError(eDb, ResourceManager::loadString(RID_STR_ERR_DELETERECORD)); throw; } } @@ -3484,7 +3477,7 @@ void SAL_CALL ODatabaseForm::cancelRowUpdates() } catch(const SQLException& eDb) { - onError(eDb, FRM_RES_STRING(RID_STR_ERR_INSERTRECORD)); + onError(eDb, ResourceManager::loadString(RID_STR_ERR_INSERTRECORD)); throw; } } @@ -3548,7 +3541,7 @@ Sequence<sal_Int32> SAL_CALL ODatabaseForm::deleteRows(const Sequence<Any>& rows } catch(const SQLException& eDb) { - onError(eDb, FRM_RES_STRING(RID_STR_ERR_DELETERECORDS)); + onError(eDb, ResourceManager::loadString(RID_STR_ERR_DELETERECORDS)); throw; } @@ -3886,10 +3879,10 @@ void SAL_CALL ODatabaseForm::read(const Reference<XObjectInputStream>& _rxInStre OUString sAggregateProp; _rxInStream >> sAggregateProp; if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_DATASOURCE, makeAny(sAggregateProp)); + m_xAggregateSet->setPropertyValue(PROPERTY_DATASOURCE, Any(sAggregateProp)); _rxInStream >> sAggregateProp; if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_COMMAND, makeAny(sAggregateProp)); + m_xAggregateSet->setPropertyValue(PROPERTY_COMMAND, Any(sAggregateProp)); _rxInStream >> m_aMasterFields; _rxInStream >> m_aDetailFields; @@ -3905,13 +3898,13 @@ void SAL_CALL ODatabaseForm::read(const Reference<XObjectInputStream>& _rxInStre { nCommandType = CommandType::COMMAND; bool bEscapeProcessing = static_cast<DataSelectionType>(nCursorSourceType) != DataSelectionType_SQLPASSTHROUGH; - m_xAggregateSet->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, makeAny(bEscapeProcessing)); + m_xAggregateSet->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, Any(bEscapeProcessing)); } break; default : OSL_FAIL("ODatabaseForm::read : wrong CommandType !"); } if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_COMMANDTYPE, makeAny(nCommandType)); + m_xAggregateSet->setPropertyValue(PROPERTY_COMMANDTYPE, Any(nCommandType)); // obsolete _rxInStream->readShort(); @@ -3924,7 +3917,7 @@ void SAL_CALL ODatabaseForm::read(const Reference<XObjectInputStream>& _rxInStre bool bInsertOnly = _rxInStream->readBoolean(); if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_INSERTONLY, makeAny(bInsertOnly)); + m_xAggregateSet->setPropertyValue(PROPERTY_INSERTONLY, Any(bInsertOnly)); m_bAllowInsert = _rxInStream->readBoolean(); m_bAllowUpdate = _rxInStream->readBoolean(); @@ -3946,12 +3939,12 @@ void SAL_CALL ODatabaseForm::read(const Reference<XObjectInputStream>& _rxInStre _rxInStream >> sAggregateProp; if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_FILTER, makeAny(sAggregateProp)); + m_xAggregateSet->setPropertyValue(PROPERTY_FILTER, Any(sAggregateProp)); if(nVersion > 3) { _rxInStream >> sAggregateProp; if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_SORT, makeAny(sAggregateProp)); + m_xAggregateSet->setPropertyValue(PROPERTY_SORT, Any(sAggregateProp)); } } @@ -3968,13 +3961,13 @@ void SAL_CALL ODatabaseForm::read(const Reference<XObjectInputStream>& _rxInStre m_aCycle.clear(); } if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_APPLYFILTER, makeAny((nAnyMask & DONTAPPLYFILTER) == 0)); + m_xAggregateSet->setPropertyValue(PROPERTY_APPLYFILTER, Any((nAnyMask & DONTAPPLYFILTER) == 0)); if(nVersion > 4) { _rxInStream >> sAggregateProp; if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_HAVINGCLAUSE, makeAny(sAggregateProp)); + m_xAggregateSet->setPropertyValue(PROPERTY_HAVINGCLAUSE, Any(sAggregateProp)); } } @@ -4034,7 +4027,7 @@ OUString SAL_CALL ODatabaseForm::getName() void SAL_CALL ODatabaseForm::setName(const OUString& aName) { - setFastPropertyValue(PROPERTY_ID_NAME, makeAny(aName)); + setFastPropertyValue(PROPERTY_ID_NAME, Any(aName)); } } // namespace frm diff --git a/forms/source/component/DatabaseForm.hxx b/forms/source/component/DatabaseForm.hxx index 4e7a670d0d23..73831a9c67ba 100644 --- a/forms/source/component/DatabaseForm.hxx +++ b/forms/source/component/DatabaseForm.hxx @@ -22,6 +22,7 @@ #include <sal/config.h> #include <string_view> +#include <utility> #include <vector> #include <propertybaghelper.hxx> @@ -62,7 +63,7 @@ #include <connectivity/filtermanager.hxx> #include <connectivity/warningscontainer.hxx> -#include <listenercontainers.hxx> +#include <comphelper/interfacecontainer3.hxx> #include <comphelper/propmultiplex.hxx> #include <comphelper/uno3.hxx> #include <cppuhelper/implbase12.hxx> @@ -94,10 +95,10 @@ public: OUString aValue; sal_uInt16 nRepresentation; - HtmlSuccessfulObj( const OUString& _rName, const OUString& _rValue, + HtmlSuccessfulObj( OUString _aName, OUString _aValue, sal_uInt16 _nRepresent = SUCCESSFUL_REPRESENT_TEXT ) - :aName( _rName ) - ,aValue( _rValue ) + :aName(std::move( _aName )) + ,aValue(std::move( _aValue )) ,nRepresentation( _nRepresent ) { } @@ -149,11 +150,11 @@ class ODatabaseForm :public OFormComponents friend class OFormSubmitResetThread; // listener administration - ::comphelper::OInterfaceContainerHelper2 m_aLoadListeners; - ::comphelper::OInterfaceContainerHelper2 m_aRowSetApproveListeners; - ::comphelper::OInterfaceContainerHelper2 m_aSubmitListeners; - ::comphelper::OInterfaceContainerHelper2 m_aErrorListeners; - ResetListeners m_aResetListeners; + ::comphelper::OInterfaceContainerHelper3<css::form::XLoadListener> m_aLoadListeners; + ::comphelper::OInterfaceContainerHelper3<css::sdb::XRowSetApproveListener> m_aRowSetApproveListeners; + ::comphelper::OInterfaceContainerHelper3<css::form::XSubmitListener> m_aSubmitListeners; + ::comphelper::OInterfaceContainerHelper3<css::sdb::XSQLErrorListener> m_aErrorListeners; + ::comphelper::OInterfaceContainerHelper3<css::form::XResetListener> m_aResetListeners; ::osl::Mutex m_aResetSafety; css::uno::Any m_aCycle; css::uno::Any m_aIgnoreResult; // set when we are a subform and our master form positioned on a new row diff --git a/forms/source/component/Date.cxx b/forms/source/component/Date.cxx index 1d16109ce672..a349cd064cd1 100644 --- a/forms/source/component/Date.cxx +++ b/forms/source/component/Date.cxx @@ -20,9 +20,11 @@ #include "Date.hxx" #include <property.hxx> #include <services.hxx> -#include <tools/diagnose_ex.h> +#include <tools/debug.hxx> +#include <comphelper/diagnose_ex.hxx> #include <connectivity/dbconversion.hxx> #include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> using namespace dbtools; @@ -37,11 +39,7 @@ using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::util; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::io; -using namespace ::com::sun::star::lang; ODateControl::ODateControl(const Reference<XComponentContext>& _rxFactory) @@ -71,7 +69,7 @@ Sequence<Type> ODateModel::_getTypes() ODateModel::ODateModel(const Reference<XComponentContext>& _rxFactory) : OEditBaseModel(_rxFactory, VCL_CONTROLMODEL_DATEFIELD, FRM_SUN_CONTROL_DATEFIELD, true, true) - // use the old control name for compytibility reasons + // use the old control name for compatibility reasons , OLimitedFormats(_rxFactory, FormComponentType::DATEFIELD) , m_bDateTimeField(false) { @@ -84,7 +82,7 @@ ODateModel::ODateModel(const Reference<XComponentContext>& _rxFactory) try { if ( m_xAggregateSet.is() ) - m_xAggregateSet->setPropertyValue( PROPERTY_DATEMIN, makeAny(util::Date(1, 1, 1800)) ); + m_xAggregateSet->setPropertyValue( PROPERTY_DATEMIN, Any(util::Date(1, 1, 1800)) ); } catch( const Exception& ) { @@ -110,7 +108,12 @@ ODateModel::~ODateModel( ) // XCloneable -IMPLEMENT_DEFAULT_CLONING( ODateModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL ODateModel::createClone() +{ + rtl::Reference<ODateModel> pClone = new ODateModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} // XServiceInfo @@ -141,12 +144,16 @@ OUString SAL_CALL ODateModel::getServiceName() void ODateModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 4, OEditBaseModel ) - DECL_PROP3(DEFAULT_DATE, util::Date, BOUND, MAYBEDEFAULT, MAYBEVOID); - DECL_PROP1(TABINDEX, sal_Int16, BOUND); - DECL_PROP1(FORMATKEY, sal_Int32, TRANSIENT); - DECL_IFACE_PROP2(FORMATSSUPPLIER, XNumberFormatsSupplier, READONLY, TRANSIENT); - END_DESCRIBE_PROPERTIES(); + OEditBaseModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 4); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_DEFAULT_DATE, PROPERTY_ID_DEFAULT_DATE, cppu::UnoType<util::Date>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT | css::beans::PropertyAttribute::MAYBEVOID); + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_FORMATKEY, PROPERTY_ID_FORMATKEY, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_FORMATSSUPPLIER, PROPERTY_ID_FORMATSSUPPLIER, cppu::UnoType<XNumberFormatsSupplier>::get(), + css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } @@ -210,40 +217,40 @@ void ODateModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm ) bool ODateModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) { Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) ); - if ( aControlValue != m_aSaveValue ) + if ( aControlValue == m_aSaveValue ) + return true; + + if ( !aControlValue.hasValue() ) + m_xColumnUpdate->updateNull(); + else { - if ( !aControlValue.hasValue() ) - m_xColumnUpdate->updateNull(); - else + try { - try + util::Date aDate; + if ( !( aControlValue >>= aDate ) ) { - util::Date aDate; - if ( !( aControlValue >>= aDate ) ) - { - sal_Int32 nAsInt(0); - aControlValue >>= nAsInt; - aDate = DBTypeConversion::toDate(nAsInt); - } - - if ( !m_bDateTimeField ) - m_xColumnUpdate->updateDate( aDate ); - else - { - util::DateTime aDateTime = m_xColumn->getTimestamp(); - aDateTime.Day = aDate.Day; - aDateTime.Month = aDate.Month; - aDateTime.Year = aDate.Year; - m_xColumnUpdate->updateTimestamp( aDateTime ); - } + sal_Int32 nAsInt(0); + aControlValue >>= nAsInt; + aDate = DBTypeConversion::toDate(nAsInt); } - catch(const Exception&) + + if ( !m_bDateTimeField ) + m_xColumnUpdate->updateDate( aDate ); + else { - return false; + util::DateTime aDateTime = m_xColumn->getTimestamp(); + aDateTime.Day = aDate.Day; + aDateTime.Month = aDate.Month; + aDateTime.Year = aDate.Year; + m_xColumnUpdate->updateTimestamp( aDateTime ); } } - m_aSaveValue = aControlValue; + catch(const Exception&) + { + return false; + } } + m_aSaveValue = aControlValue; return true; } diff --git a/forms/source/component/Date.hxx b/forms/source/component/Date.hxx index 36a04acc79fa..77d4d8a3e033 100644 --- a/forms/source/component/Date.hxx +++ b/forms/source/component/Date.hxx @@ -37,7 +37,15 @@ protected: virtual css::uno::Sequence< css::uno::Type> _getTypes() override; public: - DECLARE_DEFAULT_LEAF_XTOR( ODateModel ); + ODateModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + ODateModel( + const ODateModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~ODateModel() override; + // XPersistObject virtual OUString SAL_CALL getServiceName() override; diff --git a/forms/source/component/Edit.cxx b/forms/source/component/Edit.cxx index e1eefb02f396..b1b81b0bbcfd 100644 --- a/forms/source/component/Edit.cxx +++ b/forms/source/component/Edit.cxx @@ -22,6 +22,7 @@ #include <property.hxx> #include <services.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/uno/Type.hxx> #include <com/sun/star/awt/XWindow.hpp> @@ -36,7 +37,8 @@ #include <comphelper/property.hxx> #include <comphelper/types.hxx> -#include <tools/diagnose_ex.h> +#include <tools/debug.hxx> +#include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> using namespace dbtools; @@ -53,7 +55,6 @@ using namespace ::com::sun::star::awt; using namespace ::com::sun::star::io; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; -using namespace ::com::sun::star::form::binding; Sequence<Type> OEditControl::_getTypes() @@ -288,7 +289,12 @@ OEditModel::~OEditModel() } -IMPLEMENT_DEFAULT_CLONING( OEditModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL OEditModel::createClone() +{ + rtl::Reference<OEditModel> pClone = new OEditModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} void OEditModel::disposing() @@ -349,13 +355,18 @@ void SAL_CALL OEditModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) void OEditModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 5, OEditBaseModel ) - DECL_PROP2(PERSISTENCE_MAXTEXTLENGTH,sal_Int16, READONLY, TRANSIENT); - DECL_PROP2(DEFAULT_TEXT, OUString, BOUND, MAYBEDEFAULT); - DECL_BOOL_PROP1(EMPTY_IS_NULL, BOUND); - DECL_PROP1(TABINDEX, sal_Int16, BOUND); - DECL_BOOL_PROP2(FILTERPROPOSAL, BOUND, MAYBEDEFAULT); - END_DESCRIBE_PROPERTIES(); + OEditBaseModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 5); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_PERSISTENCE_MAXTEXTLENGTH, PROPERTY_ID_PERSISTENCE_MAXTEXTLENGTH, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_DEFAULT_TEXT, PROPERTY_ID_DEFAULT_TEXT, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_EMPTY_IS_NULL, PROPERTY_ID_EMPTY_IS_NULL, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_FILTERPROPOSAL, PROPERTY_ID_FILTERPROPOSAL, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } @@ -370,6 +381,7 @@ void OEditModel::describeAggregateProperties( Sequence< Property >& _rAggregateP RemoveProperty( _rAggregateProps, PROPERTY_NAME ); RemoveProperty( _rAggregateProps, PROPERTY_TAG ); RemoveProperty( _rAggregateProps, PROPERTY_NATIVE_LOOK ); + RemoveProperty( _rAggregateProps, PROPERTY_STANDARD_THEME ); } @@ -502,19 +514,19 @@ void OEditModel::write(const Reference<XObjectOutputStream>& _rxOutStream) aCurrentText = m_xAggregateSet->getPropertyValue(PROPERTY_TEXT); m_xAggregateSet->getPropertyValue(PROPERTY_MAXTEXTLEN) >>= nOldTextLen; - m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, makeAny(sal_Int16(0))); + m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, Any(sal_Int16(0))); } OEditBaseModel::write(_rxOutStream); if ( m_bMaxTextLenModified ) { // Reset again - m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, makeAny(nOldTextLen)); + m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, Any(nOldTextLen)); // and reset the text // First we set it to an empty string : Without this the second setPropertyValue would not do anything as it thinks // we aren't changing the prop (it didn't notify the - implicit - change of the text prop while setting the max text len) // This seems to be a bug with in toolkit's EditControl-implementation. - m_xAggregateSet->setPropertyValue(PROPERTY_TEXT, makeAny(OUString())); + m_xAggregateSet->setPropertyValue(PROPERTY_TEXT, Any(OUString())); m_xAggregateSet->setPropertyValue(PROPERTY_TEXT, aCurrentText); } } @@ -534,7 +546,7 @@ void OEditModel::read(const Reference<XObjectInputStream>& _rxInStream) && (getString(aDefaultControl) == STARDIV_ONE_FORM_CONTROL_TEXTFIELD ) ) { - m_xAggregateSet->setPropertyValue( PROPERTY_DEFAULTCONTROL, makeAny( OUString(STARDIV_ONE_FORM_CONTROL_EDIT) ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_DEFAULTCONTROL, Any( STARDIV_ONE_FORM_CONTROL_EDIT ) ); // Older as well as current versions should understand this : the former knew only the STARDIV_ONE_FORM_CONTROL_EDIT, // the latter are registered for both STARDIV_ONE_FORM_CONTROL_EDIT and STARDIV_ONE_FORM_CONTROL_TEXTFIELD. } @@ -670,20 +682,20 @@ Any OEditModel::translateDbColumnToControlValue() if ( nMaxTextLen && sValue.getLength() > nMaxTextLen ) { sal_Int32 nDiff = sValue.getLength() - nMaxTextLen; - sValue = sValue.replaceAt( nMaxTextLen, nDiff, OUString() ); + sValue = sValue.replaceAt( nMaxTextLen, nDiff, u"" ); } aRet <<= sValue; } } - return aRet.hasValue() ? aRet : makeAny( OUString() ); + return aRet.hasValue() ? aRet : Any( OUString() ); } Any OEditModel::getDefaultForReset() const { - return makeAny( m_aDefaultText ); + return Any( m_aDefaultText ); } } diff --git a/forms/source/component/Edit.hxx b/forms/source/component/Edit.hxx index 998a44aacf55..219b41d21d17 100644 --- a/forms/source/component/Edit.hxx +++ b/forms/source/component/Edit.hxx @@ -23,6 +23,7 @@ #include "EditBase.hxx" #include <tools/link.hxx> +#include <comphelper/interfacecontainer3.hxx> #include <cppuhelper/implbase3.hxx> #include <com/sun/star/form/XChangeBroadcaster.hpp> @@ -42,7 +43,14 @@ class OEditModel final : public OEditBaseModel bool m_bWritingFormattedFake : 1; // are we writing something which should be interpreted as formatted upon reading? public: - DECLARE_DEFAULT_LEAF_XTOR( OEditModel ); + OEditModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OEditModel( + const OEditModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OEditModel() override; private: void enableFormattedWriteFake() { m_bWritingFormattedFake = true; } @@ -119,7 +127,7 @@ typedef ::cppu::ImplHelper3< css::awt::XFocusListener, class OEditControl : public OBoundControl ,public OEditControl_BASE { - ::comphelper::OInterfaceContainerHelper2 + ::comphelper::OInterfaceContainerHelper3<css::form::XChangeListener> m_aChangeListeners; OUString m_aHtmlChangeValue; diff --git a/forms/source/component/EditBase.cxx b/forms/source/component/EditBase.cxx index 80e8d245c95d..faf27cf3f0f7 100644 --- a/forms/source/component/EditBase.cxx +++ b/forms/source/component/EditBase.cxx @@ -36,12 +36,7 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::form; -using namespace ::com::sun::star::awt; using namespace ::com::sun::star::io; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; namespace @@ -358,9 +353,9 @@ Any OEditBaseModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const switch (nHandle) { case PROPERTY_ID_DEFAULT_TEXT: - return makeAny(OUString()); + return Any(OUString()); case PROPERTY_ID_FILTERPROPOSAL: - return makeAny(false); + return Any(false); case PROPERTY_ID_DEFAULT_VALUE: case PROPERTY_ID_DEFAULT_DATE: case PROPERTY_ID_DEFAULT_TIME: diff --git a/forms/source/component/EditBase.hxx b/forms/source/component/EditBase.hxx index 67e88a433b27..c74476bc038c 100644 --- a/forms/source/component/EditBase.hxx +++ b/forms/source/component/EditBase.hxx @@ -57,7 +57,12 @@ public: const bool _bSupportExternalBinding, const bool _bSupportsValidation ); - DECLARE_DEFAULT_CLONE_CTOR( OEditBaseModel ) + + OEditBaseModel( + const OEditBaseModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OEditBaseModel() override; // XPersistObject diff --git a/forms/source/component/EventThread.cxx b/forms/source/component/EventThread.cxx index 0b38e33f7a4d..2d5336fe384b 100644 --- a/forms/source/component/EventThread.cxx +++ b/forms/source/component/EventThread.cxx @@ -79,7 +79,7 @@ void OComponentEventThread::disposing( const EventObject& evt ) if( evt.Source != static_cast<XWeak*>(m_xComp.get()) ) return; - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); // Remove EventListener Reference<XEventListener> xEvtLstnr = static_cast<XEventListener*>(this); @@ -107,7 +107,7 @@ void OComponentEventThread::addEvent( std::unique_ptr<EventObject> _pEvt, const Reference<XControl>& rControl, bool bFlag ) { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); // Put data into the queue m_aEvents.push_back( std::move( _pEvt ) ); @@ -140,7 +140,7 @@ void OComponentEventThread::run() do { - ::osl::MutexGuard aGuard(m_aMutex); + std::unique_lock aGuard(m_aMutex); while( !m_aEvents.empty() ) { @@ -160,7 +160,7 @@ void OComponentEventThread::run() m_aFlags.erase( firstFlag ); { - MutexRelease aReleaseOnce(m_aMutex); + aGuard.unlock(); // Because a queryHardRef can throw an Exception, it should not be called when // the mutex is locked. Reference<XControl> xControl; @@ -170,6 +170,7 @@ void OComponentEventThread::run() if( xComp.is() ) processEvent( xComp.get(), pEvt.get(), xControl, bFlag ); + aGuard.lock(); } } @@ -181,9 +182,10 @@ void OComponentEventThread::run() // Reset waiting condition m_aCond.reset(); { - MutexRelease aReleaseOnce(m_aMutex); + aGuard.unlock(); // And wait ... if, in the meantime, an Event came in after all m_aCond.wait(); + aGuard.lock(); } } while( true ); diff --git a/forms/source/component/EventThread.hxx b/forms/source/component/EventThread.hxx index 20aff73113db..df7b33ee134f 100644 --- a/forms/source/component/EventThread.hxx +++ b/forms/source/component/EventThread.hxx @@ -22,6 +22,7 @@ #include <sal/config.h> #include <memory> +#include <mutex> #include <vector> #include <com/sun/star/lang/XEventListener.hpp> @@ -50,7 +51,7 @@ class OComponentEventThread typedef std::vector<std::unique_ptr<css::lang::EventObject>> ThreadEvents; typedef std::vector< css::uno::Reference< css::uno::XAdapter> > ThreadObjects; - ::osl::Mutex m_aMutex; + std::mutex m_aMutex; ::osl::Condition m_aCond; // Queue filled? ThreadEvents m_aEvents; // EventQueue ThreadObjects m_aControls; // Control for Submit diff --git a/forms/source/component/File.cxx b/forms/source/component/File.cxx index e92f168d3de3..51e1ac47e970 100644 --- a/forms/source/component/File.cxx +++ b/forms/source/component/File.cxx @@ -19,6 +19,7 @@ #include "File.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <property.hxx> @@ -38,9 +39,7 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; -using namespace ::com::sun::star::awt; using namespace ::com::sun::star::io; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; @@ -95,7 +94,12 @@ OFileControlModel::~OFileControlModel() } -IMPLEMENT_DEFAULT_CLONING( OFileControlModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL OFileControlModel::createClone() +{ + rtl::Reference<OFileControlModel> pClone = new OFileControlModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} Any SAL_CALL OFileControlModel::queryAggregation(const Type& _rType) @@ -125,7 +129,7 @@ Any OFileControlModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const switch ( _nHandle ) { case PROPERTY_ID_DEFAULT_TEXT: - return makeAny( OUString() ); + return Any( OUString() ); } return OControlModel::getPropertyDefaultByHandle( _nHandle ); } @@ -170,10 +174,13 @@ sal_Bool OFileControlModel::convertFastPropertyValue(Any& rConvertedValue, Any& void OFileControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 2, OControlModel ) - DECL_PROP1(DEFAULT_TEXT, OUString, BOUND); - DECL_PROP1(TABINDEX, sal_Int16, BOUND); - END_DESCRIBE_PROPERTIES(); + OControlModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 2); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_DEFAULT_TEXT, PROPERTY_ID_DEFAULT_TEXT, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } @@ -225,18 +232,18 @@ void OFileControlModel::read(const Reference<css::io::XObjectInputStream>& _rxIn void SAL_CALL OFileControlModel::reset() { - ::comphelper::OInterfaceIteratorHelper2 aIter(m_aResetListeners); + ::comphelper::OInterfaceIteratorHelper3 aIter(m_aResetListeners); EventObject aEvt(static_cast<XWeak*>(this)); bool bContinue = true; while (aIter.hasMoreElements() && bContinue) - bContinue = static_cast<XResetListener*>(aIter.next())->approveReset(aEvt); + bContinue = aIter.next()->approveReset(aEvt); if (bContinue) { // don't lock our mutex as setting aggregate properties // may cause any uno controls belonging to us to lock the solar mutex, which is potentially dangerous with // our own mutex locked - m_xAggregateSet->setPropertyValue(PROPERTY_TEXT, makeAny(m_sDefaultValue)); + m_xAggregateSet->setPropertyValue(PROPERTY_TEXT, Any(m_sDefaultValue)); m_aResetListeners.notifyEach( &XResetListener::resetted, aEvt ); } } diff --git a/forms/source/component/File.hxx b/forms/source/component/File.hxx index a2bf28d6214c..6ef7532aa842 100644 --- a/forms/source/component/File.hxx +++ b/forms/source/component/File.hxx @@ -20,6 +20,7 @@ #pragma once #include <FormComponent.hxx> +#include <comphelper/interfacecontainer3.hxx> namespace frm @@ -29,14 +30,21 @@ class OFileControlModel :public OControlModel ,public css::form::XReset { - ::comphelper::OInterfaceContainerHelper2 m_aResetListeners; + ::comphelper::OInterfaceContainerHelper3<css::form::XResetListener> m_aResetListeners; OUString m_sDefaultValue; protected: virtual css::uno::Sequence< css::uno::Type> _getTypes() override; public: - DECLARE_DEFAULT_LEAF_XTOR( OFileControlModel ); + OFileControlModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OFileControlModel( + const OFileControlModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OFileControlModel() override; DECLARE_UNO3_AGG_DEFAULTS(OFileControlModel, OControlModel) virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type& _rType) override; diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx index ce137f3bb1ca..bf33ce4ae8b8 100644 --- a/forms/source/component/Filter.cxx +++ b/forms/source/component/Filter.cxx @@ -22,8 +22,6 @@ #include <config_features.h> #include <config_fuzzers.h> -#include <string_view> - #include "Filter.hxx" #include <strings.hrc> #include <frm_resource.hxx> @@ -58,7 +56,7 @@ #include <connectivity/predicateinput.hxx> #include <o3tl/safeint.hxx> #include <rtl/ustrbuf.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <tools/gen.hxx> @@ -76,8 +74,6 @@ namespace frm using namespace ::com::sun::star::container; using namespace ::com::sun::star::ui::dialogs; - using namespace ::connectivity; - OFilterControl::OFilterControl( const Reference< XComponentContext >& _rxORB ) :m_aTextListeners( *this ) ,m_xContext( _rxORB ) @@ -137,7 +133,7 @@ namespace frm } - OUString OFilterControl::GetComponentServiceName() + OUString OFilterControl::GetComponentServiceName() const { OUString aServiceName; switch (m_nControlClass) @@ -185,8 +181,8 @@ namespace frm case FormComponentType::CHECKBOX: { // checkboxes always have a tristate-mode - xVclWindow->setProperty( PROPERTY_TRISTATE, makeAny( true ) ); - xVclWindow->setProperty( PROPERTY_STATE, makeAny( sal_Int32( TRISTATE_INDET ) ) ); + xVclWindow->setProperty( PROPERTY_TRISTATE, Any( true ) ); + xVclWindow->setProperty( PROPERTY_STATE, Any( sal_Int32( TRISTATE_INDET ) ) ); Reference< XCheckBox > xBox( getPeer(), UNO_QUERY_THROW ); xBox->addItemListener( this ); @@ -196,7 +192,7 @@ namespace frm case FormComponentType::RADIOBUTTON: { - xVclWindow->setProperty( PROPERTY_STATE, makeAny( sal_Int32( TRISTATE_FALSE ) ) ); + xVclWindow->setProperty( PROPERTY_STATE, Any( sal_Int32( TRISTATE_FALSE ) ) ); Reference< XRadioButton > xRadio( getPeer(), UNO_QUERY_THROW ); xRadio->addItemListener( this ); @@ -212,7 +208,7 @@ namespace frm case FormComponentType::COMBOBOX: { - xVclWindow->setProperty(PROPERTY_AUTOCOMPLETE, makeAny( true ) ); + xVclWindow->setProperty(PROPERTY_AUTOCOMPLETE, Any( true ) ); [[fallthrough]]; } @@ -232,7 +228,7 @@ namespace frm Reference< XPropertySet > xModel( getModel(), UNO_QUERY_THROW ); Reference< XPropertySetInfo > xModelPSI( xModel->getPropertySetInfo(), UNO_SET_THROW ); if ( xModelPSI->hasPropertyByName( PROPERTY_READONLY ) ) - xVclWindow->setProperty( PROPERTY_READONLY, makeAny( false ) ); + xVclWindow->setProperty( PROPERTY_READONLY, Any( false ) ); } catch( const Exception& ) { @@ -357,9 +353,7 @@ namespace frm m_aText = sText; TextEvent aEvt; aEvt.Source = *this; - ::comphelper::OInterfaceIteratorHelper2 aIt( m_aTextListeners ); - while( aIt.hasMoreElements() ) - static_cast<XTextListener *>(aIt.next())->textChanged( aEvt ); + m_aTextListeners.notifyEach(&css::awt::XTextListener::textChanged, aEvt); } #endif } @@ -416,18 +410,16 @@ namespace frm const Reference< XDatabaseMetaData > xMeta( xConnection->getMetaData(), UNO_SET_THROW ); const OUString sQuoteChar = xMeta->getIdentifierQuoteString(); - aStatement.append( "SELECT DISTINCT " ); - aStatement.append( sQuoteChar ); - aStatement.append( sRealFieldName ); - aStatement.append( sQuoteChar ); + aStatement.append( + "SELECT DISTINCT " + + sQuoteChar + + sRealFieldName + + sQuoteChar ); // if the field had an alias in our form's statement, give it this alias in the new statement, too if ( !sFieldName.isEmpty() && ( sFieldName != sRealFieldName ) ) { - aStatement.append(" AS "); - aStatement.append( sQuoteChar ); - aStatement.append( sFieldName ); - aStatement.append( sQuoteChar ); + aStatement.append(" AS "+ sQuoteChar + sFieldName + sQuoteChar ); } aStatement.append( " FROM " ); @@ -510,32 +502,27 @@ namespace frm default: return true; } - if ( m_aText != aText ) + if ( m_aText == aText ) + return true; + // check the text with the SQL-Parser + OUString aNewText = aText.trim(); + if ( !aNewText.isEmpty() ) { - // check the text with the SQL-Parser - OUString aNewText = aText.trim(); - if ( !aNewText.isEmpty() ) + ::dbtools::OPredicateInputController aPredicateInput( m_xContext, m_xConnection, getParseContext() ); + OUString sErrorMessage; + if ( !aPredicateInput.normalizePredicateString( aNewText, m_xField, &sErrorMessage ) ) { - ::dbtools::OPredicateInputController aPredicateInput( m_xContext, m_xConnection, getParseContext() ); - OUString sErrorMessage; - if ( !aPredicateInput.normalizePredicateString( aNewText, m_xField, &sErrorMessage ) ) - { - // display the error and outta here - SQLContext aError; - aError.Message = FRM_RES_STRING( RID_STR_SYNTAXERROR ); - aError.Details = sErrorMessage; - displayException( aError ); - return false; - } + // display the error and outta here + SQLContext aError(ResourceManager::loadString(RID_STR_SYNTAXERROR), {}, {}, 0, {}, sErrorMessage); + displayException( aError ); + return false; } - - setText(aNewText); - TextEvent aEvt; - aEvt.Source = *this; - ::comphelper::OInterfaceIteratorHelper2 aIt( m_aTextListeners ); - while( aIt.hasMoreElements() ) - static_cast< XTextListener* >( aIt.next() )->textChanged( aEvt ); } + + setText(aNewText); + TextEvent aEvt; + aEvt.Source = *this; + m_aTextListeners.notifyEach(&css::awt::XTextListener::textChanged, aEvt); #endif return true; } @@ -733,7 +720,7 @@ namespace frm { try { - Reference< XExecutableDialog > xErrorDialog = ErrorMessageDialog::create( m_xContext, "", m_xMessageParent, makeAny(_rExcept)); + Reference< XExecutableDialog > xErrorDialog = ErrorMessageDialog::create( m_xContext, "", m_xMessageParent, Any(_rExcept)); xErrorDialog->execute(); } catch( const Exception& ) diff --git a/forms/source/component/Filter.hxx b/forms/source/component/Filter.hxx index 8561d2f5d5af..8815f5f11a02 100644 --- a/forms/source/component/Filter.hxx +++ b/forms/source/component/Filter.hxx @@ -80,7 +80,7 @@ namespace frm DECLARE_UNO3_AGG_DEFAULTS(OFilterControl,OWeakAggObject) css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override; - virtual OUString GetComponentServiceName() override; + virtual OUString GetComponentServiceName() const override; virtual void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit > & rxToolkit, const css::uno::Reference< css::awt::XWindowPeer > & rParentPeer ) override; // css::lang::XComponent diff --git a/forms/source/component/FixedText.cxx b/forms/source/component/FixedText.cxx index 67fa5288ef75..012ba04493db 100644 --- a/forms/source/component/FixedText.cxx +++ b/forms/source/component/FixedText.cxx @@ -32,11 +32,8 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; -using namespace ::com::sun::star::awt; using namespace ::com::sun::star::io; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; using namespace comphelper; @@ -60,7 +57,12 @@ OFixedTextModel::~OFixedTextModel( ) } -IMPLEMENT_DEFAULT_CLONING( OFixedTextModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL OFixedTextModel::createClone() +{ + rtl::Reference<OFixedTextModel> pClone = new OFixedTextModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} css::uno::Sequence<OUString> SAL_CALL OFixedTextModel::getSupportedServiceNames() diff --git a/forms/source/component/FixedText.hxx b/forms/source/component/FixedText.hxx index a6d6f0b2d5c1..a4bafab60d27 100644 --- a/forms/source/component/FixedText.hxx +++ b/forms/source/component/FixedText.hxx @@ -29,7 +29,14 @@ class OFixedTextModel :public OControlModel { public: - DECLARE_DEFAULT_LEAF_XTOR( OFixedTextModel ); + OFixedTextModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OFixedTextModel( + const OFixedTextModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OFixedTextModel() override; // XServiceInfo OUString SAL_CALL getImplementationName() override diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index 0f67f8433e95..a5ae6c07cec4 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -25,6 +25,7 @@ #include <com/sun/star/awt/XTextComponent.hpp> #include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/form/XForm.hpp> #include <com/sun/star/form/XLoadable.hpp> @@ -43,13 +44,12 @@ #include <comphelper/basicio.hxx> #include <comphelper/guarding.hxx> -#include <comphelper/interfacecontainer2.hxx> #include <comphelper/property.hxx> #include <connectivity/dbtools.hxx> #include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/supportsservice.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> #include <algorithm> @@ -103,7 +103,7 @@ public: { Reference< XPropertySet > xNewField( m_rModel.getField() ); if ( m_xOldField != xNewField ) - m_rLock.addPropertyNotification( PROPERTY_ID_BOUNDFIELD, makeAny( m_xOldField ), makeAny( xNewField ) ); + m_rLock.addPropertyNotification( PROPERTY_ID_BOUNDFIELD, Any( m_xOldField ), Any( xNewField ) ); } private: @@ -459,7 +459,7 @@ void OControlModel::readHelpTextCompatibly(const css::uno::Reference< css::io::X try { if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_HELPTEXT, makeAny(sHelpText)); + m_xAggregateSet->setPropertyValue(PROPERTY_HELPTEXT, Any(sHelpText)); } catch(const Exception&) { @@ -496,6 +496,7 @@ OControlModel::OControlModel( ,m_nTabIndex(FRM_DEFAULT_TABINDEX) ,m_nClassId(FormComponentType::CONTROL) ,m_bNativeLook( false ) + ,m_bStandardTheme( false ) ,m_bGenerateVbEvents( false ) ,m_nControlTypeinMSO(0) // 0 : default value is create from AOO ,m_nObjIDinMSO(INVALID_OBJ_ID_IN_MSO) @@ -516,7 +517,7 @@ OControlModel::OControlModel( try { if ( !rDefault.isEmpty() ) - m_xAggregateSet->setPropertyValue( PROPERTY_DEFAULTCONTROL, makeAny( rDefault ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_DEFAULTCONTROL, Any( rDefault ) ); } catch( const Exception& ) { @@ -548,6 +549,7 @@ OControlModel::OControlModel( const OControlModel* _pOriginal, const Reference< m_nTabIndex = _pOriginal->m_nTabIndex; m_nClassId = _pOriginal->m_nClassId; m_bNativeLook = _pOriginal->m_bNativeLook; + m_bStandardTheme = _pOriginal->m_bStandardTheme; m_bGenerateVbEvents = _pOriginal->m_bGenerateVbEvents; m_nControlTypeinMSO = _pOriginal->m_nControlTypeinMSO; m_nObjIDinMSO = _pOriginal->m_nObjIDinMSO; @@ -645,7 +647,7 @@ void SAL_CALL OControlModel::setName(const OUString& _rName) { try { - setFastPropertyValue(PROPERTY_ID_NAME, makeAny(_rName)); + setFastPropertyValue(PROPERTY_ID_NAME, Any(_rName)); } catch (const css::beans::UnknownPropertyException&) { @@ -743,7 +745,7 @@ void SAL_CALL OControlModel::write(const Reference<css::io::XObjectOutputStream> if ( !xMark.is() ) { throw IOException( - FRM_RES_STRING( RID_STR_INVALIDSTREAM ), + ResourceManager::loadString(RID_STR_INVALIDSTREAM), static_cast< ::cppu::OWeakObject* >( this ) ); } @@ -786,7 +788,7 @@ void OControlModel::read(const Reference<css::io::XObjectInputStream>& InStream) if ( !xMark.is() ) { throw IOException( - FRM_RES_STRING( RID_STR_INVALIDSTREAM ), + ResourceManager::loadString(RID_STR_INVALIDSTREAM), static_cast< ::cppu::OWeakObject* >( this ) ); } @@ -871,6 +873,9 @@ Any OControlModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const case PROPERTY_ID_NATIVE_LOOK: aReturn <<= true; break; + case PROPERTY_ID_STANDARD_THEME: + aReturn <<= false; + break; case PROPERTY_ID_GENERATEVBAEVENTS: aReturn <<= false; break; @@ -909,6 +914,9 @@ void OControlModel::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) con case PROPERTY_ID_NATIVE_LOOK: _rValue <<= m_bNativeLook; break; + case PROPERTY_ID_STANDARD_THEME: + _rValue <<= m_bStandardTheme; + break; case PROPERTY_ID_GENERATEVBAEVENTS: _rValue <<= m_bGenerateVbEvents; break; @@ -946,6 +954,9 @@ sal_Bool OControlModel::convertFastPropertyValue( case PROPERTY_ID_NATIVE_LOOK: bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_bNativeLook); break; + case PROPERTY_ID_STANDARD_THEME: + bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_bStandardTheme); + break; case PROPERTY_ID_GENERATEVBAEVENTS: bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_bGenerateVbEvents); break; @@ -988,6 +999,9 @@ void OControlModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const A case PROPERTY_ID_NATIVE_LOOK: OSL_VERIFY( _rValue >>= m_bNativeLook ); break; + case PROPERTY_ID_STANDARD_THEME: + OSL_VERIFY( _rValue >>= m_bStandardTheme ); + break; case PROPERTY_ID_GENERATEVBAEVENTS: OSL_VERIFY( _rValue >>= m_bGenerateVbEvents ); break; @@ -1009,15 +1023,19 @@ void OControlModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const A void OControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_BASE_PROPERTIES( 7 ) - DECL_PROP2 (CLASSID, sal_Int16, READONLY, TRANSIENT); - DECL_PROP1 (NAME, OUString, BOUND); - DECL_BOOL_PROP2 (NATIVE_LOOK, BOUND, TRANSIENT); - DECL_PROP1 (TAG, OUString, BOUND); - DECL_PROP1 (GENERATEVBAEVENTS, sal_Bool, TRANSIENT); - DECL_PROP1 (CONTROL_TYPE_IN_MSO,sal_Int16, BOUND); - DECL_PROP1 (OBJ_ID_IN_MSO,cppu::UnoUnsignedShortType, BOUND); - END_DESCRIBE_PROPERTIES() + _rProps.realloc(8); + css::beans::Property* pProperties = _rProps.getArray(); + *pProperties++ = css::beans::Property(PROPERTY_CLASSID, PROPERTY_ID_CLASSID, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_NAME, PROPERTY_ID_NAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_NATIVE_LOOK, PROPERTY_ID_NATIVE_LOOK, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_STANDARD_THEME, PROPERTY_ID_STANDARD_THEME, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_TAG, PROPERTY_ID_TAG, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_GENERATEVBAEVENTS, PROPERTY_ID_GENERATEVBAEVENTS, cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_CONTROL_TYPE_IN_MSO, PROPERTY_ID_CONTROL_TYPE_IN_MSO, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_OBJ_ID_IN_MSO, PROPERTY_ID_OBJ_ID_IN_MSO, cppu::UnoType<cppu::UnoUnsignedShortType>::get(), css::beans::PropertyAttribute::BOUND); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } void OControlModel::describeAggregateProperties( Sequence< Property >& /* [out] */ _rAggregateProps ) const @@ -1043,7 +1061,7 @@ void OControlModel::describeFixedAndAggregateProperties( Sequence< Property >& _ Reference< XMultiPropertySet > OControlModel::getPropertiesInterface() { - return Reference< XMultiPropertySet >( *this, UNO_QUERY ); + return this; } Reference< XPropertySetInfo> SAL_CALL OControlModel::getPropertySetInfo() @@ -1475,7 +1493,7 @@ void SAL_CALL OBoundControlModel::disposing(const css::lang::EventObject& _rEven Reference<XPropertySet> xOldValue = m_xLabelControl; m_xLabelControl = nullptr; // fire a propertyChanged (when we leave aLock's scope) - aLock.addPropertyNotification( PROPERTY_ID_CONTROLLABEL, makeAny( xOldValue ), makeAny( m_xLabelControl ) ); + aLock.addPropertyNotification( PROPERTY_ID_CONTROLLABEL, Any( xOldValue ), Any( m_xLabelControl ) ); } else if ( _rEvent.Source == m_xExternalBinding ) @@ -1852,14 +1870,14 @@ sal_Bool SAL_CALL OBoundControlModel::commit() // we reach this only if we're not working with an external binding if ( !hasField() ) return true; - ::comphelper::OInterfaceIteratorHelper2 aIter( m_aUpdateListeners ); + ::comphelper::OInterfaceIteratorHelper3 aIter( m_aUpdateListeners ); EventObject aEvent; aEvent.Source = static_cast< XWeak* >( this ); bool bSuccess = true; aLock.release(); // UNSAFE > while (aIter.hasMoreElements() && bSuccess) - bSuccess = static_cast< XUpdateListener* >( aIter.next() )->approveUpdate( aEvent ); + bSuccess = aIter.next()->approveUpdate( aEvent ); // < UNSAFE aLock.acquire(); if ( bSuccess ) @@ -1942,12 +1960,13 @@ void OBoundControlModel::connectToField(const Reference<XRowSet>& rForm) m_xColumn.set( m_xField, UNO_QUERY ); sal_Int32 nNullableFlag = ColumnValue::NO_NULLS; m_xField->getPropertyValue(PROPERTY_ISNULLABLE) >>= nNullableFlag; - m_bRequired = (ColumnValue::NO_NULLS == nNullableFlag); + // tdf#122319 - don't allow nullable form components if input is required + m_bRequired = (ColumnValue::NO_NULLS == nNullableFlag || m_bInputRequired); // we're optimistic: in case of ColumnValue_NULLABLE_UNKNOWN we assume nullability... } else { - SAL_WARN("forms.component", "OBoundControlModel::connectToField: property " PROPERTY_VALUE " not supported!"); + SAL_WARN("forms.component", "OBoundControlModel::connectToField: property " << PROPERTY_VALUE << " not supported!"); impl_setField_noNotify( nullptr ); } @@ -2149,7 +2168,7 @@ void OBoundControlModel::onConnectedValidator( ) if ( m_xAggregateSet.is() ) xAggregatePropertyInfo = m_xAggregateSet->getPropertySetInfo(); if ( xAggregatePropertyInfo.is() && xAggregatePropertyInfo->hasPropertyByName( PROPERTY_ENFORCE_FORMAT ) ) - m_xAggregateSet->setPropertyValue( PROPERTY_ENFORCE_FORMAT, makeAny( false ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_ENFORCE_FORMAT, Any( false ) ); } catch( const Exception& ) @@ -2168,7 +2187,7 @@ void OBoundControlModel::onDisconnectedValidator( ) if ( m_xAggregateSet.is() ) xAggregatePropertyInfo = m_xAggregateSet->getPropertySetInfo(); if ( xAggregatePropertyInfo.is() && xAggregatePropertyInfo->hasPropertyByName( PROPERTY_ENFORCE_FORMAT ) ) - m_xAggregateSet->setPropertyValue( PROPERTY_ENFORCE_FORMAT, makeAny( true ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_ENFORCE_FORMAT, Any( true ) ); } catch( const Exception& ) @@ -2349,7 +2368,7 @@ bool OBoundControlModel::impl_approveValueBinding_nolock( const Reference< XValu // < SYNCHRONIZED } - for ( auto const & type : std::as_const(aTypeCandidates) ) + for (auto const& type : aTypeCandidates) { if ( _rxBinding->supportsType( type ) ) return true; @@ -2469,7 +2488,7 @@ void SAL_CALL OBoundControlModel::setValueBinding( const Reference< XValueBindin if ( _rxBinding.is() && !impl_approveValueBinding_nolock( _rxBinding ) ) { throw IncompatibleTypesException( - FRM_RES_STRING( RID_STR_INCOMPATIBLE_TYPES ), + ResourceManager::loadString(RID_STR_INCOMPATIBLE_TYPES), *this ); } @@ -2688,7 +2707,7 @@ void SAL_CALL OBoundControlModel::setValidator( const Reference< XValidator >& _ if ( m_xValidator.is() && ( m_xValidator == m_xExternalBinding ) ) throw VetoException( - FRM_RES_STRING( RID_STR_INVALID_VALIDATOR ), + ResourceManager::loadString(RID_STR_INVALID_VALIDATOR), *this ); @@ -2778,13 +2797,19 @@ void OBoundControlModel::recheckValidity( bool _bForceNotification ) void OBoundControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 5, OControlModel ) - DECL_PROP1 ( CONTROLSOURCE, OUString, BOUND ); - DECL_IFACE_PROP3( BOUNDFIELD, XPropertySet, BOUND, READONLY, TRANSIENT ); - DECL_IFACE_PROP2( CONTROLLABEL, XPropertySet, BOUND, MAYBEVOID ); - DECL_PROP2 ( CONTROLSOURCEPROPERTY, OUString, READONLY, TRANSIENT ); - DECL_BOOL_PROP1 ( INPUT_REQUIRED, BOUND ); - END_DESCRIBE_PROPERTIES() + OControlModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 5); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_CONTROLSOURCE, PROPERTY_ID_CONTROLSOURCE, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_BOUNDFIELD, PROPERTY_ID_BOUNDFIELD, cppu::UnoType<XPropertySet>::get(), + css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_CONTROLLABEL, PROPERTY_ID_CONTROLLABEL, cppu::UnoType<XPropertySet>::get(), + css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID); + *pProperties++ = css::beans::Property(PROPERTY_CONTROLSOURCEPROPERTY, PROPERTY_ID_CONTROLSOURCEPROPERTY, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_INPUT_REQUIRED, PROPERTY_ID_INPUT_REQUIRED, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } } diff --git a/forms/source/component/FormattedField.cxx b/forms/source/component/FormattedField.cxx index 7bef964464e9..fa1fdb216b2b 100644 --- a/forms/source/component/FormattedField.cxx +++ b/forms/source/component/FormattedField.cxx @@ -28,13 +28,13 @@ #include <connectivity/dbconversion.hxx> #include <o3tl/any.hxx> #include <svl/numformat.hxx> -#include <svl/zforlist.hxx> #include <svl/numuno.hxx> #include <vcl/keycodes.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <tools/debug.hxx> #include <i18nlangtag/languagetag.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/util/NumberFormat.hpp> #include <com/sun/star/util/Date.hpp> @@ -59,7 +59,6 @@ using namespace dbtools; using namespace css::uno; using namespace css::sdb; using namespace css::sdbc; -using namespace css::sdbcx; using namespace css::beans; using namespace css::container; using namespace css::form; @@ -67,7 +66,6 @@ using namespace css::awt; using namespace css::io; using namespace css::lang; using namespace css::util; -using namespace css::form::binding; namespace frm { @@ -121,7 +119,7 @@ Reference< XNumberFormatsSupplier > StandardFormatsSupplier::get( const Referenc // somebody used the small time frame where the mutex was not locked to create and set // the supplier return xSupplier; - s_xDefaultFormatsSupplier = pSupplier; + s_xDefaultFormatsSupplier = css::uno::Reference<css::uno::XWeak>(pSupplier); } return pSupplier; } @@ -268,7 +266,7 @@ void OFormattedModel::implConstruct() } OFormattedModel::OFormattedModel(const Reference<XComponentContext>& _rxFactory) :OEditBaseModel(_rxFactory, VCL_CONTROLMODEL_FORMATTEDFIELD, FRM_SUN_CONTROL_FORMATTEDFIELD, true, true ) - // use the old control name for compytibility reasons + // use the old control name for compatibility reasons ,OErrorBroadcaster( OComponentHelper::rBHelper ) { implConstruct(); @@ -287,7 +285,12 @@ OFormattedModel::~OFormattedModel() } // XCloneable -IMPLEMENT_DEFAULT_CLONING( OFormattedModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL OFormattedModel::createClone() +{ + rtl::Reference<OFormattedModel> pClone = new OFormattedModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} void SAL_CALL OFormattedModel::disposing() { @@ -339,11 +342,16 @@ OUString SAL_CALL OFormattedModel::getServiceName() // XPropertySet void OFormattedModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 3, OEditBaseModel ) - DECL_BOOL_PROP1(EMPTY_IS_NULL, BOUND); - DECL_PROP1(TABINDEX, sal_Int16, BOUND); - DECL_BOOL_PROP2(FILTERPROPOSAL, BOUND, MAYBEDEFAULT); - END_DESCRIBE_PROPERTIES(); + OEditBaseModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 3); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_EMPTY_IS_NULL, PROPERTY_ID_EMPTY_IS_NULL, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_FILTERPROPOSAL, PROPERTY_ID_FILTERPROPOSAL, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } void OFormattedModel::describeAggregateProperties( Sequence< Property >& _rAggregateProps ) const @@ -369,7 +377,7 @@ void OFormattedModel::setPropertyToDefaultByHandle(sal_Int32 nHandle) Reference<XNumberFormatsSupplier> xSupplier = calcDefaultFormatsSupplier(); DBG_ASSERT(m_xAggregateSet.is(), "OFormattedModel::setPropertyToDefaultByHandle(FORMATSSUPPLIER) : have no aggregate !"); if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, makeAny(xSupplier)); + m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, Any(xSupplier)); } else OEditBaseModel::setPropertyToDefaultByHandle(nHandle); @@ -390,7 +398,7 @@ Any OFormattedModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const if (nHandle == PROPERTY_ID_FORMATSSUPPLIER) { Reference<XNumberFormatsSupplier> xSupplier = calcDefaultFormatsSupplier(); - return makeAny(xSupplier); + return Any(xSupplier); } else return OEditBaseModel::getPropertyDefaultByHandle(nHandle); @@ -561,7 +569,7 @@ void OFormattedModel::onConnectedDbColumn( const Reference< XInterface >& _rxFor } } aSupplier >>= m_xOriginalFormatter; - m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, makeAny(xSupplier)); + m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, Any(xSupplier)); m_xAggregateSet->setPropertyValue(PROPERTY_FORMATKEY, aFmtKey); // Adapt the NumericFalg to my bound field if (xField.is()) @@ -589,7 +597,7 @@ void OFormattedModel::onConnectedDbColumn( const Reference< XInterface >& _rxFor } else m_bNumeric = m_bOriginalNumeric; - setPropertyValue(PROPERTY_TREATASNUMERIC, makeAny(m_bNumeric)); + setPropertyValue(PROPERTY_TREATASNUMERIC, Any(m_bNumeric)); OSL_VERIFY( aFmtKey >>= nFormatKey ); } } @@ -606,9 +614,9 @@ void OFormattedModel::onDisconnectedDbColumn() OEditBaseModel::onDisconnectedDbColumn(); if (m_xOriginalFormatter.is()) { // Our aggregated model does not hold any Format information - m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, makeAny(m_xOriginalFormatter)); + m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, Any(m_xOriginalFormatter)); m_xAggregateSet->setPropertyValue(PROPERTY_FORMATKEY, Any()); - setPropertyValue(PROPERTY_TREATASNUMERIC, makeAny(m_bOriginalNumeric)); + setPropertyValue(PROPERTY_TREATASNUMERIC, Any(m_bOriginalNumeric)); m_xOriginalFormatter = nullptr; } m_nKeyType = NumberFormat::UNDEFINED; @@ -646,7 +654,7 @@ void OFormattedModel::write(const Reference<XObjectOutputStream>& _rxOutStream) Reference<XNumberFormats> xFormats = xSupplier->getNumberFormats(); OUString sFormatDescription; LanguageType eFormatLanguage = LANGUAGE_DONTKNOW; - static constexpr OUStringLiteral s_aLocaleProp = u"Locale"; + static constexpr OUString s_aLocaleProp = u"Locale"_ustr; Reference<css::beans::XPropertySet> xFormat = xFormats->getByKey(nKey); if (hasProperty(s_aLocaleProp, xFormat)) { @@ -657,7 +665,7 @@ void OFormattedModel::write(const Reference<XObjectOutputStream>& _rxOutStream) eFormatLanguage = LanguageTag::convertToLanguageType( *pLocale, false); } } - static constexpr OUStringLiteral s_aFormatStringProp = u"FormatString"; + static constexpr OUString s_aFormatStringProp = u"FormatString"_ustr; if (hasProperty(s_aFormatStringProp, xFormat)) xFormat->getPropertyValue(s_aFormatStringProp) >>= sFormatDescription; _rxOutStream->writeUTF(sFormatDescription); @@ -780,8 +788,8 @@ void OFormattedModel::read(const Reference<XObjectInputStream>& _rxInStream) } if ((nKey != -1) && m_xAggregateSet.is()) { - m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, makeAny(xSupplier)); - m_xAggregateSet->setPropertyValue(PROPERTY_FORMATKEY, makeAny(nKey)); + m_xAggregateSet->setPropertyValue(PROPERTY_FORMATSSUPPLIER, Any(xSupplier)); + m_xAggregateSet->setPropertyValue(PROPERTY_FORMATKEY, Any(nKey)); } else { @@ -799,38 +807,38 @@ sal_uInt16 OFormattedModel::getPersistenceFlags() const bool OFormattedModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) { Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) ); - if ( aControlValue != m_aSaveValue ) - { - // empty string + EmptyIsNull = void - if ( !aControlValue.hasValue() - || ( ( aControlValue.getValueType().getTypeClass() == TypeClass_STRING ) - && getString( aControlValue ).isEmpty() - && m_bEmptyIsNull - ) + if ( aControlValue == m_aSaveValue ) + return true; + + // empty string + EmptyIsNull = void + if ( !aControlValue.hasValue() + || ( ( aControlValue.getValueType().getTypeClass() == TypeClass_STRING ) + && getString( aControlValue ).isEmpty() + && m_bEmptyIsNull ) - m_xColumnUpdate->updateNull(); - else + ) + m_xColumnUpdate->updateNull(); + else + { + try { - try + double f = 0.0; + if ( aControlValue.getValueType().getTypeClass() == TypeClass_DOUBLE || (aControlValue >>= f)) // #i110323 { - double f = 0.0; - if ( aControlValue.getValueType().getTypeClass() == TypeClass_DOUBLE || (aControlValue >>= f)) // #i110323 - { - DBTypeConversion::setValue( m_xColumnUpdate, m_aNullDate, getDouble( aControlValue ), m_nKeyType ); - } - else - { - DBG_ASSERT( aControlValue.getValueType().getTypeClass() == TypeClass_STRING, "OFormattedModel::commitControlValueToDbColumn: invalid value type!" ); - m_xColumnUpdate->updateString( getString( aControlValue ) ); - } + DBTypeConversion::setValue( m_xColumnUpdate, m_aNullDate, getDouble( aControlValue ), m_nKeyType ); } - catch(const Exception&) + else { - return false; + DBG_ASSERT( aControlValue.getValueType().getTypeClass() == TypeClass_STRING, "OFormattedModel::commitControlValueToDbColumn: invalid value type!" ); + m_xColumnUpdate->updateString( getString( aControlValue ) ); } } - m_aSaveValue = aControlValue; + catch(const Exception&) + { + return false; + } } + m_aSaveValue = aControlValue; return true; } diff --git a/forms/source/component/FormattedField.hxx b/forms/source/component/FormattedField.hxx index e1520cd6ee47..c9d0f1c1705e 100644 --- a/forms/source/component/FormattedField.hxx +++ b/forms/source/component/FormattedField.hxx @@ -50,7 +50,14 @@ class OFormattedModel final css::uno::Reference< css::util::XNumberFormatsSupplier> calcFormFormatsSupplier() const; css::uno::Reference< css::util::XNumberFormatsSupplier> calcFormatsSupplier() const; - DECLARE_DEFAULT_LEAF_XTOR( OFormattedModel ); + OFormattedModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OFormattedModel( + const OFormattedModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OFormattedModel() override; friend class OFormattedFieldWrapper; diff --git a/forms/source/component/FormattedFieldWrapper.cxx b/forms/source/component/FormattedFieldWrapper.cxx index 8a8f27830395..d97387e4b6e1 100644 --- a/forms/source/component/FormattedFieldWrapper.cxx +++ b/forms/source/component/FormattedFieldWrapper.cxx @@ -35,23 +35,22 @@ using namespace frm; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::form; -using namespace ::com::sun::star::awt; using namespace ::com::sun::star::io; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; -OFormattedFieldWrapper::OFormattedFieldWrapper(const Reference<XComponentContext>& _rxFactory) +OFormattedFieldWrapper::OFormattedFieldWrapper(const Reference<XComponentContext>& _rxFactory, + OUString const & implementationName) :m_xContext(_rxFactory) + ,m_implementationName(implementationName) { } -css::uno::Reference<css::uno::XInterface> OFormattedFieldWrapper::createFormattedFieldWrapper(const css::uno::Reference< css::uno::XComponentContext>& _rxFactory, bool bActAsFormatted) +css::uno::Reference<css::uno::XInterface> OFormattedFieldWrapper::createFormattedFieldWrapper(const css::uno::Reference< css::uno::XComponentContext>& _rxFactory, bool bActAsFormatted, OUString const & implementationName) { - rtl::Reference<OFormattedFieldWrapper> pRef = new OFormattedFieldWrapper(_rxFactory); + rtl::Reference<OFormattedFieldWrapper> pRef = new OFormattedFieldWrapper(_rxFactory, + implementationName); if (bActAsFormatted) { @@ -82,7 +81,8 @@ Reference< XCloneable > SAL_CALL OFormattedFieldWrapper::createClone() { ensureAggregate(); - rtl::Reference< OFormattedFieldWrapper > xRef(new OFormattedFieldWrapper(m_xContext)); + rtl::Reference< OFormattedFieldWrapper > xRef(new OFormattedFieldWrapper(m_xContext, + m_implementationName)); Reference< XCloneable > xCloneAccess; query_aggregation( m_xAggregate, xCloneAccess ); @@ -174,7 +174,7 @@ OUString SAL_CALL OFormattedFieldWrapper::getServiceName() OUString SAL_CALL OFormattedFieldWrapper::getImplementationName( ) { - return "com.sun.star.comp.forms.OFormattedFieldWrapper_ForcedFormatted"; + return m_implementationName; } sal_Bool SAL_CALL OFormattedFieldWrapper::supportsService( const OUString& _rServiceName ) @@ -342,7 +342,8 @@ com_sun_star_form_OFormattedFieldWrapper_get_implementation(css::uno::XComponent css::uno::Sequence<css::uno::Any> const &) { css::uno::Reference<css::uno::XInterface> inst( - OFormattedFieldWrapper::createFormattedFieldWrapper(component, false)); + OFormattedFieldWrapper::createFormattedFieldWrapper( + component, false, "com.sun.star.form.OFormattedFieldWrapper")); inst->acquire(); return inst.get(); } @@ -352,7 +353,8 @@ com_sun_star_comp_forms_OFormattedFieldWrapper_ForcedFormatted_get_implementatio css::uno::Sequence<css::uno::Any> const &) { css::uno::Reference<css::uno::XInterface> inst( - OFormattedFieldWrapper::createFormattedFieldWrapper(component, true)); + OFormattedFieldWrapper::createFormattedFieldWrapper( + component, true, "com.sun.star.comp.forms.OFormattedFieldWrapper_ForcedFormatted")); inst->acquire(); return inst.get(); } diff --git a/forms/source/component/FormattedFieldWrapper.hxx b/forms/source/component/FormattedFieldWrapper.hxx index b34db4148531..9dc093dece0d 100644 --- a/forms/source/component/FormattedFieldWrapper.hxx +++ b/forms/source/component/FormattedFieldWrapper.hxx @@ -42,6 +42,7 @@ typedef ::cppu::WeakAggImplHelper3 < css::io::XPersistObject class OFormattedFieldWrapper final : public OFormattedFieldWrapper_Base { css::uno::Reference< css::uno::XComponentContext> m_xContext; + OUString m_implementationName; css::uno::Reference< css::uno::XAggregation> m_xAggregate; @@ -49,7 +50,8 @@ class OFormattedFieldWrapper final : public OFormattedFieldWrapper_Base // if we act as formatted this is used to write the EditModel part css::uno::Reference< css::io::XPersistObject> m_xFormattedPart; - OFormattedFieldWrapper(const css::uno::Reference< css::uno::XComponentContext>& _rxFactory); + OFormattedFieldWrapper(const css::uno::Reference< css::uno::XComponentContext>& _rxFactory, + OUString const & implementationName); virtual ~OFormattedFieldWrapper() override; @@ -58,7 +60,7 @@ public: // to read and write the FormattedModel part // if bActAsFormatted is false, the state is undetermined until somebody calls // ::read or does anything which requires a living aggregate - static css::uno::Reference<css::uno::XInterface> createFormattedFieldWrapper(const css::uno::Reference< css::uno::XComponentContext>& _rxFactory, bool bActAsFormatted); + static css::uno::Reference<css::uno::XInterface> createFormattedFieldWrapper(const css::uno::Reference< css::uno::XComponentContext>& _rxFactory, bool bActAsFormatted, OUString const & implementationName); // UNO DECLARE_UNO3_AGG_DEFAULTS(OFormattedFieldWrapper, OWeakAggObject) diff --git a/forms/source/component/FormsCollection.cxx b/forms/source/component/FormsCollection.cxx index 0f1b6d95c056..2d426c7a34ab 100644 --- a/forms/source/component/FormsCollection.cxx +++ b/forms/source/component/FormsCollection.cxx @@ -25,10 +25,8 @@ #include <rtl/ref.hxx> using namespace frm; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::form; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::util; OUString SAL_CALL OFormsCollection::getServiceName() diff --git a/forms/source/component/Grid.cxx b/forms/source/component/Grid.cxx index b92f763d578e..1290aa91af7f 100644 --- a/forms/source/component/Grid.cxx +++ b/forms/source/component/Grid.cxx @@ -22,6 +22,7 @@ #include "Grid.hxx" #include <property.hxx> #include <services.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/io/XMarkableStream.hpp> #include <com/sun/star/text/WritingMode2.hpp> @@ -31,7 +32,8 @@ #include <comphelper/types.hxx> #include <vcl/unohelp.hxx> #include <vcl/svapp.hxx> -#include <tools/diagnose_ex.h> +#include <tools/debug.hxx> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star::uno; @@ -163,10 +165,11 @@ css::uno::Sequence<OUString> OGridControlModel::getSupportedServiceNames() { css::uno::Sequence<OUString> aSupported = OControlModel::getSupportedServiceNames(); aSupported.realloc(aSupported.getLength() + 4); - aSupported[aSupported.getLength()-4] = "com.sun.star.awt.UnoControlModel"; - aSupported[aSupported.getLength()-3] = FRM_SUN_COMPONENT_GRIDCONTROL; - aSupported[aSupported.getLength()-2] = FRM_COMPONENT_GRID; - aSupported[aSupported.getLength()-1] = FRM_COMPONENT_GRIDCONTROL; + auto pSupported = aSupported.getArray(); + pSupported[aSupported.getLength()-4] = "com.sun.star.awt.UnoControlModel"; + pSupported[aSupported.getLength()-3] = FRM_SUN_COMPONENT_GRIDCONTROL; + pSupported[aSupported.getLength()-2] = FRM_COMPONENT_GRID; + pSupported[aSupported.getLength()-1] = FRM_COMPONENT_GRIDCONTROL; return aSupported; } Any SAL_CALL OGridControlModel::queryAggregation( const Type& _rType ) @@ -290,7 +293,7 @@ sal_Bool SAL_CALL OGridControlModel::select(const Any& rElement) } Any SAL_CALL OGridControlModel::getSelection() { - return makeAny(m_xSelection); + return Any(m_xSelection); } void OGridControlModel::addSelectionChangeListener(const Reference< XSelectionChangeListener >& _rxListener) @@ -339,11 +342,11 @@ css::uno::Sequence<OUString> SAL_CALL OGridControlModel::getColumnTypes() // XReset void SAL_CALL OGridControlModel::reset() { - ::comphelper::OInterfaceIteratorHelper2 aIter(m_aResetListeners); + ::comphelper::OInterfaceIteratorHelper3 aIter(m_aResetListeners); EventObject aEvt(static_cast<XWeak*>(this)); bool bContinue = true; while (aIter.hasMoreElements() && bContinue) - bContinue = static_cast<XResetListener*>(aIter.next())->approveReset(aEvt); + bContinue = aIter.next()->approveReset(aEvt); if (bContinue) { _reset(); @@ -373,45 +376,48 @@ void OGridControlModel::_reset() // XPropertySet void OGridControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_BASE_PROPERTIES( 37 ) - DECL_PROP1(NAME, OUString, BOUND); - DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT); - DECL_PROP1(TAG, OUString, BOUND); - DECL_PROP1(TABINDEX, sal_Int16, BOUND); - DECL_PROP3(TABSTOP, sal_Bool, BOUND, MAYBEDEFAULT, MAYBEVOID); - DECL_PROP2(HASNAVIGATION, sal_Bool, BOUND, MAYBEDEFAULT); - DECL_PROP1(ENABLED, sal_Bool, BOUND); - DECL_PROP2(ENABLEVISIBLE, sal_Bool, BOUND, MAYBEDEFAULT); - DECL_PROP1(BORDER, sal_Int16, BOUND); - DECL_PROP2(BORDERCOLOR, sal_Int16, BOUND, MAYBEVOID); - DECL_PROP1(DEFAULTCONTROL, OUString, BOUND); - DECL_PROP3(TEXTCOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID); - DECL_PROP3(BACKGROUNDCOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID); - DECL_PROP2(FONT, FontDescriptor, BOUND, MAYBEDEFAULT); - DECL_PROP3(ROWHEIGHT, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID); - DECL_PROP1(HELPTEXT, OUString, BOUND); - DECL_PROP1(FONT_NAME, OUString, MAYBEDEFAULT); - DECL_PROP1(FONT_STYLENAME, OUString, MAYBEDEFAULT); - DECL_PROP1(FONT_FAMILY, sal_Int16, MAYBEDEFAULT); - DECL_PROP1(FONT_CHARSET, sal_Int16, MAYBEDEFAULT); - DECL_PROP1(FONT_HEIGHT, float, MAYBEDEFAULT); - DECL_PROP1(FONT_WEIGHT, float, MAYBEDEFAULT); - DECL_PROP1(FONT_SLANT, sal_Int16, MAYBEDEFAULT); - DECL_PROP1(FONT_UNDERLINE, sal_Int16, MAYBEDEFAULT); - DECL_BOOL_PROP1(FONT_WORDLINEMODE, MAYBEDEFAULT); - DECL_PROP3(TEXTLINECOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID); - DECL_PROP2(FONTEMPHASISMARK, sal_Int16, BOUND, MAYBEDEFAULT); - DECL_PROP2(FONTRELIEF, sal_Int16, BOUND, MAYBEDEFAULT); - DECL_PROP1(FONT_STRIKEOUT, sal_Int16, MAYBEDEFAULT); - DECL_PROP2(RECORDMARKER, sal_Bool, BOUND, MAYBEDEFAULT ); - DECL_PROP2(PRINTABLE, sal_Bool, BOUND, MAYBEDEFAULT ); - DECL_PROP4(CURSORCOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID , TRANSIENT); - DECL_PROP3(ALWAYSSHOWCURSOR, sal_Bool, BOUND, MAYBEDEFAULT, TRANSIENT); - DECL_PROP3(DISPLAYSYNCHRON, sal_Bool, BOUND, MAYBEDEFAULT, TRANSIENT); - DECL_PROP2(HELPURL, OUString, BOUND, MAYBEDEFAULT); - DECL_PROP2(WRITING_MODE, sal_Int16, BOUND, MAYBEDEFAULT); - DECL_PROP3(CONTEXT_WRITING_MODE,sal_Int16, BOUND, MAYBEDEFAULT, TRANSIENT); - END_DESCRIBE_PROPERTIES(); + _rProps.realloc(37); + css::beans::Property* pProperties = _rProps.getArray(); + *pProperties++ = css::beans::Property(PROPERTY_NAME, PROPERTY_ID_NAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_CLASSID, PROPERTY_ID_CLASSID, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_TAG, PROPERTY_ID_TAG, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TABSTOP, PROPERTY_ID_TABSTOP, cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT | css::beans::PropertyAttribute::MAYBEVOID); + *pProperties++ = css::beans::Property(PROPERTY_HASNAVIGATION, PROPERTY_ID_HASNAVIGATION, cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_ENABLED, PROPERTY_ID_ENABLED, cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_ENABLEVISIBLE, PROPERTY_ID_ENABLEVISIBLE, cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_BORDER, PROPERTY_ID_BORDER, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_BORDERCOLOR, PROPERTY_ID_BORDERCOLOR, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID); + *pProperties++ = css::beans::Property(PROPERTY_DEFAULTCONTROL, PROPERTY_ID_DEFAULTCONTROL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TEXTCOLOR, PROPERTY_ID_TEXTCOLOR, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT | css::beans::PropertyAttribute::MAYBEVOID); + *pProperties++ = css::beans::Property(PROPERTY_BACKGROUNDCOLOR, PROPERTY_ID_BACKGROUNDCOLOR, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT | css::beans::PropertyAttribute::MAYBEVOID); + *pProperties++ = css::beans::Property(PROPERTY_FONT, PROPERTY_ID_FONT, cppu::UnoType<FontDescriptor>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_ROWHEIGHT, PROPERTY_ID_ROWHEIGHT, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT | css::beans::PropertyAttribute::MAYBEVOID); + *pProperties++ = css::beans::Property(PROPERTY_HELPTEXT, PROPERTY_ID_HELPTEXT, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_FONT_NAME, PROPERTY_ID_FONT_NAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_STYLENAME, PROPERTY_ID_FONT_STYLENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_FAMILY, PROPERTY_ID_FONT_FAMILY, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_CHARSET, PROPERTY_ID_FONT_CHARSET, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_HEIGHT, PROPERTY_ID_FONT_HEIGHT, cppu::UnoType<float>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_WEIGHT, PROPERTY_ID_FONT_WEIGHT, cppu::UnoType<float>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_SLANT, PROPERTY_ID_FONT_SLANT, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_UNDERLINE, PROPERTY_ID_FONT_UNDERLINE, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_WORDLINEMODE, PROPERTY_ID_FONT_WORDLINEMODE, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_TEXTLINECOLOR, PROPERTY_ID_TEXTLINECOLOR, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT | css::beans::PropertyAttribute::MAYBEVOID); + *pProperties++ = css::beans::Property(PROPERTY_FONTEMPHASISMARK, PROPERTY_ID_FONTEMPHASISMARK, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONTRELIEF, PROPERTY_ID_FONTRELIEF, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_STRIKEOUT, PROPERTY_ID_FONT_STRIKEOUT, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_RECORDMARKER, PROPERTY_ID_RECORDMARKER, cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_PRINTABLE, PROPERTY_ID_PRINTABLE, cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_CURSORCOLOR, PROPERTY_ID_CURSORCOLOR, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT | + css::beans::PropertyAttribute::MAYBEVOID | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_ALWAYSSHOWCURSOR, PROPERTY_ID_ALWAYSSHOWCURSOR, cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_DISPLAYSYNCHRON, PROPERTY_ID_DISPLAYSYNCHRON, cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_HELPURL, PROPERTY_ID_HELPURL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_WRITING_MODE, PROPERTY_ID_WRITING_MODE, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_CONTEXT_WRITING_MODE, PROPERTY_ID_CONTEXT_WRITING_MODE, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT | css::beans::PropertyAttribute::TRANSIENT); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } void OGridControlModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) const { @@ -647,7 +653,7 @@ Any OGridControlModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const aReturn <<= WritingMode2::CONTEXT; break; case PROPERTY_ID_DEFAULTCONTROL: - aReturn <<= OUString( STARDIV_ONE_FORM_CONTROL_GRID ); + aReturn <<= STARDIV_ONE_FORM_CONTROL_GRID; break; case PROPERTY_ID_PRINTABLE: case PROPERTY_ID_HASNAVIGATION: diff --git a/forms/source/component/Grid.hxx b/forms/source/component/Grid.hxx index 523a8132db68..8339bb49a539 100644 --- a/forms/source/component/Grid.hxx +++ b/forms/source/component/Grid.hxx @@ -29,6 +29,7 @@ #include <com/sun/star/sdb/XRowSetChangeBroadcaster.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> +#include <comphelper/interfacecontainer3.hxx> #include <cppuhelper/implbase7.hxx> @@ -54,9 +55,9 @@ class OGridControlModel final :public OControlModel ,public FontControlModel ,public OGridControlModel_BASE { - ::comphelper::OInterfaceContainerHelper2 m_aSelectListeners, - m_aResetListeners, - m_aRowSetChangeListeners; + ::comphelper::OInterfaceContainerHelper3<css::view::XSelectionChangeListener> m_aSelectListeners; + ::comphelper::OInterfaceContainerHelper3<css::form::XResetListener> m_aResetListeners; + ::comphelper::OInterfaceContainerHelper3<css::sdb::XRowSetChangeListener> m_aRowSetChangeListeners; // [properties] css::uno::Any m_aRowHeight; // Row height @@ -87,7 +88,14 @@ class OGridControlModel final :public OControlModel void _reset(); public: - DECLARE_DEFAULT_LEAF_XTOR( OGridControlModel ); + OGridControlModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OGridControlModel( + const OGridControlModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OGridControlModel() override; // UNO Binding DECLARE_UNO3_AGG_DEFAULTS(OGridControlModel, OControlModel) diff --git a/forms/source/component/GroupBox.cxx b/forms/source/component/GroupBox.cxx index 25c353a0bceb..9d979dc1d621 100644 --- a/forms/source/component/GroupBox.cxx +++ b/forms/source/component/GroupBox.cxx @@ -31,11 +31,8 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; -using namespace ::com::sun::star::awt; using namespace ::com::sun::star::io; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; using namespace comphelper; @@ -73,7 +70,12 @@ OGroupBoxModel::~OGroupBoxModel() } -IMPLEMENT_DEFAULT_CLONING( OGroupBoxModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL OGroupBoxModel::createClone() +{ + rtl::Reference<OGroupBoxModel> pClone = new OGroupBoxModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} void OGroupBoxModel::describeAggregateProperties( Sequence< Property >& _rAggregateProps ) const diff --git a/forms/source/component/GroupBox.hxx b/forms/source/component/GroupBox.hxx index 00f4523aad07..c1c53df0b613 100644 --- a/forms/source/component/GroupBox.hxx +++ b/forms/source/component/GroupBox.hxx @@ -29,7 +29,14 @@ class OGroupBoxModel :public OControlModel { public: - DECLARE_DEFAULT_LEAF_XTOR( OGroupBoxModel ); + OGroupBoxModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OGroupBoxModel( + const OGroupBoxModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OGroupBoxModel() override; // XServiceInfo OUString SAL_CALL getImplementationName() override diff --git a/forms/source/component/GroupManager.cxx b/forms/source/component/GroupManager.cxx index deec1bcd572c..edd296d6c77a 100644 --- a/forms/source/component/GroupManager.cxx +++ b/forms/source/component/GroupManager.cxx @@ -27,6 +27,7 @@ #include <frm_strings.hxx> #include <algorithm> +#include <utility> namespace frm { @@ -54,9 +55,9 @@ namespace } } -OGroupCompAcc::OGroupCompAcc(const Reference<XPropertySet>& rxElement, const OGroupComp& _rGroupComp ) +OGroupCompAcc::OGroupCompAcc(const Reference<XPropertySet>& rxElement, OGroupComp _aGroupComp ) :m_xComponent( rxElement ) - ,m_aGroupComp( _rGroupComp ) + ,m_aGroupComp(std::move( _aGroupComp )) { } @@ -118,8 +119,8 @@ public: } }; -OGroup::OGroup( const OUString& rGroupName ) - :m_aGroupName( rGroupName ) +OGroup::OGroup( OUString sGroupName ) + :m_aGroupName(std::move( sGroupName )) ,m_nInsertPos(0) { } diff --git a/forms/source/component/GroupManager.hxx b/forms/source/component/GroupManager.hxx index 9365d1b44ea8..4cefd7ac3a12 100644 --- a/forms/source/component/GroupManager.hxx +++ b/forms/source/component/GroupManager.hxx @@ -114,7 +114,7 @@ class OGroupCompAcc friend class OGroupCompAccLess; public: - OGroupCompAcc(const css::uno::Reference< css::beans::XPropertySet>& rxElement, const OGroupComp& _rGroupComp ); + OGroupCompAcc(const css::uno::Reference< css::beans::XPropertySet>& rxElement, OGroupComp _aGroupComp ); bool operator==( const OGroupCompAcc& rCompAcc ) const; @@ -132,7 +132,7 @@ class OGroup final friend class OGroupLess; public: - explicit OGroup(const OUString& rGroupName); + explicit OGroup(OUString sGroupName); const OUString& GetGroupName() const { return m_aGroupName; } css::uno::Sequence< css::uno::Reference< css::awt::XControlModel> > GetControlModels() const; diff --git a/forms/source/component/Hidden.cxx b/forms/source/component/Hidden.cxx index ff19660cda3c..1f9ab4fcf6d3 100644 --- a/forms/source/component/Hidden.cxx +++ b/forms/source/component/Hidden.cxx @@ -23,6 +23,7 @@ #include <tools/debug.hxx> #include <comphelper/basicio.hxx> #include <comphelper/property.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> @@ -32,11 +33,8 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; -using namespace ::com::sun::star::awt; using namespace ::com::sun::star::io; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; @@ -59,7 +57,12 @@ OHiddenModel::~OHiddenModel( ) } -IMPLEMENT_DEFAULT_CLONING( OHiddenModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL OHiddenModel::createClone() +{ + rtl::Reference<OHiddenModel> pClone = new OHiddenModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} void OHiddenModel::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const @@ -106,12 +109,13 @@ sal_Bool OHiddenModel::convertFastPropertyValue( void OHiddenModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_BASE_PROPERTIES(4) - DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT); - DECL_PROP1(HIDDEN_VALUE, OUString, BOUND); - DECL_PROP1(NAME, OUString, BOUND); - DECL_PROP1(TAG, OUString, BOUND); - END_DESCRIBE_PROPERTIES(); + _rProps.realloc(4); + css::beans::Property* pProperties = _rProps.getArray(); + *pProperties++ = css::beans::Property(PROPERTY_CLASSID, PROPERTY_ID_CLASSID, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_HIDDEN_VALUE, PROPERTY_ID_HIDDEN_VALUE, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_NAME, PROPERTY_ID_NAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TAG, PROPERTY_ID_TAG, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } // XServiceInfo diff --git a/forms/source/component/Hidden.hxx b/forms/source/component/Hidden.hxx index 9ed34f3e406f..7bd01ccf939a 100644 --- a/forms/source/component/Hidden.hxx +++ b/forms/source/component/Hidden.hxx @@ -31,7 +31,14 @@ class OHiddenModel OUString m_sHiddenValue; public: - DECLARE_DEFAULT_LEAF_XTOR( OHiddenModel ); + OHiddenModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OHiddenModel( + const OHiddenModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OHiddenModel() override; // OPropertySetHelper virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle) const override; diff --git a/forms/source/component/ImageButton.cxx b/forms/source/component/ImageButton.cxx index ef3fda257123..1dd66ca0dbdc 100644 --- a/forms/source/component/ImageButton.cxx +++ b/forms/source/component/ImageButton.cxx @@ -18,11 +18,13 @@ */ #include "ImageButton.hxx" +#include <tools/debug.hxx> #include <tools/urlobj.hxx> #include <vcl/svapp.hxx> #include <osl/mutex.hxx> #include <comphelper/basicio.hxx> #include <com/sun/star/awt/MouseButton.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <property.hxx> #include <services.hxx> @@ -35,7 +37,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; using namespace ::com::sun::star::io; using namespace ::com::sun::star::lang; @@ -44,7 +45,7 @@ using namespace ::com::sun::star::util; // OImageButtonModel OImageButtonModel::OImageButtonModel(const Reference<XComponentContext>& _rxFactory) :OClickableImageBaseModel( _rxFactory, VCL_CONTROLMODEL_IMAGEBUTTON, FRM_SUN_CONTROL_IMAGEBUTTON ) - // use the old control name for compytibility reasons + // use the old control name for compatibility reasons { m_nClassId = FormComponentType::IMAGEBUTTON; } @@ -55,7 +56,12 @@ OImageButtonModel::OImageButtonModel( const OImageButtonModel* _pOriginal, const implInitializeImageURL(); } -IMPLEMENT_DEFAULT_CLONING( OImageButtonModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL OImageButtonModel::createClone() +{ + rtl::Reference<OImageButtonModel> pClone = new OImageButtonModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} OImageButtonModel::~OImageButtonModel() { @@ -75,13 +81,16 @@ css::uno::Sequence<OUString> OImageButtonModel::getSupportedServiceNames() void OImageButtonModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 5, OClickableImageBaseModel ) - DECL_PROP1(BUTTONTYPE, FormButtonType, BOUND); - DECL_PROP1(DISPATCHURLINTERNAL, sal_Bool, BOUND); - DECL_PROP1(TARGET_URL, OUString, BOUND); - DECL_PROP1(TARGET_FRAME, OUString, BOUND); - DECL_PROP1(TABINDEX, sal_Int16, BOUND); - END_DESCRIBE_PROPERTIES(); + OClickableImageBaseModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 5); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_BUTTONTYPE, PROPERTY_ID_BUTTONTYPE, cppu::UnoType<FormButtonType>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_DISPATCHURLINTERNAL, PROPERTY_ID_DISPATCHURLINTERNAL, cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TARGET_URL, PROPERTY_ID_TARGET_URL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TARGET_FRAME, PROPERTY_ID_TARGET_FRAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } OUString OImageButtonModel::getServiceName() diff --git a/forms/source/component/ImageButton.hxx b/forms/source/component/ImageButton.hxx index d3d248566944..0e5c402abbc3 100644 --- a/forms/source/component/ImageButton.hxx +++ b/forms/source/component/ImageButton.hxx @@ -30,7 +30,14 @@ class OImageButtonModel :public OClickableImageBaseModel { public: - DECLARE_DEFAULT_LEAF_XTOR( OImageButtonModel ); + OImageButtonModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OImageButtonModel( + const OImageButtonModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OImageButtonModel() override; // css::lang::XServiceInfo OUString SAL_CALL getImplementationName() override diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx index f51988ee4ca2..0f48eecf5496 100644 --- a/forms/source/component/ImageControl.cxx +++ b/forms/source/component/ImageControl.cxx @@ -30,6 +30,7 @@ #include <com/sun/star/awt/PopupMenu.hpp> #include <com/sun/star/awt/XPopupMenu.hpp> #include <com/sun/star/awt/PopupMenuDirection.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> @@ -43,14 +44,14 @@ #include <tools/urlobj.hxx> #include <tools/stream.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <vcl/graph.hxx> #include <vcl/svapp.hxx> -#include <unotools/streamhelper.hxx> #include <comphelper/guarding.hxx> #include <comphelper/property.hxx> #include <comphelper/types.hxx> #include <cppuhelper/queryinterface.hxx> +#include <unotools/streamwrap.hxx> #include <unotools/ucbstreamhelper.hxx> #include <svl/urihelper.hxx> @@ -128,7 +129,7 @@ Sequence<Type> OImageControlModel::_getTypes() OImageControlModel::OImageControlModel(const Reference<XComponentContext>& _rxFactory) :OBoundControlModel( _rxFactory, VCL_CONTROLMODEL_IMAGECONTROL, FRM_SUN_CONTROL_IMAGECONTROL, false, false, false ) - // use the old control name for compytibility reasons + // use the old control name for compatibility reasons ,m_bExternalGraphic( true ) ,m_bReadOnly( false ) { @@ -141,7 +142,7 @@ OImageControlModel::OImageControlModel(const Reference<XComponentContext>& _rxFa OImageControlModel::OImageControlModel( const OImageControlModel* _pOriginal, const Reference< XComponentContext >& _rxFactory ) :OBoundControlModel( _pOriginal, _rxFactory ) - // use the old control name for compytibility reasons + // use the old control name for compatibility reasons ,m_bExternalGraphic( true ) ,m_bReadOnly( _pOriginal->m_bReadOnly ) ,m_sImageURL( _pOriginal->m_sImageURL ) @@ -178,7 +179,12 @@ OImageControlModel::~OImageControlModel() // XCloneable -IMPLEMENT_DEFAULT_CLONING( OImageControlModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL OImageControlModel::createClone() +{ + rtl::Reference<OImageControlModel> pClone = new OImageControlModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} // XServiceInfo @@ -310,12 +316,17 @@ sal_Bool OImageControlModel::convertFastPropertyValue(Any& rConvertedValue, Any& void OImageControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 4, OBoundControlModel ) - DECL_IFACE_PROP2( GRAPHIC, XGraphic, BOUND, TRANSIENT ); - DECL_PROP1 ( IMAGE_URL, OUString, BOUND ); - DECL_BOOL_PROP1 ( READONLY, BOUND ); - DECL_PROP1 ( TABINDEX, sal_Int16, BOUND ); - END_DESCRIBE_PROPERTIES(); + OBoundControlModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 4); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_GRAPHIC, PROPERTY_ID_GRAPHIC, cppu::UnoType<XGraphic>::get(), + css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_IMAGE_URL, PROPERTY_ID_IMAGE_URL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_READONLY, PROPERTY_ID_READONLY, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } @@ -388,7 +399,6 @@ void OImageControlModel::read(const Reference<XObjectInputStream>& _rxInStream) bool OImageControlModel::impl_updateStreamForURL_lck( const OUString& _rURL, ValueChangeInstigator _eInstigator ) { // create a stream for the image specified by the URL - std::unique_ptr< SvStream > pImageStream; Reference< XInputStream > xImageStream; if ( ::svt::GraphicAccess::isSupportedURL( _rURL ) ) @@ -397,19 +407,11 @@ bool OImageControlModel::impl_updateStreamForURL_lck( const OUString& _rURL, Val } else { - pImageStream = ::utl::UcbStreamHelper::CreateStream( _rURL, StreamMode::READ ); + std::unique_ptr< SvStream > pImageStream = ::utl::UcbStreamHelper::CreateStream( _rURL, StreamMode::READ ); bool bSetNull = (pImageStream == nullptr) || (ERRCODE_NONE != pImageStream->GetErrorCode()); if ( !bSetNull ) - { - // get the size of the stream - sal_uInt64 const nSize = pImageStream->remainingSize(); - if (pImageStream->GetBufferSize() < 8192) - pImageStream->SetBufferSize(8192); - pImageStream->Seek(STREAM_SEEK_TO_BEGIN); - - xImageStream = new ::utl::OInputStreamHelper( new SvLockBytes( pImageStream.get(), false ), nSize ); - } + xImageStream = new ::utl::OInputStreamWrapper( std::move(pImageStream) ); } if ( xImageStream.is() ) @@ -417,7 +419,7 @@ bool OImageControlModel::impl_updateStreamForURL_lck( const OUString& _rURL, Val if ( m_xColumnUpdate.is() ) m_xColumnUpdate->updateBinaryStream( xImageStream, xImageStream->available() ); else - setControlValue( makeAny( xImageStream ), _eInstigator ); + setControlValue( Any( xImageStream ), _eInstigator ); xImageStream->closeInput(); return true; } @@ -538,14 +540,14 @@ Any OImageControlModel::translateDbColumnToControlValue() Reference< XInputStream > xImageStream( m_xColumn->getBinaryStream() ); if ( m_xColumn->wasNull() ) xImageStream.clear(); - return makeAny( xImageStream ); + return Any( xImageStream ); } case ImageStoreLink: { OUString sImageLink( m_xColumn->getString() ); if ( !m_sDocumentURL.isEmpty() ) sImageLink = INetURLObject::GetAbsURL( m_sDocumentURL, sImageLink ); - return makeAny( sImageLink ); + return Any( sImageLink ); } case ImageStoreInvalid: OSL_FAIL( "OImageControlModel::translateDbColumnToControlValue: invalid field type!" ); @@ -557,7 +559,7 @@ Any OImageControlModel::translateDbColumnToControlValue() Any OImageControlModel::getControlValue( ) const { - return makeAny( m_sImageURL ); + return Any( m_sImageURL ); } @@ -646,7 +648,7 @@ IMPL_LINK( OImageControlModel, OnImageImportDone, ::Graphic*, i_pGraphic, void ) m_bExternalGraphic = false; try { - setPropertyValue( PROPERTY_GRAPHIC, makeAny( xGraphic ) ); + setPropertyValue( PROPERTY_GRAPHIC, Any( xGraphic ) ); } catch ( const Exception& ) { @@ -750,12 +752,12 @@ void OImageControlControl::implClearGraphics( bool _bForce ) if ( sOldImageURL.isEmpty() ) // the ImageURL is already empty, so simply setting a new empty one would not suffice // (since it would be ignored) - xSet->setPropertyValue( PROPERTY_IMAGE_URL, makeAny( OUString( "private:emptyImage" ) ) ); + xSet->setPropertyValue( PROPERTY_IMAGE_URL, Any( OUString( "private:emptyImage" ) ) ); // (the concrete URL we're passing here doesn't matter. It's important that // the model cannot resolve it to a valid resource describing an image stream } - xSet->setPropertyValue( PROPERTY_IMAGE_URL, makeAny( OUString() ) ); + xSet->setPropertyValue( PROPERTY_IMAGE_URL, Any( OUString() ) ); } @@ -765,7 +767,7 @@ bool OImageControlControl::implInsertGraphics() if ( !xSet.is() ) return false; - OUString sTitle = FRM_RES_STRING(RID_STR_IMPORT_GRAPHIC); + OUString sTitle = ResourceManager::loadString(RID_STR_IMPORT_GRAPHIC); // build some arguments for the upcoming dialog try { @@ -794,7 +796,7 @@ bool OImageControlControl::implInsertGraphics() OSL_VERIFY( xBoundField->getPropertyValue( PROPERTY_FIELDTYPE ) >>= nFieldType ); bImageIsLinked = ( lcl_getImageStoreType( nFieldType ) == ImageStoreLink ); } - xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, makeAny( bImageIsLinked ) ); + xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, Any( bImageIsLinked ) ); if ( ERRCODE_NONE == aDialog.Execute() ) { @@ -812,10 +814,10 @@ bool OImageControlControl::implInsertGraphics() { Graphic aGraphic; aDialog.GetGraphic( aGraphic ); - xSet->setPropertyValue( PROPERTY_GRAPHIC, makeAny( aGraphic.GetXGraphic() ) ); + xSet->setPropertyValue( PROPERTY_GRAPHIC, Any( aGraphic.GetXGraphic() ) ); } else - xSet->setPropertyValue( PROPERTY_IMAGE_URL, makeAny( aDialog.GetPath() ) ); + xSet->setPropertyValue( PROPERTY_IMAGE_URL, Any( aDialog.GetPath() ) ); return true; } @@ -868,8 +870,8 @@ void OImageControlControl::mousePressed(const css::awt::MouseEvent& e) if ( xMenu.is() && xWindowPeer.is() ) { - xMenu->insertItem( ID_OPEN_GRAPHICS, FRM_RES_STRING( RID_STR_OPEN_GRAPHICS ), 0, 0 ); - xMenu->insertItem( ID_CLEAR_GRAPHICS, FRM_RES_STRING( RID_STR_CLEAR_GRAPHICS ), 0, 1 ); + xMenu->insertItem( ID_OPEN_GRAPHICS, ResourceManager::loadString(RID_STR_OPEN_GRAPHICS), 0, 0 ); + xMenu->insertItem( ID_CLEAR_GRAPHICS, ResourceManager::loadString(RID_STR_CLEAR_GRAPHICS), 0, 1 ); // check if the ImageURL is empty if ( impl_isEmptyGraphics_nothrow() ) diff --git a/forms/source/component/ImageControl.hxx b/forms/source/component/ImageControl.hxx index 8776d891e83a..245d13163e4f 100644 --- a/forms/source/component/ImageControl.hxx +++ b/forms/source/component/ImageControl.hxx @@ -25,6 +25,7 @@ #include <com/sun/star/awt/XMouseListener.hpp> #include <com/sun/star/util/XModifyBroadcaster.hpp> #include <com/sun/star/graphic/XGraphicObject.hpp> +#include <comphelper/interfacecontainer3.hxx> #include <cppuhelper/implbase2.hxx> #include <rtl/ref.hxx> @@ -57,7 +58,14 @@ class OImageControlModel final ImageProducer* GetImageProducer() { return m_xImageProducer.get(); } public: - DECLARE_DEFAULT_LEAF_XTOR( OImageControlModel ); + OImageControlModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OImageControlModel( + const OImageControlModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OImageControlModel() override; virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle ) const override; virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any& rValue) override; @@ -138,7 +146,7 @@ class OImageControlControl : public OBoundControl , public OImageControlControl_Base { private: - ::comphelper::OInterfaceContainerHelper2 m_aModifyListeners; + ::comphelper::OInterfaceContainerHelper3<css::util::XModifyListener> m_aModifyListeners; // XTypeProvider virtual css::uno::Sequence< css::uno::Type> _getTypes() override; diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index 2f95f6331f01..33d31180315c 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -28,6 +28,7 @@ #include "BaseListBox.hxx" #include <componenttools.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/sdbc/XRow.hpp> @@ -44,7 +45,7 @@ #include <o3tl/any.hxx> #include <o3tl/safeint.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> #include <unotools/sharedunocomponent.hxx> @@ -98,7 +99,7 @@ namespace frm void operator()( const ORowSetValue& _append ) { - m_string += _append; + m_string += _append.getString(); } private: @@ -193,7 +194,12 @@ namespace frm // XCloneable - IMPLEMENT_DEFAULT_CLONING( OListBoxModel ) + css::uno::Reference< css::util::XCloneable > SAL_CALL OListBoxModel::createClone() +{ + rtl::Reference<OListBoxModel> pClone = new OListBoxModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} // XServiceInfo @@ -467,6 +473,10 @@ namespace frm ); if ( ( pSelectedItemsPos != _rPropertyNames.end() ) && aStringItemListExists ) { + if (_rPropertyNames.getLength() != _rValues.getLength()) + throw css::lang::IllegalArgumentException("lengths do not match", + static_cast<cppu::OWeakObject*>(this), -1); + // both properties are present // -> remember the value for the select sequence pSelectSequenceValue = _rValues.getConstArray() + ( pSelectedItemsPos - _rPropertyNames.begin() ); @@ -487,18 +497,21 @@ namespace frm void OListBoxModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 10, OBoundControlModel ) - DECL_PROP1(TABINDEX, sal_Int16, BOUND); - DECL_PROP2(BOUNDCOLUMN, sal_Int16, BOUND, MAYBEVOID); - DECL_PROP1(LISTSOURCETYPE, ListSourceType, BOUND); - DECL_PROP1(LISTSOURCE, css::uno::Sequence<OUString>, BOUND); - DECL_PROP3(VALUE_SEQ, css::uno::Sequence<OUString>, BOUND, READONLY, TRANSIENT); - DECL_PROP2(SELECT_VALUE_SEQ, Sequence< Any >, BOUND, TRANSIENT); - DECL_PROP2(SELECT_VALUE, Any, BOUND, TRANSIENT); - DECL_PROP1(DEFAULT_SELECT_SEQ, Sequence<sal_Int16>, BOUND); - DECL_PROP1(STRINGITEMLIST, Sequence< OUString >, BOUND); - DECL_PROP1(TYPEDITEMLIST, Sequence< Any >, OPTIONAL); - END_DESCRIBE_PROPERTIES(); + OBoundControlModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 10); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_BOUNDCOLUMN, PROPERTY_ID_BOUNDCOLUMN, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID); + *pProperties++ = css::beans::Property(PROPERTY_LISTSOURCETYPE, PROPERTY_ID_LISTSOURCETYPE, cppu::UnoType<ListSourceType>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_LISTSOURCE, PROPERTY_ID_LISTSOURCE, cppu::UnoType<css::uno::Sequence<OUString>>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_VALUE_SEQ, PROPERTY_ID_VALUE_SEQ, cppu::UnoType<css::uno::Sequence<OUString>>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_SELECT_VALUE_SEQ, PROPERTY_ID_SELECT_VALUE_SEQ, cppu::UnoType<Sequence< Any >>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_SELECT_VALUE, PROPERTY_ID_SELECT_VALUE, cppu::UnoType<Any>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_DEFAULT_SELECT_SEQ, PROPERTY_ID_DEFAULT_SELECT_SEQ, cppu::UnoType<Sequence<sal_Int16>>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_STRINGITEMLIST, PROPERTY_ID_STRINGITEMLIST, cppu::UnoType<Sequence< OUString >>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TYPEDITEMLIST, PROPERTY_ID_TYPEDITEMLIST, cppu::UnoType<Sequence< Any >>::get(), css::beans::PropertyAttribute::OPTIONAL); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } @@ -681,8 +694,8 @@ namespace frm && !hasExternalListSource() ) { - setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( css::uno::Sequence<OUString>() ) ); - setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, makeAny( css::uno::Sequence<css::uno::Any>() ) ); + setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, Any( css::uno::Sequence<OUString>() ) ); + setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, Any( css::uno::Sequence<css::uno::Any>() ) ); } if (nVersion > 3) @@ -851,7 +864,7 @@ namespace frm } catch(const SQLException& eSQL) { - onError(eSQL, FRM_RES_STRING(RID_BASELISTBOX_ERROR_FILLLIST)); + onError(eSQL, ResourceManager::loadString(RID_BASELISTBOX_ERROR_FILLLIST)); return; } catch(const Exception&) @@ -980,7 +993,7 @@ namespace frm } catch(const SQLException& eSQL) { - onError(eSQL, FRM_RES_STRING(RID_BASELISTBOX_ERROR_FILLLIST)); + onError(eSQL, ResourceManager::loadString(RID_BASELISTBOX_ERROR_FILLLIST)); return; } catch( const Exception& ) @@ -1002,8 +1015,8 @@ namespace frm setBoundValues(std::move(aValueList)); - setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( lcl_convertToStringSequence( aDisplayList ) ) ); - setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, makeAny( css::uno::Sequence<css::uno::Any>() ) ); + setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, Any( lcl_convertToStringSequence( aDisplayList ) ) ); + setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, Any( css::uno::Sequence<css::uno::Any>() ) ); } @@ -1030,7 +1043,7 @@ namespace frm if ( m_eListSourceType != ListSourceType_VALUELIST ) { if ( !hasExternalListSource() ) - setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( css::uno::Sequence<OUString>() ) ); + setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, Any( css::uno::Sequence<OUString>() ) ); m_aListRowSet.dispose(); } @@ -1178,8 +1191,7 @@ namespace frm { if ( m_nNULLPos != -1 ) { - aSelectionIndicies.realloc(1); - aSelectionIndicies[0] = m_nNULLPos; + aSelectionIndicies = { m_nNULLPos }; } } else @@ -1191,8 +1203,7 @@ namespace frm ValueList::const_iterator curValuePos = ::std::find( aValues.begin(), aValues.end(), v ); if ( curValuePos != aValues.end() ) { - aSelectionIndicies.realloc( 1 ); - aSelectionIndicies[0] = curValuePos - aValues.begin(); + aSelectionIndicies = { o3tl::narrowing<sal_Int16>(curValuePos - aValues.begin()) }; } } @@ -1255,7 +1266,7 @@ namespace frm m_aSaveValue = aCurrentValue; - return makeAny( translateDbValueToControlValue(aCurrentValue) ); + return Any( translateDbValueToControlValue(aCurrentValue) ); #else return Any(); #endif @@ -1389,10 +1400,9 @@ namespace frm { sal_Int32 nSelectIndex = -1; OSL_VERIFY( _rExternalValue >>= nSelectIndex ); - if ( ( nSelectIndex >= 0 ) && ( nSelectIndex < static_cast<sal_Int32>(getStringItemList().size()) ) ) + if ( ( nSelectIndex >= 0 ) && ( o3tl::make_unsigned(nSelectIndex) < getStringItemList().size() ) ) { - aSelectIndexes.realloc( 1 ); - aSelectIndexes[ 0 ] = static_cast< sal_Int16 >( nSelectIndex ); + aSelectIndexes = { o3tl::narrowing<sal_Int16>(nSelectIndex) }; } } break; @@ -1406,7 +1416,7 @@ namespace frm ::std::set< sal_Int16 > aSelectionSet; // find the selection entries in our item list - for ( OUString const & selectEntry : std::as_const(aSelectEntries) ) + for (OUString const& selectEntry : aSelectEntries) { int idx = 0; for(const OUString& s : getStringItemList()) @@ -1440,7 +1450,7 @@ namespace frm break; } - return makeAny( aSelectIndexes ); + return Any( aSelectIndexes ); } @@ -1514,7 +1524,7 @@ namespace frm aSelectedEntriesTexts.getArray(), ExtractStringFromSequence_Safe( _rStringList ) ); - return makeAny( aSelectedEntriesTexts ); + return Any( aSelectedEntriesTexts ); } @@ -1725,8 +1735,8 @@ namespace frm suspendValueListening(); try { - m_xAggregateSet->setPropertyValue( PROPERTY_STRINGITEMLIST, makeAny( comphelper::containerToSequence(getStringItemList()) ) ); - m_xAggregateSet->setPropertyValue( PROPERTY_TYPEDITEMLIST, makeAny( getTypedItemList() ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_STRINGITEMLIST, Any( comphelper::containerToSequence(getStringItemList()) ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_TYPEDITEMLIST, Any( getTypedItemList() ) ); } catch( const Exception& ) { @@ -1746,7 +1756,7 @@ namespace frm else { if ( m_aDefaultSelectSeq.hasElements() ) - setControlValue( makeAny( m_aDefaultSelectSeq ), eOther ); + setControlValue( Any( m_aDefaultSelectSeq ), eOther ); } } } diff --git a/forms/source/component/ListBox.hxx b/forms/source/component/ListBox.hxx index b4b51d4d8ce0..cad8cc708b4b 100644 --- a/forms/source/component/ListBox.hxx +++ b/forms/source/component/ListBox.hxx @@ -30,6 +30,7 @@ #include <com/sun/star/awt/XListBox.hpp> #include <com/sun/star/form/XChangeBroadcaster.hpp> +#include <comphelper/interfacecontainer3.hxx> #include <comphelper/asyncnotification.hxx> #include <connectivity/FValue.hxx> #include <cppuhelper/implbase4.hxx> @@ -121,7 +122,14 @@ private: virtual css::uno::Sequence< css::uno::Type> _getTypes() override; public: - DECLARE_DEFAULT_LEAF_XTOR( OListBoxModel ); + OListBoxModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OListBoxModel( + const OListBoxModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OListBoxModel() override; // XServiceInfo OUString SAL_CALL getImplementationName() override @@ -238,8 +246,8 @@ class OListBoxControl :public OBoundControl ,public IEventProcessor { private: - ::comphelper::OInterfaceContainerHelper2 m_aChangeListeners; - ::comphelper::OInterfaceContainerHelper2 m_aItemListeners; + ::comphelper::OInterfaceContainerHelper3<css::form::XChangeListener> m_aChangeListeners; + ::comphelper::OInterfaceContainerHelper3<css::awt::XItemListener> m_aItemListeners; css::uno::Any m_aCurrentSelection; Idle m_aChangeIdle; diff --git a/forms/source/component/Numeric.cxx b/forms/source/component/Numeric.cxx index 9fb87e0b4695..b3465d7c940c 100644 --- a/forms/source/component/Numeric.cxx +++ b/forms/source/component/Numeric.cxx @@ -21,6 +21,8 @@ #include <services.hxx> #include <property.hxx> #include <comphelper/types.hxx> +#include <tools/debug.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> namespace frm @@ -30,13 +32,8 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::io; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; -using namespace ::com::sun::star::form::binding; ONumericControl::ONumericControl(const Reference<XComponentContext>& _rxFactory) :OBoundControl(_rxFactory, VCL_CONTROL_NUMERICFIELD) @@ -59,7 +56,7 @@ css::uno::Sequence<OUString> ONumericControl::getSupportedServiceNames() ONumericModel::ONumericModel(const Reference<XComponentContext>& _rxFactory) :OEditBaseModel( _rxFactory, VCL_CONTROLMODEL_NUMERICFIELD, FRM_SUN_CONTROL_NUMERICFIELD, true, true ) - // use the old control name for compytibility reasons + // use the old control name for compatibility reasons { m_nClassId = FormComponentType::NUMERICFIELD; @@ -79,7 +76,12 @@ ONumericModel::~ONumericModel() // XCloneable -IMPLEMENT_DEFAULT_CLONING( ONumericModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL ONumericModel::createClone() +{ + rtl::Reference<ONumericModel> pClone = new ONumericModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} // XServiceInfo @@ -110,10 +112,13 @@ css::uno::Sequence<OUString> ONumericModel::getSupportedServiceNames() void ONumericModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 2, OEditBaseModel ) - DECL_PROP3(DEFAULT_VALUE, double, BOUND, MAYBEDEFAULT, MAYBEVOID); - DECL_PROP1(TABINDEX, sal_Int16, BOUND); - END_DESCRIBE_PROPERTIES(); + OEditBaseModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 2); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_DEFAULT_VALUE, PROPERTY_ID_DEFAULT_VALUE, cppu::UnoType<double>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT | css::beans::PropertyAttribute::MAYBEVOID); + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } diff --git a/forms/source/component/Numeric.hxx b/forms/source/component/Numeric.hxx index 6a77cc556dce..0b5cb703eca2 100644 --- a/forms/source/component/Numeric.hxx +++ b/forms/source/component/Numeric.hxx @@ -32,7 +32,14 @@ private: css::uno::Any m_aSaveValue; public: - DECLARE_DEFAULT_LEAF_XTOR( ONumericModel ); + ONumericModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + ONumericModel( + const ONumericModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~ONumericModel() override; // css::lang::XServiceInfo OUString SAL_CALL getImplementationName() override diff --git a/forms/source/component/Pattern.cxx b/forms/source/component/Pattern.cxx index 129bbd3753f7..acd0d419e18e 100644 --- a/forms/source/component/Pattern.cxx +++ b/forms/source/component/Pattern.cxx @@ -20,6 +20,8 @@ #include "Pattern.hxx" #include <property.hxx> #include <services.hxx> +#include <tools/debug.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> using ::com::sun::star::uno::Reference; @@ -28,7 +30,6 @@ using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::beans::Property; using ::com::sun::star::uno::XInterface; using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::makeAny; using ::com::sun::star::sdbc::XRowSet; using ::com::sun::star::uno::UNO_QUERY; @@ -59,7 +60,7 @@ css::uno::Sequence<OUString> OPatternControl::getSupportedServiceNames() OPatternModel::OPatternModel(const Reference<XComponentContext>& _rxFactory) :OEditBaseModel( _rxFactory, VCL_CONTROLMODEL_PATTERNFIELD, FRM_SUN_CONTROL_PATTERNFIELD, false, false ) - // use the old control name for compytibility reasons + // use the old control name for compatibility reasons { m_nClassId = FormComponentType::PATTERNFIELD; @@ -79,7 +80,12 @@ OPatternModel::~OPatternModel() // XCloneable -IMPLEMENT_DEFAULT_CLONING( OPatternModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL OPatternModel::createClone() +{ + rtl::Reference<OPatternModel> pClone = new OPatternModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} // XServiceInfo @@ -98,12 +104,16 @@ css::uno::Sequence<OUString> SAL_CALL OPatternModel::getSupportedServiceNames() void OPatternModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 4, OEditBaseModel ) - DECL_PROP2(DEFAULT_TEXT, OUString, BOUND, MAYBEDEFAULT); - DECL_BOOL_PROP1(EMPTY_IS_NULL, BOUND); - DECL_PROP1(TABINDEX, sal_Int16, BOUND); - DECL_PROP2(FILTERPROPOSAL, sal_Bool, BOUND, MAYBEDEFAULT); - END_DESCRIBE_PROPERTIES(); + OEditBaseModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 4); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_DEFAULT_TEXT, PROPERTY_ID_DEFAULT_TEXT, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_EMPTY_IS_NULL, PROPERTY_ID_EMPTY_IS_NULL, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_FILTERPROPOSAL, PROPERTY_ID_FILTERPROPOSAL, cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } @@ -117,33 +127,33 @@ bool OPatternModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) { Any aNewValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) ); - if ( aNewValue != m_aLastKnownValue ) - { - OUString sNewValue; - aNewValue >>= sNewValue; + if ( aNewValue == m_aLastKnownValue ) + return true; - if ( !aNewValue.hasValue() - || ( sNewValue.isEmpty() // an empty string - && m_bEmptyIsNull // which should be interpreted as NULL - ) - ) - { - m_xColumnUpdate->updateNull(); - } - else - { - OSL_ENSURE(m_pFormattedValue, - "OPatternModel::commitControlValueToDbColumn: no value helper!"); - if (!m_pFormattedValue) - return false; + OUString sNewValue; + aNewValue >>= sNewValue; - if ( !m_pFormattedValue->setFormattedValue( sNewValue ) ) - return false; - } + if ( !aNewValue.hasValue() + || ( sNewValue.isEmpty() // an empty string + && m_bEmptyIsNull // which should be interpreted as NULL + ) + ) + { + m_xColumnUpdate->updateNull(); + } + else + { + OSL_ENSURE(m_pFormattedValue, + "OPatternModel::commitControlValueToDbColumn: no value helper!"); + if (!m_pFormattedValue) + return false; - m_aLastKnownValue = aNewValue; + if ( !m_pFormattedValue->setFormattedValue( sNewValue ) ) + return false; } + m_aLastKnownValue = aNewValue; + return true; } @@ -191,7 +201,7 @@ Any OPatternModel::translateDbColumnToControlValue() else m_aLastKnownValue.clear(); - return m_aLastKnownValue.hasValue() ? m_aLastKnownValue : makeAny( OUString() ); + return m_aLastKnownValue.hasValue() ? m_aLastKnownValue : Any( OUString() ); // (m_aLastKnownValue is allowed to be VOID, the control value isn't) } @@ -199,7 +209,7 @@ Any OPatternModel::translateDbColumnToControlValue() Any OPatternModel::getDefaultForReset() const { - return makeAny( m_aDefaultText ); + return Any( m_aDefaultText ); } void OPatternModel::resetNoBroadcast() diff --git a/forms/source/component/Pattern.hxx b/forms/source/component/Pattern.hxx index d7cfa9d09f0d..d0923c13cf58 100644 --- a/forms/source/component/Pattern.hxx +++ b/forms/source/component/Pattern.hxx @@ -38,7 +38,14 @@ private: m_pFormattedValue; public: - DECLARE_DEFAULT_LEAF_XTOR( OPatternModel ); + OPatternModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OPatternModel( + const OPatternModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OPatternModel() override; // css::lang::XServiceInfo OUString SAL_CALL getImplementationName() override diff --git a/forms/source/component/RadioButton.cxx b/forms/source/component/RadioButton.cxx index d066e26a6e7e..3a6ffb139642 100644 --- a/forms/source/component/RadioButton.cxx +++ b/forms/source/component/RadioButton.cxx @@ -23,6 +23,8 @@ #include <services.hxx> #include <comphelper/basicio.hxx> #include <comphelper/property.hxx> +#include <tools/debug.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/form/FormComponentType.hpp> @@ -34,11 +36,8 @@ using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; -using namespace ::com::sun::star::awt; using namespace ::com::sun::star::io; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; -using namespace ::com::sun::star::form::binding; css::uno::Sequence<OUString> SAL_CALL ORadioButtonControl::getSupportedServiceNames() @@ -61,7 +60,7 @@ ORadioButtonControl::ORadioButtonControl(const Reference<XComponentContext>& _rx ORadioButtonModel::ORadioButtonModel(const Reference<XComponentContext>& _rxFactory) :OReferenceValueComponent( _rxFactory, VCL_CONTROLMODEL_RADIOBUTTON, FRM_SUN_CONTROL_RADIOBUTTON ) - // use the old control name for compytibility reasons + // use the old control name for compatibility reasons { m_nClassId = FormComponentType::RADIOBUTTON; @@ -83,7 +82,12 @@ ORadioButtonModel::~ORadioButtonModel() // XCloneable -IMPLEMENT_DEFAULT_CLONING( ORadioButtonModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL ORadioButtonModel::createClone() +{ + rtl::Reference<ORadioButtonModel> pClone = new ORadioButtonModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} // XServiceInfo @@ -238,9 +242,12 @@ void ORadioButtonModel::setControlSource() void ORadioButtonModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 1, OReferenceValueComponent ) - DECL_PROP1(TABINDEX, sal_Int16, BOUND); - END_DESCRIBE_PROPERTIES(); + OReferenceValueComponent::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 1); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } @@ -336,7 +343,7 @@ void ORadioButtonModel::_propertyChanged(const PropertyChangeEvent& _rEvent) Any ORadioButtonModel::translateDbColumnToControlValue() { - return makeAny( static_cast<sal_Int16>( ( m_xColumn->getString() == getReferenceValue() ) ? TRISTATE_TRUE : TRISTATE_FALSE ) + return Any( static_cast<sal_Int16>( ( m_xColumn->getString() == getReferenceValue() ) ? TRISTATE_TRUE : TRISTATE_FALSE ) ); } @@ -363,7 +370,7 @@ bool ORadioButtonModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) sal_Int16 nValue = 0; m_xAggregateSet->getPropertyValue( PROPERTY_STATE ) >>= nValue; if ( nValue == 1 ) - xField->setPropertyValue( PROPERTY_VALUE, makeAny( getReferenceValue() ) ); + xField->setPropertyValue( PROPERTY_VALUE, Any( getReferenceValue() ) ); } catch(const Exception&) { diff --git a/forms/source/component/RadioButton.hxx b/forms/source/component/RadioButton.hxx index b85a0a27ef9f..0e50acfc4245 100644 --- a/forms/source/component/RadioButton.hxx +++ b/forms/source/component/RadioButton.hxx @@ -28,7 +28,14 @@ namespace frm class ORadioButtonModel final : public OReferenceValueComponent { public: - DECLARE_DEFAULT_LEAF_XTOR( ORadioButtonModel ); + ORadioButtonModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + ORadioButtonModel( + const ORadioButtonModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~ORadioButtonModel() override; // XServiceInfo OUString SAL_CALL getImplementationName() override diff --git a/forms/source/component/Time.cxx b/forms/source/component/Time.cxx index 8ab3e9a10390..2b8c2339b80f 100644 --- a/forms/source/component/Time.cxx +++ b/forms/source/component/Time.cxx @@ -21,6 +21,8 @@ #include <property.hxx> #include <services.hxx> #include <connectivity/dbconversion.hxx> +#include <tools/debug.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/util/DateTime.hpp> #include <com/sun/star/form/FormComponentType.hpp> @@ -35,12 +37,8 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; using namespace ::com::sun::star::util; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::io; -using namespace ::com::sun::star::lang; //= @@ -134,7 +132,12 @@ OTimeModel::~OTimeModel( ) // XCloneable -IMPLEMENT_DEFAULT_CLONING( OTimeModel ) +css::uno::Reference< css::util::XCloneable > SAL_CALL OTimeModel::createClone() +{ + rtl::Reference<OTimeModel> pClone = new OTimeModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} OUString SAL_CALL OTimeModel::getServiceName() @@ -146,12 +149,16 @@ OUString SAL_CALL OTimeModel::getServiceName() void OTimeModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 4, OEditBaseModel ) - DECL_PROP3(DEFAULT_TIME, util::Time, BOUND, MAYBEDEFAULT, MAYBEVOID); - DECL_PROP1(TABINDEX, sal_Int16, BOUND); - DECL_PROP1(FORMATKEY, sal_Int32, TRANSIENT); - DECL_IFACE_PROP2(FORMATSSUPPLIER, XNumberFormatsSupplier, READONLY, TRANSIENT); - END_DESCRIBE_PROPERTIES(); + OEditBaseModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 4); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_DEFAULT_TIME, PROPERTY_ID_DEFAULT_TIME, cppu::UnoType<util::Time>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT | css::beans::PropertyAttribute::MAYBEVOID); + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_FORMATKEY, PROPERTY_ID_FORMATKEY, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_FORMATSSUPPLIER, PROPERTY_ID_FORMATSSUPPLIER, cppu::UnoType<XNumberFormatsSupplier>::get(), + css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } @@ -215,43 +222,43 @@ void OTimeModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm ) bool OTimeModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) { Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) ); - if ( aControlValue != m_aSaveValue ) + if ( aControlValue == m_aSaveValue ) + return true; + + if ( !aControlValue.hasValue() ) + m_xColumnUpdate->updateNull(); + else { - if ( !aControlValue.hasValue() ) - m_xColumnUpdate->updateNull(); - else + try { - try + util::Time aTime; + if ( !( aControlValue >>= aTime ) ) { - util::Time aTime; - if ( !( aControlValue >>= aTime ) ) - { - sal_Int64 nAsInt(0); - aControlValue >>= nAsInt; - aTime = DBTypeConversion::toTime(nAsInt); - } - - if (!m_bDateTimeField) - m_xColumnUpdate->updateTime(aTime); - else - { - util::DateTime aDateTime = m_xColumn->getTimestamp(); - if (aDateTime.Year == 0 && aDateTime.Month == 0 && aDateTime.Day == 0) - aDateTime = ::com::sun::star::util::DateTime(0,0,0,0,30,12,1899, false); - aDateTime.NanoSeconds = aTime.NanoSeconds; - aDateTime.Seconds = aTime.Seconds; - aDateTime.Minutes = aTime.Minutes; - aDateTime.Hours = aTime.Hours; - m_xColumnUpdate->updateTimestamp(aDateTime); - } + sal_Int64 nAsInt(0); + aControlValue >>= nAsInt; + aTime = DBTypeConversion::toTime(nAsInt); } - catch(const Exception&) + + if (!m_bDateTimeField) + m_xColumnUpdate->updateTime(aTime); + else { - return false; + util::DateTime aDateTime = m_xColumn->getTimestamp(); + if (aDateTime.Year == 0 && aDateTime.Month == 0 && aDateTime.Day == 0) + aDateTime = ::com::sun::star::util::DateTime(0,0,0,0,30,12,1899, false); + aDateTime.NanoSeconds = aTime.NanoSeconds; + aDateTime.Seconds = aTime.Seconds; + aDateTime.Minutes = aTime.Minutes; + aDateTime.Hours = aTime.Hours; + m_xColumnUpdate->updateTimestamp(aDateTime); } } - m_aSaveValue = aControlValue; + catch(const Exception&) + { + return false; + } } + m_aSaveValue = aControlValue; return true; } diff --git a/forms/source/component/Time.hxx b/forms/source/component/Time.hxx index d1187d39f318..3a6793fa5c81 100644 --- a/forms/source/component/Time.hxx +++ b/forms/source/component/Time.hxx @@ -38,7 +38,14 @@ protected: virtual css::uno::Sequence< css::uno::Type> _getTypes() override; public: - DECLARE_DEFAULT_LEAF_XTOR( OTimeModel ); + OTimeModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OTimeModel( + const OTimeModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OTimeModel() override; // css::io::XPersistObject virtual OUString SAL_CALL getServiceName() override; diff --git a/forms/source/component/cachedrowset.cxx b/forms/source/component/cachedrowset.cxx index 77368f76cff2..a2cfaf252903 100644 --- a/forms/source/component/cachedrowset.cxx +++ b/forms/source/component/cachedrowset.cxx @@ -26,7 +26,7 @@ #include <com/sun/star/sdbc/SQLException.hpp> #include <com/sun/star/sdbc/ResultSetType.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace frm @@ -39,7 +39,7 @@ namespace frm using ::com::sun::star::uno::Exception; using ::com::sun::star::sdbc::XConnection; using ::com::sun::star::beans::XPropertySet; - using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Any; using ::com::sun::star::sdbc::SQLException; using ::com::sun::star::sdb::XQueriesSupplier; using ::com::sun::star::container::XNameAccess; @@ -132,8 +132,8 @@ namespace frm Reference< XStatement > xStatement( m_pData->xConnection->createStatement(), UNO_SET_THROW ); Reference< XPropertySet > xStatementProps( xStatement, UNO_QUERY_THROW ); - xStatementProps->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, makeAny( m_pData->bEscapeProcessing ) ); - xStatementProps->setPropertyValue( PROPERTY_RESULTSET_TYPE, makeAny( ResultSetType::FORWARD_ONLY ) ); + xStatementProps->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, Any( m_pData->bEscapeProcessing ) ); + xStatementProps->setPropertyValue( PROPERTY_RESULTSET_TYPE, Any( ResultSetType::FORWARD_ONLY ) ); xResult.set( xStatement->executeQuery( m_pData->sCommand ), UNO_SET_THROW ); m_pData->bStatementDirty = false; diff --git a/forms/source/component/clickableimage.cxx b/forms/source/component/clickableimage.cxx index 8dd3489967f5..02187ee2aabd 100644 --- a/forms/source/component/clickableimage.cxx +++ b/forms/source/component/clickableimage.cxx @@ -28,13 +28,12 @@ #include <com/sun/star/frame/XController.hpp> #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/awt/ActionEvent.hpp> -#include <com/sun/star/awt/XActionListener.hpp> #include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/graphic/GraphicObject.hpp> #include <com/sun/star/util/VetoException.hpp> #include <tools/urlobj.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <vcl/graph.hxx> #include <vcl/svapp.hxx> #include <sfx2/docfile.hxx> @@ -42,8 +41,9 @@ #include <osl/mutex.hxx> #include <property.hxx> #include <services.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer3.hxx> #include <comphelper/property.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/types.hxx> #include <cppuhelper/exc_hlp.hxx> #include <svtools/imageresourceaccess.hxx> @@ -61,7 +61,6 @@ namespace frm using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; using namespace ::com::sun::star::awt; - using namespace ::com::sun::star::io; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; using namespace ::com::sun::star::frame; @@ -85,10 +84,10 @@ namespace frm OClickableImageBaseControl::OClickableImageBaseControl(const Reference<XComponentContext>& _rxFactory, const OUString& _aService) :OControl(_rxFactory, _aService) ,m_aSubmissionVetoListeners( m_aMutex ) + ,m_aFeatureInterception( _rxFactory ) ,m_aApproveActionListeners( m_aMutex ) ,m_aActionListeners( m_aMutex ) { - m_pFeatureInterception.reset( new ControlFeatureInterception( _rxFactory ) ); } @@ -129,13 +128,13 @@ namespace frm void SAL_CALL OClickableImageBaseControl::registerDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) { - m_pFeatureInterception->registerDispatchProviderInterceptor( _rxInterceptor ); + m_aFeatureInterception.registerDispatchProviderInterceptor( _rxInterceptor ); } void SAL_CALL OClickableImageBaseControl::releaseDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) { - m_pFeatureInterception->releaseDispatchProviderInterceptor( _rxInterceptor ); + m_aFeatureInterception.releaseDispatchProviderInterceptor( _rxInterceptor ); } // OComponentHelper @@ -146,7 +145,7 @@ namespace frm m_aApproveActionListeners.disposeAndClear( aEvent ); m_aActionListeners.disposeAndClear( aEvent ); m_aSubmissionVetoListeners.disposeAndClear( aEvent ); - m_pFeatureInterception->dispose(); + m_aFeatureInterception.dispose(); { ::osl::MutexGuard aGuard( m_aMutex ); @@ -173,11 +172,11 @@ namespace frm bool bCancelled = false; EventObject aEvent( static_cast< XWeak* >( this ) ); - ::comphelper::OInterfaceIteratorHelper2 aIter( m_aApproveActionListeners ); + ::comphelper::OInterfaceIteratorHelper3 aIter( m_aApproveActionListeners ); while( !bCancelled && aIter.hasMoreElements() ) { // Every approveAction method must be thread-safe! - if( !static_cast< XApproveActionListener* >( aIter.next() )->approveAction( aEvent ) ) + if( !aIter.next()->approveAction( aEvent ) ) bCancelled = true; } @@ -234,7 +233,7 @@ namespace frm case FormButtonType_SUBMIT: { // if some outer component can provide an interaction handler, use it - Reference< XInteractionHandler > xHandler( m_pFeatureInterception->queryDispatch( "private:/InteractionHandler" ), UNO_QUERY ); + Reference< XInteractionHandler > xHandler( m_aFeatureInterception.queryDispatch( "private:/InteractionHandler" ), UNO_QUERY ); try { implSubmit( rEvt, xHandler ); @@ -292,7 +291,7 @@ namespace frm xSet->getPropertyValue(PROPERTY_DISPATCHURLINTERNAL) >>= bDispatchUrlInternal; if ( bDispatchUrlInternal ) { - m_pFeatureInterception->getTransformer().parseSmartWithAsciiProtocol( aURL, INET_FILE_SCHEME ); + m_aFeatureInterception.getTransformer().parseSmartWithProtocol( aURL, INET_FILE_SCHEME ); OUString aTargetFrame; xSet->getPropertyValue(PROPERTY_TARGET_FRAME) >>= aTargetFrame; @@ -301,31 +300,25 @@ namespace frm FrameSearchFlag::SELF | FrameSearchFlag::PARENT | FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE ); - Sequence<PropertyValue> aArgs(1); - PropertyValue& rProp = aArgs.getArray()[0]; - rProp.Name = "Referer"; - rProp.Value <<= xModel->getURL(); + Sequence<PropertyValue> aArgs { comphelper::makePropertyValue("Referer", xModel->getURL()) }; if (xDisp.is()) xDisp->dispatch( aURL, aArgs ); } else { - URL aHyperLink = m_pFeatureInterception->getTransformer().getStrictURL( ".uno:OpenHyperlink" ); + URL aHyperLink = m_aFeatureInterception.getTransformer().getStrictURL( ".uno:OpenHyperlink" ); Reference< XDispatch > xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY_THROW)->queryDispatch(aHyperLink, OUString() , 0); if ( xDisp.is() ) { - Sequence<PropertyValue> aProps(3); - aProps[0].Name = "URL"; - aProps[0].Value <<= aURL.Complete; - - aProps[1].Name = "FrameName"; - aProps[1].Value = xSet->getPropertyValue(PROPERTY_TARGET_FRAME); - - aProps[2].Name = "Referer"; - aProps[2].Value <<= xModel->getURL(); + Sequence<PropertyValue> aProps{ + comphelper::makePropertyValue("URL", aURL.Complete), + comphelper::makePropertyValue( + "FrameName", xSet->getPropertyValue(PROPERTY_TARGET_FRAME)), + comphelper::makePropertyValue("Referer", xModel->getURL()) + }; xDisp->dispatch( aHyperLink, aProps ); } @@ -803,10 +796,10 @@ namespace frm { switch (nHandle) { - case PROPERTY_ID_BUTTONTYPE : return makeAny( FormButtonType_PUSH ); + case PROPERTY_ID_BUTTONTYPE : return Any( FormButtonType_PUSH ); case PROPERTY_ID_TARGET_URL : - case PROPERTY_ID_TARGET_FRAME : return makeAny( OUString() ); - case PROPERTY_ID_DISPATCHURLINTERNAL : return makeAny( false ); + case PROPERTY_ID_TARGET_FRAME : return Any( OUString() ); + case PROPERTY_ID_DISPATCHURLINTERNAL : return Any( false ); default: return OControlModel::getPropertyDefaultByHandle(nHandle); } diff --git a/forms/source/component/clickableimage.hxx b/forms/source/component/clickableimage.hxx index eea5ed827e7d..2ec7b921224b 100644 --- a/forms/source/component/clickableimage.hxx +++ b/forms/source/component/clickableimage.hxx @@ -23,8 +23,11 @@ #include <FormComponent.hxx> #include "EventThread.hxx" #include "imgprod.hxx" +#include <controlfeatureinterception.hxx> #include <tools/link.hxx> +#include <comphelper/interfacecontainer3.hxx> #include <comphelper/propmultiplex.hxx> +#include <com/sun/star/awt/XActionListener.hpp> #include <com/sun/star/form/XImageProducerSupplier.hpp> #include <com/sun/star/form/FormButtonType.hpp> #include <com/sun/star/form/XApproveActionListener.hpp> @@ -43,7 +46,6 @@ namespace frm class OImageProducerThread_Impl; - class ControlFeatureInterception; // OClickableImageBaseModel @@ -91,7 +93,12 @@ namespace frm const OUString& _rUnoControlModelTypeName, const OUString& _rDefault ); - DECLARE_DEFAULT_CLONE_CTOR( OClickableImageBaseModel ) + + OClickableImageBaseModel ( + const OClickableImageBaseModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OClickableImageBaseModel() override; // UNO Binding @@ -181,13 +188,13 @@ namespace frm private: rtl::Reference<OImageProducerThread_Impl> m_pThread; - ::comphelper::OInterfaceContainerHelper2 m_aSubmissionVetoListeners; - ::std::unique_ptr< ControlFeatureInterception > - m_pFeatureInterception; + ::comphelper::OInterfaceContainerHelper3<css::form::submission::XSubmissionVetoListener> + m_aSubmissionVetoListeners; + ControlFeatureInterception m_aFeatureInterception; protected: - ::comphelper::OInterfaceContainerHelper2 m_aApproveActionListeners; - ::comphelper::OInterfaceContainerHelper2 m_aActionListeners; + ::comphelper::OInterfaceContainerHelper3<css::form::XApproveActionListener> m_aApproveActionListeners; + ::comphelper::OInterfaceContainerHelper3<css::awt::XActionListener> m_aActionListeners; OUString m_aActionCommand; // XSubmission diff --git a/forms/source/component/entrylisthelper.cxx b/forms/source/component/entrylisthelper.cxx index ef27610006d2..0f781076328c 100644 --- a/forms/source/component/entrylisthelper.cxx +++ b/forms/source/component/entrylisthelper.cxx @@ -20,6 +20,7 @@ #include "entrylisthelper.hxx" #include <FormComponent.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <comphelper/sequence.hxx> #include <comphelper/property.hxx> @@ -82,13 +83,13 @@ namespace frm OSL_ENSURE( _rEvent.Source == m_xListSource, "OEntryListHelper::entryChanged: where did this come from?" ); - OSL_ENSURE( ( _rEvent.Position >= 0 ) && ( _rEvent.Position < static_cast<sal_Int32>(m_aStringItems.size()) ), + OSL_ENSURE( ( _rEvent.Position >= 0 ) && ( o3tl::make_unsigned(_rEvent.Position) < m_aStringItems.size() ), "OEntryListHelper::entryChanged: invalid index!" ); OSL_ENSURE( _rEvent.Entries.getLength() == 1, "OEntryListHelper::entryChanged: invalid string list!" ); if ( ( _rEvent.Position >= 0 ) - && ( _rEvent.Position < static_cast<sal_Int32>(m_aStringItems.size()) ) + && ( o3tl::make_unsigned(_rEvent.Position) < m_aStringItems.size() ) && _rEvent.Entries.hasElements() ) { @@ -106,11 +107,11 @@ namespace frm OSL_ENSURE( _rEvent.Source == m_xListSource, "OEntryListHelper::entryRangeInserted: where did this come from?" ); - OSL_ENSURE( ( _rEvent.Position > 0 ) && ( _rEvent.Position < static_cast<sal_Int32>(m_aStringItems.size()) ) && _rEvent.Entries.hasElements(), + OSL_ENSURE( ( _rEvent.Position > 0 ) && ( o3tl::make_unsigned(_rEvent.Position) < m_aStringItems.size() ) && _rEvent.Entries.hasElements(), "OEntryListHelper::entryRangeRemoved: invalid count and/or position!" ); if ( ( _rEvent.Position > 0 ) - && ( _rEvent.Position < static_cast<sal_Int32>(m_aStringItems.size()) ) + && ( o3tl::make_unsigned(_rEvent.Position) < m_aStringItems.size() ) && _rEvent.Entries.hasElements() ) { @@ -142,16 +143,17 @@ namespace frm if (_rEvent.Position + _rEvent.Count <= m_aTypedItems.getLength()) { Sequence<Any> aTmp( m_aTypedItems.getLength() - _rEvent.Count ); + auto aTmpRange = asNonConstRange(aTmp); sal_Int32 nStop = _rEvent.Position; sal_Int32 i = 0; for ( ; i < nStop; ++i) { - aTmp[i] = m_aTypedItems[i]; + aTmpRange[i] = m_aTypedItems[i]; } nStop = aTmp.getLength(); for (sal_Int32 j = _rEvent.Position + _rEvent.Count; i < nStop; ++i, ++j) { - aTmp[i] = m_aTypedItems[j]; + aTmpRange[i] = m_aTypedItems[j]; } m_aTypedItems = aTmp; } diff --git a/forms/source/component/entrylisthelper.hxx b/forms/source/component/entrylisthelper.hxx index 58f2369fcbcc..cb0e0789a4aa 100644 --- a/forms/source/component/entrylisthelper.hxx +++ b/forms/source/component/entrylisthelper.hxx @@ -24,7 +24,7 @@ #include <com/sun/star/form/binding/XListEntryListener.hpp> #include <cppuhelper/implbase3.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer3.hxx> namespace frm @@ -53,7 +53,7 @@ namespace frm m_aStringItems; /// "overridden" StringItemList property value css::uno::Sequence< css::uno::Any > m_aTypedItems; /// "overridden" TypedItemList property value - ::comphelper::OInterfaceContainerHelper2 + ::comphelper::OInterfaceContainerHelper3<css::util::XRefreshListener> m_aRefreshListeners; diff --git a/forms/source/component/errorbroadcaster.cxx b/forms/source/component/errorbroadcaster.cxx index 16e362865c7b..7f37e4e0e95a 100644 --- a/forms/source/component/errorbroadcaster.cxx +++ b/forms/source/component/errorbroadcaster.cxx @@ -72,13 +72,7 @@ namespace frm void OErrorBroadcaster::onError( const css::sdb::SQLErrorEvent& _rError ) { - if ( m_aErrorListeners.getLength() ) - { - - ::comphelper::OInterfaceIteratorHelper2 aIter( m_aErrorListeners ); - while ( aIter.hasMoreElements() ) - static_cast< XSQLErrorListener* >( aIter.next() )->errorOccured( _rError ); - } + m_aErrorListeners.notifyEach( &XSQLErrorListener::errorOccured, _rError ); } diff --git a/forms/source/component/errorbroadcaster.hxx b/forms/source/component/errorbroadcaster.hxx index c8ad66c1ee17..17fcb4d0f2d0 100644 --- a/forms/source/component/errorbroadcaster.hxx +++ b/forms/source/component/errorbroadcaster.hxx @@ -22,7 +22,7 @@ #include <cppuhelper/implbase1.hxx> #include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp> #include <cppuhelper/interfacecontainer.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer3.hxx> #include <com/sun/star/sdbc/SQLException.hpp> #include <com/sun/star/sdb/SQLErrorEvent.hpp> @@ -37,7 +37,7 @@ namespace frm { private: ::cppu::OBroadcastHelper& m_rBHelper; - ::comphelper::OInterfaceContainerHelper2 m_aErrorListeners; + ::comphelper::OInterfaceContainerHelper3<css::sdb::XSQLErrorListener> m_aErrorListeners; protected: explicit OErrorBroadcaster( ::cppu::OBroadcastHelper& _rBHelper ); diff --git a/forms/source/component/formcontrolfont.cxx b/forms/source/component/formcontrolfont.cxx index 1399e2b94971..9f6663d09c71 100644 --- a/forms/source/component/formcontrolfont.cxx +++ b/forms/source/component/formcontrolfont.cxx @@ -28,6 +28,7 @@ #include <toolkit/helper/emptyfontdescriptor.hxx> #include <com/sun/star/awt/FontRelief.hpp> #include <com/sun/star/awt/FontEmphasisMark.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> namespace frm @@ -37,7 +38,6 @@ namespace frm using namespace ::comphelper; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; - using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; @@ -193,28 +193,30 @@ namespace frm _rProps.realloc( nPos + 21 ); Property* pProperties = _rProps.getArray(); - DECL_PROP2 ( FONT, FontDescriptor, BOUND, MAYBEDEFAULT ); - DECL_PROP2 ( FONTEMPHASISMARK, sal_Int16, BOUND, MAYBEDEFAULT ); - DECL_PROP2 ( FONTRELIEF, sal_Int16, BOUND, MAYBEDEFAULT ); - DECL_PROP3 ( TEXTCOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ); - DECL_PROP3 ( TEXTLINECOLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ); - - DECL_PROP1 ( FONT_CHARWIDTH, float, MAYBEDEFAULT ); - DECL_BOOL_PROP1 ( FONT_KERNING, MAYBEDEFAULT ); - DECL_PROP1 ( FONT_ORIENTATION, float, MAYBEDEFAULT ); - DECL_PROP1 ( FONT_PITCH, sal_Int16, MAYBEDEFAULT ); - DECL_PROP1 ( FONT_TYPE, sal_Int16, MAYBEDEFAULT ); - DECL_PROP1 ( FONT_WIDTH, sal_Int16, MAYBEDEFAULT ); - DECL_PROP1 ( FONT_NAME, OUString, MAYBEDEFAULT ); - DECL_PROP1 ( FONT_STYLENAME, OUString, MAYBEDEFAULT ); - DECL_PROP1 ( FONT_FAMILY, sal_Int16, MAYBEDEFAULT ); - DECL_PROP1 ( FONT_CHARSET, sal_Int16, MAYBEDEFAULT ); - DECL_PROP1 ( FONT_HEIGHT, float, MAYBEDEFAULT ); - DECL_PROP1 ( FONT_WEIGHT, float, MAYBEDEFAULT ); - DECL_PROP1 ( FONT_SLANT, sal_Int16, MAYBEDEFAULT ); - DECL_PROP1 ( FONT_UNDERLINE, sal_Int16, MAYBEDEFAULT ); - DECL_PROP1 ( FONT_STRIKEOUT, sal_Int16, MAYBEDEFAULT ); - DECL_BOOL_PROP1 ( FONT_WORDLINEMODE, MAYBEDEFAULT ); + *pProperties++ = css::beans::Property(PROPERTY_FONT, PROPERTY_ID_FONT, cppu::UnoType<FontDescriptor>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONTEMPHASISMARK, PROPERTY_ID_FONTEMPHASISMARK, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONTRELIEF, PROPERTY_ID_FONTRELIEF, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_TEXTCOLOR, PROPERTY_ID_TEXTCOLOR, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT | css::beans::PropertyAttribute::MAYBEVOID); + *pProperties++ = css::beans::Property(PROPERTY_TEXTLINECOLOR, PROPERTY_ID_TEXTLINECOLOR, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT | css::beans::PropertyAttribute::MAYBEVOID); + + *pProperties++ = css::beans::Property(PROPERTY_FONT_CHARWIDTH, PROPERTY_ID_FONT_CHARWIDTH, cppu::UnoType<float>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_KERNING, PROPERTY_ID_FONT_KERNING, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_ORIENTATION, PROPERTY_ID_FONT_ORIENTATION, cppu::UnoType<float>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_PITCH, PROPERTY_ID_FONT_PITCH, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_TYPE, PROPERTY_ID_FONT_TYPE, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_WIDTH, PROPERTY_ID_FONT_WIDTH, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_NAME, PROPERTY_ID_FONT_NAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_STYLENAME, PROPERTY_ID_FONT_STYLENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_FAMILY, PROPERTY_ID_FONT_FAMILY, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_CHARSET, PROPERTY_ID_FONT_CHARSET, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_HEIGHT, PROPERTY_ID_FONT_HEIGHT, cppu::UnoType<float>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_WEIGHT, PROPERTY_ID_FONT_WEIGHT, cppu::UnoType<float>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_SLANT, PROPERTY_ID_FONT_SLANT, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_UNDERLINE, PROPERTY_ID_FONT_UNDERLINE, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_STRIKEOUT, PROPERTY_ID_FONT_STRIKEOUT, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::MAYBEDEFAULT); + *pProperties++ = css::beans::Property(PROPERTY_FONT_WORDLINEMODE, PROPERTY_ID_FONT_WORDLINEMODE, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::MAYBEDEFAULT); } @@ -273,7 +275,7 @@ namespace frm case PROPERTY_ID_FONT: { - Any aWorkAroundGccLimitation = makeAny( m_aFont ); + Any aWorkAroundGccLimitation( m_aFont ); bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, aWorkAroundGccLimitation, cppu::UnoType<decltype(m_aFont)>::get() ); } break; @@ -447,7 +449,7 @@ namespace frm // then set that as the actual property - will eventually call // this method recursively again... - (rBase.*pSet)(PROPERTY_ID_FONT, makeAny(font)); + (rBase.*pSet)(PROPERTY_ID_FONT, Any(font)); #ifndef NDEBUG // verify that the nHandle property has the new value Any tmp; @@ -517,7 +519,7 @@ namespace frm { EmptyFontDescriptor aEmpty; if ( PROPERTY_ID_FONT == _nHandle ) - return makeAny( FontDescriptor(aEmpty) ); + return Any( FontDescriptor(aEmpty) ); return lcl_extractFontDescriptorAggregate( _nHandle, aEmpty ); } diff --git a/forms/source/component/imgprod.cxx b/forms/source/component/imgprod.cxx index 5446b2082af7..d281367eb23a 100644 --- a/forms/source/component/imgprod.cxx +++ b/forms/source/component/imgprod.cxx @@ -21,148 +21,26 @@ #include <osl/diagnose.h> #include <tools/debug.hxx> +#include <utility> #include <vcl/BitmapReadAccess.hxx> #include <vcl/cvtgrf.hxx> #include <vcl/svapp.hxx> #include <unotools/ucbstreamhelper.hxx> #include <cppuhelper/queryinterface.hxx> +#include <cppuhelper/supportsservice.hxx> #include <com/sun/star/awt/ImageStatus.hpp> #include <com/sun/star/io/XInputStream.hpp> #include <svtools/imageresourceaccess.hxx> #include <comphelper/processfactory.hxx> -namespace { - -class ImgProdLockBytes : public SvLockBytes -{ - css::uno::Reference< css::io::XInputStream > xStmRef; - css::uno::Sequence<sal_Int8> maSeq; - -public: - - ImgProdLockBytes( SvStream* pStm, bool bOwner ); - explicit ImgProdLockBytes( css::uno::Reference< css::io::XInputStream > const & rStreamRef ); - - virtual ErrCode ReadAt( sal_uInt64 nPos, void* pBuffer, std::size_t nCount, std::size_t * pRead ) const override; - virtual ErrCode WriteAt( sal_uInt64 nPos, const void* pBuffer, std::size_t nCount, std::size_t * pWritten ) override; - virtual ErrCode Flush() const override; - virtual ErrCode SetSize( sal_uInt64 nSize ) override; - virtual ErrCode Stat( SvLockBytesStat* ) const override; -}; - -} - -ImgProdLockBytes::ImgProdLockBytes( SvStream* pStm, bool bOwner ) : - SvLockBytes( pStm, bOwner ) -{ -} - - -ImgProdLockBytes::ImgProdLockBytes( css::uno::Reference< css::io::XInputStream > const & rStmRef ) : - xStmRef( rStmRef ) -{ - if( !xStmRef.is() ) - return; - - const sal_uInt32 nBytesToRead = 65535; - sal_uInt32 nRead; - - do - { - css::uno::Sequence< sal_Int8 > aReadSeq; - - nRead = xStmRef->readSomeBytes( aReadSeq, nBytesToRead ); - - if( nRead ) - { - const sal_uInt32 nOldLength = maSeq.getLength(); - maSeq.realloc( nOldLength + nRead ); - memcpy( maSeq.getArray() + nOldLength, aReadSeq.getConstArray(), aReadSeq.getLength() ); - } - } - while( nBytesToRead == nRead ); -} - -ErrCode ImgProdLockBytes::ReadAt(sal_uInt64 const nPos, - void* pBuffer, std::size_t nCount, std::size_t * pRead) const -{ - if( GetStream() ) - { - const_cast<SvStream*>(GetStream())->ResetError(); - const ErrCode nErr = SvLockBytes::ReadAt( nPos, pBuffer, nCount, pRead ); - const_cast<SvStream*>(GetStream())->ResetError(); - return nErr; - } - else - { - const std::size_t nSeqLen = maSeq.getLength(); - - if( nPos < nSeqLen ) - { - if( ( nPos + nCount ) > nSeqLen ) - nCount = nSeqLen - nPos; - - memcpy( pBuffer, maSeq.getConstArray() + nPos, nCount ); - *pRead = nCount; - } - else - *pRead = 0; - - return ERRCODE_NONE; - } -} - - -ErrCode ImgProdLockBytes::WriteAt(sal_uInt64 const nPos, - const void* pBuffer, std::size_t nCount, std::size_t * pWritten) -{ - if( GetStream() ) - return SvLockBytes::WriteAt( nPos, pBuffer, nCount, pWritten ); - else - { - DBG_ASSERT( xStmRef.is(), "ImgProdLockBytes::WriteAt: xInputStream has no reference..." ); - return ERRCODE_IO_CANTWRITE; - } -} - - -ErrCode ImgProdLockBytes::Flush() const -{ - return ERRCODE_NONE; -} - - -ErrCode ImgProdLockBytes::SetSize(sal_uInt64 const nSize) -{ - if( GetStream() ) - return SvLockBytes::SetSize( nSize ); - else - { - OSL_FAIL( "ImgProdLockBytes::SetSize not supported for xInputStream..." ); - return ERRCODE_IO_CANTWRITE; - } -} - - -ErrCode ImgProdLockBytes::Stat( SvLockBytesStat* pStat ) const -{ - if( GetStream() ) - return SvLockBytes::Stat( pStat ); - else - { - DBG_ASSERT( xStmRef.is(), "ImgProdLockBytes::Stat: xInputStream has no reference..." ); - pStat->nSize = maSeq.getLength(); - return ERRCODE_NONE; - } -} - ImageProducer::ImageProducer() - : mnTransIndex(0) + : mpStm(nullptr) + , mnTransIndex(0) , mbConsInit(false) { - mpGraphic.reset( new Graphic ); + moGraphic.emplace(); } ImageProducer::~ImageProducer() @@ -175,6 +53,7 @@ css::uno::Any ImageProducer::queryInterface( const css::uno::Type & rType ) { css::uno::Any aRet = ::cppu::queryInterface( rType, static_cast< css::lang::XInitialization* >(this), + static_cast< css::lang::XServiceInfo* >(this), static_cast< css::awt::XImageProducer* >(this) ); return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); } @@ -200,19 +79,20 @@ void ImageProducer::removeConsumer( const css::uno::Reference< css::awt::XImageC void ImageProducer::SetImage( const OUString& rPath ) { maURL = rPath; - mpGraphic->Clear(); + moGraphic->Clear(); mbConsInit = false; - mpStm.reset(); + mxOwnedStream.reset(); + mpStm = nullptr; if ( ::svt::GraphicAccess::isSupportedURL( maURL ) ) { - mpStm = ::svt::GraphicAccess::getImageStream( ::comphelper::getProcessComponentContext(), maURL ); + mxOwnedStream = ::svt::GraphicAccess::getImageStream( ::comphelper::getProcessComponentContext(), maURL ); + mpStm = mxOwnedStream.get(); } else if( !maURL.isEmpty() ) { - std::unique_ptr<SvStream> pIStm = ::utl::UcbStreamHelper::CreateStream( maURL, StreamMode::STD_READ ); - if (pIStm) - mpStm.reset( new SvStream( new ImgProdLockBytes( pIStm.release(), true ) ) ); + mxOwnedStream = ::utl::UcbStreamHelper::CreateStream( maURL, StreamMode::STD_READ ); + mpStm = mxOwnedStream.get(); } } @@ -220,28 +100,32 @@ void ImageProducer::SetImage( const OUString& rPath ) void ImageProducer::SetImage( SvStream& rStm ) { maURL.clear(); - mpGraphic->Clear(); + moGraphic->Clear(); mbConsInit = false; - - mpStm.reset( new SvStream( new ImgProdLockBytes( &rStm, false ) ) ); + mxOwnedStream.reset(); + mpStm = &rStm; } void ImageProducer::setImage( css::uno::Reference< css::io::XInputStream > const & rInputStmRef ) { maURL.clear(); - mpGraphic->Clear(); + moGraphic->Clear(); mbConsInit = false; - mpStm.reset(); + mxOwnedStream.reset(); + mpStm = nullptr; if( rInputStmRef.is() ) - mpStm.reset( new SvStream( new ImgProdLockBytes( rInputStmRef ) ) ); + { + mxOwnedStream = utl::UcbStreamHelper::CreateStream( rInputStmRef ); + mpStm = mxOwnedStream.get(); + } } void ImageProducer::NewDataAvailable() { - if( ( GraphicType::NONE == mpGraphic->GetType() ) || mpGraphic->GetReaderContext() ) + if( ( GraphicType::NONE == moGraphic->GetType() ) || moGraphic->GetReaderContext() ) startProduction(); } @@ -254,18 +138,18 @@ void ImageProducer::startProduction() bool bNotifyEmptyGraphics = false; // valid stream or filled graphic? => update consumers - if( mpStm || ( mpGraphic->GetType() != GraphicType::NONE ) ) + if( mpStm || ( moGraphic->GetType() != GraphicType::NONE ) ) { // if we already have a graphic, we don't have to import again; // graphic is cleared if a new Stream is set - if( ( mpGraphic->GetType() == GraphicType::NONE ) || mpGraphic->GetReaderContext() ) + if( ( moGraphic->GetType() == GraphicType::NONE ) || moGraphic->GetReaderContext() ) { - if ( ImplImportGraphic( *mpGraphic ) ) - maDoneHdl.Call( mpGraphic.get() ); + if ( ImplImportGraphic( *moGraphic ) ) + maDoneHdl.Call( &*moGraphic ); } - if( mpGraphic->GetType() != GraphicType::NONE ) - ImplUpdateData( *mpGraphic ); + if( moGraphic->GetType() != GraphicType::NONE ) + ImplUpdateData( *moGraphic ); else bNotifyEmptyGraphics = true; } @@ -358,13 +242,15 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic ) { BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); Bitmap aBmp( aBmpEx.GetBitmap() ); - BitmapReadAccess* pBmpAcc = aBmp.AcquireReadAccess(); + BitmapScopedReadAccess pBmpAcc(aBmp); if( !pBmpAcc ) return; - Bitmap aMask( aBmpEx.GetAlpha() ); - BitmapReadAccess* pMskAcc = !aMask.IsEmpty() ? aMask.AcquireReadAccess() : nullptr; + AlphaMask aMask( aBmpEx.GetAlphaMask() ); + BitmapScopedReadAccess pMskAcc; + if (!aMask.IsEmpty()) + pMskAcc = aMask; const tools::Long nWidth = pBmpAcc->Width(); const tools::Long nHeight = pBmpAcc->Height(); const tools::Long nStartX = 0; @@ -376,9 +262,9 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic ) if( !pMskAcc ) { - aMask = Bitmap(aBmp.GetSizePixel(), vcl::PixelFormat::N1_BPP); - aMask.Erase( COL_BLACK ); - pMskAcc = aMask.AcquireReadAccess(); + aMask = AlphaMask(aBmp.GetSizePixel()); + aMask.Erase( 0 ); + pMskAcc = aMask; } // create temporary list to hold interfaces @@ -386,7 +272,7 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic ) if( pBmpAcc->HasPalette() ) { - const BitmapColor aWhite( pMskAcc->GetBestMatchingColor( COL_WHITE ) ); + const BitmapColor aWhite( pMskAcc->GetBestMatchingColor( COL_ALPHA_TRANSPARENT ) ); if( mnTransIndex < 256 ) { @@ -461,9 +347,6 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic ) for (auto const& elem : aTmp) elem->setPixelsByLongs( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth ); } - - Bitmap::ReleaseAccess( pBmpAcc ); - Bitmap::ReleaseAccess( pMskAcc ); } @@ -480,6 +363,18 @@ void ImageProducer::initialize( const css::uno::Sequence< css::uno::Any >& aArgu } } +OUString ImageProducer::getImplementationName() { + return "com.sun.star.form.ImageProducer"; +} + +sal_Bool ImageProducer::supportsService(OUString const & ServiceName) { + return cppu::supportsService(this, ServiceName); +} + +css::uno::Sequence<OUString> ImageProducer::getSupportedServiceNames() { + return {"com.sun.star.awt.ImageProducer"}; +} + extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_form_ImageProducer_get_implementation(css::uno::XComponentContext*, diff --git a/forms/source/component/imgprod.hxx b/forms/source/component/imgprod.hxx index 0e746eb6bd5d..d1562caebf9f 100644 --- a/forms/source/component/imgprod.hxx +++ b/forms/source/component/imgprod.hxx @@ -23,18 +23,21 @@ #include <com/sun/star/awt/XImageConsumer.hpp> #include <com/sun/star/awt/XImageProducer.hpp> #include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include <cppuhelper/weak.hxx> +#include <vcl/graph.hxx> #include <memory> +#include <optional> #include <vector> class SvStream; -class Graphic; namespace com::sun::star::io { class XInputStream; } class ImageProducer : public css::awt::XImageProducer, public css::lang::XInitialization, + public css::lang::XServiceInfo, public ::cppu::OWeakObject { private: @@ -43,10 +46,10 @@ private: OUString maURL; ConsumerList_t maConsList; - std::unique_ptr<Graphic> - mpGraphic; - std::unique_ptr<SvStream> - mpStm; + std::optional<Graphic> + moGraphic; + SvStream* mpStm; + std::unique_ptr<SvStream> mxOwnedStream; sal_uInt32 mnTransIndex; bool mbConsInit; Link<Graphic*,void> maDoneHdl; @@ -84,6 +87,10 @@ public: // css::lang::XInitialization void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + OUString SAL_CALL getImplementationName() override; + sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/component/navigationbar.cxx b/forms/source/component/navigationbar.cxx index 368ab62d3fa9..429a9ceb9f62 100644 --- a/forms/source/component/navigationbar.cxx +++ b/forms/source/component/navigationbar.cxx @@ -21,11 +21,13 @@ #include <property.hxx> #include <services.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <comphelper/streamsection.hxx> #include <comphelper/basicio.hxx> +#include <tools/debug.hxx> using namespace comphelper; @@ -37,17 +39,11 @@ namespace frm using namespace ::com::sun::star::form; using namespace ::com::sun::star::awt; using namespace ::com::sun::star::io; - using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; - using namespace ::com::sun::star::container; using namespace ::comphelper; namespace WritingMode2 = ::com::sun::star::text::WritingMode2; -#define REGISTER_VOID_PROP( prop, memberAny, type ) \ - registerMayBeVoidProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT | PropertyAttribute::MAYBEVOID, \ - &memberAny, cppu::UnoType<type>::get() ); - ONavigationBarModel::ONavigationBarModel( const Reference< XComponentContext >& _rxFactory ) :OControlModel( _rxFactory, OUString() ) ,FontControlModel( true ) @@ -99,23 +95,41 @@ namespace frm void ONavigationBarModel::implInitPropertyContainer() { - REGISTER_PROP_2( DEFAULTCONTROL, m_sDefaultControl, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( HELPTEXT, m_sHelpText, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( HELPURL, m_sHelpURL, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( ENABLED, m_bEnabled, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( ENABLEVISIBLE, m_bEnableVisible, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( ICONSIZE, m_nIconSize, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( BORDER, m_nBorder, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( DELAY, m_nDelay, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( SHOW_POSITION, m_bShowPosition, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( SHOW_NAVIGATION, m_bShowNavigation, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( SHOW_RECORDACTIONS, m_bShowActions, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( SHOW_FILTERSORT, m_bShowFilterSort, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( WRITING_MODE, m_nWritingMode, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_3( CONTEXT_WRITING_MODE,m_nContextWritingMode, BOUND, MAYBEDEFAULT, TRANSIENT ); - - REGISTER_VOID_PROP( TABSTOP, m_aTabStop, sal_Bool ); - REGISTER_VOID_PROP( BACKGROUNDCOLOR, m_aBackgroundColor, sal_Int32 ); + registerProperty( PROPERTY_DEFAULTCONTROL, PROPERTY_ID_DEFAULTCONTROL, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_sDefaultControl, cppu::UnoType<decltype(m_sDefaultControl)>::get() ); + registerProperty( PROPERTY_HELPTEXT, PROPERTY_ID_HELPTEXT, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_sHelpText, cppu::UnoType<decltype(m_sHelpText)>::get() ); + registerProperty( PROPERTY_HELPURL, PROPERTY_ID_HELPURL, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_sHelpURL, cppu::UnoType<decltype(m_sHelpURL)>::get() ); + registerProperty( PROPERTY_ENABLED, PROPERTY_ID_ENABLED, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bEnabled, cppu::UnoType<decltype(m_bEnabled)>::get() ); + registerProperty( PROPERTY_ENABLEVISIBLE, PROPERTY_ID_ENABLEVISIBLE, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bEnableVisible, cppu::UnoType<decltype(m_bEnableVisible)>::get() ); + registerProperty( PROPERTY_ICONSIZE, PROPERTY_ID_ICONSIZE, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_nIconSize, cppu::UnoType<decltype(m_nIconSize)>::get() ); + registerProperty( PROPERTY_BORDER, PROPERTY_ID_BORDER, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_nBorder, cppu::UnoType<decltype(m_nBorder)>::get() ); + registerProperty( PROPERTY_DELAY, PROPERTY_ID_DELAY, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_nDelay, cppu::UnoType<decltype(m_nDelay)>::get() ); + registerProperty( PROPERTY_SHOW_POSITION, PROPERTY_ID_SHOW_POSITION, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bShowPosition, cppu::UnoType<decltype(m_bShowPosition)>::get() ); + registerProperty( PROPERTY_SHOW_NAVIGATION, PROPERTY_ID_SHOW_NAVIGATION, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bShowNavigation, cppu::UnoType<decltype(m_bShowNavigation)>::get() ); + registerProperty( PROPERTY_SHOW_RECORDACTIONS, PROPERTY_ID_SHOW_RECORDACTIONS, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bShowActions, cppu::UnoType<decltype(m_bShowActions)>::get() ); + registerProperty( PROPERTY_SHOW_FILTERSORT, PROPERTY_ID_SHOW_FILTERSORT, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bShowFilterSort, cppu::UnoType<decltype(m_bShowFilterSort)>::get() ); + registerProperty( PROPERTY_WRITING_MODE, PROPERTY_ID_WRITING_MODE, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_nWritingMode, cppu::UnoType<decltype(m_nWritingMode)>::get() ); + + registerProperty( PROPERTY_CONTEXT_WRITING_MODE, PROPERTY_ID_CONTEXT_WRITING_MODE, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT | PropertyAttribute::TRANSIENT, + &m_nContextWritingMode, cppu::UnoType<decltype(m_nContextWritingMode)>::get() ); + + registerMayBeVoidProperty( PROPERTY_TABSTOP, PROPERTY_ID_TABSTOP, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT | PropertyAttribute::MAYBEVOID, + &m_aTabStop, cppu::UnoType<sal_Bool>::get() ); + + registerMayBeVoidProperty( PROPERTY_BACKGROUNDCOLOR, PROPERTY_ID_BACKGROUNDCOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT | PropertyAttribute::MAYBEVOID, + &m_aBackgroundColor, cppu::UnoType<sal_Int32>::get() ); } @@ -144,7 +158,12 @@ namespace frm IMPLEMENT_FORWARD_XTYPEPROVIDER2( ONavigationBarModel, OControlModel, ONavigationBarModel_BASE ) - IMPLEMENT_DEFAULT_CLONING( ONavigationBarModel ) + css::uno::Reference< css::util::XCloneable > SAL_CALL ONavigationBarModel::createClone() +{ + rtl::Reference<ONavigationBarModel> pClone = new ONavigationBarModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} OUString SAL_CALL ONavigationBarModel::getImplementationName() @@ -432,9 +451,12 @@ namespace frm void ONavigationBarModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 1, OControlModel ) - DECL_PROP2( TABINDEX, sal_Int16, BOUND, MAYBEDEFAULT ); - END_DESCRIBE_PROPERTIES(); + OControlModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 1); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); // properties which the OPropertyContainerHelper is responsible for Sequence< Property > aContainedProperties; diff --git a/forms/source/component/navigationbar.hxx b/forms/source/component/navigationbar.hxx index fade59422f8c..ceb84dbe8ecd 100644 --- a/forms/source/component/navigationbar.hxx +++ b/forms/source/component/navigationbar.hxx @@ -59,7 +59,14 @@ namespace frm // </properties> public: - DECLARE_DEFAULT_LEAF_XTOR( ONavigationBarModel ); + ONavigationBarModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + ONavigationBarModel( + const ONavigationBarModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~ONavigationBarModel() override; // UNO DECLARE_UNO3_AGG_DEFAULTS( ONavigationBarModel, OControlModel ) diff --git a/forms/source/component/propertybaghelper.cxx b/forms/source/component/propertybaghelper.cxx index f5c77c707a99..e2c92e24c008 100644 --- a/forms/source/component/propertybaghelper.cxx +++ b/forms/source/component/propertybaghelper.cxx @@ -22,12 +22,13 @@ #include <property.hxx> #include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/PropertyExistException.hpp> #include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/beans/NotRemoveableException.hpp> #include <com/sun/star/beans/UnknownPropertyException.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <comphelper/sequence.hxx> @@ -46,7 +47,6 @@ namespace frm using ::com::sun::star::beans::PropertyExistException; using ::com::sun::star::beans::PropertyValue; using ::com::sun::star::uno::Reference; - using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::beans::XMultiPropertySet; using ::com::sun::star::beans::XPropertySetInfo; using ::com::sun::star::uno::RuntimeException; @@ -267,7 +267,7 @@ namespace frm aValues = xMe->getPropertyValues( aPropertyNames ); if ( aValues.getLength() != aPropertyNames.getLength() ) - throw RuntimeException(); + throw RuntimeException("property name and value counts out of sync"); } catch( const RuntimeException& ) { throw; } catch( const Exception& ) diff --git a/forms/source/component/refvaluecomponent.cxx b/forms/source/component/refvaluecomponent.cxx index 559d3bd86543..09765259f18e 100644 --- a/forms/source/component/refvaluecomponent.cxx +++ b/forms/source/component/refvaluecomponent.cxx @@ -21,7 +21,10 @@ #include <property.hxx> #include <comphelper/property.hxx> -#include <tools/diagnose_ex.h> +#include <tools/debug.hxx> +#include <comphelper/diagnose_ex.hxx> + +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <vector> @@ -33,7 +36,6 @@ namespace frm using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; - using namespace ::com::sun::star::form::binding; //= @@ -148,17 +150,20 @@ namespace frm Any OReferenceValueComponent::getDefaultForReset() const { - return makeAny( static_cast<sal_Int16>(m_eDefaultChecked) ); + return Any( static_cast<sal_Int16>(m_eDefaultChecked) ); } void OReferenceValueComponent::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 3, OBoundControlModel ) - DECL_PROP1( REFVALUE, OUString, BOUND ); - DECL_PROP1( DEFAULT_STATE, sal_Int16, BOUND ); - DECL_PROP1( UNCHECKED_REFVALUE, OUString, BOUND ); - END_DESCRIBE_PROPERTIES(); + OBoundControlModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 3); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_REFVALUE, PROPERTY_ID_REFVALUE, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_DEFAULT_STATE, PROPERTY_ID_DEFAULT_STATE, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_UNCHECKED_REFVALUE, PROPERTY_ID_UNCHECKED_REFVALUE, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } @@ -206,7 +211,7 @@ namespace frm OSL_FAIL( "OReferenceValueComponent::translateExternalValueToControlValue: unexpected value type!" ); } - return makeAny( nState ); + return Any( nState ); } diff --git a/forms/source/component/refvaluecomponent.hxx b/forms/source/component/refvaluecomponent.hxx index 09131c172bf7..79f343888c1c 100644 --- a/forms/source/component/refvaluecomponent.hxx +++ b/forms/source/component/refvaluecomponent.hxx @@ -52,7 +52,11 @@ namespace frm const OUString& _rUnoControlModelTypeName, const OUString& _rDefault ); - DECLARE_DEFAULT_CLONE_CTOR( OReferenceValueComponent ) + OReferenceValueComponent( + const OReferenceValueComponent* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OReferenceValueComponent() override; // OPropertySet and friends diff --git a/forms/source/component/scrollbar.cxx b/forms/source/component/scrollbar.cxx index 4e18dd69ec56..36f4d2ce6ced 100644 --- a/forms/source/component/scrollbar.cxx +++ b/forms/source/component/scrollbar.cxx @@ -24,6 +24,8 @@ #include <comphelper/streamsection.hxx> #include <comphelper/basicio.hxx> #include <rtl/math.hxx> +#include <tools/debug.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> namespace frm @@ -32,11 +34,8 @@ namespace frm using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::form; - using namespace ::com::sun::star::awt; - using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; using namespace ::com::sun::star::io; - using namespace ::com::sun::star::form::binding; //= helper @@ -70,7 +69,7 @@ namespace frm _rxProperties->getPropertyValue( _rMinValueName ) >>= nControlValue; } - return makeAny( nControlValue ); + return Any( nControlValue ); } @@ -131,16 +130,24 @@ namespace frm ); } - IMPLEMENT_DEFAULT_CLONING( OScrollBarModel ) + css::uno::Reference< css::util::XCloneable > SAL_CALL OScrollBarModel::createClone() +{ + rtl::Reference<OScrollBarModel> pClone = new OScrollBarModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} void OScrollBarModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 3, OControlModel ) - DECL_PROP1( DEFAULT_SCROLL_VALUE, sal_Int32, BOUND ); - DECL_PROP1( TABINDEX, sal_Int16, BOUND ); - DECL_PROP2( CONTROLSOURCEPROPERTY,OUString, READONLY, TRANSIENT ); - END_DESCRIBE_PROPERTIES(); + OControlModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 3); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_DEFAULT_SCROLL_VALUE, PROPERTY_ID_DEFAULT_SCROLL_VALUE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_CONTROLSOURCEPROPERTY, PROPERTY_ID_CONTROLSOURCEPROPERTY, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } @@ -226,7 +233,7 @@ namespace frm Any OScrollBarModel::getDefaultForReset() const { - return makeAny( m_nDefaultScrollValue ); + return Any( m_nDefaultScrollValue ); } diff --git a/forms/source/component/scrollbar.hxx b/forms/source/component/scrollbar.hxx index 356d101be40e..0acb91a3a009 100644 --- a/forms/source/component/scrollbar.hxx +++ b/forms/source/component/scrollbar.hxx @@ -31,7 +31,14 @@ namespace frm // </properties> public: - DECLARE_DEFAULT_LEAF_XTOR( OScrollBarModel ); + OScrollBarModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OScrollBarModel( + const OScrollBarModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OScrollBarModel() override; protected: // XServiceInfo @@ -39,7 +46,9 @@ namespace frm virtual ::css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; // XPersistObject - DECLARE_XPERSISTOBJECT() + virtual OUString SAL_CALL getServiceName() override; + virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream>& _rxOutStream) override; + virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream>& _rxInStream) override; // XCloneable virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override; diff --git a/forms/source/component/spinbutton.cxx b/forms/source/component/spinbutton.cxx index db45651ab8a9..eec9522639ba 100644 --- a/forms/source/component/spinbutton.cxx +++ b/forms/source/component/spinbutton.cxx @@ -22,6 +22,8 @@ #include <comphelper/property.hxx> #include <comphelper/streamsection.hxx> #include <comphelper/basicio.hxx> +#include <tools/debug.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <property.hxx> #include <services.hxx> @@ -33,11 +35,8 @@ namespace frm using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::form; - using namespace ::com::sun::star::awt; - using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; using namespace ::com::sun::star::io; - using namespace ::com::sun::star::form::binding; //= OSpinButtonModel @@ -85,16 +84,24 @@ namespace frm ); } - IMPLEMENT_DEFAULT_CLONING( OSpinButtonModel ) + css::uno::Reference< css::util::XCloneable > SAL_CALL OSpinButtonModel::createClone() +{ + rtl::Reference<OSpinButtonModel> pClone = new OSpinButtonModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} void OSpinButtonModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 3, OControlModel ) - DECL_PROP1( DEFAULT_SPIN_VALUE, sal_Int32, BOUND ); - DECL_PROP1( TABINDEX, sal_Int16, BOUND ); - DECL_PROP2( CONTROLSOURCEPROPERTY,OUString, READONLY, TRANSIENT ); - END_DESCRIBE_PROPERTIES(); + OControlModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 3); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_DEFAULT_SPIN_VALUE, PROPERTY_ID_DEFAULT_SPIN_VALUE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_CONTROLSOURCEPROPERTY, PROPERTY_ID_CONTROLSOURCEPROPERTY, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } @@ -180,7 +187,7 @@ namespace frm Any OSpinButtonModel::getDefaultForReset() const { - return makeAny( m_nDefaultSpinValue ); + return Any( m_nDefaultSpinValue ); } diff --git a/forms/source/component/spinbutton.hxx b/forms/source/component/spinbutton.hxx index 2579c322d733..b9800274f063 100644 --- a/forms/source/component/spinbutton.hxx +++ b/forms/source/component/spinbutton.hxx @@ -32,7 +32,14 @@ namespace frm // </properties> public: - DECLARE_DEFAULT_LEAF_XTOR( OSpinButtonModel ); + OSpinButtonModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + OSpinButtonModel( + const OSpinButtonModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~OSpinButtonModel() override; protected: // XServiceInfo @@ -40,7 +47,9 @@ namespace frm virtual ::css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; // XPersistObject - DECLARE_XPERSISTOBJECT() + virtual OUString SAL_CALL getServiceName() override; + virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream>& _rxOutStream) override; + virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream>& _rxInStream) override; // XCloneable virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override; diff --git a/forms/source/helper/commandimageprovider.cxx b/forms/source/helper/commandimageprovider.cxx index ca2d7052567f..dce1f50e24bc 100644 --- a/forms/source/helper/commandimageprovider.cxx +++ b/forms/source/helper/commandimageprovider.cxx @@ -26,7 +26,7 @@ #include <com/sun/star/frame/ModuleManager.hpp> #include <com/sun/star/ui/ImageType.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace frm @@ -34,14 +34,12 @@ namespace frm using ::com::sun::star::uno::Reference; - using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::UNO_SET_THROW; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::frame::XModel; - using ::com::sun::star::ui::XImageManager; using ::com::sun::star::ui::XUIConfigurationManagerSupplier; using ::com::sun::star::ui::XUIConfigurationManager; using ::com::sun::star::ui::XModuleUIConfigurationManagerSupplier; diff --git a/forms/source/helper/controlfeatureinterception.cxx b/forms/source/helper/controlfeatureinterception.cxx index 091af550cc29..e8a4ebb337d3 100644 --- a/forms/source/helper/controlfeatureinterception.cxx +++ b/forms/source/helper/controlfeatureinterception.cxx @@ -29,7 +29,6 @@ namespace frm using namespace ::com::sun::star::uno; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::util; - using namespace ::com::sun::star::lang; ControlFeatureInterception::ControlFeatureInterception( const Reference< XComponentContext >& _rxORB ) :m_pUrlTransformer( new UrlTransformer( _rxORB ) ) @@ -71,8 +70,7 @@ namespace frm if ( m_xFirstDispatchInterceptor == _rxInterceptor ) { // our chain will have a new first element - Reference< XDispatchProviderInterceptor > xSlave( m_xFirstDispatchInterceptor->getSlaveDispatchProvider(), UNO_QUERY ); - m_xFirstDispatchInterceptor = xSlave; + m_xFirstDispatchInterceptor.set(m_xFirstDispatchInterceptor->getSlaveDispatchProvider(), UNO_QUERY); } // do this before removing the interceptor from the chain as we won't know it's slave afterwards) diff --git a/forms/source/helper/formnavigation.cxx b/forms/source/helper/formnavigation.cxx index 547a5781649a..be87c063e303 100644 --- a/forms/source/helper/formnavigation.cxx +++ b/forms/source/helper/formnavigation.cxx @@ -24,7 +24,9 @@ #include <com/sun/star/form/runtime/FormFeature.hpp> +#include <comphelper/propertyvalue.hxx> #include <tools/debug.hxx> +#include <o3tl/string_view.hxx> #include <osl/diagnose.h> @@ -41,9 +43,9 @@ namespace frm OFormNavigationHelper::OFormNavigationHelper( const Reference< XComponentContext >& _rxORB ) :m_xORB( _rxORB ) + ,m_aFeatureInterception( m_xORB ) ,m_nConnectedFeatures( 0 ) { - m_pFeatureInterception.reset( new ControlFeatureInterception( m_xORB ) ); } @@ -54,7 +56,7 @@ namespace frm void OFormNavigationHelper::dispose( ) { - m_pFeatureInterception->dispose(); + m_aFeatureInterception.dispose(); disconnectDispatchers(); } @@ -79,14 +81,14 @@ namespace frm void SAL_CALL OFormNavigationHelper::registerDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) { - m_pFeatureInterception->registerDispatchProviderInterceptor( _rxInterceptor ); + m_aFeatureInterception.registerDispatchProviderInterceptor( _rxInterceptor ); interceptorsChanged(); } void SAL_CALL OFormNavigationHelper::releaseDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) { - m_pFeatureInterception->releaseDispatchProviderInterceptor( _rxInterceptor ); + m_aFeatureInterception.releaseDispatchProviderInterceptor( _rxInterceptor ); interceptorsChanged(); } @@ -260,7 +262,7 @@ namespace frm Reference< XDispatch > OFormNavigationHelper::queryDispatch( const URL& _rURL ) { - return m_pFeatureInterception->queryDispatch( _rURL ); + return m_aFeatureInterception.queryDispatch( _rURL ); } @@ -272,9 +274,8 @@ namespace frm { if ( aInfo->second.xDispatcher.is() ) { - Sequence< PropertyValue > aArgs( 1 ); - aArgs[0].Name = OUString::createFromAscii( _pParamAsciiName ); - aArgs[0].Value = _rParamValue; + Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue( + OUString::createFromAscii( _pParamAsciiName ), _rParamValue) }; aInfo->second.xDispatcher->dispatch( aInfo->second.aURL, aArgs ); } @@ -427,12 +428,12 @@ namespace frm } - sal_Int16 OFormNavigationMapper::getFeatureId( const OUString& _rCompleteURL ) + sal_Int16 OFormNavigationMapper::getFeatureId( std::u16string_view _rCompleteURL ) { const FeatureURL* pFeatures = lcl_getFeatureTable(); while ( pFeatures->pAsciiURL ) { - if ( _rCompleteURL.equalsAscii( pFeatures->pAsciiURL ) ) + if ( o3tl::equalsAscii( _rCompleteURL, pFeatures->pAsciiURL ) ) return pFeatures->nFormFeature; ++pFeatures; } diff --git a/forms/source/helper/resettable.cxx b/forms/source/helper/resettable.cxx index 6eac1633d82d..8994254a6e20 100644 --- a/forms/source/helper/resettable.cxx +++ b/forms/source/helper/resettable.cxx @@ -48,12 +48,12 @@ namespace frm bool ResetHelper::approveReset() { - ::comphelper::OInterfaceIteratorHelper2 aIter( m_aResetListeners ); + ::comphelper::OInterfaceIteratorHelper3 aIter( m_aResetListeners ); EventObject aResetEvent( m_rParent ); bool bContinue = true; while ( aIter.hasMoreElements() && bContinue ) - bContinue = static_cast< XResetListener* >( aIter.next() )->approveReset( aResetEvent ); + bContinue = aIter.next()->approveReset( aResetEvent ); return bContinue; } diff --git a/forms/source/helper/urltransformer.cxx b/forms/source/helper/urltransformer.cxx index 10f664705e61..e112041c2256 100644 --- a/forms/source/helper/urltransformer.cxx +++ b/forms/source/helper/urltransformer.cxx @@ -71,13 +71,12 @@ namespace frm } - void UrlTransformer::parseSmartWithAsciiProtocol( css::util::URL& _rURL, const char* _pAsciiURL ) const + void UrlTransformer::parseSmartWithProtocol( css::util::URL& _rURL, const OUString& _rProtocol ) const { if ( implEnsureTransformer() ) - m_xTransformer->parseSmart( _rURL, OUString::createFromAscii( _pAsciiURL ) ); + m_xTransformer->parseSmart( _rURL, _rProtocol ); } - } // namespace frm diff --git a/forms/source/helper/windowstateguard.cxx b/forms/source/helper/windowstateguard.cxx index 0202baa7404b..dd47dd2989b9 100644 --- a/forms/source/helper/windowstateguard.cxx +++ b/forms/source/helper/windowstateguard.cxx @@ -20,10 +20,11 @@ #include <windowstateguard.hxx> #include <frm_strings.hxx> +#include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/awt/XWindowListener2.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <cppuhelper/implbase.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace frm @@ -35,6 +36,7 @@ namespace frm using ::com::sun::star::awt::XWindow2; using ::com::sun::star::awt::WindowEvent; using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::awt::XControlModel; using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::lang::EventObject; @@ -88,8 +90,10 @@ namespace frm :m_xWindow( _rxWindow ) ,m_xModelProps( _rxMdelProps ) { - if ( !m_xWindow.is() || !m_xModelProps.is() ) - throw RuntimeException(); + if ( !m_xWindow.is() ) + throw IllegalArgumentException("no window supplied", *this, 0); + if ( !m_xModelProps.is() ) + throw IllegalArgumentException("no property set supplied", *this, 1); osl_atomic_increment( &m_refCount ); { diff --git a/forms/source/inc/FormComponent.hxx b/forms/source/inc/FormComponent.hxx index 0310e3455a02..0a0ec19be553 100644 --- a/forms/source/inc/FormComponent.hxx +++ b/forms/source/inc/FormComponent.hxx @@ -49,6 +49,7 @@ #include <com/sun/star/util/XModifyListener.hpp> #include <com/sun/star/form/XLoadable.hpp> +#include <comphelper/interfacecontainer3.hxx> #include <comphelper/propagg.hxx> #include <comphelper/propmultiplex.hxx> #include <comphelper/uno3.hxx> @@ -70,12 +71,6 @@ namespace frm // default tab index for components const sal_Int16 FRM_DEFAULT_TABINDEX = 0; - // macros for quickly declaring/implementing XServiceInfo - #define DECLARE_XPERSISTOBJECT() \ - virtual OUString SAL_CALL getServiceName() override; \ - virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream>& _rxOutStream) override; \ - virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream>& _rxInStream) override; - class OControlModel; @@ -326,6 +321,7 @@ protected: sal_Int16 m_nTabIndex; // index within the taborder sal_Int16 m_nClassId; // type of the control bool m_bNativeLook; // should the control use the native platform look? + bool m_bStandardTheme; // should the default control colors be 'standard' or use the native platform theme? bool m_bGenerateVbEvents; // should the control generate fake vba events //added for exporting OCX control sal_Int16 m_nControlTypeinMSO; //keep the MS office control type for exporting to MS binary file @@ -489,34 +485,6 @@ public: getInstanceMutex() { return m_aMutex; } }; -// constructor for cloning a class -#define DECLARE_DEFAULT_CLONE_CTOR( classname ) \ - classname( \ - const classname* _pOriginal, \ - const css::uno::Reference< css::uno::XComponentContext>& _rxFactory \ - ); \ - -// all xtors for a leaf class of the object hierarchy -#define DECLARE_DEFAULT_LEAF_XTOR( classname ) \ - classname( \ - const css::uno::Reference< css::uno::XComponentContext>& _rxFactory \ - ); \ - classname( \ - const classname* _pOriginal, \ - const css::uno::Reference< css::uno::XComponentContext>& _rxFactory \ - ); \ - virtual ~classname() override \ - - -#define IMPLEMENT_DEFAULT_CLONING( classname ) \ - css::uno::Reference< css::util::XCloneable > SAL_CALL classname::createClone( ) \ - { \ - rtl::Reference<classname> pClone = new classname( this, getContext() ); \ - pClone->clonedFrom( this ); \ - return pClone; \ - } - - //= OBoundControlModel //= model of a form layer control which is bound to a data source field @@ -570,8 +538,10 @@ private: bool m_bValuePropertyMayBeVoid; ResetHelper m_aResetHelper; - ::comphelper::OInterfaceContainerHelper2 m_aUpdateListeners; - ::comphelper::OInterfaceContainerHelper2 m_aFormComponentListeners; + ::comphelper::OInterfaceContainerHelper3<css::form::XUpdateListener> + m_aUpdateListeners; + ::comphelper::OInterfaceContainerHelper3<css::form::validation::XFormComponentValidityListener> + m_aFormComponentListeners; css::uno::Reference< css::form::binding::XValueBinding > m_xExternalBinding; diff --git a/forms/source/inc/InterfaceContainer.hxx b/forms/source/inc/InterfaceContainer.hxx index da55f0ebebb1..66135a02e48e 100644 --- a/forms/source/inc/InterfaceContainer.hxx +++ b/forms/source/inc/InterfaceContainer.hxx @@ -34,7 +34,7 @@ #include <com/sun/star/form/XFormComponent.hpp> #include <com/sun/star/util/XCloneable.hpp> #include <osl/mutex.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer3.hxx> #include <cppuhelper/component.hxx> #include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase8.hxx> @@ -89,7 +89,7 @@ protected: OInterfaceArray m_aItems; OInterfaceMap m_aMap; - ::comphelper::OInterfaceContainerHelper2 m_aContainerListeners; + ::comphelper::OInterfaceContainerHelper3<css::container::XContainerListener> m_aContainerListeners; const css::uno::Type m_aElementType; diff --git a/forms/source/inc/formnavigation.hxx b/forms/source/inc/formnavigation.hxx index 3ca32a996add..03715d28aba8 100644 --- a/forms/source/inc/formnavigation.hxx +++ b/forms/source/inc/formnavigation.hxx @@ -24,6 +24,7 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <cppuhelper/implbase2.hxx> #include "featuredispatcher.hxx" +#include "controlfeatureinterception.hxx" #include <vector> #include <map> #include <memory> @@ -34,7 +35,6 @@ namespace frm class UrlTransformer; - class ControlFeatureInterception; //= OFormNavigationHelper @@ -62,8 +62,8 @@ namespace frm private: css::uno::Reference< css::uno::XComponentContext > m_xORB; - ::std::unique_ptr< ControlFeatureInterception > - m_pFeatureInterception; + ControlFeatureInterception + m_aFeatureInterception; // all supported features FeatureMap m_aSupportedFeatures; @@ -203,7 +203,7 @@ namespace frm the id of the feature URL, or -1 if the URl is not known (which is a valid usage) */ - static sal_Int16 getFeatureId( const OUString& _rCompleteURL ); + static sal_Int16 getFeatureId( std::u16string_view _rCompleteURL ); private: OFormNavigationMapper( const OFormNavigationMapper& ) = delete; diff --git a/forms/source/inc/frm_resource.hxx b/forms/source/inc/frm_resource.hxx index ea629440bbce..711018a158d0 100644 --- a/forms/source/inc/frm_resource.hxx +++ b/forms/source/inc/frm_resource.hxx @@ -25,8 +25,6 @@ namespace frm { -#define FRM_RES_STRING(id) ResourceManager::loadString(id) - // handling resources within the FormLayer library namespace ResourceManager { diff --git a/forms/source/inc/frm_strings.hxx b/forms/source/inc/frm_strings.hxx index d0558f80b450..90edf195d20e 100644 --- a/forms/source/inc/frm_strings.hxx +++ b/forms/source/inc/frm_strings.hxx @@ -19,279 +19,269 @@ #pragma once +#include <rtl/ustring.hxx> -namespace frm -{ +//- properties +inline constexpr OUString PROPERTY_TABINDEX = u"TabIndex"_ustr; +inline constexpr OUString PROPERTY_TAG = u"Tag"_ustr; +inline constexpr OUString PROPERTY_NAME = u"Name"_ustr; +inline constexpr OUString PROPERTY_GROUP_NAME = u"GroupName"_ustr; +inline constexpr OUString PROPERTY_CLASSID = u"ClassId"_ustr; +inline constexpr OUString PROPERTY_FETCHSIZE = u"FetchSize"_ustr; +inline constexpr OUString PROPERTY_VALUE = u"Value"_ustr; +inline constexpr OUString PROPERTY_TEXT = u"Text"_ustr; +inline constexpr OUString PROPERTY_LABEL = u"Label"_ustr; +inline constexpr OUString PROPERTY_NAVIGATION = u"NavigationBarMode"_ustr; +inline constexpr OUString PROPERTY_HASNAVIGATION = u"HasNavigationBar"_ustr; +inline constexpr OUString PROPERTY_CYCLE = u"Cycle"_ustr; +inline constexpr OUString PROPERTY_CONTROLSOURCE = u"DataField"_ustr; +inline constexpr OUString PROPERTY_ENABLED = u"Enabled"_ustr; +inline constexpr OUString PROPERTY_ENABLEVISIBLE = u"EnableVisible"_ustr; +inline constexpr OUString PROPERTY_READONLY = u"ReadOnly"_ustr; +inline constexpr OUString PROPERTY_RELEVANT = u"Relevant"_ustr; +inline constexpr OUString PROPERTY_ISREADONLY = u"IsReadOnly"_ustr; +inline constexpr OUString PROPERTY_FILTER = u"Filter"_ustr; +inline constexpr OUString PROPERTY_HAVINGCLAUSE = u"HavingClause"_ustr; +inline constexpr OUString PROPERTY_WIDTH = u"Width"_ustr; +inline constexpr OUString PROPERTY_SEARCHABLE = u"IsSearchable"_ustr; +inline constexpr OUString PROPERTY_MULTILINE = u"MultiLine"_ustr; +inline constexpr OUString PROPERTY_TARGET_URL = u"TargetURL"_ustr; +inline constexpr OUString PROPERTY_TARGET_FRAME = u"TargetFrame"_ustr; +inline constexpr OUString PROPERTY_DEFAULTCONTROL = u"DefaultControl"_ustr; +inline constexpr OUString PROPERTY_MAXTEXTLEN = u"MaxTextLen"_ustr; +inline constexpr OUString PROPERTY_EDITMASK = u"EditMask"_ustr; +inline constexpr OUString PROPERTY_SIZE = u"Size"_ustr; +inline constexpr OUString PROPERTY_SPIN = u"Spin"_ustr; +inline constexpr OUString PROPERTY_DATE = u"Date"_ustr; +inline constexpr OUString PROPERTY_TIME = u"Time"_ustr; +inline constexpr OUString PROPERTY_STATE = u"State"_ustr; +inline constexpr OUString PROPERTY_TRISTATE = u"TriState"_ustr; +inline constexpr OUString PROPERTY_HIDDEN_VALUE = u"HiddenValue"_ustr; +inline constexpr OUString PROPERTY_BUTTONTYPE = u"ButtonType"_ustr; +inline constexpr OUString PROPERTY_STRINGITEMLIST = u"StringItemList"_ustr; +inline constexpr OUString PROPERTY_TYPEDITEMLIST = u"TypedItemList"_ustr; +inline constexpr OUString PROPERTY_DEFAULT_TEXT = u"DefaultText"_ustr; +inline constexpr OUString PROPERTY_DEFAULT_STATE = u"DefaultState"_ustr; +inline constexpr OUString PROPERTY_FORMATKEY = u"FormatKey"_ustr; +inline constexpr OUString PROPERTY_FORMATSSUPPLIER = u"FormatsSupplier"_ustr; +inline constexpr OUString PROPERTY_SUBMIT_ACTION = u"SubmitAction"_ustr; +inline constexpr OUString PROPERTY_SUBMIT_TARGET = u"SubmitTarget"_ustr; +inline constexpr OUString PROPERTY_SUBMIT_METHOD = u"SubmitMethod"_ustr; +inline constexpr OUString PROPERTY_SUBMIT_ENCODING = u"SubmitEncoding"_ustr; +inline constexpr OUString PROPERTY_IMAGE_URL = u"ImageURL"_ustr; +inline constexpr OUString PROPERTY_GRAPHIC = u"Graphic"_ustr; +inline constexpr OUString PROPERTY_IMAGE_POSITION = u"ImagePosition"_ustr; +inline constexpr OUString PROPERTY_EMPTY_IS_NULL = u"ConvertEmptyToNull"_ustr; +inline constexpr OUString PROPERTY_LISTSOURCETYPE = u"ListSourceType"_ustr; +inline constexpr OUString PROPERTY_LISTSOURCE = u"ListSource"_ustr; +inline constexpr OUString PROPERTY_SELECT_SEQ = u"SelectedItems"_ustr; +inline constexpr OUString PROPERTY_VALUE_SEQ = u"ValueItemList"_ustr; +inline constexpr OUString PROPERTY_SELECT_VALUE_SEQ = u"SelectedValues"_ustr; +inline constexpr OUString PROPERTY_SELECT_VALUE = u"SelectedValue"_ustr; +inline constexpr OUString PROPERTY_DEFAULT_SELECT_SEQ = u"DefaultSelection"_ustr; +inline constexpr OUString PROPERTY_MULTISELECTION = u"MultiSelection"_ustr; +inline constexpr OUString PROPERTY_ALIGN = u"Align"_ustr; +inline constexpr OUString PROPERTY_VERTICAL_ALIGN = u"VerticalAlign"_ustr; +inline constexpr OUString PROPERTY_DEFAULT_DATE = u"DefaultDate"_ustr; +inline constexpr OUString PROPERTY_DEFAULT_TIME = u"DefaultTime"_ustr; +inline constexpr OUString PROPERTY_DEFAULT_VALUE = u"DefaultValue"_ustr; +inline constexpr OUString PROPERTY_DECIMAL_ACCURACY = u"DecimalAccuracy"_ustr; +inline constexpr OUString PROPERTY_FIELDTYPE = u"Type"_ustr; +inline constexpr OUString PROPERTY_DECIMALS = u"Decimals"_ustr; +inline constexpr OUString PROPERTY_REFVALUE = u"RefValue"_ustr; +inline constexpr OUString PROPERTY_UNCHECKED_REFVALUE = u"SecondaryRefValue"_ustr; +inline constexpr OUString PROPERTY_VALUEMIN = u"ValueMin"_ustr; +inline constexpr OUString PROPERTY_VALUEMAX = u"ValueMax"_ustr; +inline constexpr OUString PROPERTY_STRICTFORMAT = u"StrictFormat"_ustr; +inline constexpr OUString PROPERTY_ALLOWADDITIONS = u"AllowInserts"_ustr; +inline constexpr OUString PROPERTY_ALLOWEDITS = u"AllowUpdates"_ustr; +inline constexpr OUString PROPERTY_ALLOWDELETIONS = u"AllowDeletes"_ustr; +inline constexpr OUString PROPERTY_MASTERFIELDS = u"MasterFields"_ustr; +inline constexpr OUString PROPERTY_ISPASSTHROUGH = u"IsPassThrough"_ustr; +inline constexpr OUString PROPERTY_QUERY = u"Query"_ustr; +inline constexpr OUString PROPERTY_LITERALMASK = u"LiteralMask"_ustr; +inline constexpr OUString PROPERTY_VALUESTEP = u"ValueStep"_ustr; +inline constexpr OUString PROPERTY_SHOWTHOUSANDSEP = u"ShowThousandsSeparator"_ustr; +inline constexpr OUString PROPERTY_CURRENCYSYMBOL = u"CurrencySymbol"_ustr; +inline constexpr OUString PROPERTY_DATEFORMAT = u"DateFormat"_ustr; +inline constexpr OUString PROPERTY_DATEMIN = u"DateMin"_ustr; +inline constexpr OUString PROPERTY_DATEMAX = u"DateMax"_ustr; +inline constexpr OUString PROPERTY_DATE_SHOW_CENTURY = u"DateShowCentury"_ustr; +inline constexpr OUString PROPERTY_TIMEFORMAT = u"TimeFormat"_ustr; +inline constexpr OUString PROPERTY_TIMEMIN = u"TimeMin"_ustr; +inline constexpr OUString PROPERTY_TIMEMAX = u"TimeMax"_ustr; +inline constexpr OUString PROPERTY_LINECOUNT = u"LineCount"_ustr; +inline constexpr OUString PROPERTY_BOUNDCOLUMN = u"BoundColumn"_ustr; +inline constexpr OUString PROPERTY_FONT = u"FontDescriptor"_ustr; +inline constexpr OUString PROPERTY_FILLCOLOR = u"FillColor"_ustr; +inline constexpr OUString PROPERTY_LINECOLOR = u"LineColor"_ustr; +inline constexpr OUString PROPERTY_DROPDOWN = u"Dropdown"_ustr; +inline constexpr OUString PROPERTY_HSCROLL = u"HScroll"_ustr; +inline constexpr OUString PROPERTY_VSCROLL = u"VScroll"_ustr; +inline constexpr OUString PROPERTY_TABSTOP = u"Tabstop"_ustr; +inline constexpr OUString PROPERTY_AUTOCOMPLETE = u"Autocomplete"_ustr; +inline constexpr OUString PROPERTY_HARDLINEBREAKS = u"HardLineBreaks"_ustr; +inline constexpr OUString PROPERTY_PRINTABLE = u"Printable"_ustr; +inline constexpr OUString PROPERTY_ECHO_CHAR = u"EchoChar"_ustr; +inline constexpr OUString PROPERTY_ROWHEIGHT = u"RowHeight"_ustr; +inline constexpr OUString PROPERTY_HELPTEXT = u"HelpText"_ustr; +inline constexpr OUString PROPERTY_FONT_NAME = u"FontName"_ustr; +inline constexpr OUString PROPERTY_FONT_STYLENAME = u"FontStyleName"_ustr; +inline constexpr OUString PROPERTY_FONT_FAMILY = u"FontFamily"_ustr; +inline constexpr OUString PROPERTY_FONT_CHARSET = u"FontCharset"_ustr; +inline constexpr OUString PROPERTY_FONT_HEIGHT = u"FontHeight"_ustr; +inline constexpr OUString PROPERTY_FONT_WEIGHT = u"FontWeight"_ustr; +inline constexpr OUString PROPERTY_FONT_SLANT = u"FontSlant"_ustr; +inline constexpr OUString PROPERTY_FONT_UNDERLINE = u"FontUnderline"_ustr; +inline constexpr OUString PROPERTY_FONT_WORDLINEMODE = u"FontWordLineMode"_ustr; +inline constexpr OUString PROPERTY_FONT_STRIKEOUT = u"FontStrikeout"_ustr; +inline constexpr OUString PROPERTY_FONTEMPHASISMARK = u"FontEmphasisMark"_ustr; +inline constexpr OUString PROPERTY_FONTRELIEF = u"FontRelief"_ustr; +inline constexpr OUString PROPERTY_FONT_CHARWIDTH = u"FontCharWidth"_ustr; +inline constexpr OUString PROPERTY_FONT_KERNING = u"FontKerning"_ustr; +inline constexpr OUString PROPERTY_FONT_ORIENTATION = u"FontOrientation"_ustr; +inline constexpr OUString PROPERTY_FONT_PITCH = u"FontPitch"_ustr; +inline constexpr OUString PROPERTY_FONT_TYPE = u"FontType"_ustr; +inline constexpr OUString PROPERTY_FONT_WIDTH = u"FontWidth"_ustr; +inline constexpr OUString PROPERTY_HELPURL = u"HelpURL"_ustr; +inline constexpr OUString PROPERTY_RECORDMARKER = u"HasRecordMarker"_ustr; +inline constexpr OUString PROPERTY_BOUNDFIELD = u"BoundField"_ustr; +inline constexpr OUString PROPERTY_INPUT_REQUIRED = u"InputRequired"_ustr; +inline constexpr OUString PROPERTY_TREATASNUMERIC = u"TreatAsNumber"_ustr; +inline constexpr OUString PROPERTY_EFFECTIVE_VALUE = u"EffectiveValue"_ustr; +inline constexpr OUString PROPERTY_EFFECTIVE_DEFAULT = u"EffectiveDefault"_ustr; +inline constexpr OUString PROPERTY_EFFECTIVE_MIN = u"EffectiveMin"_ustr; +inline constexpr OUString PROPERTY_EFFECTIVE_MAX = u"EffectiveMax"_ustr; +inline constexpr OUString PROPERTY_HIDDEN = u"Hidden"_ustr; +inline constexpr OUString PROPERTY_FILTERPROPOSAL = u"UseFilterValueProposal"_ustr; +inline constexpr OUString PROPERTY_FIELDSOURCE = u"FieldSource"_ustr; +inline constexpr OUString PROPERTY_TABLENAME = u"TableName"_ustr; +inline constexpr OUString PROPERTY_CONTROLLABEL = u"LabelControl"_ustr; +inline constexpr OUString PROPERTY_CURRSYM_POSITION = u"PrependCurrencySymbol"_ustr; +inline constexpr OUString PROPERTY_CURSORCOLOR = u"CursorColor"_ustr; +inline constexpr OUString PROPERTY_ALWAYSSHOWCURSOR = u"AlwaysShowCursor"_ustr; +inline constexpr OUString PROPERTY_DISPLAYSYNCHRON = u"DisplayIsSynchron"_ustr; +inline constexpr OUString PROPERTY_TEXTCOLOR = u"TextColor"_ustr; +inline constexpr OUString PROPERTY_DELAY = u"RepeatDelay"_ustr; +inline constexpr OUString PROPERTY_DEFAULT_SCROLL_VALUE = u"DefaultScrollValue"_ustr; +inline constexpr OUString PROPERTY_SCROLL_VALUE = u"ScrollValue"_ustr; +inline constexpr OUString PROPERTY_DEFAULT_SPIN_VALUE = u"DefaultSpinValue"_ustr; +inline constexpr OUString PROPERTY_SPIN_VALUE = u"SpinValue"_ustr; +inline constexpr OUString PROPERTY_REFERENCE_DEVICE = u"ReferenceDevice"_ustr; +inline constexpr OUString PROPERTY_ISMODIFIED = u"IsModified"_ustr; +inline constexpr OUString PROPERTY_ISNEW = u"IsNew"_ustr; +inline constexpr OUString PROPERTY_PRIVILEGES = u"Privileges"_ustr; +inline constexpr OUString PROPERTY_COMMAND = u"Command"_ustr; +inline constexpr OUString PROPERTY_COMMANDTYPE = u"CommandType"_ustr; +inline constexpr OUString PROPERTY_RESULTSET_CONCURRENCY = u"ResultSetConcurrency"_ustr; +inline constexpr OUString PROPERTY_INSERTONLY = u"IgnoreResult"_ustr; +inline constexpr OUString PROPERTY_RESULTSET_TYPE = u"ResultSetType"_ustr; +inline constexpr OUString PROPERTY_ESCAPE_PROCESSING = u"EscapeProcessing"_ustr; +inline constexpr OUString PROPERTY_APPLYFILTER = u"ApplyFilter"_ustr; +inline constexpr OUString PROPERTY_ROWCOUNT = u"RowCount"_ustr; +inline constexpr OUString PROPERTY_ROWCOUNTFINAL = u"IsRowCountFinal"_ustr; - //- properties +inline constexpr OUString PROPERTY_ISNULLABLE = u"IsNullable"_ustr; +inline constexpr OUString PROPERTY_ACTIVECOMMAND = u"ActiveCommand"_ustr; +inline constexpr OUString PROPERTY_ISCURRENCY = u"IsCurrency"_ustr; +inline constexpr OUString PROPERTY_URL = u"URL"_ustr; +inline constexpr OUString PROPERTY_TITLE = u"Title"_ustr; +inline constexpr OUString PROPERTY_ACTIVE_CONNECTION = u"ActiveConnection"_ustr; +inline constexpr OUString PROPERTY_SCALE = u"Scale"_ustr; +inline constexpr OUString PROPERTY_SORT = u"Order"_ustr; +inline constexpr OUString PROPERTY_DATASOURCE = u"DataSourceName"_ustr; +inline constexpr OUString PROPERTY_DETAILFIELDS = u"DetailFields"_ustr; - #define PROPERTY_TABINDEX "TabIndex" - #define PROPERTY_TAG "Tag" - #define PROPERTY_NAME "Name" - #define PROPERTY_GROUP_NAME "GroupName" - #define PROPERTY_CLASSID "ClassId" - #define PROPERTY_FETCHSIZE "FetchSize" - #define PROPERTY_VALUE "Value" - #define PROPERTY_TEXT "Text" - #define PROPERTY_LABEL "Label" - #define PROPERTY_CANINSERT "CanInsert" - #define PROPERTY_CANUPDATE "CanUpdate" - #define PROPERTY_CANDELETE "CanDelete" - #define PROPERTY_NAVIGATION "NavigationBarMode" - #define PROPERTY_HASNAVIGATION "HasNavigationBar" - #define PROPERTY_CYCLE "Cycle" - #define PROPERTY_CONTROLSOURCE "DataField" - #define PROPERTY_ENABLED "Enabled" - #define PROPERTY_ENABLEVISIBLE "EnableVisible" - #define PROPERTY_READONLY "ReadOnly" - #define PROPERTY_RELEVANT "Relevant" - #define PROPERTY_ISREADONLY "IsReadOnly" - #define PROPERTY_FILTER "Filter" - #define PROPERTY_HAVINGCLAUSE "HavingClause" - #define PROPERTY_WIDTH "Width" - #define PROPERTY_SEARCHABLE "IsSearchable" - #define PROPERTY_MULTILINE "MultiLine" - #define PROPERTY_TARGET_URL "TargetURL" - #define PROPERTY_TARGET_FRAME "TargetFrame" - #define PROPERTY_DEFAULTCONTROL "DefaultControl" - #define PROPERTY_MAXTEXTLEN "MaxTextLen" - #define PROPERTY_EDITMASK "EditMask" - #define PROPERTY_SIZE "Size" - #define PROPERTY_SPIN "Spin" - #define PROPERTY_DATE "Date" - #define PROPERTY_TIME "Time" - #define PROPERTY_STATE "State" - #define PROPERTY_TRISTATE "TriState" - #define PROPERTY_HIDDEN_VALUE "HiddenValue" - #define PROPERTY_BUTTONTYPE "ButtonType" - #define PROPERTY_STRINGITEMLIST "StringItemList" - #define PROPERTY_TYPEDITEMLIST "TypedItemList" - #define PROPERTY_DEFAULT_TEXT "DefaultText" - #define PROPERTY_DEFAULT_STATE "DefaultState" - #define PROPERTY_FORMATKEY "FormatKey" - #define PROPERTY_FORMATSSUPPLIER "FormatsSupplier" - #define PROPERTY_SUBMIT_ACTION "SubmitAction" - #define PROPERTY_SUBMIT_TARGET "SubmitTarget" - #define PROPERTY_SUBMIT_METHOD "SubmitMethod" - #define PROPERTY_SUBMIT_ENCODING "SubmitEncoding" - #define PROPERTY_IMAGE_URL "ImageURL" - #define PROPERTY_GRAPHIC "Graphic" - #define PROPERTY_IMAGE_POSITION "ImagePosition" - #define PROPERTY_EMPTY_IS_NULL "ConvertEmptyToNull" - #define PROPERTY_LISTSOURCETYPE "ListSourceType" - #define PROPERTY_LISTSOURCE "ListSource" - #define PROPERTY_SELECT_SEQ "SelectedItems" - #define PROPERTY_VALUE_SEQ "ValueItemList" - #define PROPERTY_SELECT_VALUE_SEQ "SelectedValues" - #define PROPERTY_SELECT_VALUE "SelectedValue" - #define PROPERTY_DEFAULT_SELECT_SEQ "DefaultSelection" - #define PROPERTY_MULTISELECTION "MultiSelection" - #define PROPERTY_ALIGN "Align" - #define PROPERTY_VERTICAL_ALIGN "VerticalAlign" - #define PROPERTY_DEFAULT_DATE "DefaultDate" - #define PROPERTY_DEFAULT_TIME "DefaultTime" - #define PROPERTY_DEFAULT_VALUE "DefaultValue" - #define PROPERTY_DECIMAL_ACCURACY "DecimalAccuracy" - #define PROPERTY_CURSORSOURCE "DataSelection" - #define PROPERTY_CURSORSOURCETYPE "DataSelectionType" - #define PROPERTY_FIELDTYPE "Type" - #define PROPERTY_DECIMALS "Decimals" - #define PROPERTY_REFVALUE "RefValue" - #define PROPERTY_UNCHECKED_REFVALUE "SecondaryRefValue" - #define PROPERTY_VALUEMIN "ValueMin" - #define PROPERTY_VALUEMAX "ValueMax" - #define PROPERTY_STRICTFORMAT "StrictFormat" - #define PROPERTY_ALLOWADDITIONS "AllowInserts" - #define PROPERTY_ALLOWEDITS "AllowUpdates" - #define PROPERTY_ALLOWDELETIONS "AllowDeletes" - #define PROPERTY_MASTERFIELDS "MasterFields" - #define PROPERTY_ISPASSTHROUGH "IsPassThrough" - #define PROPERTY_QUERY "Query" - #define PROPERTY_LITERALMASK "LiteralMask" - #define PROPERTY_VALUESTEP "ValueStep" - #define PROPERTY_SHOWTHOUSANDSEP "ShowThousandsSeparator" - #define PROPERTY_CURRENCYSYMBOL "CurrencySymbol" - #define PROPERTY_DATEFORMAT "DateFormat" - #define PROPERTY_DATEMIN "DateMin" - #define PROPERTY_DATEMAX "DateMax" - #define PROPERTY_DATE_SHOW_CENTURY "DateShowCentury" - #define PROPERTY_TIMEFORMAT "TimeFormat" - #define PROPERTY_TIMEMIN "TimeMin" - #define PROPERTY_TIMEMAX "TimeMax" - #define PROPERTY_LINECOUNT "LineCount" - #define PROPERTY_BOUNDCOLUMN "BoundColumn" - #define PROPERTY_FONT u"FontDescriptor" - #define PROPERTY_FILLCOLOR "FillColor" - #define PROPERTY_LINECOLOR "LineColor" - #define PROPERTY_DROPDOWN "Dropdown" - #define PROPERTY_HSCROLL "HScroll" - #define PROPERTY_VSCROLL "VScroll" - #define PROPERTY_TABSTOP "Tabstop" - #define PROPERTY_AUTOCOMPLETE "Autocomplete" - #define PROPERTY_HARDLINEBREAKS "HardLineBreaks" - #define PROPERTY_PRINTABLE "Printable" - #define PROPERTY_ECHO_CHAR "EchoChar" - #define PROPERTY_ROWHEIGHT "RowHeight" - #define PROPERTY_HELPTEXT "HelpText" - #define PROPERTY_FONT_NAME "FontName" - #define PROPERTY_FONT_STYLENAME "FontStyleName" - #define PROPERTY_FONT_FAMILY "FontFamily" - #define PROPERTY_FONT_CHARSET "FontCharset" - #define PROPERTY_FONT_HEIGHT "FontHeight" - #define PROPERTY_FONT_WEIGHT "FontWeight" - #define PROPERTY_FONT_SLANT "FontSlant" - #define PROPERTY_FONT_UNDERLINE "FontUnderline" - #define PROPERTY_FONT_WORDLINEMODE "FontWordLineMode" - #define PROPERTY_FONT_STRIKEOUT "FontStrikeout" - #define PROPERTY_FONTEMPHASISMARK "FontEmphasisMark" - #define PROPERTY_FONTRELIEF "FontRelief" - #define PROPERTY_FONT_CHARWIDTH "FontCharWidth" - #define PROPERTY_FONT_KERNING "FontKerning" - #define PROPERTY_FONT_ORIENTATION "FontOrientation" - #define PROPERTY_FONT_PITCH "FontPitch" - #define PROPERTY_FONT_TYPE "FontType" - #define PROPERTY_FONT_WIDTH "FontWidth" - #define PROPERTY_HELPURL "HelpURL" - #define PROPERTY_RECORDMARKER "HasRecordMarker" - #define PROPERTY_BOUNDFIELD "BoundField" - #define PROPERTY_INPUT_REQUIRED "InputRequired" - #define PROPERTY_TREATASNUMERIC "TreatAsNumber" - #define PROPERTY_EFFECTIVE_VALUE "EffectiveValue" - #define PROPERTY_EFFECTIVE_DEFAULT "EffectiveDefault" - #define PROPERTY_EFFECTIVE_MIN "EffectiveMin" - #define PROPERTY_EFFECTIVE_MAX "EffectiveMax" - #define PROPERTY_HIDDEN "Hidden" - #define PROPERTY_FILTERPROPOSAL "UseFilterValueProposal" - #define PROPERTY_FIELDSOURCE "FieldSource" - #define PROPERTY_TABLENAME "TableName" - #define PROPERTY_ISFILTERAPPLIED "IsFilterApplied" - #define PROPERTY_CONTROLLABEL "LabelControl" - #define PROPERTY_CURRSYM_POSITION "PrependCurrencySymbol" - #define PROPERTY_CURSORCOLOR "CursorColor" - #define PROPERTY_ALWAYSSHOWCURSOR "AlwaysShowCursor" - #define PROPERTY_DISPLAYSYNCHRON "DisplayIsSynchron" - #define PROPERTY_TEXTCOLOR "TextColor" - #define PROPERTY_DELAY "RepeatDelay" - #define PROPERTY_DEFAULT_SCROLL_VALUE "DefaultScrollValue" - #define PROPERTY_SCROLL_VALUE "ScrollValue" - #define PROPERTY_DEFAULT_SPIN_VALUE "DefaultSpinValue" - #define PROPERTY_SPIN_VALUE "SpinValue" - #define PROPERTY_REFERENCE_DEVICE "ReferenceDevice" - #define PROPERTY_ISMODIFIED "IsModified" - #define PROPERTY_ISNEW "IsNew" - #define PROPERTY_PRIVILEGES "Privileges" - #define PROPERTY_COMMAND "Command" - #define PROPERTY_COMMANDTYPE "CommandType" - #define PROPERTY_RESULTSET_CONCURRENCY "ResultSetConcurrency" - #define PROPERTY_INSERTONLY "IgnoreResult" - #define PROPERTY_RESULTSET_TYPE "ResultSetType" - #define PROPERTY_ESCAPE_PROCESSING "EscapeProcessing" - #define PROPERTY_APPLYFILTER "ApplyFilter" - #define PROPERTY_ROWCOUNT "RowCount" - #define PROPERTY_ROWCOUNTFINAL "IsRowCountFinal" +inline constexpr OUString PROPERTY_COLUMNSERVICENAME = u"ColumnServiceName"_ustr; +inline constexpr OUString PROPERTY_REALNAME = u"RealName"_ustr; +inline constexpr OUString PROPERTY_CONTROLSOURCEPROPERTY = u"DataFieldProperty"_ustr; +inline constexpr OUString PROPERTY_USER = u"User"_ustr; +inline constexpr OUString PROPERTY_PASSWORD = u"Password"_ustr; +inline constexpr OUString PROPERTY_DISPATCHURLINTERNAL = u"DispatchURLInternal"_ustr; +inline constexpr OUString PROPERTY_PERSISTENCE_MAXTEXTLENGTH = u"PersistenceMaxTextLength"_ustr; +inline constexpr OUString PROPERTY_RICH_TEXT = u"RichText"_ustr; +inline constexpr OUString PROPERTY_ENFORCE_FORMAT = u"EnforceFormat"_ustr; +inline constexpr OUString PROPERTY_LINEEND_FORMAT = u"LineEndFormat"_ustr; +inline constexpr OUString PROPERTY_WRITING_MODE = u"WritingMode"_ustr; +inline constexpr OUString PROPERTY_CONTEXT_WRITING_MODE = u"ContextWritingMode"_ustr; - #define PROPERTY_ISNULLABLE "IsNullable" - #define PROPERTY_ACTIVECOMMAND "ActiveCommand" - #define PROPERTY_ISCURRENCY "IsCurrency" - #define PROPERTY_URL "URL" - #define PROPERTY_TITLE "Title" - #define PROPERTY_ACTIVE_CONNECTION "ActiveConnection" - #define PROPERTY_SCALE "Scale" - #define PROPERTY_SORT "Order" - #define PROPERTY_DATASOURCE "DataSourceName" - #define PROPERTY_DETAILFIELDS "DetailFields" +inline constexpr OUString PROPERTY_NATIVE_LOOK = u"NativeWidgetLook"_ustr; +inline constexpr OUString PROPERTY_BORDER = u"Border"_ustr; +inline constexpr OUString PROPERTY_BORDERCOLOR = u"BorderColor"_ustr; +inline constexpr OUString PROPERTY_BACKGROUNDCOLOR = u"BackgroundColor"_ustr; +inline constexpr OUString PROPERTY_ICONSIZE = u"IconSize"_ustr; +inline constexpr OUString PROPERTY_TEXTLINECOLOR = u"TextLineColor"_ustr; +inline constexpr OUString PROPERTY_HIDEINACTIVESELECTION = u"HideInactiveSelection"_ustr; - #define PROPERTY_COLUMNSERVICENAME "ColumnServiceName" - #define PROPERTY_REALNAME "RealName" - #define PROPERTY_CONTROLSOURCEPROPERTY "DataFieldProperty" - #define PROPERTY_USER "User" - #define PROPERTY_PASSWORD "Password" - #define PROPERTY_DISPATCHURLINTERNAL "DispatchURLInternal" - #define PROPERTY_PERSISTENCE_MAXTEXTLENGTH "PersistenceMaxTextLength" - #define PROPERTY_RICH_TEXT "RichText" - #define PROPERTY_ENFORCE_FORMAT "EnforceFormat" - #define PROPERTY_LINEEND_FORMAT "LineEndFormat" - #define PROPERTY_WRITING_MODE u"WritingMode" - #define PROPERTY_CONTEXT_WRITING_MODE "ContextWritingMode" +inline constexpr OUString PROPERTY_STANDARD_THEME = u"StandardTheme"_ustr; - #define PROPERTY_NATIVE_LOOK "NativeWidgetLook" - #define PROPERTY_BORDER "Border" - #define PROPERTY_BORDERCOLOR "BorderColor" - #define PROPERTY_BACKGROUNDCOLOR "BackgroundColor" - #define PROPERTY_ICONSIZE "IconSize" - #define PROPERTY_TEXTLINECOLOR "TextLineColor" - #define PROPERTY_HIDEINACTIVESELECTION "HideInactiveSelection" +inline constexpr OUString PROPERTY_SHOW_POSITION = u"ShowPosition"_ustr; +inline constexpr OUString PROPERTY_SHOW_NAVIGATION = u"ShowNavigation"_ustr; +inline constexpr OUString PROPERTY_SHOW_RECORDACTIONS = u"ShowRecordActions"_ustr; +inline constexpr OUString PROPERTY_SHOW_FILTERSORT = u"ShowFilterSort"_ustr; - #define PROPERTY_SHOW_POSITION "ShowPosition" - #define PROPERTY_SHOW_NAVIGATION "ShowNavigation" - #define PROPERTY_SHOW_RECORDACTIONS "ShowRecordActions" - #define PROPERTY_SHOW_FILTERSORT "ShowFilterSort" +inline constexpr OUString PROPERTY_XSD_WHITESPACE = u"WhiteSpace"_ustr; +inline constexpr OUString PROPERTY_XSD_PATTERN = u"Pattern"_ustr; +inline constexpr OUString PROPERTY_XSD_LENGTH = u"Length"_ustr; +inline constexpr OUString PROPERTY_XSD_MIN_LENGTH = u"MinLength"_ustr; +inline constexpr OUString PROPERTY_XSD_MAX_LENGTH = u"MaxLength"_ustr; +inline constexpr OUString PROPERTY_XSD_TOTAL_DIGITS = u"TotalDigits"_ustr; +inline constexpr OUString PROPERTY_XSD_FRACTION_DIGITS = u"FractionDigits"_ustr; +inline constexpr OUString PROPERTY_XSD_MAX_INCLUSIVE_INT = u"MaxInclusiveInt"_ustr; +inline constexpr OUString PROPERTY_XSD_MAX_EXCLUSIVE_INT = u"MaxExclusiveInt"_ustr; +inline constexpr OUString PROPERTY_XSD_MIN_INCLUSIVE_INT = u"MinInclusiveInt"_ustr; +inline constexpr OUString PROPERTY_XSD_MIN_EXCLUSIVE_INT = u"MinExclusiveInt"_ustr; +inline constexpr OUString PROPERTY_XSD_MAX_INCLUSIVE_DOUBLE = u"MaxInclusiveDouble"_ustr; +inline constexpr OUString PROPERTY_XSD_MAX_EXCLUSIVE_DOUBLE = u"MaxExclusiveDouble"_ustr; +inline constexpr OUString PROPERTY_XSD_MIN_INCLUSIVE_DOUBLE = u"MinInclusiveDouble"_ustr; +inline constexpr OUString PROPERTY_XSD_MIN_EXCLUSIVE_DOUBLE = u"MinExclusiveDouble"_ustr; +inline constexpr OUString PROPERTY_XSD_MAX_INCLUSIVE_DATE = u"MaxInclusiveDate"_ustr; +inline constexpr OUString PROPERTY_XSD_MAX_EXCLUSIVE_DATE = u"MaxExclusiveDate"_ustr; +inline constexpr OUString PROPERTY_XSD_MIN_INCLUSIVE_DATE = u"MinInclusiveDate"_ustr; +inline constexpr OUString PROPERTY_XSD_MIN_EXCLUSIVE_DATE = u"MinExclusiveDate"_ustr; +inline constexpr OUString PROPERTY_XSD_MAX_INCLUSIVE_TIME = u"MaxInclusiveTime"_ustr; +inline constexpr OUString PROPERTY_XSD_MAX_EXCLUSIVE_TIME = u"MaxExclusiveTime"_ustr; +inline constexpr OUString PROPERTY_XSD_MIN_INCLUSIVE_TIME = u"MinInclusiveTime"_ustr; +inline constexpr OUString PROPERTY_XSD_MIN_EXCLUSIVE_TIME = u"MinExclusiveTime"_ustr; +inline constexpr OUString PROPERTY_XSD_MAX_INCLUSIVE_DATE_TIME = u"MaxInclusiveDateTime"_ustr; +inline constexpr OUString PROPERTY_XSD_MAX_EXCLUSIVE_DATE_TIME = u"MaxExclusiveDateTime"_ustr; +inline constexpr OUString PROPERTY_XSD_MIN_INCLUSIVE_DATE_TIME = u"MinInclusiveDateTime"_ustr; +inline constexpr OUString PROPERTY_XSD_MIN_EXCLUSIVE_DATE_TIME = u"MinExclusiveDateTime"_ustr; +inline constexpr OUString PROPERTY_XSD_IS_BASIC = u"IsBasic"_ustr; +inline constexpr OUString PROPERTY_XSD_TYPE_CLASS = u"TypeClass"_ustr; - #define PROPERTY_XSD_WHITESPACE "WhiteSpace" - #define PROPERTY_XSD_PATTERN "Pattern" - #define PROPERTY_XSD_LENGTH "Length" - #define PROPERTY_XSD_MIN_LENGTH "MinLength" - #define PROPERTY_XSD_MAX_LENGTH "MaxLength" - #define PROPERTY_XSD_TOTAL_DIGITS "TotalDigits" - #define PROPERTY_XSD_FRACTION_DIGITS "FractionDigits" - #define PROPERTY_XSD_MAX_INCLUSIVE_INT "MaxInclusiveInt" - #define PROPERTY_XSD_MAX_EXCLUSIVE_INT "MaxExclusiveInt" - #define PROPERTY_XSD_MIN_INCLUSIVE_INT "MinInclusiveInt" - #define PROPERTY_XSD_MIN_EXCLUSIVE_INT "MinExclusiveInt" - #define PROPERTY_XSD_MAX_INCLUSIVE_DOUBLE "MaxInclusiveDouble" - #define PROPERTY_XSD_MAX_EXCLUSIVE_DOUBLE "MaxExclusiveDouble" - #define PROPERTY_XSD_MIN_INCLUSIVE_DOUBLE "MinInclusiveDouble" - #define PROPERTY_XSD_MIN_EXCLUSIVE_DOUBLE "MinExclusiveDouble" - #define PROPERTY_XSD_MAX_INCLUSIVE_DATE "MaxInclusiveDate" - #define PROPERTY_XSD_MAX_EXCLUSIVE_DATE "MaxExclusiveDate" - #define PROPERTY_XSD_MIN_INCLUSIVE_DATE "MinInclusiveDate" - #define PROPERTY_XSD_MIN_EXCLUSIVE_DATE "MinExclusiveDate" - #define PROPERTY_XSD_MAX_INCLUSIVE_TIME "MaxInclusiveTime" - #define PROPERTY_XSD_MAX_EXCLUSIVE_TIME "MaxExclusiveTime" - #define PROPERTY_XSD_MIN_INCLUSIVE_TIME "MinInclusiveTime" - #define PROPERTY_XSD_MIN_EXCLUSIVE_TIME "MinExclusiveTime" - #define PROPERTY_XSD_MAX_INCLUSIVE_DATE_TIME "MaxInclusiveDateTime" - #define PROPERTY_XSD_MAX_EXCLUSIVE_DATE_TIME "MaxExclusiveDateTime" - #define PROPERTY_XSD_MIN_INCLUSIVE_DATE_TIME "MinInclusiveDateTime" - #define PROPERTY_XSD_MIN_EXCLUSIVE_DATE_TIME "MinExclusiveDateTime" - #define PROPERTY_XSD_IS_BASIC "IsBasic" - #define PROPERTY_XSD_TYPE_CLASS "TypeClass" +inline constexpr OUString PROPERTY_DYNAMIC_CONTROL_BORDER = u"DynamicControlBorder"_ustr; +inline constexpr OUString PROPERTY_CONTROL_BORDER_COLOR_FOCUS = u"ControlBorderColorOnFocus"_ustr; +inline constexpr OUString PROPERTY_CONTROL_BORDER_COLOR_MOUSE = u"ControlBorderColorOnHover"_ustr; +inline constexpr OUString PROPERTY_CONTROL_BORDER_COLOR_INVALID = u"ControlBorderColorOnInvalid"_ustr; +inline constexpr OUString PROPERTY_GENERATEVBAEVENTS = u"GenerateVbaEvents"_ustr; +inline constexpr OUString PROPERTY_CONTROL_TYPE_IN_MSO = u"ControlTypeinMSO"_ustr; +inline constexpr OUString PROPERTY_OBJ_ID_IN_MSO = u"ObjIDinMSO"_ustr; - #define PROPERTY_DYNAMIC_CONTROL_BORDER "DynamicControlBorder" - #define PROPERTY_CONTROL_BORDER_COLOR_FOCUS "ControlBorderColorOnFocus" - #define PROPERTY_CONTROL_BORDER_COLOR_MOUSE "ControlBorderColorOnHover" - #define PROPERTY_CONTROL_BORDER_COLOR_INVALID "ControlBorderColorOnInvalid" - #define PROPERTY_GENERATEVBAEVENTS "GenerateVbaEvents" - #define PROPERTY_CONTROL_TYPE_IN_MSO "ControlTypeinMSO" - #define PROPERTY_OBJ_ID_IN_MSO "ObjIDinMSO" +//- URLs - //- URLs +#define URL_FORM_POSITION ".uno:FormController/positionForm" +#define URL_FORM_RECORDCOUNT ".uno:FormController/RecordCount" +#define URL_RECORD_FIRST ".uno:FormController/moveToFirst" +#define URL_RECORD_PREV ".uno:FormController/moveToPrev" +#define URL_RECORD_NEXT ".uno:FormController/moveToNext" +#define URL_RECORD_LAST ".uno:FormController/moveToLast" +#define URL_RECORD_SAVE ".uno:FormController/saveRecord" +#define URL_RECORD_UNDO ".uno:FormController/undoRecord" +#define URL_RECORD_NEW ".uno:FormController/moveToNew" +#define URL_RECORD_DELETE ".uno:FormController/deleteRecord" +#define URL_FORM_REFRESH ".uno:FormController/refreshForm" +#define URL_FORM_REFRESH_CURRENT_CONTROL ".uno:FormController/refreshCurrentControl" - #define URL_FORM_POSITION ".uno:FormController/positionForm" - #define URL_FORM_RECORDCOUNT ".uno:FormController/RecordCount" - #define URL_RECORD_FIRST ".uno:FormController/moveToFirst" - #define URL_RECORD_PREV ".uno:FormController/moveToPrev" - #define URL_RECORD_NEXT ".uno:FormController/moveToNext" - #define URL_RECORD_LAST ".uno:FormController/moveToLast" - #define URL_RECORD_SAVE ".uno:FormController/saveRecord" - #define URL_RECORD_UNDO ".uno:FormController/undoRecord" - #define URL_RECORD_NEW ".uno:FormController/moveToNew" - #define URL_RECORD_DELETE ".uno:FormController/deleteRecord" - #define URL_FORM_REFRESH ".uno:FormController/refreshForm" - #define URL_FORM_REFRESH_CURRENT_CONTROL ".uno:FormController/refreshCurrentControl" - - #define URL_FORM_SORT_UP ".uno:FormController/sortUp" - #define URL_FORM_SORT_DOWN ".uno:FormController/sortDown" - #define URL_FORM_SORT ".uno:FormController/sort" - #define URL_FORM_AUTO_FILTER ".uno:FormController/autoFilter" - #define URL_FORM_FILTER ".uno:FormController/filter" - #define URL_FORM_APPLY_FILTER ".uno:FormController/applyFilter" - #define URL_FORM_REMOVE_FILTER ".uno:FormController/removeFilterOrder" - - -} // namespace frm +#define URL_FORM_SORT_UP ".uno:FormController/sortUp" +#define URL_FORM_SORT_DOWN ".uno:FormController/sortDown" +#define URL_FORM_SORT ".uno:FormController/sort" +#define URL_FORM_AUTO_FILTER ".uno:FormController/autoFilter" +#define URL_FORM_FILTER ".uno:FormController/filter" +#define URL_FORM_APPLY_FILTER ".uno:FormController/applyFilter" +#define URL_FORM_REMOVE_FILTER ".uno:FormController/removeFilterOrder" /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/limitedformats.hxx b/forms/source/inc/limitedformats.hxx index a176df06f054..9ef4534423cd 100644 --- a/forms/source/inc/limitedformats.hxx +++ b/forms/source/inc/limitedformats.hxx @@ -43,7 +43,6 @@ namespace frm static css::uno::Reference< css::util::XNumberFormatsSupplier > s_xStandardFormats; - protected: sal_Int32 m_nFormatEnumPropertyHandle; const sal_Int16 m_nTableId; css::uno::Reference< css::beans::XFastPropertySet > diff --git a/forms/source/inc/listenercontainers.hxx b/forms/source/inc/listenercontainers.hxx deleted file mode 100644 index f7b0cbb88579..000000000000 --- a/forms/source/inc/listenercontainers.hxx +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once - -#include <com/sun/star/form/XResetListener.hpp> -#include <comphelper/listenernotification.hxx> -#include <cppuhelper/weak.hxx> - - -namespace frm -{ - - template < class LISTENER > - class EventListeners : public ::comphelper::OListenerContainerBase< LISTENER, css::lang::EventObject > - { - public: - typedef ::comphelper::OListenerContainerBase< LISTENER, css::lang::EventObject > - EventListeners_Base; - - private: - ::cppu::OWeakObject& m_rInstigator; - - protected: - EventListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex ) - :EventListeners_Base( _rMutex ) - ,m_rInstigator( _rInstigator ) - { - } - - public: - bool notify() - { - css::lang::EventObject aEvent( m_rInstigator ); - return EventListeners_Base::notify( aEvent ); - } - - void disposing() - { - css::lang::EventObject aEvent( m_rInstigator ); - EventListeners_Base::disposing( aEvent ); - } - protected: - using EventListeners_Base::notify; - using EventListeners_Base::disposing; - }; - - typedef EventListeners < css::form::XResetListener - > ResetListeners_Base; - class ResetListeners : public ResetListeners_Base - { - private: - enum NotificationType - { - eApproval, - eFinal - }; - NotificationType m_eCurrentNotificationType; - - public: - ResetListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex ) - :ResetListeners_Base( _rInstigator, _rMutex ) - ,m_eCurrentNotificationType( eApproval ) - { - } - - /** see whether all our listeners approve the reset - */ - bool approveReset() - { - m_eCurrentNotificationType = eApproval; - return notify(); - } - - /** tell all our listeners that the reset happened - */ - void resetted() - { - m_eCurrentNotificationType = eFinal; - notify(); - } - - protected: - virtual bool implTypedNotify( - const css::uno::Reference< css::form::XResetListener >& _rxListener, - const css::lang::EventObject& _rEvent - ) override; - }; - - -} // namespace frm - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/property.hxx b/forms/source/inc/property.hxx index f0383433d4b9..00b2075ccebd 100644 --- a/forms/source/inc/property.hxx +++ b/forms/source/inc/property.hxx @@ -23,9 +23,7 @@ #include <unordered_map> -#include <com/sun/star/beans/PropertyAttribute.hpp> #include <comphelper/propagg.hxx> -#include <tools/debug.hxx> #include "frm_strings.hxx" @@ -59,7 +57,7 @@ namespace frm #define PROPERTY_ID_VERTICAL_ALIGN (PROPERTY_ID_START + 22) #define PROPERTY_ID_GRAPHIC (PROPERTY_ID_START + 23) #define PROPERTY_ID_GROUP_NAME (PROPERTY_ID_START + 24) - // free +#define PROPERTY_ID_STANDARD_THEME (PROPERTY_ID_START + 25) // free // free // free @@ -328,7 +326,7 @@ private: // a class implementing the comphelper::IPropertyInfoService -class ConcreteInfoService : public ::comphelper::IPropertyInfoService +class ConcreteInfoService final : public ::comphelper::IPropertyInfoService { public: virtual ~ConcreteInfoService() {} @@ -336,96 +334,6 @@ public: virtual sal_Int32 getPreferredPropertyId(const OUString& _rName) override; }; - -#define DECL_PROP_IMPL(varname, type) \ - *pProperties++ = css::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, cppu::UnoType<type>::get(), - - -#define DECL_BOOL_PROP_IMPL(varname) \ - *pProperties++ = css::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, cppu::UnoType<bool>::get(), - - -#define DECL_IFACE_PROP_IMPL(varname, type) \ - *pProperties++ = css::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, cppu::UnoType<type>::get(), - - -#define BEGIN_DESCRIBE_PROPERTIES( count, baseclass ) \ - baseclass::describeFixedProperties( _rProps ); \ - sal_Int32 nOldCount = _rProps.getLength(); \ - _rProps.realloc( nOldCount + ( count ) ); \ - css::beans::Property* pProperties = _rProps.getArray() + nOldCount; \ - - -#define BEGIN_DESCRIBE_BASE_PROPERTIES( count ) \ - _rProps.realloc( count ); \ - css::beans::Property* pProperties = _rProps.getArray(); \ - - -#define DECL_PROP0(varname, type) \ - DECL_PROP_IMPL(varname, type) 0) - - -#define DECL_PROP1(varname, type, attrib1) \ - DECL_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1) - - -#define DECL_PROP2(varname, type, attrib1, attrib2) \ - DECL_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2) - - -#define DECL_PROP3(varname, type, attrib1, attrib2, attrib3) \ - DECL_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2 | css::beans::PropertyAttribute::attrib3) - - -#define DECL_PROP4(varname, type, attrib1, attrib2, attrib3, attrib4) \ - DECL_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2 | css::beans::PropertyAttribute::attrib3 | css::beans::PropertyAttribute::attrib4) - -// === some property types require special handling -// === such as interfaces - -#define DECL_IFACE_PROP2(varname, type, attrib1, attrib2) \ - DECL_IFACE_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2) - - -#define DECL_IFACE_PROP3(varname, type, attrib1, attrib2, attrib3) \ - DECL_IFACE_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2 | css::beans::PropertyAttribute::attrib3) - - -#define DECL_IFACE_PROP4(varname, type, attrib1, attrib2, attrib3, attrib4) \ - DECL_IFACE_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2 | css::beans::PropertyAttribute::attrib3 | PropertyAttribute::attrib4) - -// === or Boolean properties - -#define DECL_BOOL_PROP1(varname, attrib1) \ - DECL_BOOL_PROP_IMPL(varname) css::beans::PropertyAttribute::attrib1) - - -#define DECL_BOOL_PROP2(varname, attrib1, attrib2) \ - DECL_BOOL_PROP_IMPL(varname) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2) - - -#define DECL_BOOL_PROP3( varname, attrib1, attrib2, attrib3 ) \ - DECL_BOOL_PROP_IMPL(varname) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2 | css::beans::PropertyAttribute::attrib3 ) - - -#define END_DESCRIBE_PROPERTIES() \ - DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); \ - - -#define REGISTER_PROP_2( prop, member, attrib1, attrib2 ) \ - registerProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::attrib1 | PropertyAttribute::attrib2, \ - &member, cppu::UnoType<decltype(member)>::get() ); - -#define REGISTER_PROP_3( prop, member, attrib1, attrib2, attrib3 ) \ - registerProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::attrib1 | PropertyAttribute::attrib2 | PropertyAttribute::attrib3, \ - &member, cppu::UnoType<decltype(member)>::get() ); - - -#define REGISTER_VOID_PROP_2( prop, memberAny, type, attrib1, attrib2 ) \ - registerMayBeVoidProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::MAYBEVOID | PropertyAttribute::attrib1 | PropertyAttribute::attrib2, \ - &memberAny, cppu::UnoType<type>::get() ); - - } //... namespace frm ....................................................... diff --git a/forms/source/inc/resettable.hxx b/forms/source/inc/resettable.hxx index 2bdb16404b22..cbbc13e50b3f 100644 --- a/forms/source/inc/resettable.hxx +++ b/forms/source/inc/resettable.hxx @@ -21,7 +21,7 @@ #include <com/sun/star/form/XResetListener.hpp> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer3.hxx> namespace cppu { @@ -52,7 +52,7 @@ namespace frm private: ::cppu::OWeakObject& m_rParent; - ::comphelper::OInterfaceContainerHelper2 m_aResetListeners; + ::comphelper::OInterfaceContainerHelper3<css::form::XResetListener> m_aResetListeners; }; diff --git a/forms/source/inc/services.hxx b/forms/source/inc/services.hxx index 01a346e3f55f..acd15cd63672 100644 --- a/forms/source/inc/services.hxx +++ b/forms/source/inc/services.hxx @@ -19,183 +19,177 @@ #pragma once -#define AWT_CONTROL_TEXTFIELD "com.sun.star.awt.TextField" - -#define VCL_CONTROL_EDIT "stardiv.vcl.control.Edit" -#define VCL_CONTROL_LISTBOX "stardiv.vcl.control.ListBox" -#define VCL_CONTROL_COMBOBOX "stardiv.vcl.control.ComboBox" -#define VCL_CONTROL_RADIOBUTTON "stardiv.vcl.control.RadioButton" -#define VCL_CONTROL_GROUPBOX "stardiv.vcl.control.GroupBox" -#define VCL_CONTROL_FIXEDTEXT "stardiv.vcl.control.FixedText" -#define VCL_CONTROL_COMMANDBUTTON "stardiv.vcl.control.Button" -#define VCL_CONTROL_CHECKBOX "stardiv.vcl.control.CheckBox" -#define VCL_CONTROL_IMAGEBUTTON "stardiv.vcl.control.ImageButton" -#define VCL_CONTROL_FILECONTROL "stardiv.vcl.control.FileControl" -#define VCL_CONTROL_TIMEFIELD "stardiv.vcl.control.TimeField" -#define VCL_CONTROL_DATEFIELD "stardiv.vcl.control.DateField" -#define VCL_CONTROL_NUMERICFIELD "stardiv.vcl.control.NumericField" -#define VCL_CONTROL_CURRENCYFIELD "stardiv.vcl.control.CurrencyField" -#define VCL_CONTROL_PATTERNFIELD "stardiv.vcl.control.PatternField" -#define VCL_CONTROL_FORMATTEDFIELD "stardiv.vcl.control.FormattedField" -#define VCL_CONTROL_IMAGECONTROL "stardiv.vcl.control.ImageControl" - -#define VCL_CONTROLMODEL_EDIT "stardiv.vcl.controlmodel.Edit" -#define VCL_CONTROLMODEL_LISTBOX "stardiv.vcl.controlmodel.ListBox" -#define VCL_CONTROLMODEL_COMBOBOX "stardiv.vcl.controlmodel.ComboBox" -#define VCL_CONTROLMODEL_RADIOBUTTON "stardiv.vcl.controlmodel.RadioButton" -#define VCL_CONTROLMODEL_GROUPBOX "stardiv.vcl.controlmodel.GroupBox" -#define VCL_CONTROLMODEL_FIXEDTEXT "stardiv.vcl.controlmodel.FixedText" -#define VCL_CONTROLMODEL_COMMANDBUTTON "stardiv.vcl.controlmodel.Button" -#define VCL_CONTROLMODEL_CHECKBOX "stardiv.vcl.controlmodel.CheckBox" -#define VCL_CONTROLMODEL_IMAGEBUTTON "stardiv.vcl.controlmodel.ImageButton" -#define VCL_CONTROLMODEL_FILECONTROL "stardiv.vcl.controlmodel.FileControl" -#define VCL_CONTROLMODEL_TIMEFIELD "stardiv.vcl.controlmodel.TimeField" -#define VCL_CONTROLMODEL_DATEFIELD "stardiv.vcl.controlmodel.DateField" -#define VCL_CONTROLMODEL_NUMERICFIELD "stardiv.vcl.controlmodel.NumericField" -#define VCL_CONTROLMODEL_CURRENCYFIELD "stardiv.vcl.controlmodel.CurrencyField" -#define VCL_CONTROLMODEL_PATTERNFIELD "stardiv.vcl.controlmodel.PatternField" -#define VCL_CONTROLMODEL_FORMATTEDFIELD "stardiv.vcl.controlmodel.FormattedField" -#define VCL_CONTROLMODEL_IMAGECONTROL "stardiv.vcl.controlmodel.ImageControl" - -#define VCL_CONTROLMODEL_SCROLLBAR "com.sun.star.awt.UnoControlScrollBarModel" -#define VCL_CONTROL_SCROLLBAR "com.sun.star.awt.UnoControlScrollBar" -#define VCL_CONTROLMODEL_SPINBUTTON "com.sun.star.awt.UnoControlSpinButtonModel" -#define VCL_CONTROL_SPINBUTTON "com.sun.star.awt.UnoControlSpinButton" +#include <rtl/ustring.hxx> + +inline constexpr OUString VCL_CONTROL_LISTBOX = u"stardiv.vcl.control.ListBox"_ustr; +inline constexpr OUString VCL_CONTROL_COMBOBOX = u"stardiv.vcl.control.ComboBox"_ustr; +inline constexpr OUString VCL_CONTROL_RADIOBUTTON = u"stardiv.vcl.control.RadioButton"_ustr; +inline constexpr OUString VCL_CONTROL_GROUPBOX = u"stardiv.vcl.control.GroupBox"_ustr; +inline constexpr OUString VCL_CONTROL_COMMANDBUTTON = u"stardiv.vcl.control.Button"_ustr; +inline constexpr OUString VCL_CONTROL_CHECKBOX = u"stardiv.vcl.control.CheckBox"_ustr; +inline constexpr OUString VCL_CONTROL_IMAGEBUTTON = u"stardiv.vcl.control.ImageButton"_ustr; +inline constexpr OUString VCL_CONTROL_TIMEFIELD = u"stardiv.vcl.control.TimeField"_ustr; +inline constexpr OUString VCL_CONTROL_DATEFIELD = u"stardiv.vcl.control.DateField"_ustr; +inline constexpr OUString VCL_CONTROL_NUMERICFIELD = u"stardiv.vcl.control.NumericField"_ustr; +inline constexpr OUString VCL_CONTROL_CURRENCYFIELD = u"stardiv.vcl.control.CurrencyField"_ustr; +inline constexpr OUString VCL_CONTROL_PATTERNFIELD = u"stardiv.vcl.control.PatternField"_ustr; +inline constexpr OUString VCL_CONTROL_FORMATTEDFIELD = u"stardiv.vcl.control.FormattedField"_ustr; +inline constexpr OUString VCL_CONTROL_IMAGECONTROL = u"stardiv.vcl.control.ImageControl"_ustr; + +inline constexpr OUString VCL_CONTROLMODEL_EDIT = u"stardiv.vcl.controlmodel.Edit"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_LISTBOX = u"stardiv.vcl.controlmodel.ListBox"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_COMBOBOX = u"stardiv.vcl.controlmodel.ComboBox"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_RADIOBUTTON = u"stardiv.vcl.controlmodel.RadioButton"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_GROUPBOX = u"stardiv.vcl.controlmodel.GroupBox"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_FIXEDTEXT = u"stardiv.vcl.controlmodel.FixedText"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_COMMANDBUTTON = u"stardiv.vcl.controlmodel.Button"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_CHECKBOX = u"stardiv.vcl.controlmodel.CheckBox"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_IMAGEBUTTON = u"stardiv.vcl.controlmodel.ImageButton"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_FILECONTROL = u"stardiv.vcl.controlmodel.FileControl"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_TIMEFIELD = u"stardiv.vcl.controlmodel.TimeField"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_DATEFIELD = u"stardiv.vcl.controlmodel.DateField"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_NUMERICFIELD = u"stardiv.vcl.controlmodel.NumericField"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_CURRENCYFIELD = u"stardiv.vcl.controlmodel.CurrencyField"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_PATTERNFIELD = u"stardiv.vcl.controlmodel.PatternField"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_FORMATTEDFIELD = u"stardiv.vcl.controlmodel.FormattedField"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_IMAGECONTROL = u"stardiv.vcl.controlmodel.ImageControl"_ustr; + +inline constexpr OUString VCL_CONTROLMODEL_SCROLLBAR = u"com.sun.star.awt.UnoControlScrollBarModel"_ustr; +inline constexpr OUString VCL_CONTROL_SCROLLBAR = u"com.sun.star.awt.UnoControlScrollBar"_ustr; +inline constexpr OUString VCL_CONTROLMODEL_SPINBUTTON = u"com.sun.star.awt.UnoControlSpinButtonModel"_ustr; +inline constexpr OUString VCL_CONTROL_SPINBUTTON = u"com.sun.star.awt.UnoControlSpinButton"_ustr; // service names for compatibility -#define FRM_COMPONENT_FORM "stardiv.one.form.component.Form" -#define FRM_COMPONENT_EDIT "stardiv.one.form.component.Edit" // compatibility -#define FRM_COMPONENT_TEXTFIELD "stardiv.one.form.component.TextField" -#define FRM_COMPONENT_LISTBOX "stardiv.one.form.component.ListBox" -#define FRM_COMPONENT_COMBOBOX "stardiv.one.form.component.ComboBox" -#define FRM_COMPONENT_RADIOBUTTON "stardiv.one.form.component.RadioButton" -#define FRM_COMPONENT_GROUPBOX "stardiv.one.form.component.GroupBox" // compatibility -#define FRM_COMPONENT_FIXEDTEXT "stardiv.one.form.component.FixedText" // compatibility -#define FRM_COMPONENT_COMMANDBUTTON "stardiv.one.form.component.CommandButton" -#define FRM_COMPONENT_CHECKBOX "stardiv.one.form.component.CheckBox" -#define FRM_COMPONENT_GRID "stardiv.one.form.component.Grid" // compatibility -#define FRM_COMPONENT_GRIDCONTROL "stardiv.one.form.component.GridControl" -#define FRM_COMPONENT_IMAGEBUTTON "stardiv.one.form.component.ImageButton" -#define FRM_COMPONENT_FILECONTROL "stardiv.one.form.component.FileControl" -#define FRM_COMPONENT_TIMEFIELD "stardiv.one.form.component.TimeField" -#define FRM_COMPONENT_DATEFIELD "stardiv.one.form.component.DateField" -#define FRM_COMPONENT_NUMERICFIELD "stardiv.one.form.component.NumericField" -#define FRM_COMPONENT_CURRENCYFIELD "stardiv.one.form.component.CurrencyField" -#define FRM_COMPONENT_PATTERNFIELD "stardiv.one.form.component.PatternField" -#define FRM_COMPONENT_HIDDEN "stardiv.one.form.component.Hidden" -#define FRM_COMPONENT_HIDDENCONTROL "stardiv.one.form.component.HiddenControl" -#define FRM_COMPONENT_IMAGECONTROL "stardiv.one.form.component.ImageControl" -#define FRM_COMPONENT_FORMATTEDFIELD "stardiv.one.form.component.FormattedField" +inline constexpr OUString FRM_COMPONENT_FORM = u"stardiv.one.form.component.Form"_ustr; +inline constexpr OUString FRM_COMPONENT_EDIT = u"stardiv.one.form.component.Edit"_ustr; // compatibility +inline constexpr OUString FRM_COMPONENT_TEXTFIELD = u"stardiv.one.form.component.TextField"_ustr; +inline constexpr OUString FRM_COMPONENT_LISTBOX = u"stardiv.one.form.component.ListBox"_ustr; +inline constexpr OUString FRM_COMPONENT_COMBOBOX = u"stardiv.one.form.component.ComboBox"_ustr; +inline constexpr OUString FRM_COMPONENT_RADIOBUTTON = u"stardiv.one.form.component.RadioButton"_ustr; +inline constexpr OUString FRM_COMPONENT_GROUPBOX = u"stardiv.one.form.component.GroupBox"_ustr; // compatibility +inline constexpr OUString FRM_COMPONENT_FIXEDTEXT = u"stardiv.one.form.component.FixedText"_ustr; // compatibility +inline constexpr OUString FRM_COMPONENT_COMMANDBUTTON = u"stardiv.one.form.component.CommandButton"_ustr; +inline constexpr OUString FRM_COMPONENT_CHECKBOX = u"stardiv.one.form.component.CheckBox"_ustr; +inline constexpr OUString FRM_COMPONENT_GRID = u"stardiv.one.form.component.Grid"_ustr; // compatibility +inline constexpr OUString FRM_COMPONENT_GRIDCONTROL = u"stardiv.one.form.component.GridControl"_ustr; +inline constexpr OUString FRM_COMPONENT_IMAGEBUTTON = u"stardiv.one.form.component.ImageButton"_ustr; +inline constexpr OUString FRM_COMPONENT_FILECONTROL = u"stardiv.one.form.component.FileControl"_ustr; +inline constexpr OUString FRM_COMPONENT_TIMEFIELD = u"stardiv.one.form.component.TimeField"_ustr; +inline constexpr OUString FRM_COMPONENT_DATEFIELD = u"stardiv.one.form.component.DateField"_ustr; +inline constexpr OUString FRM_COMPONENT_NUMERICFIELD = u"stardiv.one.form.component.NumericField"_ustr; +inline constexpr OUString FRM_COMPONENT_CURRENCYFIELD = u"stardiv.one.form.component.CurrencyField"_ustr; +inline constexpr OUString FRM_COMPONENT_PATTERNFIELD = u"stardiv.one.form.component.PatternField"_ustr; +inline constexpr OUString FRM_COMPONENT_HIDDEN = u"stardiv.one.form.component.Hidden"_ustr; +inline constexpr OUString FRM_COMPONENT_HIDDENCONTROL = u"stardiv.one.form.component.HiddenControl"_ustr; +inline constexpr OUString FRM_COMPONENT_IMAGECONTROL = u"stardiv.one.form.component.ImageControl"_ustr; +inline constexpr OUString FRM_COMPONENT_FORMATTEDFIELD = u"stardiv.one.form.component.FormattedField"_ustr; // <compatibility_I> -#define STARDIV_ONE_FORM_CONTROL_COMMANDBUTTON "stardiv.one.form.control.CommandButton" -#define STARDIV_ONE_FORM_CONTROL_RADIOBUTTON "stardiv.one.form.control.RadioButton" -#define STARDIV_ONE_FORM_CONTROL_CHECKBOX "stardiv.one.form.control.CheckBox" -#define STARDIV_ONE_FORM_CONTROL_EDIT "stardiv.one.form.control.Edit" -#define STARDIV_ONE_FORM_CONTROL_LISTBOX "stardiv.one.form.control.ListBox" -#define STARDIV_ONE_FORM_CONTROL_COMBOBOX "stardiv.one.form.control.ComboBox" -#define STARDIV_ONE_FORM_CONTROL_GROUPBOX "stardiv.one.form.control.GroupBox" -#define STARDIV_ONE_FORM_CONTROL_TEXTFIELD "stardiv.one.form.control.TextField" -#define STARDIV_ONE_FORM_CONTROL_GRID "stardiv.one.form.control.Grid" -#define STARDIV_ONE_FORM_CONTROL_IMAGEBUTTON "stardiv.one.form.control.ImageButton" -#define STARDIV_ONE_FORM_CONTROL_TIMEFIELD "stardiv.one.form.control.TimeField" -#define STARDIV_ONE_FORM_CONTROL_DATEFIELD "stardiv.one.form.control.DateField" -#define STARDIV_ONE_FORM_CONTROL_NUMERICFIELD "stardiv.one.form.control.NumericField" -#define STARDIV_ONE_FORM_CONTROL_CURRENCYFIELD "stardiv.one.form.control.CurrencyField" -#define STARDIV_ONE_FORM_CONTROL_PATTERNFIELD "stardiv.one.form.control.PatternField" -#define STARDIV_ONE_FORM_CONTROL_IMAGECONTROL "stardiv.one.form.control.ImageControl" -#define STARDIV_ONE_FORM_CONTROL_FORMATTEDFIELD "stardiv.one.form.control.FormattedField" +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_COMMANDBUTTON = u"stardiv.one.form.control.CommandButton"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_RADIOBUTTON = u"stardiv.one.form.control.RadioButton"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_CHECKBOX = u"stardiv.one.form.control.CheckBox"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_EDIT = u"stardiv.one.form.control.Edit"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_LISTBOX = u"stardiv.one.form.control.ListBox"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_COMBOBOX = u"stardiv.one.form.control.ComboBox"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_GROUPBOX = u"stardiv.one.form.control.GroupBox"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_TEXTFIELD = u"stardiv.one.form.control.TextField"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_GRID = u"stardiv.one.form.control.Grid"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_IMAGEBUTTON = u"stardiv.one.form.control.ImageButton"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_TIMEFIELD = u"stardiv.one.form.control.TimeField"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_DATEFIELD = u"stardiv.one.form.control.DateField"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_NUMERICFIELD = u"stardiv.one.form.control.NumericField"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_CURRENCYFIELD = u"stardiv.one.form.control.CurrencyField"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_PATTERNFIELD = u"stardiv.one.form.control.PatternField"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_IMAGECONTROL = u"stardiv.one.form.control.ImageControl"_ustr; +inline constexpr OUString STARDIV_ONE_FORM_CONTROL_FORMATTEDFIELD = u"stardiv.one.form.control.FormattedField"_ustr; // </compatibility_I> // new (sun) service names -#define FRM_SUN_COMPONENT_FORM "com.sun.star.form.component.Form" -#define FRM_SUN_COMPONENT_HTMLFORM "com.sun.star.form.component.HTMLForm" -#define FRM_SUN_COMPONENT_DATAFORM "com.sun.star.form.component.DataForm" -#define FRM_SUN_COMPONENT_TEXTFIELD "com.sun.star.form.component.TextField" -#define FRM_SUN_COMPONENT_LISTBOX "com.sun.star.form.component.ListBox" -#define FRM_SUN_COMPONENT_COMBOBOX "com.sun.star.form.component.ComboBox" -#define FRM_SUN_COMPONENT_RADIOBUTTON "com.sun.star.form.component.RadioButton" -#define FRM_SUN_COMPONENT_GROUPBOX "com.sun.star.form.component.GroupBox" -#define FRM_SUN_COMPONENT_FIXEDTEXT "com.sun.star.form.component.FixedText" -#define FRM_SUN_COMPONENT_COMMANDBUTTON "com.sun.star.form.component.CommandButton" -#define FRM_SUN_COMPONENT_CHECKBOX "com.sun.star.form.component.CheckBox" -#define FRM_SUN_COMPONENT_GRIDCONTROL "com.sun.star.form.component.GridControl" -#define FRM_SUN_COMPONENT_IMAGEBUTTON "com.sun.star.form.component.ImageButton" -#define FRM_SUN_COMPONENT_FILECONTROL "com.sun.star.form.component.FileControl" -#define FRM_SUN_COMPONENT_TIMEFIELD "com.sun.star.form.component.TimeField" -#define FRM_SUN_COMPONENT_DATEFIELD "com.sun.star.form.component.DateField" -#define FRM_SUN_COMPONENT_NUMERICFIELD "com.sun.star.form.component.NumericField" -#define FRM_SUN_COMPONENT_CURRENCYFIELD "com.sun.star.form.component.CurrencyField" -#define FRM_SUN_COMPONENT_PATTERNFIELD "com.sun.star.form.component.PatternField" -#define FRM_SUN_COMPONENT_HIDDENCONTROL "com.sun.star.form.component.HiddenControl" -#define FRM_SUN_COMPONENT_FORMATTEDFIELD "com.sun.star.form.component.FormattedField" -#define FRM_SUN_COMPONENT_SCROLLBAR "com.sun.star.form.component.ScrollBar" -#define FRM_SUN_COMPONENT_SPINBUTTON "com.sun.star.form.component.SpinButton" -#define FRM_SUN_COMPONENT_RICHTEXTCONTROL "com.sun.star.form.component.RichTextControl" -#define FRM_SUN_COMPONENT_NAVTOOLBAR "com.sun.star.form.component.NavigationToolBar" -#define FRM_SUN_COMPONENT_SUBMITBUTTON "com.sun.star.form.component.SubmitButton" - -#define FRM_SUN_COMPONENT_IMAGECONTROL "com.sun.star.form.component.DatabaseImageControl" -#define FRM_SUN_COMPONENT_DATABASE_RADIOBUTTON "com.sun.star.form.component.DatabaseRadioButton" -#define FRM_SUN_COMPONENT_DATABASE_CHECKBOX "com.sun.star.form.component.DatabaseCheckBox" -#define FRM_SUN_COMPONENT_DATABASE_LISTBOX "com.sun.star.form.component.DatabaseListBox" -#define FRM_SUN_COMPONENT_DATABASE_COMBOBOX "com.sun.star.form.component.DatabaseComboBox" -#define FRM_SUN_COMPONENT_DATABASE_FORMATTEDFIELD "com.sun.star.form.component.DatabaseFormattedField" -#define FRM_SUN_COMPONENT_DATABASE_TEXTFIELD "com.sun.star.form.component.DatabaseTextField" -#define FRM_SUN_COMPONENT_DATABASE_DATEFIELD "com.sun.star.form.component.DatabaseDateField" -#define FRM_SUN_COMPONENT_DATABASE_TIMEFIELD "com.sun.star.form.component.DatabaseTimeField" -#define FRM_SUN_COMPONENT_DATABASE_NUMERICFIELD "com.sun.star.form.component.DatabaseNumericField" -#define FRM_SUN_COMPONENT_DATABASE_CURRENCYFIELD "com.sun.star.form.component.DatabaseCurrencyField" -#define FRM_SUN_COMPONENT_DATABASE_PATTERNFIELD "com.sun.star.form.component.DatabasePatternField" - -#define FRM_SUN_CONTROL_TEXTFIELD "com.sun.star.form.control.TextField" -#define FRM_SUN_CONTROL_LISTBOX "com.sun.star.form.control.ListBox" -#define FRM_SUN_CONTROL_COMBOBOX "com.sun.star.form.control.ComboBox" -#define FRM_SUN_CONTROL_RADIOBUTTON "com.sun.star.form.control.RadioButton" -#define FRM_SUN_CONTROL_GROUPBOX "com.sun.star.form.control.GroupBox" -#define FRM_SUN_CONTROL_FIXEDTEXT "com.sun.star.form.control.FixedText" -#define FRM_SUN_CONTROL_COMMANDBUTTON "com.sun.star.form.control.CommandButton" -#define FRM_SUN_CONTROL_CHECKBOX "com.sun.star.form.control.CheckBox" -#define FRM_SUN_CONTROL_GRIDCONTROL "com.sun.star.form.control.GridControl" -#define FRM_SUN_CONTROL_IMAGEBUTTON "com.sun.star.form.control.ImageButton" -#define FRM_SUN_CONTROL_TIMEFIELD "com.sun.star.form.control.TimeField" -#define FRM_SUN_CONTROL_DATEFIELD "com.sun.star.form.control.DateField" -#define FRM_SUN_CONTROL_NUMERICFIELD "com.sun.star.form.control.NumericField" -#define FRM_SUN_CONTROL_CURRENCYFIELD "com.sun.star.form.control.CurrencyField" -#define FRM_SUN_CONTROL_PATTERNFIELD "com.sun.star.form.control.PatternField" -#define FRM_SUN_CONTROL_IMAGECONTROL "com.sun.star.form.control.ImageControl" -#define FRM_SUN_CONTROL_FORMATTEDFIELD "com.sun.star.form.control.FormattedField" -#define FRM_SUN_CONTROL_RICHTEXTCONTROL "com.sun.star.form.control.RichTextControl" -#define FRM_SUN_CONTROL_SUBMITBUTTON "com.sun.star.form.control.SubmitButton" - -#define BINDABLE_DATABASE_CHECK_BOX "com.sun.star.form.binding.BindableDatabaseCheckBox" -#define BINDABLE_DATABASE_COMBO_BOX "com.sun.star.form.binding.BindableDatabaseComboBox" -#define BINDABLE_DATABASE_FORMATTED_FIELD "com.sun.star.form.binding.BindableDatabaseFormattedField" -#define BINDABLE_DATABASE_LIST_BOX "com.sun.star.form.binding.BindableDatabaseListBox" -#define BINDABLE_DATABASE_NUMERIC_FIELD "com.sun.star.form.binding.BindableDatabaseNumericField" -#define BINDABLE_DATABASE_RADIO_BUTTON "com.sun.star.form.binding.BindableDatabaseRadioButton" -#define BINDABLE_DATABASE_TEXT_FIELD "com.sun.star.form.binding.BindableDatabaseTextField" -#define BINDABLE_DATABASE_DATE_FIELD "com.sun.star.form.binding.BindableDatabaseDateField" -#define BINDABLE_DATABASE_TIME_FIELD "com.sun.star.form.binding.BindableDatabaseTimeField" - -#define BINDABLE_CONTROL_MODEL "com.sun.star.form.binding.BindableControlModel" -#define BINDABLE_INTEGER_VALUE_RANGE "com.sun.star.form.binding.BindableIntegerValueRange" -#define BINDABLE_DATA_AWARE_CONTROL_MODEL "com.sun.star.form.binding.BindableDataAwareControlModel" -#define DATA_AWARE_CONTROL_MODEL "com.sun.star.form.binding.DataAwareControlModel" -#define VALIDATABLE_CONTROL_MODEL "com.sun.star.form.binding.ValidatableControlModel" -#define VALIDATABLE_BINDABLE_CONTROL_MODEL "com.sun.star.form.binding.ValidatableBindableControlModel" +inline constexpr OUString FRM_SUN_COMPONENT_FORM = u"com.sun.star.form.component.Form"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_HTMLFORM = u"com.sun.star.form.component.HTMLForm"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_DATAFORM = u"com.sun.star.form.component.DataForm"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_TEXTFIELD = u"com.sun.star.form.component.TextField"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_LISTBOX = u"com.sun.star.form.component.ListBox"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_COMBOBOX = u"com.sun.star.form.component.ComboBox"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_RADIOBUTTON = u"com.sun.star.form.component.RadioButton"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_GROUPBOX = u"com.sun.star.form.component.GroupBox"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_FIXEDTEXT = u"com.sun.star.form.component.FixedText"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_COMMANDBUTTON = u"com.sun.star.form.component.CommandButton"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_CHECKBOX = u"com.sun.star.form.component.CheckBox"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_GRIDCONTROL = u"com.sun.star.form.component.GridControl"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_IMAGEBUTTON = u"com.sun.star.form.component.ImageButton"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_FILECONTROL = u"com.sun.star.form.component.FileControl"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_TIMEFIELD = u"com.sun.star.form.component.TimeField"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_DATEFIELD = u"com.sun.star.form.component.DateField"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_NUMERICFIELD = u"com.sun.star.form.component.NumericField"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_CURRENCYFIELD = u"com.sun.star.form.component.CurrencyField"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_PATTERNFIELD = u"com.sun.star.form.component.PatternField"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_HIDDENCONTROL = u"com.sun.star.form.component.HiddenControl"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_FORMATTEDFIELD = u"com.sun.star.form.component.FormattedField"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_SCROLLBAR = u"com.sun.star.form.component.ScrollBar"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_SPINBUTTON = u"com.sun.star.form.component.SpinButton"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_RICHTEXTCONTROL = u"com.sun.star.form.component.RichTextControl"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_NAVTOOLBAR = u"com.sun.star.form.component.NavigationToolBar"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_SUBMITBUTTON = u"com.sun.star.form.component.SubmitButton"_ustr; + +inline constexpr OUString FRM_SUN_COMPONENT_IMAGECONTROL = u"com.sun.star.form.component.DatabaseImageControl"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_DATABASE_RADIOBUTTON = u"com.sun.star.form.component.DatabaseRadioButton"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_DATABASE_CHECKBOX = u"com.sun.star.form.component.DatabaseCheckBox"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_DATABASE_LISTBOX = u"com.sun.star.form.component.DatabaseListBox"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_DATABASE_COMBOBOX = u"com.sun.star.form.component.DatabaseComboBox"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_DATABASE_FORMATTEDFIELD = u"com.sun.star.form.component.DatabaseFormattedField"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_DATABASE_TEXTFIELD = u"com.sun.star.form.component.DatabaseTextField"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_DATABASE_DATEFIELD = u"com.sun.star.form.component.DatabaseDateField"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_DATABASE_TIMEFIELD = u"com.sun.star.form.component.DatabaseTimeField"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_DATABASE_NUMERICFIELD = u"com.sun.star.form.component.DatabaseNumericField"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_DATABASE_CURRENCYFIELD = u"com.sun.star.form.component.DatabaseCurrencyField"_ustr; +inline constexpr OUString FRM_SUN_COMPONENT_DATABASE_PATTERNFIELD = u"com.sun.star.form.component.DatabasePatternField"_ustr; + +inline constexpr OUString FRM_SUN_CONTROL_TEXTFIELD = u"com.sun.star.form.control.TextField"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_LISTBOX = u"com.sun.star.form.control.ListBox"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_COMBOBOX = u"com.sun.star.form.control.ComboBox"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_RADIOBUTTON = u"com.sun.star.form.control.RadioButton"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_GROUPBOX = u"com.sun.star.form.control.GroupBox"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_COMMANDBUTTON = u"com.sun.star.form.control.CommandButton"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_CHECKBOX = u"com.sun.star.form.control.CheckBox"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_GRIDCONTROL = u"com.sun.star.form.control.GridControl"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_IMAGEBUTTON = u"com.sun.star.form.control.ImageButton"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_TIMEFIELD = u"com.sun.star.form.control.TimeField"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_DATEFIELD = u"com.sun.star.form.control.DateField"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_NUMERICFIELD = u"com.sun.star.form.control.NumericField"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_CURRENCYFIELD = u"com.sun.star.form.control.CurrencyField"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_PATTERNFIELD = u"com.sun.star.form.control.PatternField"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_IMAGECONTROL = u"com.sun.star.form.control.ImageControl"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_FORMATTEDFIELD = u"com.sun.star.form.control.FormattedField"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_RICHTEXTCONTROL = u"com.sun.star.form.control.RichTextControl"_ustr; +inline constexpr OUString FRM_SUN_CONTROL_SUBMITBUTTON = u"com.sun.star.form.control.SubmitButton"_ustr; + +inline constexpr OUString BINDABLE_DATABASE_CHECK_BOX = u"com.sun.star.form.binding.BindableDatabaseCheckBox"_ustr; +inline constexpr OUString BINDABLE_DATABASE_COMBO_BOX = u"com.sun.star.form.binding.BindableDatabaseComboBox"_ustr; +inline constexpr OUString BINDABLE_DATABASE_FORMATTED_FIELD = u"com.sun.star.form.binding.BindableDatabaseFormattedField"_ustr; +inline constexpr OUString BINDABLE_DATABASE_LIST_BOX = u"com.sun.star.form.binding.BindableDatabaseListBox"_ustr; +inline constexpr OUString BINDABLE_DATABASE_NUMERIC_FIELD = u"com.sun.star.form.binding.BindableDatabaseNumericField"_ustr; +inline constexpr OUString BINDABLE_DATABASE_RADIO_BUTTON = u"com.sun.star.form.binding.BindableDatabaseRadioButton"_ustr; +inline constexpr OUString BINDABLE_DATABASE_TEXT_FIELD = u"com.sun.star.form.binding.BindableDatabaseTextField"_ustr; +inline constexpr OUString BINDABLE_DATABASE_DATE_FIELD = u"com.sun.star.form.binding.BindableDatabaseDateField"_ustr; +inline constexpr OUString BINDABLE_DATABASE_TIME_FIELD = u"com.sun.star.form.binding.BindableDatabaseTimeField"_ustr; + +inline constexpr OUString BINDABLE_CONTROL_MODEL = u"com.sun.star.form.binding.BindableControlModel"_ustr; +inline constexpr OUString BINDABLE_INTEGER_VALUE_RANGE = u"com.sun.star.form.binding.BindableIntegerValueRange"_ustr; +inline constexpr OUString BINDABLE_DATA_AWARE_CONTROL_MODEL = u"com.sun.star.form.binding.BindableDataAwareControlModel"_ustr; +inline constexpr OUString DATA_AWARE_CONTROL_MODEL = u"com.sun.star.form.binding.DataAwareControlModel"_ustr; +inline constexpr OUString VALIDATABLE_CONTROL_MODEL = u"com.sun.star.form.binding.ValidatableControlModel"_ustr; +inline constexpr OUString VALIDATABLE_BINDABLE_CONTROL_MODEL = u"com.sun.star.form.binding.ValidatableBindableControlModel"_ustr; // common -#define FRM_SUN_FORMCOMPONENT "com.sun.star.form.FormComponent" +inline constexpr OUString FRM_SUN_FORMCOMPONENT = u"com.sun.star.form.FormComponent"_ustr; // misc -#define SRV_AWT_IMAGEPRODUCER "com.sun.star.awt.ImageProducer" - -#define SRV_SDB_ROWSET "com.sun.star.sdb.RowSet" -#define SRV_SDB_CONNECTION "com.sun.star.sdb.Connection" +inline constexpr OUString SRV_SDB_ROWSET = u"com.sun.star.sdb.RowSet"_ustr; +inline constexpr OUString SRV_SDB_CONNECTION = u"com.sun.star.sdb.Connection"_ustr; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/urltransformer.hxx b/forms/source/inc/urltransformer.hxx index e11661176b92..3cfe225945bb 100644 --- a/forms/source/inc/urltransformer.hxx +++ b/forms/source/inc/urltransformer.hxx @@ -49,10 +49,10 @@ namespace frm css::util::URL getStrictURLFromAscii( const char* _pAsciiURL ) const; - /** parses a given URL smartly, with a protocol given by ASCII string + /** parses a given URL smartly, with a given protocol */ void - parseSmartWithAsciiProtocol( css::util::URL& _rURL, const char* _pAsciiURL ) const; + parseSmartWithProtocol( css::util::URL& _rURL, const OUString& _rProtocol ) const; private: /** ensures that we have a URLTransformer instance in <member>m_xTransformer</member> diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx index 61d1265aa4be..90a918f5edcd 100644 --- a/forms/source/misc/InterfaceContainer.cxx +++ b/forms/source/misc/InterfaceContainer.cxx @@ -43,8 +43,9 @@ #include <comphelper/sequence.hxx> #include <comphelper/types.hxx> #include <cppuhelper/exc_hlp.hxx> +#include <o3tl/safeint.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> #include <algorithm> @@ -70,15 +71,6 @@ using namespace ::com::sun::star::io; using namespace ::com::sun::star::form; using namespace ::com::sun::star::util; -namespace -{ - - void lcl_throwIllegalArgumentException() - { - throw IllegalArgumentException(); - } -} - static bool lcl_hasVbaEvents( const Sequence< ScriptEventDescriptor >& sEvents ) { @@ -203,7 +195,7 @@ void OInterfaceContainer::clonedFrom(const OInterfaceContainer& _cloneSource) { Reference< XCloneable > xCloneable( xSourceHierarchy->getByIndex( i ), UNO_QUERY_THROW ); Reference< XInterface > xClone( xCloneable->createClone() ); - insertByIndex( i, makeAny( xClone ) ); + insertByIndex( i, Any( xClone ) ); } } catch (const RuntimeException&) @@ -437,7 +429,7 @@ void SAL_CALL OInterfaceContainer::readEvents(const Reference<XObjectInputStream { Reference< XInterface > xAsIFace( item, UNO_QUERY ); // important to normalize this... Reference< XPropertySet > xAsSet( xAsIFace, UNO_QUERY ); - m_xEventAttacher->attach( i++, xAsIFace, makeAny( xAsSet ) ); + m_xEventAttacher->attach( i++, xAsIFace, Any( xAsSet ) ); } } } @@ -488,8 +480,8 @@ namespace { try { - xObjProps->setPropertyValue( PROPERTY_NAME, makeAny( FRM_RES_STRING( RID_STR_CONTROL_SUBSTITUTED_NAME ) ) ); - xObjProps->setPropertyValue( PROPERTY_TAG, makeAny( FRM_RES_STRING( RID_STR_CONTROL_SUBSTITUTED_EPXPLAIN ) ) ); + xObjProps->setPropertyValue( PROPERTY_NAME, Any( ResourceManager::loadString(RID_STR_CONTROL_SUBSTITUTED_NAME) ) ); + xObjProps->setPropertyValue( PROPERTY_TAG, Any( ResourceManager::loadString(RID_STR_CONTROL_SUBSTITUTED_EPXPLAIN) ) ); } catch(const Exception&) { @@ -560,7 +552,7 @@ void SAL_CALL OInterfaceContainer::read( const Reference< XObjectInputStream >& } catch( const Exception& ) { - SAL_WARN("forms.misc", "OInterfaceContainerHelper2::read: reading succeeded, but not inserting!" ); + SAL_WARN("forms.misc", "OInterfaceContainerHelper3::read: reading succeeded, but not inserting!" ); // create a placeholder xElement.set(lcl_createPlaceHolder( m_xContext ), css::uno::UNO_QUERY); if ( !xElement.is() ) @@ -722,7 +714,7 @@ sal_Int32 OInterfaceContainer::getCount() Any OInterfaceContainer::getByIndex(sal_Int32 _nIndex) { - if (_nIndex < 0 || (_nIndex >= static_cast<sal_Int32>(m_aItems.size()))) + if (_nIndex < 0 || (o3tl::make_unsigned(_nIndex) >= m_aItems.size())) throw IndexOutOfBoundsException(); return m_aItems[_nIndex]->queryInterface( m_aElementType ); @@ -733,22 +725,22 @@ void OInterfaceContainer::approveNewElement( const Reference< XPropertySet >& _r { // it has to be non-NULL if ( !_rxObject.is() ) - throw IllegalArgumentException(FRM_RES_STRING(RID_STR_NEED_NON_NULL_OBJECT), static_cast<XContainer*>(this), 1); + throw IllegalArgumentException(ResourceManager::loadString(RID_STR_NEED_NON_NULL_OBJECT), static_cast<XContainer*>(this), 1); // it has to support our element type interface Any aCorrectType = _rxObject->queryInterface( m_aElementType ); if ( !aCorrectType.hasValue() ) - lcl_throwIllegalArgumentException(); + throw IllegalArgumentException(); // it has to have a "Name" property if ( !hasProperty( PROPERTY_NAME, _rxObject ) ) - lcl_throwIllegalArgumentException(); + throw IllegalArgumentException(); // it has to be a child, and it must not have a parent already Reference< XChild > xChild( _rxObject, UNO_QUERY ); if ( !xChild.is() || xChild->getParent().is() ) { - lcl_throwIllegalArgumentException(); + throw IllegalArgumentException(); } // passed all tests. cache the information we have so far @@ -812,7 +804,7 @@ void OInterfaceContainer::implInsert(sal_Int32 _nIndex, const Reference< XProper if ( bHandleEvents ) { m_xEventAttacher->insertEntry(_nIndex); - m_xEventAttacher->attach( _nIndex, pElementMetaData->xInterface, makeAny( _rxElement ) ); + m_xEventAttacher->attach( _nIndex, pElementMetaData->xInterface, Any( _rxElement ) ); } // notify derived classes @@ -915,7 +907,7 @@ void SAL_CALL OInterfaceContainer::insertByIndex( sal_Int32 _nIndex, const Any& void OInterfaceContainer::implReplaceByIndex( const sal_Int32 _nIndex, const Any& _rNewElement, ::osl::ClearableMutexGuard& _rClearBeforeNotify ) { - OSL_PRECOND( ( _nIndex >= 0 ) && ( _nIndex < static_cast<sal_Int32>(m_aItems.size()) ), "OInterfaceContainer::implReplaceByIndex: precondition not met (index)!" ); + OSL_PRECOND( ( _nIndex >= 0 ) && ( o3tl::make_unsigned(_nIndex) < m_aItems.size() ), "OInterfaceContainer::implReplaceByIndex: precondition not met (index)!" ); // approve the new object std::unique_ptr< ElementDescription > aElementMetaData( createElementMetaData() ); @@ -976,7 +968,7 @@ void OInterfaceContainer::implReplaceByIndex( const sal_Int32 _nIndex, const Any { m_xEventAttacher->insertEntry( _nIndex ); m_xEventAttacher->attach(_nIndex, aElementMetaData->xInterface, - makeAny(aElementMetaData->xPropertySet)); + Any(aElementMetaData->xPropertySet)); } ContainerEvent aReplaceEvent; @@ -991,7 +983,7 @@ void OInterfaceContainer::implReplaceByIndex( const sal_Int32 _nIndex, const Any void OInterfaceContainer::implCheckIndex( const sal_Int32 _nIndex ) { - if (_nIndex < 0 || _nIndex >= static_cast<sal_Int32>(m_aItems.size())) + if (_nIndex < 0 || o3tl::make_unsigned(_nIndex) >= m_aItems.size()) throw IndexOutOfBoundsException(); } @@ -1008,7 +1000,7 @@ void SAL_CALL OInterfaceContainer::replaceByIndex(sal_Int32 _nIndex, const Any& void OInterfaceContainer::implRemoveByIndex( const sal_Int32 _nIndex, ::osl::ClearableMutexGuard& _rClearBeforeNotify ) { - OSL_PRECOND( ( _nIndex >= 0 ) && ( _nIndex < static_cast<sal_Int32>(m_aItems.size()) ), "OInterfaceContainer::implRemoveByIndex: precondition not met (index)!" ); + OSL_PRECOND( ( _nIndex >= 0 ) && ( o3tl::make_unsigned(_nIndex) < m_aItems.size() ), "OInterfaceContainer::implRemoveByIndex: precondition not met (index)!" ); OInterfaceArray::iterator i = m_aItems.begin() + _nIndex; css::uno::Reference<css::uno::XInterface> xElement(*i); @@ -1079,7 +1071,7 @@ void SAL_CALL OInterfaceContainer::insertByName(const OUString& _rName, const An _rElement >>= xElementProps; approveNewElement( xElementProps, aElementMetaData.get() ); - xElementProps->setPropertyValue( PROPERTY_NAME, makeAny( _rName ) ); + xElementProps->setPropertyValue( PROPERTY_NAME, Any( _rName ) ); } catch( const IllegalArgumentException& ) { @@ -1106,16 +1098,16 @@ void SAL_CALL OInterfaceContainer::replaceByName(const OUString& Name, const Any throw NoSuchElementException(); if (Element.getValueType().getTypeClass() != TypeClass_INTERFACE) - lcl_throwIllegalArgumentException(); + throw IllegalArgumentException(); Reference<XPropertySet> xSet; Element >>= xSet; if (xSet.is()) { if (!hasProperty(PROPERTY_NAME, xSet)) - lcl_throwIllegalArgumentException(); + throw IllegalArgumentException(); - xSet->setPropertyValue(PROPERTY_NAME, makeAny(Name)); + xSet->setPropertyValue(PROPERTY_NAME, Any(Name)); } // determine the element pos diff --git a/forms/source/misc/limitedformats.cxx b/forms/source/misc/limitedformats.cxx index f49b8617ff2c..b7a0d5abcbd6 100644 --- a/forms/source/misc/limitedformats.cxx +++ b/forms/source/misc/limitedformats.cxx @@ -271,70 +271,68 @@ namespace frm { OSL_ENSURE(m_xAggregate.is() && (-1 != m_nFormatEnumPropertyHandle), "OLimitedFormats::convertFormatKeyPropertyValue: not initialized!"); - if (m_xAggregate.is()) + if (!m_xAggregate) + return false; + + // the new format key to set + sal_Int32 nNewFormat = 0; + if (!(_rNewValue >>= nNewFormat)) + throw IllegalArgumentException(); + + // get the old (enum) value from the aggregate + Any aEnumPropertyValue = m_xAggregate->getFastPropertyValue(m_nFormatEnumPropertyHandle); + sal_Int32 nOldEnumValue = -1; + ::cppu::enum2int(nOldEnumValue, aEnumPropertyValue); + + // get the translation table + const FormatEntry* pFormats = lcl_getFormatTable(m_nTableId); + + _rOldValue.clear(); + _rConvertedValue.clear(); + + // look for the entry with the given format key + sal_Int32 nTablePosition = 0; + for ( ; + (nullptr != pFormats->pDescription) && (nNewFormat != pFormats->nKey); + ++pFormats, ++nTablePosition + ) { - // the new format key to set - sal_Int32 nNewFormat = 0; - if (!(_rNewValue >>= nNewFormat)) - throw IllegalArgumentException(); - - // get the old (enum) value from the aggregate - Any aEnumPropertyValue = m_xAggregate->getFastPropertyValue(m_nFormatEnumPropertyHandle); - sal_Int32 nOldEnumValue = -1; - ::cppu::enum2int(nOldEnumValue, aEnumPropertyValue); - - // get the translation table - const FormatEntry* pFormats = lcl_getFormatTable(m_nTableId); - - _rOldValue.clear(); - _rConvertedValue.clear(); - - // look for the entry with the given format key - sal_Int32 nTablePosition = 0; - for ( ; - (nullptr != pFormats->pDescription) && (nNewFormat != pFormats->nKey); - ++pFormats, ++nTablePosition - ) - { - if (nTablePosition == nOldEnumValue) - _rOldValue <<= pFormats->nKey; - } + if (nTablePosition == nOldEnumValue) + _rOldValue <<= pFormats->nKey; + } - bool bFoundIt = (nullptr != pFormats->pDescription); - bool bModified = false; - if (bFoundIt) - { - _rConvertedValue <<= static_cast<sal_Int16>(nTablePosition); - bModified = nTablePosition != nOldEnumValue; - } + bool bFoundIt = (nullptr != pFormats->pDescription); + bool bModified = false; + if (bFoundIt) + { + _rConvertedValue <<= static_cast<sal_Int16>(nTablePosition); + bModified = nTablePosition != nOldEnumValue; + } - if (!_rOldValue.hasValue()) - { // did not reach the end of the table (means we found nNewFormat) - // -> go to the end to ensure that _rOldValue is set - while (pFormats->pDescription) + if (!_rOldValue.hasValue()) + { // did not reach the end of the table (means we found nNewFormat) + // -> go to the end to ensure that _rOldValue is set + while (pFormats->pDescription) + { + if (nTablePosition == nOldEnumValue) { - if (nTablePosition == nOldEnumValue) - { - _rOldValue <<= pFormats->nKey; - break; - } - - ++pFormats; - ++nTablePosition; + _rOldValue <<= pFormats->nKey; + break; } - } - OSL_ENSURE(_rOldValue.hasValue(), "OLimitedFormats::convertFormatKeyPropertyValue: did not find the old enum value in the table!"); - - if (!bFoundIt) - { // somebody gave us a format which we can't translate - throw IllegalArgumentException("This control supports only a very limited number of formats.", nullptr, 2); + ++pFormats; + ++nTablePosition; } + } + + OSL_ENSURE(_rOldValue.hasValue(), "OLimitedFormats::convertFormatKeyPropertyValue: did not find the old enum value in the table!"); - return bModified; + if (!bFoundIt) + { // somebody gave us a format which we can't translate + throw IllegalArgumentException("This control supports only a very limited number of formats.", nullptr, 2); } - return false; + return bModified; } diff --git a/forms/source/misc/listenercontainers.cxx b/forms/source/misc/listenercontainers.cxx deleted file mode 100644 index 13adf3e612ad..000000000000 --- a/forms/source/misc/listenercontainers.cxx +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <listenercontainers.hxx> -#include <osl/diagnose.h> - - -namespace frm -{ - - - using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::lang; - using namespace ::com::sun::star::form; - - - //= ResetListeners - - - bool ResetListeners::implTypedNotify( const Reference< XResetListener >& _rxListener, - const EventObject& _rEvent ) - { - switch ( m_eCurrentNotificationType ) - { - case eApproval: - if ( !_rxListener->approveReset( _rEvent ) ) - return false; - return true; - case eFinal: - _rxListener->resetted( _rEvent ); - break; - default: - OSL_FAIL( "ResetListeners::implNotify: invalid notification type!" ); - } - return true; - } - - -} // namespace frm - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/misc/property.cxx b/forms/source/misc/property.cxx index 11c3ad7d2022..6200b343865d 100644 --- a/forms/source/misc/property.cxx +++ b/forms/source/misc/property.cxx @@ -45,174 +45,171 @@ sal_Int32 ConcreteInfoService::getPreferredPropertyId(const OUString& _rName) } -#define EXPAND_PROP_INIT(varname) \ - { PROPERTY_##varname, PROPERTY_ID_##varname } - void PropertyInfoService::initialize() { if (!s_AllKnownProperties.empty()) return; s_AllKnownProperties.insert({ - EXPAND_PROP_INIT(NAME), - EXPAND_PROP_INIT(TAG), - EXPAND_PROP_INIT(TABINDEX), - EXPAND_PROP_INIT(CLASSID), - EXPAND_PROP_INIT(ALIGN), - EXPAND_PROP_INIT(FETCHSIZE), - EXPAND_PROP_INIT(VALUE), - EXPAND_PROP_INIT(VALUEMIN), - EXPAND_PROP_INIT(VALUEMAX), - EXPAND_PROP_INIT(VALUESTEP), - EXPAND_PROP_INIT(TEXT), - EXPAND_PROP_INIT(LABEL), - EXPAND_PROP_INIT(NAVIGATION), - EXPAND_PROP_INIT(CYCLE), - EXPAND_PROP_INIT(CONTROLSOURCE), - EXPAND_PROP_INIT(ENABLED), - EXPAND_PROP_INIT(ENABLEVISIBLE), - EXPAND_PROP_INIT(SPIN), - EXPAND_PROP_INIT(READONLY), - EXPAND_PROP_INIT(FILTER), - EXPAND_PROP_INIT(WIDTH), - EXPAND_PROP_INIT(SEARCHABLE), - EXPAND_PROP_INIT(MULTILINE), - EXPAND_PROP_INIT(TARGET_URL), - EXPAND_PROP_INIT(DEFAULTCONTROL), - EXPAND_PROP_INIT(MAXTEXTLEN), - EXPAND_PROP_INIT(SIZE), - EXPAND_PROP_INIT(DATE), - EXPAND_PROP_INIT(TIME), - EXPAND_PROP_INIT(STATE), - EXPAND_PROP_INIT(TRISTATE), - EXPAND_PROP_INIT(HIDDEN_VALUE), - EXPAND_PROP_INIT(TARGET_FRAME), - EXPAND_PROP_INIT(BUTTONTYPE), - EXPAND_PROP_INIT(STRINGITEMLIST), - EXPAND_PROP_INIT(TYPEDITEMLIST), - EXPAND_PROP_INIT(DEFAULT_TEXT), - EXPAND_PROP_INIT(DEFAULT_STATE), - EXPAND_PROP_INIT(DEFAULT_DATE), - EXPAND_PROP_INIT(DEFAULT_TIME), - EXPAND_PROP_INIT(DEFAULT_VALUE), - EXPAND_PROP_INIT(FORMATKEY), - EXPAND_PROP_INIT(FORMATSSUPPLIER), - EXPAND_PROP_INIT(SUBMIT_ACTION), - EXPAND_PROP_INIT(SUBMIT_TARGET), - EXPAND_PROP_INIT(SUBMIT_METHOD), - EXPAND_PROP_INIT(SUBMIT_ENCODING), - EXPAND_PROP_INIT(IMAGE_URL), - EXPAND_PROP_INIT(GRAPHIC), - EXPAND_PROP_INIT(EMPTY_IS_NULL), - EXPAND_PROP_INIT(LISTSOURCETYPE), - EXPAND_PROP_INIT(LISTSOURCE), - EXPAND_PROP_INIT(SELECT_SEQ), - EXPAND_PROP_INIT(VALUE_SEQ), - EXPAND_PROP_INIT(SELECT_VALUE), - EXPAND_PROP_INIT(SELECT_VALUE_SEQ), - EXPAND_PROP_INIT(DEFAULT_SELECT_SEQ), - EXPAND_PROP_INIT(MULTISELECTION), - EXPAND_PROP_INIT(DECIMAL_ACCURACY), - EXPAND_PROP_INIT(EDITMASK), - EXPAND_PROP_INIT(ISREADONLY), - EXPAND_PROP_INIT(FIELDTYPE), - EXPAND_PROP_INIT(DECIMALS), - EXPAND_PROP_INIT(REFVALUE), - EXPAND_PROP_INIT(STRICTFORMAT), - EXPAND_PROP_INIT(DATASOURCE), - EXPAND_PROP_INIT(ALLOWADDITIONS), - EXPAND_PROP_INIT(ALLOWEDITS), - EXPAND_PROP_INIT(ALLOWDELETIONS), - EXPAND_PROP_INIT(MASTERFIELDS), - EXPAND_PROP_INIT(ISPASSTHROUGH), - EXPAND_PROP_INIT(QUERY), - EXPAND_PROP_INIT(LITERALMASK), - EXPAND_PROP_INIT(SHOWTHOUSANDSEP), - EXPAND_PROP_INIT(CURRENCYSYMBOL), - EXPAND_PROP_INIT(DATEFORMAT), - EXPAND_PROP_INIT(DATEMIN), - EXPAND_PROP_INIT(DATEMAX), - EXPAND_PROP_INIT(DATE_SHOW_CENTURY), - EXPAND_PROP_INIT(TIMEFORMAT), - EXPAND_PROP_INIT(TIMEMIN), - EXPAND_PROP_INIT(TIMEMAX), - EXPAND_PROP_INIT(LINECOUNT), - EXPAND_PROP_INIT(BOUNDCOLUMN), - EXPAND_PROP_INIT(HASNAVIGATION), - EXPAND_PROP_INIT(FONT), - EXPAND_PROP_INIT(BACKGROUNDCOLOR), - EXPAND_PROP_INIT(FILLCOLOR), - EXPAND_PROP_INIT(TEXTCOLOR), - EXPAND_PROP_INIT(LINECOLOR), - EXPAND_PROP_INIT(BORDER), - EXPAND_PROP_INIT(DROPDOWN), - EXPAND_PROP_INIT(HSCROLL), - EXPAND_PROP_INIT(VSCROLL), - EXPAND_PROP_INIT(TABSTOP), - EXPAND_PROP_INIT(AUTOCOMPLETE), - EXPAND_PROP_INIT(HARDLINEBREAKS), - EXPAND_PROP_INIT(PRINTABLE), - EXPAND_PROP_INIT(ECHO_CHAR), - EXPAND_PROP_INIT(ROWHEIGHT), - EXPAND_PROP_INIT(HELPTEXT), - EXPAND_PROP_INIT(FONT_NAME), - EXPAND_PROP_INIT(FONT_STYLENAME), - EXPAND_PROP_INIT(FONT_FAMILY), - EXPAND_PROP_INIT(FONT_CHARSET), - EXPAND_PROP_INIT(FONT_HEIGHT), - EXPAND_PROP_INIT(FONT_WEIGHT), - EXPAND_PROP_INIT(FONT_SLANT), - EXPAND_PROP_INIT(FONT_UNDERLINE), - EXPAND_PROP_INIT(FONT_WORDLINEMODE), - EXPAND_PROP_INIT(FONT_STRIKEOUT), - EXPAND_PROP_INIT(TEXTLINECOLOR), - EXPAND_PROP_INIT(FONTEMPHASISMARK), - EXPAND_PROP_INIT(FONTRELIEF), - EXPAND_PROP_INIT(HELPURL), - EXPAND_PROP_INIT(RECORDMARKER), - EXPAND_PROP_INIT(BOUNDFIELD), - EXPAND_PROP_INIT(INPUT_REQUIRED), - EXPAND_PROP_INIT(TREATASNUMERIC), - EXPAND_PROP_INIT(EFFECTIVE_VALUE), - EXPAND_PROP_INIT(EFFECTIVE_DEFAULT), - EXPAND_PROP_INIT(EFFECTIVE_MIN), - EXPAND_PROP_INIT(EFFECTIVE_MAX), - EXPAND_PROP_INIT(HIDDEN), - EXPAND_PROP_INIT(FILTERPROPOSAL), - EXPAND_PROP_INIT(FIELDSOURCE), - EXPAND_PROP_INIT(TABLENAME), - EXPAND_PROP_INIT(CONTROLLABEL), - EXPAND_PROP_INIT(CURRSYM_POSITION), - EXPAND_PROP_INIT(CURSORCOLOR), - EXPAND_PROP_INIT(ALWAYSSHOWCURSOR), - EXPAND_PROP_INIT(DISPLAYSYNCHRON), - EXPAND_PROP_INIT(ISMODIFIED), - EXPAND_PROP_INIT(ISNEW), - EXPAND_PROP_INIT(PRIVILEGES), - EXPAND_PROP_INIT(DETAILFIELDS), - EXPAND_PROP_INIT(COMMAND), - EXPAND_PROP_INIT(COMMANDTYPE), - EXPAND_PROP_INIT(RESULTSET_CONCURRENCY), - EXPAND_PROP_INIT(INSERTONLY), - EXPAND_PROP_INIT(RESULTSET_TYPE), - EXPAND_PROP_INIT(ESCAPE_PROCESSING), - EXPAND_PROP_INIT(APPLYFILTER), - EXPAND_PROP_INIT(ISNULLABLE), - EXPAND_PROP_INIT(ACTIVECOMMAND), - EXPAND_PROP_INIT(ISCURRENCY), - EXPAND_PROP_INIT(URL), - EXPAND_PROP_INIT(TITLE), - EXPAND_PROP_INIT(ACTIVE_CONNECTION), - EXPAND_PROP_INIT(SCALE), - EXPAND_PROP_INIT(SORT), - EXPAND_PROP_INIT(PERSISTENCE_MAXTEXTLENGTH), - EXPAND_PROP_INIT(SCROLL_VALUE), - EXPAND_PROP_INIT(SPIN_VALUE), - EXPAND_PROP_INIT(DEFAULT_SCROLL_VALUE), - EXPAND_PROP_INIT(DEFAULT_SPIN_VALUE), - EXPAND_PROP_INIT( WRITING_MODE ), - EXPAND_PROP_INIT( CONTEXT_WRITING_MODE ), - EXPAND_PROP_INIT( GENERATEVBAEVENTS ) + { PROPERTY_NAME, PROPERTY_ID_NAME }, + { PROPERTY_TAG, PROPERTY_ID_TAG }, + { PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX }, + { PROPERTY_CLASSID, PROPERTY_ID_CLASSID }, + { PROPERTY_ALIGN, PROPERTY_ID_ALIGN }, + { PROPERTY_FETCHSIZE, PROPERTY_ID_FETCHSIZE }, + { PROPERTY_VALUE, PROPERTY_ID_VALUE }, + { PROPERTY_VALUEMIN, PROPERTY_ID_VALUEMIN }, + { PROPERTY_VALUEMAX, PROPERTY_ID_VALUEMAX }, + { PROPERTY_VALUESTEP, PROPERTY_ID_VALUESTEP }, + { PROPERTY_TEXT, PROPERTY_ID_TEXT }, + { PROPERTY_LABEL, PROPERTY_ID_LABEL }, + { PROPERTY_NAVIGATION, PROPERTY_ID_NAVIGATION }, + { PROPERTY_CYCLE, PROPERTY_ID_CYCLE }, + { PROPERTY_CONTROLSOURCE, PROPERTY_ID_CONTROLSOURCE }, + { PROPERTY_ENABLED, PROPERTY_ID_ENABLED }, + { PROPERTY_ENABLEVISIBLE, PROPERTY_ID_ENABLEVISIBLE }, + { PROPERTY_SPIN, PROPERTY_ID_SPIN }, + { PROPERTY_READONLY, PROPERTY_ID_READONLY }, + { PROPERTY_FILTER, PROPERTY_ID_FILTER }, + { PROPERTY_WIDTH, PROPERTY_ID_WIDTH }, + { PROPERTY_SEARCHABLE, PROPERTY_ID_SEARCHABLE }, + { PROPERTY_MULTILINE, PROPERTY_ID_MULTILINE }, + { PROPERTY_TARGET_URL, PROPERTY_ID_TARGET_URL }, + { PROPERTY_DEFAULTCONTROL, PROPERTY_ID_DEFAULTCONTROL }, + { PROPERTY_MAXTEXTLEN, PROPERTY_ID_MAXTEXTLEN }, + { PROPERTY_SIZE, PROPERTY_ID_SIZE }, + { PROPERTY_DATE, PROPERTY_ID_DATE }, + { PROPERTY_TIME, PROPERTY_ID_TIME }, + { PROPERTY_STATE, PROPERTY_ID_STATE }, + { PROPERTY_TRISTATE, PROPERTY_ID_TRISTATE }, + { PROPERTY_HIDDEN_VALUE, PROPERTY_ID_HIDDEN_VALUE }, + { PROPERTY_TARGET_FRAME, PROPERTY_ID_TARGET_FRAME }, + { PROPERTY_BUTTONTYPE, PROPERTY_ID_BUTTONTYPE }, + { PROPERTY_STRINGITEMLIST, PROPERTY_ID_STRINGITEMLIST }, + { PROPERTY_TYPEDITEMLIST, PROPERTY_ID_TYPEDITEMLIST }, + { PROPERTY_DEFAULT_TEXT, PROPERTY_ID_DEFAULT_TEXT }, + { PROPERTY_DEFAULT_STATE, PROPERTY_ID_DEFAULT_STATE }, + { PROPERTY_DEFAULT_DATE, PROPERTY_ID_DEFAULT_DATE }, + { PROPERTY_DEFAULT_TIME, PROPERTY_ID_DEFAULT_TIME }, + { PROPERTY_DEFAULT_VALUE, PROPERTY_ID_DEFAULT_VALUE }, + { PROPERTY_FORMATKEY, PROPERTY_ID_FORMATKEY }, + { PROPERTY_FORMATSSUPPLIER, PROPERTY_ID_FORMATSSUPPLIER }, + { PROPERTY_SUBMIT_ACTION, PROPERTY_ID_SUBMIT_ACTION }, + { PROPERTY_SUBMIT_TARGET, PROPERTY_ID_SUBMIT_TARGET }, + { PROPERTY_SUBMIT_METHOD, PROPERTY_ID_SUBMIT_METHOD }, + { PROPERTY_SUBMIT_ENCODING, PROPERTY_ID_SUBMIT_ENCODING }, + { PROPERTY_IMAGE_URL, PROPERTY_ID_IMAGE_URL }, + { PROPERTY_GRAPHIC, PROPERTY_ID_GRAPHIC }, + { PROPERTY_EMPTY_IS_NULL, PROPERTY_ID_EMPTY_IS_NULL }, + { PROPERTY_LISTSOURCETYPE, PROPERTY_ID_LISTSOURCETYPE }, + { PROPERTY_LISTSOURCE, PROPERTY_ID_LISTSOURCE }, + { PROPERTY_SELECT_SEQ, PROPERTY_ID_SELECT_SEQ }, + { PROPERTY_VALUE_SEQ, PROPERTY_ID_VALUE_SEQ }, + { PROPERTY_SELECT_VALUE, PROPERTY_ID_SELECT_VALUE }, + { PROPERTY_SELECT_VALUE_SEQ, PROPERTY_ID_SELECT_VALUE_SEQ }, + { PROPERTY_DEFAULT_SELECT_SEQ, PROPERTY_ID_DEFAULT_SELECT_SEQ }, + { PROPERTY_MULTISELECTION, PROPERTY_ID_MULTISELECTION }, + { PROPERTY_DECIMAL_ACCURACY, PROPERTY_ID_DECIMAL_ACCURACY }, + { PROPERTY_EDITMASK, PROPERTY_ID_EDITMASK }, + { PROPERTY_ISREADONLY, PROPERTY_ID_ISREADONLY }, + { PROPERTY_FIELDTYPE, PROPERTY_ID_FIELDTYPE }, + { PROPERTY_DECIMALS, PROPERTY_ID_DECIMALS }, + { PROPERTY_REFVALUE, PROPERTY_ID_REFVALUE }, + { PROPERTY_STRICTFORMAT, PROPERTY_ID_STRICTFORMAT }, + { PROPERTY_DATASOURCE, PROPERTY_ID_DATASOURCE }, + { PROPERTY_ALLOWADDITIONS, PROPERTY_ID_ALLOWADDITIONS }, + { PROPERTY_ALLOWEDITS, PROPERTY_ID_ALLOWEDITS }, + { PROPERTY_ALLOWDELETIONS, PROPERTY_ID_ALLOWDELETIONS }, + { PROPERTY_MASTERFIELDS, PROPERTY_ID_MASTERFIELDS }, + { PROPERTY_ISPASSTHROUGH, PROPERTY_ID_ISPASSTHROUGH }, + { PROPERTY_QUERY, PROPERTY_ID_QUERY }, + { PROPERTY_LITERALMASK, PROPERTY_ID_LITERALMASK }, + { PROPERTY_SHOWTHOUSANDSEP, PROPERTY_ID_SHOWTHOUSANDSEP }, + { PROPERTY_CURRENCYSYMBOL, PROPERTY_ID_CURRENCYSYMBOL }, + { PROPERTY_DATEFORMAT, PROPERTY_ID_DATEFORMAT }, + { PROPERTY_DATEMIN, PROPERTY_ID_DATEMIN }, + { PROPERTY_DATEMAX, PROPERTY_ID_DATEMAX }, + { PROPERTY_DATE_SHOW_CENTURY, PROPERTY_ID_DATE_SHOW_CENTURY }, + { PROPERTY_TIMEFORMAT, PROPERTY_ID_TIMEFORMAT }, + { PROPERTY_TIMEMIN, PROPERTY_ID_TIMEMIN }, + { PROPERTY_TIMEMAX, PROPERTY_ID_TIMEMAX }, + { PROPERTY_LINECOUNT, PROPERTY_ID_LINECOUNT }, + { PROPERTY_BOUNDCOLUMN, PROPERTY_ID_BOUNDCOLUMN }, + { PROPERTY_HASNAVIGATION, PROPERTY_ID_HASNAVIGATION }, + { PROPERTY_FONT, PROPERTY_ID_FONT }, + { PROPERTY_BACKGROUNDCOLOR, PROPERTY_ID_BACKGROUNDCOLOR }, + { PROPERTY_FILLCOLOR, PROPERTY_ID_FILLCOLOR }, + { PROPERTY_TEXTCOLOR, PROPERTY_ID_TEXTCOLOR }, + { PROPERTY_LINECOLOR, PROPERTY_ID_LINECOLOR }, + { PROPERTY_BORDER, PROPERTY_ID_BORDER }, + { PROPERTY_DROPDOWN, PROPERTY_ID_DROPDOWN }, + { PROPERTY_HSCROLL, PROPERTY_ID_HSCROLL }, + { PROPERTY_VSCROLL, PROPERTY_ID_VSCROLL }, + { PROPERTY_TABSTOP, PROPERTY_ID_TABSTOP }, + { PROPERTY_AUTOCOMPLETE, PROPERTY_ID_AUTOCOMPLETE }, + { PROPERTY_HARDLINEBREAKS, PROPERTY_ID_HARDLINEBREAKS }, + { PROPERTY_PRINTABLE, PROPERTY_ID_PRINTABLE }, + { PROPERTY_ECHO_CHAR, PROPERTY_ID_ECHO_CHAR }, + { PROPERTY_ROWHEIGHT, PROPERTY_ID_ROWHEIGHT }, + { PROPERTY_HELPTEXT, PROPERTY_ID_HELPTEXT }, + { PROPERTY_FONT_NAME, PROPERTY_ID_FONT_NAME }, + { PROPERTY_FONT_STYLENAME, PROPERTY_ID_FONT_STYLENAME }, + { PROPERTY_FONT_FAMILY, PROPERTY_ID_FONT_FAMILY }, + { PROPERTY_FONT_CHARSET, PROPERTY_ID_FONT_CHARSET }, + { PROPERTY_FONT_HEIGHT, PROPERTY_ID_FONT_HEIGHT }, + { PROPERTY_FONT_WEIGHT, PROPERTY_ID_FONT_WEIGHT }, + { PROPERTY_FONT_SLANT, PROPERTY_ID_FONT_SLANT }, + { PROPERTY_FONT_UNDERLINE, PROPERTY_ID_FONT_UNDERLINE }, + { PROPERTY_FONT_WORDLINEMODE, PROPERTY_ID_FONT_WORDLINEMODE }, + { PROPERTY_FONT_STRIKEOUT, PROPERTY_ID_FONT_STRIKEOUT }, + { PROPERTY_TEXTLINECOLOR, PROPERTY_ID_TEXTLINECOLOR }, + { PROPERTY_FONTEMPHASISMARK, PROPERTY_ID_FONTEMPHASISMARK }, + { PROPERTY_FONTRELIEF, PROPERTY_ID_FONTRELIEF }, + { PROPERTY_HELPURL, PROPERTY_ID_HELPURL }, + { PROPERTY_RECORDMARKER, PROPERTY_ID_RECORDMARKER }, + { PROPERTY_BOUNDFIELD, PROPERTY_ID_BOUNDFIELD }, + { PROPERTY_INPUT_REQUIRED, PROPERTY_ID_INPUT_REQUIRED }, + { PROPERTY_TREATASNUMERIC, PROPERTY_ID_TREATASNUMERIC }, + { PROPERTY_EFFECTIVE_VALUE, PROPERTY_ID_EFFECTIVE_VALUE }, + { PROPERTY_EFFECTIVE_DEFAULT, PROPERTY_ID_EFFECTIVE_DEFAULT }, + { PROPERTY_EFFECTIVE_MIN, PROPERTY_ID_EFFECTIVE_MIN }, + { PROPERTY_EFFECTIVE_MAX, PROPERTY_ID_EFFECTIVE_MAX }, + { PROPERTY_HIDDEN, PROPERTY_ID_HIDDEN }, + { PROPERTY_FILTERPROPOSAL, PROPERTY_ID_FILTERPROPOSAL }, + { PROPERTY_FIELDSOURCE, PROPERTY_ID_FIELDSOURCE }, + { PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME }, + { PROPERTY_CONTROLLABEL, PROPERTY_ID_CONTROLLABEL }, + { PROPERTY_CURRSYM_POSITION, PROPERTY_ID_CURRSYM_POSITION }, + { PROPERTY_CURSORCOLOR, PROPERTY_ID_CURSORCOLOR }, + { PROPERTY_ALWAYSSHOWCURSOR, PROPERTY_ID_ALWAYSSHOWCURSOR }, + { PROPERTY_DISPLAYSYNCHRON, PROPERTY_ID_DISPLAYSYNCHRON }, + { PROPERTY_ISMODIFIED, PROPERTY_ID_ISMODIFIED }, + { PROPERTY_ISNEW, PROPERTY_ID_ISNEW }, + { PROPERTY_PRIVILEGES, PROPERTY_ID_PRIVILEGES }, + { PROPERTY_DETAILFIELDS, PROPERTY_ID_DETAILFIELDS }, + { PROPERTY_COMMAND, PROPERTY_ID_COMMAND }, + { PROPERTY_COMMANDTYPE, PROPERTY_ID_COMMANDTYPE }, + { PROPERTY_RESULTSET_CONCURRENCY, PROPERTY_ID_RESULTSET_CONCURRENCY }, + { PROPERTY_INSERTONLY, PROPERTY_ID_INSERTONLY }, + { PROPERTY_RESULTSET_TYPE, PROPERTY_ID_RESULTSET_TYPE }, + { PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING }, + { PROPERTY_APPLYFILTER, PROPERTY_ID_APPLYFILTER }, + { PROPERTY_ISNULLABLE, PROPERTY_ID_ISNULLABLE }, + { PROPERTY_ACTIVECOMMAND, PROPERTY_ID_ACTIVECOMMAND }, + { PROPERTY_ISCURRENCY, PROPERTY_ID_ISCURRENCY }, + { PROPERTY_URL, PROPERTY_ID_URL }, + { PROPERTY_TITLE, PROPERTY_ID_TITLE }, + { PROPERTY_ACTIVE_CONNECTION, PROPERTY_ID_ACTIVE_CONNECTION }, + { PROPERTY_SCALE, PROPERTY_ID_SCALE }, + { PROPERTY_SORT, PROPERTY_ID_SORT }, + { PROPERTY_PERSISTENCE_MAXTEXTLENGTH, PROPERTY_ID_PERSISTENCE_MAXTEXTLENGTH }, + { PROPERTY_SCROLL_VALUE, PROPERTY_ID_SCROLL_VALUE }, + { PROPERTY_SPIN_VALUE, PROPERTY_ID_SPIN_VALUE }, + { PROPERTY_DEFAULT_SCROLL_VALUE, PROPERTY_ID_DEFAULT_SCROLL_VALUE }, + { PROPERTY_DEFAULT_SPIN_VALUE, PROPERTY_ID_DEFAULT_SPIN_VALUE }, + { PROPERTY_WRITING_MODE , PROPERTY_ID_WRITING_MODE }, + { PROPERTY_CONTEXT_WRITING_MODE , PROPERTY_ID_CONTEXT_WRITING_MODE }, + { PROPERTY_GENERATEVBAEVENTS , PROPERTY_ID_GENERATEVBAEVENTS } }); } diff --git a/forms/source/richtext/attributedispatcher.cxx b/forms/source/richtext/attributedispatcher.cxx index 0cabb526c75f..f4e11c8c8bf1 100644 --- a/forms/source/richtext/attributedispatcher.cxx +++ b/forms/source/richtext/attributedispatcher.cxx @@ -30,7 +30,6 @@ namespace frm using namespace ::com::sun::star::uno; using namespace ::com::sun::star::frame; - using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; using namespace ::com::sun::star::beans; @@ -103,9 +102,9 @@ namespace frm OSL_ENSURE( _nAttributeId == m_nAttributeId, "OAttributeDispatcher::onAttributeStateChanged: wrong attribute!" ); FeatureStateEvent aEvent( buildStatusEvent() ); - ::comphelper::OInterfaceIteratorHelper2 aIter( getStatusListeners() ); + ::comphelper::OInterfaceIteratorHelper3 aIter( getStatusListeners() ); while ( aIter.hasMoreElements() ) - doNotify( static_cast< XStatusListener* >( aIter.next() ), aEvent ); + doNotify( aIter.next(), aEvent ); } diff --git a/forms/source/richtext/featuredispatcher.cxx b/forms/source/richtext/featuredispatcher.cxx index d667790c9756..f583a8e7c699 100644 --- a/forms/source/richtext/featuredispatcher.cxx +++ b/forms/source/richtext/featuredispatcher.cxx @@ -19,7 +19,9 @@ #include "featuredispatcher.hxx" #include <osl/diagnose.h> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> + +#include <utility> namespace frm @@ -31,8 +33,8 @@ namespace frm using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; - ORichTextFeatureDispatcher::ORichTextFeatureDispatcher( EditView& _rView, const URL& _rURL ) - :m_aFeatureURL( _rURL ) + ORichTextFeatureDispatcher::ORichTextFeatureDispatcher( EditView& _rView, URL _aURL ) + :m_aFeatureURL(std::move( _aURL )) ,m_aStatusListeners( m_aMutex ) ,m_pEditView( &_rView ) ,m_bDisposed( false ) @@ -109,9 +111,9 @@ namespace frm void ORichTextFeatureDispatcher::invalidateFeatureState_Broadcast() { FeatureStateEvent aEvent( buildStatusEvent() ); - ::comphelper::OInterfaceIteratorHelper2 aIter( getStatusListeners() ); + ::comphelper::OInterfaceIteratorHelper3 aIter( getStatusListeners() ); while ( aIter.hasMoreElements() ) - doNotify( static_cast< XStatusListener* >( aIter.next() ), aEvent ); + doNotify( aIter.next(), aEvent ); } diff --git a/forms/source/richtext/featuredispatcher.hxx b/forms/source/richtext/featuredispatcher.hxx index feba00d5bfb2..5c863f10f8eb 100644 --- a/forms/source/richtext/featuredispatcher.hxx +++ b/forms/source/richtext/featuredispatcher.hxx @@ -21,7 +21,7 @@ #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/lang/DisposedException.hpp> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer3.hxx> #include <cppuhelper/implbase.hxx> #include <cppuhelper/basemutex.hxx> @@ -38,7 +38,7 @@ namespace frm { private: css::util::URL m_aFeatureURL; - ::comphelper::OInterfaceContainerHelper2 m_aStatusListeners; + ::comphelper::OInterfaceContainerHelper3<css::frame::XStatusListener> m_aStatusListeners; EditView* m_pEditView; bool m_bDisposed; @@ -48,12 +48,12 @@ namespace frm protected: const css::util::URL& getFeatureURL() const { return m_aFeatureURL; } - ::comphelper::OInterfaceContainerHelper2& getStatusListeners() { return m_aStatusListeners; } + ::comphelper::OInterfaceContainerHelper3<css::frame::XStatusListener>& getStatusListeners() { return m_aStatusListeners; } bool isDisposed() const { return m_bDisposed; } void checkDisposed() const { if ( isDisposed() ) throw css::lang::DisposedException(); } protected: - ORichTextFeatureDispatcher( EditView& _rView, const css::util::URL& _rURL ); + ORichTextFeatureDispatcher( EditView& _rView, css::util::URL _aURL ); virtual ~ORichTextFeatureDispatcher( ) override; public: diff --git a/forms/source/richtext/parametrizedattributedispatcher.cxx b/forms/source/richtext/parametrizedattributedispatcher.cxx index d6666e2b0262..15b69b0888b6 100644 --- a/forms/source/richtext/parametrizedattributedispatcher.cxx +++ b/forms/source/richtext/parametrizedattributedispatcher.cxx @@ -35,7 +35,6 @@ namespace frm using namespace ::com::sun::star::uno; using namespace ::com::sun::star::frame; - using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; using namespace ::com::sun::star::beans; @@ -102,7 +101,7 @@ namespace frm if ( aParameterSet.Count() ) { OSL_ENSURE( aParameterSet.Count() == 1, "OParametrizedAttributeDispatcher::convertDispatchArgsToItem: Arguments which form more than 1 item? How this?" ); - WhichId nAttributeWhich = aParameterSet.GetPool()->GetWhich( nSlotId ); + WhichId nAttributeWhich = aParameterSet.GetPool()->GetWhichIDFromSlotID( nSlotId ); pArgument = aParameterSet.GetItem( nAttributeWhich ); OSL_ENSURE( pArgument, "OParametrizedAttributeDispatcher::convertDispatchArgsToItem: suspicious: there were arguments, but they're not for my slot!" ); } diff --git a/forms/source/richtext/richtextcontrol.cxx b/forms/source/richtext/richtextcontrol.cxx index bc3dbfe6002b..b2ff9f310ad0 100644 --- a/forms/source/richtext/richtextcontrol.cxx +++ b/forms/source/richtext/richtextcontrol.cxx @@ -31,7 +31,7 @@ #include <toolkit/helper/vclunohelper.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> #include <vcl/svapp.hxx> @@ -49,7 +49,6 @@ namespace frm using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::awt; - using namespace ::com::sun::star::lang; using namespace ::com::sun::star::frame; ORichTextControl::ORichTextControl() @@ -176,7 +175,7 @@ namespace frm vcl::Window* pParentWin = nullptr; if ( _rParentPeer.is() ) { - VCLXWindow* pParentXWin = comphelper::getFromUnoTunnel<VCLXWindow>( _rParentPeer ); + VCLXWindow* pParentXWin = dynamic_cast<VCLXWindow*>( _rParentPeer.get() ); if ( pParentXWin ) pParentWin = pParentXWin->GetWindow(); DBG_ASSERT( pParentWin, "ORichTextControl::createPeer: could not obtain the VCL-level parent window!" ); @@ -239,13 +238,10 @@ namespace frm Sequence< Reference< XDispatch > > SAL_CALL ORichTextControl::queryDispatches( const Sequence< DispatchDescriptor >& _rRequests ) { - Sequence< Reference< XDispatch > > aReturn; - Reference< XDispatchProvider > xTypedPeer( getPeer(), UNO_QUERY ); - if ( xTypedPeer.is() ) - { - aReturn = xTypedPeer->queryDispatches( _rRequests ); - } - return aReturn; + Reference<XDispatchProvider> xTypedPeer(getPeer(), UNO_QUERY); + if (xTypedPeer.is()) + return xTypedPeer->queryDispatches(_rRequests); + return Sequence<Reference<XDispatch>>(); } bool ORichTextControl::requiresNewPeer( const OUString& _rPropertyName ) const @@ -260,7 +256,7 @@ namespace frm // the EditEngine of the model RichTextEngine* pEngine = ORichTextModel::getEditEngine( _rxModel ); - OSL_ENSURE( pEngine, "ORichTextPeer::Create: could not obtaine the edit engine from the model!" ); + OSL_ENSURE( pEngine, "ORichTextPeer::Create: could not obtain the edit engine from the model!" ); if ( !pEngine ) return nullptr; @@ -480,7 +476,7 @@ namespace frm default: { const SfxItemPool& rPool = *pRichTextControl->getView().GetEmptyItemSet().GetPool(); - bool bSupportedSlot = rPool.IsInRange( rPool.GetWhich( _nSlotId ) ); + bool bSupportedSlot = rPool.IsInRange( rPool.GetWhichIDFromSlotID( _nSlotId ) ); if ( !bSupportedSlot ) bSupportedSlot = RichTextControl::isMappableSlot( _nSlotId ); @@ -589,10 +585,10 @@ namespace frm } // is it a UNO slot? - OUString sUnoProtocolPrefix( ".uno:" ); + static constexpr std::u16string_view sUnoProtocolPrefix( u".uno:" ); if ( _rURL.Complete.startsWith( sUnoProtocolPrefix ) ) { - OUString sUnoSlotName = _rURL.Complete.copy( sUnoProtocolPrefix.getLength() ); + OUString sUnoSlotName = _rURL.Complete.copy( sUnoProtocolPrefix.size() ); SfxSlotId nSlotId = lcl_getSlotFromUnoName( SfxSlotPool::GetSlotPool(), sUnoSlotName ); if ( nSlotId > 0 ) { diff --git a/forms/source/richtext/richtextcontrol.hxx b/forms/source/richtext/richtextcontrol.hxx index 9cda83bb5257..81e0ad2a0f01 100644 --- a/forms/source/richtext/richtextcontrol.hxx +++ b/forms/source/richtext/richtextcontrol.hxx @@ -26,7 +26,7 @@ #include <comphelper/uno3.hxx> #include <cppuhelper/implbase1.hxx> #include <rtl/ref.hxx> -#include <tools/wintypes.hxx> +#include <vcl/wintypes.hxx> #include "rtattributes.hxx" #include "textattributelistener.hxx" diff --git a/forms/source/richtext/richtextengine.cxx b/forms/source/richtext/richtextengine.cxx index 14f50a6fca4d..37570639e808 100644 --- a/forms/source/richtext/richtextengine.cxx +++ b/forms/source/richtext/richtextengine.cxx @@ -45,8 +45,6 @@ namespace frm SolarMutexGuard g; rtl::Reference<SfxItemPool> pPool = EditEngine::CreatePool(); - pPool->FreezeIdRanges(); - RichTextEngine* pReturn = new RichTextEngine( pPool.get() ); OutputDevice* pOutputDevice = pReturn->GetRefDevice(); const MapMode& aDeviceMapMode( pOutputDevice->GetMapMode() ); @@ -58,18 +56,18 @@ namespace frm // defaults vcl::Font aFont = Application::GetSettings().GetStyleSettings().GetAppFont(); aFont.SetFamilyName( "Times New Roman" ); - pPool->SetPoolDefaultItem( SvxFontItem( aFont.GetFamilyType(), aFont.GetFamilyName(), OUString(), aFont.GetPitch(), aFont.GetCharSet(), EE_CHAR_FONTINFO ) ); + pPool->SetUserDefaultItem( SvxFontItem( aFont.GetFamilyType(), aFont.GetFamilyName(), OUString(), aFont.GetPitch(), aFont.GetCharSet(), EE_CHAR_FONTINFO ) ); // 12 pt font size MapMode aPointMapMode( MapUnit::MapPoint ); Size a12PointSize( OutputDevice::LogicToLogic( Size( 12, 0 ), aPointMapMode, aDeviceMapMode ) ); - pPool->SetPoolDefaultItem( SvxFontHeightItem( a12PointSize.Width(), 100, EE_CHAR_FONTHEIGHT ) ); + pPool->SetUserDefaultItem( SvxFontHeightItem( a12PointSize.Width(), 100, EE_CHAR_FONTHEIGHT ) ); // font languages SvtLinguOptions aLinguOpt; - pPool->SetPoolDefaultItem( SvxLanguageItem( aLinguOpt.nDefaultLanguage, EE_CHAR_LANGUAGE ) ); - pPool->SetPoolDefaultItem( SvxLanguageItem( aLinguOpt.nDefaultLanguage_CJK, EE_CHAR_LANGUAGE_CJK ) ); - pPool->SetPoolDefaultItem( SvxLanguageItem( aLinguOpt.nDefaultLanguage_CTL, EE_CHAR_LANGUAGE_CTL ) ); + pPool->SetUserDefaultItem( SvxLanguageItem( aLinguOpt.nDefaultLanguage, EE_CHAR_LANGUAGE ) ); + pPool->SetUserDefaultItem( SvxLanguageItem( aLinguOpt.nDefaultLanguage_CJK, EE_CHAR_LANGUAGE_CJK ) ); + pPool->SetUserDefaultItem( SvxLanguageItem( aLinguOpt.nDefaultLanguage_CTL, EE_CHAR_LANGUAGE_CTL ) ); return pReturn; } diff --git a/forms/source/richtext/richtextimplcontrol.cxx b/forms/source/richtext/richtextimplcontrol.cxx index d1cbd7f6aec3..eeb9fba98d33 100644 --- a/forms/source/richtext/richtextimplcontrol.cxx +++ b/forms/source/richtext/richtextimplcontrol.cxx @@ -46,7 +46,6 @@ namespace frm ,m_pViewport ( nullptr ) ,m_pHScroll ( nullptr ) ,m_pVScroll ( nullptr ) - ,m_pScrollCorner ( nullptr ) ,m_pEngine ( _pEngine ) ,m_pTextAttrListener ( _pTextAttrListener ) ,m_pSelectionListener ( _pSelectionListener ) @@ -84,7 +83,6 @@ namespace frm m_pAntiImpl->SetBackground( Wallpaper( m_pAntiImpl->GetSettings().GetStyleSettings().GetFieldColor() ) ); } - RichTextControlImpl::~RichTextControlImpl( ) { m_pEngine->RemoveView( m_pView.get() ); @@ -93,16 +91,14 @@ namespace frm m_pViewport.disposeAndClear(); m_pHScroll.disposeAndClear(); m_pVScroll.disposeAndClear(); - m_pScrollCorner.disposeAndClear(); } - void RichTextControlImpl::implUpdateAttribute( const AttributeHandlerPool::const_iterator& _pHandler ) { - if ( ( _pHandler->first == SID_ATTR_CHAR_WEIGHT ) - || ( _pHandler->first == SID_ATTR_CHAR_POSTURE ) - || ( _pHandler->first == SID_ATTR_CHAR_FONT ) - || ( _pHandler->first == SID_ATTR_CHAR_FONTHEIGHT ) + if ( ( _pHandler->first == sal_uInt16(SID_ATTR_CHAR_WEIGHT) ) + || ( _pHandler->first == sal_uInt16(SID_ATTR_CHAR_POSTURE) ) + || ( _pHandler->first == sal_uInt16(SID_ATTR_CHAR_FONT) ) + || ( _pHandler->first == sal_uInt16(SID_ATTR_CHAR_FONTHEIGHT) ) ) { // these are attributes whose value depends on the current script type. @@ -221,7 +217,7 @@ namespace frm _rScriptSetItem.GetItemSet().Put( m_pView->GetAttribs(), false ); const SfxPoolItem* pNormalizedItem = _rScriptSetItem.GetItemOfScript( getSelectedScriptType() ); - WhichId nNormalizedWhichId = _rScriptSetItem.GetItemSet().GetPool()->GetWhich( _rScriptSetItem.Which() ); + WhichId nNormalizedWhichId = _rScriptSetItem.GetItemSet().GetPool()->GetWhichIDFromSlotID( _rScriptSetItem.Which() ); if ( pNormalizedItem ) { _rScriptSetItem.GetItemSet().Put( pNormalizedItem->CloneSetWhich(nNormalizedWhichId) ); @@ -306,25 +302,23 @@ namespace frm m_pVScroll->SetThumbPos( m_pView->GetVisArea().Top() ); } - IMPL_LINK_NOARG( RichTextControlImpl, OnInvalidateAllAttributes, LinkParamNone*, void ) { updateAllAttributes(); } - - IMPL_LINK( RichTextControlImpl, OnHScroll, ScrollBar*, _pScrollbar, void ) + IMPL_LINK( RichTextControlImpl, OnHScroll, weld::Scrollbar&, rScrollbar, void ) { - m_pView->Scroll( -_pScrollbar->GetDelta(), 0, ScrollRangeCheck::PaperWidthTextSize ); + auto nDiff = m_pView->GetVisArea().Left() - rScrollbar.adjustment_get_value(); + m_pView->Scroll(nDiff, 0, ScrollRangeCheck::PaperWidthTextSize); } - - IMPL_LINK( RichTextControlImpl, OnVScroll, ScrollBar*, _pScrollbar, void ) + IMPL_LINK(RichTextControlImpl, OnVScroll, weld::Scrollbar&, rScrollbar, void) { - m_pView->Scroll( 0, -_pScrollbar->GetDelta(), ScrollRangeCheck::PaperWidthTextSize ); + auto nDiff = m_pView->GetVisArea().Top() - rScrollbar.adjustment_get_value(); + m_pView->Scroll(0, nDiff, ScrollRangeCheck::PaperWidthTextSize); } - void RichTextControlImpl::ensureScrollbars() { bool bNeedVScroll = 0 != ( m_pAntiImpl->GetStyle() & WB_VSCROLL ); @@ -341,7 +335,7 @@ namespace frm } else { - m_pVScroll = VclPtr<ScrollBar>::Create( m_pAntiImpl, WB_VSCROLL | WB_DRAG | WB_REPEAT ); + m_pVScroll = VclPtr<ScrollAdaptor>::Create( m_pAntiImpl, false ); m_pVScroll->SetScrollHdl ( LINK( this, RichTextControlImpl, OnVScroll ) ); m_pVScroll->Show(); } @@ -352,26 +346,14 @@ namespace frm } else { - m_pHScroll = VclPtr<ScrollBar>::Create( m_pAntiImpl, WB_HSCROLL | WB_DRAG | WB_REPEAT ); + m_pHScroll = VclPtr<ScrollAdaptor>::Create( m_pAntiImpl, true ); m_pHScroll->SetScrollHdl ( LINK( this, RichTextControlImpl, OnHScroll ) ); m_pHScroll->Show(); } - if ( m_pHScroll && m_pVScroll ) - { - m_pScrollCorner.disposeAndClear(); - m_pScrollCorner = VclPtr<ScrollBarBox>::Create( m_pAntiImpl ); - m_pScrollCorner->Show(); - } - else - { - m_pScrollCorner.disposeAndClear(); - } - layoutWindow(); } - void RichTextControlImpl::ensureLineBreakSetting() { if ( !windowHasAutomaticLineBreak() ) @@ -380,7 +362,6 @@ namespace frm layoutWindow(); } - void RichTextControlImpl::layoutWindow() { if ( !m_bHasEverBeenShown ) @@ -417,11 +398,15 @@ namespace frm m_pViewport->SetPosSizePixel( Point( nOffset, nOffset ), aViewportSizePixel ); // position the scrollbars if ( m_pVScroll ) + { + m_pVScroll->SetThickness(nScrollBarWidth); m_pVScroll->SetPosSizePixel( Point( aViewportPlaygroundPixel.Width(), 0 ), Size( nScrollBarWidth, aViewportPlaygroundPixel.Height() ) ); + } if ( m_pHScroll ) + { + m_pHScroll->SetThickness(nScrollBarHeight); m_pHScroll->SetPosSizePixel( Point( 0, aViewportPlaygroundPixel.Height() ), Size( aViewportPlaygroundPixel.Width(), nScrollBarHeight ) ); - if ( m_pScrollCorner ) - m_pScrollCorner->SetPosSizePixel( Point( aViewportPlaygroundPixel.Width(), aViewportPlaygroundPixel.Height() ), Size( nScrollBarWidth, nScrollBarHeight ) ); + } // paper size if ( windowHasAutomaticLineBreak() ) diff --git a/forms/source/richtext/richtextimplcontrol.hxx b/forms/source/richtext/richtextimplcontrol.hxx index d4fef2f66806..86b1a1831684 100644 --- a/forms/source/richtext/richtextimplcontrol.hxx +++ b/forms/source/richtext/richtextimplcontrol.hxx @@ -21,7 +21,7 @@ #include "rtattributehandler.hxx" #include "richtextviewport.hxx" #include "richtextengine.hxx" -#include <vcl/scrbar.hxx> +#include <svtools/scrolladaptor.hxx> #include <editeng/editdata.hxx> #include <map> @@ -53,9 +53,8 @@ namespace frm VclPtr<Control> m_pAntiImpl; VclPtr<RichTextViewPort> m_pViewport; - VclPtr<ScrollBar> m_pHScroll; - VclPtr<ScrollBar> m_pVScroll; - VclPtr<ScrollBarBox> m_pScrollCorner; + VclPtr<ScrollAdaptor> m_pHScroll; + VclPtr<ScrollAdaptor> m_pVScroll; RichTextEngine* m_pEngine; std::unique_ptr<EditView> m_pView; ITextAttributeListener* m_pTextAttrListener; @@ -173,8 +172,8 @@ namespace frm private: DECL_LINK( OnInvalidateAllAttributes, LinkParamNone*, void ); - DECL_LINK( OnHScroll, ScrollBar*, void ); - DECL_LINK( OnVScroll, ScrollBar*, void ); + DECL_LINK( OnHScroll, weld::Scrollbar&, void ); + DECL_LINK( OnVScroll, weld::Scrollbar&, void ); }; diff --git a/forms/source/richtext/richtextmodel.cxx b/forms/source/richtext/richtextmodel.cxx index 3b78baa524e0..02e1585a1852 100644 --- a/forms/source/richtext/richtextmodel.cxx +++ b/forms/source/richtext/richtextmodel.cxx @@ -25,16 +25,17 @@ #include <services.hxx> #include <com/sun/star/awt/LineEndFormat.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/style/VerticalAlignment.hpp> #include <comphelper/guarding.hxx> #include <comphelper/servicehelper.hxx> -#include <svl/itempool.hxx> #include <toolkit/awt/vclxdevice.hxx> #include <toolkit/helper/vclunohelper.hxx> -#include <tools/diagnose_ex.h> +#include <tools/debug.hxx> +#include <comphelper/diagnose_ex.hxx> #include <editeng/editstat.hxx> #include <vcl/outdev.hxx> #include <vcl/svapp.hxx> @@ -45,7 +46,6 @@ namespace frm using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; using namespace ::com::sun::star::lang; - using namespace ::com::sun::star::io; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::form; using namespace ::com::sun::star::util; @@ -63,7 +63,9 @@ namespace frm m_nClassId = FormComponentType::TEXTFIELD; getPropertyDefaultByHandle( PROPERTY_ID_DEFAULTCONTROL ) >>= m_sDefaultControl; - getPropertyDefaultByHandle( PROPERTY_ID_BORDER ) >>= m_nBorder; + // Default to 'flat' instead of '3D Look' for form controls, but don't change + // getPropertyDefaultByHandle, see tdf#152974 + m_nBorder = 2; getPropertyDefaultByHandle( PROPERTY_ID_ENABLED ) >>= m_bEnabled; getPropertyDefaultByHandle( PROPERTY_ID_ENABLEVISIBLE ) >>= m_bEnableVisible; getPropertyDefaultByHandle( PROPERTY_ID_HARDLINEBREAKS ) >>= m_bHardLineBreaks; @@ -165,37 +167,64 @@ namespace frm void ORichTextModel::implRegisterProperties() { - REGISTER_PROP_2( DEFAULTCONTROL, m_sDefaultControl, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( HELPTEXT, m_sHelpText, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( HELPURL, m_sHelpURL, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( ENABLED, m_bEnabled, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( ENABLEVISIBLE, m_bEnableVisible, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( BORDER, m_nBorder, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( HARDLINEBREAKS, m_bHardLineBreaks, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( HSCROLL, m_bHScroll, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( VSCROLL, m_bVScroll, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( READONLY, m_bReadonly, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( PRINTABLE, m_bPrintable, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( REFERENCE_DEVICE, m_xReferenceDevice, BOUND, TRANSIENT ); - REGISTER_PROP_2( RICH_TEXT, m_bReallyActAsRichText, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( HIDEINACTIVESELECTION, m_bHideInactiveSelection, BOUND, MAYBEDEFAULT ); - - REGISTER_VOID_PROP_2( TABSTOP, m_aTabStop, sal_Bool, BOUND, MAYBEDEFAULT ); - REGISTER_VOID_PROP_2( BACKGROUNDCOLOR, m_aBackgroundColor, sal_Int32, BOUND, MAYBEDEFAULT ); - REGISTER_VOID_PROP_2( BORDERCOLOR, m_aBorderColor, sal_Int32, BOUND, MAYBEDEFAULT ); - REGISTER_VOID_PROP_2( VERTICAL_ALIGN, m_aVerticalAlignment, VerticalAlignment, BOUND, MAYBEDEFAULT ); + registerProperty( PROPERTY_DEFAULTCONTROL, PROPERTY_ID_DEFAULTCONTROL, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_sDefaultControl, cppu::UnoType<decltype(m_sDefaultControl)>::get() ); + registerProperty( PROPERTY_HELPTEXT, PROPERTY_ID_HELPTEXT, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_sHelpText, cppu::UnoType<decltype(m_sHelpText)>::get() ); + registerProperty( PROPERTY_HELPURL, PROPERTY_ID_HELPURL, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_sHelpURL, cppu::UnoType<decltype(m_sHelpURL)>::get() ); + registerProperty( PROPERTY_ENABLED, PROPERTY_ID_ENABLED, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bEnabled, cppu::UnoType<decltype(m_bEnabled)>::get() ); + registerProperty( PROPERTY_ENABLEVISIBLE, PROPERTY_ID_ENABLEVISIBLE, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bEnableVisible, cppu::UnoType<decltype(m_bEnableVisible)>::get() ); + registerProperty( PROPERTY_BORDER, PROPERTY_ID_BORDER, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_nBorder, cppu::UnoType<decltype(m_nBorder)>::get() ); + registerProperty( PROPERTY_HARDLINEBREAKS, PROPERTY_ID_HARDLINEBREAKS, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bHardLineBreaks, cppu::UnoType<decltype(m_bHardLineBreaks)>::get() ); + registerProperty( PROPERTY_HSCROLL, PROPERTY_ID_HSCROLL, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bHScroll, cppu::UnoType<decltype(m_bHScroll)>::get() ); + registerProperty( PROPERTY_VSCROLL, PROPERTY_ID_VSCROLL, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bVScroll, cppu::UnoType<decltype(m_bVScroll)>::get() ); + registerProperty( PROPERTY_READONLY, PROPERTY_ID_READONLY, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bReadonly, cppu::UnoType<decltype(m_bReadonly)>::get() ); + registerProperty( PROPERTY_PRINTABLE, PROPERTY_ID_PRINTABLE, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bPrintable, cppu::UnoType<decltype(m_bPrintable)>::get() ); + registerProperty( PROPERTY_REFERENCE_DEVICE, PROPERTY_ID_REFERENCE_DEVICE, PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT, + &m_xReferenceDevice, cppu::UnoType<decltype(m_xReferenceDevice)>::get() ); + registerProperty( PROPERTY_RICH_TEXT, PROPERTY_ID_RICH_TEXT, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bReallyActAsRichText, cppu::UnoType<decltype(m_bReallyActAsRichText)>::get() ); + registerProperty( PROPERTY_HIDEINACTIVESELECTION, PROPERTY_ID_HIDEINACTIVESELECTION, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bHideInactiveSelection, cppu::UnoType<decltype(m_bHideInactiveSelection)>::get() ); + + registerMayBeVoidProperty( PROPERTY_TABSTOP, PROPERTY_ID_TABSTOP, PropertyAttribute::MAYBEVOID | PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_aTabStop, cppu::UnoType<sal_Bool>::get() ); + registerMayBeVoidProperty( PROPERTY_BACKGROUNDCOLOR, PROPERTY_ID_BACKGROUNDCOLOR, PropertyAttribute::MAYBEVOID | PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_aBackgroundColor, cppu::UnoType<sal_Int32>::get() ); + registerMayBeVoidProperty( PROPERTY_BORDERCOLOR, PROPERTY_ID_BORDERCOLOR, PropertyAttribute::MAYBEVOID | PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_aBorderColor, cppu::UnoType<sal_Int32>::get() ); + registerMayBeVoidProperty( PROPERTY_VERTICAL_ALIGN, PROPERTY_ID_VERTICAL_ALIGN, PropertyAttribute::MAYBEVOID | PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_aVerticalAlignment, cppu::UnoType<VerticalAlignment>::get() ); // properties which exist only for compatibility with the css.swt.UnoControlEditModel, // since we replace the default implementation for this service - REGISTER_PROP_2( ECHO_CHAR, m_nEchoChar, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( MAXTEXTLEN, m_nMaxTextLength, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( MULTILINE, m_bMultiLine, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( TEXT, m_sLastKnownEngineText, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( LINEEND_FORMAT, m_nLineEndFormat, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_2( WRITING_MODE, m_nTextWritingMode, BOUND, MAYBEDEFAULT ); - REGISTER_PROP_3( CONTEXT_WRITING_MODE, m_nContextWritingMode, BOUND, MAYBEDEFAULT, TRANSIENT ); - - REGISTER_VOID_PROP_2( ALIGN, m_aAlign, sal_Int16, BOUND, MAYBEDEFAULT ); + registerProperty( PROPERTY_ECHO_CHAR, PROPERTY_ID_ECHO_CHAR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_nEchoChar, cppu::UnoType<decltype(m_nEchoChar)>::get() ); + registerProperty( PROPERTY_MAXTEXTLEN, PROPERTY_ID_MAXTEXTLEN, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_nMaxTextLength, cppu::UnoType<decltype(m_nMaxTextLength)>::get() ); + registerProperty( PROPERTY_MULTILINE, PROPERTY_ID_MULTILINE, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_bMultiLine, cppu::UnoType<decltype(m_bMultiLine)>::get() ); + registerProperty( PROPERTY_TEXT, PROPERTY_ID_TEXT, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_sLastKnownEngineText, cppu::UnoType<decltype(m_sLastKnownEngineText)>::get() ); + registerProperty( PROPERTY_LINEEND_FORMAT, PROPERTY_ID_LINEEND_FORMAT, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_nLineEndFormat, cppu::UnoType<decltype(m_nLineEndFormat)>::get() ); + registerProperty( PROPERTY_WRITING_MODE, PROPERTY_ID_WRITING_MODE, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_nTextWritingMode, cppu::UnoType<decltype(m_nTextWritingMode)>::get() ); + + registerProperty( PROPERTY_CONTEXT_WRITING_MODE, PROPERTY_ID_CONTEXT_WRITING_MODE, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT | + PropertyAttribute::TRANSIENT, &m_nContextWritingMode, cppu::UnoType<decltype(m_nContextWritingMode)>::get() ); + + registerMayBeVoidProperty( PROPERTY_ALIGN, PROPERTY_ID_ALIGN, PropertyAttribute::MAYBEVOID | PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, + &m_aAlign, cppu::UnoType<sal_Int16>::get() ); } @@ -252,7 +281,12 @@ namespace frm ); } - IMPLEMENT_DEFAULT_CLONING( ORichTextModel ) + css::uno::Reference< css::util::XCloneable > SAL_CALL ORichTextModel::createClone() +{ + rtl::Reference<ORichTextModel> pClone = new ORichTextModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} void SAL_CALL ORichTextModel::disposing() @@ -283,9 +317,12 @@ namespace frm void ORichTextModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 1, OControlModel ) - DECL_PROP2( TABINDEX, sal_Int16, BOUND, MAYBEDEFAULT ); - END_DESCRIBE_PROPERTIES(); + OControlModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 1); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEDEFAULT); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); // properties which the OPropertyContainerHelper is responsible for Sequence< Property > aContainedProperties; @@ -414,7 +451,9 @@ namespace frm } } - + // note tdf#152974, we can't simply change a default here because properties + // that match the default are not exported, so for compatibility these + // can't be changed without some sort of solution for that Any ORichTextModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const { Any aDefault; @@ -460,7 +499,7 @@ namespace frm break; case PROPERTY_ID_DEFAULTCONTROL: - aDefault <<= OUString(FRM_SUN_CONTROL_RICHTEXTCONTROL); + aDefault <<= FRM_SUN_CONTROL_RICHTEXTCONTROL; break; case PROPERTY_ID_HELPTEXT: @@ -523,7 +562,7 @@ namespace frm } - Sequence<sal_Int8> ORichTextModel::getUnoTunnelId() + const Sequence<sal_Int8> & ORichTextModel::getUnoTunnelId() { static const comphelper::UnoIdInit aId; return aId.getSeq(); diff --git a/forms/source/richtext/richtextmodel.hxx b/forms/source/richtext/richtextmodel.hxx index c4f73a1a37c6..cf0bae7db435 100644 --- a/forms/source/richtext/richtextmodel.hxx +++ b/forms/source/richtext/richtextmodel.hxx @@ -21,7 +21,7 @@ #include <FormComponent.hxx> #include <formcontrolfont.hxx> #include "richtextunowrapper.hxx" -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer3.hxx> #include <comphelper/propertycontainerhelper.hxx> #include <com/sun/star/awt/XDevice.hpp> @@ -53,7 +53,14 @@ namespace frm ,public ORichTextModel_BASE { public: - DECLARE_DEFAULT_LEAF_XTOR( ORichTextModel ); + ORichTextModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + ORichTextModel( + const ORichTextModel* _pOriginal, + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory + ); + virtual ~ORichTextModel() override; private: // <properties> @@ -94,7 +101,7 @@ namespace frm m_pEngine; bool m_bSettingEngineText; - ::comphelper::OInterfaceContainerHelper2 + ::comphelper::OInterfaceContainerHelper3<css::util::XModifyListener> m_aModifyListeners; public: @@ -119,7 +126,7 @@ namespace frm // XUnoTunnel virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; - static css::uno::Sequence<sal_Int8> getUnoTunnelId(); + static const css::uno::Sequence<sal_Int8> & getUnoTunnelId(); // XModifyBroadcaster virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override; diff --git a/forms/source/richtext/richtextunowrapper.cxx b/forms/source/richtext/richtextunowrapper.cxx index d9c4269216ea..c47f2089910e 100644 --- a/forms/source/richtext/richtextunowrapper.cxx +++ b/forms/source/richtext/richtextunowrapper.cxx @@ -34,8 +34,6 @@ namespace frm using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::lang; - using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; @@ -49,9 +47,8 @@ namespace frm SVX_UNOEDIT_CHAR_PROPERTIES, SVX_UNOEDIT_FONT_PROPERTIES, SVX_UNOEDIT_PARA_PROPERTIES, - { u"TextUserDefinedAttributes", EE_CHAR_XMLATTRIBS, cppu::UnoType<XNameContainer>::get(), 0, 0 }, - { u"ParaUserDefinedAttributes", EE_PARA_XMLATTRIBS, cppu::UnoType<XNameContainer>::get(), 0, 0 }, - { u"", 0, css::uno::Type(), 0, 0 } + { u"TextUserDefinedAttributes"_ustr, EE_CHAR_XMLATTRIBS, cppu::UnoType<XNameContainer>::get(), 0, 0 }, + { u"ParaUserDefinedAttributes"_ustr, EE_PARA_XMLATTRIBS, cppu::UnoType<XNameContainer>::get(), 0, 0 }, }; static SvxItemPropertySet aTextEnginePropertySet( aTextEnginePropertyMap, SdrObject::GetGlobalDrawObjectItemPool() ); return &aTextEnginePropertySet; diff --git a/forms/source/richtext/richtextvclcontrol.cxx b/forms/source/richtext/richtextvclcontrol.cxx index cb4d613e36b2..e4f1f0d1f77a 100644 --- a/forms/source/richtext/richtextvclcontrol.cxx +++ b/forms/source/richtext/richtextvclcontrol.cxx @@ -43,14 +43,12 @@ namespace frm implInit( _pEngine, _pTextAttribListener, _pSelectionListener ); } - void RichTextControl::implInit( RichTextEngine* _pEngine, ITextAttributeListener* _pTextAttribListener, ITextSelectionListener* _pSelectionListener ) { m_pImpl.reset( new RichTextControlImpl( this, _pEngine, _pTextAttribListener, _pSelectionListener ) ); SetCompoundControl( true ); } - RichTextControl::~RichTextControl( ) { disposeOnce(); @@ -189,7 +187,7 @@ namespace frm { if ( IsWindowOrChild( _rNEvt.GetWindow() ) ) { - if ( MouseNotifyEvent::KEYINPUT == _rNEvt.GetType() ) + if ( NotifyEventType::KEYINPUT == _rNEvt.GetType() ) { const ::KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent(); @@ -280,7 +278,7 @@ namespace frm bool RichTextControl::EventNotify( NotifyEvent& _rNEvt ) { bool bDone = false; - if ( _rNEvt.GetType() == MouseNotifyEvent::COMMAND ) + if ( _rNEvt.GetType() == NotifyEventType::COMMAND ) { const CommandEvent& rEvent = *_rNEvt.GetCommandEvent(); bDone = m_pImpl->HandleCommand( rEvent ); diff --git a/forms/source/richtext/rtattributehandler.cxx b/forms/source/richtext/rtattributehandler.cxx index 653d42e46a5f..0075bd914119 100644 --- a/forms/source/richtext/rtattributehandler.cxx +++ b/forms/source/richtext/rtattributehandler.cxx @@ -108,7 +108,7 @@ namespace frm case SID_ATTR_CHAR_LATIN_WEIGHT: nWhich = EE_CHAR_WEIGHT; break; default: - nWhich = _rPool.GetWhich( static_cast<SfxSlotId>(_nAttributeId) ); + nWhich = _rPool.GetWhichIDFromSlotID( static_cast<SfxSlotId>(_nAttributeId) ); } return nWhich; } @@ -268,9 +268,9 @@ namespace frm :AttributeHandler( _nAttributeId, _nWhichId ) ,m_bScriptDependent( false ) { - m_bScriptDependent = ( SID_ATTR_CHAR_WEIGHT == _nAttributeId ) - || ( SID_ATTR_CHAR_POSTURE == _nAttributeId ) - || ( SID_ATTR_CHAR_FONT == _nAttributeId ); + m_bScriptDependent = ( sal_uInt16(SID_ATTR_CHAR_WEIGHT) == _nAttributeId ) + || ( sal_uInt16(SID_ATTR_CHAR_POSTURE) == _nAttributeId ) + || ( sal_uInt16(SID_ATTR_CHAR_FONT) == _nAttributeId ); } @@ -304,8 +304,8 @@ namespace frm FontSizeHandler::FontSizeHandler( AttributeId _nAttributeId, WhichId _nWhichId ) :AttributeHandler( _nAttributeId, _nWhichId ) { - OSL_ENSURE( ( _nAttributeId == SID_ATTR_CHAR_FONTHEIGHT ) || ( _nAttributeId == SID_ATTR_CHAR_CTL_FONTHEIGHT ) - || ( _nAttributeId == SID_ATTR_CHAR_CJK_FONTHEIGHT ) || ( _nAttributeId == SID_ATTR_CHAR_LATIN_FONTHEIGHT ), + OSL_ENSURE( ( _nAttributeId == sal_uInt16(SID_ATTR_CHAR_FONTHEIGHT) ) || ( _nAttributeId == sal_uInt16(SID_ATTR_CHAR_CTL_FONTHEIGHT) ) + || ( _nAttributeId == sal_uInt16(SID_ATTR_CHAR_CJK_FONTHEIGHT) ) || ( _nAttributeId == sal_uInt16(SID_ATTR_CHAR_LATIN_FONTHEIGHT) ), "FontSizeHandler::FontSizeHandler: invalid attribute id!" ); } @@ -320,7 +320,7 @@ namespace frm if ( pFontHeightItem ) { // by definition, the item should have the unit twip - sal_uLong nHeight = pFontHeightItem->GetHeight(); + sal_uInt32 nHeight = pFontHeightItem->GetHeight(); if ( _rAttribs.GetPool()->GetMetric( getWhich() ) != MapUnit::MapTwip ) { nHeight = OutputDevice::LogicToLogic( @@ -347,7 +347,7 @@ namespace frm if ( !pFontHeightItem ) return; - sal_uLong nHeight = pFontHeightItem->GetHeight(); + sal_uInt32 nHeight = pFontHeightItem->GetHeight(); if ( _rNewAttribs.GetPool()->GetMetric( getWhich() ) != MapUnit::MapTwip ) { nHeight = OutputDevice::LogicToLogic( @@ -360,7 +360,7 @@ namespace frm SvxFontHeightItem aNewItem( nHeight, 100, getWhich() ); aNewItem.SetProp( pFontHeightItem->GetProp(), pFontHeightItem->GetPropUnit() ); - if ( ( getAttributeId() == SID_ATTR_CHAR_FONTHEIGHT ) && _nForScriptType != SvtScriptType::NONE) + if ( ( getAttributeId() == sal_uInt16(SID_ATTR_CHAR_FONTHEIGHT) ) && _nForScriptType != SvtScriptType::NONE) putItemForScript( _rNewAttribs, aNewItem, _nForScriptType ); else _rNewAttribs.Put( aNewItem ); @@ -402,9 +402,8 @@ namespace frm // if the current adjustment of the was the default adjustment for the *previous* text direction, // then we toggle the adjustment, too SvxAdjust eCurrentAdjustment = SvxAdjust::Left; - const SfxPoolItem* pCurrentAdjustment = nullptr; - if ( SfxItemState::SET == _rCurrentAttribs.GetItemState( EE_PARA_JUST, true, &pCurrentAdjustment ) ) - eCurrentAdjustment = static_cast< const SvxAdjustItem* >( pCurrentAdjustment )->GetAdjust(); + if ( const SvxAdjustItem* pCurrentAdjustment = _rCurrentAttribs.GetItemIfSet( EE_PARA_JUST ) ) + eCurrentAdjustment = pCurrentAdjustment->GetAdjust(); if ( eCurrentAdjustment == m_eOppositeDefaultAdjustment ) _rNewAttribs.Put( SvxAdjustItem( m_eDefaultAdjustment, EE_PARA_JUST ) ); diff --git a/forms/source/richtext/rtattributes.hxx b/forms/source/richtext/rtattributes.hxx index b60ac6518562..fa00add450f4 100644 --- a/forms/source/richtext/rtattributes.hxx +++ b/forms/source/richtext/rtattributes.hxx @@ -112,6 +112,8 @@ namespace frm if ( pItemHandleItem == _rRHS.pItemHandleItem ) return true; + assert(pItemHandleItem && _rRHS.pItemHandleItem && "otherwise have already returned"); + return *pItemHandleItem == *_rRHS.pItemHandleItem; } diff --git a/forms/source/richtext/specialdispatchers.cxx b/forms/source/richtext/specialdispatchers.cxx index db7ef6807df8..283f0db8e09a 100644 --- a/forms/source/richtext/specialdispatchers.cxx +++ b/forms/source/richtext/specialdispatchers.cxx @@ -30,7 +30,6 @@ namespace frm using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::beans; @@ -58,7 +57,7 @@ namespace frm checkDisposed(); - EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : nullptr; + EditEngine* pEngine = getEditView() ? &getEditView()->getEditEngine() : nullptr; OSL_ENSURE( pEngine, "OSelectAllDispatcher::dispatch: no edit engine - but not yet disposed?" ); if ( !pEngine ) return; @@ -91,7 +90,7 @@ namespace frm { FeatureStateEvent aEvent( OAttributeDispatcher::buildStatusEvent() ); - EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : nullptr; + EditEngine* pEngine = getEditView() ? &getEditView()->getEditEngine() : nullptr; OSL_ENSURE( pEngine, "OParagraphDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" ); if ( pEngine && pEngine->IsEffectivelyVertical() ) aEvent.IsEnabled = false; @@ -112,7 +111,7 @@ namespace frm checkDisposed(); - EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : nullptr; + EditEngine* pEngine = getEditView() ? &getEditView()->getEditEngine() : nullptr; OSL_ENSURE( pEngine, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" ); if ( !pEngine ) return; @@ -125,7 +124,7 @@ namespace frm { FeatureStateEvent aEvent( ORichTextFeatureDispatcher::buildStatusEvent() ); - EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : nullptr; + EditEngine* pEngine = getEditView() ? &getEditView()->getEditEngine() : nullptr; OSL_ENSURE( pEngine, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" ); aEvent.IsEnabled = true; @@ -155,7 +154,7 @@ namespace frm { bool bEnable = true; OSL_VERIFY( pLookup->Value >>= bEnable ); - if ( m_nAttributeId == SID_ATTR_PARA_SCRIPTSPACE ) + if ( m_nAttributeId == sal_uInt16(SID_ATTR_PARA_SCRIPTSPACE) ) return new SvxScriptSpaceItem( bEnable, static_cast<WhichId>(m_nAttributeId) ); return new SfxBoolItem( static_cast<WhichId>(m_nAttributeId), bEnable ); } diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx index 2a87bb2bd2c9..1e3df2857e74 100644 --- a/forms/source/runtime/formoperations.cxx +++ b/forms/source/runtime/formoperations.cxx @@ -52,7 +52,7 @@ #include <vcl/svapp.hxx> #include <vcl/stdtext.hxx> #include <vcl/weld.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <comphelper/container.hxx> #include <comphelper/property.hxx> #include <comphelper/namedvaluecollection.hxx> @@ -86,7 +86,6 @@ namespace frm using namespace ::com::sun::star::sdbc; using ::com::sun::star::form::XForm; using ::com::sun::star::ucb::AlreadyInitializedException; - using ::com::sun::star::util::XModifyBroadcaster; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::lang::EventObject; using ::com::sun::star::beans::PropertyChangeEvent; @@ -105,7 +104,6 @@ namespace frm using namespace ::com::sun::star::sdb; using ::com::sun::star::form::XReset; using ::com::sun::star::beans::XMultiPropertySet; - using ::com::sun::star::uno::makeAny; using ::com::sun::star::lang::WrappedTargetException; using ::com::sun::star::ui::dialogs::XExecutableDialog; using ::com::sun::star::beans::NamedValue; @@ -430,26 +428,25 @@ namespace frm // returns false if parent should *abort* (user pressed cancel) bool checkConfirmation(bool &needConfirmation, bool &shouldCommit) { - if(needConfirmation) + if(!needConfirmation) + return true; + // TODO: shouldn't this be done with an interaction handler? + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + ResourceManager::loadString(RID_STR_QUERY_SAVE_MODIFIED_ROW))); + xQueryBox->add_button(GetStandardText(StandardButtonType::Cancel), RET_CANCEL); + xQueryBox->set_default_response(RET_YES); + + switch (xQueryBox->run()) { - // TODO: shouldn't this be done with an interaction handler? - std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, - VclMessageType::Question, VclButtonsType::YesNo, - FRM_RES_STRING(RID_STR_QUERY_SAVE_MODIFIED_ROW))); - xQueryBox->add_button(GetStandardText(StandardButtonType::Cancel), RET_CANCEL); - xQueryBox->set_default_response(RET_YES); - - switch (xQueryBox->run()) - { - case RET_NO: - shouldCommit = false; - [[fallthrough]]; // don't ask again! - case RET_YES: - needConfirmation = false; - return true; - case RET_CANCEL: - return false; - } + case RET_NO: + shouldCommit = false; + [[fallthrough]]; // don't ask again! + case RET_YES: + needConfirmation = false; + return true; + case RET_CANCEL: + return false; } return true; } @@ -721,15 +718,10 @@ namespace frm OSL_ENSURE( xProperties.is(), "FormOperations::execute: no multi property access!" ); if ( xProperties.is() ) { - Sequence< OUString > aNames( 3 ); - aNames[0] = PROPERTY_FILTER; - aNames[1] = PROPERTY_HAVINGCLAUSE; - aNames[2] = PROPERTY_SORT; + Sequence< OUString > aNames{ PROPERTY_FILTER, PROPERTY_HAVINGCLAUSE, + PROPERTY_SORT }; - Sequence< Any> aValues( 3 ); - aValues[0] <<= OUString(); - aValues[1] <<= OUString(); - aValues[2] <<= OUString(); + Sequence< Any> aValues{ Any(OUString()), Any(OUString()), Any(OUString()) }; weld::WaitObject aWO(Application::GetFrameWeld(GetDialogParent())); xProperties->setPropertyValues( aNames, aValues ); @@ -746,7 +738,7 @@ namespace frm // simply toggle the value bool bApplied = false; m_xCursorProperties->getPropertyValue( PROPERTY_APPLYFILTER ) >>= bApplied; - m_xCursorProperties->setPropertyValue( PROPERTY_APPLYFILTER, makeAny( !bApplied ) ); + m_xCursorProperties->setPropertyValue( PROPERTY_APPLYFILTER, Any( !bApplied ) ); // and reload weld::WaitObject aWO(Application::GetFrameWeld(GetDialogParent())); @@ -781,7 +773,7 @@ namespace frm pErrorResourceId = RID_STR_FEATURE_REQUIRES_PARAMETERS; else if ( !lcl_isExecutableFeature( _nFeature ) ) pErrorResourceId = RID_STR_FEATURE_NOT_EXECUTABLE; - throw IllegalArgumentException( FRM_RES_STRING( pErrorResourceId ), *this, 1 ); + throw IllegalArgumentException( ResourceManager::loadString(pErrorResourceId), *this, 1 ); } } // switch } @@ -809,7 +801,7 @@ namespace frm // at the moment we have only one feature which supports execution parameters if ( !lcl_isExecutableFeature( _nFeature ) ) - throw IllegalArgumentException( FRM_RES_STRING( RID_STR_FEATURE_NOT_EXECUTABLE ), *this, 1 ); + throw IllegalArgumentException( ResourceManager::loadString(RID_STR_FEATURE_NOT_EXECUTABLE), *this, 1 ); switch ( _nFeature ) { @@ -848,7 +840,7 @@ namespace frm } break; default: - throw IllegalArgumentException( FRM_RES_STRING( RID_STR_FEATURE_UNKNOWN ), *this, 1 ); + throw IllegalArgumentException( ResourceManager::loadString(RID_STR_FEATURE_UNKNOWN), *this, 1 ); } // switch } @@ -1552,12 +1544,12 @@ namespace frm m_xParser->setOrder( OUString() ); impl_appendOrderByColumn_throw aAction(this, xBoundField, _bUp); - impl_doActionInSQLContext_throw(aAction, RID_STR_COULD_NOT_SET_ORDER ); + impl_doActionInSQLContext_throw(std::move(aAction), RID_STR_COULD_NOT_SET_ORDER ); weld::WaitObject aWO(Application::GetFrameWeld(GetDialogParent())); try { - m_xCursorProperties->setPropertyValue( PROPERTY_SORT, makeAny( m_xParser->getOrder() ) ); + m_xCursorProperties->setPropertyValue( PROPERTY_SORT, Any( m_xParser->getOrder() ) ); m_xLoadableForm->reload(); } catch( const Exception& ) @@ -1571,7 +1563,7 @@ namespace frm try { m_xParser->setOrder( sOriginalSort ); - m_xCursorProperties->setPropertyValue( PROPERTY_SORT, makeAny( m_xParser->getOrder() ) ); + m_xCursorProperties->setPropertyValue( PROPERTY_SORT, Any( m_xParser->getOrder() ) ); m_xLoadableForm->reload(); } catch( const Exception& ) @@ -1623,14 +1615,14 @@ namespace frm } impl_appendFilterByColumn_throw aAction(this, m_xParser, xBoundField); - impl_doActionInSQLContext_throw( aAction, RID_STR_COULD_NOT_SET_FILTER ); + impl_doActionInSQLContext_throw( std::move(aAction), RID_STR_COULD_NOT_SET_FILTER ); weld::WaitObject aWO(Application::GetFrameWeld(GetDialogParent())); try { - m_xCursorProperties->setPropertyValue( PROPERTY_FILTER, makeAny( m_xParser->getFilter() ) ); - m_xCursorProperties->setPropertyValue( PROPERTY_HAVINGCLAUSE, makeAny( m_xParser->getHavingClause() ) ); - m_xCursorProperties->setPropertyValue( PROPERTY_APPLYFILTER, makeAny( true ) ); + m_xCursorProperties->setPropertyValue( PROPERTY_FILTER, Any( m_xParser->getFilter() ) ); + m_xCursorProperties->setPropertyValue( PROPERTY_HAVINGCLAUSE, Any( m_xParser->getHavingClause() ) ); + m_xCursorProperties->setPropertyValue( PROPERTY_APPLYFILTER, Any( true ) ); m_xLoadableForm->reload(); } @@ -1646,9 +1638,9 @@ namespace frm { m_xParser->setFilter ( sOriginalFilter ); m_xParser->setHavingClause( sOriginalHaving ); - m_xCursorProperties->setPropertyValue( PROPERTY_APPLYFILTER, makeAny( bApplied ) ); - m_xCursorProperties->setPropertyValue( PROPERTY_FILTER, makeAny( m_xParser->getFilter() ) ); - m_xCursorProperties->setPropertyValue( PROPERTY_HAVINGCLAUSE, makeAny( m_xParser->getHavingClause() ) ); + m_xCursorProperties->setPropertyValue( PROPERTY_APPLYFILTER, Any( bApplied ) ); + m_xCursorProperties->setPropertyValue( PROPERTY_FILTER, Any( m_xParser->getFilter() ) ); + m_xCursorProperties->setPropertyValue( PROPERTY_HAVINGCLAUSE, Any( m_xParser->getHavingClause() ) ); m_xLoadableForm->reload(); } catch( const Exception& ) @@ -1715,11 +1707,11 @@ namespace frm weld::WaitObject aWO(Application::GetFrameWeld(xDialogParent)); if ( _bFilter ) { - m_xCursorProperties->setPropertyValue( PROPERTY_FILTER, makeAny( m_xParser->getFilter() ) ); - m_xCursorProperties->setPropertyValue( PROPERTY_HAVINGCLAUSE, makeAny( m_xParser->getHavingClause() ) ); + m_xCursorProperties->setPropertyValue( PROPERTY_FILTER, Any( m_xParser->getFilter() ) ); + m_xCursorProperties->setPropertyValue( PROPERTY_HAVINGCLAUSE, Any( m_xParser->getHavingClause() ) ); } else - m_xCursorProperties->setPropertyValue( PROPERTY_SORT, makeAny( m_xParser->getOrder() ) ); + m_xCursorProperties->setPropertyValue( PROPERTY_SORT, Any( m_xParser->getOrder() ) ); m_xLoadableForm->reload(); } @@ -1747,7 +1739,7 @@ namespace frm throw; SQLExceptionInfo aInfo( ::cppu::getCaughtException() ); - OUString sAdditionalError( FRM_RES_STRING( pErrorResourceId ) ); + OUString sAdditionalError( ResourceManager::loadString(pErrorResourceId) ); aInfo.prepend( sAdditionalError ); aInfo.doThrow(); } @@ -1755,7 +1747,7 @@ namespace frm catch( const RuntimeException& ) { throw; } catch( const Exception& ) { - OUString sAdditionalError( FRM_RES_STRING( pErrorResourceId ) ); + OUString sAdditionalError( ResourceManager::loadString(pErrorResourceId) ); throw WrappedTargetException( sAdditionalError, *const_cast< FormOperations* >( this ), ::cppu::getCaughtException() ); } } diff --git a/forms/source/runtime/formoperations.hxx b/forms/source/runtime/formoperations.hxx index 182b0a7e0958..a8d0ec45a432 100644 --- a/forms/source/runtime/formoperations.hxx +++ b/forms/source/runtime/formoperations.hxx @@ -36,6 +36,7 @@ #include <connectivity/dbtools.hxx> #include <tools/long.hxx> #include <unotools/resmgr.hxx> +#include <utility> namespace frm { @@ -301,10 +302,10 @@ namespace frm { public: impl_appendOrderByColumn_throw(const FormOperations *pFO, - css::uno::Reference< css::beans::XPropertySet > const & xField, + css::uno::Reference< css::beans::XPropertySet > xField, bool bUp) : m_pFO(pFO) - , m_xField(xField) + , m_xField(std::move(xField)) , m_bUp(bUp) {}; @@ -320,11 +321,11 @@ namespace frm { public: impl_appendFilterByColumn_throw(const FormOperations *pFO, - css::uno::Reference< css::sdb::XSingleSelectQueryComposer > const & xParser, - css::uno::Reference< css::beans::XPropertySet > const & xField) + css::uno::Reference< css::sdb::XSingleSelectQueryComposer > xParser, + css::uno::Reference< css::beans::XPropertySet > xField) : m_pFO(pFO) - , m_xParser(xParser) - , m_xField(xField) + , m_xParser(std::move(xParser)) + , m_xField(std::move(xField)) {}; void operator()() { diff --git a/forms/source/solar/component/navbarcontrol.cxx b/forms/source/solar/component/navbarcontrol.cxx index af8c6d561d55..61671c0f363a 100644 --- a/forms/source/solar/component/navbarcontrol.cxx +++ b/forms/source/solar/component/navbarcontrol.cxx @@ -32,7 +32,7 @@ #include <com/sun/star/frame/ModuleManager.hpp> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> @@ -45,16 +45,8 @@ namespace frm using namespace ::com::sun::star::awt; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::frame; - using namespace ::com::sun::star::graphic; namespace FormFeature = ::com::sun::star::form::runtime::FormFeature; -#define FORWARD_TO_PEER_1( unoInterface, method, param1 ) \ - Reference< unoInterface > xTypedPeer( getPeer(), UNO_QUERY ); \ - if ( xTypedPeer.is() ) \ - { \ - xTypedPeer->method( param1 ); \ - } - ONavigationBarControl::ONavigationBarControl( const Reference< XComponentContext >& _rxORB) : m_xContext(_rxORB) { @@ -123,7 +115,7 @@ namespace frm vcl::Window* pParentWin = nullptr; if ( _rParentPeer.is() ) { - VCLXWindow* pParentXWin = comphelper::getFromUnoTunnel<VCLXWindow>( _rParentPeer ); + VCLXWindow* pParentXWin = dynamic_cast<VCLXWindow*>( _rParentPeer.get() ); if ( pParentXWin ) pParentWin = pParentXWin->GetWindow(); DBG_ASSERT( pParentWin, "ONavigationBarControl::createPeer: could not obtain the VCL-level parent window!" ); @@ -174,20 +166,32 @@ namespace frm void SAL_CALL ONavigationBarControl::registerDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) { - FORWARD_TO_PEER_1( XDispatchProviderInterception, registerDispatchProviderInterceptor, _rxInterceptor ); + Reference< XDispatchProviderInterception > xTypedPeer(getPeer(), UNO_QUERY); + if (xTypedPeer.is()) + { + xTypedPeer->registerDispatchProviderInterceptor(_rxInterceptor); + } } void SAL_CALL ONavigationBarControl::releaseDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) { - FORWARD_TO_PEER_1( XDispatchProviderInterception, releaseDispatchProviderInterceptor, _rxInterceptor ); + Reference< XDispatchProviderInterception > xTypedPeer(getPeer(), UNO_QUERY); + if (xTypedPeer.is()) + { + xTypedPeer->releaseDispatchProviderInterceptor(_rxInterceptor); + } } void SAL_CALL ONavigationBarControl::setDesignMode( sal_Bool _bOn ) { UnoControl::setDesignMode( _bOn ); - FORWARD_TO_PEER_1( XVclWindowPeer, setDesignMode, _bOn ); + Reference< XVclWindowPeer > xTypedPeer(getPeer(), UNO_QUERY); + if (xTypedPeer.is()) + { + xTypedPeer->setDesignMode(_bOn); + } } diff --git a/forms/source/solar/control/navtoolbar.cxx b/forms/source/solar/control/navtoolbar.cxx index 909c5d044502..7193ac4532c1 100644 --- a/forms/source/solar/control/navtoolbar.cxx +++ b/forms/source/solar/control/navtoolbar.cxx @@ -29,6 +29,7 @@ #include <svx/labelitemwindow.hxx> +#include <utility> #include <vcl/commandinfoprovider.hxx> #include <vcl/toolbox.hxx> @@ -44,7 +45,7 @@ namespace frm { - using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Any; namespace FormFeature = ::com::sun::star::form::runtime::FormFeature; @@ -58,7 +59,7 @@ namespace frm OUString getLabelString(TranslateId pResId) { - OUString sLabel( " " + FRM_RES_STRING(pResId) + " " ); + OUString sLabel( " " + ResourceManager::loadString(pResId) + " " ); return sLabel; } @@ -90,7 +91,6 @@ namespace frm if ( pAsciiCommandName != nullptr ) return ".uno:" + OUString::createFromAscii( pAsciiCommandName ); - OSL_FAIL( "lcl_getCommandURL: unknown FormFeature!" ); return OUString(); } } @@ -134,14 +134,14 @@ namespace frm } NavigationToolBar::NavigationToolBar( vcl::Window* _pParent, WinBits _nStyle, - const PCommandImageProvider& _pImageProvider, - const OUString & sModuleId ) + PCommandImageProvider _pImageProvider, + OUString sModuleId ) :Window( _pParent, _nStyle ) ,m_pDispatcher( nullptr ) - ,m_pImageProvider( _pImageProvider ) + ,m_pImageProvider(std::move( _pImageProvider )) ,m_eImageSize( eSmall ) ,m_pToolbar( nullptr ) - ,m_sModuleId( sModuleId ) + ,m_sModuleId(std::move( sModuleId )) { implInit( ); } @@ -278,13 +278,12 @@ namespace frm { // it's _not_ a separator // insert the entry - m_pToolbar->InsertItem( ToolBoxItemId(pSupportedFeatures->nId), OUString(), pSupportedFeatures->bRepeat ? ToolBoxItemBits::REPEAT : ToolBoxItemBits::NONE ); + OUString sCommandURL( lcl_getCommandURL( pSupportedFeatures->nId ) ); + m_pToolbar->InsertItem( ToolBoxItemId(pSupportedFeatures->nId), OUString(), sCommandURL, pSupportedFeatures->bRepeat ? ToolBoxItemBits::REPEAT : ToolBoxItemBits::NONE ); m_pToolbar->SetQuickHelpText( ToolBoxItemId(pSupportedFeatures->nId), OUString() ); // TODO if ( !isArtificialItem( pSupportedFeatures->nId ) ) { - OUString sCommandURL( lcl_getCommandURL( pSupportedFeatures->nId ) ); - m_pToolbar->SetItemCommand( ToolBoxItemId(pSupportedFeatures->nId), sCommandURL ); auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(sCommandURL, m_sModuleId); m_pToolbar->SetQuickHelpText(ToolBoxItemId(pSupportedFeatures->nId), vcl::CommandInfoProvider::GetLabelForCommand(aProperties)); @@ -342,10 +341,11 @@ namespace frm // translate them into command URLs css::uno::Sequence< OUString > aCommandURLs( aFormFeatures.size() ); + auto aCommandURLsRange = asNonConstRange(aCommandURLs); size_t i = 0; for (auto const& formFeature : aFormFeatures) { - aCommandURLs[i++] = lcl_getCommandURL(formFeature); + aCommandURLsRange[i++] = lcl_getCommandURL(formFeature); } // retrieve the images for the command URLs @@ -633,7 +633,7 @@ namespace frm { if (!m_pDispatcher) return; - m_pDispatcher->dispatchWithArgument( FormFeature::MoveAbsolute, "Position", makeAny( static_cast<sal_Int32>(nRecord) ) ); + m_pDispatcher->dispatchWithArgument( FormFeature::MoveAbsolute, "Position", Any( static_cast<sal_Int32>(nRecord) ) ); } } // namespace frm diff --git a/forms/source/solar/inc/navtoolbar.hxx b/forms/source/solar/inc/navtoolbar.hxx index 8d5113357e5f..18e0e806df34 100644 --- a/forms/source/solar/inc/navtoolbar.hxx +++ b/forms/source/solar/inc/navtoolbar.hxx @@ -60,8 +60,8 @@ namespace frm NavigationToolBar( vcl::Window* _pParent, WinBits _nStyle, - const PCommandImageProvider& _pImageProvider, - const OUString & sModuleId + PCommandImageProvider _pImageProvider, + OUString sModuleId ); virtual ~NavigationToolBar( ) override; virtual void dispose() override; diff --git a/forms/source/xforms/NameContainer.hxx b/forms/source/xforms/NameContainer.hxx index fc3064e9e2d5..7c1b50993dc4 100644 --- a/forms/source/xforms/NameContainer.hxx +++ b/forms/source/xforms/NameContainer.hxx @@ -100,7 +100,7 @@ public: typename map_t::const_iterator aIter = findItem( rName ); if( aIter == maItems.end() ) throw css::container::NoSuchElementException(); - return css::uno::makeAny( aIter->second ); + return css::uno::Any( aIter->second ); } virtual css::uno::Sequence<OUString> SAL_CALL getElementNames() override diff --git a/forms/source/xforms/binding.cxx b/forms/source/xforms/binding.cxx index 6d8735f6366c..c739126642c4 100644 --- a/forms/source/xforms/binding.cxx +++ b/forms/source/xforms/binding.cxx @@ -31,9 +31,10 @@ #include <strings.hrc> #include <rtl/ustrbuf.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <algorithm> #include <functional> @@ -70,7 +71,6 @@ using com::sun::star::form::binding::InvalidBindingStateException; using com::sun::star::form::binding::XValueBinding; using com::sun::star::lang::EventObject; using com::sun::star::lang::IndexOutOfBoundsException; -using com::sun::star::lang::XUnoTunnel; using com::sun::star::uno::Any; using com::sun::star::uno::Reference; using com::sun::star::uno::RuntimeException; @@ -79,7 +79,6 @@ using com::sun::star::uno::UNO_QUERY; using com::sun::star::uno::UNO_QUERY_THROW; using com::sun::star::uno::XInterface; using com::sun::star::uno::Exception; -using com::sun::star::uno::makeAny; using com::sun::star::util::XModifyListener; using com::sun::star::xforms::XDataTypeRepository; using com::sun::star::xml::dom::NodeType_ATTRIBUTE_NODE; @@ -90,9 +89,6 @@ using com::sun::star::xml::dom::events::XEventListener; using com::sun::star::xml::dom::events::XEventTarget; using com::sun::star::xsd::XDataType; - -#define EXCEPT(msg) msg,static_cast<XValueBinding*>(this) - #define HANDLE_BindingID 0 #define HANDLE_BindingExpression 1 #define HANDLE_Model 2 @@ -125,7 +121,7 @@ Binding::~Binding() _setModel(nullptr); } -void Binding::_setModel( const css::uno::Reference<css::xforms::XModel>& xModel ) +void Binding::_setModel( const rtl::Reference<Model>& xModel ) { PropertyChangeNotifier aNotifyModelChange( *this, HANDLE_Model ); PropertyChangeNotifier aNotifyModelIDChange( *this, HANDLE_ModelID ); @@ -146,8 +142,7 @@ void Binding::_setModel( const css::uno::Reference<css::xforms::XModel>& xModel OUString Binding::getModelID() const { - Model* pModel = getModelImpl(); - return ( pModel == nullptr ) ? OUString() : pModel->getID(); + return ( mxModel == nullptr ) ? OUString() : mxModel->getID(); } @@ -211,7 +206,14 @@ bool Binding::isValid() const { // TODO: determine whether node is suitable, not just whether it exists return maBindingExpression.getNode().is() && - isValid_DataType() && + ( + // tdf#155121, validity rules should be apply when field is required or + // when the field is not required but not empty + // so if the field is not required and empty, do not check validity + (! maMIP.isRequired() && maBindingExpression.hasValue() + && maBindingExpression.getString().isEmpty() ) || + isValid_DataType() + ) && maMIP.isConstraint() && ( ! maMIP.isRequired() || ( maBindingExpression.hasValue() && @@ -228,7 +230,7 @@ bool Binding::isUseful() const // 3) we are bound to some control // (this can be assumed if some listeners are set) bool bUseful = - getModelImpl() == nullptr + mxModel == nullptr // || msBindingID.getLength() > 0 || ! msTypeName.isEmpty() || ! maReadonly.isEmptyExpression() @@ -282,15 +284,15 @@ OUString Binding::explainInvalid() EvaluationContext Binding::getEvaluationContext() const { - OSL_ENSURE( getModelImpl() != nullptr, "need model impl" ); - EvaluationContext aContext = getModelImpl()->getEvaluationContext(); + OSL_ENSURE( mxModel != nullptr, "need model impl" ); + EvaluationContext aContext = mxModel->getEvaluationContext(); aContext.mxNamespaces = getBindingNamespaces(); return aContext; } ::std::vector<EvaluationContext> Binding::getMIPEvaluationContexts() { - OSL_ENSURE( getModelImpl() != nullptr, "need model impl" ); + OSL_ENSURE( mxModel != nullptr, "need model impl" ); // bind (in case we were not bound before) bind(); @@ -422,9 +424,8 @@ bool Binding::getExternalData() const try { - Reference< XPropertySet > xModelProps( mxModel, UNO_QUERY_THROW ); OSL_VERIFY( - xModelProps->getPropertyValue( "ExternalData" ) >>= bExternalData ); + mxModel->getPropertyValue( "ExternalData" ) >>= bExternalData ); } catch( const Exception& ) { @@ -437,19 +438,14 @@ bool Binding::getExternalData() const void Binding::checkLive() { if( ! isLive() ) - throw RuntimeException( EXCEPT("Binding not initialized") ); + throw RuntimeException("Binding not initialized", static_cast<XValueBinding*>(this)); } bool Binding::isLive() const { - const Model* pModel = getModelImpl(); - return pModel && pModel->isInitialized(); + return mxModel && mxModel->isInitialized(); } -Model* Binding::getModelImpl() const -{ - return comphelper::getFromUnoTunnel<Model>( mxModel ); -} static void lcl_addListenerToNode( const Reference<XNode>& xNode, const Reference<XEventListener>& xListener ) @@ -466,8 +462,6 @@ static void lcl_addListenerToNode( const Reference<XNode>& xNode, xListener, false ); xTarget->addEventListener( "DOMAttrModified", xListener, true ); - xTarget->addEventListener( "DOMAttrModified", - xListener, true ); xTarget->addEventListener( "xforms-generic", xListener, true ); } @@ -493,7 +487,7 @@ static void lcl_removeListenerFromNode( const Reference<XNode>& xNode, ::std::vector<EvaluationContext> Binding::_getMIPEvaluationContexts() const { - OSL_ENSURE( getModelImpl() != nullptr, "need model impl" ); + OSL_ENSURE( mxModel != nullptr, "need model impl" ); // iterate over nodes of bind expression and create // EvaluationContext for each @@ -504,7 +498,7 @@ static void lcl_removeListenerFromNode( const Reference<XNode>& xNode, OSL_ENSURE( node.is(), "no node?" ); // create proper evaluation context for this MIP - aVector.emplace_back( node, getModel(), getBindingNamespaces() ); + aVector.emplace_back( node, mxModel, getBindingNamespaces() ); } return aVector; } @@ -512,7 +506,7 @@ static void lcl_removeListenerFromNode( const Reference<XNode>& xNode, void Binding::bind( bool bForceRebind ) { if( ! mxModel.is() ) - throw RuntimeException( EXCEPT("Binding has no Model") ); + throw RuntimeException("Binding has no Model", static_cast<XValueBinding*>(this)); // bind() will evaluate this binding as follows: // 1) evaluate the binding expression @@ -561,9 +555,8 @@ void Binding::bind( bool bForceRebind ) } // 3) remove old MIPs defined by this binding - Model* pModel = getModelImpl(); - OSL_ENSURE( pModel != nullptr, "need model" ); - pModel->removeMIPs( this ); + OSL_ENSURE( mxModel != nullptr, "need model" ); + mxModel->removeMIPs( this ); // 4) calculate all MIPs ::std::vector<EvaluationContext> aMIPContexts = _getMIPEvaluationContexts(); @@ -579,7 +572,7 @@ void Binding::bind( bool bForceRebind ) { mbInCalculate = true; maCalculate.evaluate( rContext ); - pModel->setSimpleContent( rContext.mxContextNode, + mxModel->setSimpleContent( rContext.mxContextNode, maCalculate.getString() ); mbInCalculate = false; } @@ -593,7 +586,7 @@ void Binding::bind( bool bForceRebind ) // type is static; does not need updating // evaluate the locally defined MIPs, and push them to the model - pModel->addMIP( this, rContext.mxContextNode, getLocalMIP() ); + mxModel->addMIP( this, rContext.mxContextNode, getLocalMIP() ); } } @@ -636,7 +629,7 @@ void Binding::valueModified() // query MIP used by our first node (also note validity) Reference<XNode> xNode = maBindingExpression.getNode(); - maMIP = getModelImpl()->queryMIP( xNode ); + maMIP = mxModel->queryMIP( xNode ); // distribute MIPs _used_ by this binding if( xNode.is() ) @@ -737,11 +730,11 @@ MIP Binding::getLocalMIP() const css::uno::Reference<css::xsd::XDataType> Binding::getDataType() const { - OSL_ENSURE( getModel().is(), "need model" ); - OSL_ENSURE( getModel()->getDataTypeRepository().is(), "need types" ); + OSL_ENSURE( mxModel.is(), "need model" ); + OSL_ENSURE( mxModel->getDataTypeRepository().is(), "need types" ); Reference<XDataTypeRepository> xRepository = - getModel()->getDataTypeRepository(); + mxModel->getDataTypeRepository(); OUString sTypeName = maMIP.getTypeName(); return ( xRepository.is() && xRepository->hasByName( sTypeName ) ) @@ -767,9 +760,8 @@ OUString Binding::explainInvalid_DataType() void Binding::clear() { // remove MIPs contributed by this binding - Model* pModel = getModelImpl(); - if( pModel != nullptr ) - pModel->removeMIPs( this ); + if( mxModel != nullptr ) + mxModel->removeMIPs( this ); // remove all references for (auto const& eventNode : maEventNodes) @@ -858,9 +850,8 @@ css::uno::Reference<css::container::XNameContainer> Binding::_getNamespaces() co lcl_copyNamespaces( mxNamespaces, xNamespaces, true ); // merge model's with binding's own namespaces - Model* pModel = getModelImpl(); - if( pModel != nullptr ) - lcl_copyNamespaces( pModel->getNamespaces(), xNamespaces, false ); + if( mxModel != nullptr ) + lcl_copyNamespaces( mxModel->getNamespaces(), xNamespaces, false ); return xNamespaces; } @@ -870,11 +861,10 @@ css::uno::Reference<css::container::XNameContainer> Binding::_getNamespaces() co void Binding::_setNamespaces( const css::uno::Reference<css::container::XNameContainer>& rNamespaces, bool bBinding ) { - Model* pModel = getModelImpl(); - css::uno::Reference<css::container::XNameContainer> xModelNamespaces = ( pModel != nullptr ) - ? pModel->getNamespaces() + css::uno::Reference<css::container::XNameContainer> xModelNamespaces = ( mxModel != nullptr ) + ? mxModel->getNamespaces() : nullptr; - OSL_ENSURE( ( pModel != nullptr ) == xModelNamespaces.is(), "no model nmsp?"); + OSL_ENSURE( ( mxModel != nullptr ) == xModelNamespaces.is(), "no model nmsp?"); // remove deleted namespaces lcl_removeOtherNamespaces( rNamespaces, mxNamespaces ); @@ -923,10 +913,10 @@ void Binding::_setNamespaces( const css::uno::Reference<css::container::XNameCon void Binding::_checkBindingID() { - if( !getModel().is() ) + if( !mxModel.is() ) return; - Reference<XNameAccess> xBindings( getModel()->getBindings(), UNO_QUERY_THROW ); + Reference<XNameAccess> xBindings( mxModel->getBindings(), UNO_QUERY_THROW ); if( !msBindingID.isEmpty() ) return; @@ -964,7 +954,7 @@ css::uno::Any Binding::getValue( const css::uno::Type& rType ) // second, check for type if( ! supportsType( rType ) ) - throw IncompatibleTypesException( EXCEPT( "type unsupported" ) ); + throw IncompatibleTypesException("type unsupported", static_cast<XValueBinding*>(this)); // return string value (if present; else return empty Any) css::uno::Any result; @@ -984,19 +974,19 @@ void Binding::setValue( const css::uno::Any& aValue ) // check for supported type if( ! supportsType( aValue.getValueType() ) ) - throw IncompatibleTypesException( EXCEPT( "type unsupported" ) ); + throw IncompatibleTypesException("type unsupported", static_cast<XValueBinding*>(this)); if( !maBindingExpression.hasValue() ) - throw InvalidBindingStateException( EXCEPT( "no suitable node found" ) ); + throw InvalidBindingStateException("no suitable node found", static_cast<XValueBinding*>(this)); css::uno::Reference<css::xml::dom::XNode> xNode = maBindingExpression.getNode(); if( !xNode.is() ) - throw InvalidBindingStateException( EXCEPT( "no suitable node found" ) ); + throw InvalidBindingStateException("no suitable node found", static_cast<XValueBinding*>(this)); OUString sValue = Convert::get().toXSD( aValue ); - bool bSuccess = getModelImpl()->setSimpleContent( xNode, sValue ); + bool bSuccess = mxModel->setSimpleContent( xNode, sValue ); if( ! bSuccess ) - throw InvalidBindingStateException( EXCEPT( "can't set value" ) ); + throw InvalidBindingStateException("can't set value", static_cast<XValueBinding*>(this)); } @@ -1046,8 +1036,8 @@ OUString Binding::getListEntry( sal_Int32 nPosition ) // check bounds and return proper item PathExpression::NodeVector_t aNodes = maBindingExpression.getNodeList(); - if( nPosition < 0 || nPosition >= static_cast<sal_Int32>( aNodes.size() ) ) - throw IndexOutOfBoundsException( EXCEPT("") ); + if( nPosition < 0 || o3tl::make_unsigned(nPosition) >= aNodes.size() ) + throw IndexOutOfBoundsException("", static_cast<XValueBinding*>(this)); return lcl_getString( aNodes[ nPosition ] ); } @@ -1177,9 +1167,8 @@ css::uno::Reference<css::util::XCloneable> SAL_CALL Binding::createClone() { Reference< XPropertySet > xClone; - Model* pModel = getModelImpl(); - if ( pModel ) - xClone = pModel->cloneBinding( this ); + if ( mxModel ) + xClone = mxModel->cloneBinding( this ); else { xClone = new Binding; @@ -1188,39 +1177,59 @@ css::uno::Reference<css::util::XCloneable> SAL_CALL Binding::createClone() return css::uno::Reference<css::util::XCloneable>( xClone, UNO_QUERY ); } +css::uno::Reference<css::xforms::XModel> Binding::getModel() const +{ + return mxModel; +} // property set implementations +void Binding::initializePropertySet() +{ + registerProperty( css::beans::Property("BindingID", HANDLE_BindingID, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Binding, OUString >(this, &Binding::setBindingID, &Binding::getBindingID)); -#define REGISTER_PROPERTY( property, type ) \ - registerProperty( PROPERTY( property, type ), \ - new DirectPropertyAccessor< Binding, type >( this, &Binding::set##property, &Binding::get##property ) ); + registerProperty( css::beans::Property("BindingExpression", HANDLE_BindingExpression, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Binding, OUString >(this, &Binding::setBindingExpression, &Binding::getBindingExpression)); -#define REGISTER_PROPERTY_RO( property, type ) \ - registerProperty( PROPERTY_RO( property, type ), \ - new DirectPropertyAccessor< Binding, type >( this, nullptr, &Binding::get##property ) ); + registerProperty( css::beans::Property("Model", HANDLE_Model, cppu::UnoType<css::uno::Reference<css::xforms::XModel>>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::READONLY ), + new DirectPropertyAccessor< Binding, css::uno::Reference<css::xforms::XModel> >(this, nullptr, &Binding::getModel)); -#define REGISTER_BOOL_PROPERTY_RO( property ) \ - registerProperty( PROPERTY_RO( property, sal_Bool ), \ - new BooleanPropertyAccessor< Binding >( this, nullptr, &Binding::get##property ) ); + registerProperty( css::beans::Property("BindingNamespaces", HANDLE_BindingNamespaces, cppu::UnoType<css::uno::Reference<css::container::XNameContainer>>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Binding, css::uno::Reference<css::container::XNameContainer> >(this, &Binding::setBindingNamespaces, &Binding::getBindingNamespaces)); -void Binding::initializePropertySet() -{ - REGISTER_PROPERTY ( BindingID, OUString ); - REGISTER_PROPERTY ( BindingExpression, OUString ); - REGISTER_PROPERTY_RO ( Model, css::uno::Reference<css::xforms::XModel> ); - REGISTER_PROPERTY ( BindingNamespaces, css::uno::Reference<css::container::XNameContainer> ); - REGISTER_PROPERTY ( ModelNamespaces, css::uno::Reference<css::container::XNameContainer> ); - REGISTER_PROPERTY_RO ( ModelID, OUString ); - REGISTER_PROPERTY ( ReadonlyExpression, OUString ); - REGISTER_PROPERTY ( RelevantExpression, OUString ); - REGISTER_PROPERTY ( RequiredExpression, OUString ); - REGISTER_PROPERTY ( ConstraintExpression, OUString ); - REGISTER_PROPERTY ( CalculateExpression, OUString ); - REGISTER_PROPERTY ( Type, OUString ); - REGISTER_PROPERTY_RO ( ReadOnly, bool ); - REGISTER_PROPERTY_RO ( Relevant, bool ); - REGISTER_BOOL_PROPERTY_RO( ExternalData ); + registerProperty( css::beans::Property("ModelNamespaces", HANDLE_ModelNamespaces, cppu::UnoType<css::uno::Reference<css::container::XNameContainer>>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Binding, css::uno::Reference<css::container::XNameContainer> >(this, &Binding::setModelNamespaces, &Binding::getModelNamespaces)); + + registerProperty( css::beans::Property("ModelID", HANDLE_ModelID, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::READONLY ), + new DirectPropertyAccessor< Binding, OUString >(this, nullptr, &Binding::getModelID)); + + registerProperty( css::beans::Property("ReadonlyExpression", HANDLE_ReadonlyExpression, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Binding, OUString >(this, &Binding::setReadonlyExpression, &Binding::getReadonlyExpression)); + + registerProperty( css::beans::Property("RelevantExpression", HANDLE_RelevantExpression, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Binding, OUString >(this, &Binding::setRelevantExpression, &Binding::getRelevantExpression)); + + registerProperty( css::beans::Property("RequiredExpression", HANDLE_RequiredExpression, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Binding, OUString >(this, &Binding::setRequiredExpression, &Binding::getRequiredExpression)); + + registerProperty( css::beans::Property("ConstraintExpression", HANDLE_ConstraintExpression, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Binding, OUString >(this, &Binding::setConstraintExpression, &Binding::getConstraintExpression)); + + registerProperty( css::beans::Property("CalculateExpression", HANDLE_CalculateExpression, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Binding, OUString >(this, &Binding::setCalculateExpression, &Binding::getCalculateExpression)); + + registerProperty( css::beans::Property("Type", HANDLE_Type, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Binding, OUString >(this, &Binding::setType, &Binding::getType)); + + registerProperty( css::beans::Property("ReadOnly", HANDLE_ReadOnly, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::READONLY ), + new DirectPropertyAccessor< Binding, bool >(this, nullptr, &Binding::getReadOnly)); + + registerProperty( css::beans::Property("Relevant", HANDLE_Relevant, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::READONLY ), + new DirectPropertyAccessor< Binding, bool >(this, nullptr, &Binding::getRelevant)); + + registerProperty( css::beans::Property("ExternalData", HANDLE_ExternalData, cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::READONLY ), + new BooleanPropertyAccessor< Binding >(this, nullptr, &Binding::getExternalData)); initializePropertyValueCache( HANDLE_ReadOnly ); initializePropertyValueCache( HANDLE_Relevant ); @@ -1260,7 +1269,7 @@ void SAL_CALL Binding::setName( const OUString& rName ) { // use the XPropertySet methods, so the change in the name is notified to the // property listeners - setFastPropertyValue( HANDLE_BindingID, makeAny( rName ) ); + setFastPropertyValue( HANDLE_BindingID, Any( rName ) ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/xforms/binding.hxx b/forms/source/xforms/binding.hxx index d7201a5b5246..76b478b944a4 100644 --- a/forms/source/xforms/binding.hxx +++ b/forms/source/xforms/binding.hxx @@ -35,6 +35,7 @@ #include "boolexpression.hxx" #include "mip.hxx" #include <rtl/ustring.hxx> +#include <rtl/ref.hxx> #include <vector> // forward declaractions @@ -94,7 +95,7 @@ public: private: /// the Model to which this Binding belongs; may be NULL - css::uno::Reference<css::xforms::XModel> mxModel; + rtl::Reference<Model> mxModel; /// binding-ID. A document-wide unique ID for this binding element. OUString msBindingID; @@ -162,8 +163,9 @@ public: // property methods: get/set value - css::uno::Reference<css::xforms::XModel> getModel() const { return mxModel;} /// get XForms model - void _setModel( const css::uno::Reference<css::xforms::XModel>& ); /// set XForms model (only called by Model) + /// get the model implementation + css::uno::Reference<css::xforms::XModel> getModel() const; /// get XForms model + void _setModel( const rtl::Reference<Model>& ); /// set XForms model (only called by Model) OUString getModelID() const; /// get ID of XForms model @@ -270,9 +272,6 @@ private: /// live: has model, and model has been initialized bool isLive() const; - /// get the model implementation - xforms::Model* getModelImpl() const; - /// get MIP evaluation contexts /// (only valid if control has already been bound) std::vector<xforms::EvaluationContext> _getMIPEvaluationContexts() const; diff --git a/forms/source/xforms/collection.hxx b/forms/source/xforms/collection.hxx index 19eb1b983f4c..5cd9f6aeb3db 100644 --- a/forms/source/xforms/collection.hxx +++ b/forms/source/xforms/collection.hxx @@ -106,7 +106,7 @@ public: bool hasItems() const { - return maItems.size() != 0; + return !maItems.empty(); } sal_Int32 countItems() const @@ -161,7 +161,7 @@ public: { if( !isValidIndex( nIndex ) ) throw css::lang::IndexOutOfBoundsException(); - return css::uno::makeAny( getItem( nIndex ) ); + return css::uno::Any( getItem( nIndex ) ); } // XIndexReplace : XIndexAccess @@ -239,8 +239,8 @@ protected: OSL_ENSURE( isValidIndex(nPos), "invalid index" ); css::container::ContainerEvent aEvent( static_cast<css::container::XIndexReplace*>( this ), - css::uno::makeAny( nPos ), - css::uno::makeAny( getItem( nPos ) ), + css::uno::Any( nPos ), + css::uno::Any( getItem( nPos ) ), css::uno::Any() ); for (auto const& listener : maListeners) { @@ -253,7 +253,7 @@ protected: css::container::ContainerEvent aEvent( static_cast<css::container::XIndexReplace*>( this ), css::uno::Any(), - css::uno::makeAny( aOld ), + css::uno::Any( aOld ), css::uno::Any() ); for (auto const& listener : maListeners) { @@ -266,9 +266,9 @@ protected: OSL_ENSURE( isValidIndex(nPos), "invalid index" ); css::container::ContainerEvent aEvent( static_cast<css::container::XIndexReplace*>( this ), - css::uno::makeAny( nPos ), - css::uno::makeAny( getItem( nPos ) ), - css::uno::makeAny( aNew ) ); + css::uno::Any( nPos ), + css::uno::Any( getItem( nPos ) ), + css::uno::Any( aNew ) ); for (auto const& listener : maListeners) { listener->elementReplaced( aEvent ); diff --git a/forms/source/xforms/convert.cxx b/forms/source/xforms/convert.cxx index acaac1bd7ba8..0f7193422fa5 100644 --- a/forms/source/xforms/convert.cxx +++ b/forms/source/xforms/convert.cxx @@ -25,6 +25,7 @@ #include <rtl/ustrbuf.hxx> #include <osl/diagnose.h> #include <tools/date.hxx> +#include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/uno/Type.hxx> #include <com/sun/star/util/Date.hpp> #include <com/sun/star/util/DateTime.hpp> @@ -34,7 +35,6 @@ using xforms::Convert; using com::sun::star::uno::Any; -using com::sun::star::uno::makeAny; using namespace utl; Convert::Convert() @@ -42,8 +42,6 @@ Convert::Convert() init(); } -#define ADD_ENTRY(XCONVERT,TYPE) XCONVERT->maMap[ cppu::UnoType<TYPE>::get() ] = Convert_t( &lcl_toXSD_##TYPE, &lcl_toAny_##TYPE ) - namespace { @@ -54,18 +52,15 @@ namespace Any lcl_toAny_OUString( const OUString& rStr ) { return Any(rStr); } - OUString lcl_toXSD_bool( const Any& rAny ) { bool b = false; rAny >>= b; return b ? OUString("true") : OUString("false"); } - Any lcl_toAny_bool( const OUString& rStr ) { bool b = ( rStr == "true" || rStr == "1" ); - return makeAny( b ); + return Any( b ); } - OUString lcl_toXSD_double( const Any& rAny ) { double f = 0.0; @@ -83,11 +78,10 @@ namespace { rtl_math_ConversionStatus eStatus; double f = rtl::math::stringToDouble( - rString, '.', ',', &eStatus ); - return ( eStatus == rtl_math_ConversionStatus_Ok ) ? makeAny( f ) : Any(); + rString.replace(',','.'), '.', ',', &eStatus ); + return ( eStatus == rtl_math_ConversionStatus_Ok ) ? Any( f ) : Any(); } - void lcl_appendInt32ToBuffer( const sal_Int32 _nValue, OUStringBuffer& _rBuffer, sal_Int16 _nMinDigits ) { if ( ( _nMinDigits >= 4 ) && ( _nValue < 1000 ) ) @@ -122,7 +116,7 @@ namespace } - css::util::Date lcl_toUNODate( const OUString& rString ) + css::util::Date lcl_toUNODate( std::u16string_view rString ) { css::util::Date aDate( 1, 1, 1900 ); @@ -140,7 +134,7 @@ namespace // all okay? if ( !bWellformed ) - return css::util::Date( 1, 1, 1900 ); + throw com::sun::star::lang::IllegalArgumentException(); return aDate; } @@ -148,7 +142,7 @@ namespace Any lcl_toAny_UNODate( const OUString& rString ) { - return makeAny( lcl_toUNODate( rString ) ); + return Any( lcl_toUNODate( rString ) ); } @@ -169,7 +163,7 @@ namespace ostr.fill('0'); ostr.width(9); ostr << rTime.NanoSeconds; - sInfo.append(OUString::createFromAscii(ostr.str().c_str())); + sInfo.appendAscii(ostr.str().c_str()); } return sInfo.makeStringAndClear(); @@ -184,7 +178,7 @@ namespace } - css::util::Time lcl_toUNOTime( const OUString& rString ) + css::util::Time lcl_toUNOTime( std::u16string_view rString ) { css::util::Time aTime; @@ -210,7 +204,7 @@ namespace // all okay? if ( !bWellformed ) - return css::util::Time(); + throw com::sun::star::lang::IllegalArgumentException(); return aTime; } @@ -218,7 +212,7 @@ namespace Any lcl_toAny_UNOTime( const OUString& rString ) { - return makeAny( lcl_toUNOTime( rString ) ); + return Any( lcl_toUNOTime( rString ) ); } @@ -254,23 +248,23 @@ namespace } else { - aDate = lcl_toUNODate( rString.copy( 0, nDateTimeSep ) ); - aTime = lcl_toUNOTime( rString.copy( nDateTimeSep + 1 ) ); + aDate = lcl_toUNODate( rString.subView( 0, nDateTimeSep ) ); + aTime = lcl_toUNOTime( rString.subView( nDateTimeSep + 1 ) ); } css::util::DateTime aDateTime( aTime.NanoSeconds, aTime.Seconds, aTime.Minutes, aTime.Hours, aDate.Day, aDate.Month, aDate.Year, aTime.IsUTC ); - return makeAny( aDateTime ); + return Any( aDateTime ); } } void Convert::init() { - ADD_ENTRY( this, OUString ); - ADD_ENTRY( this, bool ); - ADD_ENTRY( this, double ); + maMap[ cppu::UnoType<OUString>::get() ] = Convert_t(&lcl_toXSD_OUString, &lcl_toAny_OUString); + maMap[ cppu::UnoType<bool>::get() ] = Convert_t(&lcl_toXSD_bool, &lcl_toAny_bool); + maMap[ cppu::UnoType<double>::get() ] = Convert_t(&lcl_toXSD_double, &lcl_toAny_double); maMap[ cppu::UnoType<css::util::Date>::get() ] = Convert_t( &lcl_toXSD_UNODate, &lcl_toAny_UNODate ); maMap[ cppu::UnoType<css::util::Time>::get() ] = Convert_t( &lcl_toXSD_UNOTime, &lcl_toAny_UNOTime ); maMap[ cppu::UnoType<css::util::DateTime>::get() ] = Convert_t( &lcl_toXSD_UNODateTime, &lcl_toAny_UNODateTime ); diff --git a/forms/source/xforms/datatyperepository.cxx b/forms/source/xforms/datatyperepository.cxx index 22a56ce545ee..aba911c3f714 100644 --- a/forms/source/xforms/datatyperepository.cxx +++ b/forms/source/xforms/datatyperepository.cxx @@ -36,7 +36,6 @@ namespace xforms using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Type; - using ::com::sun::star::uno::makeAny; using ::com::sun::star::uno::Sequence; using ::com::sun::star::util::VetoException; using ::com::sun::star::container::NoSuchElementException; @@ -49,40 +48,40 @@ namespace xforms { // insert some basic types - OUString sName( FRM_RES_STRING( RID_STR_DATATYPE_STRING ) ); + OUString sName( ResourceManager::loadString(RID_STR_DATATYPE_STRING) ); m_aRepository[ sName ] = new OStringType( sName, css::xsd::DataTypeClass::STRING ); - sName = FRM_RES_STRING( RID_STR_DATATYPE_URL ); - m_aRepository[ sName ] = new OStringType( sName, css::xsd::DataTypeClass::anyURI ); + sName = ResourceManager::loadString(RID_STR_DATATYPE_URL); + m_aRepository[ sName ] = new OAnyURIType( sName, css::xsd::DataTypeClass::anyURI ); - sName = FRM_RES_STRING( RID_STR_DATATYPE_BOOLEAN ); + sName = ResourceManager::loadString(RID_STR_DATATYPE_BOOLEAN); m_aRepository[ sName ] = new OBooleanType( sName ); - sName = FRM_RES_STRING( RID_STR_DATATYPE_DECIMAL ); + sName = ResourceManager::loadString(RID_STR_DATATYPE_DECIMAL); m_aRepository[ sName ] = new ODecimalType( sName, css::xsd::DataTypeClass::DECIMAL ); - sName = FRM_RES_STRING( RID_STR_DATATYPE_FLOAT ); + sName = ResourceManager::loadString(RID_STR_DATATYPE_FLOAT); m_aRepository[ sName ] = new ODecimalType( sName, css::xsd::DataTypeClass::FLOAT ); - sName = FRM_RES_STRING( RID_STR_DATATYPE_DOUBLE ); + sName = ResourceManager::loadString(RID_STR_DATATYPE_DOUBLE); m_aRepository[ sName ] = new ODecimalType( sName, css::xsd::DataTypeClass::DOUBLE ); - sName = FRM_RES_STRING( RID_STR_DATATYPE_DATE ); + sName = ResourceManager::loadString(RID_STR_DATATYPE_DATE); m_aRepository[ sName ] = new ODateType( sName ); - sName = FRM_RES_STRING( RID_STR_DATATYPE_TIME ); + sName = ResourceManager::loadString(RID_STR_DATATYPE_TIME); m_aRepository[ sName ] = new OTimeType( sName ); - sName = FRM_RES_STRING( RID_STR_DATATYPE_DATETIME ); + sName = ResourceManager::loadString(RID_STR_DATATYPE_DATETIME); m_aRepository[ sName ] = new ODateTimeType( sName ); - sName = FRM_RES_STRING( RID_STR_DATATYPE_YEAR ); + sName = ResourceManager::loadString(RID_STR_DATATYPE_YEAR); m_aRepository[ sName ] = new OShortIntegerType( sName, css::xsd::DataTypeClass::gYear ); - sName = FRM_RES_STRING( RID_STR_DATATYPE_MONTH ); + sName = ResourceManager::loadString(RID_STR_DATATYPE_MONTH); m_aRepository[ sName ] = new OShortIntegerType( sName, css::xsd::DataTypeClass::gMonth ); - sName = FRM_RES_STRING( RID_STR_DATATYPE_DAY ); + sName = ResourceManager::loadString(RID_STR_DATATYPE_DAY); m_aRepository[ sName ] = new OShortIntegerType( sName, css::xsd::DataTypeClass::gDay ); } @@ -145,7 +144,7 @@ namespace xforms Repository::iterator aTypePos = implLocate( typeName ); if ( aTypePos->second->getIsBasic() ) // "This is a built-in type and cannot be removed." - throw VetoException(FRM_RES_STRING( RID_STR_XFORMS_CANT_REMOVE_TYPE ), *this ); + throw VetoException(ResourceManager::loadString(RID_STR_XFORMS_CANT_REMOVE_TYPE), *this ); m_aRepository.erase( aTypePos ); } @@ -166,7 +165,7 @@ namespace xforms Any SAL_CALL ODataTypeRepository::getByName( const OUString& aName ) { - return makeAny( getDataType( aName ) ); + return Any( getDataType( aName ) ); } @@ -205,10 +204,17 @@ namespace xforms { OValueLimitedType_Base::registerProperties(); - REGISTER_VOID_PROP( XSD_MAX_INCLUSIVE_DATE, m_aMaxInclusive, ValueType ); - REGISTER_VOID_PROP( XSD_MAX_EXCLUSIVE_DATE, m_aMaxExclusive, ValueType ); - REGISTER_VOID_PROP( XSD_MIN_INCLUSIVE_DATE, m_aMinInclusive, ValueType ); - REGISTER_VOID_PROP( XSD_MIN_EXCLUSIVE_DATE, m_aMinExclusive, ValueType ); + registerMayBeVoidProperty( PROPERTY_XSD_MAX_INCLUSIVE_DATE, PROPERTY_ID_XSD_MAX_INCLUSIVE_DATE, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMaxInclusive, cppu::UnoType<ValueType>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MAX_EXCLUSIVE_DATE, PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMaxExclusive, cppu::UnoType<ValueType>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MIN_INCLUSIVE_DATE, PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMinInclusive, cppu::UnoType<ValueType>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MIN_EXCLUSIVE_DATE, PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMinExclusive, cppu::UnoType<ValueType>::get() ); } template<> @@ -216,10 +222,17 @@ namespace xforms { OValueLimitedType_Base::registerProperties(); - REGISTER_VOID_PROP( XSD_MAX_INCLUSIVE_TIME, m_aMaxInclusive, ValueType ); - REGISTER_VOID_PROP( XSD_MAX_EXCLUSIVE_TIME, m_aMaxExclusive, ValueType ); - REGISTER_VOID_PROP( XSD_MIN_INCLUSIVE_TIME, m_aMinInclusive, ValueType ); - REGISTER_VOID_PROP( XSD_MIN_EXCLUSIVE_TIME, m_aMinExclusive, ValueType ); + registerMayBeVoidProperty( PROPERTY_XSD_MAX_INCLUSIVE_TIME, PROPERTY_ID_XSD_MAX_INCLUSIVE_TIME, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMaxInclusive, cppu::UnoType<ValueType>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MAX_EXCLUSIVE_TIME, PROPERTY_ID_XSD_MAX_EXCLUSIVE_TIME, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMaxExclusive, cppu::UnoType<ValueType>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MIN_INCLUSIVE_TIME, PROPERTY_ID_XSD_MIN_INCLUSIVE_TIME, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMinInclusive, cppu::UnoType<ValueType>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MIN_EXCLUSIVE_TIME, PROPERTY_ID_XSD_MIN_EXCLUSIVE_TIME, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMinExclusive, cppu::UnoType<ValueType>::get() ); } template<> @@ -227,10 +240,17 @@ namespace xforms { OValueLimitedType_Base::registerProperties(); - REGISTER_VOID_PROP( XSD_MAX_INCLUSIVE_DATE_TIME, m_aMaxInclusive, ValueType ); - REGISTER_VOID_PROP( XSD_MAX_EXCLUSIVE_DATE_TIME, m_aMaxExclusive, ValueType ); - REGISTER_VOID_PROP( XSD_MIN_INCLUSIVE_DATE_TIME, m_aMinInclusive, ValueType ); - REGISTER_VOID_PROP( XSD_MIN_EXCLUSIVE_DATE_TIME, m_aMinExclusive, ValueType ); + registerMayBeVoidProperty( PROPERTY_XSD_MAX_INCLUSIVE_DATE_TIME, PROPERTY_ID_XSD_MAX_INCLUSIVE_DATE_TIME, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMaxInclusive, cppu::UnoType<ValueType>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MAX_EXCLUSIVE_DATE_TIME, PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE_TIME, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMaxExclusive, cppu::UnoType<ValueType>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MIN_INCLUSIVE_DATE_TIME, PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE_TIME, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMinInclusive, cppu::UnoType<ValueType>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MIN_EXCLUSIVE_DATE_TIME, PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE_TIME, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMinExclusive, cppu::UnoType<ValueType>::get() ); } template<> @@ -238,10 +258,17 @@ namespace xforms { OValueLimitedType_Base::registerProperties(); - REGISTER_VOID_PROP( XSD_MAX_INCLUSIVE_DOUBLE, m_aMaxInclusive, ValueType ); - REGISTER_VOID_PROP( XSD_MAX_EXCLUSIVE_DOUBLE, m_aMaxExclusive, ValueType ); - REGISTER_VOID_PROP( XSD_MIN_INCLUSIVE_DOUBLE, m_aMinInclusive, ValueType ); - REGISTER_VOID_PROP( XSD_MIN_EXCLUSIVE_DOUBLE, m_aMinExclusive, ValueType ); + registerMayBeVoidProperty( PROPERTY_XSD_MAX_INCLUSIVE_DOUBLE, PROPERTY_ID_XSD_MAX_INCLUSIVE_DOUBLE, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMaxInclusive, cppu::UnoType<ValueType>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MAX_EXCLUSIVE_DOUBLE, PROPERTY_ID_XSD_MAX_EXCLUSIVE_DOUBLE, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMaxExclusive, cppu::UnoType<ValueType>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MIN_INCLUSIVE_DOUBLE, PROPERTY_ID_XSD_MIN_INCLUSIVE_DOUBLE, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMinInclusive, cppu::UnoType<ValueType>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MIN_EXCLUSIVE_DOUBLE, PROPERTY_ID_XSD_MIN_EXCLUSIVE_DOUBLE, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMinExclusive, cppu::UnoType<ValueType>::get() ); } template<> @@ -249,10 +276,17 @@ namespace xforms { OValueLimitedType_Base::registerProperties(); - REGISTER_VOID_PROP( XSD_MAX_INCLUSIVE_INT, m_aMaxInclusive, ValueType ); - REGISTER_VOID_PROP( XSD_MAX_EXCLUSIVE_INT, m_aMaxExclusive, ValueType ); - REGISTER_VOID_PROP( XSD_MIN_INCLUSIVE_INT, m_aMinInclusive, ValueType ); - REGISTER_VOID_PROP( XSD_MIN_EXCLUSIVE_INT, m_aMinExclusive, ValueType ); + registerMayBeVoidProperty( PROPERTY_XSD_MAX_INCLUSIVE_INT, PROPERTY_ID_XSD_MAX_INCLUSIVE_INT, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMaxInclusive, cppu::UnoType<ValueType>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MAX_EXCLUSIVE_INT, PROPERTY_ID_XSD_MAX_EXCLUSIVE_INT, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMaxExclusive, cppu::UnoType<ValueType>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MIN_INCLUSIVE_INT, PROPERTY_ID_XSD_MIN_INCLUSIVE_INT, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMinInclusive, cppu::UnoType<ValueType>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MIN_EXCLUSIVE_INT, PROPERTY_ID_XSD_MIN_EXCLUSIVE_INT, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMinExclusive, cppu::UnoType<ValueType>::get() ); } } // namespace xforms diff --git a/forms/source/xforms/datatypes.cxx b/forms/source/xforms/datatypes.cxx index 464b1c1adbbf..91cb67efcf9f 100644 --- a/forms/source/xforms/datatypes.cxx +++ b/forms/source/xforms/datatypes.cxx @@ -24,12 +24,15 @@ #include <property.hxx> #include <strings.hrc> #include "convert.hxx" +#include <comphelper/processfactory.hxx> #include <com/sun/star/xsd/DataTypeClass.hpp> #include <com/sun/star/xsd/WhiteSpaceTreatment.hpp> +#include <o3tl/string_view.hxx> #include <tools/datetime.hxx> #include <rtl/math.hxx> #include <sal/log.hxx> +#include <utility> namespace xforms @@ -38,7 +41,6 @@ namespace xforms using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; - using ::com::sun::star::uno::makeAny; using ::com::sun::star::util::Date; using ::com::sun::star::util::Time; using ::com::sun::star::util::DateTime; @@ -53,11 +55,10 @@ namespace xforms using namespace ::frm; U_NAMESPACE_USE - OXSDDataType::OXSDDataType( const OUString& _rName, sal_Int16 _nTypeClass ) - :OXSDDataType_PBase( m_aBHelper ) - ,m_bIsBasic( true ) + OXSDDataType::OXSDDataType( OUString _aName, sal_Int16 _nTypeClass ) + :m_bIsBasic( true ) ,m_nTypeClass( _nTypeClass ) - ,m_sName( _rName ) + ,m_sName(std::move( _aName )) ,m_nWST( WhiteSpaceTreatment::Preserve ) ,m_bPatternMatcherDirty( true ) { @@ -97,15 +98,10 @@ namespace xforms } - IMPLEMENT_FORWARD_XINTERFACE2( OXSDDataType, OXSDDataType_Base, ::comphelper::OPropertyContainer ) + IMPLEMENT_FORWARD_XINTERFACE2( OXSDDataType, OXSDDataType_Base, ::comphelper::OPropertyContainer2 ) - IMPLEMENT_FORWARD_XTYPEPROVIDER2( OXSDDataType, OXSDDataType_Base, ::comphelper::OPropertyContainer ) - -#define SET_PROPERTY( propertyid, value, member ) \ - setFastPropertyValue( PROPERTY_ID_##propertyid, makeAny( value ) ); \ - SAL_WARN_IF( member != value, "forms.misc", "OXSDDataType::setFoo: inconsistency!" ); - + IMPLEMENT_FORWARD_XTYPEPROVIDER2( OXSDDataType, OXSDDataType_Base, ::comphelper::OPropertyContainer2 ) OUString SAL_CALL OXSDDataType::getName( ) { @@ -116,7 +112,8 @@ namespace xforms void SAL_CALL OXSDDataType::setName( const OUString& aName ) { // TODO: check the name for conflicts in the repository - SET_PROPERTY( NAME, aName, m_sName ); + setFastPropertyValue( PROPERTY_ID_NAME, Any(aName) ); + SAL_WARN_IF( m_sName != aName, "forms.misc", "OXSDDataType::setName: inconsistency!" ); } @@ -128,7 +125,8 @@ namespace xforms void SAL_CALL OXSDDataType::setPattern( const OUString& _pattern ) { - SET_PROPERTY( XSD_PATTERN, _pattern, m_sPattern ); + setFastPropertyValue( PROPERTY_ID_XSD_PATTERN, Any(_pattern) ); + SAL_WARN_IF( m_sPattern != _pattern, "forms.misc", "OXSDDataType::setPattern: inconsistency!" ); } @@ -140,7 +138,8 @@ namespace xforms void SAL_CALL OXSDDataType::setWhiteSpaceTreatment( sal_Int16 _whitespacetreatment ) { - SET_PROPERTY( XSD_WHITESPACE, _whitespacetreatment, m_nWST ); + setFastPropertyValue( PROPERTY_ID_XSD_WHITESPACE, Any(_whitespacetreatment) ); + SAL_WARN_IF( m_nWST != _whitespacetreatment, "forms.misc", "OXSDDataType::setWhiteSpaceTreatment: inconsistency!" ); } @@ -158,7 +157,7 @@ namespace xforms sal_Bool OXSDDataType::validate( const OUString& sValue ) { - return bool(_validate( sValue )); + return bool(!_validate( sValue )); } @@ -233,29 +232,26 @@ namespace xforms } - sal_Bool OXSDDataType::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue ) + bool OXSDDataType::convertFastPropertyValue( std::unique_lock<std::mutex>& rGuard, Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue ) { // let the base class do the conversion - if ( !OXSDDataType_PBase::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue ) ) + if ( !::comphelper::OPropertyContainer2::convertFastPropertyValue( rGuard, _rConvertedValue, _rOldValue, _nHandle, _rValue ) ) return false; // sanity checks OUString sErrorMessage; if ( !checkPropertySanity( _nHandle, _rConvertedValue, sErrorMessage ) ) { - IllegalArgumentException aException; - aException.Message = sErrorMessage; - aException.Context = *this; - throw aException; + throw IllegalArgumentException(sErrorMessage, *this, 0); } return true; } - void SAL_CALL OXSDDataType::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) + void OXSDDataType::setFastPropertyValue_NoBroadcast( std::unique_lock<std::mutex>& rGuard, sal_Int32 _nHandle, const Any& _rValue ) { - OXSDDataType_PBase::setFastPropertyValue_NoBroadcast( _nHandle, _rValue ); + ::comphelper::OPropertyContainer2::setFastPropertyValue_NoBroadcast( rGuard, _nHandle, _rValue ); if ( _nHandle == PROPERTY_ID_XSD_PATTERN ) m_bPatternMatcherDirty = true; } @@ -283,37 +279,37 @@ namespace xforms void SAL_CALL OXSDDataType::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) { - OXSDDataType_PBase::setPropertyValue( aPropertyName, aValue ); + ::comphelper::OPropertyContainer2::setPropertyValue( aPropertyName, aValue ); } Any SAL_CALL OXSDDataType::getPropertyValue( const OUString& PropertyName ) { - return OXSDDataType_PBase::getPropertyValue( PropertyName ); + return ::comphelper::OPropertyContainer2::getPropertyValue( PropertyName ); } void SAL_CALL OXSDDataType::addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener ) { - OXSDDataType_PBase::addPropertyChangeListener( aPropertyName, xListener ); + ::comphelper::OPropertyContainer2::addPropertyChangeListener( aPropertyName, xListener ); } void SAL_CALL OXSDDataType::removePropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& aListener ) { - OXSDDataType_PBase::removePropertyChangeListener( aPropertyName, aListener ); + ::comphelper::OPropertyContainer2::removePropertyChangeListener( aPropertyName, aListener ); } void SAL_CALL OXSDDataType::addVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener ) { - OXSDDataType_PBase::addVetoableChangeListener( PropertyName, aListener ); + ::comphelper::OPropertyContainer2::addVetoableChangeListener( PropertyName, aListener ); } void SAL_CALL OXSDDataType::removeVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener ) { - OXSDDataType_PBase::removeVetoableChangeListener( PropertyName, aListener ); + ::comphelper::OPropertyContainer2::removeVetoableChangeListener( PropertyName, aListener ); } OValueLimitedType_Base::OValueLimitedType_Base( const OUString& _rName, sal_Int16 _nTypeClass ) @@ -346,10 +342,11 @@ namespace xforms } - void SAL_CALL OValueLimitedType_Base::setFastPropertyValue_NoBroadcast( + void OValueLimitedType_Base::setFastPropertyValue_NoBroadcast( + std::unique_lock<std::mutex>& rGuard, sal_Int32 _nHandle, const css::uno::Any& _rValue ) { - OXSDDataType::setFastPropertyValue_NoBroadcast( _nHandle, _rValue ); + OXSDDataType::setFastPropertyValue_NoBroadcast( rGuard, _nHandle, _rValue ); // if one of our limit properties has been set, translate it into a double // value, for later efficient validation @@ -405,7 +402,7 @@ namespace xforms rtl_math_ConversionStatus eStatus; sal_Int32 nEnd; double f = ::rtl::math::stringToDouble( - rValue, '.', u'\0', &eStatus, &nEnd ); + rValue.replace(',','.'), '.', u'\0', &eStatus, &nEnd ); // error checking... bool bReturn = false; @@ -468,13 +465,27 @@ namespace xforms { OStringType_Base::registerProperties(); - REGISTER_VOID_PROP( XSD_LENGTH, m_aLength, sal_Int32 ); - REGISTER_VOID_PROP( XSD_MIN_LENGTH, m_aMinLength, sal_Int32 ); - REGISTER_VOID_PROP( XSD_MAX_LENGTH, m_aMaxLength, sal_Int32 ); + registerMayBeVoidProperty( PROPERTY_XSD_LENGTH, PROPERTY_ID_XSD_LENGTH, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aLength, cppu::UnoType<sal_Int32>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MIN_LENGTH, PROPERTY_ID_XSD_MIN_LENGTH, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMinLength, cppu::UnoType<sal_Int32>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MAX_LENGTH, PROPERTY_ID_XSD_MAX_LENGTH, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMaxLength, cppu::UnoType<sal_Int32>::get() ); } - IMPLEMENT_DEFAULT_TYPED_CLONING( OStringType, OStringType_Base ) + rtl::Reference<OXSDDataType> OStringType::createClone( const OUString& _rName ) const + { + return new OStringType( _rName, getTypeClass() ); + } + void OStringType::initializeClone( const OXSDDataType& _rCloneSource ) + { + OStringType_Base::initializeClone( _rCloneSource ); + initializeTypedClone( static_cast< const OStringType& >( _rCloneSource ) ); + } + void OStringType::initializeTypedClone( const OStringType& _rCloneSource ) @@ -500,7 +511,7 @@ namespace xforms { sal_Int32 nValue( 0 ); OSL_VERIFY( _rNewValue >>= nValue ); - if ( nValue <= 0 ) + if ( nValue < 0 ) _rErrorMessage = "Length limits must denote positive integer values."; // TODO/eforms: localize the error message } @@ -563,6 +574,131 @@ namespace xforms return sInfo.makeStringAndClear(); } + OAnyURIType::OAnyURIType( const OUString& _rName, sal_Int16 _nTypeClass ) + : OAnyURIType_Base(_rName, _nTypeClass) + , m_xURLTransformer(css::util::URLTransformer::create(::comphelper::getProcessComponentContext())) + { + } + + void OAnyURIType::registerProperties() + { + OAnyURIType_Base::registerProperties(); + + registerMayBeVoidProperty( PROPERTY_XSD_LENGTH, PROPERTY_ID_XSD_LENGTH, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aLength, cppu::UnoType<sal_Int32>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MIN_LENGTH, PROPERTY_ID_XSD_MIN_LENGTH, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMinLength, cppu::UnoType<sal_Int32>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_MAX_LENGTH, PROPERTY_ID_XSD_MAX_LENGTH, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aMaxLength, cppu::UnoType<sal_Int32>::get() ); + } + + rtl::Reference<OXSDDataType> OAnyURIType::createClone( const OUString& _rName ) const + { + return new OAnyURIType( _rName, getTypeClass() ); + } + + void OAnyURIType::initializeClone( const OXSDDataType& _rCloneSource ) + { + OAnyURIType_Base::initializeClone( _rCloneSource ); + initializeTypedClone( static_cast< const OAnyURIType& >( _rCloneSource ) ); + } + + + + void OAnyURIType::initializeTypedClone( const OAnyURIType& _rCloneSource ) + { + m_aLength = _rCloneSource.m_aLength; + m_aMinLength = _rCloneSource.m_aMinLength; + m_aMaxLength = _rCloneSource.m_aMaxLength; + } + + + bool OAnyURIType::checkPropertySanity( sal_Int32 _nHandle, const Any& _rNewValue, OUString& _rErrorMessage ) + { + // let the base class do the conversion + if ( !OAnyURIType_Base::checkPropertySanity( _nHandle, _rNewValue, _rErrorMessage ) ) + return false; + + _rErrorMessage.clear(); + switch ( _nHandle ) + { + case PROPERTY_ID_XSD_LENGTH: + case PROPERTY_ID_XSD_MIN_LENGTH: + case PROPERTY_ID_XSD_MAX_LENGTH: + { + sal_Int32 nValue( 0 ); + OSL_VERIFY( _rNewValue >>= nValue ); + if ( nValue < 0 ) + _rErrorMessage = "Length limits must denote positive integer values."; + // TODO/eforms: localize the error message + } + break; + } + + return _rErrorMessage.isEmpty(); + } + + + TranslateId OAnyURIType::_validate( const OUString& rValue ) + { + // check regexp, whitespace etc. in parent class + TranslateId pReason = OAnyURIType_Base::_validate( rValue ); + + if (!pReason) + { + // check AnyURI constraints + sal_Int32 nLength = rValue.getLength(); + sal_Int32 nLimit = 0; + if ( m_aLength >>= nLimit ) + { + if ( nLimit != nLength ) + pReason = RID_STR_XFORMS_VALUE_LENGTH; + } + else + { + if ( ( m_aMaxLength >>= nLimit ) && ( nLength > nLimit ) ) + pReason = RID_STR_XFORMS_VALUE_MAX_LENGTH; + else if ( ( m_aMinLength >>= nLimit ) && ( nLength < nLimit ) ) + pReason = RID_STR_XFORMS_VALUE_MIN_LENGTH; + } + // check URL + css::util::URL aCommandURL; + aCommandURL.Complete = rValue; + if (!m_xURLTransformer->parseStrict(aCommandURL)) + pReason = RID_STR_XFORMS_INVALID_VALUE; + + } + return pReason; + } + + OUString OAnyURIType::_explainInvalid(TranslateId rReason) + { + sal_Int32 nValue = 0; + OUStringBuffer sInfo; + if (rReason == RID_STR_XFORMS_VALUE_LENGTH) + { + if( m_aLength >>= nValue ) + sInfo.append( nValue ); + } + else if (rReason == RID_STR_XFORMS_VALUE_MAX_LENGTH) + { + if( m_aMaxLength >>= nValue ) + sInfo.append( nValue ); + } + else if (rReason == RID_STR_XFORMS_VALUE_MIN_LENGTH) + { + if( m_aMinLength >>= nValue ) + sInfo.append( nValue ); + } + else if (rReason) + { + sInfo.append(OAnyURIType_Base::_explainInvalid(rReason)); + } + return sInfo.makeStringAndClear(); + } + OBooleanType::OBooleanType( const OUString& _rName ) :OBooleanType_Base( _rName, DataTypeClass::BOOLEAN ) { @@ -598,9 +734,15 @@ namespace xforms { } - - IMPLEMENT_DEFAULT_TYPED_CLONING( ODecimalType, ODecimalType_Base ) - + rtl::Reference<OXSDDataType> ODecimalType::createClone( const OUString& _rName ) const + { + return new ODecimalType( _rName, getTypeClass() ); + } + void ODecimalType::initializeClone( const OXSDDataType& _rCloneSource ) + { + ODecimalType_Base::initializeClone( _rCloneSource ); + initializeTypedClone( static_cast< const ODecimalType& >( _rCloneSource ) ); + } void ODecimalType::initializeTypedClone( const ODecimalType& _rCloneSource ) { @@ -613,8 +755,11 @@ namespace xforms { ODecimalType_Base::registerProperties(); - REGISTER_VOID_PROP( XSD_TOTAL_DIGITS, m_aTotalDigits, sal_Int32 ); - REGISTER_VOID_PROP( XSD_FRACTION_DIGITS, m_aFractionDigits, sal_Int32 ); + registerMayBeVoidProperty( PROPERTY_XSD_TOTAL_DIGITS, PROPERTY_ID_XSD_TOTAL_DIGITS, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aTotalDigits, cppu::UnoType<sal_Int32>::get() ); + + registerMayBeVoidProperty( PROPERTY_XSD_FRACTION_DIGITS, PROPERTY_ID_XSD_FRACTION_DIGITS, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, + &m_aFractionDigits, cppu::UnoType<sal_Int32>::get() ); } @@ -688,39 +833,36 @@ namespace xforms } - //= - -#define DEFAULT_IMPLEMNENT_SUBTYPE( classname, typeclass ) \ - classname::classname( const OUString& _rName ) \ - :classname##_Base( _rName, DataTypeClass::typeclass ) \ - { \ - } \ - rtl::Reference<OXSDDataType> classname::createClone( const OUString& _rName ) const \ - { \ - return new classname( _rName ); \ - } \ - void classname::initializeClone( const OXSDDataType& _rCloneSource ) \ - { \ - classname##_Base::initializeClone( _rCloneSource ); \ - initializeTypedClone( static_cast< const classname& >( _rCloneSource ) ); \ - } \ - - - //= ODateType - - - DEFAULT_IMPLEMNENT_SUBTYPE( ODateType, DATE ) - + ODateType::ODateType(const OUString& _rName) + :ODateType_Base(_rName, DataTypeClass::DATE) + { + } + rtl::Reference<OXSDDataType> ODateType::createClone(const OUString& _rName) const + { + return new ODateType(_rName); + } + void ODateType::initializeClone( const OXSDDataType& _rCloneSource ) + { + ODateType_Base::initializeClone(_rCloneSource); + initializeTypedClone(static_cast< const ODateType& >(_rCloneSource)); + } TranslateId ODateType::_validate( const OUString& _rValue ) { return ODateType_Base::_validate( _rValue ); } - bool ODateType::_getValue( const OUString& value, double& fValue ) { - Any aTypeValue = Convert::get().toAny( value, getCppuType() ); + Any aTypeValue; + try + { + aTypeValue = Convert::get().toAny( value, getCppuType() ); + } + catch (com::sun::star::lang::IllegalArgumentException) + { + return false; + } Date aValue; if ( !( aTypeValue >>= aValue ) ) @@ -748,21 +890,36 @@ namespace xforms } - //= OTimeType - - - DEFAULT_IMPLEMNENT_SUBTYPE( OTimeType, TIME ) - + OTimeType::OTimeType(const OUString& _rName) + :OTimeType_Base(_rName, DataTypeClass::TIME) + { + } + rtl::Reference<OXSDDataType> OTimeType::createClone(const OUString& _rName) const + { + return new OTimeType(_rName); + } + void OTimeType::initializeClone( const OXSDDataType& _rCloneSource ) + { + OTimeType_Base::initializeClone(_rCloneSource); + initializeTypedClone(static_cast< const OTimeType& >(_rCloneSource)); + } TranslateId OTimeType::_validate( const OUString& _rValue ) { return OTimeType_Base::_validate( _rValue ); } - bool OTimeType::_getValue( const OUString& value, double& fValue ) { - Any aTypedValue = Convert::get().toAny( value, getCppuType() ); + Any aTypedValue; + try + { + aTypedValue = Convert::get().toAny( value, getCppuType() ); + } + catch (com::sun::star::lang::IllegalArgumentException) + { + return false; + } css::util::Time aValue; if ( !( aTypedValue >>= aValue ) ) @@ -797,10 +954,19 @@ namespace xforms } - //= ODateTimeType - - - DEFAULT_IMPLEMNENT_SUBTYPE( ODateTimeType, DATETIME ) + ODateTimeType::ODateTimeType(const OUString& _rName) + :ODateTimeType_Base(_rName, DataTypeClass::DATETIME) + { + } + rtl::Reference<OXSDDataType> ODateTimeType::createClone(const OUString& _rName) const + { + return new ODateTimeType(_rName); + } + void ODateTimeType::initializeClone( const OXSDDataType& _rCloneSource ) + { + ODateTimeType_Base::initializeClone(_rCloneSource); + initializeTypedClone(static_cast< const ODateTimeType& >(_rCloneSource)); + } TranslateId ODateTimeType::_validate( const OUString& _rValue ) { @@ -825,7 +991,15 @@ namespace xforms bool ODateTimeType::_getValue( const OUString& value, double& fValue ) { - Any aTypedValue = Convert::get().toAny( value, getCppuType() ); + Any aTypedValue; + try + { + aTypedValue = Convert::get().toAny( value, getCppuType() ); + } + catch (com::sun::star::uno::RuntimeException) + { + return false; + } DateTime aValue; if ( !( aTypedValue >>= aValue ) ) @@ -860,23 +1034,101 @@ namespace xforms { } + rtl::Reference<OXSDDataType> OShortIntegerType::createClone( const OUString& _rName ) const + { + return new OShortIntegerType( _rName, getTypeClass() ); + } + void OShortIntegerType::initializeClone( const OXSDDataType& _rCloneSource ) + { + OShortIntegerType_Base::initializeClone( _rCloneSource ); + initializeTypedClone( static_cast< const OShortIntegerType& >( _rCloneSource ) ); + } - IMPLEMENT_DEFAULT_TYPED_CLONING( OShortIntegerType, OShortIntegerType_Base ) + static bool lcl_getValueYear( std::u16string_view value, double& fValue ) + { + if (value.size() > 4) + { + fValue = 0; + return false; + } + if (o3tl::equalsAscii(value, "0")) + { + fValue = 0; + return true; + } + sal_Int32 int32Value = o3tl::toInt32(value); + if ( + int32Value == 0 || + int32Value < 0 || + int32Value > 10000 + ) + { + fValue = 0; + return false; + } + fValue = static_cast<double>(static_cast<sal_Int16>(int32Value)); + return true; + } + static bool lcl_getValueMonth( std::u16string_view value, double& fValue ) + { + if (value.size() > 2) + { + fValue = 0; + return false; + } + sal_Int32 int32Value = o3tl::toInt32(value); + if ( + int32Value == 0 || + int32Value < 1 || + int32Value > 12 + ) + { + fValue = 0; + return false; + } + fValue = static_cast<double>(static_cast<sal_Int16>(int32Value)); + return true; + } + + static bool lcl_getValueDay( std::u16string_view value, double& fValue ) + { + if (value.size() > 2) + { + fValue = 0; + return false; + } + sal_Int32 int32Value = o3tl::toInt32(value); + if ( + int32Value == 0 || + int32Value < 1 || + int32Value > 31 + ) + { + fValue = 0; + return false; + } + fValue = static_cast<double>(static_cast<sal_Int16>(int32Value)); + return true; + } bool OShortIntegerType::_getValue( const OUString& value, double& fValue ) { - fValue = static_cast<double>(static_cast<sal_Int16>(value.toInt32())); - // TODO/eforms - // this does not care for values which do not fit into a sal_Int16, but simply - // cuts them down. A better implementation here should probably return <FALSE/> - // for those values. - // Else, we may have a situation where the UI claims an input to be valid - // (say "12345678"), while internally, and at submission time, this is cut to - // some smaller value. + switch (this->getTypeClass()) + { + case css::xsd::DataTypeClass::gYear: + return lcl_getValueYear(value, fValue); - // Additionally, this of course does not care for strings which are no numbers... - return true; + case css::xsd::DataTypeClass::gMonth: + return lcl_getValueMonth(value, fValue); + + case css::xsd::DataTypeClass::gDay: + return lcl_getValueDay(value, fValue); + default: + // for the moment, the only types which derive from OShortIntegerType are: + // gYear, gMonth and gDay, see ODataTypeRepository ctr + return false; + } } @@ -921,7 +1173,7 @@ css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL ODerivedDataType< C template< typename CONCRETE_DATA_TYPE_IMPL, typename SUPERCLASS > -::cppu::IPropertyArrayHelper& SAL_CALL ODerivedDataType< CONCRETE_DATA_TYPE_IMPL, SUPERCLASS >::getInfoHelper() +::cppu::IPropertyArrayHelper& ODerivedDataType< CONCRETE_DATA_TYPE_IMPL, SUPERCLASS >::getInfoHelper() { if ( !m_bPropertiesRegistered ) { diff --git a/forms/source/xforms/datatypes.hxx b/forms/source/xforms/datatypes.hxx index 84ca5cfe9bdd..db1500402a9d 100644 --- a/forms/source/xforms/datatypes.hxx +++ b/forms/source/xforms/datatypes.hxx @@ -24,11 +24,10 @@ #include <com/sun/star/util/Time.hpp> #include <com/sun/star/util/DateTime.hpp> #include <com/sun/star/xsd/XDataType.hpp> -#include <cppuhelper/implbase.hxx> +#include <comphelper/compbase.hxx> #include <comphelper/uno3.hxx> -#include <comphelper/propertycontainer.hxx> +#include <comphelper/propertycontainer2.hxx> #include <comphelper/proparrhlp.hxx> -#include <comphelper/broadcasthelper.hxx> #include <rtl/ref.hxx> #include <unotools/resmgr.hxx> @@ -36,6 +35,8 @@ #include <memory> +#include <com/sun/star/util/URLTransformer.hpp> + namespace xforms { @@ -43,14 +44,11 @@ namespace xforms //= OXSDDataType - typedef ::cppu::WeakImplHelper < css::xsd::XDataType + typedef ::comphelper::WeakImplHelper < css::xsd::XDataType > OXSDDataType_Base; - typedef ::comphelper::OMutexAndBroadcastHelper OXSDDataType_BBase; - typedef ::comphelper::OPropertyContainer OXSDDataType_PBase; class OXSDDataType :public OXSDDataType_Base - ,public OXSDDataType_BBase // order matters: OMutexAndBroadcastHelper before - ,public OXSDDataType_PBase // OPropertyContainer + ,public ::comphelper::OPropertyContainer2 { private: // <properties> @@ -74,7 +72,7 @@ namespace xforms protected: // create basic data type - OXSDDataType( const OUString& _rName, sal_Int16 _nTypeClass ); + OXSDDataType( OUString _aName, sal_Int16 _nTypeClass ); virtual ~OXSDDataType() override; public: @@ -106,8 +104,9 @@ namespace xforms protected: // XPropertySet and friends - virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any& _rConvertedValue, css::uno::Any& _rOldValue, sal_Int32 _nHandle, const css::uno::Any& _rValue ) override; - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + virtual bool convertFastPropertyValue( std::unique_lock<std::mutex>& rGuard, css::uno::Any& _rConvertedValue, css::uno::Any& _rOldValue, sal_Int32 _nHandle, const css::uno::Any& _rValue ) override; + virtual void setFastPropertyValue_NoBroadcast( + std::unique_lock<std::mutex>& rGuard, sal_Int32 nHandle, const css::uno::Any& rValue ) override; @@ -131,25 +130,6 @@ namespace xforms //= helper for deriving from OXSDDataType -#define DECLARE_DEFAULT_CLONING( classname ) \ - virtual rtl::Reference<OXSDDataType> createClone( const OUString& _rName ) const override; \ - virtual void initializeClone( const OXSDDataType& _rCloneSource ) override; - -#define IMPLEMENT_DEFAULT_TYPED_CLONING( classname, baseclass ) \ - rtl::Reference<OXSDDataType> classname::createClone( const OUString& _rName ) const \ - { \ - return new classname( _rName, getTypeClass() ); \ - } \ - void classname::initializeClone( const OXSDDataType& _rCloneSource ) \ - { \ - baseclass::initializeClone( _rCloneSource ); \ - initializeTypedClone( static_cast< const classname& >( _rCloneSource ) ); \ - } - -#define REGISTER_VOID_PROP( prop, memberAny, type ) \ - registerMayBeVoidProperty( PROPERTY_##prop, PROPERTY_ID_##prop, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID, \ - &memberAny, cppu::UnoType<type>::get() ); - class OValueLimitedType_Base : public OXSDDataType { protected: @@ -170,7 +150,8 @@ namespace xforms void initializeTypedClone( const OValueLimitedType_Base& _rCloneSource ); // XPropertySet and friends - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + virtual void setFastPropertyValue_NoBroadcast( + std::unique_lock<std::mutex>& rGuard, sal_Int32 nHandle, const css::uno::Any& rValue ) override; @@ -235,7 +216,7 @@ namespace xforms // XPropertySet virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; - virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + virtual ::cppu::IPropertyArrayHelper& getInfoHelper() override; }; class OBooleanType; @@ -246,7 +227,8 @@ namespace xforms explicit OBooleanType( const OUString& _rName ); protected: - DECLARE_DEFAULT_CLONING( OBooleanType ) + virtual rtl::Reference<OXSDDataType> createClone(const OUString& _rName) const override; + virtual void initializeClone(const OXSDDataType& _rCloneSource) override; // OXSDDataType overridables virtual TranslateId _validate( const OUString& value ) override; @@ -267,7 +249,8 @@ namespace xforms OStringType( const OUString& _rName, sal_Int16 _nTypeClass /* = css::xsd::DataTypeClass::STRING */ ); protected: - DECLARE_DEFAULT_CLONING( OStringType ) + virtual rtl::Reference<OXSDDataType> createClone(const OUString& _rName) const override; + virtual void initializeClone(const OXSDDataType& _rCloneSource) override; void initializeTypedClone( const OStringType& _rCloneSource ); // OXSDDataType overridables @@ -277,6 +260,33 @@ namespace xforms virtual void registerProperties() override; }; + class OAnyURIType; + typedef ODerivedDataType< OAnyURIType > OAnyURIType_Base; + class OAnyURIType :public OAnyURIType_Base + { + // <properties> + css::uno::Any m_aLength; + css::uno::Any m_aMinLength; + css::uno::Any m_aMaxLength; + // </properties> + // helper to check URL validity + css::uno::Reference<css::util::XURLTransformer> m_xURLTransformer; + + public: + OAnyURIType( const OUString& _rName, sal_Int16 _nTypeClass /* = css::xsd::DataTypeClass::anyURI */ ); + + protected: + virtual rtl::Reference<OXSDDataType> createClone(const OUString& _rName) const override; + virtual void initializeClone(const OXSDDataType& _rCloneSource) override; + void initializeTypedClone( const OAnyURIType& _rCloneSource ); + + // OXSDDataType overridables + virtual TranslateId _validate( const OUString& value ) override; + virtual OUString _explainInvalid( TranslateId rReason ) override; + virtual bool checkPropertySanity( sal_Int32 _nHandle, const css::uno::Any& _rNewValue, OUString& _rErrorMessage ) override; + virtual void registerProperties() override; + }; + class ODecimalType; typedef ODerivedDataType< ODecimalType, OValueLimitedType< double > > ODecimalType_Base; class ODecimalType : public ODecimalType_Base @@ -288,7 +298,8 @@ namespace xforms ODecimalType( const OUString& _rName, sal_Int16 _nTypeClass /* = css::xsd::DataTypeClass::DECIMAL */ ); protected: - DECLARE_DEFAULT_CLONING( ODecimalType ) + virtual rtl::Reference<OXSDDataType> createClone(const OUString& _rName) const override; + virtual void initializeClone(const OXSDDataType& _rCloneSource) override; void initializeTypedClone( const ODecimalType& _rCloneSource ); // OXSDDataType overridables @@ -307,43 +318,78 @@ namespace xforms //= -#define DEFAULT_DECLARE_SUBTYPE( classname, valuetype ) \ - class classname; \ - typedef ODerivedDataType< classname, OValueLimitedType< valuetype > > classname##_Base; \ - class classname : public classname##_Base \ - { \ - public: \ - explicit classname( const OUString& _rName ); \ - \ - protected: \ - DECLARE_DEFAULT_CLONING( classname ) \ - \ - /* OXSDDataType overridables */ \ - virtual TranslateId _validate( const OUString& value ) override; \ - virtual bool _getValue( const OUString& value, double& fValue ) override; \ - \ - /* OValueLimitedType overridables */ \ - virtual OUString typedValueAsHumanReadableString( const css::uno::Any& _rValue ) const override; \ - virtual void normalizeValue( const css::uno::Any& _rValue, double& _rDoubleValue ) const override; \ - \ - private: \ - using classname##_Base::initializeTypedClone; \ + class ODateType; + typedef ODerivedDataType< ODateType, OValueLimitedType< css::util::Date > > ODateType_Base; + class ODateType : public ODateType_Base + { + public: + explicit ODateType( const OUString& _rName ); + + protected: + virtual rtl::Reference<OXSDDataType> createClone(const OUString& _rName) const override; + virtual void initializeClone(const OXSDDataType& _rCloneSource) override; + + /* OXSDDataType overridables */ + virtual TranslateId _validate( const OUString& value ) override; + virtual bool _getValue( const OUString& value, double& fValue ) override; + + /* OValueLimitedType overridables */ + virtual OUString typedValueAsHumanReadableString( const css::uno::Any& _rValue ) const override; + virtual void normalizeValue( const css::uno::Any& _rValue, double& _rDoubleValue ) const override; + + private: + using ODateType_Base::initializeTypedClone; }; - //= ODateType + class OTimeType; + typedef ODerivedDataType< OTimeType, OValueLimitedType< css::util::Time > > OTimeType_Base; + class OTimeType : public OTimeType_Base + { + public: + explicit OTimeType( const OUString& _rName ); - DEFAULT_DECLARE_SUBTYPE( ODateType, css::util::Date ) + protected: + virtual rtl::Reference<OXSDDataType> createClone(const OUString& _rName) const override; + virtual void initializeClone(const OXSDDataType& _rCloneSource) override; + /* OXSDDataType overridables */ + virtual TranslateId _validate( const OUString& value ) override; + virtual bool _getValue( const OUString& value, double& fValue ) override; - //= OTimeType + /* OValueLimitedType overridables */ + virtual OUString typedValueAsHumanReadableString( const css::uno::Any& _rValue ) const override; + virtual void normalizeValue( const css::uno::Any& _rValue, double& _rDoubleValue ) const override; - DEFAULT_DECLARE_SUBTYPE( OTimeType, css::util::Time ) + private: + using OTimeType_Base::initializeTypedClone; + }; - //= ODateTimeType - DEFAULT_DECLARE_SUBTYPE( ODateTimeType, css::util::DateTime ) + class ODateTimeType; + typedef ODerivedDataType< OTimeType, OValueLimitedType< css::util::DateTime > > ODateTimeType_Base; + class ODateTimeType : public ODateTimeType_Base + { + public: + explicit ODateTimeType( const OUString& _rName ); + + protected: + virtual rtl::Reference<OXSDDataType> createClone(const OUString& _rName) const override; + virtual void initializeClone(const OXSDDataType& _rCloneSource) override; + + /* OXSDDataType overridables */ + virtual TranslateId _validate( const OUString& value ) override; + virtual bool _getValue( const OUString& value, double& fValue ) override; + + /* OValueLimitedType overridables */ + virtual OUString typedValueAsHumanReadableString( const css::uno::Any& _rValue ) const override; + virtual void normalizeValue( const css::uno::Any& _rValue, double& _rDoubleValue ) const override; + + private: + using ODateTimeType_Base::initializeTypedClone; + }; + class OShortIntegerType; typedef ODerivedDataType< OShortIntegerType, OValueLimitedType< sal_Int16 > > OShortIntegerType_Base; @@ -353,7 +399,8 @@ namespace xforms OShortIntegerType( const OUString& _rName, sal_Int16 _nTypeClass ); protected: - DECLARE_DEFAULT_CLONING( OShortIntegerType ) + virtual rtl::Reference<OXSDDataType> createClone(const OUString& _rName) const override; + virtual void initializeClone(const OXSDDataType& _rCloneSource) override; // OXSDDataType overridables virtual bool _getValue( const OUString& value, double& fValue ) override; diff --git a/forms/source/xforms/evaluationcontext.hxx b/forms/source/xforms/evaluationcontext.hxx index 145a1f2d25f0..e25c8524042c 100644 --- a/forms/source/xforms/evaluationcontext.hxx +++ b/forms/source/xforms/evaluationcontext.hxx @@ -22,6 +22,7 @@ #include <com/sun/star/xml/dom/XNode.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/xforms/XModel.hpp> +#include <utility> namespace xforms { @@ -38,12 +39,12 @@ public: { } EvaluationContext( - const css::uno::Reference<css::xml::dom::XNode>& xContextNode, - const css::uno::Reference<css::xforms::XModel>& xModel, - const css::uno::Reference<css::container::XNameContainer>& xNamespaces ) - : mxContextNode( xContextNode ), - mxModel( xModel ), - mxNamespaces( xNamespaces ) + css::uno::Reference<css::xml::dom::XNode> xContextNode, + css::uno::Reference<css::xforms::XModel> xModel, + css::uno::Reference<css::container::XNameContainer> xNamespaces ) + : mxContextNode(std::move( xContextNode )), + mxModel(std::move( xModel )), + mxNamespaces(std::move( xNamespaces )) { } css::uno::Reference<css::xml::dom::XNode> mxContextNode; diff --git a/forms/source/xforms/model.cxx b/forms/source/xforms/model.cxx index d5bf2182abe7..bbb460f18267 100644 --- a/forms/source/xforms/model.cxx +++ b/forms/source/xforms/model.cxx @@ -52,7 +52,6 @@ #include <com/sun/star/io/XInputStream.hpp> -using com::sun::star::lang::XUnoTunnel; using com::sun::star::beans::XPropertySet; using com::sun::star::beans::PropertyValue; using com::sun::star::ucb::SimpleFileAccess; @@ -129,13 +128,6 @@ EvaluationContext Model::getEvaluationContext() } -css::uno::Sequence<sal_Int8> Model::getUnoTunnelId() -{ - static const comphelper::UnoIdInit aImplementationId; - return aImplementationId.getSeq(); -} - - void Model::setForeignSchema( const css::uno::Reference<css::xml::dom::XDocument>& rDocument ) { mxForeignSchema = rDocument; @@ -434,9 +426,9 @@ void SAL_CALL Model::submitWithInteraction( if( mxSubmissions->hasItem( sID ) ) { Submission* pSubmission = - comphelper::getFromUnoTunnel<Submission>( mxSubmissions->getItem( sID ) ); - OSL_ENSURE( pSubmission != nullptr, "no submission?" ); - OSL_ENSURE( pSubmission->getModel() == Reference<XModel>( this ), + dynamic_cast<Submission*>( mxSubmissions->getItem( sID ).get() ); + assert(pSubmission && "no submission?"); + OSL_ENSURE( pSubmission->getModelImpl() == this, "wrong model" ); // submit. All exceptions are allowed to leave. @@ -560,25 +552,21 @@ css::uno::Reference<css::container::XSet> Model::getSubmissions() #define HANDLE_Namespaces 5 #define HANDLE_ExternalData 6 -#define REGISTER_PROPERTY( property, type ) \ - registerProperty( PROPERTY( property, type ), \ - new DirectPropertyAccessor< Model, type >( this, &Model::set##property, &Model::get##property ) ); +void Model::initializePropertySet() +{ + registerProperty( css::beans::Property("ID", HANDLE_ID, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new APIPropertyAccessor< Model, OUString >(this, &Model::setID, &Model::getID) ); + registerProperty( css::beans::Property("ForeignSchema", HANDLE_ForeignSchema, cppu::UnoType<css::uno::Reference<css::xml::dom::XDocument>>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Model, css::uno::Reference<css::xml::dom::XDocument> >( this, &Model::setForeignSchema, &Model::getForeignSchema) ); -#define REGISTER_PROPERTY_API( property, type ) \ - registerProperty( PROPERTY( property, type ), \ - new APIPropertyAccessor< Model, type >( this, &Model::set##property, &Model::get##property ) ); + registerProperty( css::beans::Property("SchemaRef", HANDLE_SchemaRef, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Model, OUString >( this, &Model::setSchemaRef, &Model::getSchemaRef) ); -#define REGISTER_BOOL_PROPERTY( property ) \ - registerProperty( PROPERTY( property, sal_Bool ), \ - new BooleanPropertyAccessor< Model >( this, &Model::set##property, &Model::get##property ) ); + registerProperty( css::beans::Property("Namespaces", HANDLE_Namespaces, cppu::UnoType<css::uno::Reference<css::container::XNameContainer>>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Model, css::uno::Reference<css::container::XNameContainer> >( this, &Model::setNamespaces, &Model::getNamespaces) ); -void Model::initializePropertySet() -{ - REGISTER_PROPERTY_API ( ID, OUString ); - REGISTER_PROPERTY ( ForeignSchema, css::uno::Reference<css::xml::dom::XDocument> ); - REGISTER_PROPERTY ( SchemaRef, OUString ); - REGISTER_PROPERTY ( Namespaces, css::uno::Reference<css::container::XNameContainer> ); - REGISTER_BOOL_PROPERTY( ExternalData ); + registerProperty( css::beans::Property("ExternalData", HANDLE_ExternalData, cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::BOUND ), + new BooleanPropertyAccessor< Model >( this, &Model::setExternalData, &Model::getExternalData ) ); } void Model::update() @@ -587,11 +575,6 @@ void Model::update() } -sal_Int64 Model::getSomething( const css::uno::Sequence<sal_Int8>& xId ) -{ - return comphelper::getSomethingImpl(xId, this); -} - Sequence<sal_Int8> Model::getImplementationId() { return css::uno::Sequence<sal_Int8>(); diff --git a/forms/source/xforms/model.hxx b/forms/source/xforms/model.hxx index 9deb8a834ae5..59fa7450fb80 100644 --- a/forms/source/xforms/model.hxx +++ b/forms/source/xforms/model.hxx @@ -25,7 +25,6 @@ #include <com/sun/star/xforms/XFormsUIHelper1.hpp> #include <com/sun/star/util/XUpdatable.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/uno/Reference.hxx> #include <rtl/ref.hxx> #include "mip.hxx" @@ -70,7 +69,6 @@ typedef cppu::ImplInheritanceHelper< css::xforms::XModel2, css::xforms::XFormsUIHelper1, css::util::XUpdatable, - css::lang::XUnoTunnel, css::lang::XServiceInfo > Model_t; class Model : public Model_t @@ -114,10 +112,6 @@ public: xforms::EvaluationContext getEvaluationContext(); - - static css::uno::Sequence<sal_Int8> getUnoTunnelId(); - - // get/set that part of the schema, that we can't interpret as data types css::uno::Reference<css::xml::dom::XDocument> getForeignSchema() const { return mxForeignSchema;} void setForeignSchema( const css::uno::Reference<css::xml::dom::XDocument>& ); @@ -347,13 +341,6 @@ public: virtual void SAL_CALL update() override; - // XUnoTunnel - - -public: - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence<sal_Int8>& ) override; - - // XTypeProvider::getImplementationId diff --git a/forms/source/xforms/model_helper.hxx b/forms/source/xforms/model_helper.hxx index d8e98c98ec26..08d7f013992d 100644 --- a/forms/source/xforms/model_helper.hxx +++ b/forms/source/xforms/model_helper.hxx @@ -64,14 +64,14 @@ protected: { auto pBinding = comphelper::getFromUnoTunnel<Binding>( t ); OSL_ENSURE( pBinding != nullptr, "invalid item?" ); - pBinding->_setModel( css::uno::Reference<css::xforms::XModel>( mpModel ) ); + pBinding->_setModel( mpModel ); } virtual void _remove( const T& t ) override { auto pBinding = comphelper::getFromUnoTunnel<Binding>( t ); OSL_ENSURE( pBinding != nullptr, "invalid item?" ); - pBinding->_setModel( css::uno::Reference<css::xforms::XModel>() ); + pBinding->_setModel( nullptr ); } }; @@ -84,22 +84,22 @@ public: virtual bool isValid( const T& t ) const override { - return comphelper::getFromUnoTunnel<Submission>( t ) != nullptr; + return dynamic_cast<Submission*>( t.get() ) != nullptr; } protected: virtual void _insert( const T& t ) override { - auto pSubmission = comphelper::getFromUnoTunnel<Submission>( t ); - OSL_ENSURE( pSubmission != nullptr, "invalid item?" ); - pSubmission->setModel( css::uno::Reference<css::xforms::XModel>( mpModel ) ); + auto pSubmission = dynamic_cast<Submission*>( t.get() ); + assert(pSubmission && "invalid item?"); + pSubmission->setModel( mpModel ); } virtual void _remove( const T& t ) override { - auto pSubmission = comphelper::getFromUnoTunnel<Submission>( t ); - OSL_ENSURE( pSubmission != nullptr, "invalid item?" ); - pSubmission->setModel( css::uno::Reference<css::xforms::XModel>( ) ); + auto pSubmission = dynamic_cast<Submission*>( t.get() ); + assert(pSubmission && "invalid item?"); + pSubmission->setModel( nullptr ); } }; diff --git a/forms/source/xforms/model_ui.cxx b/forms/source/xforms/model_ui.cxx index 890e18ea73ae..5d56e8b3baa0 100644 --- a/forms/source/xforms/model_ui.cxx +++ b/forms/source/xforms/model_ui.cxx @@ -159,8 +159,7 @@ static void lcl_OutName( OUStringBuffer& rBuffer, OUString sPrefix = xNode->getPrefix(); if( !sPrefix.isEmpty() ) { - rBuffer.insert( 0, ':' ); - rBuffer.insert( 0, sPrefix ); + rBuffer.insert( 0, sPrefix + ":" ); } } @@ -194,8 +193,7 @@ static void lcl_OutInstance( OUStringBuffer& rBuffer, sInstanceName = sId; } - rBuffer.insert( 0, sInstanceName ); - rBuffer.insert( 0, "instance('" ); + rBuffer.insert( 0, "instance('" + sInstanceName ); } OUString Model::getDefaultBindingExpressionForNode( @@ -510,7 +508,7 @@ css::uno::Reference<css::xforms::XModel> Model::newModel( const Reference<css::f pModel->setID( sName ); pModel->newInstance( OUString(), OUString(), false ); pModel->initialize(); - xModels->insertByName( sName, makeAny( xModel ) ); + xModels->insertByName( sName, Any( xModel ) ); } return xModel; @@ -527,7 +525,7 @@ void Model::renameModel( const Reference<css::frame::XModel>& xCmp, { Reference<XModel> xModel( xModels->getByName( sFrom ), UNO_QUERY ); xModel->setID( sTo ); - xModels->insertByName( sTo, makeAny( xModel ) ); + xModels->insertByName( sTo, Any( xModel ) ); xModels->removeByName( sFrom ); } } @@ -816,8 +814,7 @@ static OUString lcl_serializeForDisplay( const Reference<XNodeList>& xNodes ) if( !sLine.isEmpty() && !sLine.startsWith( "<?xml" ) ) { - sResult.append( sLine ); - sResult.append( '\n' ); + sResult.append( sLine + "\n" ); } } @@ -924,15 +921,14 @@ void xforms::getInstanceData( for( sal_Int32 n = 0; n < nValues; n++ ) { const PropertyValue& rValue = pValues[n]; -#define PROP(NAME) \ - if( p##NAME != nullptr && \ - rValue.Name == #NAME ) \ - rValue.Value >>= (*p##NAME) - PROP(ID); - PROP(Instance); - PROP(URL); - PROP(URLOnce); -#undef PROP + if( pID != nullptr && rValue.Name == "ID") + rValue.Value >>= *pID; + if( pInstance != nullptr && rValue.Name == "Instance") + rValue.Value >>= *pInstance; + if( pURL != nullptr && rValue.Name == "URL") + rValue.Value >>= *pURL; + if( pURLOnce != nullptr && rValue.Name == "URLOnce") + rValue.Value >>= *pURLOnce; } } @@ -955,38 +951,54 @@ void xforms::setInstanceData( const bool* pURLOnce = ( bURLOnce && pURL != nullptr ) ? &bURLOnce : nullptr; // determine new instance data -#define PROP(NAME) if( _p##NAME != nullptr ) p##NAME = _p##NAME - PROP(ID); - PROP(Instance); - PROP(URL); - PROP(URLOnce); -#undef PROP + if (_pID != nullptr) + pID = _pID; + if (_pInstance != nullptr) + pInstance = _pInstance; + if (_pURL != nullptr) + pURL = _pURL; + if (_pURLOnce != nullptr) + pURLOnce = _pURLOnce; // count # of values we want to set sal_Int32 nCount = 0; -#define PROP(NAME) if( p##NAME != nullptr ) nCount++ - PROP(ID); - PROP(Instance); - PROP(URL); - PROP(URLOnce); -#undef PROP + if (pID != nullptr) + ++nCount; + if (pInstance != nullptr) + ++nCount; + if (pURL != nullptr) + ++nCount; + if (pURLOnce != nullptr) + ++nCount; // realloc sequence and enter values; aSequence.realloc( nCount ); PropertyValue* pSequence = aSequence.getArray(); sal_Int32 nIndex = 0; -#define PROP(NAME) \ - if( p##NAME != nullptr ) \ - { \ - pSequence[ nIndex ].Name = #NAME; \ - pSequence[ nIndex ].Value <<= *p##NAME; \ - nIndex++; \ - } - PROP(ID); - PROP(Instance); - PROP(URL); - PROP(URLOnce); -#undef PROP + if(pID != nullptr) + { + pSequence[ nIndex ].Name = "ID"; + pSequence[ nIndex ].Value <<= *pID; + nIndex++; + } + if(pInstance != nullptr) + { + pSequence[ nIndex ].Name = "Instance"; + pSequence[ nIndex ].Value <<= *pInstance; + nIndex++; + } + if(pURL != nullptr) + { + pSequence[ nIndex ].Name = "URL"; + pSequence[ nIndex ].Value <<= *pURL; + nIndex++; + } + if(pURLOnce != nullptr) + { + pSequence[ nIndex ].Name = "URLOnce"; + pSequence[ nIndex ].Value <<= *pURLOnce; + nIndex++; + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/xforms/namedcollection.hxx b/forms/source/xforms/namedcollection.hxx index 10eeafcfd65b..4cbd99eb43ba 100644 --- a/forms/source/xforms/namedcollection.hxx +++ b/forms/source/xforms/namedcollection.hxx @@ -37,7 +37,6 @@ class NamedCollection : public cppu::ImplInheritanceHelper< using Collection<T>::hasItem; public: - NamedCollection() {} const T& getItem( const OUString& rName ) const { @@ -94,7 +93,7 @@ public: { if( !hasItem( aName ) ) throw css::container::NoSuchElementException(); - return css::uno::makeAny( getItem( aName ) ); + return css::uno::Any( getItem( aName ) ); } virtual css::uno::Sequence<OUString> SAL_CALL getElementNames() override diff --git a/forms/source/xforms/propertysetbase.cxx b/forms/source/xforms/propertysetbase.cxx index 0b0787c49c3e..0e19bfe968bc 100644 --- a/forms/source/xforms/propertysetbase.cxx +++ b/forms/source/xforms/propertysetbase.cxx @@ -120,7 +120,7 @@ void PropertySetBase::initializePropertyValueCache( sal_Int32 nHandle ) PropertyAccessorBase& PropertySetBase::locatePropertyHandler( sal_Int32 nHandle ) const { PropertyAccessors::const_iterator aPropertyPos = m_aAccessors.find( nHandle ); - OSL_ENSURE( aPropertyPos != m_aAccessors.end() && aPropertyPos->second, + assert( aPropertyPos != m_aAccessors.end() && aPropertyPos->second && "PropertySetBase::locatePropertyHandler: accessor map is corrupted!" ); // neither should this be called for handles where there is no accessor, nor should a // NULL accessor be in the map diff --git a/forms/source/xforms/propertysetbase.hxx b/forms/source/xforms/propertysetbase.hxx index 969253a04d62..d6ae97405880 100644 --- a/forms/source/xforms/propertysetbase.hxx +++ b/forms/source/xforms/propertysetbase.hxx @@ -88,12 +88,12 @@ public: virtual void getValue( css::uno::Any& rValue ) const override { - rValue = css::uno::makeAny( (m_pInstance->*m_pReader)() ); + rValue = css::uno::Any( (m_pInstance->*m_pReader)() ); } virtual bool isWriteable() const override { - return m_pWriter != 0; + return m_pWriter != nullptr; } }; @@ -337,11 +337,4 @@ public: } }; - -#define PROPERTY_FLAGS( NAME, TYPE, FLAG ) css::beans::Property( \ - #NAME, \ - HANDLE_##NAME, cppu::UnoType<TYPE>::get(), FLAG ) -#define PROPERTY( NAME, TYPE ) PROPERTY_FLAGS( NAME, TYPE, css::beans::PropertyAttribute::BOUND ) -#define PROPERTY_RO( NAME, TYPE ) PROPERTY_FLAGS( NAME, TYPE, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::READONLY ) - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/xforms/submission.cxx b/forms/source/xforms/submission.cxx index c33f1fc39f58..256838558f6e 100644 --- a/forms/source/xforms/submission.cxx +++ b/forms/source/xforms/submission.cxx @@ -42,11 +42,16 @@ #include <com/sun/star/task/XInteractionRequest.hpp> #include <com/sun/star/task/XInteractionContinuation.hpp> #include <com/sun/star/xforms/InvalidDataOnSubmitException.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> #include <com/sun/star/frame/XFrame.hpp> #include <cppuhelper/exc_hlp.hxx> #include <comphelper/interaction.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/servicehelper.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> +#include <frm_resource.hxx> +#include <strings.hrc> #include <memory> #include <string_view> @@ -55,8 +60,6 @@ using com::sun::star::form::submission::XSubmissionVetoListener; using com::sun::star::lang::WrappedTargetException; using com::sun::star::lang::NoSupportException; using com::sun::star::task::XInteractionHandler; -using com::sun::star::task::XInteractionRequest; -using com::sun::star::task::XInteractionContinuation; using com::sun::star::xforms::XModel; using com::sun::star::xforms::InvalidDataOnSubmitException; using com::sun::star::xml::xpath::XXPathObject; @@ -85,7 +88,8 @@ Submission::~Submission() noexcept void Submission::setModel( const Reference<XModel>& xModel ) { - mxModel = xModel; + mxModel = dynamic_cast<Model*>(xModel.get()); + assert(bool(mxModel)==bool(xModel) && "we only support an instance of Model here"); } @@ -202,12 +206,12 @@ bool Submission::doSubmit( const Reference< XInteractionHandler >& xHandler ) else if( !maRef.getExpression().isEmpty() ) { aExpression.setExpression( maRef.getExpression() ); - aEvalContext = comphelper::getFromUnoTunnel<Model>( mxModel )->getEvaluationContext(); + aEvalContext = mxModel->getEvaluationContext(); } else { aExpression.setExpression( "/" ); - aEvalContext = comphelper::getFromUnoTunnel<Model>( mxModel )->getEvaluationContext(); + aEvalContext = mxModel->getEvaluationContext(); } aExpression.evaluate( aEvalContext ); Reference<XXPathObject> xResult = aExpression.getXPath(); @@ -239,8 +243,31 @@ bool Submission::doSubmit( const Reference< XInteractionHandler >& xHandler ) return false; } - if (!xSubmission->IsWebProtocol()) - return false; + const INetURLObject& rURLObject = xSubmission->GetURLObject(); + INetProtocol eProtocol = rURLObject.GetProtocol(); + // tdf#154337 continue to allow submitting to http[s]: without further + // interaction. Don't allow for other protocols, except for file: + // where the user has to agree first. + if (eProtocol != INetProtocol::Http && eProtocol != INetProtocol::Https) + { + if (eProtocol != INetProtocol::File) + return false; + else + { + Reference<css::form::runtime::XFormController> xFormController(xHandler, UNO_QUERY); + Reference<css::awt::XControl> xContainerControl(xFormController ? xFormController->getContainer() : nullptr, UNO_QUERY); + Reference<css::awt::XWindow> xParent(xContainerControl ? xContainerControl->getPeer() : nullptr, UNO_QUERY); + + OUString aFileName(rURLObject.getFSysPath(FSysStyle::Detect)); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(Application::GetFrameWeld(xParent), + VclMessageType::Question, VclButtonsType::YesNo, + frm::ResourceManager::loadString(RID_STR_XFORMS_WARN_TARGET_IS_FILE).replaceFirst("$", aFileName))); + xQueryBox->set_default_response(RET_NO); + + if (xQueryBox->run() != RET_YES) + return false; + } + } CSubmission::SubmissionResult aResult = xSubmission->submit( xHandler ); @@ -253,27 +280,17 @@ bool Submission::doSubmit( const Reference< XInteractionHandler >& xHandler ) return ( aResult == CSubmission::SUCCESS ); } -Sequence<sal_Int8> Submission::getUnoTunnelId() -{ - static const comphelper::UnoIdInit aImplementationId; - return aImplementationId.getSeq(); -} - - void Submission::liveCheck() { bool bValid = mxModel.is(); if( ! bValid ) - throw RuntimeException(); + throw RuntimeException("model not set"); } -Model* Submission::getModelImpl() const +css::uno::Reference<XModel> Submission::getModel() const { - Model* pModel = nullptr; - if( mxModel.is() ) - pModel = comphelper::getFromUnoTunnel<Model>( mxModel ); - return pModel; + return mxModel; } @@ -297,32 +314,55 @@ Model* Submission::getModelImpl() const #define HANDLE_IncludeNamespacePrefixes 14 #define HANDLE_Model 15 -#define REGISTER_PROPERTY( property, type ) \ - registerProperty( PROPERTY( property, type ), \ - new DirectPropertyAccessor< Submission, type >( this, &Submission::set##property, &Submission::get##property ) ); - -#define REGISTER_PROPERTY_BOOL( property ) \ - registerProperty( PROPERTY( property, bool ), \ - new BooleanPropertyAccessor< Submission >( this, &Submission::set##property, &Submission::get##property ) ); - void Submission::initializePropertySet() { - REGISTER_PROPERTY ( ID, OUString ); - REGISTER_PROPERTY ( Bind, OUString ); - REGISTER_PROPERTY ( Ref, OUString ); - REGISTER_PROPERTY ( Action, OUString ); - REGISTER_PROPERTY ( Method, OUString ); - REGISTER_PROPERTY ( Version, OUString ); - REGISTER_PROPERTY_BOOL( Indent ); - REGISTER_PROPERTY ( MediaType, OUString ); - REGISTER_PROPERTY ( Encoding, OUString ); - REGISTER_PROPERTY_BOOL( OmitXmlDeclaration ); - REGISTER_PROPERTY_BOOL( Standalone ); - REGISTER_PROPERTY ( CDataSectionElement, OUString ); - REGISTER_PROPERTY ( Replace, OUString ); - REGISTER_PROPERTY ( Separator, OUString ); - REGISTER_PROPERTY ( IncludeNamespacePrefixes, Sequence< OUString > ); - REGISTER_PROPERTY ( Model, Reference<XModel> ); + registerProperty( css::beans::Property("ID", HANDLE_ID, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Submission, OUString >(this, &Submission::setID, &Submission::getID) ); + + registerProperty( css::beans::Property("Bind", HANDLE_Bind, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Submission, OUString >(this, &Submission::setBind, &Submission::getBind) ); + + registerProperty( css::beans::Property("Ref", HANDLE_Ref, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Submission, OUString >(this, &Submission::setRef, &Submission::getRef) ); + + registerProperty( css::beans::Property("Action", HANDLE_Action, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Submission, OUString >(this, &Submission::setAction, &Submission::getAction) ); + + registerProperty( css::beans::Property("Method", HANDLE_Method, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Submission, OUString >(this, &Submission::setMethod, &Submission::getMethod) ); + + registerProperty( css::beans::Property("Version", HANDLE_Version, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Submission, OUString >(this, &Submission::setVersion, &Submission::getVersion) ); + + registerProperty( css::beans::Property("Indent", HANDLE_Indent, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::BOUND ), + new BooleanPropertyAccessor< Submission >(this, &Submission::setIndent, &Submission::getIndent)); + + registerProperty( css::beans::Property("MediaType", HANDLE_MediaType, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Submission, OUString >(this, &Submission::setMediaType, &Submission::getMediaType) ); + + registerProperty( css::beans::Property("Encoding", HANDLE_Encoding, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Submission, OUString >(this, &Submission::setEncoding, &Submission::getEncoding) ); + + registerProperty( css::beans::Property("OmitXmlDeclaration", HANDLE_OmitXmlDeclaration, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::BOUND ), + new BooleanPropertyAccessor< Submission >(this, &Submission::setOmitXmlDeclaration, &Submission::getOmitXmlDeclaration)); + + registerProperty( css::beans::Property("Standalone", HANDLE_Standalone, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::BOUND ), + new BooleanPropertyAccessor< Submission >(this, &Submission::setStandalone, &Submission::getStandalone)); + + registerProperty( css::beans::Property("CDataSectionElement", HANDLE_CDataSectionElement, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Submission, OUString >(this, &Submission::setCDataSectionElement, &Submission::getCDataSectionElement) ); + + registerProperty( css::beans::Property("Replace", HANDLE_Replace, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Submission, OUString >(this, &Submission::setReplace, &Submission::getReplace) ); + + registerProperty( css::beans::Property("Separator", HANDLE_Separator, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Submission, OUString >(this, &Submission::setSeparator, &Submission::getSeparator) ); + + registerProperty( css::beans::Property("IncludeNamespacePrefixes", HANDLE_IncludeNamespacePrefixes, cppu::UnoType<Sequence<OUString>>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Submission, Sequence<OUString> >(this, &Submission::setIncludeNamespacePrefixes, &Submission::getIncludeNamespacePrefixes) ); + + registerProperty( css::beans::Property("Model", HANDLE_Model, cppu::UnoType<Reference<XModel>>::get(), css::beans::PropertyAttribute::BOUND ), + new DirectPropertyAccessor< Submission, Reference<XModel> >(this, &Submission::setModel, &Submission::getModel) ); initializePropertyValueCache( HANDLE_Indent ); initializePropertyValueCache( HANDLE_OmitXmlDeclaration ); @@ -345,7 +385,7 @@ sal_Bool SAL_CALL Submission::convertFastPropertyValue( aPrefixes.push_back( sTokenList.getToken( 0, ',', p ) ); Sequence< OUString > aConvertedPrefixes( aPrefixes.data(), aPrefixes.size() ); - return PropertySetBase::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, makeAny( aConvertedPrefixes ) ); + return PropertySetBase::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, Any( aConvertedPrefixes ) ); } } @@ -363,13 +403,6 @@ void SAL_CALL Submission::setName( const OUString& sID ) } -sal_Int64 SAL_CALL Submission::getSomething( - const Sequence<sal_Int8>& aId ) -{ - return comphelper::getSomethingImpl(aId, this); -} - - static OUString lcl_message( std::u16string_view rID, std::u16string_view rText ) { OUString aMessage = OUString::Concat("XForms submission '") + rID + "' failed" + rText + "."; @@ -381,7 +414,7 @@ void SAL_CALL Submission::submitWithInteraction( { // as long as this class is not really threadsafe, we need to copy // the members we're interested in - Reference< XModel > xModel( mxModel ); + rtl::Reference< Model > xModel( mxModel ); OUString sID( msID ); if ( !xModel.is() || msID.isEmpty() ) @@ -390,12 +423,9 @@ void SAL_CALL Submission::submitWithInteraction( *this ); - Model* pModel = comphelper::getFromUnoTunnel<Model>( xModel ); - OSL_ENSURE( pModel != nullptr, "illegal model?" ); - // #i36765# #i47248# warning on submission of illegal data // check for validity (and query user if invalid) - bool bValid = pModel->isValid(); + bool bValid = xModel->isValid(); if( ! bValid ) { InvalidDataOnSubmitException aInvalidDataException( @@ -406,7 +436,7 @@ void SAL_CALL Submission::submitWithInteraction( // laboriously create interaction request rtl::Reference<comphelper::OInteractionRequest> pRequest = new comphelper::OInteractionRequest( - makeAny( aInvalidDataException ) ); + Any( aInvalidDataException ) ); rtl::Reference<comphelper::OInteractionApprove> pContinue = new comphelper::OInteractionApprove(); diff --git a/forms/source/xforms/submission.hxx b/forms/source/xforms/submission.hxx index 1e7f17e4cfc7..b8f7fb11d87e 100644 --- a/forms/source/xforms/submission.hxx +++ b/forms/source/xforms/submission.hxx @@ -21,7 +21,6 @@ #include <cppuhelper/implbase.hxx> #include "propertysetbase.hxx" -#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> #include <com/sun/star/xml/dom/XDocumentFragment.hpp> #include <com/sun/star/xml/xpath/XXPathObject.hpp> @@ -52,7 +51,6 @@ namespace xforms */ typedef cppu::ImplInheritanceHelper< PropertySetBase, - css::lang::XUnoTunnel, css::xforms::XSubmission > Submission_t; @@ -78,7 +76,7 @@ class Submission : public Submission_t private: /// the Model to which this Submission belongs; may be NULL - css::uno::Reference<css::xforms::XModel> mxModel; + rtl::Reference<Model> mxModel; // this will extract the document from the model that will be submitted css::uno::Reference< css::xml::dom::XDocumentFragment > @@ -96,8 +94,10 @@ public: /// get XForms model - css::uno::Reference<css::xforms::XModel> - getModel() const { return mxModel;} + css::uno::Reference<css::xforms::XModel> getModel() const; + + /// get the model implementation + xforms::Model* getModelImpl() const { return mxModel.get(); } /// set XForms model void setModel( @@ -152,9 +152,6 @@ public: * @returns if submission was successful */ bool doSubmit( const css::uno::Reference< css::task::XInteractionHandler >& aHandler ); - // helpers for UNO tunnel - static css::uno::Sequence<sal_Int8> getUnoTunnelId(); - private: /// check whether object is live, and throw suitable exception if not @@ -163,9 +160,6 @@ private: /// @throws css::uno::RuntimeException void liveCheck(); - /// get the model implementation - xforms::Model* getModelImpl() const; - protected: @@ -195,13 +189,6 @@ public: virtual void SAL_CALL setName( const OUString& ) override; - // XUnoTunnel - - - virtual sal_Int64 SAL_CALL getSomething( - const css::uno::Sequence<sal_Int8>& ) override; - - // XSubmission diff --git a/forms/source/xforms/submission/replace.cxx b/forms/source/xforms/submission/replace.cxx index 27e9fad49ab5..ca91176c4c76 100644 --- a/forms/source/xforms/submission/replace.cxx +++ b/forms/source/xforms/submission/replace.cxx @@ -23,7 +23,8 @@ #include <rtl/ustring.hxx> #include <rtl/ref.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> +#include <o3tl/string_view.hxx> #include <comphelper/processfactory.hxx> #include <com/sun/star/uno/Reference.hxx> @@ -43,15 +44,15 @@ using namespace com::sun::star::beans; using namespace com::sun::star::task; using namespace com::sun::star::xml::dom; -CSubmission::SubmissionResult CSubmission::replace(const OUString& aReplace, const Reference<XDocument>& aDocument, const Reference<XFrame>& aFrame) +CSubmission::SubmissionResult CSubmission::replace(std::u16string_view aReplace, const Reference<XDocument>& aDocument, const Reference<XFrame>& aFrame) { if (!m_aResultStream.is()) return CSubmission::UNKNOWN_ERROR; try { Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); - if (aReplace.equalsIgnoreAsciiCase("all") - || aReplace.equalsIgnoreAsciiCase("document")) { + if (o3tl::equalsIgnoreAsciiCase(aReplace, u"all") + || o3tl::equalsIgnoreAsciiCase(aReplace, u"document")) { Reference< XComponentLoader > xLoader; if (aFrame.is()) xLoader.set(aFrame, UNO_QUERY); @@ -61,18 +62,19 @@ CSubmission::SubmissionResult CSubmission::replace(const OUString& aReplace, con // open the stream from the result... // build media descriptor - Sequence< PropertyValue > descriptor(2); - descriptor[0] = PropertyValue("InputStream", - -1, makeAny(m_aResultStream), PropertyState_DIRECT_VALUE); - descriptor[1] = PropertyValue("ReadOnly", - -1, makeAny(true), PropertyState_DIRECT_VALUE); + Sequence< PropertyValue > descriptor{ + PropertyValue("InputStream", + -1, Any(m_aResultStream), PropertyState_DIRECT_VALUE), + PropertyValue("ReadOnly", + -1, Any(true), PropertyState_DIRECT_VALUE) + }; OUString aURL = m_aURLObj.GetMainURL(INetURLObject::DecodeMechanism::NONE); xLoader->loadComponentFromURL(aURL, "_default", FrameSearchFlag::ALL, descriptor); return CSubmission::SUCCESS; - } else if (aReplace.equalsIgnoreAsciiCase("instance")) { + } else if (o3tl::equalsIgnoreAsciiCase(aReplace, u"instance")) { if (aDocument.is()) { // parse the result stream into a new document Reference< XDocumentBuilder > xBuilder(DocumentBuilder::create(xContext)); @@ -93,7 +95,7 @@ CSubmission::SubmissionResult CSubmission::replace(const OUString& aReplace, con // nothing to replace return CSubmission::UNKNOWN_ERROR; } - } else if (aReplace.equalsIgnoreAsciiCase("none")) { + } else if (o3tl::equalsIgnoreAsciiCase(aReplace, u"none")) { // do nothing \o/ return CSubmission::SUCCESS; } diff --git a/forms/source/xforms/submission/serialization_app_xml.cxx b/forms/source/xforms/submission/serialization_app_xml.cxx index 61729d027673..0e34f3d418c8 100644 --- a/forms/source/xforms/submission/serialization_app_xml.cxx +++ b/forms/source/xforms/submission/serialization_app_xml.cxx @@ -30,7 +30,7 @@ #include <com/sun/star/beans/StringPair.hpp> #include <com/sun/star/xml/dom/XDocumentBuilder.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <comphelper/processfactory.hxx> using ::com::sun::star::uno::Reference; diff --git a/forms/source/xforms/submission/serialization_urlencoded.cxx b/forms/source/xforms/submission/serialization_urlencoded.cxx index 22a625ccb4a0..8b2c78695d6a 100644 --- a/forms/source/xforms/submission/serialization_urlencoded.cxx +++ b/forms/source/xforms/submission/serialization_urlencoded.cxx @@ -35,7 +35,6 @@ using namespace css::uno; using namespace css::io; -using namespace css::xml::xpath; using namespace css::xml::dom; CSerializationURLEncoded::CSerializationURLEncoded() diff --git a/forms/source/xforms/submission/submission.hxx b/forms/source/xforms/submission/submission.hxx index 655529063a7d..26a2514c829d 100644 --- a/forms/source/xforms/submission/submission.hxx +++ b/forms/source/xforms/submission/submission.hxx @@ -21,7 +21,6 @@ #include <tools/urlobj.hxx> #include <osl/conditn.hxx> -#include <osl/mutex.hxx> #include <comphelper/processfactory.hxx> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Any.hxx> @@ -39,6 +38,8 @@ #include "serialization.hxx" #include <memory> +#include <mutex> +#include <utility> class CSubmissionPut; class CSubmissionPost; @@ -71,7 +72,7 @@ class CProgressHandlerHelper final : public cppu::WeakImplHelper< css::ucb::XPro friend class CSubmissionPost; friend class CSubmissionGet; osl::Condition m_cFinished; - osl::Mutex m_mLock; + std::mutex m_mLock; sal_Int32 m_count; public: CProgressHandlerHelper() @@ -79,20 +80,18 @@ public: {} virtual void SAL_CALL push( const css::uno::Any& /*aStatus*/) override { - m_mLock.acquire(); + std::unique_lock g(m_mLock); m_count++; - m_mLock.release(); } virtual void SAL_CALL update(const css::uno::Any& /*aStatus*/) override { } virtual void SAL_CALL pop() override { - m_mLock.acquire(); + std::unique_lock g(m_mLock); m_count--; if (m_count == 0) m_cFinished.set(); - m_mLock.release(); } }; @@ -114,23 +113,19 @@ public: UNKNOWN_ERROR }; - CSubmission(const OUString& aURL, const css::uno::Reference< css::xml::dom::XDocumentFragment >& aFragment) + CSubmission(std::u16string_view aURL, css::uno::Reference< css::xml::dom::XDocumentFragment > aFragment) : m_aURLObj(aURL) - , m_aFragment(aFragment) + , m_aFragment(std::move(aFragment)) , m_xContext(::comphelper::getProcessComponentContext()) {} - bool IsWebProtocol() const - { - INetProtocol eProtocol = m_aURLObj.GetProtocol(); - return eProtocol == INetProtocol::Http || eProtocol == INetProtocol::Https; - } + const INetURLObject& GetURLObject() const { return m_aURLObj; } virtual ~CSubmission() {} virtual SubmissionResult submit(const css::uno::Reference< css::task::XInteractionHandler >& ) = 0; - SubmissionResult replace(const OUString&, const css::uno::Reference< css::xml::dom::XDocument >&, const css::uno::Reference< css::frame::XFrame>&); + SubmissionResult replace(std::u16string_view, const css::uno::Reference< css::xml::dom::XDocument >&, const css::uno::Reference< css::frame::XFrame>&); }; diff --git a/forms/source/xforms/submission/submission_get.cxx b/forms/source/xforms/submission/submission_get.cxx index 72a9ffc1eee2..4ee8140b2172 100644 --- a/forms/source/xforms/submission/submission_get.cxx +++ b/forms/source/xforms/submission/submission_get.cxx @@ -24,21 +24,17 @@ #include <rtl/strbuf.hxx> #include <osl/diagnose.h> #include <ucbhelper/content.hxx> -#include <com/sun/star/io/Pipe.hpp> #include <com/sun/star/task/InteractionHandler.hpp> -#include <tools/diagnose_ex.h> - -#include <memory> +#include <comphelper/diagnose_ex.hxx> using namespace css::uno; using namespace css::ucb; using namespace css::task; using namespace css::io; -using namespace osl; using namespace ucbhelper; -CSubmissionGet::CSubmissionGet(const OUString& aURL, const css::uno::Reference< css::xml::dom::XDocumentFragment >& aFragment) +CSubmissionGet::CSubmissionGet(std::u16string_view aURL, const css::uno::Reference< css::xml::dom::XDocumentFragment >& aFragment) : CSubmission(aURL, aFragment) { } @@ -78,14 +74,10 @@ CSubmission::SubmissionResult CSubmissionGet::submit(const css::uno::Reference< aQueryString.append(reinterpret_cast<char const *>(aByteBuffer.getConstArray()), n); if (!aQueryString.isEmpty() && m_aURLObj.GetProtocol() != INetProtocol::File) { - aUTF8QueryURL.append('?'); - aUTF8QueryURL.append(aQueryString); + aUTF8QueryURL.append("?" + aQueryString); } - OUString aQueryURL = OStringToOUString(aUTF8QueryURL.makeStringAndClear(), RTL_TEXTENCODING_UTF8); + OUString aQueryURL = OStringToOUString(aUTF8QueryURL, RTL_TEXTENCODING_UTF8); ucbhelper::Content aContent(aQueryURL, aEnvironment, m_xContext); - css::uno::Reference< XOutputStream > aPipe( css::io::Pipe::create(m_xContext), UNO_QUERY_THROW ); - if (!aContent.openStream(aPipe)) - return UNKNOWN_ERROR; // get reply try { m_aResultStream = aContent.openStream(); diff --git a/forms/source/xforms/submission/submission_get.hxx b/forms/source/xforms/submission/submission_get.hxx index 10375c5b266e..086fab25b2be 100644 --- a/forms/source/xforms/submission/submission_get.hxx +++ b/forms/source/xforms/submission/submission_get.hxx @@ -24,7 +24,7 @@ class CSubmissionGet : public CSubmission { public: - CSubmissionGet(const OUString& aURL, + CSubmissionGet(std::u16string_view aURL, const css::uno::Reference<css::xml::dom::XDocumentFragment>& aFragment); virtual SubmissionResult submit(const css::uno::Reference<css::task::XInteractionHandler>& aInteractionHandler) override; diff --git a/forms/source/xforms/submission/submission_post.cxx b/forms/source/xforms/submission/submission_post.cxx index d5629857f81b..90cfd68c4f27 100644 --- a/forms/source/xforms/submission/submission_post.cxx +++ b/forms/source/xforms/submission/submission_post.cxx @@ -26,17 +26,16 @@ #include <ucbhelper/content.hxx> #include <ucbhelper/activedatasink.hxx> #include <com/sun/star/ucb/PostCommandArgument2.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> using namespace css::uno; using namespace css::ucb; using namespace css::task; using namespace css::io; -using namespace osl; using namespace ucbhelper; -CSubmissionPost::CSubmissionPost(const OUString& aURL, const css::uno::Reference< css::xml::dom::XDocumentFragment >& aFragment) +CSubmissionPost::CSubmissionPost(std::u16string_view aURL, const css::uno::Reference< css::xml::dom::XDocumentFragment >& aFragment) : CSubmission(aURL, aFragment) { } diff --git a/forms/source/xforms/submission/submission_post.hxx b/forms/source/xforms/submission/submission_post.hxx index c3f67443c8df..0fb63472b107 100644 --- a/forms/source/xforms/submission/submission_post.hxx +++ b/forms/source/xforms/submission/submission_post.hxx @@ -24,7 +24,7 @@ class CSubmissionPost : public CSubmission { public: - CSubmissionPost(const OUString& aURL, const css::uno::Reference< css::xml::dom::XDocumentFragment >& aFragment); + CSubmissionPost(std::u16string_view aURL, const css::uno::Reference< css::xml::dom::XDocumentFragment >& aFragment); virtual SubmissionResult submit(const css::uno::Reference< css::task::XInteractionHandler >& aInteractionHandler) override; }; diff --git a/forms/source/xforms/submission/submission_put.cxx b/forms/source/xforms/submission/submission_put.cxx index 071e527ea226..d0fd3bc25787 100644 --- a/forms/source/xforms/submission/submission_put.cxx +++ b/forms/source/xforms/submission/submission_put.cxx @@ -23,19 +23,17 @@ #include "submission_put.hxx" #include <comphelper/processfactory.hxx> -#include <osl/diagnose.h> #include <ucbhelper/content.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> using namespace css::uno; using namespace css::ucb; using namespace css::task; using namespace css::io; -using namespace osl; using namespace ucbhelper; -CSubmissionPut::CSubmissionPut(const OUString& aURL, const css::uno::Reference< css::xml::dom::XDocumentFragment >& aFragment) +CSubmissionPut::CSubmissionPut(std::u16string_view aURL, const css::uno::Reference< css::xml::dom::XDocumentFragment >& aFragment) : CSubmission(aURL, aFragment) { } diff --git a/forms/source/xforms/submission/submission_put.hxx b/forms/source/xforms/submission/submission_put.hxx index f5e6c2b36ffc..2dce84307bde 100644 --- a/forms/source/xforms/submission/submission_put.hxx +++ b/forms/source/xforms/submission/submission_put.hxx @@ -24,7 +24,7 @@ class CSubmissionPut : public CSubmission { public: - CSubmissionPut(const OUString& aURL, + CSubmissionPut(std::u16string_view aURL, const css::uno::Reference<css::xml::dom::XDocumentFragment>& aFragment); virtual SubmissionResult submit(const css::uno::Reference<css::task::XInteractionHandler>& aInteractionHandler) override; diff --git a/forms/source/xforms/xpathlib/extension.cxx b/forms/source/xforms/xpathlib/extension.cxx index 0af6a3eb17db..866dd19f592e 100644 --- a/forms/source/xforms/xpathlib/extension.cxx +++ b/forms/source/xforms/xpathlib/extension.cxx @@ -28,7 +28,6 @@ namespace com::sun::star::uno { } using namespace com::sun::star::uno; -using namespace com::sun::star::lang; using namespace com::sun::star::xforms; using namespace com::sun::star::xml::xpath; using namespace com::sun::star::beans; diff --git a/forms/source/xforms/xpathlib/xpathlib.cxx b/forms/source/xforms/xpathlib/xpathlib.cxx index 12a955639538..ffae5a59ca34 100644 --- a/forms/source/xforms/xpathlib/xpathlib.cxx +++ b/forms/source/xforms/xpathlib/xpathlib.cxx @@ -21,6 +21,7 @@ #include <string.h> #include <comphelper/servicehelper.hxx> +#include <o3tl/string_view.hxx> #include <sal/types.h> #include <rtl/ustring.hxx> #include <rtl/string.hxx> @@ -276,37 +277,40 @@ void xforms_nowFunction(xmlXPathParserContextPtr ctxt, int /*nargs*/) be omitted or, if present, the time zone must be Coordinated Universal tools::Time (UTC) indicated by a "Z". */ - DateTime aDateTime( DateTime::SYSTEM ); - OString aDateTimeString = makeDateTimeString(aDateTime); + OString aDateTimeString; + if (std::getenv("STABLE_FIELDS_HACK")) + aDateTimeString = makeDateTimeString(DateTime(DateTime::EMPTY)); + else + aDateTimeString = makeDateTimeString(DateTime(DateTime::SYSTEM)); xmlChar *pString = static_cast<xmlChar*>(xmlMalloc(aDateTimeString.getLength()+1)); strncpy(reinterpret_cast<char*>(pString), aDateTimeString.getStr(), aDateTimeString.getLength()); pString[aDateTimeString.getLength()] = 0; xmlXPathReturnString(ctxt, pString); } -static bool parseDateTime(const OUString& aString, DateTime& aDateTime) +static bool parseDateTime(std::u16string_view aString, DateTime& aDateTime) { // take apart a canonical literal xsd:dateTime string //CCYY-MM-DDThh:mm:ss(Z) - OUString aDateTimeString = aString.trim(); + OUString aDateTimeString( o3tl::trim(aString) ); // check length if (aDateTimeString.getLength() < 19 || aDateTimeString.getLength() > 20) return false; sal_Int32 nIndex = 0; - sal_Int32 nYear = aDateTimeString.getToken(0, '-', nIndex).toInt32(); - sal_Int32 nMonth = aDateTimeString.getToken(0, '-', nIndex).toInt32(); - sal_Int32 nDay = aDateTimeString.getToken(0, 'T', nIndex).toInt32(); - sal_Int32 nHour = aDateTimeString.getToken(0, ':', nIndex).toInt32(); - sal_Int32 nMinute = aDateTimeString.getToken(0, ':', nIndex).toInt32(); - sal_Int32 nSecond = aDateTimeString.getToken(0, 'Z', nIndex).toInt32(); + sal_Int32 nYear = o3tl::toInt32(o3tl::getToken(aDateTimeString, 0, '-', nIndex)); + sal_Int32 nMonth = o3tl::toInt32(o3tl::getToken(aDateTimeString, 0, '-', nIndex)); + sal_Int32 nDay = o3tl::toInt32(o3tl::getToken(aDateTimeString, 0, 'T', nIndex)); + sal_Int32 nHour = o3tl::toInt32(o3tl::getToken(aDateTimeString, 0, ':', nIndex)); + sal_Int32 nMinute = o3tl::toInt32(o3tl::getToken(aDateTimeString, 0, ':', nIndex)); + sal_Int32 nSecond = o3tl::toInt32(o3tl::getToken(aDateTimeString, 0, 'Z', nIndex)); Date tmpDate(static_cast<sal_uInt16>(nDay), static_cast<sal_uInt16>(nMonth), static_cast<sal_uInt16>(nYear)); tools::Time tmpTime(nHour, nMinute, nSecond); DateTime tmpDateTime(tmpDate, tmpTime); - if (aString.lastIndexOf('Z') < 0) + if (aString.rfind('Z') == std::u16string_view::npos) tmpDateTime.ConvertToUTC(); aDateTime = tmpDateTime; |