From 8029179e35fcda5867769d4ca6f7ee32bca3e9bc Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 29 Jan 2020 18:52:07 +0100 Subject: sw: fix rotation bugs in SwLinePortion::PrePaint() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sign was flipped for the 90° case, resulting in painting too far up the page, ever since this was added in 293ed704cf15107049578c2e6e5ed00dcac2d4fb. In SwControlCharPortion::Paint() rotation wasn't handled at all. Change-Id: I83a7eef8b2f6126e070d8c48f75378b6cf6d50e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87707 Tested-by: Jenkins Reviewed-by: Michael Stahl --- sw/source/core/text/porlin.cxx | 4 ++-- sw/source/core/text/porrst.cxx | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/sw/source/core/text/porlin.cxx b/sw/source/core/text/porlin.cxx index 0c7ff0252075..b5adccb07fba 100644 --- a/sw/source/core/text/porlin.cxx +++ b/sw/source/core/text/porlin.cxx @@ -114,12 +114,12 @@ void SwLinePortion::PrePaint( const SwTextPaintInfo& rInf, break; case 900: nPos = sal_uInt16( rInf.Y() ); - nPos -= nLastWidth + nHalfView; + nPos -= nLastWidth - nHalfView; aInf.Y( nPos ); break; case 1800: nPos = sal_uInt16( rInf.X() ); - nPos -= nLastWidth + nHalfView; + nPos -= nLastWidth - nHalfView; aInf.X( nPos ); break; case 2700: diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index e4c56b98669f..686959609cd8 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -522,7 +522,22 @@ void SwControlCharPortion::Paint( const SwTextPaintInfo &rInf ) const Point aOldPos = rInf.GetPos(); Point aNewPos( aOldPos ); - aNewPos.setX( aNewPos.X() + ( Width() / 2 ) - mnHalfCharWidth ); + auto const deltaX((Width() / 2) - mnHalfCharWidth); + switch (rInf.GetFont()->GetOrientation(rInf.GetTextFrame()->IsVertical())) + { + case 0: + aNewPos.AdjustX(deltaX); + break; + case 900: + aNewPos.AdjustY(-deltaX); + break; + case 2700: + aNewPos.AdjustY(deltaX); + break; + default: + assert(false); + break; + } const_cast< SwTextPaintInfo& >( rInf ).SetPos( aNewPos ); rInf.DrawText( aOutString, *this ); -- cgit