[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - cppcanvas/source

Bartosz Kosiorek gang65 at poczta.onet.pl
Fri Apr 28 21:03:27 UTC 2017


 cppcanvas/source/mtfrenderer/emfplus.cxx |   63 +++++++++++++++----------------
 1 file changed, 32 insertions(+), 31 deletions(-)

New commits:
commit 08fe3b0f1c1e72f15db1cd70d85effa3d63db276
Author: Bartosz Kosiorek <gang65 at poczta.onet.pl>
Date:   Fri Apr 7 14:43:44 2017 +0200

    tdf#107016 EMF+ Add support of import EmfPlusRecordTypeDrawRects record
    
    EmfPlusDrawRectss record defines the pen strokes for drawing a series of rectangles.
    
    Change-Id: Iaa061f8502fb51de44d2e65a1c92daf297b79d2b
    Reviewed-on: https://gerrit.libreoffice.org/36261
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>
    (cherry picked from commit a45feba83e5fb35eee1884887e8dbe795ebacde5)
    Reviewed-on: https://gerrit.libreoffice.org/36528
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx
index 888b40a30431..341e29e3943c 100644
--- a/cppcanvas/source/mtfrenderer/emfplus.cxx
+++ b/cppcanvas/source/mtfrenderer/emfplus.cxx
@@ -60,6 +60,7 @@ namespace
 #define EmfPlusRecordTypeObject 0x4008
 //TODO EmfPlusRecordTypeClear 0x4009
 #define EmfPlusRecordTypeFillRects 0x400A
+#define EmfPlusRecordTypeDrawRects 0x400B
 #define EmfPlusRecordTypeFillPolygon 0x400C
 #define EmfPlusRecordTypeDrawLines 0x400D
 #define EmfPlusRecordTypeFillEllipse 0x400E
@@ -92,6 +93,7 @@ namespace
 #define EmfPlusRecordTypeSetWorldTransform 0x402A
 #define EmfPlusRecordTypeResetWorldTransform 0x402B
 #define EmfPlusRecordTypeMultiplyWorldTransform 0x402C
+//TODO EmfPlusRecordTypeTranslateWorldTransform 0x402D
 //TODO EmfPlusRecordTypeScaleWorldTransform 0x402E
 //TODO EmfPlusRecordTypeRotateWorldTransform 0x402F
 #define EmfPlusRecordTypeSetPageTransform 0x4030
@@ -215,6 +217,7 @@ const char* emfTypeToName(sal_uInt16 type)
         case EmfPlusRecordTypeGetDC: return "EmfPlusRecordTypeGetDC";
         case EmfPlusRecordTypeObject: return "EmfPlusRecordTypeObject";
         case EmfPlusRecordTypeFillRects: return "EmfPlusRecordTypeFillRects";
+        case EmfPlusRecordTypeDrawRects: return "EmfPlusRecordTypeDrawRects";
         case EmfPlusRecordTypeFillPolygon: return "EmfPlusRecordTypeFillPolygon";
         case EmfPlusRecordTypeDrawLines: return "EmfPlusRecordTypeDrawLines";
         case EmfPlusRecordTypeFillEllipse: return "EmfPlusRecordTypeFillEllipse";
@@ -2002,48 +2005,46 @@ namespace cppcanvas
                         }
                         break;
                     case EmfPlusRecordTypeFillRects:
+                    case EmfPlusRecordTypeDrawRects:
                         {
-                            SAL_INFO("cppcanvas.emf", "EMF+ FillRects");
-
-                            sal_uInt32 brushIndexOrColor;
+                            // Silent MSVC warning C4701: potentially uninitialized local variable 'brushIndexOrColor' used
+                            sal_uInt32 brushIndexOrColor = 999;
                             sal_Int32 rectangles;
                             bool isColor = (flags & 0x8000);
                             ::basegfx::B2DPolygon polygon;
 
-                            rMF.ReadUInt32( brushIndexOrColor ).ReadInt32( rectangles );
+                            if ( type == EmfPlusRecordTypeFillRects )
+                            {
+                                SAL_INFO("cppcanvas.emf", "EMF+ FillRects");
+                                rMF.ReadUInt32( brushIndexOrColor );
+                                SAL_INFO("cppcanvas.emf", "EMF+\t" << (isColor ? "color" : "brush index") << ": 0x" << std::hex << brushIndexOrColor << std::dec);
+                            }
+                            else
+                            {
+                                SAL_INFO("cppcanvas.emf", "EMF+ DrawRects");
+                            }
 
-                            SAL_INFO("cppcanvas.emf", "EMF+\t" << ((flags & 0x8000) ? "color" : "brush index") << ": 0x" << std::hex << brushIndexOrColor << std::dec);
+                            rMF.ReadInt32( rectangles );
 
                             for (int i=0; i < rectangles; i++) {
-                                if (flags & 0x4000) {
-                                    /* 16bit integers */
-                                    sal_Int16 x, y, width, height;
-
-                                    rMF.ReadInt16( x ).ReadInt16( y ).ReadInt16( width ).ReadInt16( height );
-
-                                    polygon.append (Map (x, y));
-                                    polygon.append (Map (x + width, y));
-                                    polygon.append (Map (x + width, y + height));
-                                    polygon.append (Map (x, y + height));
-
-                                    SAL_INFO("cppcanvas.emf", "EMF+\trectangle: " << x << ", " << width << "x" << height);
-                                } else {
-                                    /* Single's */
-                                    float x, y, width, height;
-
-                                    rMF.ReadFloat( x ).ReadFloat( y ).ReadFloat( width ).ReadFloat( height );
+                                float x, y, width, height;
+                                ReadRectangle (rMF, x, y, width, height, bool(flags & 0x4000));
 
-                                    polygon.append (Map (x, y));
-                                    polygon.append (Map (x + width, y));
-                                    polygon.append (Map (x + width, y + height));
-                                    polygon.append (Map (x, y + height));
+                                polygon.append (Map (x, y));
+                                polygon.append (Map (x + width, y));
+                                polygon.append (Map (x + width, y + height));
+                                polygon.append (Map (x, y + height));
+                                polygon.append (Map (x, y));
 
-                                    SAL_INFO("cppcanvas.emf", "EMF+\trectangle: " << x << ", " << width << "x" << height);
-                                }
+                                SAL_INFO("cppcanvas.emf", "EMF+\trectangle: " << x << ", " << width << "x" << height);
 
                                 ::basegfx::B2DPolyPolygon polyPolygon (polygon);
-
-                                EMFPPlusFillPolygon (polyPolygon, rFactoryParms, rState, rCanvas, isColor, brushIndexOrColor);
+                                if( type == EmfPlusRecordTypeFillRects )
+                                    EMFPPlusFillPolygon( polyPolygon,
+                                                         rFactoryParms, rState, rCanvas, isColor, brushIndexOrColor );
+                                else
+                                    EMFPPlusDrawPolygon( polyPolygon,
+                                                         rFactoryParms, rState, rCanvas, flags & 0xff );
                             }
                             break;
                         }
@@ -2507,7 +2508,7 @@ namespace cppcanvas
                         break;
                     }
                     default:
-                        SAL_INFO("cppcanvas.emf", "EMF+ unhandled record type: " << type);
+                        SAL_INFO("cppcanvas.emf", "EMF+ unhandled record type: 0x" << std::hex << type << std::dec);
                         SAL_INFO("cppcanvas.emf", "EMF+\tTODO");
                     }
                 }


More information about the Libreoffice-commits mailing list