[Libreoffice-commits] core.git: drawinglayer/source

Patrick Jaap patrick.jaap at tu-dresden.de
Fri Aug 4 07:20:08 UTC 2017


 drawinglayer/source/tools/emfphelperdata.cxx |   28 +++++++++++++++++++++++----
 drawinglayer/source/tools/emfppen.cxx        |    4 ++-
 drawinglayer/source/tools/emfppen.hxx        |    2 +
 3 files changed, 29 insertions(+), 5 deletions(-)

New commits:
commit a3926e25bb0a9c79e3ea1f413b8fa83b91915758
Author: Patrick Jaap <patrick.jaap at tu-dresden.de>
Date:   Tue Aug 1 16:24:01 2017 +0200

    new EMF+ parser: EMFPPlusDrawPolygon: use correct pen width
    
    the current implementation uses PolyPolygonHairlinePrimitive2D for
    polygons. This patch uses a PolyPolygonStrokePrimitive2D which makes
    use of the correct (transformed) pen width and some basic join and cap
    attributes.
    
    Change-Id: Ifbd8cbbc41004d9d45f3c48f2c13fe449025a229
    Reviewed-on: https://gerrit.libreoffice.org/40638
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Armin Le Grand <Armin.Le.Grand at cib.de>

diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx
index a648117982ff..d7919234842f 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -331,10 +331,30 @@ namespace emfplushelper
 
         if (pen && polygon.count())
         {
-            mrTargetHolders.Current().append(
-                new drawinglayer::primitive2d::PolyPolygonHairlinePrimitive2D(
-                    polygon,
-                    pen->GetColor().getBColor()));
+          // we need a line join attribute
+          basegfx::B2DLineJoin lineJoin = basegfx::B2DLineJoin::Round;
+          if (pen->penDataFlags & 0x00000008) // additional line join information
+          {
+            lineJoin = static_cast<basegfx::B2DLineJoin>(EMFPPen::lcl_convertLineJoinType(pen->lineJoin));
+          }
+
+          // we need a line cap attribute
+          css::drawing::LineCap lineCap = css::drawing::LineCap_BUTT;
+          if (pen->penDataFlags & 0x00000002) // additional line cap information
+          {
+            lineCap = static_cast<css::drawing::LineCap>(EMFPPen::lcl_convertStrokeCap(pen->startCap));
+            SAL_WARN_IF(pen->startCap != pen->endCap, "cppcanvas.emf", "emf+ pen uses different start and end cap");
+          }
+          // transform the pen width
+          const double transformedPenWidth = MapSize(pen->penWidth, 0).getX();
+          drawinglayer::attribute::LineAttribute lineAttribute(pen->GetColor().getBColor(),
+                                                               transformedPenWidth,
+                                                               lineJoin,
+                                                               lineCap);
+          mrTargetHolders.Current().append(
+              new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(
+                  polygon,
+                  lineAttribute));
         }
     }
 
diff --git a/drawinglayer/source/tools/emfppen.cxx b/drawinglayer/source/tools/emfppen.cxx
index 9bc66e6716af..1905b8cb6f48 100644
--- a/drawinglayer/source/tools/emfppen.cxx
+++ b/drawinglayer/source/tools/emfppen.cxx
@@ -69,6 +69,8 @@ namespace emfplushelper
 
     EMFPPen::EMFPPen()
         : EMFPBrush()
+        , penDataFlags(0)
+        , penUnit(0)
         , penWidth(0.0)
         , startCap(0)
         , endCap(0)
@@ -169,7 +171,7 @@ namespace emfplushelper
 
     void EMFPPen::Read(SvStream& s, EmfPlusHelperData& rR)
     {
-        sal_uInt32 graphicsVersion, penType, penDataFlags, penUnit;
+        sal_uInt32 graphicsVersion, penType;
         int i;
         s.ReadUInt32(graphicsVersion).ReadUInt32(penType).ReadUInt32(penDataFlags).ReadUInt32(penUnit).ReadFloat(penWidth);
         SAL_INFO("cppcanvas.emf", "EMF+\tpen");
diff --git a/drawinglayer/source/tools/emfppen.hxx b/drawinglayer/source/tools/emfppen.hxx
index c338fef62029..7b8f67d41d87 100644
--- a/drawinglayer/source/tools/emfppen.hxx
+++ b/drawinglayer/source/tools/emfppen.hxx
@@ -39,6 +39,8 @@ namespace emfplushelper
     struct EMFPPen : public EMFPBrush
     {
         basegfx::B2DHomMatrix pen_transformation;   //TODO: This isn't used
+        sal_uInt32 penDataFlags;
+        sal_uInt32 penUnit;
         float penWidth;
         sal_Int32 startCap;
         sal_Int32 endCap;


More information about the Libreoffice-commits mailing list