Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "precompile.h"
21 :
22 : #include "hwplib.h"
23 : #include "hinfo.h"
24 : #include "hwpfile.h"
25 :
26 : // Info Block
27 :
28 :
29 0 : static bool HWPReadInfoBlock(void *ptr, int len, HWPFile & hwpf)
30 : {
31 0 : hwpf.info_block_len = len;
32 0 : if (0 == len)
33 0 : return true;
34 : else
35 0 : return hwpf.ReadBlock(ptr, len) ? true : false;
36 : }
37 :
38 :
39 : // Document Information
40 2 : 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 2 : , info_block(NULL)
60 : {
61 2 : back_info.isset = false;
62 2 : memset(reserved1, 0, sizeof(reserved1));
63 2 : memset(annotation, 0, sizeof(annotation));
64 2 : memset(bordermargin, 0, sizeof(bordermargin));
65 2 : }
66 :
67 2 : HWPInfo::~HWPInfo(void)
68 : {
69 2 : delete[] info_block;
70 2 : info_block = 0;
71 2 : }
72 :
73 :
74 : /**
75 : * 문서정보를 읽어들이는 함수 ( 128 bytes )
76 : * 문서정보는 파일인식정보( 30 bytes ) 다음에 위치한 정보이다.
77 : */
78 2 : bool HWPInfo::Read(HWPFile & hwpf)
79 : {
80 2 : hwpf.Read2b(&cur_col, 1); /* 문서를 저장할 당시의 커서가 위치한 문단번호 */
81 2 : hwpf.Read2b(&cur_row, 1); /* 문단 칸 */
82 :
83 2 : hwpf.Read1b(&paper.paper_kind, 1); /* 용지 종류 */
84 2 : hwpf.Read1b(&paper.paper_direction, 1); /* 용지 방향 */
85 :
86 : // paper geometry information
87 2 : paper.paper_height = (short) hwpf.Read2b(); /* 용지 길이 */
88 2 : paper.paper_width = (short) hwpf.Read2b(); /* 용지 너비 */
89 2 : paper.top_margin = (short) hwpf.Read2b(); /* 위쪽 여백 */
90 2 : paper.bottom_margin = (short) hwpf.Read2b(); /* 아래쪽 여백 */
91 2 : paper.left_margin = (short) hwpf.Read2b(); /* 왼쪽 여백 */
92 2 : paper.right_margin = (short) hwpf.Read2b(); /* 오른쪽 여백 */
93 2 : paper.header_length = (short) hwpf.Read2b(); /* 머리말 길이 */
94 2 : paper.footer_length = (short) hwpf.Read2b(); /* 꼬리말 길이 */
95 2 : paper.gutter_length = (short) hwpf.Read2b(); /* 제본여백 */
96 2 : hwpf.Read2b(&readonly, 1); /* 예약 */
97 2 : hwpf.Read1b(reserved1, 4); /* 예약 */
98 2 : hwpf.Read1b(&chain_info.chain_page_no, 1); /* 쪽 번호 연결 1-연결, 0-새로시작 (연결인쇄에서 사용) */
99 2 : hwpf.Read1b(&chain_info.chain_footnote_no, 1);/* 각주번호 연결 1-연결 0-새로시작 */
100 : /* 연결인쇄할 파일의 이름 */
101 2 : hwpf.Read1b(chain_info.chain_filename, CHAIN_MAX_PATH);
102 :
103 2 : hwpf.Read1b(annotation, ANNOTATION_LEN); /* 덧붙이는 말 ( 파일 저장할 때 덧붙이는 말에 지정한 내용 ) */
104 2 : hwpf.Read2b(&encrypted, 1); /* 암호 여부 0-보통파일, 그외-암호걸린 파일 */
105 : //hwpf.Read1b(reserved2, 6); /* 아래 3개의값으로 바뀌었다. */
106 2 : hwpf.Read2b(&beginpagenum,1); /* 페이지시작번호 */
107 :
108 : // footnote
109 2 : hwpf.Read2b(&beginfnnum,1); /* 각주 시작번호 */
110 2 : hwpf.Read2b(&countfn,1); /* 각주 갯수 */
111 2 : splinetext = (short) hwpf.Read2b();
112 2 : splinefn = (short) hwpf.Read2b();
113 2 : spfnfn = (short) hwpf.Read2b();
114 2 : hwpf.Read1b(&fnchar, 1);
115 2 : hwpf.Read1b(&fnlinetype, 1);
116 : // border layout
117 10 : for (int ii = 0; ii < 4; ++ii)
118 8 : bordermargin[ii] = (short) hwpf.Read2b();
119 2 : hwpf.Read2b(&borderline, 1);
120 :
121 2 : hwpf.Read1b(&empty_line_hide, 1);
122 2 : hwpf.Read1b(&table_move, 1);
123 2 : hwpf.Read1b(&compressed, 1);
124 :
125 2 : hwpf.Read1b(&reserved3, 1);
126 :
127 2 : hwpf.Read2b(&info_block_len, 1);
128 2 : if (hwpf.State())
129 0 : return false;
130 :
131 : /* 문서 요약을 읽는다. */
132 2 : if (!summary.Read(hwpf))
133 0 : return false;
134 2 : if (info_block_len > 0)
135 : {
136 0 : info_block = new unsigned char[info_block_len + 1];
137 :
138 0 : if (0 == info_block ||
139 0 : !HWPReadInfoBlock(info_block, info_block_len, hwpf))
140 0 : return false;
141 : }
142 :
143 : /* hwpf의 값을 재설정 한다. */
144 2 : hwpf.compressed = compressed ? true : false;
145 2 : hwpf.encrypted = encrypted ? true : false;
146 2 : hwpf.info_block_len = info_block_len;
147 2 : hwpf.SetCompressed(hwpf.compressed);
148 :
149 2 : return (!hwpf.State());
150 : }
151 :
152 :
153 : // Document Summary
154 :
155 2 : bool HWPSummary::Read(HWPFile & hwpf)
156 : {
157 2 : hwpf.Read2b(title, 56);
158 2 : hwpf.Read2b(subject, 56);
159 2 : hwpf.Read2b(author, 56);
160 2 : hwpf.Read2b(date, 56);
161 2 : hwpf.Read2b(keyword[0], 56);
162 2 : hwpf.Read2b(keyword[1], 56);
163 2 : hwpf.Read2b(etc[0], 56);
164 2 : hwpf.Read2b(etc[1], 56);
165 2 : hwpf.Read2b(etc[2], 56);
166 :
167 2 : return (!hwpf.State());
168 : }
169 :
170 :
171 28 : bool ParaShape::Read(HWPFile & hwpf)
172 : {
173 28 : pagebreak = 0;
174 28 : left_margin = (short) hwpf.Read2b();
175 28 : right_margin = (short) hwpf.Read2b();
176 28 : indent = (short) hwpf.Read2b();
177 28 : lspacing = (short) hwpf.Read2b();
178 28 : pspacing_next = (short) hwpf.Read2b();
179 :
180 28 : hwpf.Read1b(&condense, 1);
181 28 : hwpf.Read1b(&arrange_type, 1);
182 1148 : for (int ii = 0; ii < MAXTABS; ii++)
183 : {
184 1120 : hwpf.Read1b(&tabs[ii].type, 1);
185 1120 : hwpf.Read1b(&tabs[ii].dot_continue, 1);
186 1120 : tabs[ii].position = (short) hwpf.Read2b();
187 : }
188 28 : hwpf.Read1b(&coldef.ncols, 1);
189 28 : hwpf.Read1b(&coldef.separator, 1);
190 28 : coldef.spacing = (short) hwpf.Read2b();
191 28 : coldef.columnlen = (short) hwpf.Read2b();
192 28 : coldef.columnlen0 = (short) hwpf.Read2b();
193 28 : hwpf.Read1b(&shade, 1);
194 28 : hwpf.Read1b(&outline, 1);
195 28 : hwpf.Read1b(&outline_continue, 1);
196 28 : pspacing_prev = (short) hwpf.Read2b();
197 :
198 28 : hwpf.Read1b(reserved, 2);
199 28 : return (!hwpf.State());
200 : }
201 :
202 :
203 34 : bool CharShape::Read(HWPFile & hwpf)
204 : {
205 34 : size = (short) hwpf.Read2b();
206 34 : hwpf.Read1b(font, NLanguage);
207 34 : hwpf.Read1b(ratio, NLanguage);
208 34 : hwpf.Read1b(space, NLanguage);
209 34 : hwpf.Read1b(color, 2);
210 34 : hwpf.Read1b(&shade, 1);
211 34 : hwpf.Read1b(&attr, 1);
212 34 : hwpf.Read1b(reserved, 4);
213 :
214 34 : return (!hwpf.State());
215 : }
216 :
217 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|