1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
29 static bool HWPReadInfoBlock(void *ptr
, int len
, HWPFile
& hwpf
)
31 hwpf
.info_block_len
= len
;
35 return hwpf
.ReadBlock(ptr
, len
) != 0;
39 // Document Information
61 back_info
.isset
= false;
62 memset(reserved1
, 0, sizeof(reserved1
));
63 memset(annotation
, 0, sizeof(annotation
));
64 memset(bordermargin
, 0, sizeof(bordermargin
));
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
88 if (!hwpf
.Read2b(tmp16
))
90 paper
.paper_height
= tmp16
; /* 용지 길이 */
91 if (!hwpf
.Read2b(tmp16
))
93 paper
.paper_width
= tmp16
; /* 용지 너비 */
94 if (!hwpf
.Read2b(tmp16
))
96 paper
.top_margin
= tmp16
; /* 위쪽 여백 */
97 if (!hwpf
.Read2b(tmp16
))
99 paper
.bottom_margin
= tmp16
; /* 아래쪽 여백 */
100 if (!hwpf
.Read2b(tmp16
))
102 paper
.left_margin
= tmp16
; /* 왼쪽 여백 */
103 if (!hwpf
.Read2b(tmp16
))
105 paper
.right_margin
= tmp16
; /* 오른쪽 여백 */
106 if (!hwpf
.Read2b(tmp16
))
108 paper
.header_length
= tmp16
; /* 머리말 길이 */
109 if (!hwpf
.Read2b(tmp16
))
111 paper
.footer_length
= tmp16
; /* 꼬리말 길이 */
112 if (!hwpf
.Read2b(tmp16
))
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-새로시작 */
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); /* 페이지시작번호 */
128 hwpf
.Read2b(&beginfnnum
,1); /* 각주 시작번호 */
129 hwpf
.Read2b(&countfn
,1); /* 각주 갯수 */
131 if (!hwpf
.Read2b(tmp16
))
134 if (!hwpf
.Read2b(tmp16
))
137 if (!hwpf
.Read2b(tmp16
))
140 hwpf
.Read1b(&fnchar
, 1);
141 hwpf
.Read1b(&fnlinetype
, 1);
143 for (int ii
= 0; ii
< 4; ++ii
)
145 if (!hwpf
.Read2b(tmp16
))
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);
162 if (!summary
.Read(hwpf
))
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
))
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());
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
)
203 unsigned short tmp16
;
204 if (!hwpf
.Read2b(tmp16
))
207 if (!hwpf
.Read2b(tmp16
))
209 right_margin
= tmp16
;
210 if (!hwpf
.Read2b(tmp16
))
213 if (!hwpf
.Read2b(tmp16
))
216 if (!hwpf
.Read2b(tmp16
))
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
))
228 tabs
[ii
].position
= tmp16
;
230 hwpf
.Read1b(&coldef
.ncols
, 1);
231 hwpf
.Read1b(&coldef
.separator
, 1);
232 if (!hwpf
.Read2b(tmp16
))
234 coldef
.spacing
= tmp16
;
235 if (!hwpf
.Read2b(tmp16
))
237 coldef
.columnlen
= tmp16
;
238 if (!hwpf
.Read2b(tmp16
))
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
))
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
))
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: */