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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Feb 27 14:17:52 UTC 2020


 include/xmloff/xmlimp.hxx                          |    1 
 sw/source/uibase/config/StoredChapterNumbering.cxx |   29 ++++++++++++++++-----
 xmloff/source/core/xmlimp.cxx                      |    5 +++
 3 files changed, 29 insertions(+), 6 deletions(-)

New commits:
commit 5320fccc290f338d344c5d3c75101c98057788cd
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Feb 27 15:33:22 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Feb 27 15:17:10 2020 +0100

    tdf#130908 Chapter Numbering can't load custom style
    
    regression from
        commit 83e97fef3fa4de900eda35d02168fcae01c85eed
        convert ImportStoredChapterNumberingRules to XFastParser
    
    and add some more debugging trace
    
    Change-Id: I224b9c442369a4c6a7746d7ff419f069d3430513
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89633
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
index 1970f8a5c288..93c986f9f5bd 100644
--- a/include/xmloff/xmlimp.hxx
+++ b/include/xmloff/xmlimp.hxx
@@ -381,6 +381,7 @@ public:
     XMLEventImportHelper& GetEventImport();
 
     static const OUString & getNameFromToken( sal_Int32 nToken );
+    static OUString getPrefixAndNameFromToken( sal_Int32 nToken );
     static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap);
     static OUString getNamespaceURIFromToken( sal_Int32 nToken );
     static OUString getNamespacePrefixFromURI( const OUString& rURI );
diff --git a/sw/source/uibase/config/StoredChapterNumbering.cxx b/sw/source/uibase/config/StoredChapterNumbering.cxx
index 5deb102ac024..3f86ea101b75 100644
--- a/sw/source/uibase/config/StoredChapterNumbering.cxx
+++ b/sw/source/uibase/config/StoredChapterNumbering.cxx
@@ -289,7 +289,11 @@ public:
                     name = aIter.toString();
                 else if (IsXMLToken(aIter.toString(), XML_DISPLAY_NAME))
                     displayName = aIter.toString();
+                else
+                    SAL_WARN("xmloff", "unknown value for style:family=" << aIter.toString());
             }
+            else
+                SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << "=" << aIter.toString());
 
         if (nFamily != XmlStyleFamily::DATA_STYLE && !name.isEmpty() && !displayName.isEmpty())
         {
@@ -336,27 +340,40 @@ public:
         }
     }
 
-    virtual css::uno::Reference<XFastContextHandler> SAL_CALL createFastChildContext(
-                sal_Int32 Element,
-                const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override
+    virtual SvXMLImportContextRef CreateChildContext(
+            sal_uInt16 nPrefix,
+            const OUString& rLocalName,
+            const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override
     {
-        if (Element == XML_ELEMENT(TEXT, XML_OUTLINE_STYLE))
+        if (XML_NAMESPACE_TEXT == nPrefix && IsXMLToken(rLocalName, XML_OUTLINE_STYLE))
         {
             ++m_nCounter;
             if (m_nCounter <= SwChapterNumRules::nMaxRules)
             {
                 SvxXMLListStyleContext *const pContext(
-                    new SvxXMLListStyleContext(GetImport(), Element, xAttrList, true));
+                    new SvxXMLListStyleContext(GetImport(),
+                                nPrefix, rLocalName, xAttrList, true));
                 m_Contexts.emplace_back(pContext);
                 return pContext;
             }
         }
+        return nullptr;
+    }
+
+    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(TEXT, XML_OUTLINE_STYLE))
+        {
+            // handled in CreateChildContext
+        }
         else if (Element == XML_ELEMENT(STYLE, XML_STYLE))
         {
             return new StoredChapterNumberingDummyStyleContext(GetImport(), xAttrList);
         }
 
-        return SvXMLImportContext::createFastChildContext(Element, xAttrList);
+        return nullptr;
     }
 };
 
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 9165f7c18e15..1d6bc5d1d0b2 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -2030,6 +2030,11 @@ const OUString & SvXMLImport::getNameFromToken( sal_Int32 nToken )
     return xTokenHandler->getIdentifier( nToken & TOKEN_MASK );
 }
 
+OUString SvXMLImport::getPrefixAndNameFromToken( sal_Int32 nToken )
+{
+    return getNamespacePrefixFromToken(nToken, nullptr) + ":" + xTokenHandler->getIdentifier( nToken & TOKEN_MASK );
+}
+
 OUString SvXMLImport::getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap)
 {
     sal_Int32 nNamespaceToken = ( nToken & NMSP_MASK ) >> NMSP_SHIFT;


More information about the Libreoffice-commits mailing list