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

Contents of /psiconv/trunk/lib/psiconv/generate_page.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 73 - (show annotations)
Sun Dec 24 16:03:57 2000 UTC (19 years, 6 months ago) by frodo
File MIME type: text/plain
File size: 3458 byte(s)
(Frodo) We should now have enough to generate TextEd sections!

1 /*
2 generate_page.c - Part of psiconv, a PSION 5 file formats converter
3 Copyright (c) 2000 Frodo Looijaard <frodol@dds.nl>
4
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
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include "config.h"
21 #include "compat.h"
22
23 #include <stdlib.h>
24 #include <string.h>
25
26 #include "generate_routines.h"
27 #include "error.h"
28
29
30 int psiconv_write_page_header(psiconv_buffer buf,
31 const psiconv_page_header value)
32 {
33 int res;
34 psiconv_paragraph_layout basepara;
35 psiconv_character_layout basechar;
36
37 if (!value) {
38 psiconv_warn(0,psiconv_list_length(buf),"Null page header");
39 res = -PSICONV_E_GENERATE;
40 goto ERROR1;
41 }
42
43 if (!(basepara=psiconv_basic_paragraph_layout())) {
44 res = -PSICONV_E_NOMEM;
45 goto ERROR1;
46 }
47 if (!(basechar=psiconv_basic_character_layout())) {
48 res = -PSICONV_E_NOMEM;
49 goto ERROR2;
50 }
51
52 /* Unknown byte */
53 if ((res = psiconv_write_u8(buf,0x01)))
54 goto ERROR3;
55 if ((res = psiconv_write_bool(buf,value->on_first_page)))
56 goto ERROR3;
57 if ((res = psiconv_write_paragraph_layout_list(buf,
58 value->base_paragraph_layout,basepara)))
59 goto ERROR3;
60 if ((res = psiconv_write_character_layout_list(buf,
61 value->base_character_layout,basechar)))
62 goto ERROR3;
63 res = psiconv_write_texted_section(buf,value->text,
64 value->base_character_layout,
65 value->base_paragraph_layout);
66 ERROR3:
67 psiconv_free_character_layout(basechar);
68 ERROR2:
69 psiconv_free_paragraph_layout(basepara);
70 ERROR1:
71 return res;
72 }
73
74 int psiconv_write_page_layout_section(psiconv_buffer buf,
75 const psiconv_page_layout_section value)
76 {
77 int res;
78
79 if (!value) {
80 psiconv_warn(0,psiconv_list_length(buf),"Null page section");
81 return -PSICONV_E_GENERATE;
82 }
83
84 if ((res = psiconv_write_u32(buf,value->first_page_nr)))
85 return res;
86 if ((res = psiconv_write_length(buf,value->header_dist)))
87 return res;
88 if ((res = psiconv_write_length(buf,value->footer_dist)))
89 return res;
90 if ((res = psiconv_write_length(buf,value->left_margin)))
91 return res;
92 if ((res = psiconv_write_length(buf,value->right_margin)))
93 return res;
94 if ((res = psiconv_write_length(buf,value->top_margin)))
95 return res;
96 if ((res = psiconv_write_length(buf,value->bottom_margin)))
97 return res;
98 if ((res = psiconv_write_page_header(buf,value->header)))
99 return res;
100 if ((res = psiconv_write_page_header(buf,value->footer)))
101 return res;
102 if ((res = psiconv_write_u32(buf,PSICONV_ID_PAGE_DIMENSIONS)))
103 return res;
104 if ((res = psiconv_write_length(buf,value->page_width)))
105 return res;
106 return psiconv_write_length(buf,value->page_height);
107 }

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