diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-05-03 10:38:24 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-05-06 08:25:58 +0200 |
commit | 11bf2d8599bd6262d7d1b24d04bf52440daeb4b1 (patch) | |
tree | 5340a0cfc9a6ea6ddae629812e35d843e18702d2 /xmloff | |
parent | 7a895ec4205659038aa95941b65715fed1a3e7be (diff) |
replace createFromAscii with OUString literals in XMLIndexTemplateContext
Change-Id: I9ebc4835c2cc1e525360e89a19514be48b5a77dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167166
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/text/XMLIndexTemplateContext.cxx | 53 | ||||
-rw-r--r-- | xmloff/source/text/XMLIndexTemplateContext.hxx | 15 |
2 files changed, 36 insertions, 32 deletions
diff --git a/xmloff/source/text/XMLIndexTemplateContext.cxx b/xmloff/source/text/XMLIndexTemplateContext.cxx index 9a521686f596..6aa4dd045366 100644 --- a/xmloff/source/text/XMLIndexTemplateContext.cxx +++ b/xmloff/source/text/XMLIndexTemplateContext.cxx @@ -53,7 +53,7 @@ XMLIndexTemplateContext::XMLIndexTemplateContext( Reference<XPropertySet> & rPropSet, const SvXMLEnumMapEntry<sal_uInt16>* pLevelNameMap, enum XMLTokenEnum eLevelAttrName, - const char** pLevelStylePropMap, + std::span<const OUString> pLevelStylePropMap, const bool* pAllowedTokenTypes, bool bT ) : SvXMLImportContext(rImport) @@ -70,7 +70,6 @@ XMLIndexTemplateContext::XMLIndexTemplateContext( DBG_ASSERT( ((XML_TOKEN_INVALID != eLevelAttrName) && (nullptr != pLevelNameMap)) || ((XML_TOKEN_INVALID == eLevelAttrName) && (nullptr == pLevelNameMap)), "need both, attribute name and value map, or neither" ); - SAL_WARN_IF( nullptr == pOutlineLevelStylePropMap, "xmloff", "need property name map" ); SAL_WARN_IF( nullptr == pAllowedTokenTypes, "xmloff", "need allowed tokens map" ); // no map for outline-level? then use 1 @@ -142,11 +141,11 @@ void XMLIndexTemplateContext::endFastElement(sal_Int32 ) if (!bStyleNameOK) return; - const char* pStyleProperty = + const OUString pStyleProperty = pOutlineLevelStylePropMap[nOutlineLevel]; - DBG_ASSERT(nullptr != pStyleProperty, "need property name"); - if (nullptr == pStyleProperty) + DBG_ASSERT(!pStyleProperty.isEmpty(), "need property name"); + if (pStyleProperty.isEmpty()) return; OUString sDisplayStyleName = @@ -160,7 +159,7 @@ void XMLIndexTemplateContext::endFastElement(sal_Int32 ) rStyles->hasByName( sDisplayStyleName ) ) { rPropertySet->setPropertyValue( - OUString::createFromAscii(pStyleProperty), css::uno::Any(sDisplayStyleName)); + pStyleProperty, css::uno::Any(sDisplayStyleName)); } } @@ -283,11 +282,12 @@ const SvXMLEnumMapEntry<sal_uInt16> aSvLevelNameTOCMap[] = { XML_TOKEN_INVALID, 0 } }; -const char* aLevelStylePropNameTOCMap[] = - { nullptr, "ParaStyleLevel1", "ParaStyleLevel2", "ParaStyleLevel3", - "ParaStyleLevel4", "ParaStyleLevel5", "ParaStyleLevel6", - "ParaStyleLevel7", "ParaStyleLevel8", "ParaStyleLevel9", - "ParaStyleLevel10", nullptr }; +constexpr OUString aLevelStylePropNameTOCMapArray[] = + { u""_ustr, u"ParaStyleLevel1"_ustr, u"ParaStyleLevel2"_ustr, u"ParaStyleLevel3"_ustr, + u"ParaStyleLevel4"_ustr, u"ParaStyleLevel5"_ustr, u"ParaStyleLevel6"_ustr, + u"ParaStyleLevel7"_ustr, u"ParaStyleLevel8"_ustr, u"ParaStyleLevel9"_ustr, + u"ParaStyleLevel10"_ustr, u""_ustr }; +std::span<const OUString> const aLevelStylePropNameTOCMap = aLevelStylePropNameTOCMapArray; const bool aAllowedTokenTypesTOC[] = { @@ -325,9 +325,10 @@ const SvXMLEnumMapEntry<sal_uInt16> aLevelNameAlphaMap[] = { XML_TOKEN_INVALID, 0 } }; -const char* aLevelStylePropNameAlphaMap[] = - { nullptr, "ParaStyleSeparator", "ParaStyleLevel1", "ParaStyleLevel2", - "ParaStyleLevel3", nullptr }; +constexpr OUString aLevelStylePropNameAlphaMapArray[] = + { u""_ustr, u"ParaStyleSeparator"_ustr, u"ParaStyleLevel1"_ustr, u"ParaStyleLevel2"_ustr, + u"ParaStyleLevel3"_ustr, u""_ustr }; +std::span<const OUString> const aLevelStylePropNameAlphaMap = aLevelStylePropNameAlphaMapArray; const bool aAllowedTokenTypesAlpha[] = { @@ -372,16 +373,17 @@ const SvXMLEnumMapEntry<sal_uInt16> aLevelNameBibliographyMap[] = }; // TODO: replace with real property names, when available -const char* aLevelStylePropNameBibliographyMap[] = +constexpr OUString aLevelStylePropNameBibliographyMapArray[] = { - nullptr, "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1", - "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1", - "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1", - "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1", - "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1", - "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1", - "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1", - "ParaStyleLevel1", nullptr }; + u""_ustr, u"ParaStyleLevel1"_ustr, u"ParaStyleLevel1"_ustr, u"ParaStyleLevel1"_ustr, + u"ParaStyleLevel1"_ustr, u"ParaStyleLevel1"_ustr, u"ParaStyleLevel1"_ustr, + u"ParaStyleLevel1"_ustr, u"ParaStyleLevel1"_ustr, u"ParaStyleLevel1"_ustr, + u"ParaStyleLevel1"_ustr, u"ParaStyleLevel1"_ustr, u"ParaStyleLevel1"_ustr, + u"ParaStyleLevel1"_ustr, u"ParaStyleLevel1"_ustr, u"ParaStyleLevel1"_ustr, + u"ParaStyleLevel1"_ustr, u"ParaStyleLevel1"_ustr, u"ParaStyleLevel1"_ustr, + u"ParaStyleLevel1"_ustr, u"ParaStyleLevel1"_ustr, u"ParaStyleLevel1"_ustr, + u"ParaStyleLevel1"_ustr, u""_ustr }; +std::span<const OUString> const aLevelStylePropNameBibliographyMap = aLevelStylePropNameBibliographyMapArray; const bool aAllowedTokenTypesBibliography[] = { @@ -401,8 +403,9 @@ const bool aAllowedTokenTypesBibliography[] = // no name map const SvXMLEnumMapEntry<sal_uInt16>* aLevelNameTableMap = nullptr; -const char* aLevelStylePropNameTableMap[] = - { nullptr, "ParaStyleLevel1", nullptr }; +constexpr OUString aLevelStylePropNameTableMapArray[] = + { u""_ustr, u"ParaStyleLevel1"_ustr, u""_ustr }; +std::span<const OUString> const aLevelStylePropNameTableMap = aLevelStylePropNameTableMapArray; const bool aAllowedTokenTypesTable[] = { diff --git a/xmloff/source/text/XMLIndexTemplateContext.hxx b/xmloff/source/text/XMLIndexTemplateContext.hxx index 424693d7e459..2dd7c0b7517a 100644 --- a/xmloff/source/text/XMLIndexTemplateContext.hxx +++ b/xmloff/source/text/XMLIndexTemplateContext.hxx @@ -22,6 +22,7 @@ #include <xmloff/xmlictxt.hxx> #include <xmloff/xmltoken.hxx> +#include <span> #include <vector> #include <com/sun/star/uno/Reference.h> #include <com/sun/star/beans/PropertyValues.hpp> @@ -38,23 +39,23 @@ template<typename EnumT> struct SvXMLEnumMapEntry; // TOC and user defined index: extern const SvXMLEnumMapEntry<sal_uInt16> aSvLevelNameTOCMap[]; -extern const char* aLevelStylePropNameTOCMap[]; +extern std::span<const OUString> const aLevelStylePropNameTOCMap; extern const bool aAllowedTokenTypesTOC[]; extern const bool aAllowedTokenTypesUser[]; // alphabetical index: extern const SvXMLEnumMapEntry<sal_uInt16> aLevelNameAlphaMap[]; -extern const char* aLevelStylePropNameAlphaMap[]; +extern std::span<const OUString> const aLevelStylePropNameAlphaMap; extern const bool aAllowedTokenTypesAlpha[]; // bibliography: extern const SvXMLEnumMapEntry<sal_uInt16> aLevelNameBibliographyMap[]; -extern const char* aLevelStylePropNameBibliographyMap[]; +extern std::span<const OUString> const aLevelStylePropNameBibliographyMap; extern const bool aAllowedTokenTypesBibliography[]; // table, illustration and object tables: extern const SvXMLEnumMapEntry<sal_uInt16>* aLevelNameTableMap; // NULL: no outline-level -extern const char* aLevelStylePropNameTableMap[]; +extern std::span<const OUString> const aLevelStylePropNameTableMap; extern const bool aAllowedTokenTypesTable[]; @@ -70,7 +71,7 @@ class XMLIndexTemplateContext : public SvXMLImportContext const SvXMLEnumMapEntry<sal_uInt16>* pOutlineLevelNameMap; enum ::xmloff::token::XMLTokenEnum eOutlineLevelAttrName; - const char** pOutlineLevelStylePropMap; + std::span<const OUString> pOutlineLevelStylePropMap; const bool* pAllowedTokenTypesMap; sal_Int32 nOutlineLevel; @@ -88,7 +89,7 @@ public: css::uno::Reference<css::beans::XPropertySet> & rPropSet, const SvXMLEnumMapEntry<EnumT>* aLevelNameMap, enum ::xmloff::token::XMLTokenEnum eLevelAttrName, - const char** aLevelStylePropNameMap, + std::span<const OUString> aLevelStylePropNameMap, const bool* aAllowedTokenTypes, bool bTOC_=false) : XMLIndexTemplateContext(rImport,rPropSet, @@ -99,7 +100,7 @@ public: css::uno::Reference<css::beans::XPropertySet> & rPropSet, const SvXMLEnumMapEntry<sal_uInt16>* aLevelNameMap, enum ::xmloff::token::XMLTokenEnum eLevelAttrName, - const char** aLevelStylePropNameMap, + std::span<const OUString> aLevelStylePropNameMap, const bool* aAllowedTokenTypes, bool bTOC); |