xmloff/inc/XMLFootnoteConfigurationImportContext.hxx | 11 - xmloff/source/style/xmlstyle.cxx | 10 - xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx | 75 +++-------- 3 files changed, 35 insertions(+), 61 deletions(-)
New commits: commit 6dcdf182e773d11f959c5dca1c5a6b9d8205bdee Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Aug 21 09:55:25 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Aug 21 18:52:38 2020 +0200 use fast-parser in XMLFootnoteConfigurationImportContext Change-Id: Ic139ef9956f59178582a344f65926f95a6423f14 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101149 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/xmloff/inc/XMLFootnoteConfigurationImportContext.hxx b/xmloff/inc/XMLFootnoteConfigurationImportContext.hxx index 5cbae1fda6d6..04cc2c8bc17a 100644 --- a/xmloff/inc/XMLFootnoteConfigurationImportContext.hxx +++ b/xmloff/inc/XMLFootnoteConfigurationImportContext.hxx @@ -60,17 +60,14 @@ public: XMLFootnoteConfigurationImportContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList); + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList> & xAttrList); virtual ~XMLFootnoteConfigurationImportContext() override; /// for footnotes, also parse begin and end notices - virtual SvXMLImportContextRef CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const css::uno::Reference< css::xml::sax::XAttributeList> & 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; /// get token map for attributes const SvXMLTokenMap& GetFtnConfigAttrTokenMap(); diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index d91180681e89..2a98fbfaf509 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -420,6 +420,10 @@ SvXMLStyleContext *SvXMLStylesContext::CreateStyleChildContext( pStyle = new XMLIndexBibliographyConfigurationContext( GetImport(), nElement, xAttrList); break; + case XML_ELEMENT(TEXT, XML_NOTES_CONFIGURATION): + pStyle = new XMLFootnoteConfigurationImportContext( + GetImport(), nElement, xAttrList); + break; } return pStyle; @@ -481,12 +485,6 @@ SvXMLStyleContext *SvXMLStylesContext::CreateStyleChildContext( sal_uInt16 p_nPr pStyle = new SvxXMLListStyleContext( GetImport(), p_nPrefix, rLocalName, xAttrList, true ); break; - case XML_TOK_TEXT_NOTE_CONFIG: - pStyle = new XMLFootnoteConfigurationImportContext(GetImport(), - p_nPrefix, - rLocalName, - xAttrList); - break; case XML_TOK_TEXT_LINENUMBERING_CONFIG: pStyle = new XMLLineNumberingImportContext( diff --git a/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx b/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx index ea03a0589969..ad96aee7976d 100644 --- a/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx +++ b/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx @@ -65,32 +65,30 @@ public: XMLFootnoteConfigHelper( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, XMLFootnoteConfigurationImportContext& rConfigImport, bool bBegin); - virtual void EndElement() override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; - virtual void Characters( const OUString& rChars ) override; + virtual void SAL_CALL characters( const OUString& rChars ) override; }; } XMLFootnoteConfigHelper::XMLFootnoteConfigHelper( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLName, XMLFootnoteConfigurationImportContext& rConfigImport, bool bBegin) -: SvXMLImportContext(rImport, nPrfx, rLName) +: SvXMLImportContext(rImport) , sBuffer() , rConfig(rConfigImport) , bIsBegin(bBegin) { } -void XMLFootnoteConfigHelper::EndElement() +void XMLFootnoteConfigHelper::endFastElement(sal_Int32 ) { if (bIsBegin) { @@ -103,7 +101,7 @@ void XMLFootnoteConfigHelper::EndElement() // rConfig = NULL; // import contexts are ref-counted } -void XMLFootnoteConfigHelper::Characters( const OUString& rChars ) +void XMLFootnoteConfigHelper::characters( const OUString& rChars ) { sBuffer.append(rChars); } @@ -126,10 +124,9 @@ const OUStringLiteral gsPropertyBeginNotice("BeginNotice"); XMLFootnoteConfigurationImportContext::XMLFootnoteConfigurationImportContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLocalName, - const Reference<XAttributeList> & xAttrList) -: SvXMLStyleContext(rImport, nPrfx, rLocalName, xAttrList, XmlStyleFamily::TEXT_FOOTNOTECONFIG) + sal_Int32 nElement, + const Reference<XFastAttributeList> & xAttrList) +: SvXMLStyleContext(rImport, nElement, xAttrList, XmlStyleFamily::TEXT_FOOTNOTECONFIG) , sNumFormat("1") , sNumSync("false") , nOffset(0) @@ -137,18 +134,11 @@ XMLFootnoteConfigurationImportContext::XMLFootnoteConfigurationImportContext( , bPosition(false) , bIsEndnote(false) { - 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( XML_NAMESPACE_TEXT == nPrefix && IsXMLToken( sLocalName, - XML_NOTE_CLASS ) ) + if( aIter.getToken() == XML_ELEMENT(TEXT, XML_NOTE_CLASS) ) { - const OUString& rValue = xAttrList->getValueByIndex( nAttr ); - if( IsXMLToken( rValue, XML_ENDNOTE ) ) + if( IsXMLToken(aIter.toString(), XML_ENDNOTE ) ) { bIsEndnote = true; SetFamily( XmlStyleFamily::TEXT_FOOTNOTECONFIG ); @@ -274,34 +264,23 @@ void XMLFootnoteConfigurationImportContext::SetAttribute( sal_uInt16 nPrefixKey, } } -SvXMLImportContextRef XMLFootnoteConfigurationImportContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference<XAttributeList> & ) +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLFootnoteConfigurationImportContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) { - SvXMLImportContextRef xContext; + css::uno::Reference< css::xml::sax::XFastContextHandler > xContext; - if (!bIsEndnote) + if (bIsEndnote) + return nullptr; + + switch (nElement) { - if (XML_NAMESPACE_TEXT == nPrefix) - { - if ( IsXMLToken( rLocalName, - XML_FOOTNOTE_CONTINUATION_NOTICE_FORWARD ) ) - { - xContext = new XMLFootnoteConfigHelper(GetImport(), - nPrefix, rLocalName, - *this, false); - } - else if ( IsXMLToken( rLocalName, - XML_FOOTNOTE_CONTINUATION_NOTICE_BACKWARD ) ) - { - xContext = new XMLFootnoteConfigHelper(GetImport(), - nPrefix, rLocalName, - *this, true); - } - // else: default context - } - // else: unknown namespace -> default context + case XML_ELEMENT(TEXT, XML_FOOTNOTE_CONTINUATION_NOTICE_FORWARD): + xContext = new XMLFootnoteConfigHelper(GetImport(), *this, false); + break; + case XML_ELEMENT(TEXT, XML_FOOTNOTE_CONTINUATION_NOTICE_BACKWARD): + xContext = new XMLFootnoteConfigHelper(GetImport(), *this, true); + break; } return xContext; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits