/[public]/psiconv/trunk/lib/psiconv/generate_layout.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/generate_layout.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 76 Revision 78
132 132
133int psiconv_write_paragraph_layout_list(psiconv_buffer buf, 133int psiconv_write_paragraph_layout_list(psiconv_buffer buf,
134 psiconv_paragraph_layout value, 134 psiconv_paragraph_layout value,
135 psiconv_paragraph_layout base) 135 psiconv_paragraph_layout base)
136{ 136{
137 int res,i,tabs_different; 137 int res,i;
138 psiconv_buffer extra_buf; 138 psiconv_buffer extra_buf;
139 psiconv_tab value_tab,base_tab; 139 psiconv_tab tab;
140 140
141 if (!value) { 141 if (!value) {
142 psiconv_warn(0,psiconv_list_length(buf),"Null paragraph layout list"); 142 psiconv_warn(0,psiconv_list_length(buf),"Null paragraph layout list");
143 return -PSICONV_E_GENERATE; 143 return -PSICONV_E_GENERATE;
144 } 144 }
145 if (!(extra_buf = psiconv_new_buffer())) 145 if (!(extra_buf = psiconv_new_buffer()))
146 return -PSICONV_E_NOMEM; 146 return -PSICONV_E_NOMEM;
147 147
148 if (!base || !base->back_color || !value->back_color || 148 if (!base || psiconv_compare_color(base->back_color,value->back_color)) {
149 (value->back_color->red != base->back_color->red) ||
150 (value->back_color->green != base->back_color->green) ||
151 (value->back_color->blue != base->back_color->blue)) {
152 if ((res = psiconv_write_u8(extra_buf,0x01))) 149 if ((res = psiconv_write_u8(extra_buf,0x01)))
153 goto ERROR; 150 goto ERROR;
154 if ((res = psiconv_write_color(extra_buf,value->back_color))) 151 if ((res = psiconv_write_color(extra_buf,value->back_color)))
155 goto ERROR; 152 goto ERROR;
156 } 153 }
266 goto ERROR; 263 goto ERROR;
267 if ((res = psiconv_write_length(extra_buf,value->border_distance))) 264 if ((res = psiconv_write_length(extra_buf,value->border_distance)))
268 goto ERROR; 265 goto ERROR;
269 } 266 }
270 267
271 if (!base || !value->top_border || !base->top_border || 268 if (!base || psiconv_compare_border(value->top_border,base->top_border)) {
272 !value->top_border->color || !base->top_border->color ||
273 (value->top_border->kind != base->top_border->kind) ||
274 (value->top_border->thickness != base->top_border->thickness) ||
275 (value->top_border->color->red != base->top_border->color->red) ||
276 (value->top_border->color->green != base->top_border->color->green) ||
277 (value->top_border->color->blue != base->top_border->color->blue)) {
278 if ((res = psiconv_write_u8(extra_buf,0x11))) 269 if ((res = psiconv_write_u8(extra_buf,0x11)))
279 goto ERROR; 270 goto ERROR;
280 if ((res = psiconv_write_border(extra_buf,value->top_border))) 271 if ((res = psiconv_write_border(extra_buf,value->top_border)))
281 goto ERROR; 272 goto ERROR;
282 } 273 }
283 274
284 if (!base || !value->top_border || !base->top_border || 275 if (!base || psiconv_compare_border(value->bottom_border,
285 !value->top_border->color || !base->top_border->color || 276 base->bottom_border)) {
286 (value->top_border->kind != base->top_border->kind) ||
287 (value->top_border->thickness != base->top_border->thickness) ||
288 (value->top_border->color->red != base->top_border->color->red) ||
289 (value->top_border->color->green != base->top_border->color->green) ||
290 (value->top_border->color->blue != base->top_border->color->blue)) {
291 if ((res = psiconv_write_u8(extra_buf,0x12))) 277 if ((res = psiconv_write_u8(extra_buf,0x12)))
292 goto ERROR; 278 goto ERROR;
293 if ((res = psiconv_write_border(extra_buf,value->top_border))) 279 if ((res = psiconv_write_border(extra_buf,value->bottom_border)))
294 goto ERROR; 280 goto ERROR;
295 } 281 }
296 282
297 if (!base || !value->left_border || !base->left_border || 283 if (!base || psiconv_compare_border(value->left_border,
298 !value->left_border->color || !base->left_border->color || 284 base->left_border)) {
299 (value->left_border->kind != base->left_border->kind) ||
300 (value->left_border->thickness != base->left_border->thickness) ||
301 (value->left_border->color->red != base->left_border->color->red) ||
302 (value->left_border->color->green != base->left_border->color->green) ||
303 (value->left_border->color->blue != base->left_border->color->blue)) {
304 if ((res = psiconv_write_u8(extra_buf,0x13))) 285 if ((res = psiconv_write_u8(extra_buf,0x13)))
305 goto ERROR; 286 goto ERROR;
306 if ((res = psiconv_write_border(extra_buf,value->left_border))) 287 if ((res = psiconv_write_border(extra_buf,value->left_border)))
307 goto ERROR; 288 goto ERROR;
308 } 289 }
309 290
310 if (!base || !value->right_border || !base->right_border || 291 if (!base || psiconv_compare_border(value->right_border,
311 !value->right_border->color || !base->right_border->color ||
312 (value->right_border->kind != base->right_border->kind) ||
313 (value->right_border->thickness != base->right_border->thickness) ||
314 (value->right_border->color->red != base->right_border->color->red) ||
315 (value->right_border->color->green !=
316 base->right_border->color->green) || 292 base->right_border)) {
317 (value->right_border->color->blue != base->right_border->color->blue)) {
318 if ((res = psiconv_write_u8(extra_buf,0x14))) 293 if ((res = psiconv_write_u8(extra_buf,0x14)))
319 goto ERROR; 294 goto ERROR;
320 if ((res = psiconv_write_border(extra_buf,value->right_border))) 295 if ((res = psiconv_write_border(extra_buf,value->right_border)))
321 goto ERROR; 296 goto ERROR;
322 } 297 }
323 298
324 if (!base || !value->bullet || !base->bullet || 299 if (!base || psiconv_compare_bullet(value->bullet,
325 !value->bullet->color || !base->bullet->color || 300 base->bullet)) {
326 !value->bullet->font || !base->bullet->font ||
327 !value->bullet->font->name || !base->bullet->font->name ||
328 (value->bullet->on != base->bullet->on) ||
329 (value->bullet->font_size != base->bullet->font_size) ||
330 (value->bullet->character != base->bullet->character) ||
331 (value->bullet->indent != base->bullet->indent) ||
332 (value->bullet->color->red != base->bullet->color->red) ||
333 (value->bullet->color->green != base->bullet->color->green) ||
334 (value->bullet->color->blue != base->bullet->color->blue) ||
335 (value->bullet->font->screenfont != base->bullet->font->screenfont) ||
336 strcmp(value->bullet->font->name,base->bullet->font->name)) {
337 if ((res = psiconv_write_u8(extra_buf,0x15))) 301 if ((res = psiconv_write_u8(extra_buf,0x15)))
338 goto ERROR; 302 goto ERROR;
339 if ((res = psiconv_write_bullet(extra_buf,value->bullet))) 303 if ((res = psiconv_write_bullet(extra_buf,value->bullet)))
340 goto ERROR; 304 goto ERROR;
341 } 305 }
343 if (!value->tabs || !value->tabs->extras) { 307 if (!value->tabs || !value->tabs->extras) {
344 psiconv_warn(0,psiconv_list_length(buf),"Null tabs"); 308 psiconv_warn(0,psiconv_list_length(buf),"Null tabs");
345 res = -PSICONV_E_GENERATE; 309 res = -PSICONV_E_GENERATE;
346 goto ERROR; 310 goto ERROR;
347 } 311 }
312
348 /* It is not entirely clear how tabs are inherited. For now, I assume 313 /* It is not entirely clear how tabs are inherited. For now, I assume
349 if there is any difference at all, we will have to generate both 314 if there is any difference at all, we will have to generate both
350 the normal tab-interval, and all specific tabs */ 315 the normal tab-interval, and all specific tabs */
351 tabs_different = 0; 316 if (!base || psiconv_compare_all_tabs(value->tabs,base->tabs)) {
352 if (!base || !base->tabs || !base->tabs->extras || 317 if ((res = psiconv_write_u8(extra_buf,0x16)))
353 (value->tabs->normal != base->tabs->normal) || 318 goto ERROR;
354 (psiconv_list_length(value->tabs->extras) != 319 if ((res = psiconv_write_length(extra_buf,value->tabs->normal)))
355 psiconv_list_length(base->tabs->extras))) 320 goto ERROR;
356 tabs_different = 1;
357 else {
358 for (i = 0; i < psiconv_list_length(value->tabs->extras); i++) { 321 for (i = 0; i < psiconv_list_length(value->tabs->extras); i++) {
359 value_tab = psiconv_list_get(value->tabs->extras,i);
360 base_tab = psiconv_list_get(base->tabs->extras,i);
361 if (!value_tab || !base_tab) {
362 psiconv_warn(0,psiconv_list_length(buf),"Massive memory corruption");
363 res = -PSICONV_E_NOMEM;
364 goto ERROR;
365 }
366 if ((value_tab->kind != base_tab->kind) ||
367 (value_tab->location != base_tab->location)) {
368 tabs_different = 1;
369 break;
370 }
371 }
372 }
373
374 if (tabs_different) {
375 if ((res = psiconv_write_u8(extra_buf,0x16)))
376 goto ERROR;
377 if ((res = psiconv_write_length(extra_buf,value->tabs->normal)))
378 goto ERROR;
379 for (i = 0; i < psiconv_list_length(value->tabs->extras); i++) {
380 if (!(value_tab = psiconv_list_get(value->tabs->extras,i))) { 322 if (!(tab = psiconv_list_get(value->tabs->extras,i))) {
381 psiconv_warn(0,psiconv_list_length(buf),"Massive memory corruption"); 323 psiconv_warn(0,psiconv_list_length(buf),"Massive memory corruption");
382 res = -PSICONV_E_NOMEM; 324 res = -PSICONV_E_NOMEM;
383 goto ERROR; 325 goto ERROR;
384 } 326 }
385 if ((res = psiconv_write_u8(extra_buf,0x17))) 327 if ((res = psiconv_write_u8(extra_buf,0x17)))
386 goto ERROR; 328 goto ERROR;
387 if ((res = psiconv_write_tab(extra_buf,value_tab))) 329 if ((res = psiconv_write_tab(extra_buf,tab)))
388 goto ERROR; 330 goto ERROR;
389 } 331 }
390 } 332 }
391 333
392 if ((res = psiconv_write_u32(buf,psiconv_list_length(extra_buf)))) 334 if ((res = psiconv_write_u32(buf,psiconv_list_length(extra_buf))))
410 return -PSICONV_E_GENERATE; 352 return -PSICONV_E_GENERATE;
411 } 353 }
412 if (!(extra_buf = psiconv_new_buffer())) 354 if (!(extra_buf = psiconv_new_buffer()))
413 return -PSICONV_E_NOMEM; 355 return -PSICONV_E_NOMEM;
414 356
415 if (!base || !base->color || !value->color || 357 if (!base || psiconv_compare_color(base->color,value->color)) {
416 (value->color->red != base->color->red) ||
417 (value->color->green != base->color->green) ||
418 (value->color->blue != base->color->blue)) {
419 if ((res = psiconv_write_u8(extra_buf,0x19))) 358 if ((res = psiconv_write_u8(extra_buf,0x19)))
420 goto ERROR; 359 goto ERROR;
421 if ((res = psiconv_write_color(extra_buf,value->color))) 360 if ((res = psiconv_write_color(extra_buf,value->color)))
422 goto ERROR; 361 goto ERROR;
423 } 362 }
424 363
425 if (!base || !base->back_color || !value->back_color || 364 if (!base || psiconv_compare_color(base->back_color,value->back_color)) {
426 (value->back_color->red != base->back_color->red) ||
427 (value->back_color->green != base->back_color->green) ||
428 (value->back_color->blue != base->back_color->blue)) {
429 if ((res = psiconv_write_u8(extra_buf,0x1a))) 365 if ((res = psiconv_write_u8(extra_buf,0x1a)))
430 goto ERROR; 366 goto ERROR;
431 if ((res = psiconv_write_color(extra_buf,value->back_color))) 367 if ((res = psiconv_write_color(extra_buf,value->back_color)))
432 goto ERROR; 368 goto ERROR;
433 } 369 }
480 goto ERROR; 416 goto ERROR;
481 if ((res = psiconv_write_bool(extra_buf,value->strikethrough))) 417 if ((res = psiconv_write_bool(extra_buf,value->strikethrough)))
482 goto ERROR; 418 goto ERROR;
483 } 419 }
484 420
485 if (!base || !value->font || !base->font || 421 if (!base || psiconv_compare_font(base->font,value->font)) {
486 (value->font->screenfont != base->font->screenfont) ||
487 strcmp(value->font->name,base->font->name)) {
488 if ((res = psiconv_write_u8(extra_buf,0x22))) 422 if ((res = psiconv_write_u8(extra_buf,0x22)))
489 goto ERROR; 423 goto ERROR;
490 if ((res = psiconv_write_font(extra_buf,value->font))) 424 if ((res = psiconv_write_font(extra_buf,value->font)))
491 goto ERROR; 425 goto ERROR;
492 } 426 }

Legend:
Removed from v.76  
changed lines
  Added in v.78

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26