diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-11-24 20:45:40 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-11-25 10:15:10 +0100 |
commit | 6993d5d0f1079fe720a7da004b70b57361c99fc6 (patch) | |
tree | 5a4c3d85cba60c61c64910755ed00bc2e517a84e /xmloff | |
parent | b3dd7ebdab8015735dd07afdf518500bbc69a1b3 (diff) |
fastparser in XMLTextListBlockContext
Change-Id: I0225bf1196fa951909fefbaf14b3b840605fd5ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106551
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/text/XMLTextListBlockContext.cxx | 19 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextListBlockContext.hxx | 6 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextListItemContext.cxx | 32 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextListItemContext.hxx | 4 |
4 files changed, 24 insertions, 37 deletions
diff --git a/xmloff/source/text/XMLTextListBlockContext.cxx b/xmloff/source/text/XMLTextListBlockContext.cxx index 3fcdca9d25a9..57065a923a0c 100644 --- a/xmloff/source/text/XMLTextListBlockContext.cxx +++ b/xmloff/source/text/XMLTextListBlockContext.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <xmloff/xmlimp.hxx> #include <xmloff/namespacemap.hxx> +#include <xmloff/xmlnamespace.hxx> #include <xmloff/xmltoken.hxx> #include "XMLTextListItemContext.hxx" #include "XMLTextListBlockContext.hxx" @@ -247,26 +248,24 @@ void XMLTextListBlockContext::endFastElement(sal_Int32 ) mrTxtImport.GetTextListHelper().SetListItem( nullptr ); } -SvXMLImportContextRef XMLTextListBlockContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, - const Reference< xml::sax::XAttributeList > & xAttrList ) +css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTextListBlockContext::createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { SvXMLImportContext *pContext = nullptr; - const SvXMLTokenMap& rTokenMap = - mrTxtImport.GetTextListBlockElemTokenMap(); bool bHeader = false; - switch( rTokenMap.Get( nPrefix, rLocalName ) ) + switch( nElement ) { - case XML_TOK_TEXT_LIST_HEADER: + case XML_ELEMENT(TEXT, XML_LIST_HEADER): bHeader = true; [[fallthrough]]; - case XML_TOK_TEXT_LIST_ITEM: + case XML_ELEMENT(TEXT, XML_LIST_ITEM): pContext = new XMLTextListItemContext( GetImport(), mrTxtImport, - nPrefix, rLocalName, xAttrList, bHeader ); break; + default: + XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); } diff --git a/xmloff/source/text/XMLTextListBlockContext.hxx b/xmloff/source/text/XMLTextListBlockContext.hxx index c5c0182997c1..c26ef5a6ccba 100644 --- a/xmloff/source/text/XMLTextListBlockContext.hxx +++ b/xmloff/source/text/XMLTextListBlockContext.hxx @@ -60,9 +60,9 @@ public: virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; - 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 >& xAttrList ) override; sal_Int16 GetLevel() const { return mnLevel; } bool IsRestartNumbering() const { return mbRestartNumbering; } diff --git a/xmloff/source/text/XMLTextListItemContext.cxx b/xmloff/source/text/XMLTextListItemContext.cxx index 7f7886648e16..f11744d2de9a 100644 --- a/xmloff/source/text/XMLTextListItemContext.cxx +++ b/xmloff/source/text/XMLTextListItemContext.cxx @@ -31,6 +31,7 @@ #include <xmloff/xmlnumi.hxx> #include <xmloff/ProgressBarHelper.hxx> #include "XMLTextListItemContext.hxx" +#include <sal/log.hxx> using namespace ::com::sun::star; @@ -41,37 +42,25 @@ using namespace ::xmloff::token; XMLTextListItemContext::XMLTextListItemContext( SvXMLImport& rImport, XMLTextImportHelper& rTxtImp, - const sal_uInt16 nPrfx, - const OUString& rLName, - const Reference< xml::sax::XAttributeList > & xAttrList, + const Reference< xml::sax::XFastAttributeList > & xAttrList, const bool bIsHeader ) - : SvXMLImportContext( rImport, nPrfx, rLName ), + : SvXMLImportContext( rImport ), rTxtImport( rTxtImp ), nStartValue( -1 ), mnSubListCount( 0 ), mxNumRulesOverride() { - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; i++ ) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - const OUString& rAttrName = xAttrList->getNameByIndex( i ); - const OUString& rValue = xAttrList->getValueByIndex( i ); - - OUString aLocalName; - sal_uInt16 nPrefix = - GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, - &aLocalName ); - if( !bIsHeader && XML_NAMESPACE_TEXT == nPrefix && - IsXMLToken( aLocalName, XML_START_VALUE ) ) + if( !bIsHeader && aIter.getToken() == XML_ELEMENT(TEXT, XML_START_VALUE) ) { - sal_Int32 nTmp = rValue.toInt32(); + sal_Int32 nTmp = aIter.toInt32(); if( nTmp >= 0 && nTmp <= SHRT_MAX ) nStartValue = static_cast<sal_Int16>(nTmp); } - else if ( nPrefix == XML_NAMESPACE_TEXT && - IsXMLToken( aLocalName, XML_STYLE_OVERRIDE ) ) + else if ( aIter.getToken() == XML_ELEMENT(TEXT, XML_STYLE_OVERRIDE) ) { - const OUString& sListStyleOverrideName = rValue; + OUString sListStyleOverrideName = aIter.toString(); if ( !sListStyleOverrideName.isEmpty() ) { OUString sDisplayStyleName( @@ -105,11 +94,12 @@ XMLTextListItemContext::XMLTextListItemContext( } } } - else if ( (XML_NAMESPACE_XML == nPrefix) && - IsXMLToken(aLocalName, XML_ID) ) + else if ( aIter.getToken() == XML_ELEMENT(XML, XML_ID) ) { //FIXME: there is no UNO API for list items } + else + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } // If this is a <text:list-item> element, then remember it as a sign diff --git a/xmloff/source/text/XMLTextListItemContext.hxx b/xmloff/source/text/XMLTextListItemContext.hxx index 09c1b7f3727a..40768d2d02e8 100644 --- a/xmloff/source/text/XMLTextListItemContext.hxx +++ b/xmloff/source/text/XMLTextListItemContext.hxx @@ -43,9 +43,7 @@ public: XMLTextListItemContext( SvXMLImport& rImport, XMLTextImportHelper& rTxtImp, - const sal_uInt16 nPrfx, - const OUString& rLName, - const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList, const bool bIsHeader ); virtual ~XMLTextListItemContext() override; |