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
60 back_info
.isset
= false;
69 * Function for reading document information (128 bytes)
70 * Document information is the information after the file identification information (30 bytes).
72 void HWPInfo::Read(HWPFile
& hwpf
)
74 hwpf
.Read2b(&cur_col
, 1); /* When a document is saving, the paragraph number where the coursor is */
75 hwpf
.Read2b(&cur_row
, 1); /* Paragraphs rows */
77 hwpf
.Read1b(paper
.paper_kind
); /* Paper Type */
78 hwpf
.Read1b(paper
.paper_direction
); /* Paper orientation */
80 // paper geometry information
82 if (!hwpf
.Read2b(tmp16
))
84 paper
.paper_height
= tmp16
; /* Paper length */
85 if (!hwpf
.Read2b(tmp16
))
87 paper
.paper_width
= tmp16
; /* Sheet width */
88 if (!hwpf
.Read2b(tmp16
))
90 paper
.top_margin
= tmp16
; /* Top margin */
91 if (!hwpf
.Read2b(tmp16
))
93 paper
.bottom_margin
= tmp16
; /* The bottom margin */
94 if (!hwpf
.Read2b(tmp16
))
96 paper
.left_margin
= tmp16
; /* Left Margin */
97 if (!hwpf
.Read2b(tmp16
))
99 paper
.right_margin
= tmp16
; /* Right margins */
100 if (!hwpf
.Read2b(tmp16
))
102 paper
.header_length
= tmp16
; /* Header length */
103 if (!hwpf
.Read2b(tmp16
))
105 paper
.footer_length
= tmp16
; /* Footer length */
106 if (!hwpf
.Read2b(tmp16
))
108 paper
.gutter_length
= tmp16
; /* The binding margin */
109 hwpf
.Read2b(&readonly
, 1); /* Reserve */
110 hwpf
.ReadBlock(reserved1
, 4); /* Reserve */
111 hwpf
.Read1b(chain_info
.chain_page_no
); /* Connect page number: 1-Connect, 0-newly started (used in connection printing) */
112 hwpf
.Read1b(chain_info
.chain_footnote_no
); /* Connect footnote number: 1-connect, 0-newly started*/
113 /* the file name to be printed with connection */
114 hwpf
.ReadBlock(chain_info
.chain_filename
, CHAIN_MAX_PATH
);
116 hwpf
.ReadBlock(annotation
, ANNOTATION_LEN
); /* Annotation (additional information when a file is saving.) */
117 hwpf
.Read2b(&encrypted
, 1); /* encrypt: 0-normal file(without password), 1-protected by password */
118 hwpf
.Read2b(&beginpagenum
,1); /* Page starting number */
121 hwpf
.Read2b(&beginfnnum
,1); /* Footnote start number */
122 hwpf
.Read2b(&countfn
,1); /* Number of footnote */
124 if (!hwpf
.Read2b(tmp16
))
127 if (!hwpf
.Read2b(tmp16
))
130 if (!hwpf
.Read2b(tmp16
))
134 hwpf
.Read1b(fnlinetype
);
136 for (int & ii
: bordermargin
)
138 if (!hwpf
.Read2b(tmp16
))
142 hwpf
.Read2b(&borderline
, 1);
144 hwpf
.Read1b(empty_line_hide
);
145 hwpf
.Read1b(table_move
);
146 hwpf
.Read1b(compressed
);
148 hwpf
.Read1b(reserved3
);
150 hwpf
.Read2b(&info_block_len
, 1);
154 /* Read the article summary. */
155 if (!summary
.Read(hwpf
))
157 if (info_block_len
> 0)
159 info_block
.reset( new unsigned char[info_block_len
+ 1] );
161 if (!HWPReadInfoBlock(info_block
.get(), info_block_len
, hwpf
))
165 /* reset the value of hwpf. */
166 hwpf
.compressed
= compressed
!= 0;
167 hwpf
.encrypted
= encrypted
!= 0;
168 hwpf
.info_block_len
= info_block_len
;
169 hwpf
.SetCompressed(hwpf
.compressed
);
175 bool HWPSummary::Read(HWPFile
& hwpf
)
177 hwpf
.Read2b(title
, 56);
178 hwpf
.Read2b(subject
, 56);
179 hwpf
.Read2b(author
, 56);
180 hwpf
.Read2b(date
, 56);
181 hwpf
.Read2b(keyword
[0], 56);
182 hwpf
.Read2b(keyword
[1], 56);
183 hwpf
.Read2b(etc
[0], 56);
184 hwpf
.Read2b(etc
[1], 56);
185 hwpf
.Read2b(etc
[2], 56);
187 return (!hwpf
.State());
190 ParaShape::ParaShape()
200 , xColdef(new ColumnDef
)
203 , outline_continue(0)
210 void ParaShape::Read(HWPFile
& hwpf
)
213 unsigned short tmp16
;
214 if (!hwpf
.Read2b(tmp16
))
217 if (!hwpf
.Read2b(tmp16
))
219 right_margin
= tmp16
;
220 if (!hwpf
.Read2b(tmp16
))
223 if (!hwpf
.Read2b(tmp16
))
226 if (!hwpf
.Read2b(tmp16
))
228 pspacing_next
= tmp16
;
230 hwpf
.Read1b(condense
);
231 hwpf
.Read1b(arrange_type
);
232 for (TabSet
& tab
: tabs
)
234 hwpf
.Read1b(tab
.type
);
235 hwpf
.Read1b(tab
.dot_continue
);
236 if (!hwpf
.Read2b(tmp16
))
238 tab
.position
= tmp16
;
240 hwpf
.Read1b(xColdef
->ncols
);
241 hwpf
.Read1b(xColdef
->separator
);
242 if (!hwpf
.Read2b(tmp16
))
244 xColdef
->spacing
= tmp16
;
245 if (!hwpf
.Read2b(tmp16
))
247 xColdef
->columnlen
= tmp16
;
248 if (!hwpf
.Read2b(tmp16
))
250 xColdef
->columnlen0
= tmp16
;
252 hwpf
.Read1b(outline
);
253 hwpf
.Read1b(outline_continue
);
254 if (!hwpf
.Read2b(tmp16
))
256 pspacing_prev
= tmp16
;
258 hwpf
.ReadBlock(reserved
, 2);
262 void CharShape::Read(HWPFile
& hwpf
)
264 unsigned short tmp16
;
265 if (!hwpf
.Read2b(tmp16
))
268 hwpf
.ReadBlock(font
, NLanguage
);
269 hwpf
.ReadBlock(ratio
, NLanguage
);
270 hwpf
.ReadBlock(space
, NLanguage
);
271 hwpf
.ReadBlock(color
, 2);
274 hwpf
.ReadBlock(reserved
, 4);
277 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */