diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-10-08 10:48:36 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-10-08 12:09:02 +0200 |
commit | cb9ba1c2d0202b1932b637d83a9458879a1f2e6a (patch) | |
tree | 58c9c5a39a2071299207d140ad7cb4ebd9f08ffb /sw/source | |
parent | 98dd271c7228a4cf03a995d98eba8a1d64ad92f8 (diff) |
Related: tdf#120287 sw layout, TabOverMargin: fix left margin handling
The old code only worked when left and first margin was 0; feed the
relevant margin to SwTextFormatInfo, so SwTextFormatInfo::GetLineWidth()
can compare against the right rectangle.
This way TabOverMargin compat flag results in layout that matches the
Word behavior for all 3 bugdocs from the bugreport.
Change-Id: I6f81ad33b14e95ba4213c8956b3a9790ba6eee84
Reviewed-on: https://gerrit.libreoffice.org/61518
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/text/inftxt.cxx | 20 | ||||
-rw-r--r-- | sw/source/core/text/inftxt.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/text/itrform2.cxx | 1 |
3 files changed, 22 insertions, 2 deletions
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 74a046232bcd..da7f5ce7066a 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -1706,9 +1706,25 @@ SwTwips SwTextFormatInfo::GetLineWidth() if (pLastTab->GetTabPos() <= Width()) return nLineWidth; + // Calculate the width that starts at the left (or in case of first line: + // first) margin, but ends after the right paragraph margin: + // + // +--------------------+ + // |LL| |RR| + // +--------------------+ + // ^ m_nLeftMargin (absolute) + // ^ nLeftMarginWidth (relative to m_nLeftMargin), X() is relative to this + // ^ right margin + // ^ paragraph right + // <--------------------> is GetTextFrame()->getFrameArea().Width() + // <--------------> is Width() + // <-----------------> is what we need to be able to compare to X() (nTextFrameWidth) + SwTwips nLeftMarginWidth = m_nLeftMargin - GetTextFrame()->getFrameArea().Left(); + SwTwips nTextFrameWidth = GetTextFrame()->getFrameArea().Width() - nLeftMarginWidth; + // If there is one such tab portion, then text is allowed to use the full - // text frame area (even over the actual tab portion). - nLineWidth = GetTextFrame()->getFrameArea().Width() - X(); + // text frame area to the right (RR above, but not LL). + nLineWidth = nTextFrameWidth - X(); return nLineWidth; } diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx index d7881834cadf..d7a826635dc0 100644 --- a/sw/source/core/text/inftxt.hxx +++ b/sw/source/core/text/inftxt.hxx @@ -488,6 +488,8 @@ class SwTextFormatInfo : public SwTextPaintInfo SwTwips m_nLeft; // Left margin SwTwips m_nRight; // Right margin SwTwips m_nFirst; // EZE + /// First or left margin, depending on context. + SwTwips m_nLeftMargin = 0; sal_uInt16 m_nRealWidth; // "real" line width sal_uInt16 m_nWidth; // "virtual" line width sal_uInt16 m_nLineHeight; // Final height after CalcLine @@ -555,6 +557,7 @@ public: void Right( const SwTwips nNew ) { m_nRight = nNew; } SwTwips First() const { return m_nFirst; } void First( const SwTwips nNew ) { m_nFirst = nNew; } + void LeftMargin( const SwTwips nNew) { m_nLeftMargin = nNew; } sal_uInt16 RealWidth() const { return m_nRealWidth; } void RealWidth( const sal_uInt16 nNew ) { m_nRealWidth = nNew; } sal_uInt16 ForcedLeftMargin() const { return m_nForcedLeftMargin; } diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 16d35e581131..28933fa55922 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -1847,6 +1847,7 @@ void SwTextFormatter::FeedInf( SwTextFormatInfo &rInf ) const rInf.Left( Left() ); rInf.Right( Right() ); rInf.First( FirstLeft() ); + rInf.LeftMargin(GetLeftMargin()); rInf.RealWidth( sal_uInt16(rInf.Right() - GetLeftMargin()) ); rInf.Width( rInf.RealWidth() ); |