[Libreoffice-commits] core.git: chart2/source filter/source include/svx include/tools oox/source sc/source sd/source svx/source sw/source writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Aug 3 19:57:55 UTC 2018


 chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx |   23 +++-------
 chart2/source/tools/ThreeDHelper.cxx                     |   27 ++---------
 chart2/source/view/charttypes/PieChart.cxx               |   23 +++-------
 chart2/source/view/main/AbstractShapeFactory.cxx         |    6 --
 chart2/source/view/main/PlottingPositionHelper.cxx       |    7 ---
 chart2/source/view/main/PolarLabelPositionHelper.cxx     |    7 +--
 chart2/source/view/main/ShapeFactory.cxx                 |    6 --
 filter/source/graphicfilter/icgm/actimpr.cxx             |    9 +--
 filter/source/graphicfilter/idxf/dxf2mtf.cxx             |    2 
 filter/source/msfilter/escherex.cxx                      |    5 --
 filter/source/msfilter/msdffimp.cxx                      |    8 +--
 include/svx/svdtrans.hxx                                 |    4 -
 include/tools/helpers.hxx                                |   20 ++++++++
 oox/source/drawingml/chart/plotareaconverter.cxx         |    4 -
 oox/source/drawingml/shape.cxx                           |    4 -
 oox/source/shape/WpsContext.cxx                          |    2 
 oox/source/vml/vmlformatting.cxx                         |    2 
 sc/source/filter/excel/xichart.cxx                       |    4 -
 sd/source/ui/func/fusel.cxx                              |    4 -
 svx/source/dialog/dlgctl3d.cxx                           |   11 ----
 svx/source/engine3d/dragmt3d.cxx                         |    2 
 svx/source/svdraw/svddrgmt.cxx                           |   34 +++++++--------
 svx/source/svdraw/svdglue.cxx                            |    4 -
 svx/source/svdraw/svdhdl.cxx                             |    5 --
 svx/source/svdraw/svdoashp.cxx                           |    2 
 svx/source/svdraw/svdocirc.cxx                           |   24 +++++-----
 svx/source/svdraw/svdomeas.cxx                           |    6 +-
 svx/source/svdraw/svdopath.cxx                           |   18 +++----
 svx/source/svdraw/svdotext.cxx                           |    2 
 svx/source/svdraw/svdotxtr.cxx                           |    8 +--
 svx/source/svdraw/svdtrans.cxx                           |   10 ++--
 sw/source/core/graphic/grfatr.cxx                        |    2 
 sw/source/filter/ww8/wrtw8esh.cxx                        |    2 
 writerfilter/source/rtftok/rtfsdrimport.cxx              |    2 
 34 files changed, 131 insertions(+), 168 deletions(-)

New commits:
commit 81302f33073e7629d724ed269f1fa21dad29e141
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Fri Aug 3 13:05:24 2018 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Fri Aug 3 21:57:23 2018 +0200

    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 at collabora.com>

diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx
index ae8449dcf257..acc07bc386d9 100644
--- a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx
+++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx
@@ -27,6 +27,7 @@
 #include <editeng/unoprnms.hxx>
 #include <com/sun/star/drawing/ProjectionMode.hpp>
 #include <tools/diagnose_ex.h>
+#include <tools/helpers.hxx>
 
 namespace chart
 {
@@ -36,15 +37,6 @@ using namespace ::com::sun::star;
 namespace
 {
 
-void lcl_shiftAngleToValidRange( sal_Int64& rnAngleDegree )
-{
-    //valid range:  ]-180,180]
-    while( rnAngleDegree<=-180 )
-        rnAngleDegree+=360;
-    while( rnAngleDegree>180 )
-        rnAngleDegree-=360;
-}
-
 void lcl_SetMetricFieldLimits( MetricField& rField, sal_Int64 nLimit )
 {
     rField.SetMin(-1*nLimit);
@@ -87,13 +79,12 @@ ThreeD_SceneGeometry_TabPage::ThreeD_SceneGeometry_TabPage( vcl::Window* pWindow
 
     lcl_SetMetricFieldLimits( *m_pMFZRotation, 90 );
 
-    m_nXRotation = ::basegfx::fround(fXAngle*pow(10.0,m_pMFXRotation->GetDecimalDigits()));
-    m_nYRotation = ::basegfx::fround(-1.0*fYAngle*pow(10.0,m_pMFYRotation->GetDecimalDigits()));
-    m_nZRotation = ::basegfx::fround(-1.0*fZAngle*pow(10.0,m_pMFZRotation->GetDecimalDigits()));
-
-    lcl_shiftAngleToValidRange( m_nXRotation );
-    lcl_shiftAngleToValidRange( m_nYRotation );
-    lcl_shiftAngleToValidRange( m_nZRotation );
+    m_nXRotation = NormAngle180(
+        ::basegfx::fround(fXAngle * pow(10.0, m_pMFXRotation->GetDecimalDigits())));
+    m_nYRotation = NormAngle180(
+        ::basegfx::fround(-1.0 * fYAngle * pow(10.0, m_pMFYRotation->GetDecimalDigits())));
+    m_nZRotation = NormAngle180(
+        ::basegfx::fround(-1.0 * fZAngle * pow(10.0, m_pMFZRotation->GetDecimalDigits())));
 
     m_pMFXRotation->SetValue(m_nXRotation);
     m_pMFYRotation->SetValue(m_nYRotation);
diff --git a/chart2/source/tools/ThreeDHelper.cxx b/chart2/source/tools/ThreeDHelper.cxx
index 25da0b374de3..3967ce42868d 100644
--- a/chart2/source/tools/ThreeDHelper.cxx
+++ b/chart2/source/tools/ThreeDHelper.cxx
@@ -30,6 +30,7 @@
 #include <com/sun/star/drawing/LineStyle.hpp>
 #include <com/sun/star/drawing/ShadeMode.hpp>
 #include <tools/diagnose_ex.h>
+#include <tools/helpers.hxx>
 #include <sal/log.hxx>
 
 namespace chart
@@ -369,24 +370,6 @@ double lcl_shiftAngleToIntervalMinusPiToPi( double fAngleRad )
     return fAngleRad;
 }
 
-void lcl_shiftAngleToIntervalMinus180To180( sal_Int32& rnAngleDegree )
-{
-    //valid range:  ]-180,180]
-    while( rnAngleDegree<=-180 )
-        rnAngleDegree+=360;
-    while( rnAngleDegree>180 )
-        rnAngleDegree-=360;
-}
-
-void lcl_shiftAngleToIntervalZeroTo360( sal_Int32& rnAngleDegree )
-{
-    //valid range:  [0,360[
-    while( rnAngleDegree<0 )
-        rnAngleDegree+=360;
-    while( rnAngleDegree>=360 )
-        rnAngleDegree-=360;
-}
-
 void lcl_ensureIntervalMinus1To1( double& rSinOrCos )
 {
     if (rSinOrCos < -1.0)
@@ -414,8 +397,8 @@ void ThreeDHelper::convertElevationRotationDegToXYZAngleRad(
     //https://bz.apache.org/ooo/show_bug.cgi?id=72994
     //https://bz.apache.org/ooo/attachment.cgi?id=50608
 
-    lcl_shiftAngleToIntervalZeroTo360( nElevationDeg );
-    lcl_shiftAngleToIntervalZeroTo360( nRotationDeg );
+    nElevationDeg = NormAngle360(nElevationDeg);
+    nRotationDeg = NormAngle360(nRotationDeg);
 
     double& x = rfXAngleRad;
     double& y = rfYAngleRad;
@@ -1053,8 +1036,8 @@ void ThreeDHelper::getRotationFromDiagram( const uno::Reference< beans::XPropert
         // nZRotation = basegfx::fround(-1.0 * basegfx::rad2deg(fZAngle));
     }
 
-    lcl_shiftAngleToIntervalMinus180To180( rnHorizontalAngleDegree );
-    lcl_shiftAngleToIntervalMinus180To180( rnVerticalAngleDegree );
+    rnHorizontalAngleDegree = NormAngle180(rnHorizontalAngleDegree);
+    rnVerticalAngleDegree = NormAngle180(rnVerticalAngleDegree);
 }
 
 void ThreeDHelper::setRotationToDiagram( const uno::Reference< beans::XPropertySet >& xSceneProperties
diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx
index de48a1d5e893..19f978ee8301 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -33,6 +33,7 @@
 #include <com/sun/star/container/XChild.hpp>
 #include <rtl/math.hxx>
 #include <sal/log.hxx>
+#include <tools/helpers.hxx>
 
 #include <memory>
 
@@ -759,16 +760,6 @@ double lcl_degToRad(double fAngleDeg)
     return (fAngleDeg / 180) * M_PI;
 }
 
-inline
-double lcl_getDegAngleInStandardRange(double fAngle)
-{
-    while( fAngle < 0.0 )
-        fAngle += 360.0;
-    while( fAngle >= 360.0 )
-        fAngle -= 360.0;
-    return fAngle;
-}
-
 }//end anonymous namespace
 
 PieChart::PieLabelInfo::PieLabelInfo()
@@ -1277,10 +1268,10 @@ bool PieChart::performLabelBestFitInnerPlacement(ShapeParam& rShapeParam, PieLab
               "** PieChart::performLabelBestFitInnerPlacement invoked **" );
 
     // get pie slice properties
-    double fStartAngleDeg = lcl_getDegAngleInStandardRange(rShapeParam.mfUnitCircleStartAngleDegree);
+    double fStartAngleDeg = NormAngle360(rShapeParam.mfUnitCircleStartAngleDegree);
     double fWidthAngleDeg = rShapeParam.mfUnitCircleWidthAngleDegree;
     double fHalfWidthAngleDeg = fWidthAngleDeg / 2.0;
-    double fBisectingRayAngleDeg = lcl_getDegAngleInStandardRange(fStartAngleDeg + fHalfWidthAngleDeg);
+    double fBisectingRayAngleDeg = NormAngle360(fStartAngleDeg + fHalfWidthAngleDeg);
 
     // get the middle point of the arc representing the pie slice border
     double fLogicZ = rShapeParam.mfLogicZ + 1.0;
@@ -1334,7 +1325,7 @@ bool PieChart::performLabelBestFitInnerPlacement(ShapeParam& rShapeParam, PieLab
     double fLabelHeight = aBb.getHeight();
 
     // -45 <= fAlphaDeg < 315
-    double fAlphaDeg = lcl_getDegAngleInStandardRange(fBisectingRayAngleDeg + 45) - 45;
+    double fAlphaDeg = NormAngle360(fBisectingRayAngleDeg + 45) - 45;
     double fAlphaRad = lcl_degToRad(fAlphaDeg);
 
     // compute nearest edge index
@@ -1507,7 +1498,7 @@ bool PieChart::performLabelBestFitInnerPlacement(ShapeParam& rShapeParam, PieLab
 
     // check the angle between CP and CM
     double fAngleRad = aPositionalVector.angle(aVertexM);
-    double fAngleDeg = lcl_getDegAngleInStandardRange( lcl_radToDeg(fAngleRad) );
+    double fAngleDeg = NormAngle360(lcl_radToDeg(fAngleRad));
     if( fAngleDeg > 180 )  // in case the wrong angle has been computed
         fAngleDeg = 360 - fAngleDeg;
     SAL_INFO( "chart2.pie.label.bestfit.inside",
@@ -1522,7 +1513,7 @@ bool PieChart::performLabelBestFitInnerPlacement(ShapeParam& rShapeParam, PieLab
     {
         // check the angle between CP and CN
         fAngleRad = aPositionalVector.angle(aNearestVertex);
-        fAngleDeg = lcl_getDegAngleInStandardRange( lcl_radToDeg(fAngleRad) );
+        fAngleDeg = NormAngle360(lcl_radToDeg(fAngleRad));
         if( fAngleDeg > 180 )  // in case the wrong angle has been computed
             fAngleDeg = 360 - fAngleDeg;
         SAL_INFO( "chart2.pie.label.bestfit.inside",
@@ -1536,7 +1527,7 @@ bool PieChart::performLabelBestFitInnerPlacement(ShapeParam& rShapeParam, PieLab
     {
         // check the angle between CP and CG
         fAngleRad = aPositionalVector.angle(aVertexG);
-        fAngleDeg = lcl_getDegAngleInStandardRange( lcl_radToDeg(fAngleRad) );
+        fAngleDeg = NormAngle360(lcl_radToDeg(fAngleRad));
         if( fAngleDeg > 180 )  // in case the wrong angle has been computed
             fAngleDeg = 360 - fAngleDeg;
         SAL_INFO( "chart2.pie.label.bestfit.inside",
diff --git a/chart2/source/view/main/AbstractShapeFactory.cxx b/chart2/source/view/main/AbstractShapeFactory.cxx
index df2516ab82f2..6e85eb79a9ce 100644
--- a/chart2/source/view/main/AbstractShapeFactory.cxx
+++ b/chart2/source/view/main/AbstractShapeFactory.cxx
@@ -32,6 +32,7 @@
 
 #include <editeng/unoprnms.hxx>
 #include <rtl/math.hxx>
+#include <tools/helpers.hxx>
 #include <tools/svlibrary.h>
 #include <svx/svdocirc.hxx>
 #include <svx/svdopath.hxx>
@@ -262,10 +263,7 @@ awt::Size AbstractShapeFactory::getSizeAfterRotation(
             aRet = aSize;
         else
         {
-            while(fRotationAngleDegree>=360.0)
-                fRotationAngleDegree-=360.0;
-            while(fRotationAngleDegree<0.0)
-                fRotationAngleDegree+=360.0;
+            fRotationAngleDegree = NormAngle360(fRotationAngleDegree);
             if(fRotationAngleDegree>270.0)
                 fRotationAngleDegree=360.0-fRotationAngleDegree;
             else if(fRotationAngleDegree>180.0)
diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx
index 9ad4f4465e53..da5cc4159aca 100644
--- a/chart2/source/view/main/PlottingPositionHelper.cxx
+++ b/chart2/source/view/main/PlottingPositionHelper.cxx
@@ -34,6 +34,7 @@
 #include <com/sun/star/drawing/XShapes.hpp>
 
 #include <rtl/math.hxx>
+#include <tools/helpers.hxx>
 
 namespace chart
 {
@@ -477,11 +478,7 @@ double PolarPlottingPositionHelper::transformToAngleDegree( double fLogicValueOn
     fRet = m_fAngleDegreeOffset
                   + fAxisAngleScaleDirection*(fScaledLogicAngleValue-MinAngleValue)*360.0
                     /fabs(MaxAngleValue-MinAngleValue);
-    while(fRet>360.0)
-        fRet-=360.0;
-    while(fRet<0)
-        fRet+=360.0;
-    return fRet;
+    return NormAngle360(fRet);
 }
 
 /**
diff --git a/chart2/source/view/main/PolarLabelPositionHelper.cxx b/chart2/source/view/main/PolarLabelPositionHelper.cxx
index 052994c2c109..07bf9e8bae85 100644
--- a/chart2/source/view/main/PolarLabelPositionHelper.cxx
+++ b/chart2/source/view/main/PolarLabelPositionHelper.cxx
@@ -25,6 +25,8 @@
 
 #include <com/sun/star/chart/DataLabelPlacement.hpp>
 
+#include <tools/helpers.hxx>
+
 namespace chart
 {
 using namespace ::com::sun::star;
@@ -122,10 +124,7 @@ awt::Point PolarLabelPositionHelper::getLabelScreenPositionAndAlignmentForUnitCi
     //set LabelAlignment
     if( !bCenter )
     {
-        while(fAngleDegree>360.0)
-            fAngleDegree-=360.0;
-        while(fAngleDegree<0.0)
-            fAngleDegree+=360.0;
+        fAngleDegree = NormAngle360(fAngleDegree);
 
         bool bOutside = nLabelPlacement == css::chart::DataLabelPlacement::OUTSIDE;
 
diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx
index 8e3f67bb18b1..696ca39da940 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -59,6 +59,7 @@
 #include <basegfx/point/b2dpoint.hxx>
 #include <basegfx/matrix/b3dhommatrix.hxx>
 #include <tools/diagnose_ex.h>
+#include <tools/helpers.hxx>
 #include <sal/log.hxx>
 
 #include <algorithm>
@@ -877,10 +878,7 @@ uno::Reference< drawing::XShape >
     if( !xTarget.is() )
         return nullptr;
 
-    while(fUnitCircleWidthAngleDegree>360)
-        fUnitCircleWidthAngleDegree -= 360.0;
-    while(fUnitCircleWidthAngleDegree<0)
-        fUnitCircleWidthAngleDegree += 360.0;
+    fUnitCircleWidthAngleDegree = NormAngle360(fUnitCircleWidthAngleDegree);
 
     //create shape
     uno::Reference< drawing::XShape > xShape(
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
                             {
diff --git a/include/svx/svdtrans.hxx b/include/svx/svdtrans.hxx
index 89b29d4b5903..7ddb2e18dbc5 100644
--- a/include/svx/svdtrans.hxx
+++ b/include/svx/svdtrans.hxx
@@ -164,9 +164,9 @@ inline double GetCrookAngle(Point& rPnt, const Point& rCenter, const Point& rRad
  */
 SVX_DLLPUBLIC long GetAngle(const Point& rPnt);
 
-long NormAngle180(long a); /// Normalize angle to -180.00..179.99
+long NormAngle18000(long a); /// Normalize angle to -180.00..179.99
 
-SVX_DLLPUBLIC long NormAngle360(long a); /// Normalize angle to 0.00..359.99
+SVX_DLLPUBLIC long NormAngle36000(long a); /// Normalize angle to 0.00..359.99
 
 sal_uInt16 GetAngleSector(long nAngle); /// Determine sector within the cartesian coordinate system
 
diff --git a/include/tools/helpers.hxx b/include/tools/helpers.hxx
index da815e13b5e9..bbe350d455ba 100644
--- a/include/tools/helpers.hxx
+++ b/include/tools/helpers.hxx
@@ -76,6 +76,26 @@ inline long FRound( double fVal )
     return fVal > 0.0 ? static_cast<long>( fVal + 0.5 ) : -static_cast<long>( -fVal + 0.5 );
 }
 
+//valid range:  (-180,180]
+template <typename T> inline SAL_WARN_UNUSED_RESULT T NormAngle180(T angle)
+{
+    while (angle <= -180)
+        angle += 360;
+    while (angle > 180)
+        angle -= 360;
+    return angle;
+}
+
+//valid range:  [0,360)
+template <typename T> inline SAL_WARN_UNUSED_RESULT T NormAngle360(T angle)
+{
+    while (angle < 0)
+        angle += 360;
+    while (angle >= 360)
+        angle -= 360;
+    return angle;
+}
+
 /** Convert 100th-mm to twips
 
     A twip is 1/20 of a point, one inch is equal to 72 points, and
diff --git a/oox/source/drawingml/chart/plotareaconverter.cxx b/oox/source/drawingml/chart/plotareaconverter.cxx
index d9755fdb9631..c562ea82837a 100644
--- a/oox/source/drawingml/chart/plotareaconverter.cxx
+++ b/oox/source/drawingml/chart/plotareaconverter.cxx
@@ -35,6 +35,7 @@
 #include <oox/token/namespaces.hxx>
 #include <oox/token/properties.hxx>
 #include <oox/token/tokens.hxx>
+#include <tools/helpers.hxx>
 
 namespace oox {
 namespace drawingml {
@@ -234,8 +235,7 @@ void View3DConverter::convertFromModel( const Reference< XDiagram >& rxDiagram,
     }
 
     // Y rotation (map OOXML [0..359] to Chart2 [-179,180])
-    nRotationY %= 360;
-    if( nRotationY > 180 ) nRotationY -= 360;
+    nRotationY = NormAngle180(nRotationY);
     /*  Perspective (map OOXML [0..200] to Chart2 [0,100]). Seems that MSO 2007 is
         buggy here, the XML plugin of MSO 2003 writes the correct perspective in
         the range from 0 to 100. We will emulate the wrong behaviour of MSO 2007. */
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index f9b3abdd48e9..70028b34fe87 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -461,7 +461,7 @@ static inline void lcl_createPresetShape( uno::Reference<drawing::XShape>& xShap
     int nIndex = 0;
     for (auto& aEntry : aGdList)
     {
-        double fAngle = NormAngle360( aEntry.maFormula.toDouble() / -600.0 );
+        double fAngle = NormAngle36000( aEntry.maFormula.toDouble() / -600.0 );
         fAngle = 360.0 - fAngle / 100.0;
 
         aAdjustment[nIndex].Value <<= fAngle;
@@ -1318,7 +1318,7 @@ Reference< XShape > const & Shape::createAndInsert(
         if ( !bUseRotationTransform && mnRotation != 0 )
         {
             // use the same logic for rotation from VML exporter (SimpleShape::implConvertAndInsert at vmlshape.cxx)
-            aPropertySet.setAnyProperty( PROP_RotateAngle, makeAny( sal_Int32( NormAngle360( mnRotation / -600 ) ) ) );
+            aPropertySet.setAnyProperty( PROP_RotateAngle, makeAny( sal_Int32( NormAngle36000( mnRotation / -600 ) ) ) );
             aPropertySet.setAnyProperty( PROP_HoriOrientPosition, makeAny( maPosition.X ) );
             aPropertySet.setAnyProperty( PROP_VertOrientPosition, makeAny( maPosition.Y ) );
         }
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index d0d021cd1dd4..a5ed73160ef9 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -105,7 +105,7 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken
 
                     // If the text is not rotated the way the shape wants it already, set the angle.
                     const sal_Int32 nRotation = -270;
-                    if (static_cast<long>(basegfx::rad2deg(fRotate)) != NormAngle360(static_cast<long>(nRotation) * 100) / 100)
+                    if (static_cast<long>(basegfx::rad2deg(fRotate)) != NormAngle36000(static_cast<long>(nRotation) * 100) / 100)
                     {
                         comphelper::SequenceAsHashMap aCustomShapeGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry"));
                         aCustomShapeGeometry["TextPreRotateAngle"] <<= nRotation;
diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index c48b386394e9..d2132c0bc8b7 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -135,7 +135,7 @@ sal_Int32 ConversionHelper::decodeRotation( const OUString& rValue )
         return 0;
     }
 
-    return NormAngle360(fRotation * -100);
+    return NormAngle36000(fRotation * -100);
 }
 
 sal_Int64 ConversionHelper::decodeMeasureToEmu( const GraphicHelper& rGraphicHelper,
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index c42abc33a8db..a3062d2cca18 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -81,6 +81,7 @@
 #include <svx/svdpage.hxx>
 #include <svx/unoapi.hxx>
 #include <sal/log.hxx>
+#include <tools/helpers.hxx>
 
 #include <document.hxx>
 #include <drwlayer.hxx>
@@ -2430,8 +2431,7 @@ void XclImpChChart3d::Convert( ScfPropertySet& rPropSet, bool b3dWallChart ) con
     if( b3dWallChart )
     {
         // Y rotation (Excel [0..359], Chart2 [-179,180])
-        nRotationY = maData.mnRotation % 360;
-        if( nRotationY > 180 ) nRotationY -= 360;
+        nRotationY = NormAngle180(maData.mnRotation);
         // X rotation a.k.a. elevation (Excel [-90..90], Chart2 [-179,180])
         nRotationX = limit_cast< sal_Int32, sal_Int32 >( maData.mnElevation, -90, 90 );
         // perspective (Excel and Chart2 [0,100])
diff --git a/sd/source/ui/func/fusel.cxx b/sd/source/ui/func/fusel.cxx
index 84fcea47cbec..c934d50c3b6f 100644
--- a/sd/source/ui/func/fusel.cxx
+++ b/sd/source/ui/func/fusel.cxx
@@ -178,7 +178,7 @@ bool FuSelection::MouseButtonDown(const MouseEvent& rMEvt)
 
         long nAngle0  = GetAngle(aMDPos - mpView->GetRef1());
         nAngle0 -= 27000;
-        nAngle0 = NormAngle360(nAngle0);
+        nAngle0 = NormAngle36000(nAngle0);
         bMirrorSide0 = nAngle0 < 18000;
 
         if (!pHdl && mpView->Is3DRotationCreationActive())
@@ -740,7 +740,7 @@ bool FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
                     **********************************************************/
                      long nAngle1  = GetAngle(aPnt - mpView->GetRef1());
                      nAngle1 -= 27000;
-                     nAngle1 = NormAngle360(nAngle1);
+                     nAngle1 = NormAngle36000(nAngle1);
                      bool bMirrorSide1 = nAngle1 < 18000;
 
                      if (bMirrorSide0 != bMirrorSide1)
diff --git a/svx/source/dialog/dlgctl3d.cxx b/svx/source/dialog/dlgctl3d.cxx
index 9f96d6277866..1e6fa863c638 100644
--- a/svx/source/dialog/dlgctl3d.cxx
+++ b/svx/source/dialog/dlgctl3d.cxx
@@ -37,6 +37,7 @@
 #include <helpids.h>
 #include <algorithm>
 #include <svx/dialmgr.hxx>
+#include <tools/helpers.hxx>
 #include <vcl/settings.hxx>
 
 using namespace com::sun::star;
@@ -671,15 +672,7 @@ void Svx3DLightControl::Tracking( const TrackingEvent& rTEvt )
                 double fNewPosVer = mfSaveActionStartVer - static_cast<double>(aDeltaPos.Y());
 
                 // cut horizontal
-                while(fNewPosHor < 0.0)
-                {
-                    fNewPosHor += 360.0;
-                }
-
-                while(fNewPosHor >= 360.0)
-                {
-                    fNewPosHor -= 360.0;
-                }
+                fNewPosHor = NormAngle360(fNewPosHor);
 
                 // cut vertical
                 if(fNewPosVer < -90.0)
diff --git a/svx/source/engine3d/dragmt3d.cxx b/svx/source/engine3d/dragmt3d.cxx
index 255b667da859..6052a6df9610 100644
--- a/svx/source/engine3d/dragmt3d.cxx
+++ b/svx/source/engine3d/dragmt3d.cxx
@@ -341,7 +341,7 @@ void E3dDragRotate::MoveSdrDrag(const Point& rPnt)
 
             if(E3dDragConstraint::Z == meConstraint)
             {
-                fWAngle = NormAngle360(GetAngle(rPnt - DragStat().GetRef1()) -
+                fWAngle = NormAngle36000(GetAngle(rPnt - DragStat().GetRef1()) -
                     rCandidate.mnStartAngle) - rCandidate.mnLastAngle;
                 rCandidate.mnLastAngle = static_cast<long>(fWAngle) + rCandidate.mnLastAngle;
                 fWAngle /= 100.0;
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index 2bc2c74e49e5..d826a2f12422 100644
--- a/svx/source/svdraw/svddrgmt.cxx
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -1037,12 +1037,12 @@ void SdrDragMovHdl::MoveSdrDrag(const Point& rNoSnapPnt)
                 if (pH!=nullptr)
                 {
                     Point aRef(pH->GetPos());
-                    long nAngle=NormAngle360(GetAngle(aPnt-aRef));
+                    long nAngle=NormAngle36000(GetAngle(aPnt-aRef));
                     long nNewAngle=nAngle;
                     nNewAngle+=nSA/2;
                     nNewAngle/=nSA;
                     nNewAngle*=nSA;
-                    nNewAngle=NormAngle360(nNewAngle);
+                    nNewAngle=NormAngle36000(nNewAngle);
                     double a=(nNewAngle-nAngle)*nPi180;
                     double nSin=sin(a);
                     double nCos=cos(a);
@@ -2061,7 +2061,7 @@ void SdrDragRotate::TakeSdrDragComment(OUString& rStr) const
 {
     ImpTakeDescriptionStr(STR_DragMethRotate, rStr);
     rStr += " (";
-    sal_Int32 nTmpAngle(NormAngle360(nAngle));
+    sal_Int32 nTmpAngle(NormAngle36000(nAngle));
 
     if(bRight && nAngle)
     {
@@ -2114,7 +2114,7 @@ void SdrDragRotate::MoveSdrDrag(const Point& rPnt_)
     Point aPnt(rPnt_);
     if (DragStat().CheckMinMoved(aPnt))
     {
-        long nNewAngle=NormAngle360(GetAngle(aPnt-DragStat().GetRef1())-nAngle0);
+        long nNewAngle=NormAngle36000(GetAngle(aPnt-DragStat().GetRef1())-nAngle0);
         long nSA=0;
 
         if (getSdrDragView().IsAngleSnapEnabled())
@@ -2130,7 +2130,7 @@ void SdrDragRotate::MoveSdrDrag(const Point& rPnt_)
             nNewAngle*=nSA;
         }
 
-        nNewAngle=NormAngle180(nNewAngle);
+        nNewAngle=NormAngle18000(nNewAngle);
 
         if (nAngle!=nNewAngle)
         {
@@ -2207,7 +2207,7 @@ void SdrDragShear::TakeSdrDragComment(OUString& rStr) const
     if(bUpSideDown)
         nTmpAngle += 18000;
 
-    nTmpAngle = NormAngle180(nTmpAngle);
+    nTmpAngle = NormAngle18000(nTmpAngle);
 
     rStr += SdrModel::GetAngleString(nTmpAngle) + ")";
 
@@ -2305,20 +2305,20 @@ void SdrDragShear::MoveSdrDrag(const Point& rPnt)
 
     if (bSlant)
     {
-        nNewAngle=NormAngle180(-(GetAngle(aDif)-nAngle0));
+        nNewAngle=NormAngle18000(-(GetAngle(aDif)-nAngle0));
 
         if (bVertical)
-            nNewAngle=NormAngle180(-nNewAngle);
+            nNewAngle=NormAngle18000(-nNewAngle);
     }
     else
     {
         if (bVertical)
-            nNewAngle=NormAngle180(GetAngle(aDif));
+            nNewAngle=NormAngle18000(GetAngle(aDif));
         else
-            nNewAngle=NormAngle180(-(GetAngle(aDif)-9000));
+            nNewAngle=NormAngle18000(-(GetAngle(aDif)-9000));
 
         if (nNewAngle<-9000 || nNewAngle>9000)
-            nNewAngle=NormAngle180(nNewAngle+18000);
+            nNewAngle=NormAngle18000(nNewAngle+18000);
 
         if (bResize)
         {
@@ -2350,7 +2350,7 @@ void SdrDragShear::MoveSdrDrag(const Point& rPnt)
         nNewAngle*=nSA;
     }
 
-    nNewAngle=NormAngle360(nNewAngle);
+    nNewAngle=NormAngle36000(nNewAngle);
     bUpSideDown=nNewAngle>9000 && nNewAngle<27000;
 
     if (bSlant)
@@ -2480,7 +2480,7 @@ bool SdrDragMirror::ImpCheckSide(const Point& rPnt) const
 {
     long nAngle1=GetAngle(rPnt-DragStat().GetRef1());
     nAngle1-=nAngle;
-    nAngle1=NormAngle360(nAngle1);
+    nAngle1=NormAngle36000(nAngle1);
 
     return nAngle1<18000;
 }
@@ -2514,7 +2514,7 @@ bool SdrDragMirror::BeginSdrDrag()
         aDif=pH2->GetPos()-pH1->GetPos();
         bool b90=(aDif.X()==0) || aDif.Y()==0;
         bool b45=b90 || (std::abs(aDif.X()) == std::abs(aDif.Y()));
-        nAngle=NormAngle360(GetAngle(aDif));
+        nAngle=NormAngle36000(GetAngle(aDif));
 
         if (!getSdrDragView().IsMirrorAllowed() && !b45)
             return false; // free choice of axis angle not allowed
@@ -3163,13 +3163,13 @@ void SdrDragCrook::MoveSdrDrag(const Point& rPnt)
                 if (bLwr) nPntWink+=18000;
             }
 
-            nPntWink=NormAngle360(nPntWink);
+            nPntWink=NormAngle36000(nPntWink);
         }
         else
         {
             if (nNewRad<0) nPntWink+=18000;
             if (bVertical) nPntWink=18000-nPntWink;
-            nPntWink=NormAngle180(nPntWink);
+            nPntWink=NormAngle18000(nPntWink);
             nPntWink = std::abs(nPntWink);
         }
 
@@ -3177,7 +3177,7 @@ void SdrDragCrook::MoveSdrDrag(const Point& rPnt)
 
         if (bResize)
         {
-            long nMul=static_cast<long>(nUmfang*NormAngle360(nPntWink)/36000);
+            long nMul=static_cast<long>(nUmfang*NormAngle36000(nPntWink)/36000);
 
             if (bAtCenter)
                 nMul*=2;
diff --git a/svx/source/svdraw/svdglue.cxx b/svx/source/svdraw/svdglue.cxx
index cb253b121444..477f97d1130f 100644
--- a/svx/source/svdraw/svdglue.cxx
+++ b/svx/source/svdraw/svdglue.cxx
@@ -149,7 +149,7 @@ long SdrGluePoint::GetAlignAngle() const
 
 void SdrGluePoint::SetAlignAngle(long nAngle)
 {
-    nAngle=NormAngle360(nAngle);
+    nAngle=NormAngle36000(nAngle);
     if (nAngle>=33750 || nAngle<2250) nAlign=SdrAlign::HORZ_RIGHT |SdrAlign::VERT_CENTER;
     else if (nAngle< 6750) nAlign=SdrAlign::HORZ_RIGHT |SdrAlign::VERT_TOP   ;
     else if (nAngle<11250) nAlign=SdrAlign::HORZ_CENTER|SdrAlign::VERT_TOP   ;
@@ -174,7 +174,7 @@ long SdrGluePoint::EscDirToAngle(SdrEscapeDirection nEsc)
 
 SdrEscapeDirection SdrGluePoint::EscAngleToDir(long nAngle)
 {
-    nAngle=NormAngle360(nAngle);
+    nAngle=NormAngle36000(nAngle);
     if (nAngle>=31500 || nAngle<4500)
         return SdrEscapeDirection::RIGHT;
     if (nAngle<13500)
diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx
index 714332745672..68052c193e7f 100644
--- a/svx/source/svdraw/svdhdl.cxx
+++ b/svx/source/svdraw/svdhdl.cxx
@@ -979,9 +979,8 @@ Pointer SdrHdl::GetPointer() const
                 default:
                     break;
             }
-            nHdlAngle+=nRotationAngle+2249; // a little bit more (for rounding)
-            while (nHdlAngle<0) nHdlAngle+=36000;
-            while (nHdlAngle>=36000) nHdlAngle-=36000;
+            // a little bit more (for rounding)
+            nHdlAngle = NormAngle36000(nHdlAngle + nRotationAngle + 2249);
             nHdlAngle/=4500;
             switch (static_cast<sal_uInt8>(nHdlAngle)) {
                 case 0: ePtr=PointerStyle::ESize;  break;
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 2c261b5e4162..8d839abb77d5 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -2951,7 +2951,7 @@ void SdrObjCustomShape::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix,
         // #i78696#
         // fRotate is mathematically correct, but aGeoStat.nRotationAngle is
         // mirrored -> mirror value here
-        aGeoStat.nRotationAngle = NormAngle360(FRound(-fRotate / F_PI18000));
+        aGeoStat.nRotationAngle = NormAngle36000(FRound(-fRotate / F_PI18000));
         aGeoStat.RecalcSinCos();
         Rotate(Point(), aGeoStat.nRotationAngle, aGeoStat.nSin, aGeoStat.nCos);
     }
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
index 0cdaeefe3a4e..cbe1ce864f68 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -137,8 +137,8 @@ SdrCircObj::SdrCircObj(
 :   SdrRectObj(rSdrModel, rRect)
 {
     long nAngleDif=nNewEndWink-nNewStartWink;
-    nStartAngle=NormAngle360(nNewStartWink);
-    nEndAngle=NormAngle360(nNewEndWink);
+    nStartAngle=NormAngle36000(nNewStartWink);
+    nEndAngle=NormAngle36000(nNewEndWink);
     if (nAngleDif==36000) nEndAngle+=nAngleDif; // full circle
     meCircleKind=eNewKind;
     bClosedObj=eNewKind!=OBJ_CARC;
@@ -536,7 +536,7 @@ bool SdrCircObj::applySpecialDrag(SdrDragStat& rDrag)
             aPt.setX(BigMulDiv(aPt.X(),nHgt,nWdt) );
         }
 
-        long nAngle=NormAngle360(GetAngle(aPt));
+        long nAngle=NormAngle36000(GetAngle(aPt));
 
         if (rDrag.GetView() && rDrag.GetView()->IsAngleSnapEnabled())
         {
@@ -547,7 +547,7 @@ bool SdrCircObj::applySpecialDrag(SdrDragStat& rDrag)
                 nAngle+=nSA/2;
                 nAngle/=nSA;
                 nAngle*=nSA;
-                nAngle=NormAngle360(nAngle);
+                nAngle=NormAngle36000(nAngle);
             }
         }
 
@@ -649,14 +649,14 @@ void ImpCircUser::SetCreateParams(SdrDragStat const & rStat)
         } else {
             if (nWdt!=0) aP.setX(aP.X()*nHgt/nWdt );
         }
-        nStart=NormAngle360(GetAngle(aP));
+        nStart=NormAngle36000(GetAngle(aP));
         if (rStat.GetView()!=nullptr && rStat.GetView()->IsAngleSnapEnabled()) {
             long nSA=rStat.GetView()->GetSnapAngle();
             if (nSA!=0) { // angle snapping
                 nStart+=nSA/2;
                 nStart/=nSA;
                 nStart*=nSA;
-                nStart=NormAngle360(nStart);
+                nStart=NormAngle36000(nStart);
             }
         }
         aP1 = GetAnglePnt(aR,nStart);
@@ -670,14 +670,14 @@ void ImpCircUser::SetCreateParams(SdrDragStat const & rStat)
         } else {
             aP.setX(BigMulDiv(aP.X(),nHgt,nWdt) );
         }
-        nEnd=NormAngle360(GetAngle(aP));
+        nEnd=NormAngle36000(GetAngle(aP));
         if (rStat.GetView()!=nullptr && rStat.GetView()->IsAngleSnapEnabled()) {
             long nSA=rStat.GetView()->GetSnapAngle();
             if (nSA!=0) { // angle snapping
                 nEnd+=nSA/2;
                 nEnd/=nSA;
                 nEnd*=nSA;
-                nEnd=NormAngle360(nEnd);
+                nEnd=NormAngle36000(nEnd);
             }
         }
         aP2 = GetAnglePnt(aR,nEnd);
@@ -862,8 +862,8 @@ void SdrCircObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract
                 }
             }
             long nAngleDif=nE0-nS0;
-            nStartAngle=NormAngle360(nS0);
-            nEndAngle  =NormAngle360(nE0);
+            nStartAngle=NormAngle36000(nS0);
+            nEndAngle  =NormAngle36000(nE0);
             if (nAngleDif==36000) nEndAngle+=nAngleDif; // full circle
         }
     }
@@ -931,8 +931,8 @@ void SdrCircObj::NbcMirror(const Point& rRef1, const Point& rRef2)
         nStartAngle=GetAngle(aTmpPt2);
         nEndAngle  =GetAngle(aTmpPt1);
         long nAngleDif=nEndAngle-nStartAngle;
-        nStartAngle=NormAngle360(nStartAngle);
-        nEndAngle  =NormAngle360(nEndAngle);
+        nStartAngle=NormAngle36000(nStartAngle);
+        nEndAngle  =NormAngle36000(nEndAngle);
         if (nAngleDif==36000) nEndAngle+=nAngleDif; // full circle
     }
     SetXPolyDirty();
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index e2420e7d2884..24943f06d84a 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -431,7 +431,7 @@ void SdrMeasureObj::ImpCalcGeometrics(const ImpMeasureRec& rRec, ImpMeasurePoly&
 
     rPol.bAutoUpsideDown=false;
     if (rRec.bTextAutoAngle) {
-        long nTmpAngle=NormAngle360(rPol.nTextAngle-rRec.nTextAutoAngleView);
+        long nTmpAngle=NormAngle36000(rPol.nTextAngle-rRec.nTextAutoAngleView);
         if (nTmpAngle>=18000) {
             rPol.nTextAngle+=18000;
             rPol.bAutoUpsideDown=true;
@@ -439,10 +439,10 @@ void SdrMeasureObj::ImpCalcGeometrics(const ImpMeasureRec& rRec, ImpMeasurePoly&
     }
 
     if (rRec.bTextUpsideDown) rPol.nTextAngle+=18000;
-    rPol.nTextAngle=NormAngle360(rPol.nTextAngle);
+    rPol.nTextAngle=NormAngle36000(rPol.nTextAngle);
     rPol.nHlpAngle=rPol.nLineAngle+9000;
     if (rRec.bBelowRefEdge) rPol.nHlpAngle+=18000;
-    rPol.nHlpAngle=NormAngle360(rPol.nHlpAngle);
+    rPol.nHlpAngle=NormAngle36000(rPol.nHlpAngle);
     double nHlpSin=nLineCos;
     double nHlpCos=-nLineSin;
     if (rRec.bBelowRefEdge) {
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index 5173a9ff8bf3..0b8243eba921 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -315,8 +315,8 @@ void ImpPathCreateUser::CalcCircle(const Point& rP1, const Point& rP2, const Poi
     long dx=rP2.X()-rP1.X();
     long dy=rP2.Y()-rP1.Y();
     long dAngle=GetAngle(Point(dx,dy))-nTangAngle;
-    dAngle=NormAngle360(dAngle);
-    long nTmpAngle=NormAngle360(9000-dAngle);
+    dAngle=NormAngle36000(dAngle);
+    long nTmpAngle=NormAngle36000(9000-dAngle);
     bool bRet=nTmpAngle!=9000 && nTmpAngle!=27000;
     long nRad=0;
     if (bRet) {
@@ -325,13 +325,13 @@ void ImpPathCreateUser::CalcCircle(const Point& rP1, const Point& rP2, const Poi
         nRad=std::abs(FRound(nR));
     }
     if (dAngle<18000) {
-        nCircStAngle=NormAngle360(nTangAngle-9000);
-        nCircRelAngle=NormAngle360(2*dAngle);
+        nCircStAngle=NormAngle36000(nTangAngle-9000);
+        nCircRelAngle=NormAngle36000(2*dAngle);
         aCircCenter.AdjustX(FRound(nRad*cos((nTangAngle+9000)*nPi180)) );
         aCircCenter.AdjustY( -(FRound(nRad*sin((nTangAngle+9000)*nPi180))) );
     } else {
-        nCircStAngle=NormAngle360(nTangAngle+9000);
-        nCircRelAngle=-NormAngle360(36000-2*dAngle);
+        nCircStAngle=NormAngle36000(nTangAngle+9000);
+        nCircRelAngle=-NormAngle36000(36000-2*dAngle);
         aCircCenter.AdjustX(FRound(nRad*cos((nTangAngle-9000)*nPi180)) );
         aCircCenter.AdjustY( -(FRound(nRad*sin((nTangAngle-9000)*nPi180))) );
     }
@@ -344,7 +344,7 @@ void ImpPathCreateUser::CalcCircle(const Point& rP1, const Point& rP2, const Poi
             nCircRelAngle+=nSA/2;
             nCircRelAngle/=nSA;
             nCircRelAngle*=nSA;
-            nCircRelAngle=NormAngle360(nCircRelAngle);
+            nCircRelAngle=NormAngle36000(nCircRelAngle);
             if (bNeg) nCircRelAngle=-nCircRelAngle;
         }
     }
@@ -363,7 +363,7 @@ XPolygon ImpPathCreateUser::GetCirclePoly() const
         return aXP;
     } else {
         XPolygon aXP(aCircCenter,nCircRadius,nCircRadius,
-                     sal_uInt16(NormAngle360(nCircStAngle+nCircRelAngle+5)/10),sal_uInt16((nCircStAngle+5)/10),false);
+                     sal_uInt16(NormAngle36000(nCircStAngle+nCircRelAngle+5)/10),sal_uInt16((nCircStAngle+5)/10),false);
         sal_uInt16 nCount=aXP.GetPointCount();
         for (sal_uInt16 nNum=nCount/2; nNum>0;) {
             nNum--; // reverse XPoly's order of points
@@ -2982,7 +2982,7 @@ void SdrPathObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b
         // #i78696#
         // fRotate is mathematically correct, but aGeoStat.nRotationAngle is
         // mirrored -> mirror value here
-        aGeo.nRotationAngle = NormAngle360(FRound(-fRotate / F_PI18000));
+        aGeo.nRotationAngle = NormAngle36000(FRound(-fRotate / F_PI18000));
         aGeo.RecalcSinCos();
     }
 
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index a7e706da16a6..54fcda68de12 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1703,7 +1703,7 @@ void SdrTextObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b
         // #i78696#
         // fRotate is matematically correct, but aGeoStat.nRotationAngle is
         // mirrored -> mirror value here
-        aGeoStat.nRotationAngle = NormAngle360(FRound(-fRotate / F_PI18000));
+        aGeoStat.nRotationAngle = NormAngle36000(FRound(-fRotate / F_PI18000));
         aGeoStat.RecalcSinCos();
         Rotate(Point(), aGeoStat.nRotationAngle, aGeoStat.nSin, aGeoStat.nCos);
     }
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index b2b3afd2fc74..91c294eea919 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -156,7 +156,7 @@ void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract
     if (bRota90Merk) {
         bool bRota90=aGeo.nRotationAngle % 9000 ==0;
         if (!bRota90) { // there's seems to be a rounding error occurring: correct it
-            long a=NormAngle360(aGeo.nRotationAngle);
+            long a=NormAngle36000(aGeo.nRotationAngle);
             if (a<4500) a=0;
             else if (a<13500) a=9000;
             else if (a<22500) a=18000;
@@ -196,11 +196,11 @@ void SdrTextObj::NbcRotate(const Point& rRef, long nAngle, double sn, double cs)
     maRect.SetRight(maRect.Left()+dx );
     maRect.SetBottom(maRect.Top()+dy );
     if (aGeo.nRotationAngle==0) {
-        aGeo.nRotationAngle=NormAngle360(nAngle);
+        aGeo.nRotationAngle=NormAngle36000(nAngle);
         aGeo.nSin=sn;
         aGeo.nCos=cs;
     } else {
-        aGeo.nRotationAngle=NormAngle360(aGeo.nRotationAngle+nAngle);
+        aGeo.nRotationAngle=NormAngle36000(aGeo.nRotationAngle+nAngle);
         aGeo.RecalcSinCos();
     }
     SetRectsDirty();
@@ -258,7 +258,7 @@ void SdrTextObj::NbcMirror(const Point& rRef1, const Point& rRef2)
     if (bRota90Merk) {
         bool bRota90=aGeo.nRotationAngle % 9000 ==0;
         if (bRota90Merk && !bRota90) { // there's seems to be a rounding error occurring: correct it
-            long a=NormAngle360(aGeo.nRotationAngle);
+            long a=NormAngle36000(aGeo.nRotationAngle);
             if (a<4500) a=0;
             else if (a<13500) a=9000;
             else if (a<22500) a=18000;
diff --git a/svx/source/svdraw/svdtrans.cxx b/svx/source/svdraw/svdtrans.cxx
index c9e7326b26d3..34bb9396659b 100644
--- a/svx/source/svdraw/svdtrans.cxx
+++ b/svx/source/svdraw/svdtrans.cxx
@@ -394,14 +394,14 @@ long GetAngle(const Point& rPnt)
     return a;
 }
 
-long NormAngle180(long a)
+long NormAngle18000(long a)
 {
     while (a<-18000) a+=36000;
     while (a>=18000) a-=36000;
     return a;
 }
 
-long NormAngle360(long a)
+long NormAngle36000(long a)
 {
     while (a<0) a+=36000;
     while (a>=36000) a-=36000;
@@ -483,7 +483,7 @@ tools::Polygon Rect2Poly(const tools::Rectangle& rRect, const GeoStat& rGeo)
 void Poly2Rect(const tools::Polygon& rPol, tools::Rectangle& rRect, GeoStat& rGeo)
 {
     rGeo.nRotationAngle=GetAngle(rPol[1]-rPol[0]);
-    rGeo.nRotationAngle=NormAngle360(rGeo.nRotationAngle);
+    rGeo.nRotationAngle=NormAngle36000(rGeo.nRotationAngle);
     // rotation successful
     rGeo.RecalcSinCos();
 
@@ -507,9 +507,9 @@ void Poly2Rect(const tools::Polygon& rPol, tools::Rectangle& rRect, GeoStat& rGe
         nShW+=18000;
         aPt0=rPol[3];
     }
-    nShW=NormAngle180(nShW);
+    nShW=NormAngle18000(nShW);
     if (nShW<-9000 || nShW>9000) {
-        nShW=NormAngle180(nShW+18000);
+        nShW=NormAngle18000(nShW+18000);
     }
     if (nShW<-SDRMAXSHEAR) nShW=-SDRMAXSHEAR; // limit ShearWinkel (shear angle) to +/- 89.00 deg
     if (nShW>SDRMAXSHEAR)  nShW=SDRMAXSHEAR;
diff --git a/sw/source/core/graphic/grfatr.cxx b/sw/source/core/graphic/grfatr.cxx
index a9b318aebbe6..4b73f2e078c2 100644
--- a/sw/source/core/graphic/grfatr.cxx
+++ b/sw/source/core/graphic/grfatr.cxx
@@ -155,7 +155,7 @@ sal_Int16 SwRotationGrf::checkAndCorrectValue(sal_Int16 nValue)
         DBG_ASSERT(false, "SwRotationGrf: Value is in 10th degree and *has* to be in [0 .. 3600[ (!)");
         return 3600 + (nValue % 3600);
     }
-    else if (nValue > 3600)
+    else if (nValue >= 3600)
     {
         // bigger range, use modulo
         DBG_ASSERT(false, "SwRotationGrf: Value is in 10th degree and *has* to be in [0 .. 3600[ (!)");
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 9b1040de6d6f..98ec36fe9534 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -689,7 +689,7 @@ void PlcDrawObj::WritePlc( WW8Export& rWrt ) const
                     aRect = pObj->GetLogicRect();
 
                     // rotating to vertical means swapping height and width as seen in SvxMSDffManager::ImportShape
-                    const long nAngle = NormAngle360( pObj->GetRotateAngle() );
+                    const long nAngle = NormAngle36000( pObj->GetRotateAngle() );
                     const bool bAllowSwap = pObj->GetObjIdentifier() != OBJ_LINE && pObj->GetObjIdentifier() != OBJ_GRUP;
                     if ( bAllowSwap && (( nAngle > 4500 && nAngle <= 13500 ) || ( nAngle > 22500 && nAngle <= 31500 )) )
                     {
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index ae8a6333d720..2c0c1a64d515 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -248,7 +248,7 @@ void RTFSdrImport::applyProperty(uno::Reference<drawing::XShape> const& xShape,
         if (!xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
             xPropertySet->setPropertyValue(
                 "RotateAngle",
-                uno::makeAny(sal_Int32(NormAngle360(static_cast<long>(nRotation) * -1))));
+                uno::makeAny(sal_Int32(NormAngle36000(static_cast<long>(nRotation) * -1))));
     }
 
     if (nHoriOrient != 0 && xPropertySet.is())


More information about the Libreoffice-commits mailing list