diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-11-30 20:29:55 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-01 08:22:38 +0100 |
commit | 445d56983863a739797dfb940483c209c764e8d6 (patch) | |
tree | 3d53e3bb3298db7f1d03b420203cfdc5c5657164 /xmloff | |
parent | c96f5272964f199fc4ade670be30a87b931e85e0 (diff) |
fastparser in XMLSectionSourceImportContext
Change-Id: I7c716342617486b63a4ae15fb71f3bf794165011
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106913
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/text/XMLSectionImportContext.cxx | 1 | ||||
-rw-r--r-- | xmloff/source/text/XMLSectionSourceImportContext.cxx | 52 | ||||
-rw-r--r-- | xmloff/source/text/XMLSectionSourceImportContext.hxx | 11 |
3 files changed, 15 insertions, 49 deletions
diff --git a/xmloff/source/text/XMLSectionImportContext.cxx b/xmloff/source/text/XMLSectionImportContext.cxx index c4ca75ba06d6..2ed3f5b23a9a 100644 --- a/xmloff/source/text/XMLSectionImportContext.cxx +++ b/xmloff/source/text/XMLSectionImportContext.cxx @@ -341,7 +341,6 @@ SvXMLImportContextRef XMLSectionImportContext::CreateChildContext( IsXMLToken(rLocalName, XML_SECTION_SOURCE) ) { pContext = new XMLSectionSourceImportContext(GetImport(), - nPrefix, rLocalName, xSectionPropertySet); } else if ( (XML_NAMESPACE_OFFICE == nPrefix) && diff --git a/xmloff/source/text/XMLSectionSourceImportContext.cxx b/xmloff/source/text/XMLSectionSourceImportContext.cxx index 0ceb68eda53d..c24ffd9e912e 100644 --- a/xmloff/source/text/XMLSectionSourceImportContext.cxx +++ b/xmloff/source/text/XMLSectionSourceImportContext.cxx @@ -40,10 +40,8 @@ using namespace ::xmloff::token; XMLSectionSourceImportContext::XMLSectionSourceImportContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLocalName, Reference<XPropertySet> & rSectPropSet) : - SvXMLImportContext(rImport, nPrfx, rLocalName), + SvXMLImportContext(rImport), rSectionPropertySet(rSectPropSet) { } @@ -52,54 +50,28 @@ XMLSectionSourceImportContext::~XMLSectionSourceImportContext() { } -namespace { -enum XMLSectionSourceToken +void XMLSectionSourceImportContext::startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - XML_TOK_SECTION_XLINK_HREF, - XML_TOK_SECTION_TEXT_FILTER_NAME, - XML_TOK_SECTION_TEXT_SECTION_NAME -}; - -} - -const SvXMLTokenMapEntry aSectionSourceTokenMap[] = -{ - { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_SECTION_XLINK_HREF }, - { XML_NAMESPACE_TEXT, XML_FILTER_NAME, XML_TOK_SECTION_TEXT_FILTER_NAME }, - { XML_NAMESPACE_TEXT, XML_SECTION_NAME, - XML_TOK_SECTION_TEXT_SECTION_NAME }, - XML_TOKEN_MAP_END -}; - - -void XMLSectionSourceImportContext::StartElement( - const Reference<XAttributeList> & xAttrList) -{ - static const SvXMLTokenMap aTokenMap(aSectionSourceTokenMap); OUString sURL; OUString sFilterName; OUString sSectionName; - 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 ); - - switch (aTokenMap.Get(nPrefix, sLocalName)) + OUString sValue = aIter.toString(); + switch (aIter.getToken()) { - case XML_TOK_SECTION_XLINK_HREF: - sURL = xAttrList->getValueByIndex(nAttr); + case XML_ELEMENT(XLINK, XML_HREF): + sURL = sValue; break; - case XML_TOK_SECTION_TEXT_FILTER_NAME: - sFilterName = xAttrList->getValueByIndex(nAttr); + case XML_ELEMENT(TEXT, XML_FILTER_NAME): + sFilterName = sValue; break; - case XML_TOK_SECTION_TEXT_SECTION_NAME: - sSectionName = xAttrList->getValueByIndex(nAttr); + case XML_ELEMENT(TEXT, XML_SECTION_NAME): + sSectionName = sValue; break; default: diff --git a/xmloff/source/text/XMLSectionSourceImportContext.hxx b/xmloff/source/text/XMLSectionSourceImportContext.hxx index 33fb2e966291..b426b81acc38 100644 --- a/xmloff/source/text/XMLSectionSourceImportContext.hxx +++ b/xmloff/source/text/XMLSectionSourceImportContext.hxx @@ -28,25 +28,20 @@ namespace com::sun::star { namespace xml::sax { class XAttributeList; } } -class XMLSectionSourceImportContext : public SvXMLImportContext +class XMLSectionSourceImportContext final : public SvXMLImportContext { css::uno::Reference<css::beans::XPropertySet> & rSectionPropertySet; public: - XMLSectionSourceImportContext( SvXMLImport& rImport, - sal_uInt16 nPrfx, - const OUString& rLocalName, css::uno::Reference<css::beans::XPropertySet> & rSectPropSet); virtual ~XMLSectionSourceImportContext() override; -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; }; #endif |