diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-08-03 13:05:24 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-08-03 21:57:23 +0200 |
commit | 81302f33073e7629d724ed269f1fa21dad29e141 (patch) | |
tree | 59c1a5422fee301751c170e6ea24a3ca9b0caddc /filter | |
parent | 83b25e4b9fa8f95c24759a64f8cb9716ee34a4a3 (diff) |
Move angle normalization code from various places to tools
Also rename svx angle normalization functions in include/svx/svdtrans.hxx, that
deal with 100ths of degree, to avoid confusion: NormAngle180 -> NormAngle18000;
NormAngle360 -> NormAngle36000.
Some places were fixed that previously returned inclusive ranges (i.e., both 0
and 360), see changes in these files:
chart2/source/view/main/PlottingPositionHelper.cxx
chart2/source/view/main/PolarLabelPositionHelper.cxx
chart2/source/view/main/ShapeFactory.cxx
filter/source/graphicfilter/idxf/dxf2mtf.cxx
sw/source/core/graphic/grfatr.cxx
(the latter now matches the comment in the function).
Change-Id: I9f274bbb4168360d60dceff02aeba6332c519a59
Reviewed-on: https://gerrit.libreoffice.org/58556
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/graphicfilter/icgm/actimpr.cxx | 9 | ||||
-rw-r--r-- | filter/source/graphicfilter/idxf/dxf2mtf.cxx | 2 | ||||
-rw-r--r-- | filter/source/msfilter/escherex.cxx | 5 | ||||
-rw-r--r-- | filter/source/msfilter/msdffimp.cxx | 8 |
4 files changed, 9 insertions, 15 deletions
diff --git a/filter/source/graphicfilter/icgm/actimpr.cxx b/filter/source/graphicfilter/icgm/actimpr.cxx index c685ce513269..daa20e40d57f 100644 --- a/filter/source/graphicfilter/icgm/actimpr.cxx +++ b/filter/source/graphicfilter/icgm/actimpr.cxx @@ -45,6 +45,7 @@ #include <comphelper/processfactory.hxx> #include <toolkit/helper/vclunohelper.hxx> +#include <tools/helpers.hxx> #include <vcl/gradient.hxx> #include "main.hxx" @@ -496,12 +497,8 @@ void CGMImpressOutAct::DrawEllipticalArc( FloatPoint const & rCenter, FloatPoint if ( rOrientation != 0 ) { - fStartAngle += rOrientation; - if ( fStartAngle >= 360 ) - fStartAngle -= 360; - fEndAngle += rOrientation; - if ( fEndAngle >= 360 ) - fEndAngle -= 360; + fStartAngle = NormAngle360(fStartAngle + rOrientation); + fEndAngle = NormAngle360(fEndAngle + rOrientation); } switch( nType ) { diff --git a/filter/source/graphicfilter/idxf/dxf2mtf.cxx b/filter/source/graphicfilter/idxf/dxf2mtf.cxx index 40595574dde3..50a988274cff 100644 --- a/filter/source/graphicfilter/idxf/dxf2mtf.cxx +++ b/filter/source/graphicfilter/idxf/dxf2mtf.cxx @@ -192,7 +192,7 @@ bool DXF2GDIMetaFile::SetFontAttribute(const DXFBasicEntity & rE, short nAngle, vcl::Font aFont; nAngle=-nAngle; - while (nAngle>3600) nAngle-=3600; + while (nAngle>=3600) nAngle-=3600; while (nAngle<0) nAngle+=3600; nColor=GetEntityColor(rE); diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index 0540c70be8ef..6bd7638a8cc9 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -2048,10 +2048,7 @@ sal_Int32 lcl_GetConnectorAdjustValue ( const XPolygon& rPoly, sal_uInt16 nIndex void lcl_Rotate(sal_Int32 nAngle, Point center, Point& pt) { - while ( nAngle<0) - nAngle +=36000; - while (nAngle>=36000) - nAngle -=36000; + nAngle = NormAngle36000(nAngle); int cs, sn; switch (nAngle) diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index c232ee0649c1..ff3df05d0cd1 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -371,7 +371,7 @@ sal_Int32 DffPropertyReader::Fix16ToAngle( sal_Int32 nContent ) if ( nContent ) { nAngle = ( static_cast<sal_Int16>( nContent >> 16) * 100L ) + ( ( ( nContent & 0x0000ffff) * 100L ) >> 16 ); - nAngle = NormAngle360( -nAngle ); + nAngle = NormAngle36000( -nAngle ); } return nAngle; } @@ -4567,7 +4567,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r { double fNumber; seqAdjustmentValues[ 0 ].Value >>= fNumber; - nEndAngle = NormAngle360( - static_cast<sal_Int32>(fNumber) * 100 ); + nEndAngle = NormAngle36000( - static_cast<sal_Int32>(fNumber) * 100 ); } else { @@ -4583,7 +4583,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r fNumber = atan2( double( aStartPt.X() - cent.X() ),double( aStartPt.Y() - cent.Y() ) )+ F_PI; // 0..2PI fNumber /= F_PI180; // 0..360.0 } - nEndAngle = NormAngle360( - static_cast<sal_Int32>(fNumber) * 100 ); + nEndAngle = NormAngle36000( - static_cast<sal_Int32>(fNumber) * 100 ); seqAdjustmentValues[ 0 ].Value <<= fNumber; seqAdjustmentValues[ 0 ].State = css::beans::PropertyState_DIRECT_VALUE; // so this value will properly be stored } @@ -4592,7 +4592,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r { double fNumber; seqAdjustmentValues[ 1 ].Value >>= fNumber; - nStartAngle = NormAngle360( - static_cast<sal_Int32>(fNumber) * 100 ); + nStartAngle = NormAngle36000( - static_cast<sal_Int32>(fNumber) * 100 ); } else { |