include/svx/svdobj.hxx | 2 +- include/svx/svdopage.hxx | 2 ++ svx/source/svdraw/svdobj.cxx | 38 -------------------------------------- svx/source/svdraw/svdopage.cxx | 5 +++++ sw/source/core/draw/dflyobj.cxx | 5 +++++ sw/source/core/inc/dflyobj.hxx | 3 +++ 6 files changed, 16 insertions(+), 39 deletions(-)
New commits: commit b33468fa2b5dadddd7ce27afd40979aafff61285 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat Feb 11 22:02:11 2023 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Sun Mar 5 05:27:04 2023 +0000 make NbcRotate abstract as it's implementation is noop During testing the NbcRotate function on SdrObject it turned out the the function is essentially a noop, because it uses normal equality to test the values of a double, which are a product of sin and cos functions (to determine the 90 degree angles). So because of this the input rectangle was never modified - noop. Because of this we can just remove the impl. of the function and declare it abstract, so that the actual implementations define a valid function to rotate. There were some subclasses that didn't override the NbcRotate so they used the one implementation in SdrObject. These subclasses now override the function and in the implementation we call assert(false), which is never called during a test run. It seems we never rotate those objects. Change-Id: I1b1a45a8e96ed2d061f9b9f80c5fdaa5a84d4c05 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148266 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index 52923dc5b92e..ab5066d699a2 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -542,7 +542,7 @@ public: virtual void NbcMove (const Size& rSiz); 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, Degree100 nAngle, double sn, double cs); + virtual void NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs) = 0; // Utility for call sites that don't have sin and cos handy void NbcRotate(const Point& rRef, Degree100 nAngle); virtual void NbcMirror(const Point& rRef1, const Point& rRef2); diff --git a/include/svx/svdopage.hxx b/include/svx/svdopage.hxx index abb35d8239cd..279c75c758a6 100644 --- a/include/svx/svdopage.hxx +++ b/include/svx/svdopage.hxx @@ -64,6 +64,8 @@ public: virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; + + void NbcRotate(const Point& rRef, Degree100 nAngle, double sinAngle, double cosAngle) override; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index af9cac05631c..c4628f4cd2f2 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -1441,33 +1441,6 @@ void SdrObject::NbcRotate(const Point& rRef, Degree100 nAngle) namespace { - -tools::Rectangle lclRotateRectangle(tools::Rectangle const& rRectangle, Point const& rRef, double sn, double cs) -{ - tools::Rectangle aRectangle(rRectangle); - aRectangle.Move(-rRef.X(),-rRef.Y()); - tools::Rectangle R(aRectangle); - if (sn==1.0 && cs==0.0) { // 90deg - aRectangle.SetLeft(-R.Bottom() ); - aRectangle.SetRight(-R.Top() ); - aRectangle.SetTop(R.Left() ); - aRectangle.SetBottom(R.Right() ); - } else if (sn==0.0 && cs==-1.0) { // 180deg - aRectangle.SetLeft(-R.Right() ); - aRectangle.SetRight(-R.Left() ); - aRectangle.SetTop(-R.Bottom() ); - aRectangle.SetBottom(-R.Top() ); - } else if (sn==-1.0 && cs==0.0) { // 270deg - aRectangle.SetLeft(R.Top() ); - aRectangle.SetRight(R.Bottom() ); - aRectangle.SetTop(-R.Right() ); - aRectangle.SetBottom(-R.Left() ); - } - aRectangle.Move(rRef.X(),rRef.Y()); - aRectangle.Normalize(); // just in case - return aRectangle; -} - tools::Rectangle lclMirrorRectangle(tools::Rectangle const& rRectangle, Point const& rRef1, Point const& rRef2) { tools::Rectangle aRectangle(rRectangle); @@ -1499,17 +1472,6 @@ tools::Rectangle lclMirrorRectangle(tools::Rectangle const& rRectangle, Point co } // end anonymous namespace -void SdrObject::NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs) -{ - SetGlueReallyAbsolute(true); - tools::Rectangle aRectangle = getOutRectangle(); - aRectangle = lclRotateRectangle(aRectangle, rRef, sn, cs); - setOutRectangle(aRectangle); - SetBoundAndSnapRectsDirty(); - NbcRotateGluePoints(rRef, nAngle, sn, cs); - SetGlueReallyAbsolute(false); -} - void SdrObject::NbcMirror(const Point& rRef1, const Point& rRef2) { SetGlueReallyAbsolute(true); diff --git a/svx/source/svdraw/svdopage.cxx b/svx/source/svdraw/svdopage.cxx index 8bd374fe6b45..448758646afe 100644 --- a/svx/source/svdraw/svdopage.cxx +++ b/svx/source/svdraw/svdopage.cxx @@ -172,4 +172,9 @@ OUString SdrPageObj::TakeObjNamePlural() const return SvxResId(STR_ObjNamePluralPAGE); } +void SdrPageObj::NbcRotate(const Point& /*rRef*/, Degree100 /*nAngle*/, double /*sinAngle*/, double /*cosAngle*/) +{ + assert(false); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx index 45068cf1fd89..31a193a45119 100644 --- a/sw/source/core/draw/dflyobj.cxx +++ b/sw/source/core/draw/dflyobj.cxx @@ -156,6 +156,11 @@ rtl::Reference<SdrObject> SwFlyDrawObj::CloneSdrObject(SdrModel& rTargetModel) c return new SwFlyDrawObj(rTargetModel); } +void SwFlyDrawObj::NbcRotate(const Point& /*rRef*/, Degree100 /*nAngle*/, double /*sinAngle*/, double /*cosAngle*/) +{ + assert(false); +} + // TODO: Need own primitive to get the FlyFrame paint working namespace drawinglayer::primitive2d { diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx index 7e62bdaddefa..81789db285b3 100644 --- a/sw/source/core/inc/dflyobj.hxx +++ b/sw/source/core/inc/dflyobj.hxx @@ -53,6 +53,8 @@ public: virtual SdrObjKind GetObjIdentifier() const override; virtual bool IsTextBox() const override { return mbIsTextBox; } void SetTextBox(bool bIsTextBox) { mbIsTextBox = bIsTextBox; } + + virtual void NbcRotate(const Point& rRef, Degree100 nAngle, double sinAnle, double cosAngle) override; }; // virtual objects for Flys @@ -121,6 +123,7 @@ public: virtual void addCropHandles(SdrHdlList& rTarget) const override; virtual void Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs) override; + // FullDrag support virtual rtl::Reference<SdrObject> getFullDragClone() const override;