/[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 79 - (show annotations)
Mon Dec 25 22:25:33 2000 UTC (23 years, 3 months ago) by frodo
File MIME type: text/plain
File size: 3741 byte(s)
(Frodo) Added a complete buffer abstraction

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_buffer_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 /* Three unknown bytes */
58 if ((res = psiconv_write_u8(buf,0x00)))
59 goto ERROR3;
60 if ((res = psiconv_write_u8(buf,0x00)))
61 goto ERROR3;
62 if ((res = psiconv_write_u8(buf,0x00)))
63 goto ERROR3;
64 if ((res = psiconv_write_paragraph_layout_list(buf,
65 value->base_paragraph_layout,basepara)))
66 goto ERROR3;
67 if ((res = psiconv_write_character_layout_list(buf,
68 value->base_character_layout,basechar)))
69 goto ERROR3;
70 res = psiconv_write_texted_section(buf,value->text,
71 value->base_character_layout,
72 value->base_paragraph_layout);
73 ERROR3:
74 psiconv_free_character_layout(basechar);
75 ERROR2:
76 psiconv_free_paragraph_layout(basepara);
77 ERROR1:
78 return res;
79 }
80
81 int psiconv_write_page_layout_section(psiconv_buffer buf,
82 const psiconv_page_layout_section value)
83 {
84 int res;
85
86 if (!value) {
87 psiconv_warn(0,psiconv_buffer_length(buf),"Null page section");
88 return -PSICONV_E_GENERATE;
89 }
90
91 if ((res = psiconv_write_u32(buf,value->first_page_nr)))
92 return res;
93 if ((res = psiconv_write_length(buf,value->header_dist)))
94 return res;
95 if ((res = psiconv_write_length(buf,value->footer_dist)))
96 return res;
97 if ((res = psiconv_write_length(buf,value->left_margin)))
98 return res;
99 if ((res = psiconv_write_length(buf,value->right_margin)))
100 return res;
101 if ((res = psiconv_write_length(buf,value->top_margin)))
102 return res;
103 if ((res = psiconv_write_length(buf,value->bottom_margin)))
104 return res;
105 if ((res = psiconv_write_page_header(buf,value->header)))
106 return res;
107 if ((res = psiconv_write_page_header(buf,value->footer)))
108 return res;
109 if ((res = psiconv_write_u32(buf,PSICONV_ID_PAGE_DIMENSIONS2)))
110 return res;
111 if ((res = psiconv_write_length(buf,value->page_width)))
112 return res;
113 if ((res = psiconv_write_length(buf,value->page_height)))
114 return res;
115 return psiconv_write_bool(buf,value->landscape);
116 }

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