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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Oct 8 17:05:08 UTC 2018


 sw/qa/extras/ooxmlexport/data/tdf58944-repeating-table-header.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx                         |   17 +++++++
 writerfilter/source/dmapper/DomainMapperTableManager.cxx           |   22 +++++++++-
 3 files changed, 37 insertions(+), 2 deletions(-)

New commits:
commit 110781a3a27dffe9e6690839bdce993796a08331
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Tue Sep 18 14:43:31 2018 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Mon Oct 8 19:04:43 2018 +0200

    tdf#58944 DOCX import: workaround for hidden table headers
    
    Repeating table headers consisted of more than 10 table rows
    switch off table header repetition during DOCX table import
    to fix non-visible table content and broken tables.
    
    Repeating header lines are not visible in MSO, if there is no space for them.
    OOXML (and ODF) standards don't specify this exception, and unfortunately,
    it's easy to create tables with invisible repeating headers in MSO, resulting
    OOXML files with non-standardized layout. To show the same or a similar layout
    in LibreOffice (instead of a broken table with invisible content), we use a
    reasonable 10-row limit to apply header repetition, as a workaround.
    Later it's still possible to switch on header repetition or create a
    better compatible repeating table header in Writer for (pretty unlikely) tables
    with really repeating headers consisted of more than 10 table rows.
    
    Note: This workaround could help to create standard and more portable OOXML
    files in a mixed environment.
    
    Change-Id: I17fbc0173ec1c4f188a46227b99dde5726530da3
    Reviewed-on: https://gerrit.libreoffice.org/60689
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf58944-repeating-table-header.docx b/sw/qa/extras/ooxmlexport/data/tdf58944-repeating-table-header.docx
new file mode 100644
index 000000000000..56e37362adf7
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf58944-repeating-table-header.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index dd9a6c8ceb12..2f665ad620e5 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -798,6 +798,23 @@ DECLARE_OOXMLEXPORT_TEST(testLOPresetDashesConvert, "lo_preset_dashes.odt")
     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent[10]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "sysDash");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf58944RepeatingTableHeader, "tdf58944-repeating-table-header.docx")
+{
+    // DOCX tables with more than 10 repeating header lines imported without repeating header lines
+    // as a workaround for MSO's limitation of header line repetition
+    xmlDocPtr pDump = parseLayoutDump();
+    CPPUNIT_ASSERT_EQUAL(2, getPages());
+
+    // table starts on page 1 and finished on page 2
+    // instead of showing only a part of it on page 2
+    assertXPath(pDump, "/root/page[1]/body/tab", 1);
+    assertXPath(pDump, "/root/page[1]/body/tab/row", 11);
+    CPPUNIT_ASSERT_EQUAL(OUString("Test1"),
+                         parseDump("/root/page[2]/body/tab/row[1]/cell[1]/txt/text()"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Test2"),
+                         parseDump("/root/page[2]/body/tab/row[2]/cell[1]/txt/text()"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index f76f28dcac1f..962f7130e6f9 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -203,9 +203,27 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
                 // to prevent later rows from increasing the repeating m_nHeaderRepeat is set to NULL when repeating stops
                 if( nIntValue > 0 && m_nHeaderRepeat == static_cast<int>(m_nRow) )
                 {
-                    ++m_nHeaderRepeat;
                     TablePropertyMapPtr pPropMap( new TablePropertyMap );
-                    pPropMap->Insert( PROP_HEADER_ROW_COUNT, uno::makeAny( m_nHeaderRepeat ));
+
+                    // Repeating header lines are not visible in MSO, if there is no space for them.
+                    // OOXML (and ODF) standards don't specify this exception, and unfortunately,
+                    // it's easy to create tables with invisible repeating headers in MSO, resulting
+                    // OOXML files with non-standardized layout. To show the same or a similar layout
+                    // in LibreOffice (instead of a broken table with invisible content), we use a
+                    // reasonable 10-row limit to apply header repetition, as a workaround.
+                    // Later it's still possible to switch on header repetition or create a better
+                    // compatible repeating table header in Writer for (pretty unlikely) tables with
+                    // really repeating headers consisted of more than 10 table rows.
+                    if ( m_nHeaderRepeat == 10 )
+                    {
+                        m_nHeaderRepeat = -1;
+                        pPropMap->Insert( PROP_HEADER_ROW_COUNT, uno::makeAny(sal_Int32(0)));
+                    }
+                    else
+                    {
+                        ++m_nHeaderRepeat;
+                        pPropMap->Insert( PROP_HEADER_ROW_COUNT, uno::makeAny( m_nHeaderRepeat ));
+                    }
                     insertTableProps(pPropMap);
                 }
                 else


More information about the Libreoffice-commits mailing list