summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2016-08-23 18:55:30 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-08-29 09:47:58 +0000
commit8fcb00173737f6243e459c9d7a80bf29b95c4839 (patch)
tree0b8a418198442b3e517dc68800bb432c961e2a8a
parent9ae319f938de37a9de1e8a8853af106b413a4bc7 (diff)
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@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf101589_dontSplitTable.odtbin0 -> 11314 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport3.cxx6
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx30
3 files changed, 36 insertions, 0 deletions
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 000000000000..4a05018823c0
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf101589_dontSplitTable.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index b6757a579c29..72c7e8e696de 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 acb55d0dc4f1..327b169e89d9 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;