summaryrefslogtreecommitdiff
path: root/libvisio/libvisio-0.0.19.patch
blob: ee3c17f51af2b0851ef868f72d3b90210892f24c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
--- src/lib/VSDXContentCollector.cpp
+++ src/lib/VSDXContentCollector.cpp
@@ -676,7 +676,6 @@ double libvisio::VSDXContentCollector::_linePropertiesMarkerScale(unsigned marke
 
 void libvisio::VSDXContentCollector::_flushCurrentPath()
 {
-  WPXPropertyListVector path;
   WPXPropertyList fillPathProps(m_styleProps);
   fillPathProps.insert("draw:stroke", "none");
   WPXPropertyList linePathProps(m_styleProps);
@@ -695,6 +694,7 @@ void libvisio::VSDXContentCollector::_flushCurrentPath()
   if (needsGroup)
     m_shapeOutputDrawing->addStartLayer(WPXPropertyList());
 
+  std::vector<WPXPropertyList> tmpPath;
   if (m_styleProps["draw:fill"] && m_styleProps["draw:fill"]->getStr() != "none")
   {
     bool firstPoint = true;
@@ -708,39 +708,84 @@ void libvisio::VSDXContentCollector::_flushCurrentPath()
       }
       else if (m_currentFillGeometry[i]["libwpg:path-action"]->getStr() == "M")
       {
-        if (path.count() && !wasMove)
+        if (!tmpPath.empty())
         {
-          WPXPropertyList closedPath;
-          closedPath.insert("libwpg:path-action", "Z");
-          path.append(closedPath);
+          if (!wasMove)
+          {
+            WPXPropertyList closedPath;
+            closedPath.insert("libwpg:path-action", "Z");
+            tmpPath.push_back(closedPath);
+          }
+          else
+          {
+            tmpPath.pop_back();
+          }
         }
         wasMove = true;
       }
       else
         wasMove = false;
-      path.append(m_currentFillGeometry[i]);
+      tmpPath.push_back(m_currentFillGeometry[i]);
     }
-    if (path.count() && !wasMove)
+    if (!tmpPath.empty())
     {
-      WPXPropertyList closedPath;
-      closedPath.insert("libwpg:path-action", "Z");
-      path.append(closedPath);
+      if (!wasMove)
+      {
+        WPXPropertyList closedPath;
+        closedPath.insert("libwpg:path-action", "Z");
+        tmpPath.push_back(closedPath);
+      }
+      else
+        tmpPath.pop_back();
     }
-    if (path.count())
+    if (!tmpPath.empty())
     {
+      WPXPropertyListVector path;
+      for (unsigned i = 0; i < tmpPath.size(); ++i)
+        path.append(tmpPath[i]);
       m_shapeOutputDrawing->addStyle(fillPathProps, WPXPropertyListVector());
       m_shapeOutputDrawing->addPath(path);
     }
   }
   m_currentFillGeometry.clear();
-  path = WPXPropertyListVector();
+  tmpPath.clear();
 
   if (m_styleProps["draw:stroke"] && m_styleProps["draw:stroke"]->getStr() != "none")
   {
+    bool firstPoint = true;
+    bool wasMove = false;
     for (unsigned i = 0; i < m_currentLineGeometry.size(); i++)
-      path.append(m_currentLineGeometry[i]);
-    if (path.count())
     {
+      if (firstPoint)
+      {
+        firstPoint = false;
+        wasMove = true;
+      }
+      else if (m_currentLineGeometry[i]["libwpg:path-action"]->getStr() == "M")
+      {
+        if (!tmpPath.empty())
+        {
+          if (wasMove)
+          {
+            tmpPath.pop_back();
+          }
+        }
+        wasMove = true;
+      }
+      else
+        wasMove = false;
+      tmpPath.push_back(m_currentLineGeometry[i]);
+    }
+    if (!tmpPath.empty())
+    {
+      if (wasMove)
+        tmpPath.pop_back();
+    }
+    if (!tmpPath.empty())
+    {
+      WPXPropertyListVector path;
+      for (unsigned i = 0; i < tmpPath.size(); ++i)
+        path.append(tmpPath[i]);
       m_shapeOutputDrawing->addStyle(linePathProps, WPXPropertyListVector());
       m_shapeOutputDrawing->addPath(path);
     }