diff options
author | Tibor Nagy <nagy.tibor2@nisz.hu> | 2021-03-04 14:30:21 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-03-26 14:41:03 +0100 |
commit | 967e0cc303c7be4a88905b327b9d02ba12f5e375 (patch) | |
tree | 94ab66d2ae4564227294a4971f3b4ac96d1a811e /editeng | |
parent | ed62bbc71a8469fe74a699528398326e551e7301 (diff) |
tdf#119292 sc layout: fix overlapping wrapped cell texts
if rotated by 90 or 270 degrees using clipping to
cell boundaries, like MSO does. E.g. this avoid of
importing MSO documents with unreadable header cells.
Note: it's possible to improve the patch extending
clipping for the neighboring empty area instead of
clipping all text exceeding the cell boundary
(as in the case of the non-rotated, non-wrapped text).
Co-authored-by: Attila Szűcs (NISZ)
Change-Id: Idd37f7eb7208ff3818dcdab93ef0ec57275db954
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111964
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/items/svxfont.cxx | 74 |
1 files changed, 52 insertions, 22 deletions
diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx index f5d0e2d79a26..61039b316ac6 100644 --- a/editeng/source/items/svxfont.cxx +++ b/editeng/source/items/svxfont.cxx @@ -86,32 +86,62 @@ void SvxFont::SetNonAutoEscapement(short nNewEsc, const OutputDevice* pOutDev) nEsc = -MAX_ESC_POS; } -void SvxFont::DrawArrow( OutputDevice &rOut, const tools::Rectangle& rRect, - const Size& rSize, const Color& rCol, bool bLeft ) +tools::Polygon SvxFont::DrawArrow( OutputDevice &rOut, const tools::Rectangle& rRect, + const Size& rSize, const Color& rCol, bool bLeftOrTop, bool bVertical ) { - tools::Long nLeft = ( rRect.Left() + rRect.Right() - rSize.Width() )/ 2; - tools::Long nRight = nLeft + rSize.Width(); - tools::Long nMid = ( rRect.Top() + rRect.Bottom() ) / 2; - tools::Long nTop = nMid - rSize.Height() / 2; - tools::Long nBottom = nTop + rSize.Height(); - if( nLeft < rRect.Left() ) + tools::Polygon aPoly; + Point aTmp; + Point aNxt; + if (bVertical) { - nLeft = rRect.Left(); - nRight = rRect.Right(); + tools::Long nLeft = ((rRect.Left() + rRect.Right()) / 2) - (rSize.Height() / 2); + tools::Long nRight = ((rRect.Left() + rRect.Right()) / 2) + (rSize.Height() / 2); + tools::Long nMid = (rRect.Left() + rRect.Right()) / 2; + tools::Long nTop = ((rRect.Top() + rRect.Bottom()) / 2) - (rSize.Height() / 2); + tools::Long nBottom = nTop + rSize.Height(); + if (nTop < rRect.Top()) + { + if (bLeftOrTop) + { + nTop = rRect.Top(); + nBottom = rRect.Bottom(); + } + else + { + nTop = rRect.Bottom(); + nBottom = rRect.Bottom() - (rSize.Height() / 2); + } + } + aTmp.setX(nRight); + aTmp.setY(nBottom); + aNxt.setX(nMid); + aNxt.setY(nTop); + aPoly.Insert(0, aTmp); + aPoly.Insert(0, aNxt); + aTmp.setX(nLeft); + aPoly.Insert(0, aTmp); } - if( nTop < rRect.Top() ) + else { - nTop = rRect.Top(); - nBottom = rRect.Bottom(); + tools::Long nLeft = (rRect.Left() + rRect.Right() - rSize.Width()) / 2; + tools::Long nRight = nLeft + rSize.Width(); + tools::Long nMid = (rRect.Top() + rRect.Bottom()) / 2; + tools::Long nTop = nMid - rSize.Height() / 2; + tools::Long nBottom = nTop + rSize.Height(); + if (nLeft < rRect.Left()) + { + nLeft = rRect.Left(); + nRight = rRect.Right(); + } + aTmp.setX(bLeftOrTop ? nLeft : nRight); + aTmp.setY(nMid); + aNxt.setX(bLeftOrTop ? nRight : nLeft); + aNxt.setY(nTop); + aPoly.Insert(0, aTmp); + aPoly.Insert(0, aNxt); + aNxt.setY(nBottom); + aPoly.Insert(0, aNxt); } - tools::Polygon aPoly; - Point aTmp( bLeft ? nLeft : nRight, nMid ); - Point aNxt( bLeft ? nRight : nLeft, nTop ); - aPoly.Insert( 0, aTmp ); - aPoly.Insert( 0, aNxt ); - aNxt.setY( nBottom ); - aPoly.Insert( 0, aNxt ); - aPoly.Insert( 0, aTmp ); Color aOldLineColor = rOut.GetLineColor(); Color aOldFillColor = rOut.GetFillColor(); rOut.SetFillColor( rCol ); @@ -120,9 +150,9 @@ void SvxFont::DrawArrow( OutputDevice &rOut, const tools::Rectangle& rRect, rOut.DrawLine( aTmp, aNxt ); rOut.SetLineColor( aOldLineColor ); rOut.SetFillColor( aOldFillColor ); + return aPoly; } - OUString SvxFont::CalcCaseMap(const OUString &rTxt) const { if (!IsCaseMap() || rTxt.isEmpty()) |