diff options
author | Noel Grandin <noel@peralex.com> | 2013-03-20 09:16:19 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-04-08 13:53:02 +0200 |
commit | 3cfecf8427c529c7c1d32be2b361934b63fa6933 (patch) | |
tree | 0eed4fbb77434a558dd48234a95b099a9ada534b | |
parent | 002aab309055b7feeeeeb25c1835b6abe6646729 (diff) |
fdo#46808, Convert beans::PropertyBag to new style
Change-Id: Ibb2466af4c9289cba93b8330d10db033d296bfc1
-rw-r--r-- | comphelper/source/property/opropertybag.cxx | 30 | ||||
-rw-r--r-- | comphelper/source/property/opropertybag.hxx | 21 | ||||
-rw-r--r-- | dbaccess/source/core/dataaccess/ModelImpl.cxx | 13 | ||||
-rw-r--r-- | dbaccess/source/core/dataaccess/ModelImpl.hxx | 4 | ||||
-rw-r--r-- | dbaccess/source/core/dataaccess/datasource.cxx | 2 | ||||
-rw-r--r-- | offapi/com/sun/star/form/FormComponent.idl | 4 | ||||
-rw-r--r-- | offapi/type_reference/types.rdb | bin | 7439872 -> 7439872 bytes | |||
-rw-r--r-- | sfx2/source/doc/SfxDocumentMetaData.cxx | 26 | ||||
-rw-r--r-- | udkapi/UnoApi_udkapi.mk | 3 | ||||
-rw-r--r-- | udkapi/com/sun/star/beans/PropertyBag.idl | 17 | ||||
-rw-r--r-- | udkapi/com/sun/star/beans/XPropertyBag.idl | 49 |
11 files changed, 107 insertions, 62 deletions
diff --git a/comphelper/source/property/opropertybag.cxx b/comphelper/source/property/opropertybag.cxx index a3d3a64d501e..d54fdf3c2559 100644 --- a/comphelper/source/property/opropertybag.cxx +++ b/comphelper/source/property/opropertybag.cxx @@ -88,20 +88,36 @@ namespace comphelper //-------------------------------------------------------------------- void SAL_CALL OPropertyBag::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException) { - ::comphelper::NamedValueCollection aArguments( _rArguments ); - Sequence< Type > aTypes; - if ( aArguments.get_ensureType( "AllowedTypes", aTypes ) ) + bool AllowEmptyPropertyName(false); + bool AutomaticAddition(false); + + if (_rArguments.getLength() == 3 + && (_rArguments[0] >>= aTypes) + && (_rArguments[1] >>= AllowEmptyPropertyName) + && (_rArguments[2] >>= AutomaticAddition)) + { ::std::copy( aTypes.getConstArray(), aTypes.getConstArray() + aTypes.getLength(), ::std::insert_iterator< TypeBag >( m_aAllowedTypes, m_aAllowedTypes.begin() ) ); + m_bAutoAddProperties = AutomaticAddition; - aArguments.get_ensureType( "AutomaticAddition", m_bAutoAddProperties ); - bool AllowEmptyPropertyName(false); - aArguments.get_ensureType( "AllowEmptyPropertyName", - AllowEmptyPropertyName ); + } else { + ::comphelper::NamedValueCollection aArguments( _rArguments ); + + if ( aArguments.get_ensureType( "AllowedTypes", aTypes ) ) + ::std::copy( + aTypes.getConstArray(), + aTypes.getConstArray() + aTypes.getLength(), + ::std::insert_iterator< TypeBag >( m_aAllowedTypes, m_aAllowedTypes.begin() ) + ); + + aArguments.get_ensureType( "AutomaticAddition", m_bAutoAddProperties ); + aArguments.get_ensureType( "AllowEmptyPropertyName", + AllowEmptyPropertyName ); + } if (AllowEmptyPropertyName) { m_aDynamicProperties.setAllowEmptyPropertyName( AllowEmptyPropertyName); diff --git a/comphelper/source/property/opropertybag.hxx b/comphelper/source/property/opropertybag.hxx index 93fa44510921..4e463fd49273 100644 --- a/comphelper/source/property/opropertybag.hxx +++ b/comphelper/source/property/opropertybag.hxx @@ -24,14 +24,12 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/util/XModifiable.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/beans/XPropertyContainer.hpp> -#include <com/sun/star/beans/XPropertyAccess.hpp> +#include <com/sun/star/beans/XPropertyBag.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/container/XSet.hpp> #include <boost/noncopyable.hpp> -#include <cppuhelper/implbase6.hxx> +#include <cppuhelper/implbase5.hxx> #include <comphelper/propstate.hxx> #include <comphelper/broadcasthelper.hxx> #include <comphelper/propertybag.hxx> @@ -63,8 +61,7 @@ namespace comphelper //==================================================================== //= OPropertyBag //==================================================================== - typedef ::cppu::WeakAggImplHelper6 < ::com::sun::star::beans::XPropertyContainer - , ::com::sun::star::beans::XPropertyAccess + typedef ::cppu::WeakAggImplHelper5 < ::com::sun::star::beans::XPropertyBag , ::com::sun::star::util::XModifiable , ::com::sun::star::lang::XServiceInfo , ::com::sun::star::lang::XInitialization @@ -143,6 +140,18 @@ namespace comphelper // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + virtual void setPropertyValue(const rtl::OUString& p1, const com::sun::star::uno::Any& p2) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { OPropertyBag_PBase::setPropertyValue(p1, p2); } + virtual com::sun::star::uno::Any getPropertyValue(const rtl::OUString& p1) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { return OPropertyBag_PBase::getPropertyValue(p1); } + virtual void addPropertyChangeListener(const rtl::OUString& p1, const com::sun::star::uno::Reference<com::sun::star::beans::XPropertyChangeListener>& p2) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { OPropertyBag_PBase::addPropertyChangeListener(p1, p2); } + virtual void removePropertyChangeListener(const rtl::OUString& p1, const com::sun::star::uno::Reference<com::sun::star::beans::XPropertyChangeListener>& p2) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { OPropertyBag_PBase::removePropertyChangeListener(p1, p2); } + virtual void addVetoableChangeListener(const rtl::OUString& p1, const com::sun::star::uno::Reference<com::sun::star::beans::XVetoableChangeListener>& p2) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { OPropertyBag_PBase::addVetoableChangeListener(p1, p2); } + virtual void removeVetoableChangeListener(const rtl::OUString& p1, const com::sun::star::uno::Reference<com::sun::star::beans::XVetoableChangeListener>& p2) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { OPropertyBag_PBase::removeVetoableChangeListener(p1, p2); } // XSet virtual ::sal_Bool SAL_CALL has( const ::com::sun::star::uno::Any& aElement ) throw (::com::sun::star::uno::RuntimeException); diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index 882f7863da7c..95af6b73e65b 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -30,17 +30,18 @@ #include "userinformation.hxx" #include "sdbcoretools.hxx" +#include <com/sun/star/beans/PropertyBag.hpp> #include <com/sun/star/container/XSet.hpp> #include <com/sun/star/document/MacroExecMode.hpp> -#include <com/sun/star/frame/GlobalEventBroadcaster.hpp> #include <com/sun/star/embed/XTransactedObject.hpp> #include <com/sun/star/embed/XTransactionBroadcaster.hpp> #include <com/sun/star/embed/StorageFactory.hpp> +#include <com/sun/star/form/XLoadable.hpp> +#include <com/sun/star/frame/GlobalEventBroadcaster.hpp> +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/sdb/BooleanComparisonMode.hpp> #include <com/sun/star/script/DocumentScriptLibraryContainer.hpp> #include <com/sun/star/script/DocumentDialogLibraryContainer.hpp> -#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> -#include <com/sun/star/form/XLoadable.hpp> #include <com/sun/star/util/NumberFormatsSupplier.hpp> #include <comphelper/interaction.hxx> @@ -488,11 +489,7 @@ void ODatabaseModelImpl::impl_construct_nothrow() *pAllowedType++ = ::getCppuType( static_cast< sal_Int16* >( NULL ) ); *pAllowedType++ = ::getCppuType( static_cast< Sequence< Any >* >( NULL ) ); - Sequence< Any > aInitArgs( 2 ); - aInitArgs[0] <<= NamedValue("AutomaticAddition", makeAny( (sal_Bool)sal_True )); - aInitArgs[1] <<= NamedValue("AllowedTypes", makeAny( aAllowedTypes )); - - m_xSettings.set( m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.beans.PropertyBag", aInitArgs, m_aContext), UNO_QUERY_THROW ); + m_xSettings = PropertyBag::createWithTypes( m_aContext, aAllowedTypes, sal_False/*AllowEmptyPropertyName*/, sal_True/*AutomaticAddition*/ ); // insert the default settings Reference< XPropertyContainer > xContainer( m_xSettings, UNO_QUERY_THROW ); diff --git a/dbaccess/source/core/dataaccess/ModelImpl.hxx b/dbaccess/source/core/dataaccess/ModelImpl.hxx index 49f6a10efdc6..fa595648336c 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.hxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.hxx @@ -28,7 +28,7 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/beans/XPropertyAccess.hpp> +#include <com/sun/star/beans/XPropertyBag.hpp> #include <com/sun/star/container/XContainerListener.hpp> #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp> #include <com/sun/star/document/XEventListener.hpp> @@ -245,7 +245,7 @@ public: sal_Bool m_bSuppressVersionColumns : 1; sal_Bool m_bModified : 1; sal_Bool m_bDocumentReadOnly : 1; - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyAccess > + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyBag > m_xSettings; ::com::sun::star::uno::Sequence< OUString > m_aTableFilter; ::com::sun::star::uno::Sequence< OUString > m_aTableTypeFilter; diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx index 9e9d4fee411d..2b3147b82120 100644 --- a/dbaccess/source/core/dataaccess/datasource.cxx +++ b/dbaccess/source/core/dataaccess/datasource.cxx @@ -880,7 +880,7 @@ namespace @param _rAllNewPropertyValues the new property values to set for the bag */ - void lcl_setPropertyValues_resetOrRemoveOther( const Reference< XPropertyAccess >& _rxPropertyBag, const Sequence< PropertyValue >& _rAllNewPropertyValues ) + void lcl_setPropertyValues_resetOrRemoveOther( const Reference< XPropertyBag >& _rxPropertyBag, const Sequence< PropertyValue >& _rAllNewPropertyValues ) { // sequences are ugly to operate on typedef ::std::set< OUString > StringSet; diff --git a/offapi/com/sun/star/form/FormComponent.idl b/offapi/com/sun/star/form/FormComponent.idl index 3ab1545e7970..8d3aa13c50cd 100644 --- a/offapi/com/sun/star/form/FormComponent.idl +++ b/offapi/com/sun/star/form/FormComponent.idl @@ -24,7 +24,7 @@ #include <com/sun/star/container/XNamed.idl> #include <com/sun/star/beans/XPropertySet.idl> #include <com/sun/star/io/XPersistObject.idl> -#include <com/sun/star/beans/PropertyBag.idl> +#include <com/sun/star/beans/XPropertyBag.idl> @@ -84,7 +84,7 @@ published service FormComponent @since OOo 2.3 */ - [optional] service com::sun::star::beans::PropertyBag; + [optional] interface com::sun::star::beans::XPropertyBag; /** the name of the component. diff --git a/offapi/type_reference/types.rdb b/offapi/type_reference/types.rdb Binary files differindex 48ce5b9889d9..86a07526106d 100644 --- a/offapi/type_reference/types.rdb +++ b/offapi/type_reference/types.rdb diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index 7387baba5255..e4a03d0be849 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -80,6 +80,7 @@ #include <cppuhelper/implbase1.hxx> #include <com/sun/star/document/XCompatWriterDocProperties.hpp> +#include <com/sun/star/beans/PropertyBag.hpp> /** * This file contains the implementation of the service @@ -641,12 +642,7 @@ css::uno::Reference< css::beans::XPropertySet > SAL_CALL SfxDocumentMetaData::getURLProperties( const css::uno::Sequence< css::beans::PropertyValue > & i_rMedium) const { - css::uno::Reference<css::lang::XMultiComponentFactory> xMsf ( - m_xContext->getServiceManager()); - css::uno::Reference< css::beans::XPropertyContainer> xPropArg( - xMsf->createInstanceWithContext(OUString( - "com.sun.star.beans.PropertyBag"), m_xContext), - css::uno::UNO_QUERY_THROW); + css::uno::Reference< css::beans::XPropertyBag> xPropArg = css::beans::PropertyBag::createDefault( m_xContext ); try { OUString dburl("DocumentBaseURL"); OUString hdn("HierarchicalDocumentName"); @@ -2287,26 +2283,10 @@ void SfxDocumentMetaData::createUserDefined() types[9] = ::cppu::UnoType<sal_Int64>::get(); // Time is supported for backward compatibility with OOo 3.x, x<=2 types[10] = ::cppu::UnoType<css::util::Time>::get(); - css::uno::Sequence<css::uno::Any> args(2); - args[0] <<= css::beans::NamedValue( - OUString("AllowedTypes"), - css::uno::makeAny(types)); // #i94175#: ODF allows empty user-defined property names! - args[1] <<= css::beans::NamedValue( OUString( - "AllowEmptyPropertyName"), - css::uno::makeAny(sal_True)); - - const css::uno::Reference<css::lang::XMultiComponentFactory> xMsf( - m_xContext->getServiceManager()); m_xUserDefined.set( - xMsf->createInstanceWithContext( - OUString("com.sun.star.beans.PropertyBag"), m_xContext), + css::beans::PropertyBag::createWithTypes( m_xContext, types, sal_True/*AllowEmptyPropertyName*/, sal_False/*AutomaticAddition*/ ), css::uno::UNO_QUERY_THROW); - const css::uno::Reference<css::lang::XInitialization> xInit( - m_xUserDefined, css::uno::UNO_QUERY); - if (xInit.is()) { - xInit->initialize(args); - } const css::uno::Reference<css::util::XModifyBroadcaster> xMB( m_xUserDefined, css::uno::UNO_QUERY); diff --git a/udkapi/UnoApi_udkapi.mk b/udkapi/UnoApi_udkapi.mk index c907baa29dcd..0b13cac31eb8 100644 --- a/udkapi/UnoApi_udkapi.mk +++ b/udkapi/UnoApi_udkapi.mk @@ -40,7 +40,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,udkapi,udkapi/com/sun/star,\ udk-modules \ )) $(eval $(call gb_UnoApi_add_idlfiles_noheader,udkapi,udkapi/com/sun/star/beans,\ - PropertyBag \ PropertySet \ )) $(eval $(call gb_UnoApi_add_idlfiles_noheader,udkapi,udkapi/com/sun/star/bridge,\ @@ -97,6 +96,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,udkapi,udkapi/com/sun/star/util,\ )) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,udkapi,udkapi/com/sun/star/beans,\ + PropertyBag \ Introspection \ )) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,udkapi,udkapi/com/sun/star/bridge,\ @@ -196,6 +196,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,udkapi,udkapi/com/sun/star/beans,\ XPropertiesChangeNotifier \ XProperty \ XPropertyAccess \ + XPropertyBag \ XPropertyChangeListener \ XPropertyContainer \ XPropertySet \ diff --git a/udkapi/com/sun/star/beans/PropertyBag.idl b/udkapi/com/sun/star/beans/PropertyBag.idl index 14c0605bb8f1..5cb477458a25 100644 --- a/udkapi/com/sun/star/beans/PropertyBag.idl +++ b/udkapi/com/sun/star/beans/PropertyBag.idl @@ -19,15 +19,11 @@ #ifndef __com_sun_star_beans_PropertyBag_idl__ #define __com_sun_star_beans_PropertyBag_idl__ -#include <com/sun/star/beans/XPropertySet.idl> +#include <com/sun/star/beans/XPropertyBag.idl> -#include <com/sun/star/beans/XPropertyContainer.idl> -#include <com/sun/star/beans/XPropertyAccess.idl> - - - module com { module sun { module star { module beans { +module com { module sun { module star { module beans { /** Implementation of this service can keep any properties and is useful @@ -37,14 +33,11 @@ property sets, giving direct access to the properties. In this case, use the methods like <member>XPropertySet::getPropertyValue</member>. */ -published service PropertyBag +published service PropertyBag : XPropertyBag { - interface com::sun::star::beans::XPropertySet; - - interface com::sun::star::beans::XPropertyContainer; - - interface com::sun::star::beans::XPropertyAccess; + createDefault(); + createWithTypes( [in] sequence<type> AllowedTypes, [in] boolean AllowEmptyPropertyName, [in] boolean AutomaticAddition ); }; diff --git a/udkapi/com/sun/star/beans/XPropertyBag.idl b/udkapi/com/sun/star/beans/XPropertyBag.idl new file mode 100644 index 000000000000..3d9efd0abb6c --- /dev/null +++ b/udkapi/com/sun/star/beans/XPropertyBag.idl @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef __com_sun_star_beans_XPropertyBag_idl__ +#define __com_sun_star_beans_XPropertyBag_idl__ + +#include <com/sun/star/beans/XPropertySet.idl> +#include <com/sun/star/beans/XPropertyContainer.idl> +#include <com/sun/star/beans/XPropertyAccess.idl> + + + + module com { module sun { module star { module beans { + + +/** + @since LibreOffice 4.1 + */ +published interface XPropertyBag +{ + interface com::sun::star::beans::XPropertySet; + + interface com::sun::star::beans::XPropertyContainer; + + interface com::sun::star::beans::XPropertyAccess; + +}; + + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |