summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2022-10-28 17:54:32 +0200
committerArmin Le Grand <Armin.Le.Grand@me.com>2022-10-31 10:01:46 +0100
commit604f6fc8fe7438f7cfbcfc8a3107ace59e950627 (patch)
tree33b5a08ea57b14281bf1a16662cb2f8019ab7a2b /sc
parentd3caee0a7af6d184e950414d880be29cbab60498 (diff)
tdf#143377 Correct maximum Skew for TextOrientation in Calc
For zero or 180 degree text orinentation errors can happen in the Border visualization, theoretically also in the Text rendering. Ths has to do with sin(0) and sin(180) being zero and lead internal to numerical problems, e.g. a very huge Skew that when applied show the reported 'errors'. I limit this mechanism now to +/- 1/2 degree from the critical mentioned places, for Border and Text - to not risk to have different points of corrections. The UI only allows angles of 1 degree steps, but UNO API and pdf import may allow more. Change-Id: Idbc68f6a7beab84df0672165c2a813d96eeff84e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141999 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/view/output2.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index a7efd3dbb088..abee5a2e8756 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -4689,15 +4689,25 @@ void ScOutputData::DrawRotated(bool bPixelToLogic)
{
eRotMode = pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet).GetValue();
- if ( nAttrRotate == 18000_deg100 )
+ // tdf#143377 To use the same limits to avoid too big Skew
+ // with TextOrientation in Calc, use 1/2 degree here, too.
+ // This equals '50' in the notation here
+ const bool bForbidSkew(
+ nAttrRotate < Degree100(50) || // range [0..50]
+ nAttrRotate > Degree100(36000 - 50) || // range [35950..36000[
+ (nAttrRotate > Degree100(18000 - 50) && (nAttrRotate < Degree100(18000 + 50)))); // range 50 around 18000
+
+ if ( bForbidSkew )
+ {
eRotMode = SVX_ROTATE_MODE_STANDARD; // no overflow
+ }
if ( bLayoutRTL )
nAttrRotate = -nAttrRotate;
double nRealOrient = toRadians(nAttrRotate); // 1/100 degree
nCos = cos( nRealOrient );
- nSin = sin( nRealOrient );
+ nSin = bForbidSkew ? 0 : sin( nRealOrient );
}
}