diff options
author | Noel <noelgrandin@gmail.com> | 2020-12-02 13:49:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-03 07:04:22 +0100 |
commit | a186fd4f2427df7baa50f78e99644dc5a50dfb12 (patch) | |
tree | 84e5028f121b1d5fe9d0bc11b6ea133d7db6e9a9 /xmloff | |
parent | 1df2581cfffc87386c6de7614793b2d664244e5a (diff) |
fastparser in ScXMLChangeTextPContext
Change-Id: Ia20ec9890a6da48b0a1db740842c056701b24ae5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107125
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/core/xmlictxt.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/xmloff/source/core/xmlictxt.cxx b/xmloff/source/core/xmlictxt.cxx index 175adf28c876..0074ee886089 100644 --- a/xmloff/source/core/xmlictxt.cxx +++ b/xmloff/source/core/xmlictxt.cxx @@ -110,6 +110,45 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SvXMLImportContext::cre return nullptr; } +css::uno::Reference< css::xml::sax::XFastContextHandler > SvXMLImportContext::createFastChildContextFallback(sal_Int32 Element, const uno::Reference< xml::sax::XFastAttributeList > & Attribs) +{ + // fall back to slow-parser path + const OUString& rPrefix = SvXMLImport::getNamespacePrefixFromToken(Element, &mrImport.GetNamespaceMap()); + const OUString& rLocalName = SvXMLImport::getNameFromToken( Element ); + OUString aName = rPrefix.isEmpty() ? rLocalName : rPrefix + SvXMLImport::aNamespaceSeparator + rLocalName; + OUString aLocalName; + sal_uInt16 nPrefix = + mrImport.mpNamespaceMap->GetKeyByAttrName( aName, &aLocalName ); + + mrImport.maAttrList->Clear(); + + if ( Attribs.is() ) + { + for( auto &it : sax_fastparser::castToFastAttributeList( Attribs ) ) + { + sal_Int32 nToken = it.getToken(); + const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken(nToken, &mrImport.GetNamespaceMap()); + OUString sAttrName = SvXMLImport::getNameFromToken( nToken ); + if ( !rAttrNamespacePrefix.isEmpty() ) + sAttrName = rAttrNamespacePrefix + SvXMLImport::aNamespaceSeparator + sAttrName; + + mrImport.maAttrList->AddAttribute( sAttrName, "CDATA", it.toString() ); + } + + const uno::Sequence< xml::Attribute > unknownAttribs = Attribs->getUnknownAttributes(); + for ( const auto& rUnknownAttrib : unknownAttribs ) + { + const OUString& rAttrValue = rUnknownAttrib.Value; + const OUString& rAttrName = rUnknownAttrib.Name; + // note: rAttrName is expected to be namespace-prefixed here + mrImport.maAttrList->AddAttribute( rAttrName, "CDATA", rAttrValue ); + } + } + + SAL_INFO("xmloff.core", "calling CreateChildContext on " << typeid(*this).name()); + return CreateChildContext(nPrefix, aLocalName, mrImport.maAttrList.get() ).get(); +} + uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SvXMLImportContext::createUnknownChildContext (const OUString & /*rNamespace*/, const OUString & /*rName*/, const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/) { |