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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Feb 6 16:30:44 UTC 2020


 sw/source/core/swg/SwXMLSectionList.cxx |   47 +++++++++++++++++---------------
 sw/source/filter/xml/swxml.cxx          |    3 ++
 2 files changed, 29 insertions(+), 21 deletions(-)

New commits:
commit d0ec225bf654bb998fd1e62a1b832aa20464fb90
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Feb 5 15:00:13 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Feb 6 17:30:10 2020 +0100

    tdf#129881 missing sections in link section
    
    actually this is a regression from
        commit 2b77d9dba51e1c3841428f3343e9186ca9c446ae
        Date:   Wed Nov 6 11:19:12 2019 +0200
        convert SwXMLSectionList to FastParser
    the commit mentioned in the bug report was fixed by caolan, and then I
    broke it again with the above commit
    
    Change-Id: If6d3dad7baadcdfcc73d87d1e9d6a91c9f65a6e5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88019
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/core/swg/SwXMLSectionList.cxx b/sw/source/core/swg/SwXMLSectionList.cxx
index 2dfcb49e8457..d0df14d7e90d 100644
--- a/sw/source/core/swg/SwXMLSectionList.cxx
+++ b/sw/source/core/swg/SwXMLSectionList.cxx
@@ -36,6 +36,9 @@ private:
 public:
     SvXMLSectionListContext(SwXMLSectionList& rImport);
 
+    virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/,
+        const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {}
+
     virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext(
         sal_Int32 Element,
         const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override;
@@ -52,26 +55,33 @@ public:
     {
     }
 
+    virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/,
+        const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {}
+
     virtual css::uno::Reference<XFastContextHandler> SAL_CALL createFastChildContext(
         sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & /*xAttrList*/ ) override
     {
         if (Element == XML_ELEMENT(OFFICE, XML_BODY) ||
-            Element == XML_ELEMENT(TEXT, XML_P) ||
-            Element == XML_ELEMENT(TEXT, XML_H) ||
-            Element == XML_ELEMENT(TEXT, XML_A) ||
-            Element == XML_ELEMENT(TEXT, XML_SPAN) ||
-            Element == XML_ELEMENT(TEXT, XML_SECTION) ||
-            Element == XML_ELEMENT(TEXT, XML_INDEX_BODY) ||
-            Element == XML_ELEMENT(TEXT, XML_INDEX_TITLE) ||
-            Element == XML_ELEMENT(TEXT, XML_INSERTION) ||
-            Element == XML_ELEMENT(TEXT, XML_DELETION))
+            Element == XML_ELEMENT(OFFICE_OOO, XML_BODY))
         {
             return new SvXMLSectionListContext(GetImport());
         }
-        else
+        if ((Element & NMSP_MASK) == NAMESPACE_TOKEN(XML_NAMESPACE_TEXT) ||
+            (Element & NMSP_MASK) == NAMESPACE_TOKEN(XML_NAMESPACE_TEXT_OOO))
         {
-            return new SwXMLParentContext(GetImport());
+            auto nToken = Element & TOKEN_MASK;
+            if (nToken == XML_P ||
+                nToken == XML_H ||
+                nToken == XML_A ||
+                nToken == XML_SPAN ||
+                nToken == XML_SECTION ||
+                nToken == XML_INDEX_BODY ||
+                nToken == XML_INDEX_TITLE ||
+                nToken == XML_INSERTION ||
+                nToken == XML_DELETION)
+                return new SvXMLSectionListContext(GetImport());
         }
+        return new SwXMLParentContext(GetImport());
     }
 };
 
@@ -81,14 +91,6 @@ SwXMLSectionList::SwXMLSectionList(const css::uno::Reference< css::uno::XCompone
 : SvXMLImport(rContext, "")
 , m_rSectionList(rNewSectionList)
 {
-    // TODO: verify if these should match the same-name constants
-    //       in xmloff/source/core/xmlimp.cxx ("_office" and "_office")
-    GetNamespaceMap().Add( "_ooffice",
-                            GetXMLToken(XML_N_OFFICE_OOO),
-                            XML_NAMESPACE_OFFICE );
-    GetNamespaceMap().Add( "_otext",
-                            GetXMLToken(XML_N_TEXT_OOO),
-                            XML_NAMESPACE_TEXT );
 }
 
 SwXMLSectionList::~SwXMLSectionList()
@@ -115,14 +117,17 @@ css::uno::Reference<css::xml::sax::XFastContextHandler> SvXMLSectionListContext:
     SvXMLImportContext *pContext = nullptr;
 
     if (Element == XML_ELEMENT(TEXT, XML_SECTION ) ||
-        Element == XML_ELEMENT(TEXT, XML_BOOKMARK) )
+        Element == XML_ELEMENT(TEXT, XML_BOOKMARK) ||
+        Element == XML_ELEMENT(TEXT_OOO, XML_SECTION ) ||
+        Element == XML_ELEMENT(TEXT_OOO, XML_BOOKMARK) )
     {
         sax_fastparser::FastAttributeList *pAttribList =
             sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );
 
         OUString sName;
         for (auto &aIter : *pAttribList)
-            if (aIter.getToken() == (XML_NAMESPACE_TEXT | XML_NAME))
+            if (aIter.getToken() == XML_ELEMENT(TEXT, XML_NAME) ||
+                aIter.getToken() == XML_ELEMENT(TEXT_OOO, XML_NAME))
                 sName = aIter.toString();
         if ( !sName.isEmpty() )
             GetImport().m_rSectionList.push_back(sName);
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index 780479c1e992..d3b84dccf456 100644
--- a/sw/source/filter/xml/swxml.cxx
+++ b/sw/source/filter/xml/swxml.cxx
@@ -1001,14 +1001,17 @@ size_t XMLReader::GetSectionList( SfxMedium& rMedium,
         }
         catch( xml::sax::SAXParseException&  )
         {
+            TOOLS_WARN_EXCEPTION("sw", "");
             // re throw ?
         }
         catch( xml::sax::SAXException&  )
         {
+            TOOLS_WARN_EXCEPTION("sw", "");
             // re throw ?
         }
         catch( io::IOException& )
         {
+            TOOLS_WARN_EXCEPTION("sw", "");
             // re throw ?
         }
         catch( packages::WrongPasswordException& )


More information about the Libreoffice-commits mailing list