[Libreoffice-commits] core.git: sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Apr 8 10:57:20 UTC 2016
sw/qa/extras/ooxmlimport/data/tdf99140.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 9 +++++++++
writerfilter/source/dmapper/PropertyMap.cxx | 25 ++++++++++++++++++++++++-
3 files changed, 33 insertions(+), 1 deletion(-)
New commits:
commit c07f04ab422eadba0f2c3c128a0e3ff78e90cdf2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Apr 8 11:13:46 2016 +0200
tdf#99140 DOCX import: fix table at the bottom of the page to span over ...
... multiple pages.
In short, one more blacklist entry when conversion should not be
performed.
Change-Id: I764f02cc58ae1b7af802b81e570e4feaf73ee2c1
Reviewed-on: https://gerrit.libreoffice.org/23912
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sw/qa/extras/ooxmlimport/data/tdf99140.docx b/sw/qa/extras/ooxmlimport/data/tdf99140.docx
new file mode 100644
index 0000000..42fa73d
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf99140.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 25008a3..da3ccc7d 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -3224,6 +3224,15 @@ DECLARE_OOXMLIMPORT_TEST(testTdf99074, "tdf99074.docx")
CPPUNIT_ASSERT(getProperty<bool>(xSettings, "InBrowseMode"));
}
+DECLARE_OOXMLIMPORT_TEST(testTdf99140, "tdf99140.docx")
+{
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xTextDocument, uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+ // This was 1: a multi-page floating table was imported as a TextFrame.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index ff8e5f3..bd88d4d 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -36,6 +36,8 @@
#include <com/sun/star/style/XStyle.hpp>
#include <com/sun/star/table/ShadowFormat.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/text/VertOrientation.hpp>
#include <com/sun/star/text/WritingMode.hpp>
#include <com/sun/star/text/XTextColumns.hpp>
#include <com/sun/star/text/XText.hpp>
@@ -1044,7 +1046,8 @@ bool SectionPropertyMap::FloatingTableConversion(FloatingTableInfo& rInfo)
// table that is floating and can span over multiple pages at the same
// time.
- sal_Int32 nTextAreaWidth = GetPageWidth() - GetLeftMargin() - GetRightMargin();
+ sal_Int32 nPageWidth = GetPageWidth();
+ sal_Int32 nTextAreaWidth = nPageWidth - GetLeftMargin() - GetRightMargin();
// Count the layout width of the table.
sal_Int32 nTableWidth = rInfo.m_nTableWidth;
sal_Int32 nLeftMargin = 0;
@@ -1054,6 +1057,26 @@ bool SectionPropertyMap::FloatingTableConversion(FloatingTableInfo& rInfo)
if (rInfo.getPropertyValue("RightMargin") >>= nRightMargin)
nTableWidth += nRightMargin;
+ sal_Int16 nHoriOrientRelation = rInfo.getPropertyValue("HoriOrientRelation").get<sal_Int16>();
+ sal_Int16 nVertOrientRelation = rInfo.getPropertyValue("VertOrientRelation").get<sal_Int16>();
+ if (nHoriOrientRelation == text::RelOrientation::PAGE_FRAME && nVertOrientRelation == text::RelOrientation::PAGE_FRAME)
+ {
+ sal_Int16 nHoriOrient = rInfo.getPropertyValue("HoriOrient").get<sal_Int16>();
+ sal_Int16 nVertOrient = rInfo.getPropertyValue("VertOrient").get<sal_Int16>();
+ if (nHoriOrient == text::HoriOrientation::NONE && nVertOrient == text::VertOrientation::NONE)
+ {
+ // Anchor position is relative to the page horizontally and vertically as well and is an absolute position.
+ // The more close we are to the left edge, the less likely there will be any wrapping.
+ // The more close we are to the bottom, the more likely the table will span over to the next page
+ // So if we're in the bottom left quarter, don't do any conversion.
+ sal_Int32 nHoriOrientPosition = rInfo.getPropertyValue("HoriOrientPosition").get<sal_Int32>();
+ sal_Int32 nVertOrientPosition = rInfo.getPropertyValue("VertOrientPosition").get<sal_Int32>();
+ sal_Int32 nPageHeight = getProperty(PROP_HEIGHT)->second.get<sal_Int32>();
+ if (nHoriOrientPosition < (nPageWidth / 2) && nVertOrientPosition > (nPageHeight / 2))
+ return false;
+ }
+ }
+
// 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.
More information about the Libreoffice-commits
mailing list