summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2014-07-21 10:56:52 +0200
committerLuboš Luňák <l.lunak@collabora.com>2014-07-21 11:02:04 +0200
commitc5ed52b1cd6f22787c94bec035ceecf9e1da3271 (patch)
treeb438551504bb36ae1ac4bb2fb44b091420ed2d68
parent2aa6589aa5bbcd7cd74b33b81e431fb6837a2458 (diff)
ww8import create a pagedesc if continuous section changes margins (bnc#875383)
This is similar to what writerfilter does. MSWord can have one page with several different margins, which are saved using continuous sections, which causes all kinds of trouble, because either we treat them as Writer sections, which means we lose some of the data, or we treat them as Writer page styles, which causes spurious page breaks if in the wrong place. Either option has its problems, but here it seems slightly better to go for keeping the data and hoping the page break will be in a place where a break will be anyway. Change-Id: I8f52aa820750da6788ea04180a15ac334f6bf87b
-rw-r--r--sw/qa/extras/ww8import/data/floating-table-section-margins.docbin0 -> 38400 bytes
-rw-r--r--sw/qa/extras/ww8import/ww8import.cxx12
-rw-r--r--sw/source/filter/ww8/ww8par.cxx4
3 files changed, 16 insertions, 0 deletions
diff --git a/sw/qa/extras/ww8import/data/floating-table-section-margins.doc b/sw/qa/extras/ww8import/data/floating-table-section-margins.doc
new file mode 100644
index 000000000000..f414be7f1ec8
--- /dev/null
+++ b/sw/qa/extras/ww8import/data/floating-table-section-margins.doc
Binary files differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index a5f3a8ca973c..fe4a8fcca05a 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -34,6 +34,18 @@ public:
#define DECLARE_WW8IMPORT_TEST(TestName, filename) DECLARE_SW_IMPORT_TEST(TestName, filename, Test)
+DECLARE_WW8IMPORT_TEST(testFloatingTableSectionMargins, "floating-table-section-margins.doc")
+{
+ sal_Int32 pageLeft = parseDump("/root/page[2]/infos/bounds", "left").toInt32();
+ sal_Int32 pageWidth = parseDump("/root/page[2]/infos/bounds", "width").toInt32();
+ sal_Int32 tableLeft = parseDump("/root/page[2]/body/column/body/section/column/body/txt[2]/anchored/fly/tab/infos/bounds", "left").toInt32();
+ sal_Int32 tableWidth = parseDump("/root/page[2]/body/column/body/section/column/body/txt[2]/anchored/fly/tab/infos/bounds", "width").toInt32();
+ CPPUNIT_ASSERT( pageWidth > 0 );
+ CPPUNIT_ASSERT( tableWidth > 0 );
+ // The table's resulting position should be roughly centered.
+ CPPUNIT_ASSERT( abs(( pageLeft + pageWidth / 2 ) - ( tableLeft + tableWidth / 2 )) < 20 );
+}
+
DECLARE_WW8IMPORT_TEST(testN757910, "n757910.doc")
{
// The internal margin was larger than 0.28cm
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 56c184d366ea..09062322a65e 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4440,6 +4440,10 @@ void wwSectionManager::InsertSegments()
bool bInsertSection = (aIter != aStart) && aIter->IsContinuous() && bThisAndPreviousAreCompatible;
bool bInsertPageDesc = !bInsertSection;
+ // HACK Force new pagedesc if margins change, otherwise e.g. floating tables may be anchored improperly.
+ if( aIter->maSep.dyaTop != aPrev->maSep.dyaTop || aIter->maSep.dyaBottom != aPrev->maSep.dyaBottom
+ || aIter->maSep.dxaLeft != aPrev->maSep.dxaLeft || aIter->maSep.dxaRight != aPrev->maSep.dxaRight )
+ bInsertPageDesc = true;
bool bProtected = SectionIsProtected(*aIter); // do we really need this ?? I guess I have a different logic in editshell which disables this...
if (bUseEnhFields && mrReader.pWDop->fProtEnabled && aIter->IsNotProtected())
{