summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNoel <noelgrandin@gmail.com>2020-12-02 09:07:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-12-02 08:58:50 +0100
commit4d7ad433c6ebd9fbcac480ebdd00af933a437df5 (patch)
tree5585548615cff7feb82e938f3cdb83ceeefa5041 /xmloff
parentff270d936d1d0209d9036aaa9149a8ee489aaebf (diff)
fastparser in XMLChangeElementImportContext
with the help of a fallback method for CreateTextChildContext Change-Id: Ic74ad8e74a4763906ae58a9064ecd54c5b9075ad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107043 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/text/XMLChangeElementImportContext.cxx16
-rw-r--r--xmloff/source/text/XMLChangeElementImportContext.hxx9
-rw-r--r--xmloff/source/text/XMLChangeInfoContext.cxx4
-rw-r--r--xmloff/source/text/XMLChangeInfoContext.hxx2
-rw-r--r--xmloff/source/text/txtimp.cxx43
5 files changed, 54 insertions, 20 deletions
diff --git a/xmloff/source/text/XMLChangeElementImportContext.cxx b/xmloff/source/text/XMLChangeElementImportContext.cxx
index a3bce265ae43..4fc81a755eda 100644
--- a/xmloff/source/text/XMLChangeElementImportContext.cxx
+++ b/xmloff/source/text/XMLChangeElementImportContext.cxx
@@ -44,17 +44,15 @@ XMLChangeElementImportContext::XMLChangeElementImportContext(
{
}
-SvXMLImportContextRef XMLChangeElementImportContext::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const Reference<XAttributeList> & xAttrList)
+css::uno::Reference< css::xml::sax::XFastContextHandler > XMLChangeElementImportContext::createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
{
SvXMLImportContextRef xContext;
- if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
- IsXMLToken( rLocalName, XML_CHANGE_INFO) )
+ if ( nElement == XML_ELEMENT(OFFICE, XML_CHANGE_INFO) )
{
- xContext = new XMLChangeInfoContext(GetImport(), nPrefix, rLocalName,
+ xContext = new XMLChangeInfoContext(GetImport(),
rChangedRegion, maType);
}
else
@@ -63,7 +61,7 @@ SvXMLImportContextRef XMLChangeElementImportContext::CreateChildContext(
rChangedRegion.UseRedlineText();
xContext = GetImport().GetTextImport()->CreateTextChildContext(
- GetImport(), nPrefix, rLocalName, xAttrList,
+ GetImport(), nElement, xAttrList,
XMLTextType::ChangedRegion);
if (!xContext)
@@ -74,7 +72,7 @@ SvXMLImportContextRef XMLChangeElementImportContext::CreateChildContext(
}
}
- return xContext;
+ return xContext.get();
}
void XMLChangeElementImportContext::startFastElement( sal_Int32, const Reference< css::xml::sax::XFastAttributeList >& )
diff --git a/xmloff/source/text/XMLChangeElementImportContext.hxx b/xmloff/source/text/XMLChangeElementImportContext.hxx
index e43e86248224..fb7bef4aa13f 100644
--- a/xmloff/source/text/XMLChangeElementImportContext.hxx
+++ b/xmloff/source/text/XMLChangeElementImportContext.hxx
@@ -37,7 +37,7 @@ class XMLChangedRegionImportContext;
* Import <text:deletion> and <text:insertion> elements contained in a
* <text:changed-region> element.
*/
-class XMLChangeElementImportContext : public SvXMLImportContext
+ class XMLChangeElementImportContext : public SvXMLImportContext
{
/**
* accept text content (paragraphs) in element as redline content?
@@ -60,7 +60,6 @@ class XMLChangeElementImportContext : public SvXMLImportContext
public:
-
XMLChangeElementImportContext(
SvXMLImport& rImport,
/// accept text content (paragraphs) in element as redline content?
@@ -69,10 +68,8 @@ public:
XMLChangedRegionImportContext& rParent,
OUString const & rType);
- 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;
// Start- and EndElement are needed here to set the inside_deleted_section
// flag at the corresponding TextImportHelper
diff --git a/xmloff/source/text/XMLChangeInfoContext.cxx b/xmloff/source/text/XMLChangeInfoContext.cxx
index fd51c12f55d5..c49dc1889832 100644
--- a/xmloff/source/text/XMLChangeInfoContext.cxx
+++ b/xmloff/source/text/XMLChangeInfoContext.cxx
@@ -35,11 +35,9 @@ using ::com::sun::star::xml::sax::XAttributeList;
XMLChangeInfoContext::XMLChangeInfoContext(
SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
XMLChangedRegionImportContext& rPParent,
const OUString& rChangeType)
-: SvXMLImportContext(rImport, nPrefix, rLocalName)
+: SvXMLImportContext(rImport)
, rType(rChangeType)
, rChangedRegion(rPParent)
{
diff --git a/xmloff/source/text/XMLChangeInfoContext.hxx b/xmloff/source/text/XMLChangeInfoContext.hxx
index 1c2d9356c284..8d1f3965e283 100644
--- a/xmloff/source/text/XMLChangeInfoContext.hxx
+++ b/xmloff/source/text/XMLChangeInfoContext.hxx
@@ -53,8 +53,6 @@ public:
XMLChangeInfoContext(
SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
XMLChangedRegionImportContext& rChangedRegion,
const OUString& rChangeType);
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx
index f37e571ab51b..88695e599a8b 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -69,6 +69,7 @@
#include <com/sun/star/beans/XPropertyState.hpp>
#include <txtlists.hxx>
#include <xmloff/odffields.hxx>
+#include <comphelper/attributelist.hxx>
using ::com::sun::star::ucb::XAnyCompare;
@@ -2134,6 +2135,48 @@ void XMLTextImportHelper::SetAutoStyles( SvXMLStylesContext *pStyles )
SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext(
SvXMLImport& rImport,
+ sal_Int32 Element,
+ const Reference< XFastAttributeList > & Attribs,
+ XMLTextType eType )
+{
+ // fall back to slow-parser path
+ const OUString& rPrefix = SvXMLImport::getNamespacePrefixFromToken(Element, &GetXMLImport().GetNamespaceMap());
+ const OUString& rLocalName = SvXMLImport::getNameFromToken( Element );
+ OUString aName = rPrefix.isEmpty() ? rLocalName : rPrefix + SvXMLImport::aNamespaceSeparator + rLocalName;
+ OUString aLocalName;
+ sal_uInt16 nPrefix =
+ GetXMLImport().GetNamespaceMap().GetKeyByAttrName( aName, &aLocalName );
+
+ rtl::Reference < comphelper::AttributeList > maAttrList = new comphelper::AttributeList();
+
+ if ( Attribs.is() )
+ {
+ for( auto &it : sax_fastparser::castToFastAttributeList( Attribs ) )
+ {
+ sal_Int32 nToken = it.getToken();
+ const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken(nToken, &GetXMLImport().GetNamespaceMap());
+ OUString sAttrName = SvXMLImport::getNameFromToken( nToken );
+ if ( !rAttrNamespacePrefix.isEmpty() )
+ sAttrName = rAttrNamespacePrefix + SvXMLImport::aNamespaceSeparator + sAttrName;
+
+ 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
+ maAttrList->AddAttribute( rAttrName, "CDATA", rAttrValue );
+ }
+ }
+
+ return CreateTextChildContext(rImport, nPrefix, aLocalName, maAttrList.get(), eType );
+}
+
+SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext(
+ SvXMLImport& rImport,
sal_uInt16 nPrefix, const OUString& rLocalName,
const Reference< XAttributeList > & xAttrList,
XMLTextType eType )