summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2017-11-15 13:56:38 +0100
committerArmin Le Grand <Armin.Le.Grand@cib.de>2017-11-18 13:07:46 +0100
commitd74b26b41bfea3ba7a1834953b2bfe9b7ff0d70f (patch)
tree9e9684d1481df209e585ab08b079de5bfa86a466 /svx
parent1059e234f4b3b3f6b770b2e4d973923e54e7045b (diff)
RotateFlyFrame3: Corrected interactive Crop
To correct interactive Crop in transformed states, I had to rework some stuff involved that anyways was in a non optimal state. Added functionality to translate the object to make Crop seem to work more seamlessly. Some mapping was needed to make the Cropped, transformed object to be in the correct relative position to the uncropped, untransfomed one. Restructured TransformableSwFrame to directly re-create last non-transformed SwFrame(s) from the SwFrameAreaDefinition from the current Transformations, offering the untransformed SwRect(s) now for usage. Identified and corrected error when FlyFrame was translated using keyboard, the accessing method needed to adapt position in the transformed case. Started to look at Contour stuff, adapted a set contour to be correctly used by adapting it as needed in the transformed case. Change-Id: I0d5f14958bcd6f826b9abd53f1f47b7d0bc5a0e2
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svddrgmt.cxx20
-rw-r--r--svx/source/svdraw/svdobj.cxx10
-rw-r--r--svx/source/uitest/sdrobject.cxx16
3 files changed, 20 insertions, 26 deletions
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index 714d4e66a334..1e3344c26410 100644
--- a/svx/source/svdraw/svddrgmt.cxx
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -3766,25 +3766,17 @@ bool SdrDragCrop::EndSdrDrag(bool /*bCopy*/)
if(bExternal)
{
- // With Ref point (opposed to dragged point), X scale and Y scale,
+ // With aLocalStart point (opposed to dragged point), X scale and Y scale,
// we call crop (virtual method) on pSdrObject which calls VirtFlyDrawObj
- // crop. aRef needs to be adapted to concrete Object's boundaries which
- // is different from Crop-Ranges. This is because the Graphic and it's
- // SdrObject representation is inside the FlyFrame, but not identical
- // with it.
- const tools::Rectangle& rOutRect(pExternalSdrObject->GetCurrentBoundRect());
- const basegfx::B2DHomMatrix aExternalTransform(
- basegfx::utils::createScaleTranslateB2DHomMatrix(
- rOutRect.getWidth(), rOutRect.getHeight(),
- rOutRect.Left(), rOutRect.Top()));
- const basegfx::B2DPoint aRef(aExternalTransform * aLocalStart);
+ // crop. Use aLocalStart unchanged, so being relative to the Crop-Action,
+ // the called instance knows best how to use it
const double fScaleX(aRangeNewNoShearNoRotate.getWidth() / aRangeOriginalNoShearNoRotate.getWidth());
const double fScaleY(aRangeNewNoShearNoRotate.getHeight() / aRangeOriginalNoShearNoRotate.getHeight());
pExternalSdrObject->Crop(
- Point(basegfx::fround(aRef.getX()), basegfx::fround(aRef.getY())),
- Fraction(fScaleX),
- Fraction(fScaleY));
+ aLocalStart,
+ fScaleX,
+ fScaleY);
}
else
{
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index d5ef63b3c842..020c75655be8 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -1485,8 +1485,10 @@ void SdrObject::Move(const Size& rSiz)
}
}
-void SdrObject::NbcCrop(const Point& /*rRef*/, const Fraction& /*xFact*/, const Fraction& /*yFact*/) {
- // Default: does nothing. Real behaviour in SwVirtFlyDrawObj and SdrGrafObj
+void SdrObject::NbcCrop(const basegfx::B2DPoint& /*aRef*/, double /*fxFact*/, double /*fyFact*/)
+{
+ // Default: does nothing. Real behaviour in SwVirtFlyDrawObj and SdrDragCrop::EndSdrDrag.
+ // Where SwVirtFlyDrawObj is the only real user of it to do something local
}
void SdrObject::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative)
@@ -1507,10 +1509,10 @@ void SdrObject::Resize(const Point& rRef, const Fraction& xFact, const Fraction&
}
}
-void SdrObject::Crop(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+void SdrObject::Crop(const basegfx::B2DPoint& rRef, double fxFact, double fyFact)
{
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
- NbcCrop(rRef, xFact, yFact);
+ NbcCrop(rRef, fxFact, fyFact);
SetChanged();
BroadcastObjectChange();
SendUserCall(SdrUserCallType::Resize,aBoundRect0);
diff --git a/svx/source/uitest/sdrobject.cxx b/svx/source/uitest/sdrobject.cxx
index f70cb2e3c511..4fdd4c315764 100644
--- a/svx/source/uitest/sdrobject.cxx
+++ b/svx/source/uitest/sdrobject.cxx
@@ -99,6 +99,8 @@ void SdrUIObject::execute(const OUString& rAction,
}
else if (rAction == "CROP")
{
+ // RotateFlyFrame3: Note: Crop does nothing at SdrObject
+ // anymore, see comment at SdrObject::NbcCrop
auto itrNX = rParameters.find("X");
if (itrNX == rParameters.end())
throw css::uno::RuntimeException("missing parameter X");
@@ -107,23 +109,21 @@ void SdrUIObject::execute(const OUString& rAction,
if (itrNY == rParameters.end())
throw css::uno::RuntimeException("missing parameter Y");
- long nX = itrNX->second.toInt32();
- long nY = itrNY->second.toInt32();
- Point aPos(nX, nY);
+ const double fX(itrNX->second.toDouble());
+ const double fY(itrNY->second.toDouble());
+ const basegfx::B2DPoint aPos(fX, fY);
auto itrFracX = rParameters.find("FRAC_X");
if (itrFracX == rParameters.end())
throw css::uno::RuntimeException("missing parameter FRAC_X");
- double nFracX = itrFracX->second.toDouble();
- Fraction aFracX(nFracX);
+ const double fFracX(itrFracX->second.toDouble());
auto itrFracY = rParameters.find("FRAC_Y");
if (itrFracY == rParameters.end())
throw css::uno::RuntimeException("missing parameter FRAC_Y");
- double nFracY = itrFracY->second.toDouble();
- Fraction aFracY(nFracY);
+ const double fFracY(itrFracY->second.toDouble());
- pObj->Crop(aPos, aFracX, aFracY);
+ pObj->Crop(aPos, fFracX, fFracY);
}
else if (rAction == "ROTATE")
{