diff options
author | Noel <noelgrandin@gmail.com> | 2020-12-01 10:06:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-01 16:29:57 +0100 |
commit | 9dc284bb68d2648be6c1846df313519056a5b894 (patch) | |
tree | ee25b1cf612e2aea15f399355490f31ad40ed756 /xmloff | |
parent | 8601eca3c8573b433933ab59180624d798c6189e (diff) |
fastparser in XMLIndexSourceBaseContext
Change-Id: Iadb23ecac16438281a7301a2913fc393c3445cac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106931
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
14 files changed, 77 insertions, 87 deletions
diff --git a/xmloff/source/text/XMLIndexAlphabeticalSourceContext.cxx b/xmloff/source/text/XMLIndexAlphabeticalSourceContext.cxx index b6ed744129c8..08522e6aee81 100644 --- a/xmloff/source/text/XMLIndexAlphabeticalSourceContext.cxx +++ b/xmloff/source/text/XMLIndexAlphabeticalSourceContext.cxx @@ -40,8 +40,7 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; using ::com::sun::star::xml::sax::XAttributeList; using ::xmloff::token::IsXMLToken; -using ::xmloff::token::XML_ALPHABETICAL_INDEX_ENTRY_TEMPLATE; -using ::xmloff::token::XML_OUTLINE_LEVEL; +using namespace ::xmloff::token; XMLIndexAlphabeticalSourceContext::XMLIndexAlphabeticalSourceContext( SvXMLImport& rImport, @@ -64,14 +63,14 @@ XMLIndexAlphabeticalSourceContext::~XMLIndexAlphabeticalSourceContext() } void XMLIndexAlphabeticalSourceContext::ProcessAttribute( - enum IndexSourceParamEnum eParam, + sal_Int32 nAttributeToken, const OUString& rValue) { bool bTmp(false); - switch (eParam) + switch (nAttributeToken) { - case XML_TOK_INDEXSOURCE_MAIN_ENTRY_STYLE: + case XML_ELEMENT(TEXT, XML_MAIN_ENTRY_STYLE_NAME): { sMainEntryStyleName = rValue; OUString sDisplayStyleName = GetImport().GetStyleDisplayName( @@ -82,79 +81,79 @@ void XMLIndexAlphabeticalSourceContext::ProcessAttribute( } break; - case XML_TOK_INDEXSOURCE_IGNORE_CASE: + case XML_ELEMENT(TEXT, XML_IGNORE_CASE): if (::sax::Converter::convertBool(bTmp, rValue)) { bCaseSensitive = !bTmp; } break; - case XML_TOK_INDEXSOURCE_SEPARATORS: + case XML_ELEMENT(TEXT, XML_ALPHABETICAL_SEPARATORS): if (::sax::Converter::convertBool(bTmp, rValue)) { bSeparators = bTmp; } break; - case XML_TOK_INDEXSOURCE_COMBINE_ENTRIES: + case XML_ELEMENT(TEXT, XML_COMBINE_ENTRIES): if (::sax::Converter::convertBool(bTmp, rValue)) { bCombineEntries = bTmp; } break; - case XML_TOK_INDEXSOURCE_COMBINE_WITH_DASH: + case XML_ELEMENT(TEXT, XML_COMBINE_ENTRIES_WITH_DASH): if (::sax::Converter::convertBool(bTmp, rValue)) { bCombineDash = bTmp; } break; - case XML_TOK_INDEXSOURCE_KEYS_AS_ENTRIES: + case XML_ELEMENT(TEXT, XML_USE_KEYS_AS_ENTRIES): if (::sax::Converter::convertBool(bTmp, rValue)) { bEntry = bTmp; } break; - case XML_TOK_INDEXSOURCE_COMBINE_WITH_PP: + case XML_ELEMENT(TEXT, XML_COMBINE_ENTRIES_WITH_PP): if (::sax::Converter::convertBool(bTmp, rValue)) { bCombinePP = bTmp; } break; - case XML_TOK_INDEXSOURCE_CAPITALIZE: + case XML_ELEMENT(TEXT, XML_CAPITALIZE_ENTRIES): if (::sax::Converter::convertBool(bTmp, rValue)) { bUpperCase = bTmp; } break; - case XML_TOK_INDEXSOURCE_COMMA_SEPARATED: + case XML_ELEMENT(TEXT, XML_COMMA_SEPARATED): if (::sax::Converter::convertBool(bTmp, rValue)) { bCommaSeparated = bTmp; } break; - case XML_TOK_INDEXSOURCE_SORT_ALGORITHM: + case XML_ELEMENT(TEXT, XML_SORT_ALGORITHM): sAlgorithm = rValue; break; - case XML_TOK_INDEXSOURCE_RFC_LANGUAGE_TAG: + case XML_ELEMENT(STYLE, XML_RFC_LANGUAGE_TAG): maLanguageTagODF.maRfcLanguageTag = rValue; break; - case XML_TOK_INDEXSOURCE_LANGUAGE: + case XML_ELEMENT(FO, XML_LANGUAGE): maLanguageTagODF.maLanguage = rValue; break; - case XML_TOK_INDEXSOURCE_SCRIPT: + case XML_ELEMENT(FO, XML_SCRIPT): maLanguageTagODF.maScript = rValue; break; - case XML_TOK_INDEXSOURCE_COUNTRY: + case XML_ELEMENT(FO, XML_COUNTRY): maLanguageTagODF.maCountry = rValue; break; default: - XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue); + XMLIndexSourceBaseContext::ProcessAttribute(nAttributeToken, rValue); break; } } diff --git a/xmloff/source/text/XMLIndexAlphabeticalSourceContext.hxx b/xmloff/source/text/XMLIndexAlphabeticalSourceContext.hxx index ef4938b5be69..a3a4ceba80be 100644 --- a/xmloff/source/text/XMLIndexAlphabeticalSourceContext.hxx +++ b/xmloff/source/text/XMLIndexAlphabeticalSourceContext.hxx @@ -63,7 +63,7 @@ public: protected: virtual void ProcessAttribute( - enum IndexSourceParamEnum eParam, + sal_Int32 nAttributeToken, const OUString& rValue) 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 6ac60aece7ba..03d14efd9643 100644 --- a/xmloff/source/text/XMLIndexBibliographySourceContext.cxx +++ b/xmloff/source/text/XMLIndexBibliographySourceContext.cxx @@ -26,6 +26,7 @@ #include <xmloff/xmltoken.hxx> #include <xmloff/xmluconv.hxx> #include <rtl/ustring.hxx> +#include <sal/log.hxx> using namespace ::xmloff::token; @@ -48,10 +49,11 @@ XMLIndexBibliographySourceContext::~XMLIndexBibliographySourceContext() } void XMLIndexBibliographySourceContext::ProcessAttribute( - enum IndexSourceParamEnum, - const OUString&) + sal_Int32 nAttributeToken, + const OUString& rValue) { // We have no attributes. Who wants attributes, anyway? + XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttributeToken, rValue); } void XMLIndexBibliographySourceContext::endFastElement(sal_Int32 ) diff --git a/xmloff/source/text/XMLIndexBibliographySourceContext.hxx b/xmloff/source/text/XMLIndexBibliographySourceContext.hxx index bc02d9568b54..80fb3ea14f75 100644 --- a/xmloff/source/text/XMLIndexBibliographySourceContext.hxx +++ b/xmloff/source/text/XMLIndexBibliographySourceContext.hxx @@ -47,7 +47,7 @@ public: protected: virtual void ProcessAttribute( - enum IndexSourceParamEnum eParam, + sal_Int32 nAttributeToken, const OUString& rValue) 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 d73acd30b047..682300027b12 100644 --- a/xmloff/source/text/XMLIndexObjectSourceContext.cxx +++ b/xmloff/source/text/XMLIndexObjectSourceContext.cxx @@ -38,8 +38,7 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; using ::com::sun::star::xml::sax::XAttributeList; using ::xmloff::token::IsXMLToken; -using ::xmloff::token::XML_OBJECT_INDEX_ENTRY_TEMPLATE; -using ::xmloff::token::XML_TOKEN_INVALID; +using namespace ::xmloff::token; XMLIndexObjectSourceContext::XMLIndexObjectSourceContext( @@ -60,42 +59,42 @@ XMLIndexObjectSourceContext::~XMLIndexObjectSourceContext() } void XMLIndexObjectSourceContext::ProcessAttribute( - enum IndexSourceParamEnum eParam, + sal_Int32 nAttributeToken, const OUString& rValue) { bool bTmp(false); - switch (eParam) + switch (nAttributeToken) { - case XML_TOK_INDEXSOURCE_USE_OTHER_OBJECTS: + case XML_ELEMENT(TEXT, XML_USE_OTHER_OBJECTS): if (::sax::Converter::convertBool(bTmp, rValue)) { bUseOtherObjects = bTmp; } break; - case XML_TOK_INDEXSOURCE_USE_SHEET: + case XML_ELEMENT(TEXT, XML_USE_SPREADSHEET_OBJECTS): if (::sax::Converter::convertBool(bTmp, rValue)) { bUseCalc = bTmp; } break; - case XML_TOK_INDEXSOURCE_USE_CHART: + case XML_ELEMENT(TEXT, XML_USE_CHART_OBJECTS): if (::sax::Converter::convertBool(bTmp, rValue)) { bUseChart = bTmp; } break; - case XML_TOK_INDEXSOURCE_USE_DRAW: + case XML_ELEMENT(TEXT, XML_USE_DRAW_OBJECTS): if (::sax::Converter::convertBool(bTmp, rValue)) { bUseDraw = bTmp; } break; - case XML_TOK_INDEXSOURCE_USE_MATH: + case XML_ELEMENT(TEXT, XML_USE_MATH_OBJECTS): if (::sax::Converter::convertBool(bTmp, rValue)) { bUseMath = bTmp; @@ -103,7 +102,7 @@ void XMLIndexObjectSourceContext::ProcessAttribute( break; default: - XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue); + XMLIndexSourceBaseContext::ProcessAttribute(nAttributeToken, rValue); break; } } diff --git a/xmloff/source/text/XMLIndexObjectSourceContext.hxx b/xmloff/source/text/XMLIndexObjectSourceContext.hxx index 98f5c8c803b6..ca076d9fe899 100644 --- a/xmloff/source/text/XMLIndexObjectSourceContext.hxx +++ b/xmloff/source/text/XMLIndexObjectSourceContext.hxx @@ -53,7 +53,7 @@ public: protected: virtual void ProcessAttribute( - enum IndexSourceParamEnum eParam, + sal_Int32 nAttributeToken, const OUString& rValue) 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 c4c2a58f38c2..732e5a7f9a31 100644 --- a/xmloff/source/text/XMLIndexSourceBaseContext.cxx +++ b/xmloff/source/text/XMLIndexSourceBaseContext.cxx @@ -28,6 +28,7 @@ #include <xmloff/xmltoken.hxx> #include <sax/tools/converter.hxx> #include <rtl/ustring.hxx> +#include <sal/log.hxx> using namespace ::xmloff::token; @@ -154,41 +155,29 @@ XMLIndexSourceBaseContext::~XMLIndexSourceBaseContext() { } -void XMLIndexSourceBaseContext::StartElement( - const Reference<XAttributeList> & xAttrList) +void XMLIndexSourceBaseContext::startFastElement( + sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - static const SvXMLTokenMap aTokenMap(aIndexSourceTokenMap); - // process attributes - sal_Int16 nLength = xAttrList->getLength(); - for(sal_Int16 i=0; i<nLength; i++) - { - // map to IndexSourceParamEnum - OUString sLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). - GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName ); - sal_uInt16 nToken = aTokenMap.Get(nPrefix, sLocalName); - - // process attribute - ProcessAttribute(static_cast<enum IndexSourceParamEnum>(nToken), - xAttrList->getValueByIndex(i)); - } + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) + ProcessAttribute(aIter.getToken(), aIter.toString()); } void XMLIndexSourceBaseContext::ProcessAttribute( - enum IndexSourceParamEnum eParam, + sal_Int32 nAttributeToken, const OUString& rValue) { - switch (eParam) + switch (nAttributeToken) { - case XML_TOK_INDEXSOURCE_INDEX_SCOPE: + case XML_ELEMENT(TEXT, XML_INDEX_SCOPE): if ( IsXMLToken( rValue, XML_CHAPTER ) ) { bChapterIndex = true; } break; - case XML_TOK_INDEXSOURCE_RELATIVE_TABS: + case XML_ELEMENT(TEXT, XML_RELATIVE_TAB_STOP_POSITION): { bool bTmp(false); if (::sax::Converter::convertBool(bTmp, rValue)) @@ -200,6 +189,7 @@ void XMLIndexSourceBaseContext::ProcessAttribute( default: // unknown attribute -> ignore + XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttributeToken, rValue); break; } } diff --git a/xmloff/source/text/XMLIndexSourceBaseContext.hxx b/xmloff/source/text/XMLIndexSourceBaseContext.hxx index 2e1fb871baa7..b312bff1a712 100644 --- a/xmloff/source/text/XMLIndexSourceBaseContext.hxx +++ b/xmloff/source/text/XMLIndexSourceBaseContext.hxx @@ -96,11 +96,12 @@ public: protected: - virtual void StartElement( - const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override; + virtual void SAL_CALL startFastElement( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; virtual void ProcessAttribute( - enum IndexSourceParamEnum eParam, + sal_Int32 nAttributeToken, const OUString& rValue); virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; diff --git a/xmloff/source/text/XMLIndexTOCSourceContext.cxx b/xmloff/source/text/XMLIndexTOCSourceContext.cxx index 62b05e0635ba..b07abee86015 100644 --- a/xmloff/source/text/XMLIndexTOCSourceContext.cxx +++ b/xmloff/source/text/XMLIndexTOCSourceContext.cxx @@ -54,12 +54,12 @@ XMLIndexTOCSourceContext::~XMLIndexTOCSourceContext() } void XMLIndexTOCSourceContext::ProcessAttribute( - enum IndexSourceParamEnum eParam, + sal_Int32 nAttributeToken, const OUString& rValue) { - switch (eParam) + switch (nAttributeToken) { - case XML_TOK_INDEXSOURCE_OUTLINE_LEVEL: + case XML_ELEMENT(TEXT, XML_OUTLINE_LEVEL): if ( IsXMLToken( rValue, XML_NONE ) ) { // #104651# use OUTLINE_LEVEL and USE_OUTLINE_LEVEL instead of @@ -80,7 +80,7 @@ void XMLIndexTOCSourceContext::ProcessAttribute( } break; - case XML_TOK_INDEXSOURCE_USE_OUTLINE_LEVEL: + case XML_ELEMENT(TEXT, XML_USE_OUTLINE_LEVEL): { bool bTmp(false); if (::sax::Converter::convertBool(bTmp, rValue)) @@ -91,7 +91,7 @@ void XMLIndexTOCSourceContext::ProcessAttribute( } - case XML_TOK_INDEXSOURCE_USE_INDEX_MARKS: + case XML_ELEMENT(TEXT, XML_USE_INDEX_MARKS): { bool bTmp(false); if (::sax::Converter::convertBool(bTmp, rValue)) @@ -101,7 +101,7 @@ void XMLIndexTOCSourceContext::ProcessAttribute( break; } - case XML_TOK_INDEXSOURCE_USE_INDEX_SOURCE_STYLES: + case XML_ELEMENT(TEXT, XML_USE_INDEX_SOURCE_STYLES): { bool bTmp(false); if (::sax::Converter::convertBool(bTmp, rValue)) @@ -113,7 +113,7 @@ void XMLIndexTOCSourceContext::ProcessAttribute( default: // default: ask superclass - XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue); + XMLIndexSourceBaseContext::ProcessAttribute(nAttributeToken, rValue); break; } } diff --git a/xmloff/source/text/XMLIndexTOCSourceContext.hxx b/xmloff/source/text/XMLIndexTOCSourceContext.hxx index 7a0897eca7c1..a52b07753ef2 100644 --- a/xmloff/source/text/XMLIndexTOCSourceContext.hxx +++ b/xmloff/source/text/XMLIndexTOCSourceContext.hxx @@ -52,7 +52,7 @@ public: protected: virtual void ProcessAttribute( - enum IndexSourceParamEnum eParam, + sal_Int32 nAttributeToken, const OUString& rValue) 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 87f06dc6eb2b..0ecfa333d335 100644 --- a/xmloff/source/text/XMLIndexTableSourceContext.cxx +++ b/xmloff/source/text/XMLIndexTableSourceContext.cxx @@ -73,26 +73,26 @@ SvXMLEnumMapEntry<sal_uInt16> const lcl_aReferenceTypeTokenMap[] = }; void XMLIndexTableSourceContext::ProcessAttribute( - enum IndexSourceParamEnum eParam, + sal_Int32 nAttributeToken, const OUString& rValue) { bool bTmp(false); - switch (eParam) + switch (nAttributeToken) { - case XML_TOK_INDEXSOURCE_USE_CAPTION: + case XML_ELEMENT(TEXT, XML_USE_CAPTION): if (::sax::Converter::convertBool(bTmp, rValue)) { bUseCaption = bTmp; } break; - case XML_TOK_INDEXSOURCE_SEQUENCE_NAME: + case XML_ELEMENT(TEXT, XML_CAPTION_SEQUENCE_NAME): sSequence = rValue; bSequenceOK = true; break; - case XML_TOK_INDEXSOURCE_SEQUENCE_FORMAT: + case XML_ELEMENT(TEXT, XML_CAPTION_SEQUENCE_FORMAT): { sal_uInt16 nTmp; if (SvXMLUnitConverter::convertEnum(nTmp, rValue, @@ -105,7 +105,7 @@ void XMLIndexTableSourceContext::ProcessAttribute( } default: - XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue); + XMLIndexSourceBaseContext::ProcessAttribute(nAttributeToken, rValue); break; } } diff --git a/xmloff/source/text/XMLIndexTableSourceContext.hxx b/xmloff/source/text/XMLIndexTableSourceContext.hxx index 624480f780b4..7fa62e735d22 100644 --- a/xmloff/source/text/XMLIndexTableSourceContext.hxx +++ b/xmloff/source/text/XMLIndexTableSourceContext.hxx @@ -53,7 +53,7 @@ public: protected: virtual void ProcessAttribute( - enum IndexSourceParamEnum eParam, + sal_Int32 nAttributeToken, const OUString& rValue) 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 df6239b95755..1201e9f5506e 100644 --- a/xmloff/source/text/XMLIndexUserSourceContext.cxx +++ b/xmloff/source/text/XMLIndexUserSourceContext.cxx @@ -33,8 +33,7 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; using ::com::sun::star::xml::sax::XAttributeList; using ::xmloff::token::IsXMLToken; -using ::xmloff::token::XML_USER_INDEX_ENTRY_TEMPLATE; -using ::xmloff::token::XML_OUTLINE_LEVEL; +using namespace ::xmloff::token; XMLIndexUserSourceContext::XMLIndexUserSourceContext( SvXMLImport& rImport, @@ -56,68 +55,68 @@ XMLIndexUserSourceContext::~XMLIndexUserSourceContext() } void XMLIndexUserSourceContext::ProcessAttribute( - enum IndexSourceParamEnum eParam, + sal_Int32 nAttributeToken, const OUString& rValue) { bool bTmp(false); - switch (eParam) + switch (nAttributeToken) { - case XML_TOK_INDEXSOURCE_USE_INDEX_MARKS: + case XML_ELEMENT(TEXT, XML_USE_INDEX_MARKS): if (::sax::Converter::convertBool(bTmp, rValue)) { bUseMarks = bTmp; } break; - case XML_TOK_INDEXSOURCE_USE_OBJECTS: + case XML_ELEMENT(TEXT, XML_USE_OBJECTS): if (::sax::Converter::convertBool(bTmp, rValue)) { bUseObjects = bTmp; } break; - case XML_TOK_INDEXSOURCE_USE_GRAPHICS: + case XML_ELEMENT(TEXT, XML_USE_GRAPHICS): if (::sax::Converter::convertBool(bTmp, rValue)) { bUseGraphic = bTmp; } break; - case XML_TOK_INDEXSOURCE_USE_TABLES: + case XML_ELEMENT(TEXT, XML_USE_TABLES): if (::sax::Converter::convertBool(bTmp, rValue)) { bUseTables = bTmp; } break; - case XML_TOK_INDEXSOURCE_USE_FRAMES: + case XML_ELEMENT(TEXT, XML_USE_FLOATING_FRAMES): if (::sax::Converter::convertBool(bTmp, rValue)) { bUseFrames = bTmp; } break; - case XML_TOK_INDEXSOURCE_COPY_OUTLINE_LEVELS: + case XML_ELEMENT(TEXT, XML_COPY_OUTLINE_LEVELS): if (::sax::Converter::convertBool(bTmp, rValue)) { bUseLevelFromSource = bTmp; } break; - case XML_TOK_INDEXSOURCE_USE_INDEX_SOURCE_STYLES: + case XML_ELEMENT(TEXT, XML_USE_INDEX_SOURCE_STYLES): if (::sax::Converter::convertBool(bTmp, rValue)) { bUseLevelParagraphStyles = bTmp; } break; - case XML_TOK_INDEXSOURCE_USER_INDEX_NAME: + case XML_ELEMENT(TEXT, XML_INDEX_NAME): sIndexName = rValue; break; default: - XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue); + XMLIndexSourceBaseContext::ProcessAttribute(nAttributeToken, rValue); break; } } diff --git a/xmloff/source/text/XMLIndexUserSourceContext.hxx b/xmloff/source/text/XMLIndexUserSourceContext.hxx index f2f9151bc6c1..8da6a7e4da30 100644 --- a/xmloff/source/text/XMLIndexUserSourceContext.hxx +++ b/xmloff/source/text/XMLIndexUserSourceContext.hxx @@ -55,7 +55,7 @@ public: protected: virtual void ProcessAttribute( - enum IndexSourceParamEnum eParam, + sal_Int32 nAttributeToken, const OUString& rValue) override; virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; |