summaryrefslogtreecommitdiff
path: root/graphics/dia/patches/0018-Bug-683700-vdx-full-of-errors.patch
blob: 550bc6226295e25a63ffed59501237b4a6d9b264 (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
From 61431fec37ed855db7284c6737cb3777577cc904 Mon Sep 17 00:00:00 2001
From: Hans Breuer <hans@breuer.org>
Date: Fri, 16 Aug 2013 20:54:12 +0200
Subject: [PATCH 18/24] Bug 683700 - vdx full of errors

Ensure message_error strings are linefeed-terminated.
Plus fixes merged from master:

cairo: don't screw cairo's matrix by scaling with 0
Seen with the VDX attached to bug 683700 - maybe there is also something wrong with the import?

vdx: UTF-8 safe variant to remove last newline
With the VDX attached to bug 683700 scrambled text appeared. Now corrected with the UTF-8 safe variant to search and replace "\n".
---
 plug-ins/cairo/diacairo-renderer.c | 23 ++++++-----------------
 plug-ins/vdx/vdx-import.c          | 21 +++++++++++++++++++--
 plug-ins/vdx/vdx-xml.c             |  2 +-
 3 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/plug-ins/cairo/diacairo-renderer.c b/plug-ins/cairo/diacairo-renderer.c
index 137411e..57f6184 100644
--- a/plug-ins/cairo/diacairo-renderer.c
+++ b/plug-ins/cairo/diacairo-renderer.c
@@ -572,9 +572,14 @@ _ellipse(DiaRenderer *self,
   DIAG_NOTE(g_message("%s_ellipse %fx%f center @ %f,%f", 
             fill ? "fill" : "draw", width, height, center->x, center->y));
 
+  /* avoid screwing cairo context - I'd say restore should fix it again, but it doesn't
+   * (dia.exe:3152): DiaCairo-WARNING **: diacairo-renderer.c:254, invalid matrix (not invertible)
+   */
+  if (!(width > 0. && height > 0.))
+    return;
+
   cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
   
-#if 1
   cairo_save (renderer->cr);
   /* don't create a line from the current point to the beginning 
    * of the ellipse */
@@ -584,22 +589,6 @@ _ellipse(DiaRenderer *self,
   cairo_scale (renderer->cr, width / 2., height / 2.);
   cairo_arc (renderer->cr, 0., 0., 1., 0., 2 * G_PI);
   cairo_restore (renderer->cr);
-#else
-  /* FIXME: how to make a perfect ellipse from a bezier ? */
-  co = sqrt(pow(width,2)/4 + pow(height,2)/4);
-
-  cairo_new_path (renderer->cr);
-  cairo_move_to (renderer->cr,
-                 center->x, center->y - height/2);
-  cairo_curve_to (renderer->cr,
-                  center->x + co, center->y - height/2,
-                  center->x + co, center->y + height/2,
-                  center->x, center->y + height/2);
-  cairo_curve_to (renderer->cr,
-                  center->x - co, center->y + height/2,
-                  center->x - co, center->y - height/2,
-                  center->x, center->y - height/2);
-#endif
 
   if (fill)
     cairo_fill (renderer->cr);
diff --git a/plug-ins/vdx/vdx-import.c b/plug-ins/vdx/vdx-import.c
index ffefa58..7da0c05 100644
--- a/plug-ins/vdx/vdx-import.c
+++ b/plug-ins/vdx/vdx-import.c
@@ -1737,7 +1737,7 @@ plot_nurbs(const struct vdx_Geom *Geom, const struct vdx_XForm *XForm,
         }
         if (n % 4 || ! n)
         {
-            message_error(_("Invalid NURBS formula"));
+            message_error(_("Invalid NURBS formula\n"));
             g_debug("Invalid NURBS formula");
             return 0;
         }
@@ -2066,7 +2066,7 @@ plot_image(const struct vdx_Geom *Geom, const struct vdx_XForm *XForm,
         }
         else
         {
-            message_error(_("Couldn't handle foreign object type %s"),
+            message_error(_("Couldn't handle foreign object type %s\n"),
                           ForeignData->ForeignType ? ForeignData->ForeignType
                           : "Unknown");
             return 0;
@@ -2398,12 +2398,29 @@ plot_text(const struct vdx_Text *Text, const struct vdx_XForm *XForm,
         }
     }
 
+#if 0 /* this is not utf-8 safe - see bug 683700 */ 
     /* Remove trailing line breaks */
     while (tprop->text_data[0] &&
            isspace(tprop->text_data[strlen(tprop->text_data)-1]))
     {
         tprop->text_data[strlen(tprop->text_data)-1] = 0;
     }
+#else
+    {
+        char *s = tprop->text_data;
+        char *srep = NULL;
+        while ( (s = g_utf8_strchr(s, -1, '\n')) != NULL ) {
+            srep = s;
+            s = g_utf8_next_char(s);
+            if (*s)
+                srep = NULL;
+            else
+                break;
+        }
+        if (srep)
+            *srep = '\0';
+    }
+#endif
 
     /* Other standard text properties */
     tprop->attr.alignment = alignment;
diff --git a/plug-ins/vdx/vdx-xml.c b/plug-ins/vdx/vdx-xml.c
index 1fdac65..1c9567d 100644
--- a/plug-ins/vdx/vdx-xml.c
+++ b/plug-ins/vdx/vdx-xml.c
@@ -3341,7 +3341,7 @@ vdx_read_object(xmlNodePtr cur, VDXDocument *theDoc, void *p)
         return s;
     }
 
-    message_error(_("Can't decode object %s"), (char*)cur->name);
+    message_error(_("Can't decode object %s\n"), (char*)cur->name);
     return 0;
 }
 
-- 
1.8.4.4