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

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

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

Revision 171 Revision 270
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, 2000 Frodo Looijaard <frodol@dds.nl> 3 Copyright (c) 1999-2005 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.
21#include "compat.h" 21#include "compat.h"
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"
27#include "error.h"
26 28
27#ifdef DMALLOC 29#ifdef DMALLOC
28#include <dmalloc.h> 30#include <dmalloc.h>
29#endif 31#endif
30 32
82 { 84 {
83 0xff, /* red */ 85 0xff, /* red */
84 0xff, /* green */ 86 0xff, /* green */
85 0xff, /* blue */ 87 0xff, /* blue */
86 }; 88 };
89 static psiconv_ucs2 font_times[16] = { 'T','i','m','e','s',' ',
90 'N','e','w',' ',
91 'R','o','m','a','n',0 };
87 static struct psiconv_font_s font = 92 static struct psiconv_font_s font =
88 { 93 {
89 "Times New Roman", /* name */ 94 font_times, /* name */
90 3 /* screenfont */ 95 3 /* screenfont */
91 }; 96 };
92 struct psiconv_character_layout_s cl = 97 struct psiconv_character_layout_s cl =
93 { 98 {
94 &black, /* color */ 99 &black, /* color */
107 112
108/* Note: these defaults seem to be hard-coded somewhere outside the 113/* Note: these defaults seem to be hard-coded somewhere outside the
109 files themself. */ 114 files themself. */
110psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) 115psiconv_paragraph_layout psiconv_basic_paragraph_layout(void)
111{ 116{
117 static psiconv_ucs2 font_times[16] = { 'T','i','m','e','s',' ',
118 'N','e','w',' ',
119 'R','o','m','a','n',0 };
120
112 static struct psiconv_font_s font = 121 static struct psiconv_font_s font =
113 { 122 {
114 "Times New Roman", /* name */ 123 font_times, /* name */
115 2 /* screenfont */ 124 2 /* screenfont */
116 }; 125 };
117 static struct psiconv_color_s black = 126 static struct psiconv_color_s black =
118 { 127 {
119 0x00, /* red */ 128 0x00, /* red */
134 }; 143 };
135 static struct psiconv_bullet_s bullet = 144 static struct psiconv_bullet_s bullet =
136 { 145 {
137 psiconv_bool_false, /* on */ 146 psiconv_bool_false, /* on */
138 10.0, /* font_size */ 147 10.0, /* font_size */
139 0x95, /* character */ 148 0x201d, /* character */
140 psiconv_bool_true, /* indent */ 149 psiconv_bool_true, /* indent */
141 &black, /* color */ 150 &black, /* color */
142 &font, /* font */ 151 &font, /* font */
143 }; 152 };
144 static struct psiconv_all_tabs_s tabs = 153 static struct psiconv_all_tabs_s tabs =
193{ 202{
194 psiconv_font result; 203 psiconv_font result;
195 if(!(result = malloc(sizeof(*result)))) 204 if(!(result = malloc(sizeof(*result))))
196 goto ERROR1; 205 goto ERROR1;
197 *result = *font; 206 *result = *font;
198 if (!(result->name = strdup(result->name))) 207 if (!(result->name = psiconv_unicode_strdup(result->name)))
199 goto ERROR2; 208 goto ERROR2;
200 return result; 209 return result;
201ERROR2: 210ERROR2:
202 free(result); 211 free(result);
203ERROR1: 212ERROR1:
325 return ss->normal; 334 return ss->normal;
326 else 335 else
327 return psiconv_list_get(ss->styles,0xff - nr); 336 return psiconv_list_get(ss->styles,0xff - nr);
328} 337}
329 338
339int 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
330psiconv_formula psiconv_get_formula (psiconv_formula_list ss, int nr) 366psiconv_formula psiconv_get_formula (psiconv_formula_list ss, int nr)
331{ 367{
332 return psiconv_list_get(ss,psiconv_list_length(ss)-nr-1); 368 return psiconv_list_get(ss,psiconv_list_length(ss)-nr-1);
333} 369}
334 370
439 psiconv_free_style_aux(style); 475 psiconv_free_style_aux(style);
440 free(style); 476 free(style);
441 } 477 }
442} 478}
443 479
480void 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
444void psiconv_free_word_styles_section(psiconv_word_styles_section styles) 486void psiconv_free_word_styles_section(psiconv_word_styles_section styles)
445{ 487{
446 if (styles) { 488 if (styles) {
447 psiconv_free_word_style(styles->normal); 489 psiconv_free_word_style(styles->normal);
448 if (styles->styles) 490 psiconv_free_word_style_list(styles->styles);
449 psiconv_list_free_el(styles->styles,psiconv_free_style_aux);
450 free(styles); 491 free(styles);
451 } 492 }
452} 493}
453 494
454void psiconv_free_header_section(psiconv_header_section header) 495void psiconv_free_header_section(psiconv_header_section header)
885} 926}
886 927
887void psiconv_free_clipart_section_aux(void *section) 928void psiconv_free_clipart_section_aux(void *section)
888{ 929{
889 if (section) 930 if (section)
890 free(((psiconv_clipart_section ) section)->picture); 931 psiconv_free_paint_data_section(((psiconv_clipart_section) section)->picture);
891} 932}
892 933
893void psiconv_free_clipart_section(psiconv_clipart_section section) 934void psiconv_free_clipart_section(psiconv_clipart_section section)
894{ 935{
895 if (section) { 936 if (section) {
948 const psiconv_font value2) 989 const psiconv_font value2)
949{ 990{
950 if (!value1 || !value2 || !value1->name || !value2->name) 991 if (!value1 || !value2 || !value1->name || !value2->name)
951 return 1; 992 return 1;
952 if ((value1->screenfont == value2->screenfont) && 993 if ((value1->screenfont == value2->screenfont) &&
953 !strcmp(value1->name,value2->name)) 994 !psiconv_unicode_strcmp(value1->name,value2->name))
954 return 0; 995 return 0;
955 else 996 else
956 return 1; 997 return 1;
957} 998}
958 999

Legend:
Removed from v.171  
changed lines
  Added in v.270

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