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 :
41 0 : HWPInfo::HWPInfo(void)
42 : {
43 0 : info_block = 0;
44 0 : back_info.isset = false;
45 0 : }
46 :
47 :
48 0 : HWPInfo::~HWPInfo(void)
49 : {
50 0 : if (info_block)
51 0 : delete[]info_block;
52 0 : info_block = 0;
53 0 : }
54 :
55 :
56 : /**
57 : * 문서정보를 읽어들이는 함수 ( 128 bytes )
58 : * 문서정보는 파일인식정보( 30 bytes ) 다음에 위치한 정보이다.
59 : */
60 0 : bool HWPInfo::Read(HWPFile & hwpf)
61 : {
62 0 : hwpf.Read2b(&cur_col, 1); /* 문서를 저장할 당시의 커서가 위치한 문단번호 */
63 0 : hwpf.Read2b(&cur_row, 1); /* 문단 칸 */
64 :
65 0 : hwpf.Read1b(&paper.paper_kind, 1); /* 용지 종류 */
66 0 : hwpf.Read1b(&paper.paper_direction, 1); /* 용지 방향 */
67 :
68 : // paper geometry information
69 0 : paper.paper_height = (short) hwpf.Read2b(); /* 용지 길이 */
70 0 : paper.paper_width = (short) hwpf.Read2b(); /* 용지 너비 */
71 0 : paper.top_margin = (short) hwpf.Read2b(); /* 위쪽 여백 */
72 0 : paper.bottom_margin = (short) hwpf.Read2b(); /* 아래쪽 여백 */
73 0 : paper.left_margin = (short) hwpf.Read2b(); /* 왼쪽 여백 */
74 0 : paper.right_margin = (short) hwpf.Read2b(); /* 오른쪽 여백 */
75 0 : paper.header_length = (short) hwpf.Read2b(); /* 머리말 길이 */
76 0 : paper.footer_length = (short) hwpf.Read2b(); /* 꼬리말 길이 */
77 0 : paper.gutter_length = (short) hwpf.Read2b(); /* 제본여백 */
78 0 : hwpf.Read2b(&readonly, 1); /* 예약 */
79 0 : hwpf.Read1b(reserved1, 4); /* 예약 */
80 0 : hwpf.Read1b(&chain_info.chain_page_no, 1); /* 쪽 번호 연결 1-연결, 0-새로시작 (연결인쇄에서 사용) */
81 0 : hwpf.Read1b(&chain_info.chain_footnote_no, 1);/* 각주번호 연결 1-연결 0-새로시작 */
82 : /* 연결인쇄할 파일의 이름 */
83 0 : hwpf.Read1b(chain_info.chain_filename, CHAIN_MAX_PATH);
84 :
85 0 : hwpf.Read1b(annotation, ANNOTATION_LEN); /* 덧붙이는 말 ( 파일 저장할 때 덧붙이는 말에 지정한 내용 ) */
86 0 : hwpf.Read2b(&encrypted, 1); /* 암호 여부 0-보통파일, 그외-암호걸린 파일 */
87 : //hwpf.Read1b(reserved2, 6); /* 아래 3개의값으로 바뀌었다. */
88 0 : hwpf.Read2b(&beginpagenum,1); /* 페이지시작번호 */
89 :
90 : // footnote
91 0 : hwpf.Read2b(&beginfnnum,1); /* 각주 시작번호 */
92 0 : hwpf.Read2b(&countfn,1); /* 각주 갯수 */
93 0 : splinetext = (short) hwpf.Read2b();
94 0 : splinefn = (short) hwpf.Read2b();
95 0 : spfnfn = (short) hwpf.Read2b();
96 0 : hwpf.Read1b(&fnchar, 1);
97 0 : hwpf.Read1b(&fnlinetype, 1);
98 : // border layout
99 0 : for (int ii = 0; ii < 4; ++ii)
100 0 : bordermargin[ii] = (short) hwpf.Read2b();
101 0 : hwpf.Read2b(&borderline, 1);
102 :
103 0 : hwpf.Read1b(&empty_line_hide, 1);
104 0 : hwpf.Read1b(&table_move, 1);
105 0 : hwpf.Read1b(&compressed, 1);
106 :
107 0 : hwpf.Read1b(&reserved3, 1);
108 :
109 0 : hwpf.Read2b(&info_block_len, 1);
110 0 : if (hwpf.State())
111 0 : return false;
112 :
113 : /* 문서 요약을 읽는다. */
114 0 : if (!summary.Read(hwpf))
115 0 : return false;
116 0 : if (info_block_len > 0)
117 : {
118 0 : info_block = new unsigned char[info_block_len + 1];
119 :
120 0 : if (0 == info_block ||
121 0 : !HWPReadInfoBlock(info_block, info_block_len, hwpf))
122 0 : return false;
123 : }
124 :
125 : /* hwpf의 값을 재설정 한다. */
126 0 : hwpf.compressed = compressed ? true : false;
127 0 : hwpf.encrypted = encrypted ? true : false;
128 0 : hwpf.info_block_len = info_block_len;
129 0 : hwpf.SetCompressed(hwpf.compressed);
130 :
131 0 : return (!hwpf.State());
132 : }
133 :
134 :
135 : // Document Summary
136 :
137 0 : bool HWPSummary::Read(HWPFile & hwpf)
138 : {
139 0 : hwpf.Read2b(title, 56);
140 0 : hwpf.Read2b(subject, 56);
141 0 : hwpf.Read2b(author, 56);
142 0 : hwpf.Read2b(date, 56);
143 0 : hwpf.Read2b(keyword[0], 56);
144 0 : hwpf.Read2b(keyword[1], 56);
145 0 : hwpf.Read2b(etc[0], 56);
146 0 : hwpf.Read2b(etc[1], 56);
147 0 : hwpf.Read2b(etc[2], 56);
148 :
149 0 : return (!hwpf.State());
150 : }
151 :
152 :
153 0 : bool ParaShape::Read(HWPFile & hwpf)
154 : {
155 0 : pagebreak = 0;
156 0 : left_margin = (short) hwpf.Read2b();
157 0 : right_margin = (short) hwpf.Read2b();
158 0 : indent = (short) hwpf.Read2b();
159 0 : lspacing = (short) hwpf.Read2b();
160 0 : pspacing_next = (short) hwpf.Read2b();
161 :
162 0 : hwpf.Read1b(&condense, 1);
163 0 : hwpf.Read1b(&arrange_type, 1);
164 0 : for (int ii = 0; ii < MAXTABS; ii++)
165 : {
166 0 : hwpf.Read1b(&tabs[ii].type, 1);
167 0 : hwpf.Read1b(&tabs[ii].dot_continue, 1);
168 0 : tabs[ii].position = (short) hwpf.Read2b();
169 : }
170 0 : hwpf.Read1b(&coldef.ncols, 1);
171 0 : hwpf.Read1b(&coldef.separator, 1);
172 0 : coldef.spacing = (short) hwpf.Read2b();
173 0 : coldef.columnlen = (short) hwpf.Read2b();
174 0 : coldef.columnlen0 = (short) hwpf.Read2b();
175 0 : hwpf.Read1b(&shade, 1);
176 0 : hwpf.Read1b(&outline, 1);
177 0 : hwpf.Read1b(&outline_continue, 1);
178 0 : pspacing_prev = (short) hwpf.Read2b();
179 :
180 0 : hwpf.Read1b(reserved, 2);
181 0 : return (!hwpf.State());
182 : }
183 :
184 :
185 0 : bool CharShape::Read(HWPFile & hwpf)
186 : {
187 0 : size = (short) hwpf.Read2b();
188 0 : hwpf.Read1b(font, NLanguage);
189 0 : hwpf.Read1b(ratio, NLanguage);
190 0 : hwpf.Read1b(space, NLanguage);
191 0 : hwpf.Read1b(color, 2);
192 0 : hwpf.Read1b(&shade, 1);
193 0 : hwpf.Read1b(&attr, 1);
194 0 : hwpf.Read1b(reserved, 4);
195 :
196 0 : return (!hwpf.State());
197 : }
198 :
199 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|