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


Hello,

attached is a patch for libmspub that fixes a crash when converting
files with dashed lines to svg.

Greetings,
Franz Schmid
From 836d91e46d24ddf0ee4616ae5b2ae4cf2325c087 Mon Sep 17 00:00:00 2001
From: Franz Schmid <franz@linux-hp-i7.site>
Date: Wed, 17 Apr 2013 22:48:01 +0200
Subject: [PATCH] Fixed crash when converting files with dashed lines to svg.

---
 src/lib/MSPUBCollector.cpp    |    2 +-
 src/lib/MSPUBSVGGenerator.cpp |   35 +++++++++++++++++++++++------------
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/src/lib/MSPUBCollector.cpp b/src/lib/MSPUBCollector.cpp
index 895b736..4af4969 100644
--- a/src/lib/MSPUBCollector.cpp
+++ b/src/lib/MSPUBCollector.cpp
@@ -743,7 +743,7 @@ boost::function<void(void)> libmspub::MSPUBCollector::paintShape(const ShapeInfo
           graphicsProps.insert("svg:stroke-linecap", "round");
           break;
         case RECT_DOT:
-          graphicsProps.insert("svg:stroke-linecap", "rect");
+          graphicsProps.insert("svg:stroke-linecap", "butt");
           break;
         default:
           break;
diff --git a/src/lib/MSPUBSVGGenerator.cpp b/src/lib/MSPUBSVGGenerator.cpp
index 7546230..4b5482f 100644
--- a/src/lib/MSPUBSVGGenerator.cpp
+++ b/src/lib/MSPUBSVGGenerator.cpp
@@ -546,9 +546,10 @@ void libmspub::MSPUBSVGGenerator::writeStyle(bool /* isClosed */)
 {
   m_outputSink << "style=\"";
 
+  double width = 1.0 / 72.0;
   if (m_style["svg:stroke-width"])
   {
-    double width = m_style["svg:stroke-width"]->getDouble();
+    width = m_style["svg:stroke-width"]->getDouble();
     if (width == 0.0 && m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() != "none")
       width = 0.2 / 72.0; // reasonable hairline
     m_outputSink << "stroke-width: " << doubleToString(72*width) << "; ";
@@ -562,29 +563,39 @@ void libmspub::MSPUBSVGGenerator::writeStyle(bool /* isClosed */)
   }
 
   if (m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() == "solid")
-    m_outputSink << "stroke-dasharray:  solid; ";
-  else if (m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() == "dash")
+    m_outputSink << "stroke-dasharray:  none; ";
+  if (m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() == "dash")
   {
-    int dots1 = m_style["draw:dots1"]->getInt();
-    int dots2 = m_style["draw:dots2"]->getInt();
-    double dots1len = m_style["draw:dots1-length"]->getDouble();
-    double dots2len = m_style["draw:dots2-length"]->getDouble();
-    double gap = m_style["draw:distance"]->getDouble();
+    int dots1 = 0;
+    if (m_style["draw:dots1"])
+      dots1 = m_style["draw:dots1"]->getInt();
+    int dots2 = 0;
+    if (m_style["draw:dots2"])
+      dots2 = m_style["draw:dots2"]->getInt();
+    double dots1len = width * 72.0;
+    double dots2len = width * 72.0;
+    double gap = width * 72.0;
+    if (m_style["draw:dots1-length"])
+      dots1len = m_style["draw:dots1-length"]->getDouble() * 72.0;
+    if (m_style["draw:dots2-length"])
+      dots2len = m_style["draw:dots2-length"]->getDouble() * 72.0;
+    if (m_style["draw:distance"])
+      gap = m_style["draw:distance"]->getDouble() * 72.0;
     m_outputSink << "stroke-dasharray: ";
     for (int i = 0; i < dots1; i++)
     {
       if (i)
         m_outputSink << ", ";
-      m_outputSink << (int)dots1len;
+      m_outputSink << dots1len;
       m_outputSink << ", ";
-      m_outputSink << (int)gap;
+      m_outputSink << gap;
     }
     for (int j = 0; j < dots2; j++)
     {
       m_outputSink << ", ";
-      m_outputSink << (int)dots2len;
+      m_outputSink << dots2len;
       m_outputSink << ", ";
-      m_outputSink << (int)gap;
+      m_outputSink << gap;
     }
     m_outputSink << "; ";
   }
-- 
1.7.1


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.