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

Justin Luth justin_luth at sil.org
Mon Aug 29 09:48:20 UTC 2016


 sw/qa/extras/ooxmlexport/data/tdf101589_dontSplitTable.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx                  |    6 ++
 sw/source/filter/ww8/wrtw8nds.cxx                          |   30 +++++++++++++
 3 files changed, 36 insertions(+)

New commits:
commit 8fcb00173737f6243e459c9d7a80bf29b95c4839
Author: Justin Luth <justin_luth at sil.org>
Date:   Tue Aug 23 18:55:30 2016 +0300

    tdf#101589 MS export: use dont-split-row for 1-row table
    
    .doc and .docx do not have a setting for "do not split table" so
    it was being emulated by "keep paragraph with next" for all but
    the last table-row.  That means that a single-row table with
    lots of content might be split.
    
    There is a setting to prevent a row from splitting, so use
    that instead in this corner case.  It needs to be
    separate from the other function in order to be
    set in time for docx to write w:cantSplit w:val="true"
    before the row contents. For some reason it did not work
    to move the whole function here.
    
    Change-Id: Idc11626e0e2cf1706b87a83f2bd4a802348cb633
    Reviewed-on: https://gerrit.libreoffice.org/28352
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf101589_dontSplitTable.odt b/sw/qa/extras/ooxmlexport/data/tdf101589_dontSplitTable.odt
new file mode 100644
index 0000000..4a05018
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf101589_dontSplitTable.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index b6757a5..72c7e8e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -932,6 +932,12 @@ DECLARE_OOXMLEXPORT_TEST(testcantSplit, "2_table_doc.docx")
     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[2]/w:tr/w:trPr/w:cantSplit","val","true");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testDontSplitTable, "tdf101589_dontSplitTable.odt")
+{
+    //single row tables need to prevent split by setting row to no split
+    CPPUNIT_ASSERT_EQUAL( OUString("Row 1"), parseDump("/root/page[2]/body/tab[1]/row[1]/cell[1]/txt[1]") );
+}
+
 DECLARE_OOXMLEXPORT_TEST(testExtraSectionBreak, "1_page.docx")
 {
     // There was a problem for some documents during export.Invalid sectPr getting added
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index acb55d0..327b169 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -2079,6 +2079,36 @@ void MSWordExportBase::OutputTextNode( const SwTextNode& rNode )
         }
     }
 
+    // Emulate: If 1-row table is marked as don't split, then set the row as don't split.
+    if ( IsInTable() )
+    {
+        const SwTableNode* pTableNode = rNode.FindTableNode();
+        if ( pTableNode )
+        {
+            const SwTable& rTable = pTableNode->GetTable();
+            const bool bKeep = rTable.GetFrameFormat()->GetKeep().GetValue();
+            const bool bDontSplit = !rTable.GetFrameFormat()->GetLayoutSplit().GetValue();
+            // bKeep handles this a different way later on, so ignore now
+            if ( !bKeep && bDontSplit && rTable.GetTabLines().size() == 1 )
+            {
+                // bDontSplit : set don't split once for the row
+                // but only for non-complex tables
+                const SwTableBox* pBox = rNode.GetTableBox();
+                const SwTableLine* pLine = pBox ? pBox->GetUpper() : nullptr;
+                if ( pLine && !pLine->GetUpper() )
+                {
+                    // check if box is first in that line:
+                    if ( 0 == pLine->GetBoxPos( pBox ) && pBox->GetSttNd() )
+                    {
+                        // check if paragraph is first in that line:
+                        if ( 1 == ( rNode.GetIndex() - pBox->GetSttNd()->GetIndex() ) )
+                            pLine->GetFrameFormat()->SetFormatAttr(SwFormatRowSplit(!bDontSplit));
+                    }
+                }
+            }
+        }
+    }
+
     AttrOutput().StartParagraph( pTextNodeInfo );
 
     const SwSection* pTOXSect = nullptr;


More information about the Libreoffice-commits mailing list