Kaydet (Commit) ba18832c authored tarafından Mike Kaganski's avatar Mike Kaganski Kaydeden (comit) Miklos Vajna

tdf#75221: make margin collapsing implementation conform OASIS proposal

Since the margin collapsing (aka contextual spacing, implemented
for LO 3.6 by Miklos Vajna, commits
6f04bf5e,
0662778b,
11059331,
03f9b6be,
8631dbf8,
9f4bb5bd,
f722299e) is only meant
to suppress fo:margin-top and fo:margin-bottom, as seen in
https://issues.oasis-open.org/browse/OFFICE-3767, current
implementation is inconsistent: it nullifies all spacing, including
normal line spacing.

This patch makes sure that collapsing conforms to specification.

Change-Id: I413f6469d7891dd85f1f7a2c666f219187ddaec4
Reviewed-on: https://gerrit.libreoffice.org/28692Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst d45d8ae3
......@@ -658,5 +658,14 @@ DECLARE_ODFIMPORT_TEST(testFdo47267, "fdo47267-3.odt")
// This was a Style Families getByName() crash
}
DECLARE_ODFIMPORT_TEST(testTdf75221, "tdf75221.odt")
{
// When "Don't add space between paragraphs of the same style" setting set,
// spacing between same-style paragraphs must be equal to their line spacing.
// It used to be 0.
OUString top = parseDump("/root/page/body/txt[2]/infos/prtBounds", "top");
CPPUNIT_ASSERT(top.toInt32() > 0);
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -1391,6 +1391,10 @@ SwTwips SwFlowFrame::CalcUpperSpace( const SwBorderAttrs *pAttrs,
const bool bUseFormerLineSpacing = rIDSA.get(DocumentSettingId::OLD_LINE_SPACING);
if( pPrevFrame )
{
const bool bContextualSpacing = pAttrs->GetULSpace().GetContext()
&& lcl_getContextualSpacing(pPrevFrame)
&& lcl_IdenticalStyles(pPrevFrame, &m_rThis);
// OD 2004-03-10 #i11860# - use new method to determine needed spacing
// values of found previous frame and use these values.
SwTwips nPrevLowerSpace = 0;
......@@ -1402,7 +1406,7 @@ SwTwips SwFlowFrame::CalcUpperSpace( const SwBorderAttrs *pAttrs,
bPrevLineSpacingPorportional );
if( rIDSA.get(DocumentSettingId::PARA_SPACE_MAX) )
{
nUpper = nPrevLowerSpace + pAttrs->GetULSpace().GetUpper();
nUpper = (bContextualSpacing) ? 0 : nPrevLowerSpace + pAttrs->GetULSpace().GetUpper();
SwTwips nAdd = nPrevLineSpacing;
// OD 07.01.2004 #i11859# - consideration of the line spacing
// for the upper spacing of a text frame
......@@ -1445,8 +1449,8 @@ SwTwips SwFlowFrame::CalcUpperSpace( const SwBorderAttrs *pAttrs,
}
else
{
nUpper = std::max( static_cast<long>(nPrevLowerSpace),
static_cast<long>(pAttrs->GetULSpace().GetUpper()) );
nUpper = bContextualSpacing ? 0 : std::max(static_cast<long>(nPrevLowerSpace),
static_cast<long>(pAttrs->GetULSpace().GetUpper()) );
// OD 07.01.2004 #i11859# - consideration of the line spacing
// for the upper spacing of a text frame
if ( bUseFormerLineSpacing )
......@@ -1510,16 +1514,7 @@ SwTwips SwFlowFrame::CalcUpperSpace( const SwBorderAttrs *pAttrs,
{
nUpper += GetUpperSpaceAmountConsideredForPageGrid_( nUpper );
}
const bool bContextualSpacing = pAttrs->GetULSpace().GetContext();
if (bContextualSpacing && pPrevFrame && lcl_getContextualSpacing(pPrevFrame)
&& lcl_IdenticalStyles(pPrevFrame, &m_rThis))
{
return 0;
}
else
return nUpper;
return nUpper;
}
/** method to detemine the upper space amount, which is considered for
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment