From 818be5ed71d6c4eb515c907add4179100eed6072 Mon Sep 17 00:00:00 2001 From: Noel Date: Fri, 27 Nov 2020 14:56:19 +0200 Subject: fastparser in XMLFootnoteBodyImportContext Change-Id: Id822765b23c7251f89f2c3f24136cf5f14762449 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106769 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../source/text/XMLFootnoteBodyImportContext.cxx | 7 ++-- .../source/text/XMLFootnoteBodyImportContext.hxx | 6 +--- xmloff/source/text/XMLFootnoteImportContext.cxx | 38 ++++++++-------------- xmloff/source/text/XMLFootnoteImportContext.hxx | 6 ++-- 4 files changed, 19 insertions(+), 38 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/text/XMLFootnoteBodyImportContext.cxx b/xmloff/source/text/XMLFootnoteBodyImportContext.cxx index dc560f624c10..8b0268318355 100644 --- a/xmloff/source/text/XMLFootnoteBodyImportContext.cxx +++ b/xmloff/source/text/XMLFootnoteBodyImportContext.cxx @@ -28,11 +28,8 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::xml::sax::XAttributeList; -XMLFootnoteBodyImportContext::XMLFootnoteBodyImportContext( - SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLocalName ) : - SvXMLImportContext(rImport, nPrfx, rLocalName) +XMLFootnoteBodyImportContext::XMLFootnoteBodyImportContext( SvXMLImport& rImport ) : + SvXMLImportContext(rImport) { } diff --git a/xmloff/source/text/XMLFootnoteBodyImportContext.hxx b/xmloff/source/text/XMLFootnoteBodyImportContext.hxx index 647867a5cdcf..19007558899e 100644 --- a/xmloff/source/text/XMLFootnoteBodyImportContext.hxx +++ b/xmloff/source/text/XMLFootnoteBodyImportContext.hxx @@ -37,11 +37,7 @@ class XMLFootnoteBodyImportContext : public SvXMLImportContext public: - - XMLFootnoteBodyImportContext( - SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLocalName ); + XMLFootnoteBodyImportContext( SvXMLImport& rImport ); protected: diff --git a/xmloff/source/text/XMLFootnoteImportContext.cxx b/xmloff/source/text/XMLFootnoteImportContext.cxx index 645e910c8a36..95a30097675e 100644 --- a/xmloff/source/text/XMLFootnoteImportContext.cxx +++ b/xmloff/source/text/XMLFootnoteImportContext.cxx @@ -34,6 +34,7 @@ #include #include #include +#include using namespace ::com::sun::star::uno; @@ -164,49 +165,38 @@ void XMLFootnoteImportContext::endFastElement(sal_Int32 ) } } -SvXMLImportContextRef XMLFootnoteImportContext::CreateChildContext( - sal_uInt16 p_nPrefix, - const OUString& rLocalName, - const Reference & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLFootnoteImportContext::createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContextRef xContext; - static const SvXMLTokenMap aTokenMap(aFootnoteChildTokenMap); - - switch(aTokenMap.Get(p_nPrefix, rLocalName)) + switch(nElement) { - case XML_TOK_FTN_NOTE_CITATION: + case XML_ELEMENT(TEXT, XML_NOTE_CITATION): { // little hack: we only care for one attribute of the citation // element. We handle that here, and then return a // default context. - sal_Int16 nLength = xAttrList->getLength(); - for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - OUString sLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). - GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), - &sLocalName ); - - if ( (nPrefix == XML_NAMESPACE_TEXT) && - IsXMLToken( sLocalName, XML_LABEL ) ) - { - xFootnote->setLabel(xAttrList->getValueByIndex(nAttr)); - } + if ( aIter.getToken() == XML_ELEMENT(TEXT, XML_LABEL) ) + xFootnote->setLabel(aIter.toString()); } // ignore content: return default context break; } - case XML_TOK_FTN_NOTE_BODY: + case XML_ELEMENT(TEXT, XML_NOTE_BODY): // return footnote body - xContext = new XMLFootnoteBodyImportContext(GetImport(), - p_nPrefix, rLocalName); + xContext = new XMLFootnoteBodyImportContext(GetImport()); break; + + default: + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); } - return xContext; + return xContext.get(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/text/XMLFootnoteImportContext.hxx b/xmloff/source/text/XMLFootnoteImportContext.hxx index 72ad330c876a..ff2acc296988 100644 --- a/xmloff/source/text/XMLFootnoteImportContext.hxx +++ b/xmloff/source/text/XMLFootnoteImportContext.hxx @@ -66,10 +66,8 @@ protected: virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; - virtual SvXMLImportContextRef CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference & xAttrList ) override; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override; }; -- cgit