diff options
-rw-r--r-- | sw/qa/core/layout/calcmove.cxx | 18 | ||||
-rw-r--r-- | sw/qa/core/layout/data/ignore-top-margin-page-style-change.docx | bin | 0 -> 12243 bytes | |||
-rw-r--r-- | sw/source/core/layout/calcmove.cxx | 10 |
3 files changed, 28 insertions, 0 deletions
diff --git a/sw/qa/core/layout/calcmove.cxx b/sw/qa/core/layout/calcmove.cxx index 0fca693eca54..893d3fd89915 100644 --- a/sw/qa/core/layout/calcmove.cxx +++ b/sw/qa/core/layout/calcmove.cxx @@ -84,6 +84,24 @@ CPPUNIT_TEST_FIXTURE(Test, testIgnoreTopMarginFly) CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4000), nParaTopMargin); } +CPPUNIT_TEST_FIXTURE(Test, testIgnoreTopMarginPageStyleChange) +{ + // Given a DOCX (>= Word 2013), section break (next page) between pages 2 and 3: + createSwDoc("ignore-top-margin-page-style-change.docx"); + + // When laying out that document: + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + + // Then make sure that the top margin is not ignored on page 3: + sal_Int32 nParaTopMargin + = getXPath(pXmlDoc, "/root/page[3]/body/txt/infos/prtBounds", "top").toInt32(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2000 + // - Actual : 0 + // i.e. the top margin was ignored, which is incorrect. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2000), nParaTopMargin); +} + CPPUNIT_TEST_FIXTURE(Test, testHideWhitespaceGrowingLastPage) { // Given a document with a full first page, then hiding whitespace: diff --git a/sw/qa/core/layout/data/ignore-top-margin-page-style-change.docx b/sw/qa/core/layout/data/ignore-top-margin-page-style-change.docx Binary files differnew file mode 100644 index 000000000000..ea7d16d8851f --- /dev/null +++ b/sw/qa/core/layout/data/ignore-top-margin-page-style-change.docx diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index a591ec954795..43b3c5d8afda 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -1131,6 +1131,16 @@ bool SwFrame::IsCollapseUpper() const return false; } + // Avoid the ignore after applying a new page style (but do it after page breaks). + const SwTextNode* pTextNode = pTextFrame->GetTextNodeForParaProps(); + if (pTextNode) + { + if (pTextNode->HasSwAttrSet() && pTextNode->GetSwAttrSet().HasItem(RES_PAGEDESC)) + { + return false; + } + } + return true; } |