From a75324ccabcf09c0f1bc7a1a43256aa37f0da751 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sun, 7 Nov 2021 18:45:58 +0200 Subject: rtl::Instance->thread-safe static in PropertyNameVector Change-Id: I3f595585b78c9e5ac32d9fc345c55a4eb14101c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124824 Tested-by: Jenkins Reviewed-by: Noel Grandin --- include/oox/helper/propertymap.hxx | 5 ++--- include/oox/token/propertynames.hxx | 18 +++--------------- oox/source/helper/propertymap.cxx | 4 ++-- oox/source/token/propertynames.cxx | 9 +++++---- 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/include/oox/helper/propertymap.hxx b/include/oox/helper/propertymap.hxx index 85635f314d5e..3e48c9817fd1 100644 --- a/include/oox/helper/propertymap.hxx +++ b/include/oox/helper/propertymap.hxx @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -37,8 +38,6 @@ namespace com::sun::star::beans { namespace oox { -struct PropertyNameVector; - typedef ::std::map< OUString, css::uno::Any > PropertyNameMap; @@ -114,7 +113,7 @@ public: static void dumpData( const css::uno::Reference& rXPropSet); #endif private: - const PropertyNameVector* mpPropNames; + const std::vector* mpPropNames; protected: std::map< sal_Int32, css::uno::Any > maProperties; diff --git a/include/oox/token/propertynames.hxx b/include/oox/token/propertynames.hxx index 84077359e1fe..91e07cbdd33b 100644 --- a/include/oox/token/propertynames.hxx +++ b/include/oox/token/propertynames.hxx @@ -16,30 +16,18 @@ * 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_OOX_TOKEN_PROPERTYNAMES_HXX -#define INCLUDED_OOX_TOKEN_PROPERTYNAMES_HXX +#pragma once #include -#include #include namespace oox { /** A vector that contains all predefined property names used in the filters. */ -struct PropertyNameVector : public ::std::vector -{ - PropertyNameVector(); -}; - -/** Thread-save singleton of a vector of all supported property names. */ -struct StaticPropertyNameVector : public ::rtl::Static -{ -}; +/** Thread-safe singleton of a vector of all supported property names. */ +const std::vector& GetPropertyNameVector(); } // namespace oox -#endif - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/helper/propertymap.cxx b/oox/source/helper/propertymap.cxx index afb6ef6ff6f6..83495dc879b1 100644 --- a/oox/source/helper/propertymap.cxx +++ b/oox/source/helper/propertymap.cxx @@ -180,7 +180,7 @@ sal_Bool SAL_CALL GenericPropertySet::hasPropertyByName( const OUString& rProper } // namespace PropertyMap::PropertyMap() : - mpPropNames( &StaticPropertyNameVector::get() ) // pointer instead reference to get compiler generated copy c'tor and operator= + mpPropNames( &GetPropertyNameVector() ) // pointer instead reference to get compiler generated copy c'tor and operator= { } @@ -221,7 +221,7 @@ void PropertyMap::assignUsed( const PropertyMap& rPropMap ) const OUString& PropertyMap::getPropertyName( sal_Int32 nPropId ) { OSL_ENSURE( (0 <= nPropId) && (nPropId < PROP_COUNT), "PropertyMap::getPropertyName - invalid property identifier" ); - return StaticPropertyNameVector::get()[ nPropId ]; + return GetPropertyNameVector()[ nPropId ]; } void PropertyMap::assignAll( const PropertyMap& rPropMap ) diff --git a/oox/source/token/propertynames.cxx b/oox/source/token/propertynames.cxx index b7c5e544143c..eadf0d5d4d7a 100644 --- a/oox/source/token/propertynames.cxx +++ b/oox/source/token/propertynames.cxx @@ -21,12 +21,13 @@ namespace oox { -PropertyNameVector::PropertyNameVector() - : ::std::vector{ +const std::vector& GetPropertyNameVector() +{ + static const std::vector NAMES{ // include auto-generated C array with property names as C strings #include - } -{ + }; + return NAMES; } } // namespace oox -- cgit