diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-11-16 12:54:21 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-11-18 13:07:47 +0100 |
commit | 059469926e359153b9b291790ef2df84fa63fda9 (patch) | |
tree | 0afc7da1aa97c22250823ae43acdfdfd3fdd77b0 /sw | |
parent | d74b26b41bfea3ba7a1834953b2bfe9b7ff0d70f (diff) |
RotateFlyFrame3: Corrected Contour when rotated
When rotated, the contour has to be adapted to that state
and also needs to be calculated in untransformed state,
added needed code. Also need to add a ClipRegion set at
the target OutputDevice (e.g. from Contour) to the prepared
GraphicPrimitive. It was sometimes used due to a VCL_Based
PrimitiveRenderer being used, but that is just a coincidence.
Change-Id: I1888ecd0468243bf2f41233b0cb3f99a50ac9805
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/notxtfrm.cxx | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 9432576bdcf4..93103489af70 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -78,6 +78,7 @@ #include <txtfly.hxx> #include <vcl/graphicfilter.hxx> #include <vcl/pdfextoutdevdata.hxx> +#include <drawinglayer/primitive2d/maskprimitive2d.hxx> using namespace com::sun::star; @@ -348,10 +349,15 @@ void SwNoTextFrame::GetGrfArea( SwRect &rRect, SwRect* pOrigRect ) const { // Currently only used for scaling, cropping and mirroring the contour of graphics! // Everything else is handled by GraphicObject - // We put the graphic's visible rectangle into rRect. // pOrigRect contains position and size of the whole graphic. + // RotateFlyFrame3: SwFrame may be transformed. Get untransformed + // SwRect(s) as base of calculation + const TransformableSwFrame* pTransformableSwFrame(getTransformableSwFrame()); + const SwRect aFrameArea(pTransformableSwFrame ? pTransformableSwFrame->getUntransformedFrameArea() : getFrameArea()); + const SwRect aFramePrintArea(pTransformableSwFrame ? pTransformableSwFrame->getUntransformedFramePrintArea() : getFramePrintArea()); + const SwAttrSet& rAttrSet = GetNode()->GetSwAttrSet(); const SwCropGrf& rCrop = rAttrSet.GetCropGrf(); MirrorGraph nMirror = rAttrSet.GetMirrorGrf().GetValue(); @@ -376,7 +382,7 @@ void SwNoTextFrame::GetGrfArea( SwRect &rRect, SwRect* pOrigRect ) const Size aOrigSz( static_cast<const SwNoTextNode*>(GetNode())->GetTwipSize() ); if ( !aOrigSz.Width() ) { - aOrigSz.Width() = getFramePrintArea().Width(); + aOrigSz.Width() = aFramePrintArea.Width(); nLeftCrop = -rCrop.GetLeft(); nRightCrop = -rCrop.GetRight(); } @@ -384,7 +390,7 @@ void SwNoTextFrame::GetGrfArea( SwRect &rRect, SwRect* pOrigRect ) const { nLeftCrop = std::max( aOrigSz.Width() - (rCrop.GetRight() + rCrop.GetLeft()), long(1) ); - const double nScale = double(getFramePrintArea().Width()) / double(nLeftCrop); + const double nScale = double(aFramePrintArea.Width()) / double(nLeftCrop); nLeftCrop = long(nScale * -rCrop.GetLeft() ); nRightCrop = long(nScale * -rCrop.GetRight() ); } @@ -399,14 +405,14 @@ void SwNoTextFrame::GetGrfArea( SwRect &rRect, SwRect* pOrigRect ) const if( !aOrigSz.Height() ) { - aOrigSz.Height() = getFramePrintArea().Height(); + aOrigSz.Height() = aFramePrintArea.Height(); nTopCrop = -rCrop.GetTop(); nBottomCrop= -rCrop.GetBottom(); } else { nTopCrop = std::max( aOrigSz.Height() - (rCrop.GetTop() + rCrop.GetBottom()), long(1) ); - const double nScale = double(getFramePrintArea().Height()) / double(nTopCrop); + const double nScale = double(aFramePrintArea.Height()) / double(nTopCrop); nTopCrop = long(nScale * -rCrop.GetTop() ); nBottomCrop= long(nScale * -rCrop.GetBottom() ); } @@ -419,9 +425,9 @@ void SwNoTextFrame::GetGrfArea( SwRect &rRect, SwRect* pOrigRect ) const nBottomCrop= nTmpCrop; } - Size aVisSz( getFramePrintArea().SSize() ); + Size aVisSz( aFramePrintArea.SSize() ); Size aGrfSz( aVisSz ); - Point aVisPt( getFrameArea().Pos() + getFramePrintArea().Pos() ); + Point aVisPt( aFrameArea.Pos() + aFramePrintArea.Pos() ); Point aGrfPt( aVisPt ); // Set the "visible" rectangle first @@ -999,6 +1005,28 @@ void paintGraphicUsingPrimitivesHelper( rGraphicTransform, rGrfObj, rGraphicAttr); + + // RotateFlyFrame3: If ClipRegion is set at OutputDevice, we + // need to use that. Usually the renderer would be a VCL-based + // PrimitiveRenderer, but there are system-specific shortcuts that + // will *not* use the VCL-Paint of Bitmap and thus ignore this. + // Anyways, indirectly using a CLipRegion set at the taget OutDev + // when using a PrimitiveRenderer is a non-valid implication. + // First tried only to use when HasPolyPolygonOrB2DPolyPolygon(), + // but there is an optimization at ClipRegion creation that detects + // a single Rectangle in a tools::PolyPolygon and forces to a simple + // RegionBand-based implementation, so cannot use it here. + if(rOutputDevice.IsClipRegion()) + { + const basegfx::B2DPolyPolygon aClip(rOutputDevice.GetClipRegion().GetAsB2DPolyPolygon()); + + if(0 != aClip.count()) + { + aContent[0] = new drawinglayer::primitive2d::MaskPrimitive2D( + aClip, + aContent); + } + } } basegfx::B2DRange aTargetRange(0.0, 0.0, 1.0, 1.0); |