summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2017-11-09 15:53:33 +0100
committerArmin Le Grand <Armin.Le.Grand@cib.de>2017-11-18 13:07:45 +0100
commit7d391f9a563041aae416c7017dcec36bbf4dfb2c (patch)
tree47553b0ddc74bf2db30f0015249e756d78ff9386
parentRotateFlyFrame3: Added basic transformation support (diff)
downloadcore-7d391f9a563041aae416c7017dcec36bbf4dfb2c.tar.gz
core-7d391f9a563041aae416c7017dcec36bbf4dfb2c.zip
RotateFlyFrame3: Restructured TransformableSwFrame
No longer derive a SwFrame that needs Transformation support from TransformableSwFrame, but keep it as a member (in a std::unique_ptr). Adapted all usages, also added reset of local SwRect(s) in local SwFrameAreaDefinition during layouting. That makes PrintPreview work correctly. Change-Id: I2e7720e67b57d4d29c0feb065878e246192a8a4c
-rw-r--r--sw/source/core/doc/notxtfrm.cxx104
-rw-r--r--sw/source/core/inc/flyfrms.hxx10
-rw-r--r--sw/source/core/inc/frame.hxx87
-rw-r--r--sw/source/core/inc/notxtfrm.hxx10
-rw-r--r--sw/source/core/layout/flylay.cxx67
-rw-r--r--sw/source/core/layout/wsfrm.cxx107
6 files changed, 177 insertions, 208 deletions
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 897e9f6d1121..3971c9140da2 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -144,7 +144,8 @@ static void lcl_PaintReplacement( const SwRect &rRect, const OUString &rText,
SwNoTextFrame::SwNoTextFrame(SwNoTextNode * const pNode, SwFrame* pSib )
: SwContentFrame( pNode, pSib ),
- TransformableSwFrame()
+ // RotateFlyFrame3
+ mpTransformableSwFrame()
{
mnFrameType = SwFrameType::NoTxt;
}
@@ -474,25 +475,41 @@ void SwNoTextFrame::MakeAll(vcl::RenderContext* pRenderContext)
// RotateFlyFrame3 - inner frame. Get rotation and check if used
const double fRotation(getFrameRotation());
const bool bRotated(!basegfx::fTools::equalZero(fRotation));
- SwFlyFreeFrame* pUpperFly(dynamic_cast< SwFlyFreeFrame* >(GetUpper()));
- if(bRotated && pUpperFly && !pUpperFly->isFrameAreaDefinitionValid())
+ if(bRotated)
{
- // RotateFlyFrame3: outer frame *needs* to be layouted first, force this by calling
- // it's ::Calc directly
- pUpperFly->Calc(pRenderContext);
- }
+ SwFlyFreeFrame* pUpperFly(dynamic_cast< SwFlyFreeFrame* >(GetUpper()));
- if(bRotated && pUpperFly)
- {
- // Reset outer frame to unrotated state. This is necessary to make the
- // layouting below work as currently implemented in Writer. As expected
- // using Transformations allows to do this on the fly due to all information
- // being included there.
- // The full solution would be to adapt the whole layouting
- // process of Writer to take care of Transformations, but that
- // is currently beyond scope
- pUpperFly->resetAreaDefinitionsToUntransformed(*pUpperFly);
+ if(pUpperFly)
+ {
+ if(!pUpperFly->isFrameAreaDefinitionValid())
+ {
+ // RotateFlyFrame3: outer frame *needs* to be layouted first, force this by calling
+ // it's ::Calc directly
+ pUpperFly->Calc(pRenderContext);
+ }
+
+ // Reset outer frame to unrotated state. This is necessary to make the
+ // layouting below work as currently implemented in Writer. As expected
+ // using Transformations allows to do this on the fly due to all information
+ // being included there.
+ // The full solution would be to adapt the whole layouting
+ // process of Writer to take care of Transformations, but that
+ // is currently beyond scope
+ if(pUpperFly->isTransformableSwFrame())
+ {
+ pUpperFly->getTransformableSwFrame()->resetAreaDefinitionsToUntransformed();
+ }
+ }
+
+ // Re-layout may be partially (see all isFrameAreaDefinitionValid() flags),
+ // so resetting the local SwFrame(s) in the local SwFrameAreaDefinition is also
+ // needed (e.g. for PrintPreview).
+ // Reset to BoundAreas will be done below automatically
+ if(isTransformableSwFrame())
+ {
+ getTransformableSwFrame()->resetAreaDefinitionsToUntransformed();
+ }
}
SwContentNotify aNotify( this );
@@ -519,15 +536,9 @@ void SwNoTextFrame::MakeAll(vcl::RenderContext* pRenderContext)
}
// RotateFlyFrame3 - inner frame
- // After the unrotated layout is finished, apply possible set rotation to it
- if(!bRotated)
+ if(bRotated)
{
- // reset transformations to show that they are not used
- resetLocalAreaTransformations();
- }
- else
- {
- const bool bMeValid(isFrameAreaDefinitionValid());
+ SwFlyFreeFrame* pUpperFly(dynamic_cast< SwFlyFreeFrame* >(GetUpper()));
if(pUpperFly)
{
@@ -536,30 +547,41 @@ void SwNoTextFrame::MakeAll(vcl::RenderContext* pRenderContext)
// the transformed SwFrame. All needed information is part
// of the already correctly created Transformations of the
// upper frame, so it can bre re-created on the fly
- pUpperFly->resetAreaDefinitionsToTransformed(*pUpperFly);
+ if(pUpperFly->isTransformableSwFrame())
+ {
+ pUpperFly->getTransformableSwFrame()->resetAreaDefinitionsToTransformed();
+ }
}
- if(bMeValid)
+ // After the unrotated layout is finished, apply possible set rotation to it
+ // get center from outer frame (layout frame) to be on the safe side
+ const Point aCenter(GetUpper() ? GetUpper()->getFrameArea().Center() : getFrameArea().Center());
+ const basegfx::B2DPoint aB2DCenter(aCenter.X(), aCenter.Y());
+
+ if(!mpTransformableSwFrame)
{
- // get center from outer frame (layout frame) to be on the safe side
- const Point aCenter(GetUpper() ? GetUpper()->getFrameArea().Center() : getFrameArea().Center());
- const basegfx::B2DPoint aB2DCenter(aCenter.X(), aCenter.Y());
-
- updateTransformationsAndFrameAreaDefinitions(
- *this,
- fRotation,
- aB2DCenter);
+ mpTransformableSwFrame.reset(new TransformableSwFrame(*this));
}
+
+ getTransformableSwFrame()->createFrameAreaTransformations(
+ fRotation,
+ aB2DCenter);
+ getTransformableSwFrame()->resetAreaDefinitionsToTransformed();
+ }
+ else
+ {
+ // reset transformations to show that they are not used
+ mpTransformableSwFrame.reset();
}
}
// RotateFlyFrame3 - Support for Transformations - outer frame
basegfx::B2DHomMatrix SwNoTextFrame::getFrameAreaTransformation() const
{
- if(!getLocalFrameAreaTransformation().isIdentity())
+ if(isTransformableSwFrame())
{
// use pre-created transformation
- return getLocalFrameAreaTransformation();
+ return getTransformableSwFrame()->getLocalFrameAreaTransformation();
}
// call parent
@@ -568,10 +590,10 @@ basegfx::B2DHomMatrix SwNoTextFrame::getFrameAreaTransformation() const
basegfx::B2DHomMatrix SwNoTextFrame::getFramePrintAreaTransformation() const
{
- if(!getLocalFramePrintAreaTransformation().isIdentity())
+ if(isTransformableSwFrame())
{
// use pre-created transformation
- return getLocalFramePrintAreaTransformation();
+ return getTransformableSwFrame()->getLocalFramePrintAreaTransformation();
}
// call parent
@@ -586,14 +608,14 @@ void SwNoTextFrame::transform_translate(const Point& rOffset)
SwContentFrame::transform_translate(rOffset);
// check if the Transformations need to be adapted
- if(isTransformationUsed())
+ if(isTransformableSwFrame())
{
const basegfx::B2DHomMatrix aTransform(
basegfx::utils::createTranslateB2DHomMatrix(
rOffset.X(), rOffset.Y()));
// transform using TransformableSwFrame
- doTransform(aTransform);
+ getTransformableSwFrame()->doTransform(aTransform);
}
}
diff --git a/sw/source/core/inc/flyfrms.hxx b/sw/source/core/inc/flyfrms.hxx
index c388d80a0c0b..429ff26b25e8 100644
--- a/sw/source/core/inc/flyfrms.hxx
+++ b/sw/source/core/inc/flyfrms.hxx
@@ -30,7 +30,7 @@ double getFrameRotation_from_SwNoTextFrame(const SwNoTextFrame& rNoTextFrame);
// Base class for those Flys that can "move freely" or better that are not
// bound in Content.
-class SwFlyFreeFrame : public SwFlyFrame, public TransformableSwFrame
+class SwFlyFreeFrame : public SwFlyFrame
{
private:
// #i34753# - flag for at-page anchored Writer fly frames
@@ -43,6 +43,9 @@ private:
SwRect maUnclippedFrame;
+ // RotateFlyFrame3 add TransformableSwFrame
+ std::unique_ptr< TransformableSwFrame > mpTransformableSwFrame;
+
void CheckClip( const SwFormatFrameSize &rSz ); //'Emergency' Clipping.
/** determines, if direct environment of fly frame has 'auto' size
@@ -126,6 +129,11 @@ public:
virtual bool IsFormatPossible() const override;
// RotateFlyFrame3 - Support for Transformations
+ bool isTransformableSwFrame() const { return bool(mpTransformableSwFrame); }
+ TransformableSwFrame* getTransformableSwFrame() { return mpTransformableSwFrame.get(); }
+ const TransformableSwFrame* getTransformableSwFrame() const { return mpTransformableSwFrame.get(); }
+
+ // RotateFlyFrame3 - Support for Transformations
virtual basegfx::B2DHomMatrix getFrameAreaTransformation() const override;
virtual basegfx::B2DHomMatrix getFramePrintAreaTransformation() const override;
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index 7cb12dadad1a..b8a2d7ab0370 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -220,54 +220,25 @@ public:
class SW_DLLPUBLIC TransformableSwFrame
{
private:
+ // The SwFrameAreaDefinition to work on
+ SwFrameAreaDefinition& mrSwFrameAreaDefinition;
+
// FrameAreaTransformation and FramePrintAreaTransformation
// here when more than translate/scale is used (e.g. rotation)
basegfx::B2DHomMatrix maFrameAreaTransformation;
basegfx::B2DHomMatrix maFramePrintAreaTransformation;
- // helper method to create FrameAreaTransformations based on the
- // curent FrameAreaDefinition
- void createFrameAreaTransformations(
- const SwFrameAreaDefinition& rSwFrameAreaDefinition,
- double fRotation,
- const basegfx::B2DPoint& rCenter);
-
- // helper method to set FrameAreaDefinitions based on given
- // transformations
- void setFrameAreaDefinitionsToBoundRangesOfTransformations(
- SwFrameAreaDefinition& rSwFrameAreaDefinition);
-
-protected:
- // Full update of Transformations and BoundAreas:
- // - Re-create Transformations based on SwRect(s) from the
- // given SwFrameAreaDefinition.
- // - Based on that, create BoundRanges for the Transformations
- // and use as new SwRect(s) for the given SwFrameAreaDefinition.
- void updateTransformationsAndFrameAreaDefinitions(
- SwFrameAreaDefinition& rSwFrameAreaDefinition,
- double fRotation,
- const basegfx::B2DPoint& rCenter);
-
- void setLocalFrameAreaTransformation(const basegfx::B2DHomMatrix& rNew)
- {
- maFrameAreaTransformation = rNew;
- }
-
- void setLocalFramePrintAreaTransformation(const basegfx::B2DHomMatrix& rNew)
- {
- maFramePrintAreaTransformation = rNew;
- }
-
- void resetLocalAreaTransformations()
- {
- maFrameAreaTransformation.identity();
- maFramePrintAreaTransformation.identity();
- }
+ // last saved versions of SwRect(s) from SwFrameAreaDefinition
+ SwRect maSavedFrameArea;
+ SwRect maSavedFramePrintArea;
public:
- TransformableSwFrame()
- : maFrameAreaTransformation(),
- maFramePrintAreaTransformation()
+ TransformableSwFrame(SwFrameAreaDefinition& rSwFrameAreaDefinition)
+ : mrSwFrameAreaDefinition(rSwFrameAreaDefinition),
+ maFrameAreaTransformation(),
+ maFramePrintAreaTransformation(),
+ maSavedFrameArea(),
+ maSavedFramePrintArea()
{
}
@@ -282,27 +253,23 @@ public:
return maFramePrintAreaTransformation;
}
- // This method allows to reset the SwRect(s) in the
- // given SwFrameAreaDefinition which are already apapted to
- // Transformation and thus have a changed BoundArea back to
- // the untransformed state. Only the SwRect(s) are changed
- // back, not the transformations. As expected from using
- // Transformations, these contain all the necessary
- // information
- void resetAreaDefinitionsToUntransformed(
- SwFrameAreaDefinition& rSwFrameAreaDefinition);
+ // Helper method to re-create FrameAreaTransformations based on the
+ // curent FrameAreaDefinition, given rotation and Center
+ void createFrameAreaTransformations(
+ double fRotation,
+ const basegfx::B2DPoint& rCenter);
+
+ // Tooling method to reset the SwRect(s) in the current
+ // SwFrameAreaDefinition which are already apapted to
+ // Transformation back to the untransformed state that was
+ // last saved (see resetAreaDefinitionsToTransformed).
+ // Only the SwRect(s) are changed back, not the transformations.
+ void resetAreaDefinitionsToUntransformed();
// Re-Creates the SwRect(s) as BoundAreas based on the current
- // Transformations, useful to set back the SwRect(s) to Transformed
- // state when itz was necessary to reset them temporarily (see above)
- void resetAreaDefinitionsToTransformed(
- SwFrameAreaDefinition& rSwFrameAreaDefinition);
-
- // check if used
- bool isTransformationUsed() const
- {
- return !maFrameAreaTransformation.isIdentity() || !maFramePrintAreaTransformation.isIdentity();
- }
+ // set Transformations, also saves the last SwRect(s) to the save
+ // values.
+ void resetAreaDefinitionsToTransformed();
// transform by given B2DHomMatrix
void doTransform(const basegfx::B2DHomMatrix aTransform);
diff --git a/sw/source/core/inc/notxtfrm.hxx b/sw/source/core/inc/notxtfrm.hxx
index 0054078890a4..6144b32e58eb 100644
--- a/sw/source/core/inc/notxtfrm.hxx
+++ b/sw/source/core/inc/notxtfrm.hxx
@@ -26,7 +26,7 @@ class OutputDevice;
class SwBorderAttrs;
struct SwCursorMoveState;
-class SwNoTextFrame: public SwContentFrame, public TransformableSwFrame
+class SwNoTextFrame: public SwContentFrame
{
private:
friend void FrameFinit();
@@ -38,6 +38,9 @@ private:
virtual void DestroyImpl() override;
virtual ~SwNoTextFrame() override;
+ // RotateFlyFrame3 add TransformableSwFrame
+ std::unique_ptr< TransformableSwFrame > mpTransformableSwFrame;
+
// RotateFlyFrame3 - Support for inner frame of a SwGrfNode.
// Only for local data extraction. To uniquely access information
// for local transformation, use getFrameArea(Print)Transformation.
@@ -66,6 +69,11 @@ public:
bool HasAnimation() const;
// RotateFlyFrame3 - Support for Transformations
+ bool isTransformableSwFrame() const { return bool(mpTransformableSwFrame); }
+ TransformableSwFrame* getTransformableSwFrame() { return mpTransformableSwFrame.get(); }
+ const TransformableSwFrame* getTransformableSwFrame() const { return mpTransformableSwFrame.get(); }
+
+ // RotateFlyFrame3 - Support for Transformations
virtual basegfx::B2DHomMatrix getFrameAreaTransformation() const override;
virtual basegfx::B2DHomMatrix getFramePrintAreaTransformation() const override;
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index 7a9aa676dfdc..10c519fea697 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -47,12 +47,13 @@ using namespace ::com::sun::star;
SwFlyFreeFrame::SwFlyFreeFrame( SwFlyFrameFormat *pFormat, SwFrame* pSib, SwFrame *pAnch )
: SwFlyFrame( pFormat, pSib, pAnch ),
- TransformableSwFrame(),
// #i34753#
mbNoMakePos( false ),
// #i37068#
mbNoMoveOnCheckClip( false ),
- maUnclippedFrame( )
+ maUnclippedFrame(),
+ // RotateFlyFrame3
+ mpTransformableSwFrame()
{
}
@@ -154,6 +155,21 @@ void SwFlyFreeFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/)
int nLoopControlRuns = 0;
const int nLoopControlMax = 10;
+ // RotateFlyFrame3 - outer frame
+ const double fRotation(getFrameRotation());
+ const bool bRotated(!basegfx::fTools::equalZero(fRotation));
+
+ if(bRotated)
+ {
+ // Re-layout may be partially (see all isFrameAreaDefinitionValid() flags),
+ // so resetting the local SwFrame(s) in the local SwFrameAreaDefinition is
+ // needed. Reset to BoundAreas will be done below automatically
+ if(isTransformableSwFrame())
+ {
+ getTransformableSwFrame()->resetAreaDefinitionsToUntransformed();
+ }
+ }
+
while ( !isFrameAreaPositionValid() || !isFrameAreaSizeValid() || !isFramePrintAreaValid() || m_bFormatHeightOnly || !m_bValidContentPos )
{
SwRectFnSet aRectFnSet(this);
@@ -233,30 +249,27 @@ void SwFlyFreeFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/)
// RotateFlyFrame3 - outer frame
// Do not refresh transforms/Areas self here, this will be done
// when inner and outer frame are layouted, in SwNoTextFrame::MakeAll
- const double fRotation(getFrameRotation());
- const bool bRotated(!basegfx::fTools::equalZero(fRotation));
-
- if(!bRotated)
- {
- // reset transformations to show that they are not used
- resetLocalAreaTransformations();
- }
- else
+ if(bRotated)
{
// RotateFlyFrame3: Safe changes locally
- const bool bMeValid(isFrameAreaDefinitionValid());
+ // get center from outer frame (layout frame) to be on the safe side
+ const Point aCenter(getFrameArea().Center());
+ const basegfx::B2DPoint aB2DCenter(aCenter.X(), aCenter.Y());
- if(bMeValid)
+ if(!mpTransformableSwFrame)
{
- // get center from outer frame (layout frame) to be on the safe side
- const Point aCenter(getFrameArea().Center());
- const basegfx::B2DPoint aB2DCenter(aCenter.X(), aCenter.Y());
-
- updateTransformationsAndFrameAreaDefinitions(
- *this,
- fRotation,
- aB2DCenter);
+ mpTransformableSwFrame.reset(new TransformableSwFrame(*this));
}
+
+ getTransformableSwFrame()->createFrameAreaTransformations(
+ fRotation,
+ aB2DCenter);
+ getTransformableSwFrame()->resetAreaDefinitionsToTransformed();
+ }
+ else
+ {
+ // reset transformations to show that they are not used
+ mpTransformableSwFrame.reset();
}
Unlock();
@@ -273,10 +286,10 @@ void SwFlyFreeFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/)
// RotateFlyFrame3 - Support for Transformations - outer frame
basegfx::B2DHomMatrix SwFlyFreeFrame::getFrameAreaTransformation() const
{
- if(!getLocalFrameAreaTransformation().isIdentity())
+ if(isTransformableSwFrame())
{
// use pre-created transformation
- return getLocalFrameAreaTransformation();
+ return getTransformableSwFrame()->getLocalFrameAreaTransformation();
}
// call parent
@@ -285,10 +298,10 @@ basegfx::B2DHomMatrix SwFlyFreeFrame::getFrameAreaTransformation() const
basegfx::B2DHomMatrix SwFlyFreeFrame::getFramePrintAreaTransformation() const
{
- if(!getLocalFramePrintAreaTransformation().isIdentity())
+ if(isTransformableSwFrame())
{
// use pre-created transformation
- return getLocalFramePrintAreaTransformation();
+ return getTransformableSwFrame()->getLocalFramePrintAreaTransformation();
}
// call parent
@@ -303,14 +316,14 @@ void SwFlyFreeFrame::transform_translate(const Point& rOffset)
SwFlyFrame::transform_translate(rOffset);
// check if the Transformations need to be adapted
- if(isTransformationUsed())
+ if(isTransformableSwFrame())
{
const basegfx::B2DHomMatrix aTransform(
basegfx::utils::createTranslateB2DHomMatrix(
rOffset.X(), rOffset.Y()));
// transform using TransformableSwFrame
- doTransform(aTransform);
+ getTransformableSwFrame()->doTransform(aTransform);
}
}
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index a67a70d46c76..4cd9245eb2f0 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -147,33 +147,26 @@ void SwFrameAreaDefinition::transform_translate(const Point& rOffset)
}
void TransformableSwFrame::createFrameAreaTransformations(
- const SwFrameAreaDefinition& rSwFrameAreaDefinition,
double fRotation,
const basegfx::B2DPoint& rCenter)
{
- // save Transformations to rFrameAreaTransformation and
- // rFramePrintAreaTransformation. Do not forget that PrintArea
- // is *relative* to FrameArea
const basegfx::B2DHomMatrix aRotateAroundCenter(
basegfx::utils::createRotateAroundPoint(
rCenter.getX(),
rCenter.getY(),
fRotation));
- const SwRect& rFrameArea(rSwFrameAreaDefinition.getFrameArea());
- const SwRect& rFramePrintArea(rSwFrameAreaDefinition.getFramePrintArea());
-
- setLocalFrameAreaTransformation(
- aRotateAroundCenter * basegfx::utils::createScaleTranslateB2DHomMatrix(
- rFrameArea.Width(), rFrameArea.Height(),
- rFrameArea.Left(), rFrameArea.Top()));
- setLocalFramePrintAreaTransformation(
- aRotateAroundCenter * basegfx::utils::createScaleTranslateB2DHomMatrix(
- rFramePrintArea.Width(), rFramePrintArea.Height(),
- rFramePrintArea.Left() + rFrameArea.Left(), rFramePrintArea.Top() + rFrameArea.Top()));
+ const SwRect& rFrameArea(mrSwFrameAreaDefinition.getFrameArea());
+ const SwRect& rFramePrintArea(mrSwFrameAreaDefinition.getFramePrintArea());
+
+ maFrameAreaTransformation = aRotateAroundCenter * basegfx::utils::createScaleTranslateB2DHomMatrix(
+ rFrameArea.Width(), rFrameArea.Height(),
+ rFrameArea.Left(), rFrameArea.Top());
+ maFramePrintAreaTransformation = aRotateAroundCenter * basegfx::utils::createScaleTranslateB2DHomMatrix(
+ rFramePrintArea.Width(), rFramePrintArea.Height(),
+ rFramePrintArea.Left() + rFrameArea.Left(), rFramePrintArea.Top() + rFrameArea.Top());
}
-void TransformableSwFrame::setFrameAreaDefinitionsToBoundRangesOfTransformations(
- SwFrameAreaDefinition& rSwFrameAreaDefinition)
+void TransformableSwFrame::resetAreaDefinitionsToTransformed()
{
if(!getLocalFrameAreaTransformation().isIdentity())
{
@@ -183,9 +176,10 @@ void TransformableSwFrame::setFrameAreaDefinitionsToBoundRangesOfTransformations
basegfx::fround(aRangeFrameArea.getMinX()), basegfx::fround(aRangeFrameArea.getMinY()),
basegfx::fround(aRangeFrameArea.getWidth()), basegfx::fround(aRangeFrameArea.getHeight()));
- if(aNewFrm != rSwFrameAreaDefinition.getFrameArea())
+ if(aNewFrm != mrSwFrameAreaDefinition.getFrameArea())
{
- SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(rSwFrameAreaDefinition);
+ maSavedFrameArea = mrSwFrameAreaDefinition.getFrameArea();
+ SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(mrSwFrameAreaDefinition);
aFrm.setSwRect(aNewFrm);
}
}
@@ -195,83 +189,40 @@ void TransformableSwFrame::setFrameAreaDefinitionsToBoundRangesOfTransformations
basegfx::B2DRange aRangeFramePrintArea(0.0, 0.0, 1.0, 1.0);
aRangeFramePrintArea.transform(getLocalFramePrintAreaTransformation());
const SwRect aNewPrt(
- basegfx::fround(aRangeFramePrintArea.getMinX()) - rSwFrameAreaDefinition.getFrameArea().Left(),
- basegfx::fround(aRangeFramePrintArea.getMinY()) - rSwFrameAreaDefinition.getFrameArea().Top(),
+ basegfx::fround(aRangeFramePrintArea.getMinX()) - mrSwFrameAreaDefinition.getFrameArea().Left(),
+ basegfx::fround(aRangeFramePrintArea.getMinY()) - mrSwFrameAreaDefinition.getFrameArea().Top(),
basegfx::fround(aRangeFramePrintArea.getWidth()),
basegfx::fround(aRangeFramePrintArea.getHeight()));
- if(aNewPrt != rSwFrameAreaDefinition.getFramePrintArea())
+ if(aNewPrt != mrSwFrameAreaDefinition.getFramePrintArea())
{
- SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(rSwFrameAreaDefinition);
+ maSavedFramePrintArea = mrSwFrameAreaDefinition.getFramePrintArea();
+ SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(mrSwFrameAreaDefinition);
aPrt.setSwRect(aNewPrt);
}
}
}
-void TransformableSwFrame::updateTransformationsAndFrameAreaDefinitions(
- SwFrameAreaDefinition& rSwFrameAreaDefinition,
- double fRotation,
- const basegfx::B2DPoint& rCenter)
+void TransformableSwFrame::resetAreaDefinitionsToUntransformed()
{
- createFrameAreaTransformations(
- rSwFrameAreaDefinition,
- fRotation,
- rCenter);
+ // 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
- setFrameAreaDefinitionsToBoundRangesOfTransformations(
- rSwFrameAreaDefinition);
-}
-
-void TransformableSwFrame::resetAreaDefinitionsToUntransformed(
- SwFrameAreaDefinition& rSwFrameAreaDefinition)
-{
- // calculate center of object
- basegfx::B2DPoint aCenter(getLocalFrameAreaTransformation() * basegfx::B2DPoint(0.5, 0.5));
-
- if(!getLocalFrameAreaTransformation().isIdentity())
+ if(!getLocalFrameAreaTransformation().isIdentity() && maSavedFrameArea != mrSwFrameAreaDefinition.getFrameArea())
{
- basegfx::B2DTuple aScale, aTranslate;
- double fRotate(0.0), fShearX(0.0);
- getLocalFrameAreaTransformation().decompose(aScale, aTranslate, fRotate, fShearX);
- const SwRect aNewFrm(
- basegfx::fround(aCenter.getX() - (0.5 * aScale.getX())),
- basegfx::fround(aCenter.getY() - (0.5 * aScale.getY())),
- basegfx::fround(aScale.getX()),
- basegfx::fround(aScale.getY()));
-
- if(aNewFrm != rSwFrameAreaDefinition.getFrameArea())
- {
- SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(rSwFrameAreaDefinition);
- aFrm.setSwRect(aNewFrm);
- }
+ SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(mrSwFrameAreaDefinition);
+ aFrm.setSwRect(maSavedFrameArea);
}
- if(!getLocalFramePrintAreaTransformation().isIdentity())
+ if(!getLocalFramePrintAreaTransformation().isIdentity() && maSavedFramePrintArea != mrSwFrameAreaDefinition.getFramePrintArea())
{
- basegfx::B2DTuple aScale, aTranslate;
- double fRotate(0.0), fShearX(0.0);
- getLocalFramePrintAreaTransformation().decompose(aScale, aTranslate, fRotate, fShearX);
- const SwRect aNewPrt(
- basegfx::fround(aCenter.getX() - (0.5 * aScale.getX())) - rSwFrameAreaDefinition.getFrameArea().Left(),
- basegfx::fround(aCenter.getY() - (0.5 * aScale.getY())) - rSwFrameAreaDefinition.getFrameArea().Top(),
- basegfx::fround(aScale.getX()),
- basegfx::fround(aScale.getY()));
-
- if(aNewPrt != rSwFrameAreaDefinition.getFramePrintArea())
- {
- SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(rSwFrameAreaDefinition);
- aPrt.setSwRect(aNewPrt);
- }
+ SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(mrSwFrameAreaDefinition);
+ aPrt.setSwRect(maSavedFramePrintArea);
}
}
-void TransformableSwFrame::resetAreaDefinitionsToTransformed(
- SwFrameAreaDefinition& rSwFrameAreaDefinition)
-{
- setFrameAreaDefinitionsToBoundRangesOfTransformations(
- rSwFrameAreaDefinition);
-}
-
// transform by given B2DHomMatrix
void TransformableSwFrame::doTransform(const basegfx::B2DHomMatrix aTransform)
{