summaryrefslogtreecommitdiffstats
path: root/sw/source/core/layout/wsfrm.cxx
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 /sw/source/core/layout/wsfrm.cxx
parentRotateFlyFrame3: Made interactions work properly (diff)
downloadcore-d74b26b41bfea3ba7a1834953b2bfe9b7ff0d70f.tar.gz
core-d74b26b41bfea3ba7a1834953b2bfe9b7ff0d70f.zip
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 'sw/source/core/layout/wsfrm.cxx')
-rw-r--r--sw/source/core/layout/wsfrm.cxx68
1 files changed, 58 insertions, 10 deletions
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 7f7068ed0362..08debf8408e2 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -65,6 +65,10 @@ SwFrameAreaDefinition::SwFrameAreaDefinition()
{
}
+SwFrameAreaDefinition::~SwFrameAreaDefinition()
+{
+}
+
void SwFrameAreaDefinition::setFrameAreaPositionValid(bool bNew)
{
if(mbFrameAreaPositionValid != bNew)
@@ -146,6 +150,55 @@ void SwFrameAreaDefinition::transform_translate(const Point& rOffset)
}
}
+SwRect TransformableSwFrame::getUntransformedFrameArea() const
+{
+ const basegfx::B2DHomMatrix& rSource(getLocalFrameAreaTransformation());
+
+ if(rSource.isIdentity())
+ {
+ return mrSwFrameAreaDefinition.getFrameArea();
+ }
+ else
+ {
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ rSource.decompose(aScale, aTranslate, fRotate, fShearX);
+ const basegfx::B2DPoint aCenter(rSource * basegfx::B2DPoint(0.5, 0.5));
+ const basegfx::B2DVector aAbsScale(basegfx::absolute(aScale));
+
+ return SwRect(
+ basegfx::fround(aCenter.getX() - (0.5 * aAbsScale.getX())),
+ basegfx::fround(aCenter.getY() - (0.5 * aAbsScale.getY())),
+ basegfx::fround(aAbsScale.getX()),
+ basegfx::fround(aAbsScale.getY()));
+ }
+}
+
+SwRect TransformableSwFrame::getUntransformedFramePrintArea() const
+{
+ const basegfx::B2DHomMatrix& rSource(getLocalFramePrintAreaTransformation());
+
+ if(rSource.isIdentity())
+ {
+ return mrSwFrameAreaDefinition.getFramePrintArea();
+ }
+ else
+ {
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ rSource.decompose(aScale, aTranslate, fRotate, fShearX);
+ const basegfx::B2DPoint aCenter(rSource * basegfx::B2DPoint(0.5, 0.5));
+ const basegfx::B2DVector aAbsScale(basegfx::absolute(aScale));
+ const SwRect aUntransformedFrameArea(getUntransformedFrameArea());
+
+ return SwRect(
+ basegfx::fround(aCenter.getX() - (0.5 * aAbsScale.getX())) - aUntransformedFrameArea.Left(),
+ basegfx::fround(aCenter.getY() - (0.5 * aAbsScale.getY())) - aUntransformedFrameArea.Top(),
+ basegfx::fround(aAbsScale.getX()),
+ basegfx::fround(aAbsScale.getY()));
+ }
+}
+
void TransformableSwFrame::createFrameAreaTransformations(
double fRotation,
const basegfx::B2DPoint& rCenter)
@@ -178,7 +231,6 @@ void TransformableSwFrame::adaptFrameAreasToTransformations()
if(aNewFrm != mrSwFrameAreaDefinition.getFrameArea())
{
- maSavedFrameArea = mrSwFrameAreaDefinition.getFrameArea();
SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(mrSwFrameAreaDefinition);
aFrm.setSwRect(aNewFrm);
}
@@ -196,7 +248,6 @@ void TransformableSwFrame::adaptFrameAreasToTransformations()
if(aNewPrt != mrSwFrameAreaDefinition.getFramePrintArea())
{
- maSavedFramePrintArea = mrSwFrameAreaDefinition.getFramePrintArea();
SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(mrSwFrameAreaDefinition);
aPrt.setSwRect(aNewPrt);
}
@@ -206,20 +257,17 @@ void TransformableSwFrame::adaptFrameAreasToTransformations()
void TransformableSwFrame::restoreFrameAreas()
{
// This can be done fully based on the Transformations currently
- // set (and I did this in the beginning and it may be necessary
- // again later), but for simplicity and performance now done using
- // the last save values for the SwRect(s), see above
-
- if(!getLocalFrameAreaTransformation().isIdentity() && maSavedFrameArea != mrSwFrameAreaDefinition.getFrameArea())
+ // set, so use this. Only needed when transformation *is* used
+ if(!getLocalFrameAreaTransformation().isIdentity())
{
SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(mrSwFrameAreaDefinition);
- aFrm.setSwRect(maSavedFrameArea);
+ aFrm.setSwRect(getUntransformedFrameArea());
}
- if(!getLocalFramePrintAreaTransformation().isIdentity() && maSavedFramePrintArea != mrSwFrameAreaDefinition.getFramePrintArea())
+ if(!getLocalFramePrintAreaTransformation().isIdentity())
{
SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(mrSwFrameAreaDefinition);
- aPrt.setSwRect(maSavedFramePrintArea);
+ aPrt.setSwRect(getUntransformedFramePrintArea());
}
}