From 5c543f7ae6de63ddf2a563162c296f69f74e7d38 Mon Sep 17 00:00:00 2001 From: Noel Date: Tue, 15 Dec 2020 15:18:47 +0200 Subject: use views to parse Change-Id: I1e6678e18e5ef298021c818036b44c5b71b180fa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107760 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../text/XMLIndexAlphabeticalSourceContext.cxx | 36 ++++++++++------------ .../text/XMLIndexAlphabeticalSourceContext.hxx | 4 +-- .../text/XMLIndexBibliographySourceContext.cxx | 6 ++-- .../text/XMLIndexBibliographySourceContext.hxx | 4 +-- xmloff/source/text/XMLIndexObjectSourceContext.cxx | 18 +++++------ xmloff/source/text/XMLIndexObjectSourceContext.hxx | 4 +-- xmloff/source/text/XMLIndexSourceBaseContext.cxx | 14 ++++----- xmloff/source/text/XMLIndexSourceBaseContext.hxx | 4 +-- xmloff/source/text/XMLIndexTOCSourceContext.cxx | 18 +++++------ xmloff/source/text/XMLIndexTOCSourceContext.hxx | 4 +-- xmloff/source/text/XMLIndexTableSourceContext.cxx | 14 ++++----- xmloff/source/text/XMLIndexTableSourceContext.hxx | 4 +-- xmloff/source/text/XMLIndexUserSourceContext.cxx | 24 +++++++-------- xmloff/source/text/XMLIndexUserSourceContext.hxx | 4 +-- 14 files changed, 65 insertions(+), 93 deletions(-) diff --git a/xmloff/source/text/XMLIndexAlphabeticalSourceContext.cxx b/xmloff/source/text/XMLIndexAlphabeticalSourceContext.cxx index 08522e6aee81..df1385d95b0e 100644 --- a/xmloff/source/text/XMLIndexAlphabeticalSourceContext.cxx +++ b/xmloff/source/text/XMLIndexAlphabeticalSourceContext.cxx @@ -62,17 +62,15 @@ XMLIndexAlphabeticalSourceContext::~XMLIndexAlphabeticalSourceContext() { } -void XMLIndexAlphabeticalSourceContext::ProcessAttribute( - sal_Int32 nAttributeToken, - const OUString& rValue) +void XMLIndexAlphabeticalSourceContext::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) { bool bTmp(false); - switch (nAttributeToken) + switch (aIter.getToken()) { case XML_ELEMENT(TEXT, XML_MAIN_ENTRY_STYLE_NAME): { - sMainEntryStyleName = rValue; + sMainEntryStyleName = aIter.toString(); OUString sDisplayStyleName = GetImport().GetStyleDisplayName( XmlStyleFamily::TEXT_TEXT, sMainEntryStyleName ); const Reference < css::container::XNameContainer >& @@ -82,78 +80,78 @@ void XMLIndexAlphabeticalSourceContext::ProcessAttribute( break; case XML_ELEMENT(TEXT, XML_IGNORE_CASE): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bCaseSensitive = !bTmp; } break; case XML_ELEMENT(TEXT, XML_ALPHABETICAL_SEPARATORS): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bSeparators = bTmp; } break; case XML_ELEMENT(TEXT, XML_COMBINE_ENTRIES): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bCombineEntries = bTmp; } break; case XML_ELEMENT(TEXT, XML_COMBINE_ENTRIES_WITH_DASH): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bCombineDash = bTmp; } break; case XML_ELEMENT(TEXT, XML_USE_KEYS_AS_ENTRIES): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bEntry = bTmp; } break; case XML_ELEMENT(TEXT, XML_COMBINE_ENTRIES_WITH_PP): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bCombinePP = bTmp; } break; case XML_ELEMENT(TEXT, XML_CAPITALIZE_ENTRIES): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUpperCase = bTmp; } break; case XML_ELEMENT(TEXT, XML_COMMA_SEPARATED): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bCommaSeparated = bTmp; } break; case XML_ELEMENT(TEXT, XML_SORT_ALGORITHM): - sAlgorithm = rValue; + sAlgorithm = aIter.toString(); break; case XML_ELEMENT(STYLE, XML_RFC_LANGUAGE_TAG): - maLanguageTagODF.maRfcLanguageTag = rValue; + maLanguageTagODF.maRfcLanguageTag = aIter.toString(); break; case XML_ELEMENT(FO, XML_LANGUAGE): - maLanguageTagODF.maLanguage = rValue; + maLanguageTagODF.maLanguage = aIter.toString(); break; case XML_ELEMENT(FO, XML_SCRIPT): - maLanguageTagODF.maScript = rValue; + maLanguageTagODF.maScript = aIter.toString(); break; case XML_ELEMENT(FO, XML_COUNTRY): - maLanguageTagODF.maCountry = rValue; + maLanguageTagODF.maCountry = aIter.toString(); break; default: - XMLIndexSourceBaseContext::ProcessAttribute(nAttributeToken, rValue); + XMLIndexSourceBaseContext::ProcessAttribute(aIter); break; } } diff --git a/xmloff/source/text/XMLIndexAlphabeticalSourceContext.hxx b/xmloff/source/text/XMLIndexAlphabeticalSourceContext.hxx index a3a4ceba80be..479405c41746 100644 --- a/xmloff/source/text/XMLIndexAlphabeticalSourceContext.hxx +++ b/xmloff/source/text/XMLIndexAlphabeticalSourceContext.hxx @@ -62,9 +62,7 @@ public: protected: - virtual void ProcessAttribute( - sal_Int32 nAttributeToken, - const OUString& rValue) override; + virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; diff --git a/xmloff/source/text/XMLIndexBibliographySourceContext.cxx b/xmloff/source/text/XMLIndexBibliographySourceContext.cxx index 03d14efd9643..0ec5563895f6 100644 --- a/xmloff/source/text/XMLIndexBibliographySourceContext.cxx +++ b/xmloff/source/text/XMLIndexBibliographySourceContext.cxx @@ -48,12 +48,10 @@ XMLIndexBibliographySourceContext::~XMLIndexBibliographySourceContext() { } -void XMLIndexBibliographySourceContext::ProcessAttribute( - sal_Int32 nAttributeToken, - const OUString& rValue) +void XMLIndexBibliographySourceContext::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) { // We have no attributes. Who wants attributes, anyway? - XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttributeToken, rValue); + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } void XMLIndexBibliographySourceContext::endFastElement(sal_Int32 ) diff --git a/xmloff/source/text/XMLIndexBibliographySourceContext.hxx b/xmloff/source/text/XMLIndexBibliographySourceContext.hxx index 80fb3ea14f75..3f66991210e6 100644 --- a/xmloff/source/text/XMLIndexBibliographySourceContext.hxx +++ b/xmloff/source/text/XMLIndexBibliographySourceContext.hxx @@ -46,9 +46,7 @@ public: protected: - virtual void ProcessAttribute( - sal_Int32 nAttributeToken, - const OUString& rValue) override; + virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; diff --git a/xmloff/source/text/XMLIndexObjectSourceContext.cxx b/xmloff/source/text/XMLIndexObjectSourceContext.cxx index 682300027b12..d35f3f025149 100644 --- a/xmloff/source/text/XMLIndexObjectSourceContext.cxx +++ b/xmloff/source/text/XMLIndexObjectSourceContext.cxx @@ -58,51 +58,49 @@ XMLIndexObjectSourceContext::~XMLIndexObjectSourceContext() { } -void XMLIndexObjectSourceContext::ProcessAttribute( - sal_Int32 nAttributeToken, - const OUString& rValue) +void XMLIndexObjectSourceContext::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) { bool bTmp(false); - switch (nAttributeToken) + switch (aIter.getToken()) { case XML_ELEMENT(TEXT, XML_USE_OTHER_OBJECTS): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseOtherObjects = bTmp; } break; case XML_ELEMENT(TEXT, XML_USE_SPREADSHEET_OBJECTS): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseCalc = bTmp; } break; case XML_ELEMENT(TEXT, XML_USE_CHART_OBJECTS): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseChart = bTmp; } break; case XML_ELEMENT(TEXT, XML_USE_DRAW_OBJECTS): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseDraw = bTmp; } break; case XML_ELEMENT(TEXT, XML_USE_MATH_OBJECTS): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseMath = bTmp; } break; default: - XMLIndexSourceBaseContext::ProcessAttribute(nAttributeToken, rValue); + XMLIndexSourceBaseContext::ProcessAttribute(aIter); break; } } diff --git a/xmloff/source/text/XMLIndexObjectSourceContext.hxx b/xmloff/source/text/XMLIndexObjectSourceContext.hxx index ca076d9fe899..907eef03752d 100644 --- a/xmloff/source/text/XMLIndexObjectSourceContext.hxx +++ b/xmloff/source/text/XMLIndexObjectSourceContext.hxx @@ -52,9 +52,7 @@ public: protected: - virtual void ProcessAttribute( - sal_Int32 nAttributeToken, - const OUString& rValue) override; + virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; diff --git a/xmloff/source/text/XMLIndexSourceBaseContext.cxx b/xmloff/source/text/XMLIndexSourceBaseContext.cxx index 6d133473ac98..b9975b7e8766 100644 --- a/xmloff/source/text/XMLIndexSourceBaseContext.cxx +++ b/xmloff/source/text/XMLIndexSourceBaseContext.cxx @@ -61,17 +61,15 @@ void XMLIndexSourceBaseContext::startFastElement( { // process attributes for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) - ProcessAttribute(aIter.getToken(), aIter.toString()); + ProcessAttribute(aIter); } -void XMLIndexSourceBaseContext::ProcessAttribute( - sal_Int32 nAttributeToken, - const OUString& rValue) +void XMLIndexSourceBaseContext::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) { - switch (nAttributeToken) + switch (aIter.getToken()) { case XML_ELEMENT(TEXT, XML_INDEX_SCOPE): - if ( IsXMLToken( rValue, XML_CHAPTER ) ) + if ( IsXMLToken( aIter, XML_CHAPTER ) ) { bChapterIndex = true; } @@ -80,7 +78,7 @@ void XMLIndexSourceBaseContext::ProcessAttribute( case XML_ELEMENT(TEXT, XML_RELATIVE_TAB_STOP_POSITION): { bool bTmp(false); - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bRelativeTabs = bTmp; } @@ -89,7 +87,7 @@ void XMLIndexSourceBaseContext::ProcessAttribute( default: // unknown attribute -> ignore - XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttributeToken, rValue); + XMLOFF_WARN_UNKNOWN("xmloff", aIter); break; } } diff --git a/xmloff/source/text/XMLIndexSourceBaseContext.hxx b/xmloff/source/text/XMLIndexSourceBaseContext.hxx index 69568bf55390..5f8b060d58b1 100644 --- a/xmloff/source/text/XMLIndexSourceBaseContext.hxx +++ b/xmloff/source/text/XMLIndexSourceBaseContext.hxx @@ -60,9 +60,7 @@ protected: sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; - virtual void ProcessAttribute( - sal_Int32 nAttributeToken, - const OUString& rValue); + virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter); virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; diff --git a/xmloff/source/text/XMLIndexTOCSourceContext.cxx b/xmloff/source/text/XMLIndexTOCSourceContext.cxx index b07abee86015..45899e4543d2 100644 --- a/xmloff/source/text/XMLIndexTOCSourceContext.cxx +++ b/xmloff/source/text/XMLIndexTOCSourceContext.cxx @@ -53,14 +53,12 @@ XMLIndexTOCSourceContext::~XMLIndexTOCSourceContext() { } -void XMLIndexTOCSourceContext::ProcessAttribute( - sal_Int32 nAttributeToken, - const OUString& rValue) +void XMLIndexTOCSourceContext::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) { - switch (nAttributeToken) + switch (aIter.getToken()) { case XML_ELEMENT(TEXT, XML_OUTLINE_LEVEL): - if ( IsXMLToken( rValue, XML_NONE ) ) + if ( IsXMLToken( aIter, XML_NONE ) ) { // #104651# use OUTLINE_LEVEL and USE_OUTLINE_LEVEL instead of // OUTLINE_LEVEL with values none|1..10. For backwards @@ -71,7 +69,7 @@ void XMLIndexTOCSourceContext::ProcessAttribute( { sal_Int32 nTmp; if (::sax::Converter::convertNumber( - nTmp, rValue, 1, GetImport().GetTextImport()-> + nTmp, aIter.toView(), 1, GetImport().GetTextImport()-> GetChapterNumbering()->getCount())) { bUseOutline = true; @@ -83,7 +81,7 @@ void XMLIndexTOCSourceContext::ProcessAttribute( case XML_ELEMENT(TEXT, XML_USE_OUTLINE_LEVEL): { bool bTmp(false); - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseOutline = bTmp; } @@ -94,7 +92,7 @@ void XMLIndexTOCSourceContext::ProcessAttribute( case XML_ELEMENT(TEXT, XML_USE_INDEX_MARKS): { bool bTmp(false); - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseMarks = bTmp; } @@ -104,7 +102,7 @@ void XMLIndexTOCSourceContext::ProcessAttribute( case XML_ELEMENT(TEXT, XML_USE_INDEX_SOURCE_STYLES): { bool bTmp(false); - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseParagraphStyles = bTmp; } @@ -113,7 +111,7 @@ void XMLIndexTOCSourceContext::ProcessAttribute( default: // default: ask superclass - XMLIndexSourceBaseContext::ProcessAttribute(nAttributeToken, rValue); + XMLIndexSourceBaseContext::ProcessAttribute(aIter); break; } } diff --git a/xmloff/source/text/XMLIndexTOCSourceContext.hxx b/xmloff/source/text/XMLIndexTOCSourceContext.hxx index a52b07753ef2..6832695792dd 100644 --- a/xmloff/source/text/XMLIndexTOCSourceContext.hxx +++ b/xmloff/source/text/XMLIndexTOCSourceContext.hxx @@ -51,9 +51,7 @@ public: protected: - virtual void ProcessAttribute( - sal_Int32 nAttributeToken, - const OUString& rValue) override; + virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; diff --git a/xmloff/source/text/XMLIndexTableSourceContext.cxx b/xmloff/source/text/XMLIndexTableSourceContext.cxx index 0ecfa333d335..aae8e0388f18 100644 --- a/xmloff/source/text/XMLIndexTableSourceContext.cxx +++ b/xmloff/source/text/XMLIndexTableSourceContext.cxx @@ -72,30 +72,28 @@ SvXMLEnumMapEntry const lcl_aReferenceTypeTokenMap[] = { XML_TOKEN_INVALID, 0 } }; -void XMLIndexTableSourceContext::ProcessAttribute( - sal_Int32 nAttributeToken, - const OUString& rValue) +void XMLIndexTableSourceContext::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) { bool bTmp(false); - switch (nAttributeToken) + switch (aIter.getToken()) { case XML_ELEMENT(TEXT, XML_USE_CAPTION): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseCaption = bTmp; } break; case XML_ELEMENT(TEXT, XML_CAPTION_SEQUENCE_NAME): - sSequence = rValue; + sSequence = aIter.toString(); bSequenceOK = true; break; case XML_ELEMENT(TEXT, XML_CAPTION_SEQUENCE_FORMAT): { sal_uInt16 nTmp; - if (SvXMLUnitConverter::convertEnum(nTmp, rValue, + if (SvXMLUnitConverter::convertEnum(nTmp, aIter.toString(), lcl_aReferenceTypeTokenMap)) { nDisplayFormat = nTmp; @@ -105,7 +103,7 @@ void XMLIndexTableSourceContext::ProcessAttribute( } default: - XMLIndexSourceBaseContext::ProcessAttribute(nAttributeToken, rValue); + XMLIndexSourceBaseContext::ProcessAttribute(aIter); break; } } diff --git a/xmloff/source/text/XMLIndexTableSourceContext.hxx b/xmloff/source/text/XMLIndexTableSourceContext.hxx index 7fa62e735d22..96b677d96d22 100644 --- a/xmloff/source/text/XMLIndexTableSourceContext.hxx +++ b/xmloff/source/text/XMLIndexTableSourceContext.hxx @@ -52,9 +52,7 @@ public: protected: - virtual void ProcessAttribute( - sal_Int32 nAttributeToken, - const OUString& rValue) override; + virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; diff --git a/xmloff/source/text/XMLIndexUserSourceContext.cxx b/xmloff/source/text/XMLIndexUserSourceContext.cxx index 1201e9f5506e..392e8b72bc5f 100644 --- a/xmloff/source/text/XMLIndexUserSourceContext.cxx +++ b/xmloff/source/text/XMLIndexUserSourceContext.cxx @@ -54,69 +54,67 @@ XMLIndexUserSourceContext::~XMLIndexUserSourceContext() { } -void XMLIndexUserSourceContext::ProcessAttribute( - sal_Int32 nAttributeToken, - const OUString& rValue) +void XMLIndexUserSourceContext::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) { bool bTmp(false); - switch (nAttributeToken) + switch (aIter.getToken()) { case XML_ELEMENT(TEXT, XML_USE_INDEX_MARKS): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseMarks = bTmp; } break; case XML_ELEMENT(TEXT, XML_USE_OBJECTS): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseObjects = bTmp; } break; case XML_ELEMENT(TEXT, XML_USE_GRAPHICS): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseGraphic = bTmp; } break; case XML_ELEMENT(TEXT, XML_USE_TABLES): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseTables = bTmp; } break; case XML_ELEMENT(TEXT, XML_USE_FLOATING_FRAMES): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseFrames = bTmp; } break; case XML_ELEMENT(TEXT, XML_COPY_OUTLINE_LEVELS): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseLevelFromSource = bTmp; } break; case XML_ELEMENT(TEXT, XML_USE_INDEX_SOURCE_STYLES): - if (::sax::Converter::convertBool(bTmp, rValue)) + if (::sax::Converter::convertBool(bTmp, aIter.toView())) { bUseLevelParagraphStyles = bTmp; } break; case XML_ELEMENT(TEXT, XML_INDEX_NAME): - sIndexName = rValue; + sIndexName = aIter.toString(); break; default: - XMLIndexSourceBaseContext::ProcessAttribute(nAttributeToken, rValue); + XMLIndexSourceBaseContext::ProcessAttribute(aIter); break; } } diff --git a/xmloff/source/text/XMLIndexUserSourceContext.hxx b/xmloff/source/text/XMLIndexUserSourceContext.hxx index 8da6a7e4da30..46a448ad6118 100644 --- a/xmloff/source/text/XMLIndexUserSourceContext.hxx +++ b/xmloff/source/text/XMLIndexUserSourceContext.hxx @@ -54,9 +54,7 @@ public: protected: - virtual void ProcessAttribute( - sal_Int32 nAttributeToken, - const OUString& rValue) override; + virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; -- cgit