diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-03-17 23:49:37 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-03-19 16:10:33 +0100 |
commit | 68fd5b36e31f7d0efbefc14d018b10cc9c7de22c (patch) | |
tree | 38f7a4edb25b15306f8a68e43f8f8c13f6956ff7 /sw/source | |
parent | e0b94a575024b6d20c4adb117a6d3a0079d80d39 (diff) |
tdf#112118: Use correct border when calculating margin
This is a longstanding (at least since 2000: already present in commit
7b0b5cdf) error where left border linespace was used when calculating
right margin. It was copypasted from ww8 import to ooxml code verbatim.
The problem only manifests itself when left and right border spacings
are not the same; and since we had other errors in the borders import,
that additional problem simply wasn't apparent.
Also use scaled border width in border distance/margin calculations.
Unit tests updated.
Change-Id: I70961e1bde29471def69e1ef944ba2779cffe307
Reviewed-on: https://gerrit.libreoffice.org/51474
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/51489
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/tox/ToxTabStopTokenHandler.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 2 |
4 files changed, 6 insertions, 8 deletions
diff --git a/sw/source/core/tox/ToxTabStopTokenHandler.cxx b/sw/source/core/tox/ToxTabStopTokenHandler.cxx index 53bae640e396..6360dfe6f91c 100644 --- a/sw/source/core/tox/ToxTabStopTokenHandler.cxx +++ b/sw/source/core/tox/ToxTabStopTokenHandler.cxx @@ -95,9 +95,7 @@ DefaultToxTabStopTokenHandler::CalculatePageMarginFromPageDescription(const SwTe - rPgDscFormat.GetLRSpace().GetRight(); // Also consider borders const SvxBoxItem& rBox = rPgDscFormat.GetBox(); - for (SvxBoxItemLine eLine : { SvxBoxItemLine::LEFT, SvxBoxItemLine::RIGHT }) - if (const editeng::SvxBorderLine* pBorder = rBox.GetLine(eLine)) - result -= pBorder->GetWidth() + rBox.GetDistance(eLine); + result -= rBox.CalcLineSpace(SvxBoxItemLine::LEFT) + rBox.CalcLineSpace(SvxBoxItemLine::RIGHT); return result; } diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 824ea4498100..859b9925ae65 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -7440,8 +7440,8 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) if ( auto pBoxItem = static_cast<const SvxBoxItem*>(m_rExport.HasItem( RES_BOX )) ) { - m_pageMargins.nRight = pBoxItem->CalcLineSpace( SvxBoxItemLine::LEFT, /*bEvenIfNoLine*/true ); - m_pageMargins.nLeft = pBoxItem->CalcLineSpace( SvxBoxItemLine::RIGHT, /*bEvenIfNoLine*/true ); + m_pageMargins.nLeft = pBoxItem->CalcLineSpace( SvxBoxItemLine::LEFT, /*bEvenIfNoLine*/true ); + m_pageMargins.nRight = pBoxItem->CalcLineSpace( SvxBoxItemLine::RIGHT, /*bEvenIfNoLine*/true ); } m_pageMargins.nLeft += sal::static_int_cast<sal_uInt16>(rLRSpace.GetLeft()); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 67a4655c0081..7c36f4977faa 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -3685,8 +3685,8 @@ void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR ) if ( auto pBoxItem = static_cast<const SvxBoxItem*>(m_rWW8Export.HasItem( RES_BOX )) ) { - m_pageMargins.nRight = pBoxItem->CalcLineSpace( SvxBoxItemLine::LEFT, /*bEvenIfNoLine*/true ); - m_pageMargins.nLeft = pBoxItem->CalcLineSpace( SvxBoxItemLine::RIGHT, /*bEvenIfNoLine*/true ); + m_pageMargins.nLeft = pBoxItem->CalcLineSpace( SvxBoxItemLine::LEFT, /*bEvenIfNoLine*/true ); + m_pageMargins.nRight = pBoxItem->CalcLineSpace( SvxBoxItemLine::RIGHT, /*bEvenIfNoLine*/true ); } m_pageMargins.nLeft += sal::static_int_cast<sal_uInt16>(rLR.GetLeft()); diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index b11a800bd3c8..b24434aebd4f 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -439,7 +439,7 @@ long SetBorderDistance(bool bFromEdge, SvxBoxItem& aBox, SvxBoxItemLine eLine, l return nMSMargin; sal_Int32 nNewMargin = nMSMargin; sal_Int32 nNewDist = aBox.GetDistance(eLine); - sal_Int32 nLineWidth = pLine->GetWidth(); + sal_Int32 nLineWidth = pLine->GetScaledWidth(); editeng::BorderDistanceFromWord(bFromEdge, nNewMargin, nNewDist, nLineWidth); aBox.SetDistance(nNewDist, eLine); |