tdf#134463 DOCX import: fix other "half" of contextualSpacing

Always ignore own bottom margin setting of the previous paragraph
with contextual spacing, if the actual paragraph is identical.
I.e. in that case, too, when the actual paragraph has no
contextual spacing, like MSO does.

Note: PARA_SPACE_MAX mode hasn't included this modification,
yet, so only ODT documents converted from DOCX use it at the
default setting.

See also commit e318d5d814
(tdf#125893 DOCX import: fix "half" contextual paragraph spacing).

Change-Id: I83fab2a2d85eeb9d48a8546d5a4e6423988d642c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97874
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
This commit is contained in:
László Németh
2020-07-03 22:59:58 +02:00
parent b6b7415095
commit a5073875fe
3 changed files with 25 additions and 7 deletions
Binary file not shown.
+8
View File
@@ -3113,6 +3113,14 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf125893)
assertXPath(pXmlDoc, "/root/page/body/txt[4]/infos/prtBounds", "top", "0");
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf134463)
{
createDoc("tdf134463.docx");
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
// This was 621. The previous paragraph must have zero bottom border.
assertXPath(pXmlDoc, "/root/page/body/txt[3]/infos/prtBounds", "top", "21");
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf117188)
{
createDoc("tdf117188.docx");
+17 -7
View File
@@ -1421,16 +1421,25 @@ SwTwips SwFlowFrame::CalcUpperSpace( const SwBorderAttrs *pAttrs,
if( pPrevFrame )
{
const bool bUseFormerLineSpacing = rIDSA.get(DocumentSettingId::OLD_LINE_SPACING);
const bool bContextualSpacing = pAttrs->GetULSpace().GetContext()
&& lcl_getContextualSpacing(pPrevFrame)
const bool bContextualSpacingThis = pAttrs->GetULSpace().GetContext();
const bool bContextualSpacingPrev = lcl_getContextualSpacing(pPrevFrame);
const bool bContextualSpacing = bContextualSpacingThis
&& bContextualSpacingPrev
&& lcl_IdenticalStyles(pPrevFrame, &m_rThis);
// tdf#125893 always ignore own top margin setting of the actual paragraph
// with contextual spacing, if the previous paragraph is identical
const bool bHalfContextualSpacing = !bContextualSpacing
&& pAttrs->GetULSpace().GetContext()
&& !lcl_getContextualSpacing(pPrevFrame)
&& lcl_getContextualSpacing(&m_rThis)
&& bContextualSpacingThis
&& !bContextualSpacingPrev
&& lcl_IdenticalStyles(pPrevFrame, &m_rThis);
// tdf#134463 always ignore own bottom margin setting of the previous paragraph
// with contextual spacing, if the actual paragraph is identical
const bool bHalfContextualSpacingPrev = !bContextualSpacing
&& !bContextualSpacingThis
&& bContextualSpacingPrev
&& lcl_IdenticalStyles(pPrevFrame, &m_rThis);
// i#11860 - use new method to determine needed spacing
@@ -1488,8 +1497,9 @@ SwTwips SwFlowFrame::CalcUpperSpace( const SwBorderAttrs *pAttrs,
}
else
{
nUpper = bContextualSpacing ? 0 : std::max(static_cast<long>(nPrevLowerSpace), bHalfContextualSpacing
? 0 : static_cast<long>(pAttrs->GetULSpace().GetUpper()) );
nUpper = bContextualSpacing ? 0 : std::max(
bHalfContextualSpacingPrev ? 0 : static_cast<long>(nPrevLowerSpace),
bHalfContextualSpacing ? 0 : static_cast<long>(pAttrs->GetULSpace().GetUpper()) );
// i#11859 - consideration of the line spacing
// for the upper spacing of a text frame