--- psiconv/trunk/lib/psiconv/data.c 2004/02/09 23:12:58 208 +++ psiconv/trunk/lib/psiconv/data.c 2005/11/15 15:52:34 270 @@ -1,6 +1,6 @@ /* data.c - Part of psiconv, a PSION 5 file formats converter - Copyright (c) 1999-2004 Frodo Looijaard + Copyright (c) 1999-2005 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 @@ -24,6 +24,7 @@ #include "data.h" #include "list.h" #include "unicode.h" +#include "error.h" #ifdef DMALLOC #include @@ -335,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); @@ -449,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); } }