[Libreoffice-commits] core.git: Branch 'feature/RotateFlyFrame3' - sw/source

Armin Le Grand Armin.Le.Grand at cib.de
Thu Nov 16 11:56:21 UTC 2017


 sw/source/core/doc/notxtfrm.cxx |   42 +++++++++++++++++++++++++++++++++-------
 1 file changed, 35 insertions(+), 7 deletions(-)

New commits:
commit 878f659ab3c38c6e3075aefd4db7c1d2db32faf6
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date:   Thu Nov 16 12:54:21 2017 +0100

    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

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);


More information about the Libreoffice-commits mailing list