[Libreoffice-commits] core.git: xmloff/source

Noel (via logerrit) logerrit at kemper.freedesktop.org
Sat Nov 28 10:03:33 UTC 2020


 xmloff/source/text/XMLChangeElementImportContext.cxx |   10 ++---
 xmloff/source/text/XMLChangeElementImportContext.hxx |    7 ++-
 xmloff/source/text/XMLChangedRegionImportContext.cxx |   38 +++++++++----------
 xmloff/source/text/XMLChangedRegionImportContext.hxx |    6 +--
 4 files changed, 29 insertions(+), 32 deletions(-)

New commits:
commit 1ca8bc9248119ee82afccbff3329f80317667a90
Author:     Noel <noelgrandin at gmail.com>
AuthorDate: Fri Nov 27 15:00:17 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Nov 28 11:02:54 2020 +0100

    fastparser in XMLChangedRegionImportContext
    
    Change-Id: I23123da0b336ed42912b6870685d5bddc33adb50
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106770
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/xmloff/source/text/XMLChangeElementImportContext.cxx b/xmloff/source/text/XMLChangeElementImportContext.cxx
index 38ec34084eca..a3bce265ae43 100644
--- a/xmloff/source/text/XMLChangeElementImportContext.cxx
+++ b/xmloff/source/text/XMLChangeElementImportContext.cxx
@@ -34,12 +34,12 @@ using ::xmloff::token::XML_CHANGE_INFO;
 
 XMLChangeElementImportContext::XMLChangeElementImportContext(
     SvXMLImport& rImport,
-    sal_uInt16 nPrefix,
-    const OUString& rLocalName,
     bool bAccContent,
-    XMLChangedRegionImportContext& rParent) :
-        SvXMLImportContext(rImport, nPrefix, rLocalName),
+    XMLChangedRegionImportContext& rParent,
+    OUString const & rType) :
+        SvXMLImportContext(rImport),
         bAcceptContent(bAccContent),
+        maType(rType),
         rChangedRegion(rParent)
 {
 }
@@ -55,7 +55,7 @@ SvXMLImportContextRef XMLChangeElementImportContext::CreateChildContext(
          IsXMLToken( rLocalName, XML_CHANGE_INFO) )
     {
         xContext = new XMLChangeInfoContext(GetImport(), nPrefix, rLocalName,
-                                            rChangedRegion, GetLocalName());
+                                            rChangedRegion, maType);
     }
     else
     {
diff --git a/xmloff/source/text/XMLChangeElementImportContext.hxx b/xmloff/source/text/XMLChangeElementImportContext.hxx
index 7a37913a3e03..e43e86248224 100644
--- a/xmloff/source/text/XMLChangeElementImportContext.hxx
+++ b/xmloff/source/text/XMLChangeElementImportContext.hxx
@@ -53,6 +53,8 @@ class XMLChangeElementImportContext : public SvXMLImportContext
      */
     bool bAcceptContent;
 
+    OUString maType;
+
     /// context of enclosing <text:changed-region> element
     XMLChangedRegionImportContext& rChangedRegion;
 
@@ -61,12 +63,11 @@ public:
 
     XMLChangeElementImportContext(
         SvXMLImport& rImport,
-        sal_uInt16 nPrefix,
-        const OUString& rLocalName,
         /// accept text content (paragraphs) in element as redline content?
         bool bAcceptContent,
         /// context of enclosing <text:changed-region> element
-        XMLChangedRegionImportContext& rParent);
+        XMLChangedRegionImportContext& rParent,
+        OUString const & rType);
 
     virtual SvXMLImportContextRef CreateChildContext(
         sal_uInt16 nPrefix,
diff --git a/xmloff/source/text/XMLChangedRegionImportContext.cxx b/xmloff/source/text/XMLChangedRegionImportContext.cxx
index 5b2313e67ded..aa257bf50ef8 100644
--- a/xmloff/source/text/XMLChangedRegionImportContext.cxx
+++ b/xmloff/source/text/XMLChangedRegionImportContext.cxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/util/DateTime.hpp>
 #include <com/sun/star/text/XTextCursor.hpp>
 
+#include <sal/log.hxx>
 #include <sax/tools/converter.hxx>
 
 #include <xmloff/xmlimp.hxx>
@@ -89,30 +90,27 @@ void XMLChangedRegionImportContext::StartElement(
     }
 }
 
-SvXMLImportContextRef XMLChangedRegionImportContext::CreateChildContext(
-    sal_uInt16 nPrefix,
-    const OUString& rLocalName,
-    const Reference<XAttributeList> & /*xAttrList*/)
+css::uno::Reference< css::xml::sax::XFastContextHandler > XMLChangedRegionImportContext::createFastChildContext(
+    sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >&  )
 {
     SvXMLImportContextRef xContext;
 
-    if (XML_NAMESPACE_TEXT == nPrefix)
+    // from the ODF 1.2 standard :
+    // The <text:changed-region> element has the following child elements:
+    // <text:deletion>, <text:format-change> and <text:insertion>.
+    if (nElement == XML_ELEMENT(TEXT, XML_INSERTION) ||
+        nElement == XML_ELEMENT(TEXT, XML_DELETION) ||
+        nElement == XML_ELEMENT(TEXT, XML_FORMAT_CHANGE) )
     {
-        // from the ODF 1.2 standard :
-        // The <text:changed-region> element has the following child elements:
-        // <text:deletion>, <text:format-change> and <text:insertion>.
-        if ( IsXMLToken( rLocalName, XML_INSERTION ) ||
-             IsXMLToken( rLocalName, XML_DELETION ) ||
-             IsXMLToken( rLocalName, XML_FORMAT_CHANGE ) )
-        {
-            // create XMLChangeElementImportContext for all kinds of changes
-            xContext = new XMLChangeElementImportContext(
-               GetImport(), nPrefix, rLocalName,
-               IsXMLToken( rLocalName, XML_DELETION ),
-               *this);
-        }
-        // else: it may be a text element, see below
+        // create XMLChangeElementImportContext for all kinds of changes
+        xContext = new XMLChangeElementImportContext(
+            GetImport(),
+            nElement == XML_ELEMENT(TEXT, XML_DELETION),
+            *this,
+            SvXMLImport::getNameFromToken(nElement));
     }
+    else
+        XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
 
     if (!xContext)
     {
@@ -121,7 +119,7 @@ SvXMLImportContextRef XMLChangedRegionImportContext::CreateChildContext(
         // or default if text fail
     }
 
-    return xContext;
+    return xContext.get();
 }
 
 void XMLChangedRegionImportContext::endFastElement(sal_Int32 )
diff --git a/xmloff/source/text/XMLChangedRegionImportContext.hxx b/xmloff/source/text/XMLChangedRegionImportContext.hxx
index 45297c573caf..2964790f8fcc 100644
--- a/xmloff/source/text/XMLChangedRegionImportContext.hxx
+++ b/xmloff/source/text/XMLChangedRegionImportContext.hxx
@@ -60,10 +60,8 @@ public:
     virtual void StartElement(
         const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override;
 
-    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;
 
     virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
 


More information about the Libreoffice-commits mailing list