Kaydet (Commit) 3cfecf84 authored tarafından Noel Grandin's avatar Noel Grandin

fdo#46808, Convert beans::PropertyBag to new style

Change-Id: Ibb2466af4c9289cba93b8330d10db033d296bfc1
üst 002aab30
......@@ -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);
......
......@@ -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);
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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;
......
......@@ -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.
......
......@@ -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);
......
......@@ -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 \
......
......@@ -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 );
};
......
/* -*- 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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment