1 | /* |
1 | /* |
2 | data.c - Part of psiconv, a PSION 5 file formats converter |
2 | data.c - Part of psiconv, a PSION 5 file formats converter |
3 | Copyright (c) 1999-2004 Frodo Looijaard <frodol@dds.nl> |
3 | Copyright (c) 1999-2014 Frodo Looijaard <frodo@frodo.looijaard.name> |
4 | |
4 | |
5 | This program is free software; you can redistribute it and/or modify |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or |
7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
8 | (at your option) any later version. |
… | |
… | |
22 | #include <stdlib.h> |
22 | #include <stdlib.h> |
23 | #include <string.h> |
23 | #include <string.h> |
24 | #include "data.h" |
24 | #include "data.h" |
25 | #include "list.h" |
25 | #include "list.h" |
26 | #include "unicode.h" |
26 | #include "unicode.h" |
|
|
27 | #include "error.h" |
27 | |
28 | |
28 | #ifdef DMALLOC |
29 | #ifdef DMALLOC |
29 | #include <dmalloc.h> |
30 | #include <dmalloc.h> |
30 | #endif |
31 | #endif |
31 | |
32 | |
… | |
… | |
333 | return ss->normal; |
334 | return ss->normal; |
334 | else |
335 | else |
335 | return psiconv_list_get(ss->styles,0xff - nr); |
336 | return psiconv_list_get(ss->styles,0xff - nr); |
336 | } |
337 | } |
337 | |
338 | |
|
|
339 | int psiconv_find_style(const psiconv_word_styles_section ss, |
|
|
340 | const psiconv_ucs2 *name, |
|
|
341 | int *nr) |
|
|
342 | { |
|
|
343 | const psiconv_ucs2 value_normal[] = { 'N','o','r','m','a','l',0 }; |
|
|
344 | psiconv_word_style style; |
|
|
345 | int i; |
|
|
346 | |
|
|
347 | if (!nr) |
|
|
348 | return PSICONV_E_OTHER; |
|
|
349 | if(!psiconv_unicode_strcmp(value_normal,name)) { |
|
|
350 | *nr = 0; |
|
|
351 | return 0; |
|
|
352 | } |
|
|
353 | for (i = 0; i < psiconv_list_length(ss->styles);i++) { |
|
|
354 | if (!(style = psiconv_list_get(ss->styles,i))) |
|
|
355 | return PSICONV_E_NOMEM; |
|
|
356 | if (!psiconv_unicode_strcmp(style->name,name)) { |
|
|
357 | *nr = 0xff - i; |
|
|
358 | return 0; |
|
|
359 | } |
|
|
360 | } |
|
|
361 | *nr = 0; |
|
|
362 | return PSICONV_E_OTHER; |
|
|
363 | } |
|
|
364 | |
|
|
365 | |
338 | psiconv_formula psiconv_get_formula (psiconv_formula_list ss, int nr) |
366 | psiconv_formula psiconv_get_formula (psiconv_formula_list ss, int nr) |
339 | { |
367 | { |
340 | return psiconv_list_get(ss,psiconv_list_length(ss)-nr-1); |
368 | return psiconv_list_get(ss,psiconv_list_length(ss)-nr-1); |
341 | } |
369 | } |
342 | |
370 | |
… | |
… | |
447 | psiconv_free_style_aux(style); |
475 | psiconv_free_style_aux(style); |
448 | free(style); |
476 | free(style); |
449 | } |
477 | } |
450 | } |
478 | } |
451 | |
479 | |
|
|
480 | void psiconv_free_word_style_list(psiconv_word_style_list style_list) |
|
|
481 | { |
|
|
482 | if (style_list) |
|
|
483 | psiconv_list_free_el(style_list,psiconv_free_style_aux); |
|
|
484 | } |
|
|
485 | |
452 | void psiconv_free_word_styles_section(psiconv_word_styles_section styles) |
486 | void psiconv_free_word_styles_section(psiconv_word_styles_section styles) |
453 | { |
487 | { |
454 | if (styles) { |
488 | if (styles) { |
455 | psiconv_free_word_style(styles->normal); |
489 | psiconv_free_word_style(styles->normal); |
456 | if (styles->styles) |
490 | psiconv_free_word_style_list(styles->styles); |
457 | psiconv_list_free_el(styles->styles,psiconv_free_style_aux); |
|
|
458 | free(styles); |
491 | free(styles); |
459 | } |
492 | } |
460 | } |
493 | } |
461 | |
494 | |
462 | void psiconv_free_header_section(psiconv_header_section header) |
495 | void psiconv_free_header_section(psiconv_header_section header) |