diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-12-23 09:09:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-23 17:06:56 +0100 |
commit | 666e14ba6e82dcad6912a205694978b2736e4319 (patch) | |
tree | b4f13570b51f96ee9f1e7825c4422ea55c8fa620 | |
parent | 961f6db0b647614e8221185c0e8ac661d87de9b6 (diff) |
add utility NbcRotate method
Change-Id: I66d016a22158f9f9ef68a80842e95e45516f0b4e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108228
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | chart2/source/controller/main/DrawCommandDispatch.cxx | 5 | ||||
-rw-r--r-- | filter/source/msfilter/msdffimp.cxx | 15 | ||||
-rw-r--r-- | filter/source/msfilter/svdfppt.cxx | 5 | ||||
-rw-r--r-- | include/svx/svdobj.hxx | 2 | ||||
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 3 | ||||
-rw-r--r-- | reportdesign/source/ui/report/ReportSection.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/fuconcustomshape.cxx | 5 | ||||
-rw-r--r-- | sd/source/ui/func/fuconcs.cxx | 5 | ||||
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShapeEngine.cxx | 11 | ||||
-rw-r--r-- | svx/source/svdraw/svdobj.cxx | 11 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/ribbar/concustomshape.cxx | 5 |
12 files changed, 26 insertions, 49 deletions
diff --git a/chart2/source/controller/main/DrawCommandDispatch.cxx b/chart2/source/controller/main/DrawCommandDispatch.cxx index 5f2e1a73923d..53ed1cfc7a32 100644 --- a/chart2/source/controller/main/DrawCommandDispatch.cxx +++ b/chart2/source/controller/main/DrawCommandDispatch.cxx @@ -144,10 +144,7 @@ void DrawCommandDispatch::setAttributes( SdrObject* pObj ) pObj->SetMergedItemSet( aDest ); sal_Int32 nAngle = pSourceObj->GetRotateAngle(); if ( nAngle ) - { - double a = nAngle * F_PI18000; - pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) ); - } + pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle ); bAttributesAppliedFromGallery = true; } } diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 395822273865..d3d548c39265 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -4137,10 +4137,7 @@ SdrObject* SvxMSDffManager::ImportGroup( const DffRecordHeader& rHd, SvStream& r } if ( nGroupRotateAngle ) - { - double a = nGroupRotateAngle * F_PI18000; - pRet->NbcRotate( aClientRect.Center(), nGroupRotateAngle, sin( a ), cos( a ) ); - } + pRet->NbcRotate( aClientRect.Center(), nGroupRotateAngle ); if ( nSpFlags & ShapeFlag::FlipV ) { // BoundRect in aBoundRect Point aLeft( aClientRect.Left(), ( aClientRect.Top() + aClientRect.Bottom() ) >> 1 ); @@ -4720,10 +4717,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r if( bIsConnector ) { if( nObjectRotation ) - { - double a = nObjectRotation * F_PI18000; - pRet->NbcRotate( aObjData.aBoundRect.Center(), nObjectRotation, sin( a ), cos( a ) ); - } + pRet->NbcRotate( aObjData.aBoundRect.Center(), nObjectRotation ); // mirrored horizontally? if ( nSpFlags & ShapeFlag::FlipH ) { @@ -4831,10 +4825,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r if ( pRet ) { if( nObjectRotation ) - { - double a = nObjectRotation * F_PI18000; - pRet->NbcRotate( aObjData.aBoundRect.Center(), nObjectRotation, sin( a ), cos( a ) ); - } + pRet->NbcRotate( aObjData.aBoundRect.Center(), nObjectRotation ); // mirrored horizontally? if ( nSpFlags & ShapeFlag::FlipH ) { diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index f877bbc99e09..d287e0ab012a 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -1187,10 +1187,7 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx if ( rObjData.nSpFlags & ShapeFlag::FlipH ) nAngle = 36000 - nAngle; if ( nAngle ) - { - double a = nAngle * F_PI18000; - pTObj->NbcRotate( rObjData.aBoundRect.Center(), nAngle, sin( a ), cos( a ) ); - } + pTObj->NbcRotate( rObjData.aBoundRect.Center(), nAngle ); } if ( pRet ) { diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index b7af53864a77..335eb3d4dcb2 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -537,6 +537,8 @@ public: virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact); virtual void NbcCrop (const basegfx::B2DPoint& rRef, double fxFact, double fyFact); virtual void NbcRotate(const Point& rRef, tools::Long nAngle, double sn, double cs); + // Utility for call sites that don't have sin and cos handy + void NbcRotate(const Point& rRef, tools::Long nAngle); virtual void NbcMirror(const Point& rRef1, const Point& rRef2); virtual void NbcShear (const Point& rRef, tools::Long nAngle, double tn, bool bVShear); diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 7ee10203341e..5b081660148d 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -1083,8 +1083,7 @@ namespace // 100 is required because in this part of the code the angle is in a hundredth of // degrees. auto nAngle = -1 * 100.0 * rTypeModel.maRotation.toDouble(); - double nHRad = nAngle * F_PI18000; - pShape->NbcRotate(pShape->GetSnapRect().Center(), nAngle, sin(nHRad), cos(nHRad)); + pShape->NbcRotate(pShape->GetSnapRect().Center(), nAngle); } } } diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx index aca5d41bf3b3..d0618c234c58 100644 --- a/reportdesign/source/ui/report/ReportSection.cxx +++ b/reportdesign/source/ui/report/ReportSection.cxx @@ -606,10 +606,7 @@ void OReportSection::createDefault(const OUString& _sType,SdrObject* _pObj) _pObj->SetMergedItemSet( aDest ); sal_Int32 nAngle = pSourceObj->GetRotateAngle(); if ( nAngle ) - { - double a = nAngle * F_PI18000; - _pObj->NbcRotate( _pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) ); - } + _pObj->NbcRotate( _pObj->GetSnapRect().Center(), nAngle ); bAttributesAppliedFromGallery = true; } } diff --git a/sc/source/ui/drawfunc/fuconcustomshape.cxx b/sc/source/ui/drawfunc/fuconcustomshape.cxx index 6650456afa34..75edd8be6a6f 100644 --- a/sc/source/ui/drawfunc/fuconcustomshape.cxx +++ b/sc/source/ui/drawfunc/fuconcustomshape.cxx @@ -182,10 +182,7 @@ void FuConstCustomShape::SetAttributes( SdrObject* pObj ) pObj->SetMergedItemSet( aDest ); sal_Int32 nAngle = pSourceObj->GetRotateAngle(); if ( nAngle ) - { - double a = nAngle * F_PI18000; - pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) ); - } + pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle ); bAttributesAppliedFromGallery = true; } } diff --git a/sd/source/ui/func/fuconcs.cxx b/sd/source/ui/func/fuconcs.cxx index a406b5819d82..844bd824fc74 100644 --- a/sd/source/ui/func/fuconcs.cxx +++ b/sd/source/ui/func/fuconcs.cxx @@ -185,10 +185,7 @@ void FuConstructCustomShape::SetAttributes( SdrObject* pObj ) pObj->SetMergedItemSet( aDest ); sal_Int32 nAngle = pSourceObj->GetRotateAngle(); if ( nAngle ) - { - double a = nAngle * F_PI18000; - pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) ); - } + pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle ); bAttributesAppliedFromGallery = true; } } diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx index bca7c5bea8b2..11f26ff775b2 100644 --- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx @@ -327,11 +327,7 @@ Reference< drawing::XShape > SAL_CALL EnhancedCustomShapeEngine::render() xRenderedShape->Shear(rSdrObjCustomShape.GetSnapRect().Center(), nShearAngle, nTan, false); } if(nRotateAngle ) - { - double a = nRotateAngle * F_PI18000; - - xRenderedShape->NbcRotate(rSdrObjCustomShape.GetSnapRect().Center(), nRotateAngle, sin( a ), cos( a )); - } + xRenderedShape->NbcRotate(rSdrObjCustomShape.GetSnapRect().Center(), nRotateAngle); if ( bFlipV ) { Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 ); @@ -428,10 +424,7 @@ drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeom } sal_Int32 nRotateAngle = aCustomShape2d.GetRotateAngle(); if( nRotateAngle ) - { - double a = nRotateAngle * F_PI18000; - pObj->NbcRotate( aRect.Center(), nRotateAngle, sin( a ), cos( a ) ); - } + pObj->NbcRotate( aRect.Center(), nRotateAngle ); if ( bFlipH ) { Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() ); diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 260d0b0dd2ac..44fa531177cb 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -1401,6 +1401,17 @@ void SdrObject::NbcResize(const Point& rRef, const Fraction& xFact, const Fracti SetRectsDirty(); } +void SdrObject::NbcRotate(const Point& rRef, tools::Long nAngle) +{ + if (nAngle == 0) + NbcRotate( rRef, nAngle, 0.0, 1.0 ); + else + { + double a = nAngle * F_PI18000; + NbcRotate( rRef, nAngle, sin( a ), cos( a ) ); + } +} + void SdrObject::NbcRotate(const Point& rRef, tools::Long nAngle, double sn, double cs) { SetGlueReallyAbsolute(true); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index d7925942c954..905cfb6c683f 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -930,8 +930,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, Point aPivot(rTextRect.TopLeft()); aPivot.AdjustX(nMinWH ); aPivot.AdjustY(nMinWH ); - double a = nTextRotationAngle * F_PI18000; - pObj->NbcRotate(aPivot, nTextRotationAngle, sin(a), cos(a)); + pObj->NbcRotate(aPivot, nTextRotationAngle); } } diff --git a/sw/source/uibase/ribbar/concustomshape.cxx b/sw/source/uibase/ribbar/concustomshape.cxx index a90652f1b6ef..be3820dab9b1 100644 --- a/sw/source/uibase/ribbar/concustomshape.cxx +++ b/sw/source/uibase/ribbar/concustomshape.cxx @@ -139,10 +139,7 @@ void ConstCustomShape::SetAttributes( SdrObject* pObj ) pObj->SetMergedItemSet( aDest ); sal_Int32 nAngle = pSourceObj->GetRotateAngle(); if ( nAngle ) - { - double a = nAngle * F_PI18000; - pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) ); - } + pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle ); bAttributesAppliedFromGallery = true; } } |