--- psiconv/trunk/lib/psiconv/data.c 2003/11/26 20:56:17 171 +++ psiconv/trunk/lib/psiconv/data.c 2004/03/16 13:47:04 241 @@ -1,6 +1,6 @@ /* data.c - Part of psiconv, a PSION 5 file formats converter - Copyright (c) 1999, 2000 Frodo Looijaard + Copyright (c) 1999-2004 Frodo Looijaard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,6 +23,8 @@ #include #include "data.h" #include "list.h" +#include "unicode.h" +#include "error.h" #ifdef DMALLOC #include @@ -84,9 +86,12 @@ 0xff, /* green */ 0xff, /* blue */ }; + static psiconv_ucs2 font_times[16] = { 'T','i','m','e','s',' ', + 'N','e','w',' ', + 'R','o','m','a','n',0 }; static struct psiconv_font_s font = { - "Times New Roman", /* name */ + font_times, /* name */ 3 /* screenfont */ }; struct psiconv_character_layout_s cl = @@ -109,9 +114,13 @@ files themself. */ psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) { + static psiconv_ucs2 font_times[16] = { 'T','i','m','e','s',' ', + 'N','e','w',' ', + 'R','o','m','a','n',0 }; + static struct psiconv_font_s font = { - "Times New Roman", /* name */ + font_times, /* name */ 2 /* screenfont */ }; static struct psiconv_color_s black = @@ -136,7 +145,7 @@ { psiconv_bool_false, /* on */ 10.0, /* font_size */ - 0x95, /* character */ + 0x201d, /* character */ psiconv_bool_true, /* indent */ &black, /* color */ &font, /* font */ @@ -195,7 +204,7 @@ if(!(result = malloc(sizeof(*result)))) goto ERROR1; *result = *font; - if (!(result->name = strdup(result->name))) + if (!(result->name = psiconv_unicode_strdup(result->name))) goto ERROR2; return result; ERROR2: @@ -327,6 +336,33 @@ return psiconv_list_get(ss->styles,0xff - nr); } +int psiconv_find_style(const psiconv_word_styles_section ss, + const psiconv_ucs2 *name, + int *nr) +{ + const psiconv_ucs2 value_normal[] = { 'N','o','r','m','a','l',0 }; + psiconv_word_style style; + int i; + + if (!nr) + return PSICONV_E_OTHER; + if(!psiconv_unicode_strcmp(value_normal,name)) { + *nr = 0; + return 0; + } + for (i = 0; i < psiconv_list_length(ss->styles);i++) { + if (!(style = psiconv_list_get(ss->styles,i))) + return PSICONV_E_NOMEM; + if (!psiconv_unicode_strcmp(style->name,name)) { + *nr = 0xff - i; + return 0; + } + } + *nr = 0; + return PSICONV_E_OTHER; +} + + psiconv_formula psiconv_get_formula (psiconv_formula_list ss, int nr) { return psiconv_list_get(ss,psiconv_list_length(ss)-nr-1); @@ -441,12 +477,17 @@ } } +void psiconv_free_word_style_list(psiconv_word_style_list style_list) +{ + if (style_list) + psiconv_list_free_el(style_list,psiconv_free_style_aux); +} + void psiconv_free_word_styles_section(psiconv_word_styles_section styles) { if (styles) { psiconv_free_word_style(styles->normal); - if (styles->styles) - psiconv_list_free_el(styles->styles,psiconv_free_style_aux); + psiconv_free_word_style_list(styles->styles); free(styles); } } @@ -887,7 +928,7 @@ void psiconv_free_clipart_section_aux(void *section) { if (section) - free(((psiconv_clipart_section ) section)->picture); + psiconv_free_paint_data_section(((psiconv_clipart_section) section)->picture); } void psiconv_free_clipart_section(psiconv_clipart_section section) @@ -950,7 +991,7 @@ if (!value1 || !value2 || !value1->name || !value2->name) return 1; if ((value1->screenfont == value2->screenfont) && - !strcmp(value1->name,value2->name)) + !psiconv_unicode_strcmp(value1->name,value2->name)) return 0; else return 1;