/[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 62 Revision 78
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 Frodo Looijaard <frodol@dds.nl> 3 Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl>
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.
32static void psiconv_free_in_line_layout_aux(void * layout); 32static void psiconv_free_in_line_layout_aux(void * layout);
33static void psiconv_free_paragraph_aux(void * paragraph); 33static void psiconv_free_paragraph_aux(void * paragraph);
34static void psiconv_free_paint_data_section_aux(void * section); 34static void psiconv_free_paint_data_section_aux(void * section);
35static void psiconv_free_clipart_section_aux(void * section); 35static void psiconv_free_clipart_section_aux(void * section);
36 36
37/* Note: these defaults seem to be hard-coded somewhere outside the
38 files themself. */
37psiconv_character_layout psiconv_basic_character_layout(void) 39psiconv_character_layout psiconv_basic_character_layout(void)
38{ 40{
39 /* Make the structures static, to oblige IRIX */ 41 /* Make the structures static, to oblige IRIX */
40 static struct psiconv_color_s black = 42 static struct psiconv_color_s black =
41 { 43 {
61 10.0, /* font_size */ 63 10.0, /* font_size */
62 psiconv_bool_false, /* italic */ 64 psiconv_bool_false, /* italic */
63 psiconv_bool_false, /* bold */ 65 psiconv_bool_false, /* bold */
64 psiconv_normalscript, /* super_sub */ 66 psiconv_normalscript, /* super_sub */
65 psiconv_bool_false, /* underline */ 67 psiconv_bool_false, /* underline */
66 psiconv_bool_false, /* strike_out */ 68 psiconv_bool_false, /* strikethrough */
67 &font, /* font */ 69 &font, /* font */
68 }; 70 };
69 71
70 return psiconv_clone_character_layout(&cl); 72 return psiconv_clone_character_layout(&cl);
71} 73}
72 74
75/* Note: these defaults seem to be hard-coded somewhere outside the
76 files themself. */
73psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) 77psiconv_paragraph_layout psiconv_basic_paragraph_layout(void)
74{ 78{
75 static struct psiconv_font_s font = 79 static struct psiconv_font_s font =
76 { 80 {
77 "Times New Roman", /* name */ 81 "Times New Roman", /* name */
115 0.0, /* indent_left */ 119 0.0, /* indent_left */
116 0.0, /* indent_right */ 120 0.0, /* indent_right */
117 0.0, /* indent_first */ 121 0.0, /* indent_first */
118 psiconv_justify_left, /* justify_hor */ 122 psiconv_justify_left, /* justify_hor */
119 psiconv_justify_middle,/* justify_ver */ 123 psiconv_justify_middle,/* justify_ver */
120 0.0, /* interline */ 124 10.0, /* linespacing */
121 psiconv_bool_false, /* interline_exact */ 125 psiconv_bool_false, /* linespacing_exact */
122 0.0, /* top_space */ 126 0.0, /* space_above */
123 0.0, /* bottom_space */ 127 0.0, /* space_below */
124 psiconv_bool_false, /* on_one_page */
125 psiconv_bool_false, /* together_with */ 128 psiconv_bool_false, /* keep_together */
129 psiconv_bool_false, /* keep_with_next */
126 psiconv_bool_false, /* on_next_page */ 130 psiconv_bool_false, /* on_next_page */
127 psiconv_bool_false, /* no_widow_protection */ 131 psiconv_bool_false, /* no_widow_protection */
128 0.0, /* left_margin */ 132 0.0, /* left_margin */
129 &bullet, /* bullet */ 133 &bullet, /* bullet */
130 &no_border, /* left_border */ 134 &no_border, /* left_border */
619 else if (file->type == psiconv_clipart_file) 623 else if (file->type == psiconv_clipart_file)
620 psiconv_free_clipart_f((psiconv_clipart_f) file->file); 624 psiconv_free_clipart_f((psiconv_clipart_f) file->file);
621 free(file); 625 free(file);
622 } 626 }
623} 627}
628
629int psiconv_compare_color(const psiconv_color value1,
630 const psiconv_color value2)
631{
632 if (!value1 || !value2)
633 return 1;
634 if ((value1->red == value2->red) &&
635 (value1->green == value2->green) &&
636 (value1->blue == value2->blue))
637 return 0;
638 else
639 return 1;
640}
641
642int psiconv_compare_font(const psiconv_font value1,
643 const psiconv_font value2)
644{
645 if (!value1 || !value2 || !value1->name || !value2->name)
646 return 1;
647 if ((value1->screenfont == value2->screenfont) &&
648 !strcmp(value1->name,value2->name))
649 return 0;
650 else
651 return 1;
652}
653
654int psiconv_compare_border(const psiconv_border value1,
655 const psiconv_border value2)
656{
657 if (!value1 || !value2)
658 return 1;
659 if ((value1->kind == value2->kind) &&
660 (value1->thickness == value2->thickness) &&
661 !psiconv_compare_color(value1->color,value2->color))
662 return 0;
663 else
664 return 1;
665}
666
667int psiconv_compare_bullet(const psiconv_bullet value1,
668 const psiconv_bullet value2)
669{
670 if (!value1 || !value2)
671 return 1;
672 if ((value1->on == value2->on) &&
673 (value1->font_size == value2->font_size) &&
674 (value1->character == value2->character) &&
675 (value1->indent == value2->indent) &&
676 !psiconv_compare_color(value1->color,value2->color) &&
677 !psiconv_compare_font(value1->font,value2->font))
678 return 0;
679 else
680 return 1;
681}
682
683int psiconv_compare_tab(const psiconv_tab value1, const psiconv_tab value2)
684{
685 if (!value1 || !value2)
686 return 1;
687 if ((value1->location == value2->location) &&
688 (value1->kind == value2->kind))
689 return 0;
690 else
691 return 1;
692}
693
694int psiconv_compare_all_tabs(const psiconv_all_tabs value1,
695 const psiconv_all_tabs value2)
696{
697 int i;
698
699 if (!value1 || !value2 || !value1->extras || !value2->extras)
700 return 1;
701
702 if ((value1->normal != value2->normal) ||
703 psiconv_list_length(value1->extras) !=
704 psiconv_list_length(value2->extras))
705 return 1;
706 for (i = 0; i < psiconv_list_length(value1->extras); i++)
707 if (psiconv_compare_tab(psiconv_list_get(value1->extras,i),
708 psiconv_list_get(value2->extras,i)))
709
710 return 1;
711 return 0;
712}
713
714int psiconv_compare_paragraph_layout(const psiconv_paragraph_layout value1,
715 const psiconv_paragraph_layout value2)
716{
717 if (!value1 || !value2)
718 return 1;
719 if ((value1->indent_left == value2->indent_left) &&
720 (value1->indent_right == value2->indent_right) &&
721 (value1->indent_first == value2->indent_first) &&
722 (value1->justify_hor == value2->justify_hor) &&
723 (value1->justify_ver == value2->justify_ver) &&
724 (value1->linespacing == value2->linespacing) &&
725 (value1->space_above == value2->space_above) &&
726 (value1->space_below == value2->space_below) &&
727 (value1->keep_together == value2->keep_together) &&
728 (value1->keep_with_next == value2->keep_with_next) &&
729 (value1->on_next_page == value2->on_next_page) &&
730 (value1->no_widow_protection == value2->no_widow_protection) &&
731 (value1->border_distance == value2->border_distance) &&
732 !psiconv_compare_color(value1->back_color,value2->back_color) &&
733 !psiconv_compare_bullet(value1->bullet,value2->bullet) &&
734 !psiconv_compare_border(value1->left_border,value2->left_border) &&
735 !psiconv_compare_border(value1->right_border,value2->right_border) &&
736 !psiconv_compare_border(value1->top_border,value2->top_border) &&
737 !psiconv_compare_border(value1->bottom_border,value2->bottom_border) &&
738 !psiconv_compare_all_tabs(value1->tabs,value2->tabs))
739 return 0;
740 else
741 return 1;
742}
743
744
745int psiconv_compare_character_layout(const psiconv_character_layout value1,
746 const psiconv_character_layout value2)
747{
748 if (!value1 || !value2)
749 return 1;
750 if ((value1->font_size == value2->font_size) &&
751 (value1->italic == value2->italic) &&
752 (value1->bold == value2->bold) &&
753 (value1->super_sub == value2->super_sub) &&
754 (value1->underline == value2->underline) &&
755 (value1->strikethrough == value2->strikethrough) &&
756 !psiconv_compare_color(value1->color,value2->color) &&
757 !psiconv_compare_color(value1->back_color,value2->back_color) &&
758 !psiconv_compare_font(value1->font,value2->font))
759 return 0;
760 else
761 return 1;
762}

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

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