diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-11-30 20:25:50 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-01 07:58:46 +0100 |
commit | c96f5272964f199fc4ade670be30a87b931e85e0 (patch) | |
tree | 683acf9eca8e8c9349b09234d51fca5775e40aa4 /xmloff/source | |
parent | 7f9215bb187f796537660e43ca6273c4fa5e28fa (diff) |
fastparser in XMLTextMarkImportContext
Change-Id: Iaa785b71ef64fd172f02f83ee1c8e9ac89dd13cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106912
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff/source')
-rw-r--r-- | xmloff/source/text/XMLTextMarkImportContext.cxx | 83 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextMarkImportContext.hxx | 11 |
2 files changed, 39 insertions, 55 deletions
diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx index ef1fa9556c0a..7d53c7b5af4d 100644 --- a/xmloff/source/text/XMLTextMarkImportContext.cxx +++ b/xmloff/source/text/XMLTextMarkImportContext.cxx @@ -148,15 +148,16 @@ static OUString lcl_getFieldmarkName(OUString const& name) } -void XMLTextMarkImportContext::StartElement( - const Reference<XAttributeList> & xAttrList) +void XMLTextMarkImportContext::startFastElement( sal_Int32 nElement, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - if (!FindName(GetImport(), xAttrList)) + if (!FindName(xAttrList)) { m_sBookmarkName.clear(); } - if (IsXMLToken(GetLocalName(), XML_FIELDMARK_START) || IsXMLToken(GetLocalName(), XML_FIELDMARK)) + if ((nElement & TOKEN_MASK) == XML_FIELDMARK_START || + (nElement & TOKEN_MASK) == XML_FIELDMARK) { if (m_sBookmarkName.isEmpty()) { @@ -167,8 +168,8 @@ void XMLTextMarkImportContext::StartElement( if (IsXMLToken(GetLocalName(), XML_BOOKMARK_START)) { - const OUString sHidden = xAttrList->getValueByName("loext:hidden"); - const OUString sCondition = xAttrList->getValueByName("loext:condition"); + const OUString sHidden = xAttrList->getOptionalValue(XML_ELEMENT(LO_EXT, XML_HIDDEN)); + const OUString sCondition = xAttrList->getOptionalValue(XML_ELEMENT(LO_EXT, XML_CONDITION)); m_rHelper.setBookmarkAttributes(m_sBookmarkName, sHidden == "true", sCondition); } } @@ -497,56 +498,42 @@ Reference<XTextContent> XMLTextMarkImportContext::CreateAndInsertMark( } bool XMLTextMarkImportContext::FindName( - SvXMLImport& rImport, - const Reference<XAttributeList> & xAttrList) + const Reference<XFastAttributeList> & xAttrList) { bool bNameOK = false; // find name attribute first - const sal_Int16 nLength = xAttrList->getLength(); - for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++) + for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) ) { - OUString sLocalName; - const sal_uInt16 nPrefix = rImport.GetNamespaceMap(). - GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), - &sLocalName ); - - if ( (XML_NAMESPACE_TEXT == nPrefix) && - IsXMLToken(sLocalName, XML_NAME) ) - { - m_sBookmarkName = xAttrList->getValueByIndex(nAttr); - bNameOK = true; - } - else if ( (XML_NAMESPACE_XML == nPrefix) && - IsXMLToken(sLocalName, XML_ID) ) - { - m_sXmlId = xAttrList->getValueByIndex(nAttr); - } - else if ( XML_NAMESPACE_XHTML == nPrefix ) + OUString sValue = aIter.toString(); + switch(aIter.getToken()) { + case XML_ELEMENT(TEXT, XML_NAME): + m_sBookmarkName = sValue; + bNameOK = true; + break; + case XML_ELEMENT(XML, XML_ID): + m_sXmlId = sValue; + break; // RDFa - if ( IsXMLToken( sLocalName, XML_ABOUT) ) - { - m_sAbout = xAttrList->getValueByIndex(nAttr); + case XML_ELEMENT(XHTML, XML_ABOUT): + m_sAbout = sValue; m_bHaveAbout = true; - } - else if ( IsXMLToken( sLocalName, XML_PROPERTY) ) - { - m_sProperty = xAttrList->getValueByIndex(nAttr); - } - else if ( IsXMLToken( sLocalName, XML_CONTENT) ) - { - m_sContent = xAttrList->getValueByIndex(nAttr); - } - else if ( IsXMLToken( sLocalName, XML_DATATYPE) ) - { - m_sDatatype = xAttrList->getValueByIndex(nAttr); - } - } - else if ( (XML_NAMESPACE_FIELD == nPrefix) && - IsXMLToken(sLocalName, XML_TYPE) ) - { - m_sFieldName = xAttrList->getValueByIndex(nAttr); + break; + case XML_ELEMENT(XHTML, XML_PROPERTY): + m_sProperty = sValue; + break; + case XML_ELEMENT(XHTML, XML_CONTENT): + m_sContent = sValue; + break; + case XML_ELEMENT(XHTML, XML_DATATYPE): + m_sDatatype = sValue; + break; + case XML_ELEMENT(FIELD, XML_TYPE): + m_sFieldName = sValue; + break; + default: + XMLOFF_WARN_UNKNOWN("xmloff", aIter); } } diff --git a/xmloff/source/text/XMLTextMarkImportContext.hxx b/xmloff/source/text/XMLTextMarkImportContext.hxx index a5817b193947..616dec670b20 100644 --- a/xmloff/source/text/XMLTextMarkImportContext.hxx +++ b/xmloff/source/text/XMLTextMarkImportContext.hxx @@ -57,7 +57,7 @@ public: * * All elements are handled by the same class due to their similarities. */ -class XMLTextMarkImportContext : public SvXMLImportContext +class XMLTextMarkImportContext final : public SvXMLImportContext { private: XMLTextImportHelper & m_rHelper; @@ -83,10 +83,8 @@ public: sal_uInt16 nPrfx, const OUString& rLocalName ); -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 SAL_CALL endFastElement(sal_Int32 nElement) override; virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( @@ -102,8 +100,7 @@ public: const OUString& i_rXmlId = OUString()); bool FindName( - SvXMLImport& rImport, - const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList); + const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList); }; #endif |