fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / hwpfilter / source / hinfo.cxx
blob96de6d753d0b91529b90aedf8c442994092856aa
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "precompile.h"
22 #include "hwplib.h"
23 #include "hinfo.h"
24 #include "hwpfile.h"
26 // Info Block
29 static bool HWPReadInfoBlock(void *ptr, int len, HWPFile & hwpf)
31 hwpf.info_block_len = len;
32 if (0 == len)
33 return true;
34 else
35 return hwpf.ReadBlock(ptr, len) != 0;
39 // Document Information
40 HWPInfo::HWPInfo()
41 : cur_col(0)
42 , cur_row(0)
43 , readonly(0)
44 , encrypted(0)
45 , beginpagenum(0)
46 , beginfnnum(0)
47 , countfn(0)
48 , splinetext(0)
49 , splinefn(0)
50 , spfnfn(0)
51 , fnchar(0)
52 , fnlinetype(0)
53 , borderline(0)
54 , empty_line_hide(0)
55 , table_move(0)
56 , compressed(0)
57 , reserved3(0)
58 , info_block_len(0)
59 , info_block(NULL)
61 back_info.isset = false;
62 memset(reserved1, 0, sizeof(reserved1));
63 memset(annotation, 0, sizeof(annotation));
64 memset(bordermargin, 0, sizeof(bordermargin));
67 HWPInfo::~HWPInfo()
69 delete[] info_block;
70 info_block = 0;
74 /**
75 * 문서정보를 읽어들이는 함수 ( 128 bytes )
76 * 문서정보는 파일인식정보( 30 bytes ) 다음에 위치한 정보이다.
78 bool HWPInfo::Read(HWPFile & hwpf)
80 hwpf.Read2b(&cur_col, 1); /* 문서를 저장할 당시의 커서가 위치한 문단번호 */
81 hwpf.Read2b(&cur_row, 1); /* 문단 칸 */
83 hwpf.Read1b(&paper.paper_kind, 1); /* 용지 종류 */
84 hwpf.Read1b(&paper.paper_direction, 1); /* 용지 방향 */
86 // paper geometry information
87 unsigned short tmp16;
88 if (!hwpf.Read2b(tmp16))
89 return false;
90 paper.paper_height = tmp16; /* 용지 길이 */
91 if (!hwpf.Read2b(tmp16))
92 return false;
93 paper.paper_width = tmp16; /* 용지 너비 */
94 if (!hwpf.Read2b(tmp16))
95 return false;
96 paper.top_margin = tmp16; /* 위쪽 여백 */
97 if (!hwpf.Read2b(tmp16))
98 return false;
99 paper.bottom_margin = tmp16; /* 아래쪽 여백 */
100 if (!hwpf.Read2b(tmp16))
101 return false;
102 paper.left_margin = tmp16; /* 왼쪽 여백 */
103 if (!hwpf.Read2b(tmp16))
104 return false;
105 paper.right_margin = tmp16; /* 오른쪽 여백 */
106 if (!hwpf.Read2b(tmp16))
107 return false;
108 paper.header_length = tmp16; /* 머리말 길이 */
109 if (!hwpf.Read2b(tmp16))
110 return false;
111 paper.footer_length = tmp16; /* 꼬리말 길이 */
112 if (!hwpf.Read2b(tmp16))
113 return false;
114 paper.gutter_length = tmp16; /* 제본여백 */
115 hwpf.Read2b(&readonly, 1); /* 예약 */
116 hwpf.Read1b(reserved1, 4); /* 예약 */
117 hwpf.Read1b(&chain_info.chain_page_no, 1); /* 쪽 번호 연결 1-연결, 0-새로시작 (연결인쇄에서 사용) */
118 hwpf.Read1b(&chain_info.chain_footnote_no, 1);/* 각주번호 연결 1-연결 0-새로시작 */
119 /* 연결인쇄할 파일의 이름 */
120 hwpf.Read1b(chain_info.chain_filename, CHAIN_MAX_PATH);
122 hwpf.Read1b(annotation, ANNOTATION_LEN); /* 덧붙이는 말 ( 파일 저장할 때 덧붙이는 말에 지정한 내용 ) */
123 hwpf.Read2b(&encrypted, 1); /* 암호 여부 0-보통파일, 그외-암호걸린 파일 */
124 //hwpf.Read1b(reserved2, 6); /* 아래 3개의값으로 바뀌었다. */
125 hwpf.Read2b(&beginpagenum,1); /* 페이지시작번호 */
127 // footnote
128 hwpf.Read2b(&beginfnnum,1); /* 각주 시작번호 */
129 hwpf.Read2b(&countfn,1); /* 각주 갯수 */
131 if (!hwpf.Read2b(tmp16))
132 return false;
133 splinetext = tmp16;
134 if (!hwpf.Read2b(tmp16))
135 return false;
136 splinefn = tmp16;
137 if (!hwpf.Read2b(tmp16))
138 return false;
139 spfnfn = tmp16;
140 hwpf.Read1b(&fnchar, 1);
141 hwpf.Read1b(&fnlinetype, 1);
142 // border layout
143 for (int ii = 0; ii < 4; ++ii)
145 if (!hwpf.Read2b(tmp16))
146 return false;
147 bordermargin[ii] = tmp16;
149 hwpf.Read2b(&borderline, 1);
151 hwpf.Read1b(&empty_line_hide, 1);
152 hwpf.Read1b(&table_move, 1);
153 hwpf.Read1b(&compressed, 1);
155 hwpf.Read1b(&reserved3, 1);
157 hwpf.Read2b(&info_block_len, 1);
158 if (hwpf.State())
159 return false;
161 /* 문서 요약을 읽는다. */
162 if (!summary.Read(hwpf))
163 return false;
164 if (info_block_len > 0)
166 info_block = new unsigned char[info_block_len + 1];
168 if (!HWPReadInfoBlock(info_block, info_block_len, hwpf))
169 return false;
172 /* hwpf의 값을 재설정 한다. */
173 hwpf.compressed = compressed != 0;
174 hwpf.encrypted = encrypted != 0;
175 hwpf.info_block_len = info_block_len;
176 hwpf.SetCompressed(hwpf.compressed);
178 return (!hwpf.State());
182 // Document Summary
184 bool HWPSummary::Read(HWPFile & hwpf)
186 hwpf.Read2b(title, 56);
187 hwpf.Read2b(subject, 56);
188 hwpf.Read2b(author, 56);
189 hwpf.Read2b(date, 56);
190 hwpf.Read2b(keyword[0], 56);
191 hwpf.Read2b(keyword[1], 56);
192 hwpf.Read2b(etc[0], 56);
193 hwpf.Read2b(etc[1], 56);
194 hwpf.Read2b(etc[2], 56);
196 return (!hwpf.State());
200 bool ParaShape::Read(HWPFile & hwpf)
202 pagebreak = 0;
203 unsigned short tmp16;
204 if (!hwpf.Read2b(tmp16))
205 return false;
206 left_margin = tmp16;
207 if (!hwpf.Read2b(tmp16))
208 return false;
209 right_margin = tmp16;
210 if (!hwpf.Read2b(tmp16))
211 return false;
212 indent = tmp16;
213 if (!hwpf.Read2b(tmp16))
214 return false;
215 lspacing = tmp16;
216 if (!hwpf.Read2b(tmp16))
217 return false;
218 pspacing_next = tmp16;
220 hwpf.Read1b(&condense, 1);
221 hwpf.Read1b(&arrange_type, 1);
222 for (int ii = 0; ii < MAXTABS; ii++)
224 hwpf.Read1b(&tabs[ii].type, 1);
225 hwpf.Read1b(&tabs[ii].dot_continue, 1);
226 if (!hwpf.Read2b(tmp16))
227 return false;
228 tabs[ii].position = tmp16;
230 hwpf.Read1b(&coldef.ncols, 1);
231 hwpf.Read1b(&coldef.separator, 1);
232 if (!hwpf.Read2b(tmp16))
233 return false;
234 coldef.spacing = tmp16;
235 if (!hwpf.Read2b(tmp16))
236 return false;
237 coldef.columnlen = tmp16;
238 if (!hwpf.Read2b(tmp16))
239 return false;
240 coldef.columnlen0 = tmp16;
241 hwpf.Read1b(&shade, 1);
242 hwpf.Read1b(&outline, 1);
243 hwpf.Read1b(&outline_continue, 1);
244 if (!hwpf.Read2b(tmp16))
245 return false;
246 pspacing_prev = tmp16;
248 hwpf.Read1b(reserved, 2);
249 return (!hwpf.State());
253 bool CharShape::Read(HWPFile & hwpf)
255 unsigned short tmp16;
256 if (!hwpf.Read2b(tmp16))
257 return false;
258 size = tmp16;
259 hwpf.Read1b(font, NLanguage);
260 hwpf.Read1b(ratio, NLanguage);
261 hwpf.Read1b(space, NLanguage);
262 hwpf.Read1b(color, 2);
263 hwpf.Read1b(&shade, 1);
264 hwpf.Read1b(&attr, 1);
265 hwpf.Read1b(reserved, 4);
267 return (!hwpf.State());
270 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */