diff --git a/filter/Library_msfilter.mk b/filter/Library_msfilter.mk index 0429a6e31874..fcc343520602 100644 --- a/filter/Library_msfilter.mk +++ b/filter/Library_msfilter.mk @@ -21,7 +21,10 @@ $(eval $(call gb_Library_Library,msfilter)) $(eval $(call gb_Library_set_componentfile,msfilter,filter/source/msfilter/msfilter,services)) -$(eval $(call gb_Library_use_external,msfilter,boost_headers)) +$(eval $(call gb_Library_use_externals,msfilter,\ + boost_headers \ + frozen \ +)) $(eval $(call gb_Library_use_sdk_api,msfilter)) diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx index 923aecb9c3dd..d3fc42af8c2d 100644 --- a/filter/source/msfilter/msvbahelper.cxx +++ b/filter/source/msfilter/msvbahelper.cxx @@ -42,7 +42,9 @@ #include #include #include -#include +#include +#include +#include using namespace ::com::sun::star; @@ -643,64 +645,51 @@ static sal_uInt16 parseChar( sal_Unicode c ) return nVclKey; } -namespace { - -struct KeyCodeEntry +namespace { - const char* sName; - sal_uInt16 nCode; + +constexpr frozen::unordered_map s_KeyCodes +{ + { u"BACKSPACE", KEY_BACKSPACE }, + { u"BS", KEY_BACKSPACE }, + { u"DELETE", KEY_DELETE }, + { u"DEL", KEY_DELETE }, + { u"DOWN", KEY_DOWN }, + { u"UP", KEY_UP }, + { u"LEFT", KEY_LEFT }, + { u"RIGHT", KEY_RIGHT }, + { u"END", KEY_END }, + { u"ESCAPE", KEY_ESCAPE }, + { u"ESC", KEY_ESCAPE }, + { u"HELP", KEY_HELP }, + { u"HOME", KEY_HOME }, + { u"PGDN", KEY_PAGEDOWN }, + { u"PGUP", KEY_PAGEUP }, + { u"INSERT", KEY_INSERT }, + { u"SCROLLLOCK", KEY_SCROLLLOCK }, + { u"NUMLOCK", KEY_NUMLOCK }, + { u"TAB", KEY_TAB }, + { u"F1", KEY_F1 }, + { u"F2", KEY_F2 }, + { u"F3", KEY_F3 }, + { u"F4", KEY_F4 }, + { u"F5", KEY_F5 }, + { u"F6", KEY_F6 }, + { u"F7", KEY_F7 }, + { u"F8", KEY_F8 }, + { u"F9", KEY_F9 }, + { u"F10", KEY_F10 }, + { u"F11", KEY_F11 }, + { u"F12", KEY_F12 }, + { u"F13", KEY_F13 }, + { u"F14", KEY_F14 }, + { u"F15", KEY_F15 } }; -} - -KeyCodeEntry const aMSKeyCodesData[] = { - { "BACKSPACE", KEY_BACKSPACE }, - { "BS", KEY_BACKSPACE }, - { "DELETE", KEY_DELETE }, - { "DEL", KEY_DELETE }, - { "DOWN", KEY_DOWN }, - { "UP", KEY_UP }, - { "LEFT", KEY_LEFT }, - { "RIGHT", KEY_RIGHT }, - { "END", KEY_END }, - { "ESCAPE", KEY_ESCAPE }, - { "ESC", KEY_ESCAPE }, - { "HELP", KEY_HELP }, - { "HOME", KEY_HOME }, - { "PGDN", KEY_PAGEDOWN }, - { "PGUP", KEY_PAGEUP }, - { "INSERT", KEY_INSERT }, - { "SCROLLLOCK", KEY_SCROLLLOCK }, - { "NUMLOCK", KEY_NUMLOCK }, - { "TAB", KEY_TAB }, - { "F1", KEY_F1 }, - { "F2", KEY_F2 }, - { "F3", KEY_F3 }, - { "F4", KEY_F4 }, - { "F5", KEY_F5 }, - { "F6", KEY_F6 }, - { "F7", KEY_F7 }, - { "F8", KEY_F8 }, - { "F9", KEY_F9 }, - { "F10", KEY_F10 }, - { "F11", KEY_F11 }, - { "F12", KEY_F12 }, - { "F13", KEY_F13 }, - { "F14", KEY_F14 }, - { "F15", KEY_F15 }, -}; +} // end anonymous namespace awt::KeyEvent parseKeyEvent( std::u16string_view Key ) { - static std::map< OUString, sal_uInt16 > s_KeyCodes = []() - { - std::map< OUString, sal_uInt16 > tmp; - for (KeyCodeEntry const & i : aMSKeyCodesData) - { - tmp[ OUString::createFromAscii( i.sName ) ] = i.nCode; - } - return tmp; - }(); std::u16string_view sKeyCode; sal_uInt16 nVclKey = 0; @@ -731,7 +720,7 @@ awt::KeyEvent parseKeyEvent( std::u16string_view Key ) nVclKey |= parseChar( sKeyCode[ 0 ] ); else { - auto it = s_KeyCodes.find( OUString(sKeyCode) ); + auto it = s_KeyCodes.find(sKeyCode); if ( it == s_KeyCodes.end() ) // unknown or unsupported throw uno::RuntimeException(); nVclKey |= it->second; diff --git a/include/oox/drawingml/clrscheme.hxx b/include/oox/drawingml/clrscheme.hxx index 33ff971c7d81..bddd58e0503b 100644 --- a/include/oox/drawingml/clrscheme.hxx +++ b/include/oox/drawingml/clrscheme.hxx @@ -25,7 +25,6 @@ #include #include #include - #include #include #include @@ -50,21 +49,7 @@ enum PredefinedClrSchemeId { Count }; -static std::map PredefinedClrNames = -{ - { dk1, "dk1" }, - { lt1, "lt1" }, - { dk2, "dk2" }, - { lt2, "lt2" }, - { accent1, "accent1" }, - { accent2, "accent2" }, - { accent3, "accent3" }, - { accent4, "accent4" }, - { accent5, "accent5" }, - { accent6, "accent6" }, - { hlink, "hlink" }, - { folHlink, "folHlink" } -}; +OOX_DLLPUBLIC std::u16string_view getPredefinedClrNames(PredefinedClrSchemeId eID); class ClrMap { 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/clrscheme.cxx b/oox/source/drawingml/clrscheme.cxx index 105ba4c35c5d..7a0b12fe3f0c 100644 --- a/oox/source/drawingml/clrscheme.cxx +++ b/oox/source/drawingml/clrscheme.cxx @@ -27,10 +27,44 @@ #include #include +#include +#include +#include + using namespace com::sun::star; namespace oox::drawingml { +namespace +{ + +constexpr frozen::unordered_map constPredefinedClrNames +{ + { dk1, u"dk1" }, + { lt1, u"lt1" }, + { dk2, u"dk2" }, + { lt2, u"lt2" }, + { accent1, u"accent1" }, + { accent2, u"accent2" }, + { accent3, u"accent3" }, + { accent4, u"accent4" }, + { accent5, u"accent5" }, + { accent6, u"accent6" }, + { hlink, u"hlink" }, + { folHlink, u"folHlink" } +}; + +} // end anonymous namespace + +std::u16string_view getPredefinedClrNames(PredefinedClrSchemeId eID) +{ + std::u16string_view empty; + auto iterator = constPredefinedClrNames.find(eID); + if (iterator == constPredefinedClrNames.end()) + return empty; + return iterator->second; +} + bool ClrMap::getColorMap( sal_Int32& nClrToken ) { sal_Int32 nMapped = 0; diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index ad0b5ca7835e..91543b3ef123 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -19,7 +19,9 @@ #include #include -#include +#include +#include +#include #include #include #include @@ -31,138 +33,131 @@ namespace oox::drawingml { -namespace { - -/** Global storage for predefined color values used in OOXML file formats. */ -struct PresetColorsPool +namespace { - typedef ::std::vector< ::Color > ColorVector; - ColorVector maDmlColors; /// Predefined colors in DrawingML, indexed by XML token. - ColorVector maVmlColors; /// Predefined colors in VML, indexed by XML token. - ColorVector maHighlightColors; /// Predefined colors in DrawingML for highlight, indexed by XML token. - - explicit PresetColorsPool(); +// predefined colors in DrawingML (map XML token identifiers to RGB values) +constexpr frozen::unordered_map constDmlColors +{ + {XML_aliceBlue, ::Color(0xF0F8FF)}, {XML_antiqueWhite, ::Color(0xFAEBD7)}, + {XML_aqua, ::Color(0x00FFFF)}, {XML_aquamarine, ::Color(0x7FFFD4)}, + {XML_azure, ::Color(0xF0FFFF)}, {XML_beige, ::Color(0xF5F5DC)}, + {XML_bisque, ::Color(0xFFE4C4)}, {XML_black, ::Color(0x000000)}, + {XML_blanchedAlmond, ::Color(0xFFEBCD)}, {XML_blue, ::Color(0x0000FF)}, + {XML_blueViolet, ::Color(0x8A2BE2)}, {XML_brown, ::Color(0xA52A2A)}, + {XML_burlyWood, ::Color(0xDEB887)}, {XML_cadetBlue, ::Color(0x5F9EA0)}, + {XML_chartreuse, ::Color(0x7FFF00)}, {XML_chocolate, ::Color(0xD2691E)}, + {XML_coral, ::Color(0xFF7F50)}, {XML_cornflowerBlue, ::Color(0x6495ED)}, + {XML_cornsilk, ::Color(0xFFF8DC)}, {XML_crimson, ::Color(0xDC143C)}, + {XML_cyan, ::Color(0x00FFFF)}, {XML_deepPink, ::Color(0xFF1493)}, + {XML_deepSkyBlue, ::Color(0x00BFFF)}, {XML_dimGray, ::Color(0x696969)}, + {XML_dkBlue, ::Color(0x00008B)}, {XML_dkCyan, ::Color(0x008B8B)}, + {XML_dkGoldenrod, ::Color(0xB8860B)}, {XML_dkGray, ::Color(0xA9A9A9)}, + {XML_dkGreen, ::Color(0x006400)}, {XML_dkKhaki, ::Color(0xBDB76B)}, + {XML_dkMagenta, ::Color(0x8B008B)}, {XML_dkOliveGreen, ::Color(0x556B2F)}, + {XML_dkOrange, ::Color(0xFF8C00)}, {XML_dkOrchid, ::Color(0x9932CC)}, + {XML_dkRed, ::Color(0x8B0000)}, {XML_dkSalmon, ::Color(0xE9967A)}, + {XML_dkSeaGreen, ::Color(0x8FBC8B)}, {XML_dkSlateBlue, ::Color(0x483D8B)}, + {XML_dkSlateGray, ::Color(0x2F4F4F)}, {XML_dkTurquoise, ::Color(0x00CED1)}, + {XML_dkViolet, ::Color(0x9400D3)}, {XML_dodgerBlue, ::Color(0x1E90FF)}, + {XML_firebrick, ::Color(0xB22222)}, {XML_floralWhite, ::Color(0xFFFAF0)}, + {XML_forestGreen, ::Color(0x228B22)}, {XML_fuchsia, ::Color(0xFF00FF)}, + {XML_gainsboro, ::Color(0xDCDCDC)}, {XML_ghostWhite, ::Color(0xF8F8FF)}, + {XML_gold, ::Color(0xFFD700)}, {XML_goldenrod, ::Color(0xDAA520)}, + {XML_gray, ::Color(0x808080)}, {XML_green, ::Color(0x008000)}, + {XML_greenYellow, ::Color(0xADFF2F)}, {XML_honeydew, ::Color(0xF0FFF0)}, + {XML_hotPink, ::Color(0xFF69B4)}, {XML_indianRed, ::Color(0xCD5C5C)}, + {XML_indigo, ::Color(0x4B0082)}, {XML_ivory, ::Color(0xFFFFF0)}, + {XML_khaki, ::Color(0xF0E68C)}, {XML_lavender, ::Color(0xE6E6FA)}, + {XML_lavenderBlush, ::Color(0xFFF0F5)}, {XML_lawnGreen, ::Color(0x7CFC00)}, + {XML_lemonChiffon, ::Color(0xFFFACD)}, {XML_lime, ::Color(0x00FF00)}, + {XML_limeGreen, ::Color(0x32CD32)}, {XML_linen, ::Color(0xFAF0E6)}, + {XML_ltBlue, ::Color(0xADD8E6)}, {XML_ltCoral, ::Color(0xF08080)}, + {XML_ltCyan, ::Color(0xE0FFFF)}, {XML_ltGoldenrodYellow, ::Color(0xFAFA78)}, + {XML_ltGray, ::Color(0xD3D3D3)}, {XML_ltGreen, ::Color(0x90EE90)}, + {XML_ltPink, ::Color(0xFFB6C1)}, {XML_ltSalmon, ::Color(0xFFA07A)}, + {XML_ltSeaGreen, ::Color(0x20B2AA)}, {XML_ltSkyBlue, ::Color(0x87CEFA)}, + {XML_ltSlateGray, ::Color(0x778899)}, {XML_ltSteelBlue, ::Color(0xB0C4DE)}, + {XML_ltYellow, ::Color(0xFFFFE0)}, {XML_magenta, ::Color(0xFF00FF)}, + {XML_maroon, ::Color(0x800000)}, {XML_medAquamarine, ::Color(0x66CDAA)}, + {XML_medBlue, ::Color(0x0000CD)}, {XML_medOrchid, ::Color(0xBA55D3)}, + {XML_medPurple, ::Color(0x9370DB)}, {XML_medSeaGreen, ::Color(0x3CB371)}, + {XML_medSlateBlue, ::Color(0x7B68EE)}, {XML_medSpringGreen, ::Color(0x00FA9A)}, + {XML_medTurquoise, ::Color(0x48D1CC)}, {XML_medVioletRed, ::Color(0xC71585)}, + {XML_midnightBlue, ::Color(0x191970)}, {XML_mintCream, ::Color(0xF5FFFA)}, + {XML_mistyRose, ::Color(0xFFE4E1)}, {XML_moccasin, ::Color(0xFFE4B5)}, + {XML_navajoWhite, ::Color(0xFFDEAD)}, {XML_navy, ::Color(0x000080)}, + {XML_oldLace, ::Color(0xFDF5E6)}, {XML_olive, ::Color(0x808000)}, + {XML_oliveDrab, ::Color(0x6B8E23)}, {XML_orange, ::Color(0xFFA500)}, + {XML_orangeRed, ::Color(0xFF4500)}, {XML_orchid, ::Color(0xDA70D6)}, + {XML_paleGoldenrod, ::Color(0xEEE8AA)}, {XML_paleGreen, ::Color(0x98FB98)}, + {XML_paleTurquoise, ::Color(0xAFEEEE)}, {XML_paleVioletRed, ::Color(0xDB7093)}, + {XML_papayaWhip, ::Color(0xFFEFD5)}, {XML_peachPuff, ::Color(0xFFDAB9)}, + {XML_peru, ::Color(0xCD853F)}, {XML_pink, ::Color(0xFFC0CB)}, + {XML_plum, ::Color(0xDDA0DD)}, {XML_powderBlue, ::Color(0xB0E0E6)}, + {XML_purple, ::Color(0x800080)}, {XML_red, ::Color(0xFF0000)}, + {XML_rosyBrown, ::Color(0xBC8F8F)}, {XML_royalBlue, ::Color(0x4169E1)}, + {XML_saddleBrown, ::Color(0x8B4513)}, {XML_salmon, ::Color(0xFA8072)}, + {XML_sandyBrown, ::Color(0xF4A460)}, {XML_seaGreen, ::Color(0x2E8B57)}, + {XML_seaShell, ::Color(0xFFF5EE)}, {XML_sienna, ::Color(0xA0522D)}, + {XML_silver, ::Color(0xC0C0C0)}, {XML_skyBlue, ::Color(0x87CEEB)}, + {XML_slateBlue, ::Color(0x6A5ACD)}, {XML_slateGray, ::Color(0x708090)}, + {XML_snow, ::Color(0xFFFAFA)}, {XML_springGreen, ::Color(0x00FF7F)}, + {XML_steelBlue, ::Color(0x4682B4)}, {XML_tan, ::Color(0xD2B48C)}, + {XML_teal, ::Color(0x008080)}, {XML_thistle, ::Color(0xD8BFD8)}, + {XML_tomato, ::Color(0xFF6347)}, {XML_turquoise, ::Color(0x40E0D0)}, + {XML_violet, ::Color(0xEE82EE)}, {XML_wheat, ::Color(0xF5DEB3)}, + {XML_white, ::Color(0xFFFFFF)}, {XML_whiteSmoke, ::Color(0xF5F5F5)}, + {XML_yellow, ::Color(0xFFFF00)}, {XML_yellowGreen, ::Color(0x9ACD32)} }; -PresetColorsPool::PresetColorsPool() : - maDmlColors( static_cast< size_t >( XML_TOKEN_COUNT ), API_RGB_TRANSPARENT ), - maVmlColors( static_cast< size_t >( XML_TOKEN_COUNT ), API_RGB_TRANSPARENT ), - maHighlightColors( static_cast(XML_TOKEN_COUNT), API_RGB_TRANSPARENT ) +constexpr ::Color lookupDmlColor(sal_Int32 nToken) { - // predefined colors in DrawingML (map XML token identifiers to RGB values) - static const std::pair spnDmlColors[] = - { - {XML_aliceBlue, ::Color(0xF0F8FF)}, {XML_antiqueWhite, ::Color(0xFAEBD7)}, - {XML_aqua, ::Color(0x00FFFF)}, {XML_aquamarine, ::Color(0x7FFFD4)}, - {XML_azure, ::Color(0xF0FFFF)}, {XML_beige, ::Color(0xF5F5DC)}, - {XML_bisque, ::Color(0xFFE4C4)}, {XML_black, ::Color(0x000000)}, - {XML_blanchedAlmond, ::Color(0xFFEBCD)}, {XML_blue, ::Color(0x0000FF)}, - {XML_blueViolet, ::Color(0x8A2BE2)}, {XML_brown, ::Color(0xA52A2A)}, - {XML_burlyWood, ::Color(0xDEB887)}, {XML_cadetBlue, ::Color(0x5F9EA0)}, - {XML_chartreuse, ::Color(0x7FFF00)}, {XML_chocolate, ::Color(0xD2691E)}, - {XML_coral, ::Color(0xFF7F50)}, {XML_cornflowerBlue, ::Color(0x6495ED)}, - {XML_cornsilk, ::Color(0xFFF8DC)}, {XML_crimson, ::Color(0xDC143C)}, - {XML_cyan, ::Color(0x00FFFF)}, {XML_deepPink, ::Color(0xFF1493)}, - {XML_deepSkyBlue, ::Color(0x00BFFF)}, {XML_dimGray, ::Color(0x696969)}, - {XML_dkBlue, ::Color(0x00008B)}, {XML_dkCyan, ::Color(0x008B8B)}, - {XML_dkGoldenrod, ::Color(0xB8860B)}, {XML_dkGray, ::Color(0xA9A9A9)}, - {XML_dkGreen, ::Color(0x006400)}, {XML_dkKhaki, ::Color(0xBDB76B)}, - {XML_dkMagenta, ::Color(0x8B008B)}, {XML_dkOliveGreen, ::Color(0x556B2F)}, - {XML_dkOrange, ::Color(0xFF8C00)}, {XML_dkOrchid, ::Color(0x9932CC)}, - {XML_dkRed, ::Color(0x8B0000)}, {XML_dkSalmon, ::Color(0xE9967A)}, - {XML_dkSeaGreen, ::Color(0x8FBC8B)}, {XML_dkSlateBlue, ::Color(0x483D8B)}, - {XML_dkSlateGray, ::Color(0x2F4F4F)}, {XML_dkTurquoise, ::Color(0x00CED1)}, - {XML_dkViolet, ::Color(0x9400D3)}, {XML_dodgerBlue, ::Color(0x1E90FF)}, - {XML_firebrick, ::Color(0xB22222)}, {XML_floralWhite, ::Color(0xFFFAF0)}, - {XML_forestGreen, ::Color(0x228B22)}, {XML_fuchsia, ::Color(0xFF00FF)}, - {XML_gainsboro, ::Color(0xDCDCDC)}, {XML_ghostWhite, ::Color(0xF8F8FF)}, - {XML_gold, ::Color(0xFFD700)}, {XML_goldenrod, ::Color(0xDAA520)}, - {XML_gray, ::Color(0x808080)}, {XML_green, ::Color(0x008000)}, - {XML_greenYellow, ::Color(0xADFF2F)}, {XML_honeydew, ::Color(0xF0FFF0)}, - {XML_hotPink, ::Color(0xFF69B4)}, {XML_indianRed, ::Color(0xCD5C5C)}, - {XML_indigo, ::Color(0x4B0082)}, {XML_ivory, ::Color(0xFFFFF0)}, - {XML_khaki, ::Color(0xF0E68C)}, {XML_lavender, ::Color(0xE6E6FA)}, - {XML_lavenderBlush, ::Color(0xFFF0F5)}, {XML_lawnGreen, ::Color(0x7CFC00)}, - {XML_lemonChiffon, ::Color(0xFFFACD)}, {XML_lime, ::Color(0x00FF00)}, - {XML_limeGreen, ::Color(0x32CD32)}, {XML_linen, ::Color(0xFAF0E6)}, - {XML_ltBlue, ::Color(0xADD8E6)}, {XML_ltCoral, ::Color(0xF08080)}, - {XML_ltCyan, ::Color(0xE0FFFF)}, {XML_ltGoldenrodYellow, ::Color(0xFAFA78)}, - {XML_ltGray, ::Color(0xD3D3D3)}, {XML_ltGreen, ::Color(0x90EE90)}, - {XML_ltPink, ::Color(0xFFB6C1)}, {XML_ltSalmon, ::Color(0xFFA07A)}, - {XML_ltSeaGreen, ::Color(0x20B2AA)}, {XML_ltSkyBlue, ::Color(0x87CEFA)}, - {XML_ltSlateGray, ::Color(0x778899)}, {XML_ltSteelBlue, ::Color(0xB0C4DE)}, - {XML_ltYellow, ::Color(0xFFFFE0)}, {XML_magenta, ::Color(0xFF00FF)}, - {XML_maroon, ::Color(0x800000)}, {XML_medAquamarine, ::Color(0x66CDAA)}, - {XML_medBlue, ::Color(0x0000CD)}, {XML_medOrchid, ::Color(0xBA55D3)}, - {XML_medPurple, ::Color(0x9370DB)}, {XML_medSeaGreen, ::Color(0x3CB371)}, - {XML_medSlateBlue, ::Color(0x7B68EE)}, {XML_medSpringGreen, ::Color(0x00FA9A)}, - {XML_medTurquoise, ::Color(0x48D1CC)}, {XML_medVioletRed, ::Color(0xC71585)}, - {XML_midnightBlue, ::Color(0x191970)}, {XML_mintCream, ::Color(0xF5FFFA)}, - {XML_mistyRose, ::Color(0xFFE4E1)}, {XML_moccasin, ::Color(0xFFE4B5)}, - {XML_navajoWhite, ::Color(0xFFDEAD)}, {XML_navy, ::Color(0x000080)}, - {XML_oldLace, ::Color(0xFDF5E6)}, {XML_olive, ::Color(0x808000)}, - {XML_oliveDrab, ::Color(0x6B8E23)}, {XML_orange, ::Color(0xFFA500)}, - {XML_orangeRed, ::Color(0xFF4500)}, {XML_orchid, ::Color(0xDA70D6)}, - {XML_paleGoldenrod, ::Color(0xEEE8AA)}, {XML_paleGreen, ::Color(0x98FB98)}, - {XML_paleTurquoise, ::Color(0xAFEEEE)}, {XML_paleVioletRed, ::Color(0xDB7093)}, - {XML_papayaWhip, ::Color(0xFFEFD5)}, {XML_peachPuff, ::Color(0xFFDAB9)}, - {XML_peru, ::Color(0xCD853F)}, {XML_pink, ::Color(0xFFC0CB)}, - {XML_plum, ::Color(0xDDA0DD)}, {XML_powderBlue, ::Color(0xB0E0E6)}, - {XML_purple, ::Color(0x800080)}, {XML_red, ::Color(0xFF0000)}, - {XML_rosyBrown, ::Color(0xBC8F8F)}, {XML_royalBlue, ::Color(0x4169E1)}, - {XML_saddleBrown, ::Color(0x8B4513)}, {XML_salmon, ::Color(0xFA8072)}, - {XML_sandyBrown, ::Color(0xF4A460)}, {XML_seaGreen, ::Color(0x2E8B57)}, - {XML_seaShell, ::Color(0xFFF5EE)}, {XML_sienna, ::Color(0xA0522D)}, - {XML_silver, ::Color(0xC0C0C0)}, {XML_skyBlue, ::Color(0x87CEEB)}, - {XML_slateBlue, ::Color(0x6A5ACD)}, {XML_slateGray, ::Color(0x708090)}, - {XML_snow, ::Color(0xFFFAFA)}, {XML_springGreen, ::Color(0x00FF7F)}, - {XML_steelBlue, ::Color(0x4682B4)}, {XML_tan, ::Color(0xD2B48C)}, - {XML_teal, ::Color(0x008080)}, {XML_thistle, ::Color(0xD8BFD8)}, - {XML_tomato, ::Color(0xFF6347)}, {XML_turquoise, ::Color(0x40E0D0)}, - {XML_violet, ::Color(0xEE82EE)}, {XML_wheat, ::Color(0xF5DEB3)}, - {XML_white, ::Color(0xFFFFFF)}, {XML_whiteSmoke, ::Color(0xF5F5F5)}, - {XML_yellow, ::Color(0xFFFF00)}, {XML_yellowGreen, ::Color(0x9ACD32)} - }; - for(auto const& nEntry : spnDmlColors) - maDmlColors[ static_cast< size_t >(nEntry.first) ] = nEntry.second; - - // predefined colors in VML (map XML token identifiers to RGB values) - static const std::pair spnVmlColors[] = - { - {XML_aqua, ::Color(0x00FFFF)}, {XML_black, ::Color(0x000000)}, - {XML_blue, ::Color(0x0000FF)}, {XML_fuchsia, ::Color(0xFF00FF)}, - {XML_gray, ::Color(0x808080)}, {XML_green, ::Color(0x008000)}, - {XML_lime, ::Color(0x00FF00)}, {XML_maroon, ::Color(0x800000)}, - {XML_navy, ::Color(0x000080)}, {XML_olive, ::Color(0x808000)}, - {XML_purple, ::Color(0x800080)}, {XML_red, ::Color(0xFF0000)}, - {XML_silver, ::Color(0xC0C0C0)}, {XML_teal, ::Color(0x008080)}, - {XML_white, ::Color(0xFFFFFF)}, {XML_yellow, ::Color(0xFFFF00)} - }; - for(auto const& nEntry : spnVmlColors) - maVmlColors[ static_cast< size_t >(nEntry.first) ] = nEntry.second; - - // predefined highlight colors in DML (map XML token identifiers to RGB values) - static const std::pair spnHighlightColors[] = - { - // tdf#131841 Predefined color for OOXML highlight. - {XML_black, ::Color(0x000000)}, {XML_blue, ::Color(0x0000FF)}, - {XML_cyan, ::Color(0x00FFFF)}, {XML_darkBlue, ::Color(0x00008B)}, - {XML_darkCyan, ::Color(0x008B8B)}, {XML_darkGray, ::Color(0xA9A9A9)}, - {XML_darkGreen, ::Color(0x006400)}, {XML_darkMagenta, ::Color(0x800080)}, - {XML_darkRed, ::Color(0x8B0000)}, {XML_darkYellow, ::Color(0x808000)}, - {XML_green, ::Color(0x00FF00)}, {XML_lightGray, ::Color(0xD3D3D3)}, - {XML_magenta, ::Color(0xFF00FF)}, {XML_red, ::Color(0xFF0000)}, - {XML_white, ::Color(0xFFFFFF)}, {XML_yellow, ::Color(0xFFFF00)} - }; - for (auto const& nEntry : spnHighlightColors) - maHighlightColors[static_cast(nEntry.first)] = nEntry.second; + auto iterator = constDmlColors.find(nToken); + if (iterator == constDmlColors.end()) + return API_RGB_TRANSPARENT; + return iterator->second; } -PresetColorsPool& StaticPresetColorsPool() +constexpr frozen::unordered_map constVmlColors { - static PresetColorsPool thePool; - return thePool; + {XML_aqua, ::Color(0x00FFFF)}, {XML_black, ::Color(0x000000)}, + {XML_blue, ::Color(0x0000FF)}, {XML_fuchsia, ::Color(0xFF00FF)}, + {XML_gray, ::Color(0x808080)}, {XML_green, ::Color(0x008000)}, + {XML_lime, ::Color(0x00FF00)}, {XML_maroon, ::Color(0x800000)}, + {XML_navy, ::Color(0x000080)}, {XML_olive, ::Color(0x808000)}, + {XML_purple, ::Color(0x800080)}, {XML_red, ::Color(0xFF0000)}, + {XML_silver, ::Color(0xC0C0C0)}, {XML_teal, ::Color(0x008080)}, + {XML_white, ::Color(0xFFFFFF)}, {XML_yellow, ::Color(0xFFFF00)} +}; + +constexpr ::Color lookupVmlColor(sal_Int32 nToken) +{ + auto iterator = constVmlColors.find(nToken); + if (iterator == constVmlColors.end()) + return API_RGB_TRANSPARENT; + return iterator->second; +} + +constexpr frozen::unordered_map constHighlightColors +{ + // tdf#131841 Predefined color for OOXML highlight. + {XML_black, ::Color(0x000000)}, {XML_blue, ::Color(0x0000FF)}, + {XML_cyan, ::Color(0x00FFFF)}, {XML_darkBlue, ::Color(0x00008B)}, + {XML_darkCyan, ::Color(0x008B8B)}, {XML_darkGray, ::Color(0xA9A9A9)}, + {XML_darkGreen, ::Color(0x006400)}, {XML_darkMagenta, ::Color(0x800080)}, + {XML_darkRed, ::Color(0x8B0000)}, {XML_darkYellow, ::Color(0x808000)}, + {XML_green, ::Color(0x00FF00)}, {XML_lightGray, ::Color(0xD3D3D3)}, + {XML_magenta, ::Color(0xFF00FF)}, {XML_red, ::Color(0xFF0000)}, + {XML_white, ::Color(0xFFFFFF)}, {XML_yellow, ::Color(0xFFFF00)} +}; + +constexpr ::Color lookupHighlightColor(sal_Int32 nToken) +{ + auto iterator = constHighlightColors.find(nToken); + if (iterator == constHighlightColors.end()) + return API_RGB_TRANSPARENT; + return iterator->second; } const double DEC_GAMMA = 2.3; @@ -214,39 +209,40 @@ void lclOffValue( sal_Int32& ornValue, sal_Int32 nOff, sal_Int32 nMax = MAX_PERC ornValue = getLimitedValue< sal_Int32, sal_Int32 >( ornValue + nOff, 0, nMax ); } -} // namespace +constexpr frozen::unordered_map 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 } +}; + +} // end anonymous namespace model::ThemeColorType schemeNameToThemeColorType(OUString const& rSchemeName) { - static std::unordered_map 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; @@ -268,7 +264,7 @@ Color::Color() : /* Do not pass nDefaultRgb to ContainerHelper::getVectorElement(), to be able to catch the existing vector entries without corresponding XML token identifier. */ - ::Color nRgbValue = ContainerHelper::getVectorElement( StaticPresetColorsPool().maDmlColors, nToken, API_RGB_TRANSPARENT ); + ::Color nRgbValue = lookupDmlColor(nToken); return (sal_Int32(nRgbValue) >= 0) ? nRgbValue : nDefaultRgb; } @@ -277,7 +273,7 @@ Color::Color() : /* Do not pass nDefaultRgb to ContainerHelper::getVectorElement(), to be able to catch the existing vector entries without corresponding XML token identifier. */ - ::Color nRgbValue = ContainerHelper::getVectorElement( StaticPresetColorsPool().maVmlColors, nToken, API_RGB_TRANSPARENT ); + ::Color nRgbValue = lookupVmlColor(nToken); return (sal_Int32(nRgbValue) >= 0) ? nRgbValue : nDefaultRgb; } @@ -286,7 +282,7 @@ Color::Color() : /* Do not pass nDefaultRgb to ContainerHelper::getVectorElement(), to be able to catch the existing vector entries without corresponding XML token identifier. */ - ::Color nRgbValue = ContainerHelper::getVectorElement( StaticPresetColorsPool().maHighlightColors, nToken, API_RGB_TRANSPARENT ); + ::Color nRgbValue = lookupHighlightColor(nToken); return (sal_Int32(nRgbValue) >= 0) ? nRgbValue : nDefaultRgb; } diff --git a/oox/source/drawingml/colorchoicecontext.cxx b/oox/source/drawingml/colorchoicecontext.cxx index b0977c5e003c..63ac44fd6aac 100644 --- a/oox/source/drawingml/colorchoicecontext.cxx +++ b/oox/source/drawingml/colorchoicecontext.cxx @@ -24,13 +24,16 @@ #include #include #include +#include +#include +#include namespace oox::drawingml { namespace { -const std::unordered_map constSystemColorMap = +constexpr frozen::unordered_map constSystemColorMap { { XML_scrollBar, model::SystemColorType::ScrollBar }, { XML_background, model::SystemColorType::Background }, @@ -64,7 +67,7 @@ const std::unordered_map constSystemColorMap { XML_menuBar, model::SystemColorType::MenuBar } }; -const std::unordered_map constTransformTypeMap = +constexpr frozen::unordered_map 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 43f2b050cdd8..3061230f9e5b 100644 --- a/oox/source/drawingml/fontworkhelpers.cxx +++ b/oox/source/drawingml/fontworkhelpers.cxx @@ -907,6 +907,18 @@ void FontworkHelpers::applyPropsToRuns(const std::vector& } } } +namespace +{ +constexpr const std::array aCharPropNames{ + u"CharColorLumMod", u"CharColorLumOff", u"CharColorTheme", u"CharComplexColor", + u"CharTransparence" +}; + +constexpr const std::array aShapePropNames{ + u"FillColorLumMod", u"FillColorLumOff", u"FillColorTheme", u"FillComplexColor", + u"FillTransparence" +}; +} void FontworkHelpers::createCharFillPropsFromShape( const uno::Reference& rXPropSet, @@ -932,17 +944,12 @@ void FontworkHelpers::createCharFillPropsFromShape( rCharPropVec.push_back(comphelper::makePropertyValue(u"CharColor", sal_Int32(aColor))); } - const std::array aCharPropNames - = { u"CharColorLumMod", u"CharColorLumOff", u"CharColorTheme", u"CharComplexColor", - u"CharTransparence" }; - const std::array 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))); } } @@ -1041,29 +1048,32 @@ typedef std::multimap ColorMapType; namespace { +constexpr const std::array 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 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 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_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 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_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..417b4f35e8a6 100644 --- a/oox/source/drawingml/misccontexts.cxx +++ b/oox/source/drawingml/misccontexts.cxx @@ -28,6 +28,9 @@ #include #include #include +#include +#include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -143,7 +146,7 @@ ContextHandlerRef GradientFillContext::onCreateContext( namespace { -std::unordered_map constPatternPresetMap = +constexpr frozen::unordered_map 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..513637e3c7ee 100644 --- a/oox/source/drawingml/table/predefined-table-styles.cxx +++ b/oox/source/drawingml/table/predefined-table-styles.cxx @@ -8,6 +8,9 @@ */ #include #include +#include +#include +#include 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 tokens = { { "", XML_dk1 }, - { "Accent1", XML_accent1 }, - { "Accent2", XML_accent2 }, - { "Accent3", XML_accent3 }, - { "Accent4", XML_accent4 }, - { "Accent5", XML_accent5 }, - { "Accent6", XML_accent6 } }; +constexpr frozen::unordered_map 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 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 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 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 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 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 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 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 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 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 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 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..8d2d90fe1598 100644 --- a/oox/source/export/ThemeExport.cxx +++ b/oox/source/export/ThemeExport.cxx @@ -19,6 +19,9 @@ #include #include #include +#include +#include +#include namespace oox { @@ -142,16 +145,84 @@ bool ThemeExport::writeFontScheme(model::FontScheme const& rFontScheme) return true; } +namespace +{ +constexpr frozen::unordered_map constTransformTypeTokenMap{ + { model::TransformationType::Tint, XML_tint }, + { model::TransformationType::Shade, XML_shade }, + { model::TransformationType::LumMod, XML_lumMod }, + { model::TransformationType::LumOff, XML_lumOff }, +}; + +constexpr frozen::unordered_map 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" } +}; + +constexpr frozen::unordered_map + 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" } + }; + +constexpr frozen::unordered_map 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 const& rTransformations) { - static std::unordered_map constTransformTypeTokenMap = { - { model::TransformationType::Tint, XML_tint }, - { model::TransformationType::Shade, XML_shade }, - { model::TransformationType::LumMod, XML_lumMod }, - { model::TransformationType::LumOff, XML_lumOff }, - }; - 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 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 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 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 constTokenArray + static const constexpr std::array 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/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx index 7a5788259921..cc972b80a8b0 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -25,6 +25,10 @@ #include #include +#include +#include +#include + #include #include #include @@ -72,12 +76,15 @@ using namespace ::com::sun::star::drawing; using namespace ::com::sun::star::presentation; using namespace ::com::sun::star::xml::sax; -namespace oox::ppt { - -static std::map PredefinedClrTokens = +namespace oox::ppt { - //{ dk1, XML_dk1 }, - //{ lt1, XML_lt1 }, + +namespace +{ +constexpr frozen::unordered_map constPredefinedClrTokens +{ + { dk1, XML_dk1 }, + { lt1, XML_lt1 }, { dk2, XML_dk2 }, { lt2, XML_lt2 }, { accent1, XML_accent1 }, @@ -90,6 +97,15 @@ static std::map PredefinedClrTokens = { folHlink, XML_folHlink } }; +sal_Int32 getPredefinedClrTokens(PredefinedClrSchemeId eID) +{ + auto iterator = constPredefinedClrTokens.find(eID); + if (iterator == constPredefinedClrTokens.end()) + return XML_TOKEN_INVALID; + return iterator->second; +} +} // end anonymous ns + PresentationFragmentHandler::PresentationFragmentHandler(XmlFilterBase& rFilter, const OUString& rFragmentPath) : FragmentHandler2( rFilter, rFragmentPath ) , mpTextListStyle( std::make_shared() ) @@ -227,8 +243,9 @@ void PresentationFragmentHandler::saveThemeToGrabBag(const oox::drawingml::Theme ClrScheme rClrScheme = pThemePtr->getClrScheme(); for (int nId = PredefinedClrSchemeId::dk2; nId != PredefinedClrSchemeId::Count; nId++) { - sal_uInt32 nToken = PredefinedClrTokens[static_cast(nId)]; - const OUString& sName = PredefinedClrNames[static_cast(nId)]; + auto eID = static_cast(nId); + sal_uInt32 nToken = getPredefinedClrTokens(eID); + OUString sName(getPredefinedClrNames(eID)); ::Color nColor; rClrScheme.getColor(nToken, nColor); diff --git a/oox/source/token/relationship.cxx b/oox/source/token/relationship.cxx index cfe1dedc508d..602793ba7424 100644 --- a/oox/source/token/relationship.cxx +++ b/oox/source/token/relationship.cxx @@ -10,21 +10,28 @@ #include #include -#include +#include +#include +#include -namespace oox { +namespace oox +{ + +namespace +{ + +constexpr frozen::unordered_map constRelationshipMap +{ +#include "relationship.inc" +}; + +} // end anonymous ns OUString getRelationship(Relationship eRelationship) { - static const std::map aMap = - { -#include "relationship.inc" - }; - - auto itr = aMap.find(eRelationship); - if (itr != aMap.end()) - return itr->second; - + 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(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"} diff --git a/sc/Library_scfilt.mk b/sc/Library_scfilt.mk index aa4e1fae787c..5837f1ec3492 100644 --- a/sc/Library_scfilt.mk +++ b/sc/Library_scfilt.mk @@ -36,6 +36,7 @@ $(eval $(call gb_Library_use_externals,scfilt,\ boost_headers \ $(call gb_Helper_optional,OPENCL,clew) \ mdds_headers \ + frozen \ )) $(eval $(call gb_Library_use_libraries,scfilt,\ diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index aeebc8b53b39..926dd86ee755 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -109,6 +109,7 @@ $(eval $(call gb_Library_use_externals,sd,\ avahi \ ) \ icu_headers \ + frozen \ )) ifneq ($(DBUS_HAVE_GLIB),) diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index 023f29dc82c6..8d0a85b16b5a 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -1947,7 +1947,7 @@ void PowerPointExport::WriteDefaultColorSchemes(const FSHelperPtr& pFS) { for (int nId = PredefinedClrSchemeId::dk2; nId != PredefinedClrSchemeId::Count; nId++) { - OUString sName = PredefinedClrNames[static_cast(nId)]; + OUString sName(getPredefinedClrNames(static_cast(nId))); sal_Int32 nColor = 0; switch (nId) diff --git a/writerfilter/Library_writerfilter.mk b/writerfilter/Library_writerfilter.mk index 3e0662b4fb35..85afb7e598cd 100644 --- a/writerfilter/Library_writerfilter.mk +++ b/writerfilter/Library_writerfilter.mk @@ -56,6 +56,7 @@ $(eval $(call gb_Library_use_externals,writerfilter,\ icuuc \ icu_headers \ libxml2 \ + frozen \ )) $(eval $(call gb_Library_add_exception_objects,writerfilter,\ diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx index f809d54432c8..64c814f79492 100644 --- a/writerfilter/source/dmapper/PropertyIds.cxx +++ b/writerfilter/source/dmapper/PropertyIds.cxx @@ -18,13 +18,16 @@ */ #include #include "PropertyIds.hxx" -#include +#include +#include +#include namespace writerfilter::dmapper{ -const OUString & getPropertyName( PropertyIds eId ) +namespace { - static const std::unordered_map map { + constexpr frozen::unordered_map constPropertyMap + { { PROP_CHAR_WEIGHT, u"CharWeight"}, { PROP_CHAR_POSTURE, u"CharPosture"}, { PROP_CHAR_STRIKEOUT, u"CharStrikeout"}, @@ -373,7 +376,15 @@ const OUString & getPropertyName( PropertyIds eId ) { PROP_PARA_CONNECT_BORDERS, u"ParaIsConnectBorder"}, { PROP_DECORATIVE, u"Decorative"}, }; - return map.at(eId); +} // end anonymous ns + +OUString getPropertyName( PropertyIds eId ) +{ + auto iterator = constPropertyMap.find(eId); + if (iterator != constPropertyMap.end()) + return OUString(iterator->second); + + return OUString(); } bool isCharacterProperty( const PropertyIds eId ) diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx index 60d6537ae6c2..d3213b7be073 100644 --- a/writerfilter/source/dmapper/PropertyIds.hxx +++ b/writerfilter/source/dmapper/PropertyIds.hxx @@ -377,7 +377,7 @@ enum PropertyIds }; //Returns the UNO string equivalent to eId. -const OUString & getPropertyName(PropertyIds eId); +OUString getPropertyName(PropertyIds eId); bool isCharacterProperty(const PropertyIds eId); diff --git a/xmloff/Library_xo.mk b/xmloff/Library_xo.mk index d2b539d514d9..8e7f3208bfe9 100644 --- a/xmloff/Library_xo.mk +++ b/xmloff/Library_xo.mk @@ -41,7 +41,10 @@ $(eval $(call gb_Library_add_defs,xo,\ -DXMLOFF_DLLIMPLEMENTATION \ )) -$(eval $(call gb_Library_use_external,xo,boost_headers)) +$(eval $(call gb_Library_use_externals,xo,\ + boost_headers \ + frozen \ +)) $(eval $(call gb_Library_use_custom_headers,xo,\ officecfg/registry \ diff --git a/xmloff/source/style/XMLRtlGutterPropertyHandler.cxx b/xmloff/source/style/XMLRtlGutterPropertyHandler.cxx index 651406f0fa2b..d5d94bdb44e4 100644 --- a/xmloff/source/style/XMLRtlGutterPropertyHandler.cxx +++ b/xmloff/source/style/XMLRtlGutterPropertyHandler.cxx @@ -18,11 +18,10 @@ */ #include - -#include - +#include +#include +#include #include - #include using namespace com::sun::star; @@ -31,13 +30,18 @@ XMLRtlGutterPropertyHandler::XMLRtlGutterPropertyHandler() = default; XMLRtlGutterPropertyHandler::~XMLRtlGutterPropertyHandler() = default; +namespace +{ +constexpr frozen::unordered_set constRtlModes{ u"rl-tb", u"tb-rl", u"rl", + u"tb" }; +} // end anonymous ns + bool XMLRtlGutterPropertyHandler::importXML(const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter&) const { // Infer RtlGutter from WritingMode. - std::set aRtlModes = { "rl-tb", "tb-rl", "rl", "tb" }; - auto it = aRtlModes.find(rStrImpValue); - rValue <<= (it != aRtlModes.end()); + auto it = constRtlModes.find(rStrImpValue); + rValue <<= (it != constRtlModes.end()); return true; }