[Libreoffice-commits] core.git: sw/inc sw/source

Armin Le Grand alg at apache.org
Tue Nov 5 16:24:39 CET 2013


 sw/inc/ndgrf.hxx                |    1 
 sw/source/core/doc/notxtfrm.cxx |  156 +++++++++-------------------------------
 2 files changed, 36 insertions(+), 121 deletions(-)

New commits:
commit 2e5167528f7566dd9b000e50fc1610b7bf99132a
Author: Armin Le Grand <alg at apache.org>
Date:   Thu Oct 31 14:43:21 2013 +0000

    Resolves: #i123500# unified Graphic processing to use GraphicPrimitive2D
    
    (cherry picked from commit f5d69b2b8b002ca6905496a9d9065ef76b5641d7)
    
    Conflicts:
    	sw/source/core/doc/notxtfrm.cxx
    
    Change-Id: I1758aadcbe97ece271277378e62300b895421768

diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index f886b2f..a2687d6 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -132,7 +132,6 @@ public:
 
     /// wrappers for non-const calls at GraphicObject
     void ReleaseGraphicFromCache() { maGrfObj.ReleaseFromCache(); }
-    void DrawGraphicWithPDFHandling(OutputDevice& rOutDev, const Point& rPt, const Size& rSz, const GraphicAttr* pGrfAttr = NULL, const sal_uLong nFlags = GRFMGR_DRAW_STANDARD) { maGrfObj.DrawWithPDFHandling(rOutDev, rPt, rSz, pGrfAttr, nFlags); }
     void StartGraphicAnimation(OutputDevice* pOut, const Point& rPt, const Size& rSz, long nExtraData = 0, const GraphicAttr* pAttr = NULL, sal_uLong nFlags = GRFMGR_DRAW_STANDARD, OutputDevice* pFirstFrameOutDev = NULL) { maGrfObj.StartAnimation(pOut, rPt, rSz, nExtraData, pAttr, nFlags, pFirstFrameOutDev); }
     void StopGraphicAnimation(OutputDevice* pOut = NULL, long nExtraData = 0) { maGrfObj.StopAnimation(pOut, nExtraData); }
 
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 2febb36..fb4abbf 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -69,7 +69,7 @@
 #include <dview.hxx>
 #include <basegfx/matrix/b2dhommatrix.hxx>
 #include <drawinglayer/processor2d/baseprocessor2d.hxx>
-#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
+#include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <drawinglayer/processor2d/processor2dtools.hxx>
 
@@ -689,57 +689,19 @@ bool paintUsingPrimitivesHelper(
     OutputDevice& rOutputDevice,
     const drawinglayer::primitive2d::Primitive2DSequence& rSequence,
     const basegfx::B2DRange& rSourceRange,
-    const basegfx::B2DRange& rTargetRange,
-    const sal_Int32 nLeftCrop = 0,
-    const sal_Int32 nTopCrop = 0,
-    const sal_Int32 nRightCrop = 0,
-    const sal_Int32 nBottomCrop = 0,
-    const bool bMirrorX = false,
-    const bool bMirrorY = false)
+    const basegfx::B2DRange& rTargetRange)
 {
-    const double fSourceWidth(rSourceRange.getWidth());
-    const double fSourceHeight(rSourceRange.getHeight());
-
-    if(rSequence.hasElements() && !basegfx::fTools::equalZero(fSourceWidth) && !basegfx::fTools::equalZero(fSourceHeight))
+    if(rSequence.hasElements() && !basegfx::fTools::equalZero(rSourceRange.getWidth()) && !basegfx::fTools::equalZero(rSourceRange.getHeight()))
     {
-        // copy target range and apply evtl. cropping
-        basegfx::B2DRange aTargetRange(rTargetRange);
-
-        if(nLeftCrop || nTopCrop || nRightCrop || nBottomCrop)
+        if(!basegfx::fTools::equalZero(rTargetRange.getWidth()) && !basegfx::fTools::equalZero(rTargetRange.getHeight()))
         {
-            // calculate original TargetRange
-            const double fFactor100thmmToTwips(72.0 / 127.0);
-
-            aTargetRange = basegfx::B2DRange(
-                aTargetRange.getMinX() - (nLeftCrop * fFactor100thmmToTwips),
-                aTargetRange.getMinY() - (nTopCrop * fFactor100thmmToTwips),
-                aTargetRange.getMaxX() + (nRightCrop * fFactor100thmmToTwips),
-                aTargetRange.getMaxY() + (nBottomCrop * fFactor100thmmToTwips));
-        }
-
-        const double fTargetWidth(aTargetRange.getWidth());
-        const double fTargetHeight(aTargetRange.getHeight());
-
-        if(!basegfx::fTools::equalZero(fTargetWidth) && !basegfx::fTools::equalZero(fTargetHeight))
-        {
-            // map graphic range to target range. This will automatically include
-            // tme mapping from Svg 1/100th mm content to twips since the target
-            // range is twips already
-            basegfx::B2DHomMatrix aMappingTransform(
-                basegfx::tools::createTranslateB2DHomMatrix(
-                    -rSourceRange.getMinX(),
-                    -rSourceRange.getMinY()));
-
-            aMappingTransform.scale(fTargetWidth / fSourceWidth, fTargetHeight / fSourceHeight);
-            aMappingTransform.translate(aTargetRange.getMinX(), aTargetRange.getMinY());
-
-            // apply mirrorings
-            if(bMirrorX || bMirrorY)
-            {
-                aMappingTransform.translate(-aTargetRange.getCenterX(), -aTargetRange.getCenterY());
-                aMappingTransform.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0); // #119176# small typo with X/Y
-                aMappingTransform.translate(aTargetRange.getCenterX(), aTargetRange.getCenterY());
-            }
+            // map graphic range to target range. This will e.g. automatically include
+            // tme mapping from 1/100th mm content to twips if needed when the target
+            // range is defined in twips
+            const basegfx::B2DHomMatrix aMappingTransform(
+                basegfx::tools::createSourceRangeTargetRangeTransform(
+                    rSourceRange,
+                    rTargetRange));
 
             // Fill ViewInformation. Use MappingTransform here, so there is no need to
             // embed the primitives to it. Use original TargetRange here so there is also
@@ -748,7 +710,7 @@ bool paintUsingPrimitivesHelper(
             const drawinglayer::geometry::ViewInformation2D aViewInformation2D(
                 aMappingTransform,
                 rOutputDevice.GetViewTransformation(),
-                aTargetRange,
+                rTargetRange,
                 0,
                 0.0,
                 uno::Sequence< beans::PropertyValue >());
@@ -857,14 +819,6 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons
                 ::lcl_PaintReplacement( aAlignedGrfArea, aTxt, *pShell, this, false );
                 bContinue = false;
             }
-            else if( rGrfObj.IsCached( pOut, aAlignedGrfArea.Pos(),
-                                    aAlignedGrfArea.SSize(), &aGrfAttr ))
-            {
-                pGrfNd->DrawGraphicWithPDFHandling(*pOut,
-                    aAlignedGrfArea.Pos(), aAlignedGrfArea.SSize(),
-                    &aGrfAttr );
-                bContinue = false;
-            }
         }
 
         if( bContinue )
@@ -901,68 +855,30 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons
                 }
                 else
                 {
-                    const SvgDataPtr& rSvgDataPtr = rGrfObj.GetGraphic().getSvgData();
-                    bool bDone(false);
-
-                    if(rSvgDataPtr.get())
-                    {
-                        // Graphic is Svg and can be painted as primitives (vector graphic)
-                        const basegfx::B2DRange aTargetRange(
-                            aAlignedGrfArea.Left(), aAlignedGrfArea.Top(),
-                            aAlignedGrfArea.Right(), aAlignedGrfArea.Bottom());
-                        const bool bCropped(aGrfAttr.IsCropped());
-                        drawinglayer::primitive2d::Primitive2DSequence aContent;
-                        GraphicAttr aSuppressGraphicAttr(aGrfAttr);
-
-                        aSuppressGraphicAttr.SetCrop(0, 0, 0, 0);
-                        aSuppressGraphicAttr.SetRotation(0);
-                        aSuppressGraphicAttr.SetMirrorFlags(0);
-
-                        const bool bNeedTransformedGraphic(
-                            aSuppressGraphicAttr.IsSpecialDrawMode() ||
-                            aSuppressGraphicAttr.IsAdjusted() ||
-                            aSuppressGraphicAttr.IsMirrored() ||
-                            aSuppressGraphicAttr.IsRotated() ||
-                            aSuppressGraphicAttr.IsTransparent());
-
-                        if(bNeedTransformedGraphic)
-                        {
-                            // #i122039# need to apply graphic transformation if GraphicAttr are used qwhich need this
-                            const Graphic aTransformedGraphic(rGrfObj.GetTransformedGraphic(&aSuppressGraphicAttr));
-                            const basegfx::B2DRange aRange(rSvgDataPtr->getRange());
-                            const basegfx::B2DHomMatrix aTransform(
-                                basegfx::tools::createScaleTranslateB2DHomMatrix(
-                                    aRange.getRange(),
-                                    aRange.getMinimum()));
-
-                            aContent.realloc(1);
-                            aContent[0] = new drawinglayer::primitive2d::BitmapPrimitive2D(
-                                aTransformedGraphic.GetBitmapEx(),
-                                aTransform);
-                        }
-                        else
-                        {
-                            aContent = rSvgDataPtr->getPrimitive2DSequence();
-                        }
-
-                        bDone = paintUsingPrimitivesHelper(
-                            *pOut,
-                            aContent,
-                            rSvgDataPtr->getRange(),
-                            aTargetRange,
-                            bCropped ? aGrfAttr.GetLeftCrop() : 0,
-                            bCropped ? aGrfAttr.GetTopCrop() : 0,
-                            bCropped ? aGrfAttr.GetRightCrop() : 0,
-                            bCropped ? aGrfAttr.GetBottomCrop() : 0,
-                            aGrfAttr.GetMirrorFlags() & BMP_MIRROR_HORZ,
-                            aGrfAttr.GetMirrorFlags() & BMP_MIRROR_VERT);
-                    }
-
-                    if(!bDone)
-                    {
-                        // fallback paint, uses replacement image
-                        pGrfNd->DrawGraphicWithPDFHandling(*pOut, aAlignedGrfArea.Pos(), aAlignedGrfArea.SSize(), &aGrfAttr);
-                    }
+                    // unify using GraphicPrimitive2D
+                    // -> the primitive handles all crop and mirror stuff
+                    // -> the primitive renderer will create the needed pdf export data
+                    // -> if bitmap conent, it will be cached system-dependent
+                    const basegfx::B2DRange aTargetRange(
+                        aAlignedGrfArea.Left(), aAlignedGrfArea.Top(),
+                        aAlignedGrfArea.Right(), aAlignedGrfArea.Bottom());
+                    const basegfx::B2DHomMatrix aTargetTransform(
+                        basegfx::tools::createScaleTranslateB2DHomMatrix(
+                            aTargetRange.getRange(),
+                            aTargetRange.getMinimum()));
+                    drawinglayer::primitive2d::Primitive2DSequence aContent;
+
+                    aContent.realloc(1);
+                    aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D(
+                        aTargetTransform,
+                        rGrfObj.GetGraphic(),
+                        aGrfAttr);
+
+                    paintUsingPrimitivesHelper(
+                        *pOut,
+                        aContent,
+                        aTargetRange,
+                        aTargetRange);
                 }
             }
             else


More information about the Libreoffice-commits mailing list