diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-20 13:09:09 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-23 13:35:25 +0100 |
commit | 70894bcdb3912dbe87031da0af9ae5d591275e2a (patch) | |
tree | ca424232691a12bfca34293b093a7d9bd21525e9 /xmloff | |
parent | 0c8b936734285ee7f373c41ecbad5a65953789dc (diff) |
improve function local statics
simplify the initialisaion and make them thread-safe i.e. initialise
them using the runtime's local static locking.
Thanks to mike kaganski for pointing out the nice lambda approach that
makes this feasible.
Change-Id: I76391189a6d0a3d7eed2d0d88d28dfa6541eaff7
Reviewed-on: https://gerrit.libreoffice.org/63645
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/forms/propertyimport.cxx | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/xmloff/source/forms/propertyimport.cxx b/xmloff/source/forms/propertyimport.cxx index 540d670c8a0c..e9ac0bba5dec 100644 --- a/xmloff/source/forms/propertyimport.cxx +++ b/xmloff/source/forms/propertyimport.cxx @@ -233,19 +233,18 @@ Type PropertyConversion::xmlTypeToUnoType( const OUString& _rType ) { Type aUnoType( cppu::UnoType<void>::get() ); - static std::map< OUString, css::uno::Type > s_aTypeNameMap; - if ( s_aTypeNameMap.empty() ) + static std::map< OUString, css::uno::Type > s_aTypeNameMap { - s_aTypeNameMap[ token::GetXMLToken( token::XML_BOOLEAN ) ] = cppu::UnoType<bool>::get(); + { token::GetXMLToken( token::XML_BOOLEAN ) , cppu::UnoType<bool>::get()}, // Not a copy paste error, quotation from: // http://nabble.documentfoundation.org/Question-unoType-for-getXmlToken-dbaccess-reportdesign-module-tp4109071p4109116.html // all numeric types (including the UNO double) // consistently map to XML_FLOAT, so taking the extra precision from the // C++ type "float" to "double" makes absolute sense - s_aTypeNameMap[ token::GetXMLToken( token::XML_FLOAT ) ] = ::cppu::UnoType<double>::get(); - s_aTypeNameMap[ token::GetXMLToken( token::XML_STRING ) ] = ::cppu::UnoType<OUString>::get(); - s_aTypeNameMap[ token::GetXMLToken( token::XML_VOID ) ] = cppu::UnoType<void>::get(); - } + { token::GetXMLToken( token::XML_FLOAT ) , ::cppu::UnoType<double>::get()}, + { token::GetXMLToken( token::XML_STRING ) , ::cppu::UnoType<OUString>::get()}, + { token::GetXMLToken( token::XML_VOID ) , cppu::UnoType<void>::get() }, + }; const std::map< OUString, css::uno::Type >::iterator aTypePos = s_aTypeNameMap.find( _rType ); OSL_ENSURE( s_aTypeNameMap.end() != aTypePos, "PropertyConversion::xmlTypeToUnoType: invalid property name!" ); |