rtl::Static -> thread-safe static local

Change-Id: I9f8fe250813f4f376dc46c6f3d7e25e90fdbb50e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120566
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2021-08-17 22:40:40 +02:00
parent 889df64fbb
commit 4dc4065904
14 changed files with 150 additions and 265 deletions
+3 -4
View File
@@ -27,7 +27,6 @@
#include <com/sun/star/frame/XModel2.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
#include <comphelper/processfactory.hxx>
#include <rtl/instance.hxx>
namespace basic::vba {
@@ -145,8 +144,6 @@ struct CurrDirPool
std::map< OUString, OUString > maCurrDirs;
};
struct StaticCurrDirPool : public ::rtl::Static< CurrDirPool, StaticCurrDirPool > {};
} // namespace
@@ -167,7 +164,9 @@ void registerCurrentDirectory( const uno::Reference< frame::XModel >& rxModel, c
if( rPath.isEmpty() )
return;
CurrDirPool& rPool = StaticCurrDirPool::get();
static CurrDirPool StaticCurrDirPool;
CurrDirPool& rPool = StaticCurrDirPool;
::osl::MutexGuard aGuard( rPool.maMutex );
try
{
+2 -3
View File
@@ -10,7 +10,6 @@
#include <comphelper/processfactory.hxx>
#include <i18nlangtag/lang.h>
#include <i18nutil/transliteration.hxx>
#include <rtl/instance.hxx>
#include <unotools/transliterationwrapper.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
@@ -35,12 +34,12 @@ namespace
utl::TransliterationWrapper& getTransliteration() { return m_aTransliteration; }
};
class theTransliterationWrapper : public rtl::Static<lclTransliterationWrapper, theTransliterationWrapper> {};
}
utl::TransliterationWrapper& SbGlobal::GetTransliteration()
{
return theTransliterationWrapper::get().getTransliteration();
static lclTransliterationWrapper theTransliterationWrapper;
return theTransliterationWrapper.getTransliteration();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+9 -10
View File
@@ -177,31 +177,31 @@ namespace {
typedef ::rtl::Reference< DocBasicItem > DocBasicItemRef;
class GaDocBasicItems : public rtl::Static<std::unordered_map< const StarBASIC *, DocBasicItemRef >,GaDocBasicItems> {};
std::unordered_map< const StarBASIC *, DocBasicItemRef > gaDocBasicItems;
const DocBasicItem* lclFindDocBasicItem( const StarBASIC* pDocBasic )
{
auto it = GaDocBasicItems::get().find( pDocBasic );
auto end = GaDocBasicItems::get().end();
auto it = gaDocBasicItems.find( pDocBasic );
auto end = gaDocBasicItems.end();
return (it != end) ? it->second.get() : nullptr;
}
void lclInsertDocBasicItem( StarBASIC& rDocBasic )
{
DocBasicItemRef& rxDocBasicItem = GaDocBasicItems::get()[ &rDocBasic ];
DocBasicItemRef& rxDocBasicItem = gaDocBasicItems[ &rDocBasic ];
rxDocBasicItem.set( new DocBasicItem( rDocBasic ) );
rxDocBasicItem->startListening();
}
void lclRemoveDocBasicItem( StarBASIC& rDocBasic )
{
auto it = GaDocBasicItems::get().find( &rDocBasic );
if( it != GaDocBasicItems::get().end() )
auto it = gaDocBasicItems.find( &rDocBasic );
if( it != gaDocBasicItems.end() )
{
it->second->stopListening();
GaDocBasicItems::get().erase( it );
gaDocBasicItems.erase( it );
}
for( auto& rEntry : GaDocBasicItems::get() )
for( auto& rEntry : gaDocBasicItems )
{
rEntry.second->clearDependingVarsOnDelete( rDocBasic );
}
@@ -1914,8 +1914,7 @@ Reference< frame::XModel > StarBASIC::GetModelFromBasic( SbxObject* pBasic )
void StarBASIC::DetachAllDocBasicItems()
{
std::unordered_map< const StarBASIC *, DocBasicItemRef >& rItems = GaDocBasicItems::get();
for (auto const& item : rItems)
for (auto const& item : gaDocBasicItems)
{
DocBasicItemRef xItem = item.second;
xItem->setDisposed(true);
+6 -8
View File
@@ -449,30 +449,28 @@ typedef std::vector< ObjectItem > NativeObjectWrapperVector;
namespace {
class GaNativeObjectWrapperVector : public rtl::Static<NativeObjectWrapperVector, GaNativeObjectWrapperVector> {};
NativeObjectWrapperVector gaNativeObjectWrapperVector;
}
void clearNativeObjectWrapperVector()
{
GaNativeObjectWrapperVector::get().clear();
gaNativeObjectWrapperVector.clear();
}
static sal_uInt32 lcl_registerNativeObjectWrapper( SbxObject* pNativeObj )
{
NativeObjectWrapperVector &rNativeObjectWrapperVector = GaNativeObjectWrapperVector::get();
sal_uInt32 nIndex = rNativeObjectWrapperVector.size();
rNativeObjectWrapperVector.emplace_back( pNativeObj );
sal_uInt32 nIndex = gaNativeObjectWrapperVector.size();
gaNativeObjectWrapperVector.emplace_back( pNativeObj );
return nIndex;
}
static SbxObject* lcl_getNativeObject( sal_uInt32 nIndex )
{
SbxObjectRef xRetObj;
NativeObjectWrapperVector &rNativeObjectWrapperVector = GaNativeObjectWrapperVector::get();
if( nIndex < rNativeObjectWrapperVector.size() )
if( nIndex < gaNativeObjectWrapperVector.size() )
{
ObjectItem& rItem = rNativeObjectWrapperVector[ nIndex ];
ObjectItem& rItem = gaNativeObjectWrapperVector[ nIndex ];
xRetObj = rItem.m_xNativeObj;
}
return xRetObj.get();
+3 -4
View File
@@ -21,7 +21,6 @@
#include <array>
#include <basic/sberrors.hxx>
#include <rtl/instance.hxx>
#include <sal/macros.h>
#include <basiccharclass.hxx>
#include <token.hxx>
@@ -192,8 +191,6 @@ public:
{ return m_pTokenCanBeLabelTab[eTok]; }
};
class StaticTokenLabelInfo: public ::rtl::Static< TokenLabelInfo, StaticTokenLabelInfo >{};
}
// #i109076
@@ -546,7 +543,9 @@ special:
bool SbiTokenizer::MayBeLabel( bool bNeedsColon )
{
if( eCurTok == SYMBOL || StaticTokenLabelInfo::get().canTokenBeLabel( eCurTok ) )
static TokenLabelInfo gaStaticTokenLabelInfo;
if( eCurTok == SYMBOL || gaStaticTokenLabelInfo.canTokenBeLabel( eCurTok ) )
{
return !bNeedsColon || DoesColonFollow();
}
+8 -11
View File
@@ -1769,17 +1769,16 @@ typedef std::unordered_map< SbxVariable*, DimAsNewRecoverItem,
namespace {
class GaDimAsNewRecoverHash : public rtl::Static<DimAsNewRecoverHash, GaDimAsNewRecoverHash> {};
DimAsNewRecoverHash gaDimAsNewRecoverHash;
}
void removeDimAsNewRecoverItem( SbxVariable* pVar )
{
DimAsNewRecoverHash &rDimAsNewRecoverHash = GaDimAsNewRecoverHash::get();
DimAsNewRecoverHash::iterator it = rDimAsNewRecoverHash.find( pVar );
if( it != rDimAsNewRecoverHash.end() )
DimAsNewRecoverHash::iterator it = gaDimAsNewRecoverHash.find( pVar );
if( it != gaDimAsNewRecoverHash.end() )
{
rDimAsNewRecoverHash.erase( it );
gaDimAsNewRecoverHash.erase( it );
}
}
@@ -1950,9 +1949,8 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
if( xPrevVarObj.is() )
{
// Object is overwritten with NULL, instantiate init object
DimAsNewRecoverHash &rDimAsNewRecoverHash = GaDimAsNewRecoverHash::get();
DimAsNewRecoverHash::iterator it = rDimAsNewRecoverHash.find( refVar.get() );
if( it != rDimAsNewRecoverHash.end() )
DimAsNewRecoverHash::iterator it = gaDimAsNewRecoverHash.find( refVar.get() );
if( it != gaDimAsNewRecoverHash.end() )
{
const DimAsNewRecoverItem& rItem = it->second;
if( rItem.m_pClassModule != nullptr )
@@ -1985,16 +1983,15 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
OUString aObjClass = pValObj->GetClassName();
SbClassModuleObject* pClassModuleObj = dynamic_cast<SbClassModuleObject*>( pValObjBase );
DimAsNewRecoverHash &rDimAsNewRecoverHash = GaDimAsNewRecoverHash::get();
if( pClassModuleObj != nullptr )
{
SbModule* pClassModule = pClassModuleObj->getClassModule();
rDimAsNewRecoverHash[refVar.get()] =
gaDimAsNewRecoverHash[refVar.get()] =
DimAsNewRecoverItem( aObjClass, pValObj->GetName(), pValObj->GetParent(), pClassModule );
}
else if( aObjClass.equalsIgnoreAsciiCase( "Collection" ) )
{
rDimAsNewRecoverHash[refVar.get()] =
gaDimAsNewRecoverHash[refVar.get()] =
DimAsNewRecoverItem( aObjClass, pValObj->GetName(), pValObj->GetParent(), nullptr );
}
}
@@ -29,7 +29,6 @@
#include <dlfcn.h>
#include <osl/mutex.hxx>
#include <rtl/instance.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/ustring.hxx>
#include <sal/log.hxx>
@@ -265,12 +264,11 @@ std::type_info * RTTI::getRTTI(typelib_TypeDescription const & pTypeDescr)
return rtti;
}
struct theRttiFactory: public rtl::Static<RTTI, theRttiFactory> {};
}
std::type_info * x86_64::getRtti(typelib_TypeDescription const & type) {
return theRttiFactory::get().getRTTI(type);
static RTTI theRttiFactory;
return theRttiFactory.getRTTI(type);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+7 -14
View File
@@ -41,7 +41,6 @@
#include <com/sun/star/util/Endianness.hpp>
#include <comphelper/sequence.hxx>
#include <cppuhelper/implbase.hxx>
#include <rtl/instance.hxx>
#include <rtl/math.hxx>
#include <tools/diagnose_ex.h>
#include <vcl/bitmapex.hxx>
@@ -1973,22 +1972,16 @@ constexpr OUStringLiteral PARAMETRICPOLYPOLYGON_IMPLEMENTATION_NAME = u"Canvas::
}
};
struct CairoNoAlphaColorSpaceHolder : public rtl::StaticWithInit<uno::Reference<rendering::XIntegerBitmapColorSpace>,
CairoNoAlphaColorSpaceHolder>
uno::Reference<rendering::XIntegerBitmapColorSpace>& GetCairoNoAlphaColorSpace()
{
uno::Reference<rendering::XIntegerBitmapColorSpace> operator()()
{
return new CairoNoAlphaColorSpace();
}
static uno::Reference<rendering::XIntegerBitmapColorSpace> SPACE = new CairoNoAlphaColorSpace();
return SPACE;
};
struct CairoColorSpaceHolder : public rtl::StaticWithInit<uno::Reference<rendering::XIntegerBitmapColorSpace>,
CairoColorSpaceHolder>
uno::Reference<rendering::XIntegerBitmapColorSpace>& GetCairoColorSpace()
{
uno::Reference<rendering::XIntegerBitmapColorSpace> operator()()
{
return new CairoColorSpace();
}
static uno::Reference<rendering::XIntegerBitmapColorSpace> SPACE = new CairoColorSpace();
return SPACE;
};
}
@@ -2012,7 +2005,7 @@ constexpr OUStringLiteral PARAMETRICPOLYPOLYGON_IMPLEMENTATION_NAME = u"Canvas::
aLayout.ScanLineBytes = nWidth*4;
aLayout.ScanLineStride = aLayout.ScanLineBytes;
aLayout.PlaneStride = 0;
aLayout.ColorSpace = mbHaveAlpha ? CairoColorSpaceHolder::get() : CairoNoAlphaColorSpaceHolder::get();
aLayout.ColorSpace = mbHaveAlpha ? GetCairoColorSpace() : GetCairoNoAlphaColorSpace();
aLayout.Palette.clear();
aLayout.IsMsbFirst = false;
+2 -13
View File
@@ -210,22 +210,11 @@ namespace cairocanvas
return uno::Any();
}
namespace
{
struct DeviceColorSpace: public rtl::StaticWithInit<uno::Reference<rendering::XColorSpace>,
DeviceColorSpace>
{
uno::Reference<rendering::XColorSpace> operator()()
{
return vcl::unotools::createStandardColorSpace();
}
};
}
uno::Reference<rendering::XColorSpace> const & DeviceHelper::getColorSpace() const
{
static uno::Reference<rendering::XColorSpace> SPACE = vcl::unotools::createStandardColorSpace();
// always the same
return DeviceColorSpace::get();
return SPACE;
}
void DeviceHelper::dumpScreenContent() const
+4 -20
View File
@@ -51,7 +51,6 @@
#include <com/sun/star/rendering/XIntegerBitmapColorSpace.hpp>
#include <com/sun/star/util/Endianness.hpp>
#include <cppuhelper/implbase.hxx>
#include <rtl/instance.hxx>
#include <sal/log.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/diagnose_ex.h>
@@ -843,33 +842,18 @@ namespace canvas::tools
}
};
struct StandardColorSpaceHolder : public rtl::StaticWithInit<uno::Reference<rendering::XIntegerBitmapColorSpace>,
StandardColorSpaceHolder>
{
uno::Reference<rendering::XIntegerBitmapColorSpace> operator()()
{
return new StandardColorSpace();
}
};
struct StandardNoAlphaColorSpaceHolder : public rtl::StaticWithInit<uno::Reference<rendering::XIntegerBitmapColorSpace>,
StandardNoAlphaColorSpaceHolder>
{
uno::Reference<rendering::XIntegerBitmapColorSpace> operator()()
{
return new StandardNoAlphaColorSpace();
}
};
}
uno::Reference<rendering::XIntegerBitmapColorSpace> const & getStdColorSpace()
{
return StandardColorSpaceHolder::get();
static uno::Reference<rendering::XIntegerBitmapColorSpace> SPACE = new StandardColorSpace();
return SPACE;
}
uno::Reference<rendering::XIntegerBitmapColorSpace> const & getStdColorSpaceWithoutAlpha()
{
return StandardNoAlphaColorSpaceHolder::get();
static uno::Reference<rendering::XIntegerBitmapColorSpace> SPACE = new StandardNoAlphaColorSpace();
return SPACE;
}
rendering::IntegerBitmapLayout getStdMemoryLayout( const geometry::IntegerSize2D& rBmpSize )
+9 -9
View File
@@ -22,7 +22,6 @@
#include <basegfx/utils/canvastools.hxx>
#include <basegfx/utils/unopolypolygon.hxx>
#include <canvas/canvastools.hxx>
#include <rtl/instance.hxx>
#include <tools/stream.hxx>
#include <vcl/canvastools.hxx>
#include <vcl/dibtools.hxx>
@@ -174,22 +173,23 @@ namespace vclcanvas
namespace
{
struct DeviceColorSpace: public rtl::StaticWithInit<uno::Reference<rendering::XColorSpace>,
DeviceColorSpace>
uno::Reference<rendering::XColorSpace>& GetDeviceColorSpace()
{
uno::Reference<rendering::XColorSpace> operator()()
static uno::Reference<rendering::XColorSpace> xColorSpace =
[]()
{
uno::Reference< rendering::XColorSpace > xColorSpace = canvas::tools::getStdColorSpace();
assert( xColorSpace.is() );
return xColorSpace;
}
auto xTmp = canvas::tools::getStdColorSpace();
assert( xTmp.is() );
return xTmp;
}();
return xColorSpace;
};
}
uno::Reference<rendering::XColorSpace> const & DeviceHelper::getColorSpace() const
{
// always the same
return DeviceColorSpace::get();
return GetDeviceColorSpace();
}
void DeviceHelper::dumpScreenContent() const
@@ -78,65 +78,41 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEDEFAULT );
}
struct StaticStockChartTypeTemplateDefaults_Initializer
::chart::tPropertyValueMap& GetStaticStockChartTypeTemplateDefaults()
{
::chart::tPropertyValueMap* operator()()
{
static ::chart::tPropertyValueMap aStaticDefaults;
lcl_AddDefaultsToMap( aStaticDefaults );
return &aStaticDefaults;
}
private:
static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
{
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME, false );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_OPEN, false );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH, true );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE, false );
}
static ::chart::tPropertyValueMap aStaticDefaults =
[](){
::chart::tPropertyValueMap aTmp;
::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME, false );
::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_STOCKCHARTTYPE_TEMPLATE_OPEN, false );
::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH, true );
::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE, false );
return aTmp;
}();
return aStaticDefaults;
};
struct StaticStockChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticStockChartTypeTemplateDefaults_Initializer >
::cppu::OPropertyArrayHelper& GetStaticStockChartTypeTemplateInfoHelper()
{
static ::cppu::OPropertyArrayHelper aPropHelper =
[](){
std::vector< css::beans::Property > aProperties;
lcl_AddPropertiesToVector( aProperties );
std::sort( aProperties.begin(), aProperties.end(),
::chart::PropertyNameLess() );
return comphelper::containerToSequence( aProperties );
}();
return aPropHelper;
};
struct StaticStockChartTypeTemplateInfoHelper_Initializer
{
::cppu::OPropertyArrayHelper* operator()()
{
static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
return &aPropHelper;
}
private:
static Sequence< Property > lcl_GetPropertySequence()
{
std::vector< css::beans::Property > aProperties;
lcl_AddPropertiesToVector( aProperties );
std::sort( aProperties.begin(), aProperties.end(),
::chart::PropertyNameLess() );
return comphelper::containerToSequence( aProperties );
}
};
struct StaticStockChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticStockChartTypeTemplateInfoHelper_Initializer >
{
};
struct StaticStockChartTypeTemplateInfo_Initializer
{
uno::Reference< beans::XPropertySetInfo >* operator()()
{
static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
::cppu::OPropertySetHelper::createPropertySetInfo(*StaticStockChartTypeTemplateInfoHelper::get() ) );
return &xPropertySetInfo;
}
};
struct StaticStockChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticStockChartTypeTemplateInfo_Initializer >
uno::Reference< beans::XPropertySetInfo >& GetStaticStockChartTypeTemplateInfo()
{
static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
::cppu::OPropertySetHelper::createPropertySetInfo(GetStaticStockChartTypeTemplateInfoHelper() ) );
return xPropertySetInfo;
};
} // anonymous namespace
@@ -172,7 +148,7 @@ StockChartTypeTemplate::~StockChartTypeTemplate()
// ____ OPropertySet ____
uno::Any StockChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
{
const tPropertyValueMap& rStaticDefaults = *StaticStockChartTypeTemplateDefaults::get();
const tPropertyValueMap& rStaticDefaults = GetStaticStockChartTypeTemplateDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
return uno::Any();
@@ -181,13 +157,13 @@ uno::Any StockChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
::cppu::IPropertyArrayHelper & SAL_CALL StockChartTypeTemplate::getInfoHelper()
{
return *StaticStockChartTypeTemplateInfoHelper::get();
return GetStaticStockChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL StockChartTypeTemplate::getPropertySetInfo()
{
return *StaticStockChartTypeTemplateInfo::get();
return GetStaticStockChartTypeTemplateInfo();
}
sal_Int32 StockChartTypeTemplate::getAxisCountByDimension( sal_Int32 nDimension )
+20 -40
View File
@@ -99,31 +99,21 @@ void lcl_AddPropertiesToVector(
beans::PropertyAttribute::BOUND );
}
struct StaticXXXDefaults_Initializer
::chart::tPropertyValueMap GetStaticXXXDefaults()
{
::chart::tPropertyValueMap* operator()()
{
static ::chart::tPropertyValueMap aStaticDefaults;
::chart::LinePropertiesHelper::AddDefaultsToMap( aStaticDefaults );
return &aStaticDefaults;
}
static ::chart::tPropertyValueMap aStaticDefaults =
[](){
::chart::tPropertyValueMap aTmp;
::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp );
return aTmp;
}();
return aStaticDefaults;
};
struct StaticXXXDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticXXXDefaults_Initializer >
::cppu::OPropertyArrayHelper& GetStaticRegressionCurveInfoHelper()
{
};
struct StaticRegressionCurveInfoHelper_Initializer
{
::cppu::OPropertyArrayHelper* operator()()
{
static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
return &aPropHelper;
}
private:
static uno::Sequence< Property > lcl_GetPropertySequence()
{
static ::cppu::OPropertyArrayHelper aPropHelper =
[](){
std::vector< css::beans::Property > aProperties;
lcl_AddPropertiesToVector( aProperties );
::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
@@ -132,25 +122,15 @@ private:
::chart::PropertyNameLess() );
return comphelper::containerToSequence( aProperties );
}
}();
return aPropHelper;
};
struct StaticRegressionCurveInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticRegressionCurveInfoHelper_Initializer >
{
};
struct StaticRegressionCurveInfo_Initializer
{
uno::Reference< beans::XPropertySetInfo >* operator()()
{
static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
::cppu::OPropertySetHelper::createPropertySetInfo(*StaticRegressionCurveInfoHelper::get() ) );
return &xPropertySetInfo;
}
};
struct StaticRegressionCurveInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticRegressionCurveInfo_Initializer >
uno::Reference< beans::XPropertySetInfo >& GetStaticRegressionCurveInfo()
{
static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
::cppu::OPropertySetHelper::createPropertySetInfo(GetStaticRegressionCurveInfoHelper() ) );
return xPropertySetInfo;
};
} // anonymous namespace
@@ -286,7 +266,7 @@ void RegressionCurveModel::fireModifyEvent()
// ____ OPropertySet ____
uno::Any RegressionCurveModel::GetDefaultValue( sal_Int32 nHandle ) const
{
const tPropertyValueMap& rStaticDefaults = *StaticXXXDefaults::get();
const tPropertyValueMap& rStaticDefaults = GetStaticXXXDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
return uno::Any();
@@ -295,13 +275,13 @@ uno::Any RegressionCurveModel::GetDefaultValue( sal_Int32 nHandle ) const
::cppu::IPropertyArrayHelper & SAL_CALL RegressionCurveModel::getInfoHelper()
{
return *StaticRegressionCurveInfoHelper::get();
return GetStaticRegressionCurveInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL RegressionCurveModel::getPropertySetInfo()
{
return *StaticRegressionCurveInfo::get();
return GetStaticRegressionCurveInfo();
}
// needed by MSC compiler
+45 -71
View File
@@ -105,84 +105,58 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEVOID );
}
struct StaticRegressionEquationDefaults_Initializer
::chart::tPropertyValueMap& GetStaticRegressionEquationDefaults()
{
::chart::tPropertyValueMap* operator()()
{
static ::chart::tPropertyValueMap aStaticDefaults;
lcl_AddDefaultsToMap( aStaticDefaults );
return &aStaticDefaults;
}
private:
static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
{
::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
::chart::FillProperties::AddDefaultsToMap( rOutMap );
::chart::CharacterProperties::AddDefaultsToMap( rOutMap );
static ::chart::tPropertyValueMap aStaticDefaults =
[](){
::chart::tPropertyValueMap aOutMap;
::chart::LinePropertiesHelper::AddDefaultsToMap( aOutMap );
::chart::FillProperties::AddDefaultsToMap( aOutMap );
::chart::CharacterProperties::AddDefaultsToMap( aOutMap );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SHOW, false );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_XNAME, OUString("x") );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_YNAME, OUString("f(x)") );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SHOW_CORRELATION_COEFF, false );
//::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SEPARATOR, OUString( '\n' ));
::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_EQUATION_SHOW, false );
::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_EQUATION_XNAME, OUString("x") );
::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_EQUATION_YNAME, OUString("f(x)") );
::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_EQUATION_SHOW_CORRELATION_COEFF, false );
//::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_EQUATION_SEPARATOR, OUString( '\n' ));
// override other defaults
::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE );
::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
// override other defaults
::chart::PropertyHelper::setPropertyValue( aOutMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE );
::chart::PropertyHelper::setPropertyValue( aOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
float fDefaultCharHeight = 10.0;
::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
}
float fDefaultCharHeight = 10.0;
::chart::PropertyHelper::setPropertyValue( aOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
::chart::PropertyHelper::setPropertyValue( aOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
::chart::PropertyHelper::setPropertyValue( aOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
return aOutMap;
}();
return aStaticDefaults;
};
struct StaticRegressionEquationDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticRegressionEquationDefaults_Initializer >
::cppu::OPropertyArrayHelper& GetStaticRegressionEquationInfoHelper()
{
static ::cppu::OPropertyArrayHelper aPropHelper =
[](){
std::vector< css::beans::Property > aProperties;
lcl_AddPropertiesToVector( aProperties );
::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
::chart::FillProperties::AddPropertiesToVector( aProperties );
::chart::CharacterProperties::AddPropertiesToVector( aProperties );
::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
std::sort( aProperties.begin(), aProperties.end(),
::chart::PropertyNameLess() );
return comphelper::containerToSequence( aProperties );
}();
return aPropHelper;
};
struct StaticRegressionEquationInfoHelper_Initializer
{
::cppu::OPropertyArrayHelper* operator()()
{
static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
return &aPropHelper;
}
private:
static uno::Sequence< Property > lcl_GetPropertySequence()
{
std::vector< css::beans::Property > aProperties;
lcl_AddPropertiesToVector( aProperties );
::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
::chart::FillProperties::AddPropertiesToVector( aProperties );
::chart::CharacterProperties::AddPropertiesToVector( aProperties );
::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
std::sort( aProperties.begin(), aProperties.end(),
::chart::PropertyNameLess() );
return comphelper::containerToSequence( aProperties );
}
};
struct StaticRegressionEquationInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticRegressionEquationInfoHelper_Initializer >
{
};
struct StaticRegressionEquationInfo_Initializer
{
uno::Reference< beans::XPropertySetInfo >* operator()()
{
static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
::cppu::OPropertySetHelper::createPropertySetInfo(*StaticRegressionEquationInfoHelper::get() ) );
return &xPropertySetInfo;
}
};
struct StaticRegressionEquationInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticRegressionEquationInfo_Initializer >
const uno::Reference< beans::XPropertySetInfo > & GetStaticRegressionEquationInfo()
{
static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
::cppu::OPropertySetHelper::createPropertySetInfo(GetStaticRegressionEquationInfoHelper()) );
return xPropertySetInfo;
};
} // anonymous namespace
@@ -213,7 +187,7 @@ uno::Reference< util::XCloneable > SAL_CALL RegressionEquation::createClone()
// ____ OPropertySet ____
uno::Any RegressionEquation::GetDefaultValue( sal_Int32 nHandle ) const
{
const tPropertyValueMap& rStaticDefaults = *StaticRegressionEquationDefaults::get();
const tPropertyValueMap& rStaticDefaults = GetStaticRegressionEquationDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
return uno::Any();
@@ -222,13 +196,13 @@ uno::Any RegressionEquation::GetDefaultValue( sal_Int32 nHandle ) const
::cppu::IPropertyArrayHelper & SAL_CALL RegressionEquation::getInfoHelper()
{
return *StaticRegressionEquationInfoHelper::get();
return GetStaticRegressionEquationInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL RegressionEquation::getPropertySetInfo()
{
return *StaticRegressionEquationInfo::get();
return GetStaticRegressionEquationInfo();
}
// ____ XModifyBroadcaster ____