[PATCH libreoffice-4-0] Backport of EMF+ changes from master

Fridrich Strba (via Code Review) gerrit at gerrit.libreoffice.org
Thu Mar 7 01:13:38 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2580

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/80/2580/1

Backport of EMF+ changes from master

Change-Id: I28553fca4db9fbe14d9fb64f57c8a9bf6e53b7fe
---
M cppcanvas/inc/cppcanvas/canvasgraphic.hxx
M cppcanvas/source/inc/canvasgraphichelper.hxx
M cppcanvas/source/inc/implrenderer.hxx
M cppcanvas/source/mtfrenderer/emfplus.cxx
M cppcanvas/source/mtfrenderer/mtftools.cxx
M cppcanvas/source/mtfrenderer/pointaction.cxx
M cppcanvas/source/mtfrenderer/polypolyaction.cxx
M cppcanvas/source/mtfrenderer/textaction.hxx
M cppcanvas/source/tools/canvasgraphichelper.cxx
9 files changed, 19 insertions(+), 38 deletions(-)



diff --git a/cppcanvas/inc/cppcanvas/canvasgraphic.hxx b/cppcanvas/inc/cppcanvas/canvasgraphic.hxx
index d423023..e496df6 100644
--- a/cppcanvas/inc/cppcanvas/canvasgraphic.hxx
+++ b/cppcanvas/inc/cppcanvas/canvasgraphic.hxx
@@ -131,13 +131,6 @@
          */
         virtual ::basegfx::B2DPolyPolygon const* getClip() const = 0;
 
-        /** Set object color
-         */
-        virtual void                             setRGBAColor( Color::IntSRGBA ) = 0;
-        /** Get object color
-         */
-        virtual Color::IntSRGBA                  getRGBAColor() const = 0;
-
         /** Set object composite mode
          */
         virtual void                             setCompositeOp( CompositeOp aOp ) = 0;
diff --git a/cppcanvas/source/inc/canvasgraphichelper.hxx b/cppcanvas/source/inc/canvasgraphichelper.hxx
index 125b1c2..f0ab8bc 100644
--- a/cppcanvas/source/inc/canvasgraphichelper.hxx
+++ b/cppcanvas/source/inc/canvasgraphichelper.hxx
@@ -52,8 +52,6 @@
             virtual void                             setClip( const ::basegfx::B2DPolyPolygon& rClipPoly );
             virtual void                             setClip();
             virtual ::basegfx::B2DPolyPolygon const* getClip() const;
-            virtual void                             setRGBAColor( Color::IntSRGBA );
-            virtual Color::IntSRGBA                  getRGBAColor() const;
             virtual void                             setCompositeOp( CompositeOp aOp );
             virtual CompositeOp                      getCompositeOp() const;
 
diff --git a/cppcanvas/source/inc/implrenderer.hxx b/cppcanvas/source/inc/implrenderer.hxx
index 7f34ad8..7d82ea7 100644
--- a/cppcanvas/source/inc/implrenderer.hxx
+++ b/cppcanvas/source/inc/implrenderer.hxx
@@ -259,7 +259,7 @@
                                    ActionVector::const_iterator& o_rRangeBegin,
                                    ActionVector::const_iterator& o_rRangeEnd ) const;
 
-            void processObjectRecord(SvMemoryStream& rObjectStream, sal_uInt16 flags, sal_Bool bUseWholeStream = sal_False);
+            void processObjectRecord(SvMemoryStream& rObjectStream, sal_uInt16 flags, sal_uInt32 dataSize, sal_Bool bUseWholeStream = sal_False);
 
             /* EMF+ */
             void processEMFPlus( MetaCommentAction* pAct, const ActionFactoryParameters& rFactoryParms, OutDevState& rState, const CanvasSharedPtr& rCanvas );
diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx
index 0c9db41..4c79953 100644
--- a/cppcanvas/source/mtfrenderer/emfplus.cxx
+++ b/cppcanvas/source/mtfrenderer/emfplus.cxx
@@ -714,7 +714,7 @@
             Graphic graphic;
 
 
-            void Read (SvMemoryStream &s, sal_Bool bUseWholeStream)
+            void Read (SvMemoryStream &s, sal_uInt32 dataSize, sal_Bool bUseWholeStream)
             {
                 sal_uInt32 header, unknown;
 
@@ -736,11 +736,11 @@
                     sal_Int32 mfType, mfSize;
 
                     s >> mfType >> mfSize;
-                    EMFP_DEBUG (printf ("EMF+\tmetafile type: %d dataSize: %d\n", mfType, mfSize));
+                    EMFP_DEBUG (printf ("EMF+\tmetafile type: %d dataSize: %d real size calculated from record dataSize: %d\n", mfType, mfSize, dataSize - 16));
 
                     GraphicFilter filter;
                     // workaround buggy metafiles, which have wrong mfSize set (n#705956 for example)
-                    SvMemoryStream mfStream (((char *)s.GetData()) + s.Tell(), bUseWholeStream ? s.remainingSize() : mfSize, STREAM_READ);
+                    SvMemoryStream mfStream (((char *)s.GetData()) + s.Tell(), bUseWholeStream ? s.remainingSize() : dataSize - 16, STREAM_READ);
 
                     filter.ImportGraphic (graphic, String (), mfStream);
 
@@ -1090,7 +1090,7 @@
             }
         }
 
-        void ImplRenderer::processObjectRecord(SvMemoryStream& rObjectStream, sal_uInt16 flags, sal_Bool bUseWholeStream)
+        void ImplRenderer::processObjectRecord(SvMemoryStream& rObjectStream, sal_uInt16 flags, sal_uInt32 dataSize, sal_Bool bUseWholeStream)
         {
             sal_uInt32 index;
 
@@ -1145,7 +1145,7 @@
                 {
                     EMFPImage *image;
                     aObjects [index] = image = new EMFPImage ();
-                    image->Read (rObjectStream, bUseWholeStream);
+                    image->Read (rObjectStream, dataSize, bUseWholeStream);
 
                     break;
                 }
@@ -1211,12 +1211,13 @@
                     if (mbMultipart) {
                         EMFP_DEBUG (printf ("EMF+ multipart record flags: %04hx\n", mMFlags));
                         mMStream.Seek (0);
-                        processObjectRecord (mMStream, mMFlags, sal_True);
+                        processObjectRecord (mMStream, mMFlags, dataSize, sal_True);
                     }
                     mbMultipart = false;
                 }
 
                 if (type != EmfPlusRecordTypeObject || !(flags & 0x8000))
+                {
                 switch (type) {
                 case EmfPlusRecordTypeHeader:
                     sal_uInt32 header, version;
@@ -1235,7 +1236,7 @@
                     EMFP_DEBUG (printf ("EMF+\talready used in svtools wmf/emf filter parser\n"));
                     break;
                 case EmfPlusRecordTypeObject:
-                    processObjectRecord (rMF, flags);
+                        processObjectRecord (rMF, flags, dataSize);
                     break;
                 case EmfPlusRecordTypeFillPie:
                     {
@@ -1476,6 +1477,9 @@
                                     ReadPoint (rMF, x2, y2, flags);
                                     ReadPoint (rMF, x3, y3, flags);
 
+                                        EMFP_DEBUG (printf ("EMF+ destination points: %f,%f %f,%f %f,%f\n", x1, y1, x2, y2, x3, y3));
+                                        EMFP_DEBUG (printf ("EMF+ destination rectangle: %f,%f %fx%f\n", x1, y1, x2 - x1, y3 - y1));
+
                                     aDstPoint = Map (x1, y1);
                                     aDstSize = MapSize(x2 - x1, y3 - y1);
 
@@ -1486,6 +1490,8 @@
 
                                 ReadRectangle (rMF, dx, dy, dw, dh, flags & 0x4000);
 
+                                    EMFP_DEBUG (printf ("EMF+ destination rectangle: %f,%f %fx%f\n", dx, dy, dw, dh));
+
                                 aDstPoint = Map (dx, dy);
                                 aDstSize = MapSize(dw, dh);
 
@@ -1494,12 +1500,9 @@
 
                             if (bValid) {
                                 BitmapEx aBmp( image.graphic.GetBitmapEx () );
-                                const Rectangle aCropRect (::vcl::unotools::pointFromB2DPoint (basegfx::B2DPoint (sx, sy)),
-                                                           ::vcl::unotools::sizeFromB2DSize (basegfx::B2DSize(sw, sh)));
-                                aBmp.Crop( aCropRect );
-
 
                                 Size aSize( aBmp.GetSizePixel() );
+                                    EMFP_DEBUG (printf ("EMF+ bitmap size: %ldx%ld\n", aSize.Width(), aSize.Height()));
                                 if( aSize.Width() > 0 && aSize.Height() > 0 ) {
                                     ActionSharedPtr pBmpAction (
                                         internal::BitmapActionFactory::createBitmapAction (
@@ -1760,6 +1763,7 @@
                     EMFP_DEBUG (printf ("EMF+ unhandled record type: %d\n", type));
                     EMFP_DEBUG (printf ("EMF+\tTODO\n"));
                 }
+                }
 
                 rMF.Seek (next);
 
diff --git a/cppcanvas/source/mtfrenderer/mtftools.cxx b/cppcanvas/source/mtfrenderer/mtftools.cxx
index 5ca31a7..f34487b 100644
--- a/cppcanvas/source/mtfrenderer/mtftools.cxx
+++ b/cppcanvas/source/mtfrenderer/mtftools.cxx
@@ -126,8 +126,6 @@
                          const ::basegfx::B2DVector*                        pScaling,
                          const double*                                      pRotation )
         {
-            const ::Point aEmptyPoint;
-
             const bool bOffsetting( !rOffset.equalZero() );
             const bool bScaling( pScaling &&
                                  pScaling->getX() != 1.0 &&
diff --git a/cppcanvas/source/mtfrenderer/pointaction.cxx b/cppcanvas/source/mtfrenderer/pointaction.cxx
index 72b2895..43bd43e 100644
--- a/cppcanvas/source/mtfrenderer/pointaction.cxx
+++ b/cppcanvas/source/mtfrenderer/pointaction.cxx
@@ -21,7 +21,7 @@
 #include <rtl/logfile.hxx>
 #include <com/sun/star/rendering/XCanvas.hpp>
 
-#include <tools/gen.hxx>
+#include <sal/types.h>
 #include <vcl/canvastools.hxx>
 
 #include <basegfx/range/b2drange.hxx>
diff --git a/cppcanvas/source/mtfrenderer/polypolyaction.cxx b/cppcanvas/source/mtfrenderer/polypolyaction.cxx
index 723dea5..92d7063 100644
--- a/cppcanvas/source/mtfrenderer/polypolyaction.cxx
+++ b/cppcanvas/source/mtfrenderer/polypolyaction.cxx
@@ -23,7 +23,7 @@
 #include <com/sun/star/rendering/XCanvas.hpp>
 #include <com/sun/star/rendering/TexturingMode.hpp>
 
-#include <tools/gen.hxx>
+#include <sal/types.h>
 #include <vcl/canvastools.hxx>
 
 #include <basegfx/range/b2drectangle.hxx>
diff --git a/cppcanvas/source/mtfrenderer/textaction.hxx b/cppcanvas/source/mtfrenderer/textaction.hxx
index d6f0f33..b3218b0a 100644
--- a/cppcanvas/source/mtfrenderer/textaction.hxx
+++ b/cppcanvas/source/mtfrenderer/textaction.hxx
@@ -26,10 +26,10 @@
 #include <cppcanvas/canvas.hxx>
 #include <cppcanvas/renderer.hxx>
 #include <tools/poly.hxx>
-#include <tools/gen.hxx>
 
 class VirtualDevice;
 class Point;
+class Size;
 class Color;
 class String;
 
diff --git a/cppcanvas/source/tools/canvasgraphichelper.cxx b/cppcanvas/source/tools/canvasgraphichelper.cxx
index 6854ff9..562be97 100644
--- a/cppcanvas/source/tools/canvasgraphichelper.cxx
+++ b/cppcanvas/source/tools/canvasgraphichelper.cxx
@@ -105,18 +105,6 @@
             return maRenderState;
         }
 
-        void CanvasGraphicHelper::setRGBAColor( Color::IntSRGBA aColor )
-        {
-            maRenderState.DeviceColor = tools::intSRGBAToDoubleSequence( mxGraphicDevice,
-                                                                         aColor );
-        }
-
-        Color::IntSRGBA CanvasGraphicHelper::getRGBAColor() const
-        {
-            return tools::doubleSequenceToIntSRGBA( mxGraphicDevice,
-                                                    maRenderState.DeviceColor );
-        }
-
         void CanvasGraphicHelper::setCompositeOp( CompositeOp aOp )
         {
             maRenderState.CompositeOperation = (sal_Int8)aOp;

-- 
To view, visit https://gerrit.libreoffice.org/2580
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I28553fca4db9fbe14d9fb64f57c8a9bf6e53b7fe
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Fridrich Strba <fridrich at documentfoundation.org>



More information about the LibreOffice mailing list