[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - include/xmloff sw/qa sw/source xmloff/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 6 22:24:25 UTC 2020


 include/xmloff/txtparae.hxx                                        |    2 +
 sw/qa/extras/odfexport/data/tdf124470TableAndEmbeddedUsedFonts.odt |binary
 sw/qa/extras/odfexport/odfexport.cxx                               |   18 ++++++++++
 sw/source/filter/xml/xmltble.cxx                                   |    9 ++++-
 sw/source/filter/xml/xmltexte.hxx                                  |    6 +++
 xmloff/source/text/txtparae.cxx                                    |    4 ++
 6 files changed, 38 insertions(+), 1 deletion(-)

New commits:
commit 378537536a135a80d97752368a032814b81cabca
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Wed Aug 5 11:16:32 2020 +0300
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Fri Aug 7 00:23:52 2020 +0200

    tdf#124470: Split export of table autostyles out from collection phase
    
    This allows to call collectAutoStyles where required (e.g. when enumerating
    used fonts), without side effect of writing table styles XML inside the call,
    out of place.
    
    Change-Id: Ida05e373eb8502590c43e2b0e85c3b0c1107c551
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100153
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit 35021cd56b3b4e38035804087f215c80085564be)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100221
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/include/xmloff/txtparae.hxx b/include/xmloff/txtparae.hxx
index 80131b11e9f7..44c15512cd70 100644
--- a/include/xmloff/txtparae.hxx
+++ b/include/xmloff/txtparae.hxx
@@ -365,6 +365,8 @@ protected:
         const css::uno::Reference< css::beans::XPropertySet> & i_xPortion,
         bool i_bAutoStyles, bool i_isProgress, bool & rPrevCharIsSpace);
 
+    virtual void exportTableAutoStyles();
+
 public:
 
     XMLTextParagraphExport(
diff --git a/sw/qa/extras/odfexport/data/tdf124470TableAndEmbeddedUsedFonts.odt b/sw/qa/extras/odfexport/data/tdf124470TableAndEmbeddedUsedFonts.odt
new file mode 100644
index 000000000000..21969e9e5485
Binary files /dev/null and b/sw/qa/extras/odfexport/data/tdf124470TableAndEmbeddedUsedFonts.odt differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 540e6359dd1f..d41ce2037d5e 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -2520,5 +2520,23 @@ DECLARE_ODFEXPORT_TEST(testPageContentBottom, "page-content-bottom.odt")
     CPPUNIT_ASSERT_EQUAL(nExpected, getProperty<sal_Int16>(xShape, "VertOrientRelation"));
 }
 
+DECLARE_ODFEXPORT_TEST(tdf124470, "tdf124470TableAndEmbeddedUsedFonts.odt")
+{
+    // Table styles were exported out of place, inside font-face-decls.
+    // Without the fix in place, this will fail already in ODF validation:
+    // "content.xml[2,2150]:  Error: tag name "style:style" is not allowed. Possible tag names are: <font-face>"
+
+    CPPUNIT_ASSERT_EQUAL(1, getPages());
+
+    xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
+    if (!pXmlDoc)
+        return;
+
+    assertXPath(pXmlDoc, "/office:document-content/office:font-face-decls/style:style", 0);
+    assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:family='table']", 1);
+    assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:family='table-column']", 2);
+    assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:family='paragraph']", 1);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index 3febc00ae82e..0d91074bd91b 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -1156,6 +1156,13 @@ void SwXMLExport::ExportTable( const SwTableNode& rTableNd )
     }
 }
 
+void SwXMLTextParagraphExport::exportTableAutoStyles() {
+    for (const auto* pTableNode : maTableNodes)
+    {
+        static_cast<SwXMLExport&>(GetExport()).ExportTableAutoStyles(*pTableNode);
+    }
+}
+
 void SwXMLTextParagraphExport::exportTable(
         const Reference < XTextContent > & rTextContent,
         bool bAutoStyles, bool _bProgress )
@@ -1193,7 +1200,7 @@ void SwXMLTextParagraphExport::exportTable(
                 // ALL flags are set at the same time.
                 const bool bExportStyles = bool( GetExport().getExportFlags() & SvXMLExportFlags::STYLES );
                 if ( bExportStyles || !pFormat->GetDoc()->IsInHeaderFooter( aIdx ) )
-                    static_cast<SwXMLExport&>(GetExport()).ExportTableAutoStyles( *pTableNd );
+                    maTableNodes.push_back(pTableNd);
             }
             else
             {
diff --git a/sw/source/filter/xml/xmltexte.hxx b/sw/source/filter/xml/xmltexte.hxx
index e7ec5a991d3e..3fc9530e6303 100644
--- a/sw/source/filter/xml/xmltexte.hxx
+++ b/sw/source/filter/xml/xmltexte.hxx
@@ -28,6 +28,7 @@
 class SwXMLExport;
 class SvXMLAutoStylePoolP;
 class SwNoTextNode;
+class SwTableNode;
 namespace com::sun::star::style { class XStyle; }
 
 class SwXMLTextParagraphExport : public XMLTextParagraphExport
@@ -36,6 +37,9 @@ class SwXMLTextParagraphExport : public XMLTextParagraphExport
     const SvGlobalName aPluginClassId;
     const SvGlobalName aIFrameClassId;
 
+    // Collected autostyles for use in exportTextAutoStyles
+    std::vector<const SwTableNode*> maTableNodes;
+
     static SwNoTextNode *GetNoTextNode(
         const css::uno::Reference < css::beans::XPropertySet >& rPropSet );
 
@@ -50,6 +54,8 @@ protected:
         const css::uno::Reference< css::text::XTextContent > & rTextContent,
         bool bAutoStyles, bool bProgress ) override;
 
+    virtual void exportTableAutoStyles() override;
+
 public:
     SwXMLTextParagraphExport(
         SwXMLExport& rExp,
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 26ff035a488b..d0c067ac7ed3 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -3692,8 +3692,12 @@ void XMLTextParagraphExport::recordTrackedChangesNoXText()
         pRedlineExport->SetCurrentXText();
 }
 
+void XMLTextParagraphExport::exportTableAutoStyles() {}
+
 void XMLTextParagraphExport::exportTextAutoStyles()
 {
+    exportTableAutoStyles();
+
     GetAutoStylePool().exportXML( XmlStyleFamily::TEXT_PARAGRAPH );
 
     GetAutoStylePool().exportXML( XmlStyleFamily::TEXT_TEXT );


More information about the Libreoffice-commits mailing list