Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hi all,

Please find attached a partial patch to import line marker shapes from Visio files. I would appreciate a review to confirm whether I am on the right path or whether I should do something different.

Thanks,

Bruno

From cf68600551d3a1d88c7daaa9f2dc8f09afdb7481 Mon Sep 17 00:00:00 2001
From: Bruno Girin <brunogirin@gmail.com>
Date: Mon, 30 Jan 2012 23:31:47 +0000
Subject: [PATCH] Partial patch for fdo#44551

---
 src/lib/VSDXContentCollector.cpp |   52 +++++++++++++++++++++++++++++++++----
 src/lib/VSDXContentCollector.h   |    3 ++
 2 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/src/lib/VSDXContentCollector.cpp b/src/lib/VSDXContentCollector.cpp
index 2a4b36f..ee0fff0 100644
--- a/src/lib/VSDXContentCollector.cpp
+++ b/src/lib/VSDXContentCollector.cpp
@@ -451,15 +451,55 @@ void libvisio::VSDXContentCollector::_lineProperties(double strokeWidth, 
Colour
   // Deal with line markers (arrows, etc.)
   if (startMarker > 0)
   {
-    m_styleProps.insert("draw:marker-start-viewbox", "0 0 20 30");
-    m_styleProps.insert("draw:marker-start-path", "m10 0-10 30h20z");
-    m_styleProps.insert("draw:marker-start-width", 
m_scale*(0.1/(strokeWidth*strokeWidth+1)+2.54*strokeWidth));
+    m_styleProps.insert("draw:marker-start-viewbox", _linePropertiesMarkerViewbox(startMarker));
+    m_styleProps.insert("draw:marker-start-path", _linePropertiesMarkerPath(startMarker));
+    m_styleProps.insert("draw:marker-start-width", 
m_scale*(0.1/(strokeWidth*strokeWidth+1)+_linePropertiesMarkerWidth(startMarker)*strokeWidth));
   }
   if (endMarker > 0)
   {
-    m_styleProps.insert("draw:marker-end-viewbox", "0 0 20 30");
-    m_styleProps.insert("draw:marker-end-path", "m10 0-10 30h20z");
-    m_styleProps.insert("draw:marker-end-width", 
m_scale*(0.1/(strokeWidth*strokeWidth+1)+2.54*strokeWidth));
+    m_styleProps.insert("draw:marker-end-viewbox", _linePropertiesMarkerViewbox(endMarker));
+    m_styleProps.insert("draw:marker-end-path", _linePropertiesMarkerPath(endMarker));
+    m_styleProps.insert("draw:marker-end-width", 
m_scale*(0.1/(strokeWidth*strokeWidth+1)+_linePropertiesMarkerWidth(endMarker)*strokeWidth));
+  }
+}
+
+const char *libvisio::VSDXContentCollector::_linePropertiesMarkerViewbox(unsigned marker)
+{
+  switch (marker)
+  {
+    case 2:
+      return "0 0 20 10";
+    case 4:
+    case 11:
+      return "0 0 20 20";
+    default:
+      return "0 0 20 30";
+  }
+}
+
+const char *libvisio::VSDXContentCollector::_linePropertiesMarkerPath(unsigned marker)
+{
+  switch (marker)
+  {
+    case 2:
+      return "m10 0-10 10h20z";
+    case 4:
+      return "m10 0-10 20h20z";
+    case 11:
+      return "m0 0l10 0l0 10l-10 0z";
+    default:
+      return "m10 0-10 30h20z";
+  }
+}
+
+double libvisio::VSDXContentCollector::_linePropertiesMarkerWidth(unsigned marker)
+{
+  switch (marker)
+  {
+    case 11:
+      return 1.27;
+    default:
+      return 2.54;
   }
 }
 
diff --git a/src/lib/VSDXContentCollector.h b/src/lib/VSDXContentCollector.h
index bfd362e..9261e60 100644
--- a/src/lib/VSDXContentCollector.h
+++ b/src/lib/VSDXContentCollector.h
@@ -173,6 +173,9 @@ private:
 
   void _applyLinePattern();
   void _lineProperties(double strokeWidth, Colour c, unsigned linePattern, unsigned startMarker, 
unsigned endMarker, unsigned lineCap);
+  const char *_linePropertiesMarkerViewbox(unsigned marker);
+  const char *_linePropertiesMarkerPath(unsigned marker);
+  double _linePropertiesMarkerWidth(unsigned marker);
   void _fillAndShadowProperties(unsigned colourIndexFG, unsigned colourIndexBG, unsigned 
fillPattern,
                                 unsigned fillFGTransparency, unsigned fillBGTransparency,
                                 unsigned shadowPattern, Colour shfgc, double shadowOffsetX, double 
shadowOffsetY);
-- 
1.7.5.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.