summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2017-07-12 16:07:10 +0200
committerAndras Timar <andras.timar@collabora.com>2017-07-14 13:00:37 +0200
commit961afc771228c77c355a0c5fd8ff051e7e241bd2 (patch)
tree900127956e16fe0ebb2b2a124557f0c353493a76
parent951af0302f60dfd5fc082552d85d8ddb522fc5a2 (diff)
tdf#109053: DOCX: Multipage table is not imported properly
An other use case when converting to a "floating table" is not a good idea. In this case we can check whether next to the table anything fits in the text area. If not then we can avoid floating table conversion. Reviewed-on: https://gerrit.libreoffice.org/39811 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> (cherry picked from commit fc55711f01af172eb3a034454405fa941454c781) Change-Id: I798a2f4c7a9dfe6aecbe4a73e3162b49ea5f0adc Reviewed-on: https://gerrit.libreoffice.org/39931 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rwxr-xr-xsw/qa/extras/ooxmlimport/data/tdf109053.docxbin0 -> 12195 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx7
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx27
3 files changed, 26 insertions, 8 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf109053.docx b/sw/qa/extras/ooxmlimport/data/tdf109053.docx
new file mode 100755
index 000000000000..f700c4d6a48d
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tdf109053.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 32ec82962ed9..0c654b89c492 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1419,6 +1419,13 @@ DECLARE_OOXMLIMPORT_TEST(testTdf100072, "tdf100072.docx")
CPPUNIT_ASSERT_MESSAGE("Shape line width does not match", abs(nFirstEnd - nSecondEnd) < 10);
}
+DECLARE_OOXMLIMPORT_TEST(testTdf109053, "tdf109053.docx")
+{
+ // Table was imported into a text frame which led to a one page document
+ // Originally the table takes two pages, so Writer should import it accordingly.
+ CPPUNIT_ASSERT_EQUAL(getPages(), 2);
+}
+
// tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index ec79cb1ba653..29fa2ab8c727 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1094,16 +1094,27 @@ bool SectionPropertyMap::FloatingTableConversion(FloatingTableInfo& rInfo)
}
}
- // If the table is wider than the text area, then don't create a fly
- // for the table: no wrapping will be performed anyway, but multi-page
- // tables will be broken.
- if (nTableWidth < nTextAreaWidth)
+ // It seems Word has a limit here, so that in case the table width is quite
+ // close to the text area width, then it won't perform a wrapping, even in
+ // case the content (e.g. an empty paragraph) would fit. The magic constant
+ // here represents this limit.
+ const sal_Int32 nMagicNumber = 469;
+
+ // If the table's with is smaller than the text area width, text might
+ // be next to the table and so it should behave as a floating table.
+ if ( nTableWidth < nTextAreaWidth )
return true;
- // If the position is relative to the edge of the page, then we always
- // create the fly.
- if (rInfo.getPropertyValue("HoriOrientRelation") == text::RelOrientation::PAGE_FRAME)
- return true;
+ // If the position is relative to the edge of the page, then we need to check the whole
+ // page width to see whether text can fit next to the table.
+ if ( rInfo.getPropertyValue( "HoriOrientRelation" ) == text::RelOrientation::PAGE_FRAME )
+ {
+ // If the table is wide enough to that no text fits next to it, then don't create a fly
+ // for the table: no wrapping will be performed anyway, but multi-page
+ // tables will be broken.
+ if ((nTableWidth + nMagicNumber) < (nPageWidth - std::min(GetLeftMargin(), GetRightMargin())))
+ return true;
+ }
// If there are columns, always create the fly, otherwise the columns would
// restrict geometry of the table.