diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-11-03 14:45:42 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-11-18 13:07:43 +0100 |
commit | 51ee0c5ba6b0ffcd4b12e652de48e3f775cccc7d (patch) | |
tree | 6a5f17c61d4a515b5ec4e1c71d29058ee5ee1fb7 /sw/source/core/layout/flylay.cxx | |
parent | 6675e6eaf999de94d49d7644d5877537fda83239 (diff) |
RotateFlyFrame3: Added transformation support to SwFrame
The layout element SwFrame now has methods to get linear
transformations for the geometry-defining FrameAreaDefinitions.
These return by default the SwRect (without being relative
for the FramePrintArea to make things easier), but are
replaced by the now two SwFrame derivates that support
rotation. The layout will now use the BoundRects of the
transformations, thus supporting a future that will allow
all kinds of free transformations (including mirror, rotation
and shear)
Change-Id: I18b85f5ddc2970a1b8c137d30b0c2ee49bb8df72
Diffstat (limited to 'sw/source/core/layout/flylay.cxx')
-rw-r--r-- | sw/source/core/layout/flylay.cxx | 89 |
1 files changed, 58 insertions, 31 deletions
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx index 69fa2615a733..e21991a32f4b 100644 --- a/sw/source/core/layout/flylay.cxx +++ b/sw/source/core/layout/flylay.cxx @@ -44,13 +44,16 @@ using namespace ::com::sun::star; -SwFlyFreeFrame::SwFlyFreeFrame( SwFlyFrameFormat *pFormat, SwFrame* pSib, SwFrame *pAnch ) : - SwFlyFrame( pFormat, pSib, pAnch ), +SwFlyFreeFrame::SwFlyFreeFrame( SwFlyFrameFormat *pFormat, SwFrame* pSib, SwFrame *pAnch ) +: SwFlyFrame( pFormat, pSib, pAnch ), // #i34753# mbNoMakePos( false ), // #i37068# mbNoMoveOnCheckClip( false ), - maUnclippedFrame( ) + maUnclippedFrame( ), + // RotateFlyFrame3 + maFrameAreaTransformation(), + maFramePrintAreaTransformation() { } @@ -223,36 +226,35 @@ void SwFlyFreeFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) } // RotateFlyFrame3 - inner frame + // After the unrotated layout is finished, apply possible set rotation to it const double fRotation(getRotation()); - if(0.0 != fRotation) + if(basegfx::fTools::equalZero(fRotation)) { - SwRect aFrameArea(getFrameArea()); - SwRect aFramePrintArea(getFramePrintArea()); - Point aCenter(aFrameArea.Center()); - - if(GetUpper()) - { - // get center from outer frame (layout frame) - const SwRect aUpperFrameArea(GetUpper()->getFrameArea()); - - aCenter = aUpperFrameArea.Center(); - } - - // apply rotation and re-set the FrameArea definitions - rotateFrameAreaDefinitionAroundPoint(aFrameArea, aFramePrintArea, aCenter, fRotation); - - if(aFrameArea != getFrameArea()) - { - SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this); - aFrm.setSwRect(aFrameArea); - } - - if(aFramePrintArea != getFramePrintArea()) - { - SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this); - aPrt.setSwRect(aFramePrintArea); - } + // reset transformations to show that they are not used + maFrameAreaTransformation.identity(); + maFramePrintAreaTransformation.identity(); + } + else + { + // save Transformations to local maFrameAreaTransformation + // and maFramePrintAreaTransformation. + + // 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()); + + createFrameAreaTransformations( + maFrameAreaTransformation, + maFramePrintAreaTransformation, + fRotation, + aB2DCenter); + + // create BoundRects of FrameAreas and re-set the FrameArea definitions + // to represent the rotated geometry in the layout object + setFrameAreaDefinitionsToBoundRangesOfTransformations( + maFrameAreaTransformation, + maFramePrintAreaTransformation); } Unlock(); @@ -266,7 +268,32 @@ void SwFlyFreeFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) #endif } -// RotateFlyFrame3 +// RotateFlyFrame3 - Support for Transformations - outer frame +basegfx::B2DHomMatrix SwFlyFreeFrame::getFrameAreaTransformation() const +{ + if(!maFrameAreaTransformation.isIdentity()) + { + // use pre-created transformation + return maFrameAreaTransformation; + } + + // call parent + return SwFlyFrame::getFrameAreaTransformation(); +} + +basegfx::B2DHomMatrix SwFlyFreeFrame::getFramePrintAreaTransformation() const +{ + if(!maFramePrintAreaTransformation.isIdentity()) + { + // use pre-created transformation + return maFramePrintAreaTransformation; + } + + // call parent + return SwFlyFrame::getFramePrintAreaTransformation(); +} + +// RotateFlyFrame3 - inner frame double SwFlyFreeFrame::getRotation() const { // SwLayoutFrame::Lower() != SwFrame::GetLower(), but SwFrame::GetLower() |