Package list unrtf / 7b80270
Add 0008-Better-processing-of-pict-including-addition-of-EMF-type.patch patch Better processing of \pict including addition of EMF type. Fixes "unrtf 0.21 outputs hex.junk to stdout". Closes: #745195 Salvatore Bonaccorso authored 6 years ago Willi Mann committed 6 years ago
2 changed file(s) with 184 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 Description: Better processing of \pict including addition of EMF type
1 Fixes "unrtf 0.21 outputs hex.junk to stdout".
2 Origin: backport, http://hg.savannah.gnu.org/hgweb/unrtf/raw-rev/ea8512202426,
3 http://hg.savannah.gnu.org/hgweb/unrtf/raw-rev/cb5aa73f1c31
4 Bug-Debian: https://bugs.debian.org/745195
5 Forwarded: not-needed
6 Author: Salvatore Bonaccorso <carnil@debian.org>
7 Last-Update: 2015-01-26
8 Applied-Upstream: 0.21.8
9
10 --- a/src/convert.c
11 +++ b/src/convert.c
12 @@ -163,8 +163,10 @@ enum {
13 PICT_WB,
14 PICT_JPEG,
15 PICT_PNG,
16 + PICT_EMF,
17 };
18 static int within_picture=FALSE;
19 +static int within_picture_depth;
20 static int picture_file_number=1;
21 static char picture_path[255];
22 static int picture_width;
23 @@ -2342,12 +2344,30 @@ static int cmd_maybe_ignore (Word *w, in
24 s = word_string(w->next);
25 if(s && strcmp(s, "\\shppict") == 0)
26 return(FALSE);
27 + if(s && strcmp(s, "\\blipuid") == 0)
28 + return(FALSE);
29 + if(s && strcmp(s, "\\picprop") == 0)
30 + return(FALSE);
31 }
32
33 return TRUE;
34 }
35
36 /*========================================================================
37 + * Name: cmd_blipuid
38 + * Purpose: Dummy function to get rid of uid
39 + * Args: Word, paragraph align info, and numeric param if any.
40 + * Returns: Flag, true only if rest of Words on line should be ignored.
41 + *=======================================================================*/
42 +
43 +static int cmd_blipuid (Word *w, int align, char has_param, int param)
44 +{
45 + char *s;
46 + CHECK_PARAM_NOT_NULL (w);
47 + return TRUE;
48 +}
49 +
50 +/*========================================================================
51 * Name: cmd_info
52 * Purpose: Executes the \info command.
53 * Args: Word, paragraph align info, and numeric param if any.
54 @@ -2373,6 +2393,18 @@ static int cmd_pict (Word *w, int align,
55 picture_type = PICT_WB;
56 return FALSE;
57 }
58 +/*========================================================================
59 + * Name: cmd_picprop
60 + * Purpose: Executes the \picprop
61 + * Args: Word, paragraph align info, and numeric param if any.
62 + * Returns: Flag, true only if rest of Words on line should be ignored.
63 + *=======================================================================*/
64 +
65 +static int cmd_picprop (Word *w, int align, char has_param, int param)
66 +{
67 + return TRUE;
68 +}
69 +
70
71 /*========================================================================
72 * Name: cmd_bin
73 @@ -2423,6 +2455,18 @@ static int cmd_pngblip (Word *w, int ali
74 }
75
76 /*========================================================================
77 + * Name: cmd_emfblip
78 + * Purpose: Executes the \emfblip command.
79 + * Args: Word, paragraph align info, and numeric param if any.
80 + * Returns: Flag, true only if rest of Words on line should be ignored.
81 + *=======================================================================*/
82 +
83 +static int cmd_emfblip (Word *w, int align, char has_param, int param) {
84 + picture_type = PICT_EMF;
85 + return FALSE;
86 +}
87 +
88 +/*========================================================================
89 * Name: cmd_pnmetafile
90 * Purpose: Executes the \pnmetafile command.
91 * Args: Word, paragraph align info, and numeric param if any.
92 @@ -2572,6 +2616,7 @@ static HashItem hashArray_b [] = {
93 { "b", &cmd_b, NULL },
94 { "bullet", &cmd_bullet, NULL },
95 { "bin", &cmd_bin, "picture is binary" },
96 + { "blipuid", &cmd_blipuid, NULL },
97 #if 0
98 { "bgbdiag", NULL, NULL },
99 { "bgcross", NULL, NULL },
100 @@ -2645,6 +2690,7 @@ static HashItem hashArray_e [] = {
101 { "embo", &cmd_emboss, NULL },
102 { "expand", &cmd_expand, NULL },
103 { "expnd", &cmd_expand, NULL },
104 + { "emfblip", &cmd_emfblip, NULL },
105 { NULL, NULL, NULL}
106 };
107 static HashItem hashArray_f [] = {
108 @@ -2713,10 +2759,12 @@ static HashItem hashArray_p [] = {
109 { "pca", &cmd_pca , NULL },
110 { "pich", &cmd_pich, NULL },
111 { "pict", &cmd_pict, "picture" },
112 + { "picprop", &cmd_picprop, "picture properties" },
113 { "picw", &cmd_picw, NULL },
114 { "plain", &cmd_plain, NULL },
115 { "pngblip", &cmd_pngblip, NULL },
116 { "pnmetafile", &cmd_pnmetafile, NULL },
117 + { "emfblip", &cmd_emfblip, NULL },
118 #if 0
119 { "piccropb", NULL, NULL },
120 { "piccropl", NULL, NULL },
121 @@ -3172,7 +3220,10 @@ word_print_core (Word *w, int groupdepth
122 }
123
124 /*----------------------------------------*/
125 - if (within_picture) {
126 + if (within_picture)
127 + {
128 + if (within_picture_depth == 0)
129 + within_picture_depth = groupdepth;
130 starting_body();
131 if (!pictfile && !nopict_mode) {
132 char *ext=NULL;
133 @@ -3184,6 +3235,7 @@ word_print_core (Word *w, int groupdepth
134 case PICT_PNG: ext="png"; break;
135 case PICT_DI: ext="dib"; break; /* Device independent bitmap=??? */
136 case PICT_PM: ext="pmm"; break; /* OS/2 metafile=??? */
137 + case PICT_EMF: ext="emf"; break; /* Enhanced MetaFile */
138 }
139 sprintf(picture_path, "pict%03d.%s",
140 picture_file_number++,ext);
141 @@ -3434,8 +3486,11 @@ word_print_core (Word *w, int groupdepth
142 w = w->next;
143 }
144
145 - if (within_picture) {
146 - if(pictfile) {
147 + if (within_picture && within_picture_depth == groupdepth)
148 + {
149 + within_picture_depth = 0;
150 + if(pictfile)
151 + {
152 fclose(pictfile);
153 if (safe_printf(0, op->imagelink_begin)) fprintf(stderr, TOO_MANY_ARGS, "imagelink_begin");
154 printf("%s", picture_path);
155 @@ -3490,14 +3545,9 @@ word_print (Word *w)
156 CHECK_PARAM_NOT_NULL (w);
157
158 if (!inline_mode) {
159 -#if 1 /* AK3 - AF */
160 if (safe_printf(0, op->document_begin)) fprintf(stderr, TOO_MANY_ARGS, "document_begin");
161 if (safe_printf(0, op->header_begin)) fprintf(stderr, TOO_MANY_ARGS, "header_begin");
162 if (safe_printf(0, op->utf8_encoding)) fprintf(stderr, TOO_MANY_ARGS, "utf8_encoding");
163 -#else
164 - printf(op->document_begin);
165 - printf(op->header_begin);
166 -#endif
167 }
168
169 print_banner ();
170 @@ -3510,12 +3560,7 @@ word_print (Word *w)
171 end_table();
172
173 if (!inline_mode) {
174 -#if 1 /* AK3 - AF */
175 if (safe_printf(0, op->body_end)) fprintf(stderr, TOO_MANY_ARGS, "body_end");
176 if (safe_printf(0, op->document_end)) fprintf(stderr, TOO_MANY_ARGS, "document_end");
177 -#else
178 - printf(op->body_end);
179 - printf(op->document_end);
180 -#endif
181 }
182 }
44 0005-attr_get_param-Silence-a-warning-message-again.patch
55 0006-Limit-depth-of-group-embedding.patch
66 0007-Improved-image-file-handling.patch
7 0008-Better-processing-of-pict-including-addition-of-EMF-type.patch