diff options
Diffstat (limited to 'forms/source/component')
76 files changed, 2003 insertions, 1407 deletions
diff --git a/forms/source/component/BaseListBox.hxx b/forms/source/component/BaseListBox.hxx index 1e3ee87a1136..fe0930ea70d1 100644 --- a/forms/source/component/BaseListBox.hxx +++ b/forms/source/component/BaseListBox.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_BASELISTBOX_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_BASELISTBOX_HXX +#pragma once #include <sal/types.h> @@ -28,6 +27,4 @@ const sal_uInt16 ENTRY_NOT_FOUND = 0xFFFF; const sal_uInt16 BOUNDCOLUMN = 0x0001; } -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_BASELISTBOX_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/component/Button.cxx b/forms/source/component/Button.cxx index 42592fa1f76e..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 @@ -142,7 +152,7 @@ void OButtonModel::write(const Reference<XObjectOutputStream>& _rxOutStream) _rxOutStream->writeShort(0x0003); // Version { - OStreamSection aSection( _rxOutStream.get() ); + OStreamSection aSection( _rxOutStream ); // this will allow readers to skip unknown bytes in their dtor _rxOutStream->writeShort( static_cast<sal_uInt16>(m_eButtonType) ); @@ -184,7 +194,7 @@ void OButtonModel::read(const Reference<XObjectInputStream>& _rxInStream) case 0x0003: { - OStreamSection aSection( _rxInStream.get() ); + OStreamSection aSection( _rxInStream ); // this will skip any unknown bytes in its dtor // button type @@ -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 95438dc86cbf..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; @@ -59,7 +60,7 @@ const sal_uInt16 COMPATIBLE_HIDDEN = 0x0008; const css::uno::Sequence<OUString>& getColumnTypes() { - static css::uno::Sequence<OUString> aColumnTypes = [&]() + static css::uno::Sequence<OUString> aColumnTypes = []() { css::uno::Sequence<OUString> tmp(10); OUString* pNames = tmp.getArray(); @@ -81,8 +82,8 @@ const css::uno::Sequence<OUString>& getColumnTypes() sal_Int32 getColumnTypeByModelName(const OUString& aModelName) { - const OUString aModelPrefix ("com.sun.star.form.component."); - const OUString aCompatibleModelPrefix ("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) @@ -106,14 +107,10 @@ sal_Int32 getColumnTypeByModelName(const OUString& aModelName) return nTypeId; } -namespace -{ - class theOGridColumnImplementationId : public rtl::Static< UnoTunnelIdInit, theOGridColumnImplementationId > {}; -} - const Sequence<sal_Int8>& OGridColumn::getUnoTunnelId() { - return theOGridColumnImplementationId::get().getSeq(); + static const comphelper::UnoIdInit theOGridColumnImplementationId; + return theOGridColumnImplementationId.getSeq(); } @@ -121,9 +118,9 @@ sal_Int64 SAL_CALL OGridColumn::getSomething( const Sequence<sal_Int8>& _rIdenti { sal_Int64 nReturn(0); - if ( isUnoTunnelId<OGridColumn>(_rIdentifier) ) + if ( comphelper::isUnoTunnelId<OGridColumn>(_rIdentifier) ) { - nReturn = reinterpret_cast<sal_Int64>(this); + nReturn = comphelper::getSomething_cast(this); } else { @@ -189,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 @@ -349,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> @@ -445,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); } @@ -455,8 +453,7 @@ Any OGridColumn::getPropertyDefaultByHandle( sal_Int32 nHandle ) const Reference< XCloneable > SAL_CALL OGridColumn::createClone( ) { - OGridColumn* pNewColumn = createCloneColumn(); - return pNewColumn; + return createCloneColumn(); } // XPersistObject @@ -557,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); +} + +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); +} -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); +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 010252615930..6c12197b90a5 100644 --- a/forms/source/component/Columns.hxx +++ b/forms/source/component/Columns.hxx @@ -32,6 +32,7 @@ #include <comphelper/uno3.hxx> #include <cppuhelper/basemutex.hxx> #include <cppuhelper/compbase2.hxx> +#include <rtl/ref.hxx> using namespace comphelper; @@ -59,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; @@ -106,65 +107,9 @@ protected: static void clearAggregateProperties(css::uno::Sequence< css::beans::Property>& seqProps, bool bAllowDropDown); static void setOwnProperties(css::uno::Sequence< css::beans::Property>& seqProps); - virtual OGridColumn* createCloneColumn() const = 0; + 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 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); \ - } \ -} \ -OGridColumn* ClassName::createCloneColumn() const \ -{ \ - return new ClassName( this ); \ -} \ - \ // column type ids #define TYPE_CHECKBOX 0 #define TYPE_COMBOBOX 1 @@ -182,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 f9eaab0b31b5..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() @@ -112,7 +110,6 @@ OComboBoxModel::OComboBoxModel(const Reference<XComponentContext>& _rxFactory) // use the old control name for compatibility reasons ,OEntryListHelper( static_cast<OControlModel&>(*this) ) ,OErrorBroadcaster( OComponentHelper::rBHelper ) - ,m_aListRowSet() ,m_eListSourceType(ListSourceType_TABLE) ,m_bEmptyIsNull(true) { @@ -125,7 +122,6 @@ OComboBoxModel::OComboBoxModel( const OComboBoxModel* _pOriginal, const Referenc :OBoundControlModel( _pOriginal, _rxFactory ) ,OEntryListHelper( *_pOriginal, static_cast<OControlModel&>(*this) ) ,OErrorBroadcaster( OComponentHelper::rBHelper ) - ,m_aListRowSet() ,m_aListSource( _pOriginal->m_aListSource ) ,m_aDefaultText( _pOriginal->m_aDefaultText ) ,m_eListSourceType( _pOriginal->m_eListSourceType ) @@ -146,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() @@ -293,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 ?"); } @@ -406,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; } @@ -437,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) @@ -537,14 +542,14 @@ void OComboBoxModel::loadData( bool _bForce ) OUString sCatalog, sSchema, sTable; qualifiedNameComponents( xMeta, m_aListSource, sCatalog, sSchema, sTable, EComposeRule::InDataManipulation ); - OUStringBuffer aStatement; - aStatement.append( "SELECT DISTINCT " ); - aStatement.append ( quoteName( aQuote, aFieldName ) ); - aStatement.append( " FROM " ); - aStatement.append ( composeTableNameForSelect( xConnection, sCatalog, sSchema, sTable ) ); + OUString aStatement = + "SELECT DISTINCT " + + quoteName( aQuote, aFieldName ) + + " FROM " + + composeTableNameForSelect( xConnection, sCatalog, sSchema, sTable ); m_aListRowSet.setEscapeProcessing( false ); - m_aListRowSet.setCommand( aStatement.makeStringAndClear() ); + m_aListRowSet.setCommand( aStatement ); bExecuteRowSet = true; } } break; @@ -577,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& ) @@ -634,8 +639,7 @@ void OComboBoxModel::loadData( bool _bForce ) if (xFieldNames.is()) { const Sequence<OUString> aFieldNames = xFieldNames->getElementNames(); - for (const OUString& rustrNames : aFieldNames) - aStringList.push_back(rustrNames); + aStringList.insert(aStringList.end(), aFieldNames.begin(), aFieldNames.end()); } } break; @@ -646,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& ) @@ -656,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>() ) ); } @@ -681,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(); } @@ -749,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; @@ -802,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 ); } @@ -817,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 3fc0240d9483..ed2360144225 100644 --- a/forms/source/component/ComboBox.hxx +++ b/forms/source/component/ComboBox.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_COMBOBOX_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_COMBOBOX_HXX +#pragma once #include <memory> #include <FormComponent.hxx> @@ -55,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; @@ -136,6 +142,4 @@ public: } -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_COMBOBOX_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 066eeb45e293..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; } @@ -1373,10 +1380,8 @@ void SAL_CALL ODatabaseForm::clearWarnings( ) Reference< XCloneable > SAL_CALL ODatabaseForm::createClone( ) { - ODatabaseForm* pClone = new ODatabaseForm( *this ); - osl_atomic_increment( &pClone->m_refCount ); + rtl::Reference<ODatabaseForm> pClone = new ODatabaseForm( *this ); pClone->clonedFrom( *this ); - osl_atomic_decrement( &pClone->m_refCount ); return pClone; } @@ -1609,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: @@ -1887,7 +1892,7 @@ void SAL_CALL ODatabaseForm::reset() return; } - if ( !m_aResetListeners.empty() ) + if ( m_aResetListeners.getLength() ) { ::osl::MutexGuard aResetGuard(m_aResetSafety); ++m_nResetsPending; @@ -1915,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 @@ -1943,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 ); @@ -2020,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(); @@ -2035,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 ); } @@ -2091,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)); @@ -2101,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); } @@ -2110,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; } @@ -2181,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); } } @@ -2214,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); } @@ -2356,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() ) ); } @@ -2407,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; } } @@ -2446,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)); } } @@ -2669,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; @@ -2711,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 @@ -2746,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(); } @@ -2789,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&) { @@ -2820,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 @@ -2830,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); } @@ -2918,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(); } } @@ -2931,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&) @@ -2941,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 @@ -3021,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 ) ) @@ -3066,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 ) ) @@ -3110,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; } @@ -3426,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; } } @@ -3446,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; } } @@ -3466,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; } } @@ -3486,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; } } @@ -3550,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; } @@ -3888,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; @@ -3907,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(); @@ -3926,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(); @@ -3948,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)); } } @@ -3970,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)); } } @@ -4036,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 be9e9696734e..df7b33ee134f 100644 --- a/forms/source/component/EventThread.hxx +++ b/forms/source/component/EventThread.hxx @@ -21,6 +21,8 @@ #include <sal/config.h> +#include <memory> +#include <mutex> #include <vector> #include <com/sun/star/lang/XEventListener.hpp> @@ -49,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 651d830ace92..6ef7532aa842 100644 --- a/forms/source/component/File.hxx +++ b/forms/source/component/File.hxx @@ -17,10 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_FILE_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_FILE_HXX +#pragma once #include <FormComponent.hxx> +#include <comphelper/interfacecontainer3.hxx> namespace frm @@ -30,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; @@ -86,6 +93,4 @@ protected: } // namespace frm -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_FILE_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx index 191173f276e4..bf33ce4ae8b8 100644 --- a/forms/source/component/Filter.cxx +++ b/forms/source/component/Filter.cxx @@ -20,8 +20,7 @@ #include <sal/config.h> #include <config_features.h> - -#include <string_view> +#include <config_fuzzers.h> #include "Filter.hxx" #include <strings.hrc> @@ -57,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> @@ -75,11 +74,8 @@ namespace frm using namespace ::com::sun::star::container; using namespace ::com::sun::star::ui::dialogs; - using namespace ::connectivity; - OFilterControl::OFilterControl( const Reference< XComponentContext >& _rxORB ) - :UnoControl() - ,m_aTextListeners( *this ) + :m_aTextListeners( *this ) ,m_xContext( _rxORB ) ,m_nControlClass( FormComponentType::TEXTFIELD ) ,m_bFilterList( false ) @@ -91,7 +87,7 @@ namespace frm bool OFilterControl::ensureInitialized( ) { -#if HAVE_FEATURE_DBCONNECTIVITY +#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS if ( !m_xField.is() ) { OSL_FAIL( "OFilterControl::ensureInitialized: improperly initialized: no field!" ); @@ -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& ) { @@ -272,7 +268,7 @@ namespace frm void SAL_CALL OFilterControl::itemStateChanged( const ItemEvent& rEvent ) { -#if !HAVE_FEATURE_DBCONNECTIVITY +#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS (void) rEvent; #else OUStringBuffer aText; @@ -306,7 +302,7 @@ namespace frm // To fix this, we would probably have to revert here to always return "1" or "0" as normalized // filter, and change our client code to properly translate this (which could be some effort). if ( nMarkerPos == 0 ) - aText.append( std::u16string_view(sText).substr(sExpressionMarker.getLength()) ); + aText.append( sText.subView(sExpressionMarker.getLength()) ); else { // fallback @@ -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 } @@ -367,7 +361,7 @@ namespace frm void OFilterControl::implInitFilterList() { -#if HAVE_FEATURE_DBCONNECTIVITY +#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS if ( !ensureInitialized( ) ) // already asserted in ensureInitialized return; @@ -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 " ); @@ -492,7 +484,7 @@ namespace frm sal_Bool SAL_CALL OFilterControl::commit() { -#if HAVE_FEATURE_DBCONNECTIVITY +#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS if ( !ensureInitialized( ) ) // already asserted in ensureInitialized return true; @@ -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& ) @@ -807,7 +794,7 @@ namespace frm void OFilterControl::initControlModel(Reference< XPropertySet > const & xControlModel) { -#if !HAVE_FEATURE_DBCONNECTIVITY +#if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS (void) xControlModel; #else if ( !xControlModel.is() ) diff --git a/forms/source/component/Filter.hxx b/forms/source/component/Filter.hxx index ed05f01f27e4..8815f5f11a02 100644 --- a/forms/source/component/Filter.hxx +++ b/forms/source/component/Filter.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_FILTER_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_FILTER_HXX +#pragma once #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XInitialization.hpp> @@ -81,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 @@ -136,6 +135,4 @@ namespace frm } // namespace frm -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_FILTER_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 58c2a8a07092..a4bafab60d27 100644 --- a/forms/source/component/FixedText.hxx +++ b/forms/source/component/FixedText.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_FIXEDTEXT_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_FIXEDTEXT_HXX +#pragma once #include <FormComponent.hxx> @@ -30,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 @@ -58,6 +64,4 @@ protected: } -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_FIXEDTEXT_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index 8b3047cc176b..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() @@ -1128,8 +1146,6 @@ OBoundControlModel::OBoundControlModel( const bool _bCommitable, const bool _bSupportExternalBinding, const bool _bSupportsValidation ) :OControlModel( _rxFactory, _rUnoControlModelTypeName, _rDefault, false ) ,OPropertyChangeListener( m_aMutex ) - ,m_xField() - ,m_xAmbientForm() ,m_nValuePropertyAggregateHandle( -1 ) ,m_nFieldType( DataType::OTHER ) ,m_bValuePropertyMayBeVoid( false ) @@ -1137,7 +1153,6 @@ OBoundControlModel::OBoundControlModel( ,m_aUpdateListeners(m_aMutex) ,m_aFormComponentListeners( m_aMutex ) ,m_bInputRequired( false ) - ,m_pAggPropMultiplexer( nullptr ) ,m_bFormListening( false ) ,m_bLoaded(false) ,m_bRequired(false) @@ -1160,8 +1175,6 @@ OBoundControlModel::OBoundControlModel( const OBoundControlModel* _pOriginal, const Reference< XComponentContext>& _rxFactory ) :OControlModel( _pOriginal, _rxFactory, true, false ) ,OPropertyChangeListener( m_aMutex ) - ,m_xField() - ,m_xAmbientForm() ,m_nValuePropertyAggregateHandle( _pOriginal->m_nValuePropertyAggregateHandle ) ,m_nFieldType( DataType::OTHER ) ,m_bValuePropertyMayBeVoid( _pOriginal->m_bValuePropertyMayBeVoid ) @@ -1170,7 +1183,6 @@ OBoundControlModel::OBoundControlModel( ,m_aFormComponentListeners( m_aMutex ) ,m_xValidator( _pOriginal->m_xValidator ) ,m_bInputRequired( false ) - ,m_pAggPropMultiplexer( nullptr ) ,m_bFormListening( false ) ,m_bLoaded( false ) ,m_bRequired( false ) @@ -1214,7 +1226,6 @@ OBoundControlModel::~OBoundControlModel() if ( m_pAggPropMultiplexer ) { m_pAggPropMultiplexer->dispose(); - m_pAggPropMultiplexer->release(); m_pAggPropMultiplexer = nullptr; } } @@ -1244,7 +1255,6 @@ void OBoundControlModel::implInitAggMultiplexer( ) if ( m_xAggregateSet.is() ) { m_pAggPropMultiplexer = new OPropertyChangeMultiplexer( this, m_xAggregateSet, false ); - m_pAggPropMultiplexer->acquire(); } osl_atomic_decrement( &m_refCount ); @@ -1483,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 ) @@ -1723,8 +1733,7 @@ void OBoundControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, co } // Check if we and the given model have a common ancestor (up to the forms collection) - Reference<XChild> xCont( - static_cast<XWeak*>(this), css::uno::UNO_QUERY); + Reference<XChild> xCont(this); Reference< XInterface > xMyTopLevel = xCont->getParent(); while (xMyTopLevel.is()) { @@ -1861,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 ) @@ -1951,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 ); } @@ -2158,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& ) @@ -2177,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& ) @@ -2358,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; @@ -2478,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 ); } @@ -2697,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 ); @@ -2787,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 ed2f748fb7cd..fa1fdb216b2b 100644 --- a/forms/source/component/FormattedField.cxx +++ b/forms/source/component/FormattedField.cxx @@ -27,13 +27,14 @@ #include <connectivity/dbtools.hxx> #include <connectivity/dbconversion.hxx> #include <o3tl/any.hxx> -#include <svl/zforlist.hxx> +#include <svl/numformat.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> @@ -58,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; @@ -66,13 +66,12 @@ using namespace css::awt; using namespace css::io; using namespace css::lang; using namespace css::util; -using namespace css::form::binding; namespace frm { namespace { -class StandardFormatsSupplier : protected SvNumberFormatsSupplierObj, public ::utl::ITerminationListener +class StandardFormatsSupplier : public SvNumberFormatsSupplierObj, public ::utl::ITerminationListener { protected: std::unique_ptr<SvNumberFormatter> m_pMyPrivateFormatter; @@ -91,8 +90,7 @@ protected: WeakReference< XNumberFormatsSupplier > StandardFormatsSupplier::s_xDefaultFormatsSupplier; StandardFormatsSupplier::StandardFormatsSupplier(const Reference< XComponentContext > & _rxContext,LanguageType _eSysLanguage) - :SvNumberFormatsSupplierObj() - ,m_pMyPrivateFormatter(new SvNumberFormatter(_rxContext, _eSysLanguage)) + :m_pMyPrivateFormatter(new SvNumberFormatter(_rxContext, _eSysLanguage)) { SetNumberFormatter(m_pMyPrivateFormatter.get()); // #i29147# @@ -113,8 +111,7 @@ Reference< XNumberFormatsSupplier > StandardFormatsSupplier::get( const Referenc // get the Office's locale eSysLanguage = SvtSysLocale().GetLanguageTag().getLanguageType( false); } - StandardFormatsSupplier* pSupplier = new StandardFormatsSupplier( _rxORB, eSysLanguage ); - Reference< XNumberFormatsSupplier > xNewlyCreatedSupplier( pSupplier ); + rtl::Reference<StandardFormatsSupplier> pSupplier = new StandardFormatsSupplier( _rxORB, eSysLanguage ); { ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); Reference< XNumberFormatsSupplier > xSupplier = s_xDefaultFormatsSupplier; @@ -122,9 +119,9 @@ 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 = xNewlyCreatedSupplier; + s_xDefaultFormatsSupplier = css::uno::Reference<css::uno::XWeak>(pSupplier); } - return xNewlyCreatedSupplier; + return pSupplier; } bool StandardFormatsSupplier::queryTermination() const { @@ -269,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(); @@ -288,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() { @@ -340,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 @@ -370,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); @@ -391,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); @@ -477,9 +484,7 @@ Reference< XNumberFormatsSupplier > OFormattedModel::calcFormatsSupplier() const Reference<XNumberFormatsSupplier> OFormattedModel::calcFormFormatsSupplier() const { - Reference<XChild> xMe( - static_cast<XWeak*>(const_cast<OFormattedModel*>(this)), - css::uno::UNO_QUERY); + Reference<XChild> xMe(const_cast<OFormattedModel*>(this)); // By this we make sure that we get the right object even when aggregating DBG_ASSERT(xMe.is(), "OFormattedModel::calcFormFormatsSupplier : I should have a content interface !"); // Iterate through until we reach a StartForm (starting with an own Parent) @@ -564,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()) @@ -592,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 ); } } @@ -609,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; @@ -649,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)) { @@ -660,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); @@ -783,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 { @@ -802,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 78b0367d92b0..c9d0f1c1705e 100644 --- a/forms/source/component/FormattedField.hxx +++ b/forms/source/component/FormattedField.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_FORMATTEDFIELD_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_FORMATTEDFIELD_HXX +#pragma once #include "EditBase.hxx" #include <tools/link.hxx> @@ -51,10 +50,18 @@ 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; + public: // XInterface DECLARE_UNO3_AGG_DEFAULTS( OFormattedModel, OEditBaseModel ) @@ -171,6 +178,5 @@ class OFormattedModel final DECL_LINK( OnKeyPressed, void*, void ); }; } -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_FORMATTEDFIELD_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/component/FormattedFieldWrapper.cxx b/forms/source/component/FormattedFieldWrapper.cxx index 02aab9b1a245..d97387e4b6e1 100644 --- a/forms/source/component/FormattedFieldWrapper.cxx +++ b/forms/source/component/FormattedFieldWrapper.cxx @@ -35,50 +35,44 @@ 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) { - OFormattedFieldWrapper *pRef = new OFormattedFieldWrapper(_rxFactory); + rtl::Reference<OFormattedFieldWrapper> pRef = new OFormattedFieldWrapper(_rxFactory, + implementationName); if (bActAsFormatted) { // instantiate a FormattedModel // (instantiate it directly ..., as the OFormattedModel isn't // registered for any service names anymore) - OFormattedModel* pModel = new OFormattedModel(pRef->m_xContext); - css::uno::Reference<css::uno::XInterface> xFormattedModel( - static_cast<XWeak*>(pModel), css::uno::UNO_QUERY); + rtl::Reference<OFormattedModel> pModel = new OFormattedModel(pRef->m_xContext); - pRef->m_xAggregate.set(xFormattedModel, UNO_QUERY); + pRef->m_xAggregate = pModel; OSL_ENSURE(pRef->m_xAggregate.is(), "the OFormattedModel didn't have an XAggregation interface !"); // _before_ setting the delegator, give it to the member references - pRef->m_xFormattedPart.set(xFormattedModel, css::uno::UNO_QUERY); + pRef->m_xFormattedPart = pModel; pRef->m_pEditPart.set(new OEditModel(pRef->m_xContext)); } - osl_atomic_increment(&pRef->m_refCount); - if (pRef->m_xAggregate.is()) { // has to be in its own block because of the temporary variable created by *this - pRef->m_xAggregate->setDelegator(static_cast<XWeak*>(pRef)); + pRef->m_xAggregate->setDelegator(static_cast<XWeak*>(pRef.get())); } css::uno::Reference<css::uno::XInterface> xRef(*pRef); - osl_atomic_decrement(&pRef->m_refCount); return xRef; } @@ -87,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 ); @@ -100,7 +95,7 @@ Reference< XCloneable > SAL_CALL OFormattedFieldWrapper::createClone() OSL_ENSURE(xRef->m_xAggregate.is(), "invalid aggregate cloned !"); xRef->m_xFormattedPart.set( - Reference< XInterface >(xClone.get()), css::uno::UNO_QUERY); + Reference< XInterface >(xClone), css::uno::UNO_QUERY); if ( m_pEditPart.is() ) { @@ -116,7 +111,7 @@ Reference< XCloneable > SAL_CALL OFormattedFieldWrapper::createClone() xRef->m_xAggregate->setDelegator(static_cast< XWeak* >(xRef.get())); } - return xRef.get(); + return xRef; } OFormattedFieldWrapper::~OFormattedFieldWrapper() @@ -179,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 ) @@ -219,8 +214,7 @@ void SAL_CALL OFormattedFieldWrapper::write(const Reference<XObjectOutputStream> // for this we transfer the current props of the formatted part to the edit part Reference<XPropertySet> xFormatProps(m_xFormattedPart, UNO_QUERY); - Reference<XPropertySet> xEditProps( - static_cast<XWeak*>(m_pEditPart.get()), css::uno::UNO_QUERY); + Reference<XPropertySet> xEditProps = m_pEditPart; Locale aAppLanguage = Application::GetSettings().GetUILanguageTag().getLocale(); dbtools::TransferFormComponentProperties(xFormatProps, xEditProps, aAppLanguage); @@ -285,7 +279,7 @@ void SAL_CALL OFormattedFieldWrapper::read(const Reference<XObjectInputStream>& if (!pBasicReader->lastReadWasFormattedFake()) { // yes -> all fine - m_xAggregate.set( pBasicReader.get() ); + m_xAggregate = pBasicReader; } else { // no -> substitute it with a formatted model @@ -318,8 +312,8 @@ void OFormattedFieldWrapper::ensureAggregate() if (!xEditModel.is()) { // arghhh... instantiate it directly... it's dirty, but we really need this aggregate - OEditModel* pModel = new OEditModel(m_xContext); - xEditModel.set(static_cast<XWeak*>(pModel), css::uno::UNO_QUERY); + rtl::Reference<OEditModel> pModel = new OEditModel(m_xContext); + xEditModel.set(static_cast<XWeak*>(pModel.get()), css::uno::UNO_QUERY); } m_xAggregate.set(xEditModel, UNO_QUERY); @@ -348,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(); } @@ -358,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 1ef0d2d0f761..9dc093dece0d 100644 --- a/forms/source/component/FormattedFieldWrapper.hxx +++ b/forms/source/component/FormattedFieldWrapper.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_FORMATTEDFIELDWRAPPER_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_FORMATTEDFIELDWRAPPER_HXX +#pragma once #include <comphelper/uno3.hxx> #include <cppuhelper/implbase3.hxx> @@ -43,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; @@ -50,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; @@ -59,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) @@ -85,6 +86,4 @@ private: } -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_FORMATTEDFIELDWRAPPER_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/component/FormsCollection.cxx b/forms/source/component/FormsCollection.cxx index e213b31e49d2..2d426c7a34ab 100644 --- a/forms/source/component/FormsCollection.cxx +++ b/forms/source/component/FormsCollection.cxx @@ -22,12 +22,11 @@ #include <cppuhelper/supportsservice.hxx> #include <sal/log.hxx> #include <com/sun/star/form/XForm.hpp> +#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() @@ -100,11 +99,9 @@ css::uno::Sequence<OUString> SAL_CALL OFormsCollection::getSupportedServiceNames // XCloneable Reference< XCloneable > SAL_CALL OFormsCollection::createClone( ) { - OFormsCollection* pClone = new OFormsCollection( *this ); - osl_atomic_increment( &pClone->m_refCount ); + rtl::Reference<OFormsCollection> pClone = new OFormsCollection( *this ); pClone->clonedFrom( *this ); - osl_atomic_decrement( &pClone->m_refCount ); - return static_cast<OInterfaceContainer*>(pClone); + return static_cast<OInterfaceContainer*>(pClone.get()); } // OComponentHelper diff --git a/forms/source/component/FormsCollection.hxx b/forms/source/component/FormsCollection.hxx index 994eda6469f6..6a97148af0ba 100644 --- a/forms/source/component/FormsCollection.hxx +++ b/forms/source/component/FormsCollection.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_FORMSCOLLECTION_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_FORMSCOLLECTION_HXX +#pragma once #include <InterfaceContainer.hxx> #include <cppuhelper/component.hxx> @@ -147,6 +146,4 @@ public: } // namespace frm -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_FORMSCOLLECTION_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/component/Grid.cxx b/forms/source/component/Grid.cxx index 0677420f0bea..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; @@ -119,14 +121,12 @@ OGridControlModel::~OGridControlModel() // XCloneable Reference< XCloneable > SAL_CALL OGridControlModel::createClone( ) { - OGridControlModel* pClone = new OGridControlModel( this, getContext() ); - osl_atomic_increment( &pClone->m_refCount ); + rtl::Reference<OGridControlModel> pClone = new OGridControlModel( this, getContext() ); pClone->OControlModel::clonedFrom( this ); // do not call OInterfaceContainer::clonedFrom, it would clone the elements aka columns, which is // already done in the ctor //pClone->OInterfaceContainer::clonedFrom( *this ); - osl_atomic_decrement( &pClone->m_refCount ); - return static_cast< XCloneable* >( static_cast< OControlModel* >( pClone ) ); + return static_cast< XCloneable* >( static_cast< OControlModel* >( pClone.get() ) ); } void OGridControlModel::cloneColumns( const OGridControlModel* _pOriginalContainer ) @@ -165,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 ) @@ -292,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) @@ -341,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(); @@ -375,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 { @@ -649,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: @@ -741,7 +745,7 @@ ElementDescription* OGridControlModel::createElementMetaData( ) void OGridControlModel::approveNewElement( const Reference< XPropertySet >& _rxObject, ElementDescription* _pElement ) { - OGridColumn* pCol = comphelper::getUnoTunnelImplementation<OGridColumn>( _rxObject ); + OGridColumn* pCol = comphelper::getFromUnoTunnel<OGridColumn>( _rxObject ); if ( !pCol ) throw IllegalArgumentException(); OInterfaceContainer::approveNewElement( _rxObject, _pElement ); @@ -765,7 +769,7 @@ void OGridControlModel::write(const Reference<XObjectOutputStream>& _rxOutStream for (sal_Int32 i = 0; i < nLen; i++) { // first the service name for the underlying model - OGridColumn* pCol = comphelper::getUnoTunnelImplementation<OGridColumn>(m_aItems[i]); + OGridColumn* pCol = comphelper::getFromUnoTunnel<OGridColumn>(m_aItems[i]); DBG_ASSERT(pCol != nullptr, "OGridControlModel::write : such items should never reach it into my container !"); _rxOutStream << pCol->getModelName(); // then the object itself @@ -869,7 +873,7 @@ void OGridControlModel::read(const Reference<XObjectInputStream>& _rxInStream) sal_Int32 nMark = xMark->createMark(); if (xCol.is()) { - OGridColumn* pCol = comphelper::getUnoTunnelImplementation<OGridColumn>(xCol); + OGridColumn* pCol = comphelper::getFromUnoTunnel<OGridColumn>(xCol); pCol->read(_rxInStream); } xMark->jumpToMark(nMark); diff --git a/forms/source/component/Grid.hxx b/forms/source/component/Grid.hxx index 1f57b32fef69..8339bb49a539 100644 --- a/forms/source/component/Grid.hxx +++ b/forms/source/component/Grid.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_GRID_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_GRID_HXX +#pragma once #include "errorbroadcaster.hxx" #include <FormComponent.hxx> @@ -30,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> @@ -55,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 @@ -88,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) @@ -190,6 +197,4 @@ private: } // namespace frm -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_GRID_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 f761b77ab7bc..c1c53df0b613 100644 --- a/forms/source/component/GroupBox.hxx +++ b/forms/source/component/GroupBox.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_GROUPBOX_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_GROUPBOX_HXX +#pragma once #include <FormComponent.hxx> @@ -30,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 @@ -73,6 +79,4 @@ public: } -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_GROUPBOX_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 d3734b751d28..4cefd7ac3a12 100644 --- a/forms/source/component/GroupManager.hxx +++ b/forms/source/component/GroupManager.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_GROUPMANAGER_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_GROUPMANAGER_HXX +#pragma once #include <com/sun/star/awt/XControlModel.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -115,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; @@ -133,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; @@ -192,6 +191,4 @@ public: } // namespace frm -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_GROUPMANAGER_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 7ff7d860f917..7bd01ccf939a 100644 --- a/forms/source/component/Hidden.hxx +++ b/forms/source/component/Hidden.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_HIDDEN_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_HIDDEN_HXX +#pragma once #include <FormComponent.hxx> @@ -32,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; @@ -67,6 +73,4 @@ protected: } -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_HIDDEN_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 8f618c47c13c..0e5c402abbc3 100644 --- a/forms/source/component/ImageButton.hxx +++ b/forms/source/component/ImageButton.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_IMAGEBUTTON_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_IMAGEBUTTON_HXX +#pragma once #include "clickableimage.hxx" #include <com/sun/star/awt/XMouseListener.hpp> @@ -31,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 @@ -92,6 +98,4 @@ public: } // namespace frm -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_IMAGEBUTTON_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx index 857c25a29ba3..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,11 +129,9 @@ 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 ) - ,m_sImageURL() - ,m_xGraphicObject() { m_nClassId = FormComponentType::IMAGECONTROL; initOwnValueProperty( PROPERTY_IMAGE_URL ); @@ -143,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 ) @@ -180,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 @@ -312,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 ?"); } @@ -390,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 ) ) @@ -399,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() ) @@ -419,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; } @@ -540,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!" ); @@ -559,7 +559,7 @@ Any OImageControlModel::translateDbColumnToControlValue() Any OImageControlModel::getControlValue( ) const { - return makeAny( m_sImageURL ); + return Any( m_sImageURL ); } @@ -648,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& ) { @@ -752,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() ) ); } @@ -767,13 +767,14 @@ 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 { Reference< XWindow > xWindow( static_cast< ::cppu::OWeakObject* >( this ), UNO_QUERY ); ::sfx2::FileDialogHelper aDialog(TemplateDescription::FILEOPEN_LINK_PREVIEW, FileDialogFlags::Graphic, Application::GetFrameWeld(xWindow)); + aDialog.SetContext(sfx2::FileDialogHelper::FormsInsertImage); aDialog.SetTitle( sTitle ); Reference< XFilePickerControlAccess > xController( aDialog.GetFilePicker(), UNO_QUERY_THROW ); @@ -795,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() ) { @@ -813,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; } @@ -869,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 01ae8018a24f..245d13163e4f 100644 --- a/forms/source/component/ImageControl.hxx +++ b/forms/source/component/ImageControl.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_IMAGECONTROL_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_IMAGECONTROL_HXX +#pragma once #include <FormComponent.hxx> #include "imgprod.hxx" @@ -26,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> @@ -58,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; @@ -139,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; @@ -186,6 +193,4 @@ private: } // namespace frm -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_IMAGECONTROL_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index 42dc08aee90d..33d31180315c 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -18,6 +18,7 @@ */ #include <config_features.h> +#include <config_fuzzers.h> #include "ListBox.hxx" #include <property.hxx> @@ -27,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> @@ -43,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> @@ -97,7 +99,7 @@ namespace frm void operator()( const ORowSetValue& _append ) { - m_string += _append; + m_string += _append.getString(); } private: @@ -148,7 +150,6 @@ namespace frm // use the old control name for compatibility reasons ,OEntryListHelper( static_cast<OControlModel&>(*this) ) ,OErrorBroadcaster( OComponentHelper::rBHelper ) - ,m_aListRowSet() ,m_nConvertedBoundValuesType(0) ,m_nNULLPos(-1) ,m_nBoundColumnType( DataType::SQLNULL ) @@ -167,7 +168,6 @@ namespace frm :OBoundControlModel( _pOriginal, _rxFactory ) ,OEntryListHelper( *_pOriginal, static_cast<OControlModel&>(*this) ) ,OErrorBroadcaster( OComponentHelper::rBHelper ) - ,m_aListRowSet() ,m_eListSourceType( _pOriginal->m_eListSourceType ) ,m_aBoundColumn( _pOriginal->m_aBoundColumn ) ,m_aListSourceValues( _pOriginal->m_aListSourceValues ) @@ -194,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 @@ -314,15 +319,15 @@ namespace frm // copy to member ValueList().swap(m_aListSourceValues); ::std::copy( - aListSource.begin(), - aListSource.end(), + std::cbegin(aListSource), + std::cend(aListSource), ::std::insert_iterator< ValueList >( m_aListSourceValues, m_aListSourceValues.end() ) ); // propagate if ( m_eListSourceType == ListSourceType_VALUELIST ) { - setBoundValues(m_aListSourceValues); + setBoundValues(std::vector(m_aListSourceValues)); } else { @@ -347,7 +352,7 @@ namespace frm } break; -#if HAVE_FEATURE_DBCONNECTIVITY +#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS case PROPERTY_ID_SELECT_VALUE : { ORowSetValue v; @@ -468,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() ); @@ -488,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 ?"); } @@ -682,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) @@ -852,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&) @@ -877,7 +889,7 @@ namespace frm switch (m_eListSourceType) { -#if HAVE_FEATURE_DBCONNECTIVITY +#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS case ListSourceType_SQL: case ListSourceType_SQLPASSTHROUGH: case ListSourceType_TABLE: @@ -953,7 +965,7 @@ namespace frm Reference<XNameAccess> xFieldNames = getTableFields(xConnection, sListSource); if (xFieldNames.is()) { - css::uno::Sequence<OUString> seqNames = xFieldNames->getElementNames(); + const css::uno::Sequence<OUString> seqNames = xFieldNames->getElementNames(); ::std::copy( seqNames.begin(), seqNames.end(), @@ -981,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& ) @@ -1001,10 +1013,10 @@ namespace frm m_nNULLPos = 0; } - setBoundValues(aValueList); + 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>() ) ); } @@ -1031,17 +1043,17 @@ 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(); } } - void OListBoxModel::setBoundValues(const ValueList &l) + void OListBoxModel::setBoundValues(ValueList && l) { m_aConvertedBoundValues.clear(); - m_aBoundValues = l; + m_aBoundValues = std::move(l); } @@ -1179,8 +1191,7 @@ namespace frm { if ( m_nNULLPos != -1 ) { - aSelectionIndicies.realloc(1); - aSelectionIndicies[0] = m_nNULLPos; + aSelectionIndicies = { m_nNULLPos }; } } else @@ -1192,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()) }; } } @@ -1208,7 +1218,7 @@ namespace frm sal_Int32 nCount(0); -#if HAVE_FEATURE_DBCONNECTIVITY +#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS sal_Int16 *pIndex = aSelectionIndicies.getArray(); for ( auto const & value : i_aValues) { @@ -1243,7 +1253,7 @@ namespace frm Any OListBoxModel::translateDbColumnToControlValue() { -#if HAVE_FEATURE_DBCONNECTIVITY +#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS Reference< XPropertySet > xBoundField( getField() ); if ( !xBoundField.is() ) { @@ -1256,7 +1266,7 @@ namespace frm m_aSaveValue = aCurrentValue; - return makeAny( translateDbValueToControlValue(aCurrentValue) ); + return Any( translateDbValueToControlValue(aCurrentValue) ); #else return Any(); #endif @@ -1271,8 +1281,7 @@ namespace frm aValue <<= m_aDefaultSelectSeq; else if (m_nNULLPos != -1) // bound Listbox { - Sequence<sal_Int16> aSeq(1); - aSeq.getArray()[0] = m_nNULLPos; + Sequence<sal_Int16> aSeq { m_nNULLPos }; aValue <<= aSeq; } else @@ -1363,7 +1372,7 @@ namespace frm break; case eValue: -#if HAVE_FEATURE_DBCONNECTIVITY +#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS { ORowSetValue v; v.fill(_rExternalValue); @@ -1380,8 +1389,8 @@ namespace frm OSL_VERIFY( _rExternalValue >>= aSelectIndexesPure ); aSelectIndexes.realloc( aSelectIndexesPure.getLength() ); ::std::copy( - aSelectIndexesPure.begin(), - aSelectIndexesPure.end(), + std::cbegin(aSelectIndexesPure), + std::cend(aSelectIndexesPure), aSelectIndexes.getArray() ); } @@ -1391,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; @@ -1408,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()) @@ -1442,7 +1450,7 @@ namespace frm break; } - return makeAny( aSelectIndexes ); + return Any( aSelectIndexes ); } @@ -1516,7 +1524,7 @@ namespace frm aSelectedEntriesTexts.getArray(), ExtractStringFromSequence_Safe( _rStringList ) ); - return makeAny( aSelectedEntriesTexts ); + return Any( aSelectedEntriesTexts ); } @@ -1592,8 +1600,8 @@ namespace frm // expects int's Sequence< sal_Int32 > aTransformed( aSelectSequence.getLength() ); ::std::copy( - aSelectSequence.begin(), - aSelectSequence.end(), + std::cbegin(aSelectSequence), + std::cend(aSelectSequence), aTransformed.getArray() ); aReturn <<= aTransformed; @@ -1707,14 +1715,15 @@ namespace frm Sequence< Type > OListBoxModel::getSupportedBindingTypes() { - Sequence< Type > aTypes(6); - aTypes[0] = cppu::UnoType<Sequence< Any >>::get(); - aTypes[1] = cppu::UnoType<Any>::get(); - aTypes[2] = cppu::UnoType<Sequence< sal_Int32 >>::get(); - aTypes[3] = cppu::UnoType<sal_Int32>::get(); - aTypes[4] = cppu::UnoType<Sequence< OUString >>::get(); - aTypes[5] = cppu::UnoType<OUString>::get(); - return aTypes; + return + { + cppu::UnoType<Sequence< Any >>::get(), + cppu::UnoType<Any>::get(), + cppu::UnoType<Sequence< sal_Int32 >>::get(), + cppu::UnoType<sal_Int32>::get(), + cppu::UnoType<Sequence< OUString >>::get(), + cppu::UnoType<OUString>::get() + }; } @@ -1726,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& ) { @@ -1747,7 +1756,7 @@ namespace frm else { if ( m_aDefaultSelectSeq.hasElements() ) - setControlValue( makeAny( m_aDefaultSelectSeq ), eOther ); + setControlValue( Any( m_aDefaultSelectSeq ), eOther ); } } } @@ -1803,6 +1812,7 @@ namespace frm :OBoundControl( _rxFactory, VCL_CONTROL_LISTBOX, false ) ,m_aChangeListeners( m_aMutex ) ,m_aItemListeners( m_aMutex ) + ,m_aChangeIdle("forms OListBoxControl m_aChangedIdle") { osl_atomic_increment(&m_refCount); diff --git a/forms/source/component/ListBox.hxx b/forms/source/component/ListBox.hxx index c0ad179d39f5..cad8cc708b4b 100644 --- a/forms/source/component/ListBox.hxx +++ b/forms/source/component/ListBox.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_LISTBOX_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_LISTBOX_HXX +#pragma once #include <FormComponent.hxx> #include "cachedrowset.hxx" @@ -31,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> @@ -122,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 @@ -215,7 +222,7 @@ private: */ void impl_refreshDbEntryList( bool _bForce ); - void setBoundValues(const ValueList&); + void setBoundValues(ValueList &&); void clearBoundValues(); ValueList impl_getValues() const; @@ -239,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; @@ -322,6 +329,4 @@ private: } -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_LISTBOX_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 6278b3e3b76c..0b5cb703eca2 100644 --- a/forms/source/component/Numeric.hxx +++ b/forms/source/component/Numeric.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_NUMERIC_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_NUMERIC_HXX +#pragma once #include "EditBase.hxx" @@ -33,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 @@ -79,6 +85,4 @@ public: } // namespace frm -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_NUMERIC_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 80ce81639255..d0923c13cf58 100644 --- a/forms/source/component/Pattern.hxx +++ b/forms/source/component/Pattern.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_PATTERN_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_PATTERN_HXX +#pragma once #include "EditBase.hxx" @@ -39,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 @@ -85,6 +91,4 @@ public: } // namespace frm -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_PATTERN_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 ab4e996a8600..0e50acfc4245 100644 --- a/forms/source/component/RadioButton.hxx +++ b/forms/source/component/RadioButton.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_RADIOBUTTON_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_RADIOBUTTON_HXX +#pragma once #include "refvaluecomponent.hxx" @@ -29,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 @@ -84,6 +90,4 @@ public: } -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_RADIOBUTTON_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 cc9ef1136042..3a6793fa5c81 100644 --- a/forms/source/component/Time.hxx +++ b/forms/source/component/Time.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_TIME_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_TIME_HXX +#pragma once #include "EditBase.hxx" #include <limitedformats.hxx> @@ -39,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; @@ -106,6 +112,4 @@ public: } // namespace frm -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_TIME_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/component/cachedrowset.cxx b/forms/source/component/cachedrowset.cxx index f18246a4c177..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; @@ -57,9 +57,7 @@ namespace frm bool bStatementDirty; CachedRowSet_Data() - :sCommand() - ,bEscapeProcessing( false ) - ,xConnection() + :bEscapeProcessing( false ) ,bStatementDirty( true ) { } @@ -134,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 6c5c80313251..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(aURL.Complete); + URL aHyperLink = m_aFeatureInterception.getTransformer().getStrictURL( ".uno:OpenHyperlink" ); - Reference< XDispatch > xDisp = m_pFeatureInterception->queryDispatch(aHyperLink); + 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 ); } @@ -448,7 +441,6 @@ namespace frm const OUString& rDefault ) :OControlModel( _rxFactory, _rUnoControlModelTypeName, rDefault ) ,OPropertyChangeListener(m_aMutex) - ,m_xGraphicObject() ,m_bDispatchUrlInternal(false) ,m_bProdStarted(false) { @@ -495,7 +487,7 @@ namespace frm { if ( m_xAggregateSet.is() ) { - OPropertyChangeMultiplexer* pMultiplexer = new OPropertyChangeMultiplexer( this, m_xAggregateSet ); + rtl::Reference<OPropertyChangeMultiplexer> pMultiplexer = new OPropertyChangeMultiplexer( this, m_xAggregateSet ); pMultiplexer->addProperty( PROPERTY_IMAGE_URL ); } } @@ -804,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 329f2d5ab430..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 @@ -103,7 +110,7 @@ namespace frm virtual void SAL_CALL disposing() override; // css::form::XImageProducerSupplier - virtual css::uno::Reference< css::awt::XImageProducer> SAL_CALL getImageProducer() override { return m_xProducer.get(); } + virtual css::uno::Reference< css::awt::XImageProducer> SAL_CALL getImageProducer() override { return m_xProducer; } // OPropertySetHelper virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle ) const override; @@ -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/findpos.hxx b/forms/source/component/findpos.hxx index b279558fdab0..2a40bc3ca958 100644 --- a/forms/source/component/findpos.hxx +++ b/forms/source/component/findpos.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_FINDPOS_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_FINDPOS_HXX +#pragma once #include <sal/config.h> #include <com/sun/star/uno/Sequence.hxx> @@ -29,6 +28,4 @@ namespace detail sal_Int32 findPos(const OUString& aStr, const css::uno::Sequence<OUString>& rList); } -#endif - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 b38632ea4148..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.GetMask() ); - BitmapReadAccess* pMskAcc = !!aMask ? 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(), 1 ); - 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 eff824b90ea8..d1562caebf9f 100644 --- a/forms/source/component/imgprod.hxx +++ b/forms/source/component/imgprod.hxx @@ -17,25 +17,27 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_IMGPROD_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_IMGPROD_HXX +#pragma once #include <tools/link.hxx> #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: @@ -44,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; @@ -71,8 +73,8 @@ public: // css::uno::XInterface css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - void SAL_CALL acquire() throw() override { OWeakObject::acquire(); } - void SAL_CALL release() throw() override { OWeakObject::release(); } + void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); } + void SAL_CALL release() noexcept override { OWeakObject::release(); } // MT: ??? void setImage( css::uno::Reference< css::io::XInputStream > const & rStmRef ); @@ -85,8 +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; -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_IMGPROD_HXX +}; /* 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 f393a046f542..ceb84dbe8ecd 100644 --- a/forms/source/component/navigationbar.hxx +++ b/forms/source/component/navigationbar.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_NAVIGATIONBAR_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_NAVIGATIONBAR_HXX +#pragma once #include <FormComponent.hxx> #include <comphelper/propertycontainerhelper.hxx> @@ -60,9 +59,15 @@ 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; - protected: // UNO DECLARE_UNO3_AGG_DEFAULTS( ONavigationBarModel, OControlModel ) virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override; @@ -108,6 +113,4 @@ namespace frm } // namespace frm -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_NAVIGATIONBAR_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/component/propertybaghelper.cxx b/forms/source/component/propertybaghelper.cxx index 134cfe6e2b10..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; @@ -256,7 +256,7 @@ namespace frm Reference< XMultiPropertySet > xMe( m_rContext.getPropertiesInterface(), css::uno::UNO_SET_THROW ); Reference< XPropertySetInfo > xPSI( xMe->getPropertySetInfo(), css::uno::UNO_SET_THROW ); - Sequence< Property > aProperties( xPSI->getProperties() ); + const Sequence< Property > aProperties( xPSI->getProperties() ); Sequence< OUString > aPropertyNames( aProperties.getLength() ); ::std::transform( aProperties.begin(), aProperties.end(), aPropertyNames.getArray(), SelectNameOfProperty() ); @@ -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 958837ffcc18..79f343888c1c 100644 --- a/forms/source/component/refvaluecomponent.hxx +++ b/forms/source/component/refvaluecomponent.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_REFVALUECOMPONENT_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_REFVALUECOMPONENT_HXX +#pragma once #include <FormComponent.hxx> #include <togglestate.hxx> @@ -53,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 @@ -81,6 +84,4 @@ namespace frm } // namespace frm -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_REFVALUECOMPONENT_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 e79338e373a4..0acb91a3a009 100644 --- a/forms/source/component/scrollbar.hxx +++ b/forms/source/component/scrollbar.hxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_SCROLLBAR_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_SCROLLBAR_HXX +#pragma once #include <FormComponent.hxx> @@ -32,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 @@ -40,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; @@ -82,6 +90,4 @@ namespace frm } // namespacefrm -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_SCROLLBAR_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 9f79ce1d94a1..b9800274f063 100644 --- a/forms/source/component/spinbutton.hxx +++ b/forms/source/component/spinbutton.hxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_FORMS_SOURCE_COMPONENT_SPINBUTTON_HXX -#define INCLUDED_FORMS_SOURCE_COMPONENT_SPINBUTTON_HXX +#pragma once #include <FormComponent.hxx> @@ -33,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 @@ -41,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; @@ -78,6 +86,4 @@ namespace frm } // namespacefrm -#endif // INCLUDED_FORMS_SOURCE_COMPONENT_SPINBUTTON_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |