Rebased ref, commits from common ancestor: commit 80773825cc2af1aa9862e7503e20110a850fdd8d Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed Jun 14 11:48:51 2023 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Jun 14 11:48:51 2023 +0900
oox: use frozen unordered_map for static data Change-Id: I4a53fa57f52900104d249c84cde36c9d3b9e1300 diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk index b878089027b1..3bf2d607918c 100644 --- a/oox/Library_oox.mk +++ b/oox/Library_oox.mk @@ -65,6 +65,7 @@ $(eval $(call gb_Library_use_libraries,oox,\ $(eval $(call gb_Library_use_externals,oox,\ boost_headers \ + frozen \ )) ifeq ($(TLS),OPENSSL) diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index ad0b5ca7835e..6660c6bd2660 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -19,7 +19,9 @@ #include <oox/drawingml/color.hxx> #include <algorithm> -#include <unordered_map> +#include <frozen/bits/defines.h> +#include <frozen/bits/elsa_std.h> +#include <frozen/unordered_map.h> #include <math.h> #include <osl/diagnose.h> #include <sal/log.hxx> @@ -214,39 +216,40 @@ void lclOffValue( sal_Int32& ornValue, sal_Int32 nOff, sal_Int32 nMax = MAX_PERC ornValue = getLimitedValue< sal_Int32, sal_Int32 >( ornValue + nOff, 0, nMax ); } +static constexpr frozen::unordered_map<std::u16string_view, model::ThemeColorType, 26> aSchemeColorNameToIndex +{ + { u"dk1", model::ThemeColorType::Dark1 }, + { u"lt1", model::ThemeColorType::Light1 }, + { u"dk2", model::ThemeColorType::Dark2 }, + { u"lt2", model::ThemeColorType::Light2 }, + { u"accent1", model::ThemeColorType::Accent1 }, + { u"accent2", model::ThemeColorType::Accent2 }, + { u"accent3", model::ThemeColorType::Accent3 }, + { u"accent4", model::ThemeColorType::Accent4 }, + { u"accent5", model::ThemeColorType::Accent5 }, + { u"accent6", model::ThemeColorType::Accent6 }, + { u"hlink", model::ThemeColorType::Hyperlink }, + { u"folHlink", model::ThemeColorType::FollowedHyperlink }, + { u"tx1", model::ThemeColorType::Dark1 }, + { u"bg1", model::ThemeColorType::Light1 }, + { u"tx2", model::ThemeColorType::Dark2 }, + { u"bg2", model::ThemeColorType::Light2 }, + { u"dark1", model::ThemeColorType::Dark1}, + { u"light1", model::ThemeColorType::Light1}, + { u"dark2", model::ThemeColorType::Dark2 }, + { u"light2", model::ThemeColorType::Light2 }, + { u"text1", model::ThemeColorType::Dark1 }, + { u"background1", model::ThemeColorType::Light1 }, + { u"text2", model::ThemeColorType::Dark2 }, + { u"background2", model::ThemeColorType::Light2 }, + { u"hyperlink", model::ThemeColorType::Hyperlink }, + { u"followedHyperlink", model::ThemeColorType::FollowedHyperlink } +}; + } // namespace model::ThemeColorType schemeNameToThemeColorType(OUString const& rSchemeName) { - static std::unordered_map<OUString, model::ThemeColorType> const aSchemeColorNameToIndex{ - { u"dk1", model::ThemeColorType::Dark1 }, - { u"lt1", model::ThemeColorType::Light1 }, - { u"dk2", model::ThemeColorType::Dark2 }, - { u"lt2", model::ThemeColorType::Light2 }, - { u"accent1", model::ThemeColorType::Accent1 }, - { u"accent2", model::ThemeColorType::Accent2 }, - { u"accent3", model::ThemeColorType::Accent3 }, - { u"accent4", model::ThemeColorType::Accent4 }, - { u"accent5", model::ThemeColorType::Accent5 }, - { u"accent6", model::ThemeColorType::Accent6 }, - { u"hlink", model::ThemeColorType::Hyperlink }, - { u"folHlink", model::ThemeColorType::FollowedHyperlink }, - { u"tx1", model::ThemeColorType::Dark1 }, - { u"bg1", model::ThemeColorType::Light1 }, - { u"tx2", model::ThemeColorType::Dark2 }, - { u"bg2", model::ThemeColorType::Light2 }, - { u"dark1", model::ThemeColorType::Dark1}, - { u"light1", model::ThemeColorType::Light1}, - { u"dark2", model::ThemeColorType::Dark2 }, - { u"light2", model::ThemeColorType::Light2 }, - { u"text1", model::ThemeColorType::Dark1 }, - { u"background1", model::ThemeColorType::Light1 }, - { u"text2", model::ThemeColorType::Dark2 }, - { u"background2", model::ThemeColorType::Light2 }, - { u"hyperlink", model::ThemeColorType::Hyperlink }, - { u"followedHyperlink", model::ThemeColorType::FollowedHyperlink} - }; - auto aIterator = aSchemeColorNameToIndex.find(rSchemeName); if (aIterator == aSchemeColorNameToIndex.end()) return model::ThemeColorType::Unknown; diff --git a/oox/source/drawingml/colorchoicecontext.cxx b/oox/source/drawingml/colorchoicecontext.cxx index b0977c5e003c..04b9f996d8d5 100644 --- a/oox/source/drawingml/colorchoicecontext.cxx +++ b/oox/source/drawingml/colorchoicecontext.cxx @@ -24,13 +24,16 @@ #include <oox/token/namespaces.hxx> #include <oox/token/tokens.hxx> #include <unordered_map> +#include <frozen/bits/defines.h> +#include <frozen/bits/elsa_std.h> +#include <frozen/unordered_map.h> namespace oox::drawingml { namespace { -const std::unordered_map<sal_Int32, model::SystemColorType> constSystemColorMap = +static constexpr frozen::unordered_map<sal_Int32, model::SystemColorType, 30> constSystemColorMap { { XML_scrollBar, model::SystemColorType::ScrollBar }, { XML_background, model::SystemColorType::Background }, @@ -64,7 +67,7 @@ const std::unordered_map<sal_Int32, model::SystemColorType> constSystemColorMap { XML_menuBar, model::SystemColorType::MenuBar } }; -const std::unordered_map<sal_Int32, model::TransformationType> constTransformTypeMap = +static constexpr frozen::unordered_map<sal_Int32, model::TransformationType, 28> constTransformTypeMap { { XML_alpha, model::TransformationType::Alpha }, { XML_alphaMod, model::TransformationType::AlphaMod }, diff --git a/oox/source/drawingml/fontworkhelpers.cxx b/oox/source/drawingml/fontworkhelpers.cxx index 3c8d28d634c6..0a68e4844a9b 100644 --- a/oox/source/drawingml/fontworkhelpers.cxx +++ b/oox/source/drawingml/fontworkhelpers.cxx @@ -905,6 +905,18 @@ void FontworkHelpers::applyPropsToRuns(const std::vector<beans::PropertyValue>& } } } +namespace +{ +constexpr const std::array<std::u16string_view, 5> aCharPropNames{ + u"CharColorLumMod", u"CharColorLumOff", u"CharColorTheme", u"CharComplexColor", + u"CharTransparence" +}; + +constexpr const std::array<std::u16string_view, 5> aShapePropNames{ + u"FillColorLumMod", u"FillColorLumOff", u"FillColorTheme", u"FillComplexColor", + u"FillTransparence" +}; +} void FontworkHelpers::createCharFillPropsFromShape( const uno::Reference<beans::XPropertySet>& rXPropSet, @@ -930,17 +942,12 @@ void FontworkHelpers::createCharFillPropsFromShape( rCharPropVec.push_back(comphelper::makePropertyValue(u"CharColor", sal_Int32(aColor))); } - const std::array<OUString, 5> aCharPropNames - = { u"CharColorLumMod", u"CharColorLumOff", u"CharColorTheme", u"CharComplexColor", - u"CharTransparence" }; - const std::array<OUString, 5> aShapePropNames - = { u"FillColorLumMod", u"FillColorLumOff", u"FillColorTheme", u"FillComplexColor", - u"FillTransparence" }; for (size_t i = 0; i < 5; i++) { - if (xPropSetInfo->hasPropertyByName(aShapePropNames[i])) + OUString aPropertyName(aShapePropNames[i]); + if (xPropSetInfo->hasPropertyByName(aPropertyName)) rCharPropVec.push_back(comphelper::makePropertyValue( - aCharPropNames[i], rXPropSet->getPropertyValue(aShapePropNames[i]))); + OUString(aCharPropNames[i]), rXPropSet->getPropertyValue(aPropertyName))); } } @@ -1039,29 +1046,32 @@ typedef std::multimap<sal_Int32, GradientStopColor> ColorMapType; namespace { +constexpr const std::array<std::u16string_view, 12> W14ColorNames{ + u"tx1", u"bg1", u"tx2", u"bg2", u"accent1", u"accent2", + u"accent3", u"accent4", u"accent5", u"accent6", u"hlink", u"folHlink" +}; + +constexpr const std::array<std::u16string_view, 12> WColorNames{ + u"text1", u"background1", u"text2", u"background2", u"accent1", u"accent2", + u"accent3", u"accent4", u"accent5", u"accent6", u"hyperlink", u"followedHyperlink" +}; + // Returns the string to be used in w14:schemeClr in case of w14:textOutline or w14:textFill OUString lcl_getW14MarkupStringForThemeColor(const model::ComplexColor& rComplexColor) { - const std::array<OUString, 12> W14ColorNames - = { u"tx1", u"bg1", u"tx2", u"bg2", u"accent1", u"accent2", - u"accent3", u"accent4", u"accent5", u"accent6", u"hlink", u"folHlink" }; const sal_uInt8 nClrNameIndex = std::clamp<sal_uInt8>( sal_Int32(rComplexColor.getSchemeType()), sal_Int32(model::ThemeColorType::Dark1), sal_Int32(model::ThemeColorType::FollowedHyperlink)); - return W14ColorNames[nClrNameIndex]; + return OUString(W14ColorNames[nClrNameIndex]); } // Returns the string to be used in w:themeColor. It is exported via CharThemeColor. OUString lcl_getWMarkupStringForThemeColor(const model::ComplexColor& rComplexColor) { - const std::array<OUString, 12> WColorNames - = { u"text1", u"background1", u"text2", u"background2", - u"accent1", u"accent2", u"accent3", u"accent4", - u"accent5", u"accent6", u"hyperlink", u"followedHyperlink" }; const sal_uInt8 nClrNameIndex = std::clamp<sal_uInt8>( sal_Int32(rComplexColor.getSchemeType()), sal_Int32(model::ThemeColorType::Dark1), sal_Int32(model::ThemeColorType::FollowedHyperlink)); - return WColorNames[nClrNameIndex]; + return OUString(WColorNames[nClrNameIndex]); } // Puts the value of the first occurrence of rType in rComplexColor into rValue and returns true. diff --git a/oox/source/drawingml/misccontexts.cxx b/oox/source/drawingml/misccontexts.cxx index 25058d392600..3de0538925b4 100644 --- a/oox/source/drawingml/misccontexts.cxx +++ b/oox/source/drawingml/misccontexts.cxx @@ -28,6 +28,9 @@ #include <vcl/GraphicExternalLink.hxx> #include <vcl/graph.hxx> #include <unordered_map> +#include <frozen/bits/defines.h> +#include <frozen/bits/elsa_std.h> +#include <frozen/unordered_map.h> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -143,7 +146,7 @@ ContextHandlerRef GradientFillContext::onCreateContext( namespace { -std::unordered_map<sal_Int32, model::PatternPreset> constPatternPresetMap = +static constexpr frozen::unordered_map<sal_Int32, model::PatternPreset, 54> constPatternPresetMap { { XML_pct5, model::PatternPreset::Percent_5 }, { XML_pct10, model::PatternPreset::Percent_10 }, diff --git a/oox/source/drawingml/table/predefined-table-styles.cxx b/oox/source/drawingml/table/predefined-table-styles.cxx index 531e20b14512..f3f9082f2501 100644 --- a/oox/source/drawingml/table/predefined-table-styles.cxx +++ b/oox/source/drawingml/table/predefined-table-styles.cxx @@ -8,6 +8,9 @@ */ #include <oox/token/tokens.hxx> #include <drawingml/table/tablestyle.hxx> +#include <frozen/bits/defines.h> +#include <frozen/bits/elsa_std.h> +#include <frozen/unordered_map.h> using namespace oox; using namespace oox::drawingml::table; @@ -194,13 +197,18 @@ static void createStyleIdMap() = std::make_pair(OUString("Dark-Style-2"), OUString("Accent5")); } -static std::map<OUString, sal_Int32> tokens = { { "", XML_dk1 }, - { "Accent1", XML_accent1 }, - { "Accent2", XML_accent2 }, - { "Accent3", XML_accent3 }, - { "Accent4", XML_accent4 }, - { "Accent5", XML_accent5 }, - { "Accent6", XML_accent6 } }; +static constexpr frozen::unordered_map<std::u16string_view, sal_Int32, 6> tokens{ + { u"Accent1", XML_accent1 }, { u"Accent2", XML_accent2 }, { u"Accent3", XML_accent3 }, + { u"Accent4", XML_accent4 }, { u"Accent5", XML_accent5 }, { u"Accent6", XML_accent6 } +}; + +sal_Int32 resolveToken(OUString const& rString) +{ + auto interator = tokens.find(rString); + if (interator != tokens.end()) + return interator->second; + return XML_dk1; +} void setBorderLineType(const oox::drawingml::LinePropertiesPtr& pLineProp, sal_Int32 nToken) { @@ -444,7 +452,7 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) setBorderLineType(pLastColBottomBorder, XML_solidFill); setBorderLineType(pLastColInsideHBorder, XML_solidFill); - sal_Int32 accent_val = tokens[mStyleIdMap[styleId].second]; + sal_Int32 accent_val = resolveToken(mStyleIdMap[styleId].second); wholeTblTextColor.setSchemeClr(XML_dk1); firstRowTextColor.setSchemeClr(XML_lt1); @@ -509,7 +517,7 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) wholeTblTextColor.setSchemeClr(XML_lt1); firstRowTextColor.setSchemeClr(XML_lt1); - accent_val = tokens[mStyleIdMap[styleId].second]; + accent_val = resolveToken(mStyleIdMap[styleId].second); pTblBgFillProperties->maFillColor.setSchemeClr(accent_val); pFirstRowBottomBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1); @@ -554,7 +562,7 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) sal_Int32 accent_val; if (!accent_name.isEmpty()) - accent_val = tokens[mStyleIdMap[styleId].second]; + accent_val = resolveToken(mStyleIdMap[styleId].second); else accent_val = XML_tx1; @@ -591,7 +599,7 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) sal_Int32 accent_val; if (!accent_name.isEmpty()) - accent_val = tokens[mStyleIdMap[styleId].second]; + accent_val = resolveToken(mStyleIdMap[styleId].second); else accent_val = XML_tx1; @@ -628,7 +636,7 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) sal_Int32 accent_val; if (!accent_name.isEmpty()) - accent_val = tokens[mStyleIdMap[styleId].second]; + accent_val = resolveToken(mStyleIdMap[styleId].second); else accent_val = XML_tx1; @@ -665,7 +673,7 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) sal_Int32 accent_val; if (!accent_name.isEmpty()) - accent_val = tokens[mStyleIdMap[styleId].second]; + accent_val = resolveToken(mStyleIdMap[styleId].second); else accent_val = XML_dk1; @@ -713,7 +721,7 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) sal_Int32 accent_val; if (!accent_name.isEmpty()) - accent_val = tokens[mStyleIdMap[styleId].second]; + accent_val = resolveToken(mStyleIdMap[styleId].second); else accent_val = XML_dk1; @@ -753,7 +761,7 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) sal_Int32 accent_val; if (!accent_name.isEmpty()) - accent_val = tokens[mStyleIdMap[styleId].second]; + accent_val = resolveToken(mStyleIdMap[styleId].second); else accent_val = XML_dk1; @@ -780,7 +788,7 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) sal_Int32 accent_val; if (!accent_name.isEmpty()) - accent_val = tokens[mStyleIdMap[styleId].second]; + accent_val = resolveToken(mStyleIdMap[styleId].second); else accent_val = XML_dk1; @@ -823,7 +831,7 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) if (!accent_name.isEmpty()) { - accent_val = tokens[mStyleIdMap[styleId].second]; + accent_val = resolveToken(mStyleIdMap[styleId].second); transform_val = XML_shade; } else @@ -866,7 +874,7 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) sal_Int32 accent_val; if (!accent_name.isEmpty()) - accent_val = tokens[mStyleIdMap[styleId].second]; + accent_val = resolveToken(mStyleIdMap[styleId].second); else accent_val = XML_dk1; diff --git a/oox/source/export/ThemeExport.cxx b/oox/source/export/ThemeExport.cxx index f09f9012e246..f60304155d9e 100644 --- a/oox/source/export/ThemeExport.cxx +++ b/oox/source/export/ThemeExport.cxx @@ -19,6 +19,9 @@ #include <sax/fastattribs.hxx> #include <unordered_map> #include <oox/export/drawingml.hxx> +#include <frozen/bits/defines.h> +#include <frozen/bits/elsa_std.h> +#include <frozen/unordered_map.h> namespace oox { @@ -142,16 +145,84 @@ bool ThemeExport::writeFontScheme(model::FontScheme const& rFontScheme) return true; } -void ThemeExport::writeColorTransformations( - std::vector<model::Transformation> const& rTransformations) +namespace { - static std::unordered_map<model::TransformationType, sal_Int32> constTransformTypeTokenMap = { +static constexpr frozen::unordered_map<model::TransformationType, sal_Int32, 4> + constTransformTypeTokenMap{ { model::TransformationType::Tint, XML_tint }, { model::TransformationType::Shade, XML_shade }, { model::TransformationType::LumMod, XML_lumMod }, { model::TransformationType::LumOff, XML_lumOff }, }; +static constexpr frozen::unordered_map<model::ThemeColorType, const char*, 12> + constThemeColorTypeTokenMap{ { model::ThemeColorType::Dark1, "dk1" }, + { model::ThemeColorType::Light1, "lt1" }, + { model::ThemeColorType::Dark2, "dk2" }, + { model::ThemeColorType::Light2, "lt2" }, + { model::ThemeColorType::Accent1, "accent1" }, + { model::ThemeColorType::Accent2, "accent2" }, + { model::ThemeColorType::Accent3, "accent3" }, + { model::ThemeColorType::Accent4, "accent4" }, + { model::ThemeColorType::Accent5, "accent5" }, + { model::ThemeColorType::Accent6, "accent6" }, + { model::ThemeColorType::Hyperlink, "hlink" }, + { model::ThemeColorType::FollowedHyperlink, "folHlink" } }; + +static constexpr frozen::unordered_map<model::SystemColorType, const char*, 30> + constSystemColorTypeTokenMap{ + { model::SystemColorType::DarkShadow3D, "3dDkShadow" }, + { model::SystemColorType::Light3D, "3dLight" }, + { model::SystemColorType::ActiveBorder, "activeBorder" }, + { model::SystemColorType::ActiveCaption, "activeCaption" }, + { model::SystemColorType::AppWorkspace, "appWorkspace" }, + { model::SystemColorType::Background, "background" }, + { model::SystemColorType::ButtonFace, "btnFace" }, + { model::SystemColorType::ButtonHighlight, "btnHighlight" }, + { model::SystemColorType::ButtonShadow, "btnShadow" }, + { model::SystemColorType::ButtonText, "btnText" }, + { model::SystemColorType::CaptionText, "captionText" }, + { model::SystemColorType::GradientActiveCaption, "gradientActiveCaption" }, + { model::SystemColorType::GradientInactiveCaption, "gradientInactiveCaption" }, + { model::SystemColorType::GrayText, "grayText" }, + { model::SystemColorType::Highlight, "highlight" }, + { model::SystemColorType::HighlightText, "highlightText" }, + { model::SystemColorType::HotLight, "hotLight" }, + { model::SystemColorType::InactiveBorder, "inactiveBorder" }, + { model::SystemColorType::InactiveCaption, "inactiveCaption" }, + { model::SystemColorType::InactiveCaptionText, "inactiveCaptionText" }, + { model::SystemColorType::InfoBack, "infoBk" }, + { model::SystemColorType::InfoText, "infoText" }, + { model::SystemColorType::Menu, "menu" }, + { model::SystemColorType::MenuBar, "menuBar" }, + { model::SystemColorType::MenuHighlight, "menuHighlight" }, + { model::SystemColorType::MenuText, "menuText" }, + { model::SystemColorType::ScrollBar, "scrollBar" }, + { model::SystemColorType::Window, "window" }, + { model::SystemColorType::WindowFrame, "windowFrame" }, + { model::SystemColorType::WindowText, "windowText" } + }; + +static constexpr frozen::unordered_map<sal_Int32, model::ThemeColorType, 12> constTokenMap{ + { XML_dk1, model::ThemeColorType::Dark1 }, + { XML_lt1, model::ThemeColorType::Light1 }, + { XML_dk2, model::ThemeColorType::Dark2 }, + { XML_lt2, model::ThemeColorType::Light2 }, + { XML_accent1, model::ThemeColorType::Accent1 }, + { XML_accent2, model::ThemeColorType::Accent2 }, + { XML_accent3, model::ThemeColorType::Accent3 }, + { XML_accent4, model::ThemeColorType::Accent4 }, + { XML_accent5, model::ThemeColorType::Accent5 }, + { XML_accent6, model::ThemeColorType::Accent6 }, + { XML_hlink, model::ThemeColorType::Hyperlink }, + { XML_folHlink, model::ThemeColorType::FollowedHyperlink } +}; + +} // end anonymous ns + +void ThemeExport::writeColorTransformations( + std::vector<model::Transformation> const& rTransformations) +{ for (model::Transformation const& rTransformation : rTransformations) { auto iterator = constTransformTypeTokenMap.find(rTransformation.meType); @@ -191,19 +262,6 @@ void ThemeExport::writeColorHSL(model::ComplexColor const& rComplexColor) void ThemeExport::writeColorScheme(model::ComplexColor const& rComplexColor) { - static std::unordered_map<model::ThemeColorType, const char*> constThemeColorTypeTokenMap - = { { model::ThemeColorType::Dark1, "dk1" }, - { model::ThemeColorType::Light1, "lt1" }, - { model::ThemeColorType::Dark2, "dk2" }, - { model::ThemeColorType::Light2, "lt2" }, - { model::ThemeColorType::Accent1, "accent1" }, - { model::ThemeColorType::Accent2, "accent2" }, - { model::ThemeColorType::Accent3, "accent3" }, - { model::ThemeColorType::Accent4, "accent4" }, - { model::ThemeColorType::Accent5, "accent5" }, - { model::ThemeColorType::Accent6, "accent6" }, - { model::ThemeColorType::Hyperlink, "hlink" }, - { model::ThemeColorType::FollowedHyperlink, "folHlink" } }; auto iterator = constThemeColorTypeTokenMap.find(rComplexColor.meSchemeType); if (iterator != constThemeColorTypeTokenMap.end()) { @@ -216,40 +274,8 @@ void ThemeExport::writeColorScheme(model::ComplexColor const& rComplexColor) void ThemeExport::writeColorSystem(model::ComplexColor const& rComplexColor) { - static std::unordered_map<model::SystemColorType, const char*> constThemeColorTypeTokenMap = { - { model::SystemColorType::DarkShadow3D, "3dDkShadow" }, - { model::SystemColorType::Light3D, "3dLight" }, - { model::SystemColorType::ActiveBorder, "activeBorder" }, - { model::SystemColorType::ActiveCaption, "activeCaption" }, - { model::SystemColorType::AppWorkspace, "appWorkspace" }, - { model::SystemColorType::Background, "background" }, - { model::SystemColorType::ButtonFace, "btnFace" }, - { model::SystemColorType::ButtonHighlight, "btnHighlight" }, - { model::SystemColorType::ButtonShadow, "btnShadow" }, - { model::SystemColorType::ButtonText, "btnText" }, - { model::SystemColorType::CaptionText, "captionText" }, - { model::SystemColorType::GradientActiveCaption, "gradientActiveCaption" }, - { model::SystemColorType::GradientInactiveCaption, "gradientInactiveCaption" }, - { model::SystemColorType::GrayText, "grayText" }, - { model::SystemColorType::Highlight, "highlight" }, - { model::SystemColorType::HighlightText, "highlightText" }, - { model::SystemColorType::HotLight, "hotLight" }, - { model::SystemColorType::InactiveBorder, "inactiveBorder" }, - { model::SystemColorType::InactiveCaption, "inactiveCaption" }, - { model::SystemColorType::InactiveCaptionText, "inactiveCaptionText" }, - { model::SystemColorType::InfoBack, "infoBk" }, - { model::SystemColorType::InfoText, "infoText" }, - { model::SystemColorType::Menu, "menu" }, - { model::SystemColorType::MenuBar, "menuBar" }, - { model::SystemColorType::MenuHighlight, "menuHighlight" }, - { model::SystemColorType::MenuText, "menuText" }, - { model::SystemColorType::ScrollBar, "scrollBar" }, - { model::SystemColorType::Window, "window" }, - { model::SystemColorType::WindowFrame, "windowFrame" }, - { model::SystemColorType::WindowText, "windowText" }, - }; - auto iterator = constThemeColorTypeTokenMap.find(rComplexColor.meSystemColorType); - if (iterator != constThemeColorTypeTokenMap.end()) + auto iterator = constSystemColorTypeTokenMap.find(rComplexColor.meSystemColorType); + if (iterator != constSystemColorTypeTokenMap.end()) { const char* sValue = iterator->second; mpFS->startElementNS(XML_a, XML_sysClr, XML_val, sValue); @@ -844,21 +870,7 @@ bool ThemeExport::writeFormatScheme(model::FormatScheme const& rFormatScheme) bool ThemeExport::writeColorSet(model::Theme const& rTheme) { - static std::unordered_map<sal_Int32, model::ThemeColorType> constTokenMap - = { { XML_dk1, model::ThemeColorType::Dark1 }, - { XML_lt1, model::ThemeColorType::Light1 }, - { XML_dk2, model::ThemeColorType::Dark2 }, - { XML_lt2, model::ThemeColorType::Light2 }, - { XML_accent1, model::ThemeColorType::Accent1 }, - { XML_accent2, model::ThemeColorType::Accent2 }, - { XML_accent3, model::ThemeColorType::Accent3 }, - { XML_accent4, model::ThemeColorType::Accent4 }, - { XML_accent5, model::ThemeColorType::Accent5 }, - { XML_accent6, model::ThemeColorType::Accent6 }, - { XML_hlink, model::ThemeColorType::Hyperlink }, - { XML_folHlink, model::ThemeColorType::FollowedHyperlink } }; - - static std::array<sal_Int32, 12> constTokenArray + static const constexpr std::array<sal_Int32, 12> constTokenArray = { XML_dk1, XML_lt1, XML_dk2, XML_lt2, XML_accent1, XML_accent2, XML_accent3, XML_accent4, XML_accent5, XML_accent6, XML_hlink, XML_folHlink }; @@ -868,11 +880,15 @@ bool ThemeExport::writeColorSet(model::Theme const& rTheme) for (auto nToken : constTokenArray) { - model::ThemeColorType eColorType = constTokenMap[nToken]; - Color aColor = pColorSet->getColor(eColorType); - mpFS->startElementNS(XML_a, nToken); - mpFS->singleElementNS(XML_a, XML_srgbClr, XML_val, I32SHEX(sal_Int32(aColor))); - mpFS->endElementNS(XML_a, nToken); + auto iterator = constTokenMap.find(nToken); + if (iterator != constTokenMap.end()) + { + model::ThemeColorType eColorType = iterator->second; + Color aColor = pColorSet->getColor(eColorType); + mpFS->startElementNS(XML_a, nToken); + mpFS->singleElementNS(XML_a, XML_srgbClr, XML_val, I32SHEX(sal_Int32(aColor))); + mpFS->endElementNS(XML_a, nToken); + } } return true; diff --git a/oox/source/token/relationship.cxx b/oox/source/token/relationship.cxx index cfe1dedc508d..7cc0bb002fe0 100644 --- a/oox/source/token/relationship.cxx +++ b/oox/source/token/relationship.cxx @@ -10,21 +10,28 @@ #include <oox/token/relationship.hxx> #include <sal/log.hxx> -#include <map> +#include <frozen/bits/defines.h> +#include <frozen/bits/elsa_std.h> +#include <frozen/unordered_map.h> -namespace oox { +namespace oox +{ -OUString getRelationship(Relationship eRelationship) +namespace +{ + +static constexpr frozen::unordered_map<Relationship, std::u16string_view, 48> constRelationshipMap { - static const std::map<Relationship, OUString> aMap = - { #include "relationship.inc" - }; +}; - auto itr = aMap.find(eRelationship); - if (itr != aMap.end()) - return itr->second; +} // end anonymous ns +OUString getRelationship(Relationship eRelationship) +{ + auto iterator = constRelationshipMap.find(eRelationship); + if (iterator != constRelationshipMap.end()) + return OUString(iterator->second); SAL_WARN("oox", "could not find an entry for the relationship: " << static_cast<int>(eRelationship)); return OUString(); } diff --git a/oox/source/token/relationship.inc b/oox/source/token/relationship.inc index 4a772671a96f..5b2f16b9264c 100644 --- a/oox/source/token/relationship.inc +++ b/oox/source/token/relationship.inc @@ -1,48 +1,48 @@ -{Relationship::ACTIVEXCONTROLBINARY, "http://schemas.microsoft.com/office/2006/relationships/activeXControlBinary"}, -{Relationship::CHART, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"}, -{Relationship::CHARTUSERSHAPES, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes"}, -{Relationship::COMMENTS, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"}, -{Relationship::COMMENTAUTHORS, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors"}, -{Relationship::COMMENTSEXTENDED, "http://schemas.microsoft.com/office/2011/relationships/commentsExtended"}, -{Relationship::CONTROL, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/control"}, -{Relationship::CTRLPROP, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp"}, -{Relationship::CUSTOMXML, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"}, -{Relationship::CUSTOMXMLPROPS, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps"}, -{Relationship::DIAGRAMCOLORS, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors"}, -{Relationship::DIAGRAMDATA, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData"}, -{Relationship::DIAGRAMDRAWING, "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing"}, -{Relationship::DIAGRAMLAYOUT, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout"}, -{Relationship::DIAGRAMQUICKSTYLE, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle"}, -{Relationship::DRAWING, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"}, -{Relationship::ENDNOTES, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes"}, -{Relationship::EXTERNALLINKPATH, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath"}, -{Relationship::FONT, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font"}, -{Relationship::FONTTABLE, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"}, -{Relationship::FOOTER, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"}, -{Relationship::FOOTNOTES, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"}, -{Relationship::GLOSSARYDOCUMENT, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument"}, -{Relationship::HDPHOTO, "http://schemas.microsoft.com/office/2007/relationships/hdphoto"}, -{Relationship::HEADER, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"}, -{Relationship::HYPERLINK, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"}, -{Relationship::IMAGE, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"}, -{Relationship::MEDIA, "http://schemas.microsoft.com/office/2007/relationships/media"}, -{Relationship::NOTESMASTER, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster"}, -{Relationship::NOTESSLIDE, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide"}, -{Relationship::NUMBERING, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"}, -{Relationship::OFFICEDOCUMENT, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"}, -{Relationship::OLEOBJECT, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"}, -{Relationship::PACKAGE, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"}, -{Relationship::PRESPROPS, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps"}, -{Relationship::SETTINGS, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"}, -{Relationship::SHAREDSTRINGS, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"}, -{Relationship::SLIDE, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"}, -{Relationship::SLIDELAYOUT, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout"}, -{Relationship::SLIDEMASTER, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster"}, -{Relationship::STYLES, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"}, -{Relationship::THEME, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"}, -{Relationship::VBAPROJECT, "http://schemas.microsoft.com/office/2006/relationships/vbaProject"}, -{Relationship::VIDEO, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video"}, -{Relationship::AUDIO, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio"}, -{Relationship::VMLDRAWING, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing"}, -{Relationship::WORDVBADATA, "http://schemas.microsoft.com/office/2006/relationships/wordVbaData"}, -{Relationship::WORKSHEET, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"} +{Relationship::ACTIVEXCONTROLBINARY, u"http://schemas.microsoft.com/office/2006/relationships/activeXControlBinary"}, +{Relationship::CHART, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"}, +{Relationship::CHARTUSERSHAPES, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes"}, +{Relationship::COMMENTS, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"}, +{Relationship::COMMENTAUTHORS, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors"}, +{Relationship::COMMENTSEXTENDED, u"http://schemas.microsoft.com/office/2011/relationships/commentsExtended"}, +{Relationship::CONTROL, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/control"}, +{Relationship::CTRLPROP, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp"}, +{Relationship::CUSTOMXML, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"}, +{Relationship::CUSTOMXMLPROPS, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps"}, +{Relationship::DIAGRAMCOLORS, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors"}, +{Relationship::DIAGRAMDATA, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData"}, +{Relationship::DIAGRAMDRAWING, u"http://schemas.microsoft.com/office/2007/relationships/diagramDrawing"}, +{Relationship::DIAGRAMLAYOUT, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout"}, +{Relationship::DIAGRAMQUICKSTYLE, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle"}, +{Relationship::DRAWING, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"}, +{Relationship::ENDNOTES, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes"}, +{Relationship::EXTERNALLINKPATH, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath"}, +{Relationship::FONT, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/font"}, +{Relationship::FONTTABLE, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"}, +{Relationship::FOOTER, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"}, +{Relationship::FOOTNOTES, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"}, +{Relationship::GLOSSARYDOCUMENT, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument"}, +{Relationship::HDPHOTO, u"http://schemas.microsoft.com/office/2007/relationships/hdphoto"}, +{Relationship::HEADER, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"}, +{Relationship::HYPERLINK, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"}, +{Relationship::IMAGE, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"}, +{Relationship::MEDIA, u"http://schemas.microsoft.com/office/2007/relationships/media"}, +{Relationship::NOTESMASTER, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster"}, +{Relationship::NOTESSLIDE, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide"}, +{Relationship::NUMBERING, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"}, +{Relationship::OFFICEDOCUMENT, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"}, +{Relationship::OLEOBJECT, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"}, +{Relationship::PACKAGE, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"}, +{Relationship::PRESPROPS, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps"}, +{Relationship::SETTINGS, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"}, +{Relationship::SHAREDSTRINGS, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"}, +{Relationship::SLIDE, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"}, +{Relationship::SLIDELAYOUT, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout"}, +{Relationship::SLIDEMASTER, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster"}, +{Relationship::STYLES, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"}, +{Relationship::THEME, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"}, +{Relationship::VBAPROJECT, u"http://schemas.microsoft.com/office/2006/relationships/vbaProject"}, +{Relationship::VIDEO, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/video"}, +{Relationship::AUDIO, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio"}, +{Relationship::VMLDRAWING, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing"}, +{Relationship::WORDVBADATA, u"http://schemas.microsoft.com/office/2006/relationships/wordVbaData"}, +{Relationship::WORKSHEET, u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"} commit 7b909b8937245bba7c30b6231785a647a02ceb79 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Jul 25 15:38:24 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Jun 14 11:48:06 2023 +0900 svgio: use "frozen" for mapping between token strings and enums Change-Id: I2061606146cfcb34169dccf69b6f720727839d04 diff --git a/svgio/Library_svgio.mk b/svgio/Library_svgio.mk index 6221cb141316..76c0e87123bb 100644 --- a/svgio/Library_svgio.mk +++ b/svgio/Library_svgio.mk @@ -25,7 +25,10 @@ $(eval $(call gb_Library_set_include,svgio,\ -I$(SRCDIR)/svgio/inc \ )) -$(eval $(call gb_Library_use_external,svgio,boost_headers)) +$(eval $(call gb_Library_use_externals,svgio,\ + boost_headers \ + frozen \ +)) $(eval $(call gb_Library_set_precompiled_header,svgio,svgio/inc/pch/precompiled_svgio)) diff --git a/svgio/source/svgreader/svgtoken.cxx b/svgio/source/svgreader/svgtoken.cxx index 8228689606bf..82ecbcf1c5a3 100644 --- a/svgio/source/svgreader/svgtoken.cxx +++ b/svgio/source/svgreader/svgtoken.cxx @@ -18,357 +18,368 @@ */ #include <svgtoken.hxx> -#include <unordered_map> +#include <frozen/bits/defines.h> +#include <frozen/bits/elsa_std.h> +#include <frozen/unordered_map.h> namespace svgio::svgreader { - const char aSVGStrWidth[] = "width"; - const char aSVGStrHeight[] = "height"; - const char aSVGStrViewBox[] = "viewBox"; - const char aSVGStrTransform[] = "transform"; - const char aSVGStrStyle[] = "style"; - const char aSVGStrDisplay[] = "display"; // #i121656# - const char aSVGStrD[] = "d"; - const char aSVGStrX[] = "x"; - const char aSVGStrY[] = "y"; - const char aSVGStrXmlns[] = "xmlns"; - const char aSVGStrVersion[] = "version"; - const char aSVGStrId[] = "id"; - const char aSVGStrIn[] = "in"; - const char aSVGStrRx[] = "rx"; - const char aSVGStrRy[] = "ry"; - const char aSVGStrPoints[] = "points"; - const char aSVGStrDx[] = "dx"; - const char aSVGStrDy[] = "dy"; - const char aSVGStrRotate[] = "rotate"; - const char aSVGStrTextLength[] = "textLength"; - const char aSVGStrLengthAdjust[] = "lengthAdjust"; - const char aSVGStrFont[] = "font"; - const char aSVGStrFontFamily[] = "font-family"; - const char aSVGStrFontSize[] = "font-size"; - const char aSVGStrFontSizeAdjust[] = "font-size-adjust"; - const char aSVGStrFontStretch[] = "font-stretch"; - const char aSVGStrFontStyle[] = "font-style"; - const char aSVGStrFontVariant[] = "font-variant"; - const char aSVGStrFontWeight[] = "font-weight"; - const char aSVGStrDirection[] = "direction"; - const char aSVGStrLetterSpacing[] = "letter-spacing"; - const char aSVGStrTextDecoration[] = "text-decoration"; - const char aSVGStrUnicodeBidi[] = "unicode-bidi"; - const char aSVGStrWordSpacing[] = "word-spacing"; - const char aSVGStrTspan[] = "tspan"; - const char aSVGStrTref[] = "tref"; - const char aSVGStrTextPath[] = "textPath"; - const char aSVGStrStartOffset[] = "startOffset"; - const char aSVGStrMethod[] = "method"; - const char aSVGStrSpacing[] = "spacing"; - const char aSVGStrStdDeviation[] = "stdDeviation"; - const char aSVGStrTextAlign[] = "text-align"; - const char aSVGStrPathLength[] = "pathLength"; - const char aSVGStrType[] = "type"; - const char aSVGStrClass[] = "class"; - const char aSVGStrTextAnchor[] = "text-anchor"; - const char aSVGStrXmlSpace[] = "xml:space"; - const char aSVGStrColor[] = "color"; - const char aSVGStrClipPathNode[] = "clipPath"; - const char aSVGStrClipPathProperty[] = "clip-path"; - const char aSVGStrFeGaussianBlur[] = "feGaussianBlur"; - const char aSVGStrFeColorMatrix[] = "feColorMatrix"; - const char aSVGStrFilter[] = "filter"; - const char aSVGStrMask[] = "mask"; - const char aSVGStrClipPathUnits[] = "clipPathUnits"; - const char aSVGStrMaskUnits[] = "maskUnits"; - const char aSVGStrMaskContentUnits[] = "maskContentUnits"; - const char aSVGStrClipRule[] = "clip-rule"; - const char aSVGStrMarker[] = "marker"; - const char aSVGStrMarkerStart[] = "marker-start"; - const char aSVGStrMarkerMid[] = "marker-mid"; - const char aSVGStrMarkerEnd[] = "marker-end"; - const char aSVGStrRefX[] = "refX"; - const char aSVGStrRefY[] = "refY"; - const char aSVGStrMarkerUnits[] = "markerUnits"; - const char aSVGStrMarkerWidth[] = "markerWidth"; - const char aSVGStrMarkerHeight[] = "markerHeight"; - const char aSVGStrOrient[] = "orient"; - const char aSVGStrPattern[] = "pattern"; - const char aSVGStrPatternUnits[] = "patternUnits"; - const char aSVGStrPatternContentUnits[] = "patternContentUnits"; - const char aSVGStrPatternTransform[] = "patternTransform"; - const char aSVGStrOpacity[] = "opacity"; - const char aSVGStrVisibility[] = "visibility"; - constexpr OUStringLiteral aSVGStrTitle = u"title"; - constexpr OUStringLiteral aSVGStrDesc = u"desc"; - const char aSVGStrPreserveAspectRatio[] = "preserveAspectRatio"; - const char aSVGStrDefer[] = "defer"; - const char aSVGStrNone[] = "none"; - const char aSVGStrXMinYMin[] = "xMinYMin"; - const char aSVGStrXMidYMin[] = "xMidYMin"; - const char aSVGStrXMaxYMin[] = "xMaxYMin"; - const char aSVGStrXMinYMid[] = "xMinYMid"; - const char aSVGStrXMidYMid[] = "xMidYMid"; - const char aSVGStrXMaxYMid[] = "xMaxYMid"; - const char aSVGStrXMinYMax[] = "xMinYMax"; - const char aSVGStrXMidYMax[] = "xMidYMax"; - const char aSVGStrXMaxYMax[] = "xMaxYMax"; - const char aSVGStrMeet[] = "meet"; - const char aSVGStrSlice[] = "slice"; +constexpr const std::u16string_view constToken_PathLength = u"pathLength"; +constexpr const std::u16string_view constTokenLowercase_PathLength = u"pathlength"; +constexpr const std::u16string_view constToken_Type = u"type"; +constexpr const std::u16string_view constToken_Class = u"class"; +constexpr const std::u16string_view constToken_TextAnchor = u"text-anchor"; +constexpr const std::u16string_view constToken_XmlSpace = u"xml:space"; +constexpr const std::u16string_view constToken_Color = u"color"; +constexpr const std::u16string_view constToken_ClipPathNode = u"clipPath"; +constexpr const std::u16string_view constTokenLowercase_ClipPathNode = u"clippath"; +constexpr const std::u16string_view constToken_ClipPathProperty = u"clip-path"; +constexpr const std::u16string_view constToken_Mask = u"mask"; +constexpr const std::u16string_view constToken_ClipPathUnits = u"clipPathUnits"; +constexpr const std::u16string_view constTokenLowercase_ClipPathUnits = u"clippathunits"; +constexpr const std::u16string_view constToken_MaskUnits = u"maskUnits"; +constexpr const std::u16string_view constTokenLowercase_MaskUnits = u"maskunits"; +constexpr const std::u16string_view constToken_MaskContentUnits = u"maskContentUnits"; +constexpr const std::u16string_view constTokenLowercase_MaskContentUnits = u"maskcontentunits"; +constexpr const std::u16string_view constToken_ClipRule = u"clip-rule"; +constexpr const std::u16string_view constToken_Marker = u"marker"; +constexpr const std::u16string_view constToken_MarkerStart = u"marker-start"; +constexpr const std::u16string_view constToken_MarkerMid = u"marker-mid"; +constexpr const std::u16string_view constToken_MarkerEnd = u"marker-end"; +constexpr const std::u16string_view constToken_RefX = u"refX"; +constexpr const std::u16string_view constToken_RefY = u"refY"; +constexpr const std::u16string_view constToken_MarkerUnits = u"markerUnits"; +constexpr const std::u16string_view constTokenLowercase_MarkerUnits = u"markerunits"; +constexpr const std::u16string_view constToken_MarkerWidth = u"markerWidth"; +constexpr const std::u16string_view constTokenLowercase_MarkerWidth = u"markerwidth"; +constexpr const std::u16string_view constToken_MarkerHeight = u"markerHeight"; +constexpr const std::u16string_view constTokenLowercase_MarkerHeight = u"markerheight"; +constexpr const std::u16string_view constToken_Orient = u"orient"; +constexpr const std::u16string_view constToken_Pattern = u"pattern"; +constexpr const std::u16string_view constToken_PatternUnits = u"patternUnits"; +constexpr const std::u16string_view constTokenLowercase_PatternUnits = u"patternunits"; +constexpr const std::u16string_view constToken_PatternContentUnits = u"patternContentUnits"; +constexpr const std::u16string_view constTokenLowercase_PatternContentUnits = u"patterncontentunits"; +constexpr const std::u16string_view constToken_PatternTransform = u"patternTransform"; +constexpr const std::u16string_view constTokenLowercase_PatternTransform = u"patterntransform"; +constexpr const std::u16string_view constToken_Opacity = u"opacity"; +constexpr const std::u16string_view constToken_Visibility = u"visibility"; +constexpr const std::u16string_view constToken_Title = u"title"; +constexpr const std::u16string_view constToken_Desc = u"desc"; - const char aSVGStrDefs[] = "defs"; - const char aSVGStrG[] = "g"; - const char aSVGStrSvg[] = "svg"; - const char aSVGStrSymbol[] = "symbol"; - const char aSVGStrUse[] = "use"; - const char aSVGStrA[] = "a"; +constexpr const std::u16string_view constToken_PreserveAspectRatio = u"preserveAspectRatio"; +constexpr const std::u16string_view constTokenLowercase_PreserveAspectRatio = u"preserveaspectratio"; +constexpr const std::u16string_view constToken_Defer = u"defer"; +constexpr const std::u16string_view constToken_None = u"none"; +constexpr const std::u16string_view constToken_XMinYMin = u"xMinYMin"; +constexpr const std::u16string_view constTokenLowercase_XMinYMin = u"xminymin"; +constexpr const std::u16string_view constToken_XMidYMin = u"xMidYMin"; +constexpr const std::u16string_view constTokenLowercase_XMidYMin = u"xmidymin"; +constexpr const std::u16string_view constToken_XMaxYMin = u"xMaxYMin"; +constexpr const std::u16string_view constTokenLowercase_XMaxYMin = u"xmaxymin"; +constexpr const std::u16string_view constToken_XMinYMid = u"xMinYMid"; +constexpr const std::u16string_view constTokenLowercase_XMinYMid = u"xminymid"; +constexpr const std::u16string_view constToken_XMidYMid = u"xMidYMid"; +constexpr const std::u16string_view constTokenLowercase_XMidYMid = u"xmidymid"; +constexpr const std::u16string_view constToken_XMaxYMid = u"xMaxYMid"; +constexpr const std::u16string_view constTokenLowercase_XMaxYMid = u"xmaxymid"; +constexpr const std::u16string_view constToken_XMinYMax = u"xMinYMax"; +constexpr const std::u16string_view constTokenLowercase_XMinYMax = u"xminymax"; +constexpr const std::u16string_view constToken_XMidYMax = u"xMidYMax"; +constexpr const std::u16string_view constTokenLowercase_XMidYMax = u"xmidymax"; +constexpr const std::u16string_view constToken_XMaxYMax = u"xMaxYMax"; +constexpr const std::u16string_view constTokenLowercase_XMaxYMax = u"xmaxymax"; +constexpr const std::u16string_view constToken_Meet = u"meet"; +constexpr const std::u16string_view constToken_Slice = u"slice"; - const char aSVGStrCircle[] = "circle"; - const char aSVGStrEllipse[] = "ellipse"; - const char aSVGStrLine[] = "line"; - const char aSVGStrPath[] = "path"; - const char aSVGStrPolygon[] = "polygon"; - const char aSVGStrPolyline[] = "polyline"; - const char aSVGStrRect[] = "rect"; - const char aSVGStrImage[] = "image"; +constexpr const std::u16string_view constToken_Defs = u"defs"; +constexpr const std::u16string_view constToken_G = u"g"; +constexpr const std::u16string_view constToken_Svg = u"svg"; +constexpr const std::u16string_view constToken_Symbol = u"symbol"; +constexpr const std::u16string_view constToken_Use = u"use"; +constexpr const std::u16string_view constToken_A = u"a"; - const char aSVGStrLinearGradient[] = "linearGradient"; - const char aSVGStrRadialGradient[] = "radialGradient"; - const char aSVGStrStop[] = "stop"; - const char aSVGStrOffset[] = "offset"; - const char aSVGStrX1[] = "x1"; - const char aSVGStrY1[] = "y1"; - const char aSVGStrX2[] = "x2"; - const char aSVGStrY2[] = "y2"; - const char aSVGStrCx[] = "cx"; - const char aSVGStrCy[] = "cy"; - const char aSVGStrFx[] = "fx"; - const char aSVGStrFy[] = "fy"; - const char aSVGStrR[] = "r"; - const char aSVGStrGradientUnits[] = "gradientUnits"; - const char aSVGStrGradientTransform[] = "gradientTransform"; - const char aSVGStrSpreadMethod[] = "spreadMethod"; - const char aSVGStrHref[] = "href"; - const char aSVGStrXlinkHref[] = "xlink:href"; - const char aSVGStrStopColor[] = "stop-color"; - const char aSVGStrStopOpacity[] = "stop-opacity"; +constexpr const std::u16string_view constToken_Circle = u"circle"; +constexpr const std::u16string_view constToken_Ellipse = u"ellipse"; +constexpr const std::u16string_view constToken_Line = u"line"; +constexpr const std::u16string_view constToken_Path = u"path"; +constexpr const std::u16string_view constToken_Polygon = u"polygon"; +constexpr const std::u16string_view constToken_Polyline = u"polyline"; +constexpr const std::u16string_view constToken_Rect = u"rect"; +constexpr const std::u16string_view constToken_Image = u"image"; - const char aSVGStrFill[] = "fill"; - const char aSVGStrFillOpacity[] = "fill-opacity"; - const char aSVGStrFillRule[] = "fill-rule"; +constexpr const std::u16string_view constToken_LinearGradient = u"linearGradient"; +constexpr const std::u16string_view constTokenLowercase_LinearGradient = u"lineargradient"; +constexpr const std::u16string_view constToken_RadialGradient = u"radialGradient"; +constexpr const std::u16string_view constTokenLowercase_RadialGradient = u"radialgradient"; +constexpr const std::u16string_view constToken_Stop = u"stop"; +constexpr const std::u16string_view constToken_Offset = u"offset"; +constexpr const std::u16string_view constToken_X1 = u"x1"; +constexpr const std::u16string_view constToken_Y1 = u"y1"; +constexpr const std::u16string_view constToken_X2 = u"x2"; +constexpr const std::u16string_view constToken_Y2 = u"y2"; +constexpr const std::u16string_view constToken_Cx = u"cx"; +constexpr const std::u16string_view constToken_Cy = u"cy"; +constexpr const std::u16string_view constToken_Fx = u"fx"; +constexpr const std::u16string_view constToken_Fy = u"fy"; +constexpr const std::u16string_view constToken_R = u"r"; +constexpr const std::u16string_view constToken_GradientUnits = u"gradientUnits"; +constexpr const std::u16string_view constTokenLowercase_GradientUnits = u"gradientunits"; +constexpr const std::u16string_view constToken_GradientTransform = u"gradientTransform"; +constexpr const std::u16string_view constTokenLowercase_GradientTransform = u"gradienttransform"; +constexpr const std::u16string_view constToken_SpreadMethod = u"spreadMethod"; +constexpr const std::u16string_view constTokenLowercase_SpreadMethod = u"spreadmethod"; +constexpr const std::u16string_view constToken_Href = u"href"; +constexpr const std::u16string_view constToken_XlinkHref = u"xlink:href"; +constexpr const std::u16string_view constToken_StopColor = u"stop-color"; +constexpr const std::u16string_view constToken_StopOpacity = u"stop-opacity"; - const char aSVGStrStroke[] = "stroke"; - const char aSVGStrStrokeDasharray[] = "stroke-dasharray"; - const char aSVGStrStrokeDashoffset[] = "stroke-dashoffset"; - const char aSVGStrStrokeLinecap[] = "stroke-linecap"; - const char aSVGStrStrokeLinejoin[] = "stroke-linejoin"; - const char aSVGStrStrokeMiterlimit[] = "stroke-miterlimit"; - const char aSVGStrStrokeOpacity[] = "stroke-opacity"; - const char aSVGStrStrokeWidth[] = "stroke-width"; +constexpr const std::u16string_view constToken_Fill = u"fill"; +constexpr const std::u16string_view constToken_FillOpacity = u"fill-opacity"; +constexpr const std::u16string_view constToken_FillRule = u"fill-rule"; - const char aSVGStrText[] = "text"; - const char aSVGStrBaselineShift[] = "baseline-shift"; +constexpr const std::u16string_view constToken_Stroke = u"stroke"; +constexpr const std::u16string_view constToken_StrokeDasharray = u"stroke-dasharray"; +constexpr const std::u16string_view constToken_StrokeDashoffset = u"stroke-dashoffset"; +constexpr const std::u16string_view constToken_StrokeLinecap = u"stroke-linecap"; +constexpr const std::u16string_view constToken_StrokeLinejoin = u"stroke-linejoin"; +constexpr const std::u16string_view constToken_StrokeMiterlimit = u"stroke-miterlimit"; +constexpr const std::u16string_view constToken_StrokeOpacity = u"stroke-opacity"; +constexpr const std::u16string_view constToken_StrokeWidth = u"stroke-width"; - const char aSVGStrFlowRoot[] = "flowRoot"; +constexpr const std::u16string_view constToken_Text = u"text"; +constexpr const std::u16string_view constToken_BaselineShift = u"baseline-shift"; + +constexpr const std::u16string_view constToken_FlowRoot = u"flowRoot"; +constexpr const std::u16string_view constTokenLowercase_FlowRoot = u"flowroot"; - SVGToken StrToSVGToken(const OUString& rStr, bool bCaseIndependent) - { - typedef std::unordered_map< OUString, SVGToken > SVGTokenMapper; - typedef std::pair< OUString, SVGToken > SVGTokenValueType; - static SVGTokenMapper aSVGTokenMapperList { - { aSVGStrWidth, SVGToken::Width }, - { aSVGStrHeight, SVGToken::Height }, - { aSVGStrViewBox, SVGToken::ViewBox }, - { aSVGStrTransform, SVGToken::Transform }, - { aSVGStrStyle, SVGToken::Style }, - { aSVGStrDisplay, SVGToken::Display }, // #i121656# - { aSVGStrD, SVGToken::D }, - { aSVGStrX, SVGToken::X }, - { aSVGStrY, SVGToken::Y }, - { aSVGStrXmlns, SVGToken::Xmlns }, - { aSVGStrVersion, SVGToken::Version }, - { aSVGStrId, SVGToken::Id }, - { aSVGStrIn, SVGToken::In }, - { aSVGStrRx, SVGToken::Rx }, - { aSVGStrRy, SVGToken::Ry }, - { aSVGStrPoints, SVGToken::Points }, - { aSVGStrDx, SVGToken::Dx }, - { aSVGStrDy, SVGToken::Dy }, - { aSVGStrRotate, SVGToken::Rotate }, - { aSVGStrTextLength, SVGToken::TextLength }, - { aSVGStrLengthAdjust, SVGToken::LengthAdjust }, - { aSVGStrFont, SVGToken::Font }, - { aSVGStrFontFamily, SVGToken::FontFamily }, - { aSVGStrFontSize, SVGToken::FontSize }, - { aSVGStrFontSizeAdjust, SVGToken::FontSizeAdjust }, - { aSVGStrFontStretch, SVGToken::FontStretch }, - { aSVGStrFontStyle, SVGToken::FontStyle }, - { aSVGStrFontVariant, SVGToken::FontVariant }, - { aSVGStrFontWeight, SVGToken::FontWeight }, - { aSVGStrDirection, SVGToken::Direction }, - { aSVGStrLetterSpacing, SVGToken::LetterSpacing }, - { aSVGStrTextDecoration, SVGToken::TextDecoration }, - { aSVGStrUnicodeBidi, SVGToken::UnicodeBidi }, - { aSVGStrWordSpacing, SVGToken::WordSpacing }, - { aSVGStrTspan, SVGToken::Tspan }, - { aSVGStrTref, SVGToken::Tref }, - { aSVGStrTextPath, SVGToken::TextPath }, - { aSVGStrStartOffset, SVGToken::StartOffset }, - { aSVGStrMethod, SVGToken::Method }, - { aSVGStrSpacing, SVGToken::Spacing }, - { aSVGStrStdDeviation, SVGToken::StdDeviation }, - { aSVGStrTextAlign, SVGToken::TextAlign }, - { aSVGStrPathLength, SVGToken::PathLength }, - { aSVGStrType, SVGToken::Type }, - { aSVGStrClass, SVGToken::Class }, - { aSVGStrTextAnchor, SVGToken::TextAnchor }, - { aSVGStrXmlSpace, SVGToken::XmlSpace }, - { aSVGStrColor, SVGToken::Color }, - { aSVGStrClipPathNode, SVGToken::ClipPathNode }, - { aSVGStrClipPathProperty, SVGToken::ClipPathProperty }, - { aSVGStrFeGaussianBlur, SVGToken::FeGaussianBlur }, - { aSVGStrFeColorMatrix, SVGToken::FeColorMatrix }, - { aSVGStrFilter, SVGToken::Filter }, - { aSVGStrMask, SVGToken::Mask }, - { aSVGStrClipPathUnits, SVGToken::ClipPathUnits }, - { aSVGStrMaskUnits, SVGToken::MaskUnits }, - { aSVGStrMaskContentUnits, SVGToken::MaskContentUnits }, - { aSVGStrClipRule, SVGToken::ClipRule }, - { aSVGStrMarker, SVGToken::Marker }, - { aSVGStrMarkerStart, SVGToken::MarkerStart }, - { aSVGStrMarkerMid, SVGToken::MarkerMid }, - { aSVGStrMarkerEnd, SVGToken::MarkerEnd }, - { aSVGStrRefX, SVGToken::RefX }, - { aSVGStrRefY, SVGToken::RefY }, - { aSVGStrMarkerUnits, SVGToken::MarkerUnits }, - { aSVGStrMarkerWidth, SVGToken::MarkerWidth }, - { aSVGStrMarkerHeight, SVGToken::MarkerHeight }, - { aSVGStrOrient, SVGToken::Orient }, - { aSVGStrPattern, SVGToken::Pattern }, - { aSVGStrPatternUnits, SVGToken::PatternUnits }, - { aSVGStrPatternContentUnits, SVGToken::PatternContentUnits }, - { aSVGStrPatternTransform, SVGToken::PatternTransform }, - { aSVGStrOpacity, SVGToken::Opacity }, - { aSVGStrVisibility, SVGToken::Visibility }, - { aSVGStrTitle, SVGToken::Title }, - { aSVGStrDesc, SVGToken::Desc }, - { aSVGStrPreserveAspectRatio, SVGToken::PreserveAspectRatio }, - { aSVGStrDefer, SVGToken::Defer }, - { aSVGStrNone, SVGToken::None }, - { aSVGStrXMinYMin, SVGToken::XMinYMin }, - { aSVGStrXMidYMin, SVGToken::XMidYMin }, - { aSVGStrXMaxYMin, SVGToken::XMaxYMin }, - { aSVGStrXMinYMid, SVGToken::XMinYMid }, - { aSVGStrXMidYMid, SVGToken::XMidYMid }, - { aSVGStrXMaxYMid, SVGToken::XMaxYMid }, - { aSVGStrXMinYMax, SVGToken::XMinYMax }, - { aSVGStrXMidYMax, SVGToken::XMidYMax }, - { aSVGStrXMaxYMax, SVGToken::XMaxYMax }, - { aSVGStrMeet, SVGToken::Meet }, - { aSVGStrSlice, SVGToken::Slice }, +static constexpr frozen::unordered_map<std::u16string_view, SVGToken, 138> aSVGTokenMapperList +{ + { u"width", SVGToken::Width }, + { u"height", SVGToken::Height }, + { u"viewBox", SVGToken::ViewBox }, + { u"transform", SVGToken::Transform }, + { u"style", SVGToken::Style }, + { u"display", SVGToken::Display }, // #i121656# + { u"d", SVGToken::D }, + { u"x", SVGToken::X }, + { u"y", SVGToken::Y }, + { u"xmlns", SVGToken::Xmlns }, + { u"version", SVGToken::Version }, + { u"id", SVGToken::Id }, + { u"in", SVGToken::In }, + { u"rx", SVGToken::Rx }, + { u"ry", SVGToken::Ry }, + { u"points", SVGToken::Points }, + { u"dx", SVGToken::Dx }, + { u"dy", SVGToken::Dy }, + { u"rotate", SVGToken::Rotate }, + { u"textLength", SVGToken::TextLength }, + { u"lengthAdjust", SVGToken::LengthAdjust }, + { u"font", SVGToken::Font }, + { u"font-family", SVGToken::FontFamily }, + { u"font-size", SVGToken::FontSize }, + { u"font-size-adjust", SVGToken::FontSizeAdjust }, + { u"font-stretch", SVGToken::FontStretch }, + { u"font-style", SVGToken::FontStyle }, + { u"font-variant", SVGToken::FontVariant }, + { u"font-weight", SVGToken::FontWeight }, + { u"direction", SVGToken::Direction }, + { u"letter-spacing", SVGToken::LetterSpacing }, + { u"text-decoration", SVGToken::TextDecoration }, + { u"unicode-bidi", SVGToken::UnicodeBidi }, + { u"word-spacing", SVGToken::WordSpacing }, + { u"tspan", SVGToken::Tspan }, + { u"tref", SVGToken::Tref }, + { u"textPath", SVGToken::TextPath }, + { u"startOffset", SVGToken::StartOffset }, + { u"method", SVGToken::Method }, + { u"spacing", SVGToken::Spacing }, + { u"stdDeviation", SVGToken::StdDeviation }, + { u"text-align", SVGToken::TextAlign }, + { constToken_PathLength, SVGToken::PathLength }, + { constToken_Type, SVGToken::Type }, + { constToken_Class, SVGToken::Class }, + { constToken_TextAnchor, SVGToken::TextAnchor }, + { constToken_XmlSpace, SVGToken::XmlSpace }, + { constToken_Color, SVGToken::Color }, + { constToken_ClipPathNode, SVGToken::ClipPathNode }, + { constToken_ClipPathProperty, SVGToken::ClipPathProperty }, + { u"feGaussianBlur", SVGToken::FeGaussianBlur }, + { u"feColorMatrix", SVGToken::FeColorMatrix }, + { u"filter", SVGToken::Filter }, + { constToken_Mask, SVGToken::Mask }, + { constToken_ClipPathUnits, SVGToken::ClipPathUnits }, + { constToken_MaskUnits, SVGToken::MaskUnits }, + { constToken_MaskContentUnits, SVGToken::MaskContentUnits }, + { constToken_ClipRule, SVGToken::ClipRule }, + { constToken_Marker, SVGToken::Marker }, + { constToken_MarkerStart, SVGToken::MarkerStart }, + { constToken_MarkerMid, SVGToken::MarkerMid }, + { constToken_MarkerEnd, SVGToken::MarkerEnd }, + { constToken_RefX, SVGToken::RefX }, + { constToken_RefY, SVGToken::RefY }, + { constToken_MarkerUnits, SVGToken::MarkerUnits }, + { constToken_MarkerWidth, SVGToken::MarkerWidth }, + { constToken_MarkerHeight, SVGToken::MarkerHeight }, + { constToken_Orient, SVGToken::Orient }, + { constToken_Pattern, SVGToken::Pattern }, + { constToken_PatternUnits, SVGToken::PatternUnits }, + { constToken_PatternContentUnits, SVGToken::PatternContentUnits }, + { constToken_PatternTransform, SVGToken::PatternTransform }, + { constToken_Opacity, SVGToken::Opacity }, + { constToken_Visibility, SVGToken::Visibility }, + { constToken_Title, SVGToken::Title }, + { constToken_Desc, SVGToken::Desc }, - { aSVGStrDefs, SVGToken::Defs }, - { aSVGStrG, SVGToken::G }, - { aSVGStrSvg, SVGToken::Svg }, - { aSVGStrSymbol, SVGToken::Symbol }, - { aSVGStrUse, SVGToken::Use }, - { aSVGStrA, SVGToken::A }, + { constToken_PreserveAspectRatio, SVGToken::PreserveAspectRatio }, + { constToken_Defer, SVGToken::Defer }, + { constToken_None, SVGToken::None }, + { constToken_XMinYMin, SVGToken::XMinYMin }, + { constToken_XMidYMin, SVGToken::XMidYMin }, + { constToken_XMaxYMin, SVGToken::XMaxYMin }, + { constToken_XMinYMid, SVGToken::XMinYMid }, + { constToken_XMidYMid, SVGToken::XMidYMid }, + { constToken_XMaxYMid, SVGToken::XMaxYMid }, + { constToken_XMinYMax, SVGToken::XMinYMax }, + { constToken_XMidYMax, SVGToken::XMidYMax }, + { constToken_XMaxYMax, SVGToken::XMaxYMax }, + { constToken_Meet, SVGToken::Meet }, + { constToken_Slice, SVGToken::Slice }, - { aSVGStrCircle, SVGToken::Circle }, - { aSVGStrEllipse, SVGToken::Ellipse }, - { aSVGStrLine, SVGToken::Line }, - { aSVGStrPath, SVGToken::Path }, - { aSVGStrPolygon, SVGToken::Polygon }, - { aSVGStrPolyline, SVGToken::Polyline }, - { aSVGStrRect, SVGToken::Rect }, - { aSVGStrImage, SVGToken::Image }, + { constToken_Defs, SVGToken::Defs }, + { constToken_G, SVGToken::G }, + { constToken_Svg, SVGToken::Svg }, + { constToken_Symbol, SVGToken::Symbol }, + { constToken_Use, SVGToken::Use }, + { constToken_A, SVGToken::A }, - { aSVGStrLinearGradient, SVGToken::LinearGradient }, - { aSVGStrRadialGradient, SVGToken::RadialGradient }, - { aSVGStrStop, SVGToken::Stop }, - { aSVGStrOffset, SVGToken::Offset }, - { aSVGStrX1, SVGToken::X1 }, - { aSVGStrY1, SVGToken::Y1 }, - { aSVGStrX2, SVGToken::X2 }, - { aSVGStrY2, SVGToken::Y2 }, - { aSVGStrCx, SVGToken::Cx }, - { aSVGStrCy, SVGToken::Cy }, - { aSVGStrFx, SVGToken::Fx }, - { aSVGStrFy, SVGToken::Fy }, - { aSVGStrR, SVGToken::R }, - { aSVGStrGradientUnits, SVGToken::GradientUnits }, - { aSVGStrGradientTransform, SVGToken::GradientTransform }, - { aSVGStrSpreadMethod, SVGToken::SpreadMethod }, - { aSVGStrHref, SVGToken::Href }, - { aSVGStrXlinkHref, SVGToken::XlinkHref }, - { aSVGStrStopColor, SVGToken::StopColor }, - { aSVGStrStopOpacity, SVGToken::StopOpacity }, + { constToken_Circle, SVGToken::Circle }, + { constToken_Ellipse, SVGToken::Ellipse }, + { constToken_Line, SVGToken::Line }, + { constToken_Path, SVGToken::Path }, + { constToken_Polygon, SVGToken::Polygon }, + { constToken_Polyline, SVGToken::Polyline }, + { constToken_Rect, SVGToken::Rect }, + { constToken_Image, SVGToken::Image }, - { aSVGStrFill, SVGToken::Fill }, - { aSVGStrFillOpacity, SVGToken::FillOpacity }, - { aSVGStrFillRule, SVGToken::FillRule }, + { constToken_LinearGradient, SVGToken::LinearGradient }, + { constToken_RadialGradient, SVGToken::RadialGradient }, + { constToken_Stop, SVGToken::Stop }, + { constToken_Offset, SVGToken::Offset }, + { constToken_X1, SVGToken::X1 }, + { constToken_Y1, SVGToken::Y1 }, + { constToken_X2, SVGToken::X2 }, + { constToken_Y2, SVGToken::Y2 }, + { constToken_Cx, SVGToken::Cx }, + { constToken_Cy, SVGToken::Cy }, + { constToken_Fx, SVGToken::Fx }, + { constToken_Fy, SVGToken::Fy }, + { constToken_R, SVGToken::R }, + { constToken_GradientUnits, SVGToken::GradientUnits }, + { constToken_GradientTransform, SVGToken::GradientTransform }, + { constToken_SpreadMethod, SVGToken::SpreadMethod }, + { constToken_Href, SVGToken::Href }, + { constToken_XlinkHref, SVGToken::XlinkHref }, + { constToken_StopColor, SVGToken::StopColor }, + { constToken_StopOpacity, SVGToken::StopOpacity }, - { aSVGStrStroke, SVGToken::Stroke }, - { aSVGStrStrokeDasharray, SVGToken::StrokeDasharray }, - { aSVGStrStrokeDashoffset, SVGToken::StrokeDashoffset }, - { aSVGStrStrokeLinecap, SVGToken::StrokeLinecap }, - { aSVGStrStrokeLinejoin, SVGToken::StrokeLinejoin }, - { aSVGStrStrokeMiterlimit, SVGToken::StrokeMiterlimit }, - { aSVGStrStrokeOpacity, SVGToken::StrokeOpacity }, - { aSVGStrStrokeWidth, SVGToken::StrokeWidth }, + { constToken_Fill, SVGToken::Fill }, + { constToken_FillOpacity, SVGToken::FillOpacity }, + { constToken_FillRule, SVGToken::FillRule }, - { aSVGStrText, SVGToken::Text }, - { aSVGStrBaselineShift, SVGToken::BaselineShift }, - { aSVGStrFlowRoot, SVGToken::FlowRoot } - }; + { constToken_Stroke, SVGToken::Stroke }, + { constToken_StrokeDasharray, SVGToken::StrokeDasharray }, + { constToken_StrokeDashoffset, SVGToken::StrokeDashoffset }, + { constToken_StrokeLinecap, SVGToken::StrokeLinecap }, + { constToken_StrokeLinejoin, SVGToken::StrokeLinejoin }, + { constToken_StrokeMiterlimit, SVGToken::StrokeMiterlimit }, + { constToken_StrokeOpacity, SVGToken::StrokeOpacity }, + { constToken_StrokeWidth, SVGToken::StrokeWidth }, - const SVGTokenMapper::const_iterator aResult(aSVGTokenMapperList.find(rStr.startsWith("svg:") ? rStr.copy(4) : rStr)); + { constToken_Text, SVGToken::Text }, + { constToken_BaselineShift, SVGToken::BaselineShift }, + { constToken_FlowRoot, SVGToken::FlowRoot } +}; - if(aResult == aSVGTokenMapperList.end()) - { - if(bCaseIndependent) - { - static SVGTokenMapper aCaseLindependentSVGTokenMapperList; +static constexpr frozen::unordered_map<std::u16string_view, SVGToken, 32> aLowerCaseList +{ + { u"viewbox", SVGToken::ViewBox }, + { u"textlength", SVGToken::TextLength }, + { u"lengthadjust", SVGToken::LengthAdjust }, + { u"textpath", SVGToken::TextPath }, + { u"startoffset", SVGToken::StartOffset }, + { constTokenLowercase_PathLength, SVGToken::PathLength }, + { constTokenLowercase_ClipPathNode, SVGToken::ClipPathNode }, + { constTokenLowercase_ClipPathUnits, SVGToken::ClipPathUnits }, + { constTokenLowercase_MaskUnits, SVGToken::MaskUnits }, + { constTokenLowercase_MaskContentUnits, SVGToken::MaskContentUnits }, + { constTokenLowercase_MarkerUnits, SVGToken::MarkerUnits }, + { constTokenLowercase_MarkerWidth, SVGToken::MarkerWidth }, + { constTokenLowercase_MarkerHeight, SVGToken::MarkerHeight }, + { constTokenLowercase_PatternUnits, SVGToken::PatternUnits }, + { constTokenLowercase_PatternContentUnits, SVGToken::PatternContentUnits }, + { constTokenLowercase_PatternTransform, SVGToken::PatternTransform }, + { constTokenLowercase_PreserveAspectRatio, SVGToken::PreserveAspectRatio }, + { constTokenLowercase_XMinYMin, SVGToken::XMinYMin }, + { constTokenLowercase_XMidYMin, SVGToken::XMidYMin }, + { constTokenLowercase_XMaxYMin, SVGToken::XMaxYMin }, + { constTokenLowercase_XMinYMid, SVGToken::XMinYMid }, + { constTokenLowercase_XMidYMid, SVGToken::XMidYMid }, + { constTokenLowercase_XMaxYMid, SVGToken::XMaxYMid }, + { constTokenLowercase_XMinYMax, SVGToken::XMinYMax }, + { constTokenLowercase_XMidYMax, SVGToken::XMidYMax }, + { constTokenLowercase_XMaxYMax, SVGToken::XMaxYMax }, + { constTokenLowercase_LinearGradient, SVGToken::LinearGradient }, + { constTokenLowercase_RadialGradient, SVGToken::RadialGradient }, + { constTokenLowercase_GradientUnits, SVGToken::GradientUnits }, + { constTokenLowercase_GradientTransform, SVGToken::GradientTransform }, + { constTokenLowercase_SpreadMethod, SVGToken::SpreadMethod }, + { constTokenLowercase_FlowRoot, SVGToken::FlowRoot } +}; - if(aCaseLindependentSVGTokenMapperList.empty()) - { - for(const auto& rCurrent : aSVGTokenMapperList) - { - aCaseLindependentSVGTokenMapperList.insert( - SVGTokenValueType( - rCurrent.first.toAsciiLowerCase(), - rCurrent.second)); - } - } +SVGToken StrToSVGToken(const OUString& rStr, bool bCaseIndependent) +{ + OUString aSearchString = rStr.startsWith("svg:") ? rStr.copy(4) : rStr; - const SVGTokenMapper::const_iterator aResult2(aCaseLindependentSVGTokenMapperList.find(rStr.toAsciiLowerCase())); + auto const aResult = aSVGTokenMapperList.find(aSearchString); - if(aResult2 == aCaseLindependentSVGTokenMapperList.end()) - { - return SVGToken::Unknown; - } - else - { - return aResult2->second; - } - } + if (aResult == aSVGTokenMapperList.end()) + { + if (bCaseIndependent) + { + auto const aResultLowerCase(aLowerCaseList.find(rStr.toAsciiLowerCase())); + if (aResultLowerCase == aLowerCaseList.end()) + { return SVGToken::Unknown; } else { - return aResult->second; + return aResultLowerCase->second; } } - OUString getStrTitle() - { - return aSVGStrTitle; - } + return SVGToken::Unknown; + } + else + { + return aResult->second; + } +} + +OUString getStrTitle() +{ + return OUString(constToken_Title); +} + +OUString getStrDesc() +{ + return OUString(constToken_Desc); +} - OUString getStrDesc() - { - return aSVGStrDesc; - } } // end of namespace svgio /* vim:set shiftwidth=4 softtabstop=4 expandtab: */