sw/qa/extras/ww8import/data/floating-table-section-margins.doc |binary sw/qa/extras/ww8import/ww8import.cxx | 12 ++++++++++ sw/source/filter/ww8/ww8par.cxx | 4 +++ 3 files changed, 16 insertions(+)
New commits: commit 75b89f28b9b3dddf3f5c64c94012528390a0e4f4 Author: LuboÅ¡ LuÅák <l.lu...@collabora.com> Date: Mon Jul 21 10:56:52 2014 +0200 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 Reviewed-on: https://gerrit.libreoffice.org/10432 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Miklos Vajna <vmik...@collabora.co.uk> 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 0000000..f414be7 Binary files /dev/null and b/sw/qa/extras/ww8import/data/floating-table-section-margins.doc differ diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index 68cb9c8..5075b8f 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -36,6 +36,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 11fafbe..ccdc07c 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -4446,6 +4446,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()) {
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits