tdf#164095 sw: fix missing top margin on paragraph after changing page style
Open the bugdoc, go to the page after the section break, there is a top
margin for the first paragraph there in Word, but not in Writer.
This went wrong in commit abd90828cf
(tdf#160952 sw: ignore top margin of para on non-first pages with newer
DOCX, 2024-05-14), where it seemed that all implicit and explicit page
breaks want to ignore that top margin for the first paragraph.
Turns out this is more complex: implicit breaks and page breaks should
be followed by an ignore, but not paragraphs after "section break (next
page)". So restore the margins for the RES_PAGEDESC, but continue to
have them for RES_BREAK & implicit breaks.
Change-Id: If1fcf3077b81a705d3587bdae422dcfa16f1c17c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177973
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
parent
7bd7adc338
commit
ae7900dd42
3 changed files with 28 additions and 0 deletions
|
@ -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:
|
||||
|
|
BIN
sw/qa/core/layout/data/ignore-top-margin-page-style-change.docx
Normal file
BIN
sw/qa/core/layout/data/ignore-top-margin-page-style-change.docx
Normal file
Binary file not shown.
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue