diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2016-09-08 07:20:18 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-08 21:08:56 +0000 |
commit | ba18832ceeda21f047a664b71a4333a54737e6c8 (patch) | |
tree | 22eed6857474964d19ffd5f57e8e2e19dbac3140 | |
parent | d45d8ae3c51606eb1d9e63396a0eab13c8742907 (diff) |
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
6f04bf5e90ff75288dcf75c43843edf798641e3d,
0662778b0b4b9958ee5e5bd3bac69f9e290f9495,
11059331718fb8faab483c75633b4e80d8028b7d,
03f9b6bebc0ca77021be46664c7bcbe4cb297503,
8631dbf85fb5ed56d225e32ea5a9c36c96b0d649,
9f4bb5bd4f55b4a80544413efde26391849b1d7f,
f722299e133568fe75f7cf9ce0c103a1553474c4) 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/28692
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | sw/qa/extras/odfimport/data/tdf75221.odt | bin | 0 -> 9131 bytes | |||
-rw-r--r-- | sw/qa/extras/odfimport/odfimport.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/layout/flowfrm.cxx | 21 |
3 files changed, 17 insertions, 13 deletions
diff --git a/sw/qa/extras/odfimport/data/tdf75221.odt b/sw/qa/extras/odfimport/data/tdf75221.odt Binary files differnew file mode 100644 index 000000000000..6ef117c24e29 --- /dev/null +++ b/sw/qa/extras/odfimport/data/tdf75221.odt diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 02fb8b1ba361..ceb55723e01a 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -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: */ diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 874733aae120..0ab2319afb3e 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -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 |