xmloff/source/text/XMLIndexTemplateContext.cxx | 53 +++++++++++++------------ xmloff/source/text/XMLIndexTemplateContext.hxx | 15 +++---- xmloff/source/text/XMLSectionExport.cxx | 53 ++++++++++++------------- 3 files changed, 62 insertions(+), 59 deletions(-)
New commits: commit 3c5424629903299c92f27a35bb287bea824fa007 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri May 3 10:43:13 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon May 6 08:26:07 2024 +0200 replace createFromAscii with OUString literals in XMLSectionExport Change-Id: Ia9c4c7ad04bb17e24b017bef074e5636f3a960a7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167167 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/xmloff/source/text/XMLSectionExport.cxx b/xmloff/source/text/XMLSectionExport.cxx index c26faca46a2e..702b5dc047ab 100644 --- a/xmloff/source/text/XMLSectionExport.cxx +++ b/xmloff/source/text/XMLSectionExport.cxx @@ -930,29 +930,29 @@ static const XMLTokenEnum* aTypeLevelNameMap[] = aLevelNameBibliographyMap // bibliography }; -static const char* aLevelStylePropNameTOCMap[] = - { nullptr, "ParaStyleLevel1", "ParaStyleLevel2", "ParaStyleLevel3", - "ParaStyleLevel4", "ParaStyleLevel5", "ParaStyleLevel6", - "ParaStyleLevel7", "ParaStyleLevel8", "ParaStyleLevel9", - "ParaStyleLevel10", nullptr }; -static const char* aLevelStylePropNameTableMap[] = - { nullptr, "ParaStyleLevel1", nullptr }; -static const char* aLevelStylePropNameAlphaMap[] = - { nullptr, "ParaStyleSeparator", "ParaStyleLevel1", "ParaStyleLevel2", - "ParaStyleLevel3", nullptr }; -static const char* aLevelStylePropNameBibliographyMap[] = +constexpr OUString aLevelStylePropNameTOCMap[] = + { 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 }; +constexpr OUString aLevelStylePropNameTableMap[] = + { u""_ustr, u"ParaStyleLevel1"_ustr, u""_ustr }; +constexpr OUString aLevelStylePropNameAlphaMap[] = + { u""_ustr, u"ParaStyleSeparator"_ustr, u"ParaStyleLevel1"_ustr, u"ParaStyleLevel2"_ustr, + u"ParaStyleLevel3"_ustr, u""_ustr }; +constexpr OUString aLevelStylePropNameBibliographyMap[] = // TODO: replace with real property names, when available - { nullptr, "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1", - "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1", - "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1", - "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1", - "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1", - "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1", - "ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1", - "ParaStyleLevel1", - nullptr }; - -static const char** aTypeLevelStylePropNameMap[] = + { 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 }; + +constexpr const OUString* aTypeLevelStylePropNameMap[] = { aLevelStylePropNameTOCMap, // TOC aLevelStylePropNameTableMap, // table index @@ -1027,13 +1027,12 @@ bool XMLSectionExport::ExportIndexTemplate( } // paragraph level style name - const char* pPropName( + const OUString pPropName( aTypeLevelStylePropNameMap[eType-TEXT_SECTION_TYPE_TOC][nOutlineLevel]); - OSL_ENSURE(nullptr != pPropName, "can't find property name"); - if (nullptr != pPropName) + OSL_ENSURE(!pPropName.isEmpty(), "can't find property name"); + if (!pPropName.isEmpty()) { - Any aAny = rPropertySet->getPropertyValue( - OUString::createFromAscii(pPropName)); + Any aAny = rPropertySet->getPropertyValue(pPropName); OUString sParaStyleName; aAny >>= sParaStyleName; GetExport().AddAttribute(XML_NAMESPACE_TEXT, commit 11bf2d8599bd6262d7d1b24d04bf52440daeb4b1 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri May 3 10:38:24 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon May 6 08:25:58 2024 +0200 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.gran...@collabora.co.uk> 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);