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

Noel (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 24 06:27:08 UTC 2021


 include/xmloff/xmlictxt.hxx                           |    4 ++++
 xmloff/source/core/XMLEmbeddedObjectImportContext.cxx |    3 +--
 xmloff/source/core/xmlimp.cxx                         |   11 ++++++++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

New commits:
commit e5f436bc53e0d07654901ef7cc8ff56d04f0686e
Author:     Noel <noel.grandin at collabora.co.uk>
AuthorDate: Fri Feb 12 13:02:25 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Feb 24 07:26:23 2021 +0100

    restore namespace unwinding in SvXMLImport
    
    accidentally lost during the fastparser conversion
    
    Change-Id: I7d53e9f32dd8cff650b9ffb6dae493419ce8461f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110813
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/xmloff/xmlictxt.hxx b/include/xmloff/xmlictxt.hxx
index 1fee33fce666..7216105fcd1f 100644
--- a/include/xmloff/xmlictxt.hxx
+++ b/include/xmloff/xmlictxt.hxx
@@ -50,6 +50,10 @@ class XMLOFF_DLLPUBLIC SvXMLImportContext : public css::xml::sax::XFastContextHa
 
     SvXMLImport&                       mrImport;
     oslInterlockedCount                m_nRefCount;
+    std::unique_ptr<SvXMLNamespaceMap> m_pRewindMap;
+
+    SAL_DLLPRIVATE std::unique_ptr<SvXMLNamespaceMap> TakeRewindMap() { return std::move(m_pRewindMap); }
+    SAL_DLLPRIVATE void PutRewindMap(std::unique_ptr<SvXMLNamespaceMap> p) { m_pRewindMap = std::move(p); }
 
 protected:
 
diff --git a/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx b/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx
index f190a4a18c75..79705901cf2d 100644
--- a/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx
+++ b/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx
@@ -82,8 +82,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLEmbeddedObjectImpor
     sal_Int32 ,
     const css::uno::Reference< css::xml::sax::XFastAttributeList >&  )
 {
-    // we have no state, so avoid allocation cost, and just use a single instance
-    return this;
+    return new XMLEmbeddedObjectImportContext_Impl(GetImport(), mxFastHandler);
 }
 
 void XMLEmbeddedObjectImportContext_Impl::startFastElement(
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 33cca656fb1f..8c4b02f50754 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -768,7 +768,7 @@ void SAL_CALL SvXMLImport::startFastElement (sal_Int32 Element,
     maNamespaceAttrList->Clear();
 
     maNamespaceHandler->addNSDeclAttributes( maNamespaceAttrList );
-    processNSAttributes( maNamespaceAttrList );
+    std::unique_ptr<SvXMLNamespaceMap> pRewindMap = processNSAttributes( maNamespaceAttrList );
 
     SvXMLImportContextRef xContext;
     const bool bRootContext = maContexts.empty();
@@ -793,6 +793,10 @@ void SAL_CALL SvXMLImport::startFastElement (sal_Int32 Element,
     if ( !xContext )
         xContext.set( new SvXMLImportContext( *this ) );
 
+    // Remember old namespace map.
+    if( pRewindMap )
+        xContext->PutRewindMap(std::move(pRewindMap));
+
     // Call a startElement at the new context.
     xContext->startFastElement( Element, Attribs );
 
@@ -847,8 +851,13 @@ void SAL_CALL SvXMLImport::endFastElement (sal_Int32 Element)
         return;
     }
     SvXMLImportContextRef xContext = std::move(maContexts.top());
+    // Get a namespace map to rewind.
+    std::unique_ptr<SvXMLNamespaceMap> pRewindMap = xContext->TakeRewindMap();
     maContexts.pop();
     xContext->endFastElement( Element );
+    // Rewind a namespace map.
+    if (pRewindMap)
+        mpNamespaceMap = std::move(pRewindMap);
 }
 
 void SAL_CALL SvXMLImport::endUnknownElement (const OUString & rPrefix, const OUString & rLocalName)


More information about the Libreoffice-commits mailing list