summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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())
{