bump product version to 4.1.6.2
[LibreOffice.git] / hwpfilter / source / hwpread.cxx
blobbecdb76773a65227ce18c1084a157846c4c9bd69
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 <comphelper/newarray.hxx>
24 #include <list>
26 #include "hwpfile.h"
27 #include "hbox.h"
28 #include "hpara.h"
29 #include "drawing.h"
30 #include "htags.h"
31 #include "hcode.h"
33 static short fboxnum = 1;
34 static int zindex = 1;
35 static int lnnumber = 0;
37 int HBox::Read(HWPFile & )
39 // already read
40 return 1;
44 // skip block
46 int SkipData::Read(HWPFile & hwpf)
48 hwpf.Read4b(&data_block_len, 1);
49 hwpf.Read2b(&dummy, 1);
51 if (!(IS_SP_SKIP_BLOCK(hh) && (hh == dummy))){
52 return hwpf.SetState(HWP_InvalidFileFormat);
55 data_block = new char[data_block_len];
57 return hwpf.Read1b(data_block, data_block_len);
61 // Field code(5)
62 int FieldCode::Read(HWPFile & hwpf)
64 ulong size;
65 hchar dummy;
66 ulong len1; /* hcharŸÀÔÀÇ ¹®ÀÚ¿­ Å×ÀÌÅÍ #1ÀÇ ±æÀÌ */
67 ulong len2; /* hcharŸÀÔÀÇ ¹®ÀÚ¿­ Å×ÀÌÅÍ #2ÀÇ ±æÀÌ */
68 ulong len3; /* hcharŸÀÔÀÇ ¹®ÀÚ¿­ Å×ÀÌÅÍ #3ÀÇ ±æÀÌ */
69 ulong binlen; /* ÀÓÀÇ Çü½ÄÀÇ ¹ÙÀ̳ʸ® µ¥ÀÌŸ ±æÀÌ */
71 hwpf.Read4b(&size, 1);
72 hwpf.Read2b(&dummy, 1);
73 hwpf.Read1b(&type, 2);
74 hwpf.Read4b(reserved1, 1);
75 hwpf.Read2b(&location_info, 1);
76 hwpf.Read1b(reserved2, 22);
77 hwpf.Read4b(&len1, 1);
78 hwpf.Read4b(&len2, 1);
79 hwpf.Read4b(&len3, 1);
80 hwpf.Read4b(&binlen, 1);
82 ulong const len1_ = ((len1 > 1024) ? 1024 : len1) / sizeof(hchar);
83 ulong const len2_ = ((len2 > 1024) ? 1024 : len2) / sizeof(hchar);
84 ulong const len3_ = ((len3 > 1024) ? 1024 : len3) / sizeof(hchar);
86 str1 = new hchar[len1_ ? len1_ : 1];
87 str2 = new hchar[len2_ ? len2_ : 1];
88 str3 = new hchar[len3_ ? len3_ : 1];
89 bin = new char[binlen];
91 hwpf.Read2b(str1, len1_);
92 hwpf.SkipBlock(len1 - (len1_ * sizeof(hchar)));
93 str1[len1_ ? (len1_ - 1) : 0] = 0;
94 hwpf.Read2b(str2, len2_);
95 hwpf.SkipBlock(len2 - (len2_ * sizeof(hchar)));
96 str2[len2_ ? (len2_ - 1) : 0] = 0;
97 hwpf.Read2b(str3, len3_);
98 hwpf.SkipBlock(len3 - (len3_ * sizeof(hchar)));
99 str3[len3_ ? (len3_ - 1) : 0] = 0;
101 hwpf.ReadBlock(bin, binlen);
103 if( type[0] == 3 && type[1] == 2 ){ /* ¸¸µç³¯Â¥·Î¼­ Æ÷¸ËÀ» »ý¼ºÇØ¾ß ÇÑ´Ù. */
104 DateCode *pDate = new DateCode;
105 for (int i = 0 ; i < static_cast<int>(len3_); i++) {
106 if(str3[i] == 0 ) break;
107 if( i >= DATE_SIZE ) break;
108 pDate->format[i] = str3[i];
110 hwpf.AddDateFormat(pDate);
111 m_pDate = pDate;
114 return true;
118 // book mark(6)
119 int Bookmark::Read(HWPFile & hwpf)
121 long len;
123 hwpf.Read4b(&len, 1);
124 dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
126 if (!(len == 34))// 2 * (BMK_COMMENT_LEN + 1) + 2
128 return hwpf.SetState(HWP_InvalidFileFormat);
130 if (!(hh == dummy && dummy == CH_BOOKMARK)){
131 return hwpf.SetState(HWP_InvalidFileFormat);
134 hwpf.Read2b(id, BMK_COMMENT_LEN + 1);
135 hwpf.Read2b(&type, 1);
136 //return hwpf.Read2b(&type, 1);
137 return 1;
141 // date format(7)
143 int DateFormat::Read(HWPFile & hwpf)
145 hwpf.Read2b(format, DATE_SIZE);
146 dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
147 if (!(hh == dummy && CH_DATE_FORM == dummy)){
148 return hwpf.SetState(HWP_InvalidFileFormat);
150 return true;
154 // date code(8)
156 int DateCode::Read(HWPFile & hwpf)
158 hwpf.Read2b(format, DATE_SIZE);
159 hwpf.Read2b(date, 6);
160 dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
161 if (!(hh == dummy && CH_DATE_CODE == dummy)){
162 return hwpf.SetState(HWP_InvalidFileFormat);
164 hwpf.AddDateFormat(this);
165 return true;
169 // tab(9)
171 int Tab::Read(HWPFile & hwpf)
173 width = hwpf.Read2b();
174 leader = sal::static_int_cast<unsigned short>(hwpf.Read2b());
175 dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
176 if (!(hh == dummy && CH_TAB == dummy)){
177 return hwpf.SetState(HWP_InvalidFileFormat);
179 return true;
183 // tbox(10) TABLE BOX MATH BUTTON HYPERTEXT
185 static void UpdateBBox(FBox * fbox)
187 fbox->boundsy = fbox->pgy;
188 fbox->boundey = fbox->pgy + fbox->ys - 1;
192 void Cell::Read(HWPFile & hwpf)
194 hwpf.Read2b(&p, 1);
195 hwpf.Read2b(&color, 1);
196 hwpf.Read2b(&x, 1);
197 hwpf.Read2b(&y, 1);
198 hwpf.Read2b(&w, 1);
199 hwpf.Read2b(&h, 1);
200 hwpf.Read2b(&txthigh, 1);
201 hwpf.Read2b(&cellhigh, 1);
203 hwpf.Read1b(&flag, 1);
204 hwpf.Read1b(&changed, 1);
205 hwpf.Read1b(&used, 1);
206 hwpf.Read1b(&ver_align, 1);
207 hwpf.Read1b(linetype, 4);
208 hwpf.Read1b(&shade, 1);
209 hwpf.Read1b(&diagonal, 1);
210 hwpf.Read1b(&protect, 1);
214 int TxtBox::Read(HWPFile & hwpf)
216 int ii, ncell;
218 hwpf.Read2b(reserved, 2);
219 hwpf.Read2b(&dummy, 1);
221 if (!(hh == dummy && CH_TEXT_BOX == dummy)){
222 return hwpf.SetState(HWP_InvalidFileFormat);
224 hwpf.AddBox(this);
225 hwpf.Read2b(&style.cap_len, 1);
226 hwpf.Read2b(&dummy1, 1);
227 hwpf.Read2b(&next, 1);
228 hwpf.Read2b(&dummy2, 1);
230 style.boxnum = fboxnum++;
231 zorder = zindex++;
232 hwpf.Read1b(&style.anchor_type, 1);
233 hwpf.Read1b(&style.txtflow, 1);
234 hwpf.Read2b(&style.xpos, 1);
235 hwpf.Read2b(&style.ypos, 1);
236 hwpf.Read2b(&option, 1);
237 hwpf.Read2b(&ctrl_ch, 1);
238 hwpf.Read2b(style.margin, 12);
239 hwpf.AddFBoxStyle(&style);
240 hwpf.Read2b(&box_xs, 1);
241 hwpf.Read2b(&box_ys, 1);
242 hwpf.Read2b(&cap_xs, 1);
243 hwpf.Read2b(&cap_ys, 1);
244 hwpf.Read2b(&style.cap_len, 1);
245 hwpf.Read2b(&xs, 1);
246 hwpf.Read2b(&ys, 1);
247 hwpf.Read2b(&cap_margin, 1);
248 hwpf.Read1b(&xpos_type, 1);
249 hwpf.Read1b(&ypos_type, 1);
250 hwpf.Read1b(&smart_linesp, 1);
251 hwpf.Read1b(&reserved1, 1);
252 hwpf.Read2b(&pgx, 1);
253 hwpf.Read2b(&pgy, 1);
254 hwpf.Read2b(&pgno, 1);
255 if( ( pgno +1 ) != hwpf.getCurrentPage() )
256 pgno = sal::static_int_cast<short>(hwpf.getCurrentPage() -1) ;
258 hwpf.Read2b(&showpg, 1);
259 hwpf.Read2b(&cap_pos, 1);
260 hwpf.Read2b(&num, 1);
261 hwpf.Read2b(&dummy3, 1);
262 hwpf.Read2b(&baseline, 1);
263 hwpf.Read2b(&type, 1);
264 hwpf.Read2b(&nCell, 1);
265 hwpf.Read2b(&protect, 1);
266 switch (type)
268 case 0: //table
269 style.boxtype = 'T';
270 break;
271 case 1: // text-box
272 style.boxtype = 'X';
273 break;
274 case 2: // equation
275 style.boxtype = 'E';
276 break;
277 case 3: // button
278 style.boxtype = 'B';
279 break;
280 default: // other
281 style.boxtype = 'O';
282 break;
285 UpdateBBox(this);
287 ncell = NCell();
288 if (!(ncell > 0)){
289 return hwpf.SetState(HWP_InvalidFileFormat);
292 cell = ::comphelper::newArray_null<Cell>(ncell);
293 if (!cell) {
294 return hwpf.SetState(HWP_InvalidFileFormat);
296 for (ii = 0; ii < ncell; ii++)
298 cell[ii].Read(hwpf);
299 cell[ii].key = sal::static_int_cast<unsigned char>(ii);
301 if (ncell == 1)
302 style.cell = &cell[0];
303 plists = ::comphelper::newArray_null< std::list< HWPPara* > >(ncell);
304 if (!plists) {
305 return hwpf.SetState(HWP_InvalidFileFormat);
307 for (ii = 0; ii < ncell; ii++)
308 hwpf.ReadParaList(plists[ii]);
309 // caption
310 hwpf.ReadParaList(caption);
312 if( type == 0 ){ // if table?
313 TCell* *pArr = ::comphelper::newArray_null<TCell *>(ncell);
314 if (!pArr) {
315 return hwpf.SetState(HWP_InvalidFileFormat);
317 Table *tbl = new Table;
318 for( ii = 0 ; ii < ncell; ii++)
320 tbl->columns.insert(cell[ii].x);
321 tbl->columns.insert(cell[ii].x + cell[ii].w);
322 tbl->rows.insert(cell[ii].y);
323 tbl->rows.insert(cell[ii].y + cell[ii].h);
325 for( ii = 0 ; ii < ncell; ii++)
327 TCell *tcell = new TCell;
328 tcell->nColumnIndex = tbl->columns.getIndex(cell[ii].x);
329 tcell->nColumnSpan = tbl->columns.getIndex(cell[ii].x + cell[ii].w) -
330 tcell->nColumnIndex;
331 tcell->nRowIndex = tbl->rows.getIndex(cell[ii].y);
332 tcell->nRowSpan = tbl->rows.getIndex(cell[ii].y + cell[ii].h) -
333 tcell->nRowIndex;
334 tcell->pCell = &cell[ii];
335 pArr[ii] = tcell;
337 TCell *tmp;
338 // Sort by row and column
339 for( ii = 0 ; ii < ncell - 1; ii++ ){
340 for( int jj = ii ; jj < ncell ; jj++){
341 if( pArr[ii]->nRowIndex > pArr[jj]->nRowIndex ){
342 tmp = pArr[ii];
343 pArr[ii] = pArr[jj];
344 pArr[jj] = tmp;
347 for( int kk = ii ; kk > 0 ; kk--){
348 if( ( pArr[kk]->nRowIndex == pArr[kk-1]->nRowIndex ) &&
349 (pArr[kk]->nColumnIndex < pArr[kk-1]->nColumnIndex )){
350 tmp = pArr[kk];
351 pArr[kk] = pArr[kk-1];
352 pArr[kk-1] = tmp;
356 for( ii = 0 ; ii < ncell ; ii++ ){
357 tbl->cells.push_back(pArr[ii]);
359 tbl->box = this;
360 hwpf.AddTable(tbl);
361 m_pTable = tbl;
362 delete[] pArr;
364 else
365 m_pTable = 0L;
367 return !hwpf.State();
371 // picture(11)
372 int Picture::Read(HWPFile & hwpf)
374 hwpf.Read2b(reserved, 2);
375 hwpf.Read2b(&dummy, 1);
377 if (!(hh == dummy && CH_PICTURE == dummy)){
378 return hwpf.SetState(HWP_InvalidFileFormat);
380 hwpf.AddBox(this);
382 hwpf.Read4b(&follow_block_size, 1);
383 hwpf.Read2b(&dummy1, 1); /* ¿¹¾à 4¹ÙÀÌÆ® */
384 hwpf.Read2b(&dummy2, 1);
386 style.boxnum = fboxnum++;
387 zorder = zindex++;
388 hwpf.Read1b(&style.anchor_type, 1); /* ±âÁØÀ§Ä¡ */
389 hwpf.Read1b(&style.txtflow, 1); /* ±×¸²ÇÇÇÔ. 0-2(ÀÚ¸®Â÷Áö,Åõ¸í,¾î¿ï¸²) */
390 hwpf.Read2b(&style.xpos, 1); /* °¡·ÎÀ§Ä¡ : 1 ¿ÞÂÊ, 2¿À¸¥ÂÊ, 3 °¡¿îµ¥, ÀÌ¿Ü = ÀÓÀÇ */
391 hwpf.Read2b(&style.ypos, 1); /* ¼¼·ÎÀ§Ä¡ : 1 À§, 2 ¾Æ·¡, 3 °¡¿îµ¥, ÀÌ¿Ü ÀÓÀÇ */
392 hwpf.Read2b(&option, 1); /* ±âŸ¿É¼Ç : Å׵θ®,±×¸²¹ÝÀü,µî. bit·Î ÀúÀå. */
393 hwpf.Read2b(&ctrl_ch, 1); /* Ç×»ó 11 */
394 hwpf.Read2b(style.margin, 12); /* ¿©¹é : [0-2][] out/in/¼¿,[][0-3] ¿Þ/¿À¸¥/À§/¾Æ·¡ ¿©¹é */
395 hwpf.Read2b(&box_xs, 1); /* ¹Ú½ºÅ©±â °¡·Î */
396 hwpf.Read2b(&box_ys, 1); /* ¼¼·Î */
397 hwpf.Read2b(&cap_xs, 1); /* ĸ¼Ç Å©±â °¡·Î */
398 hwpf.Read2b(&cap_ys, 1); /* ¼¼·Î */
399 hwpf.Read2b(&style.cap_len, 1); /* ±æÀÌ */
400 hwpf.Read2b(&xs, 1); /* Àüü Å©±â(¹Ú½º Å©±â + ĸ¼Ç + ¿©¹é) °¡·Î */
401 hwpf.Read2b(&ys, 1); /* ¼¼·Î */
402 hwpf.Read2b(&cap_margin, 1); /* ĸ¼Ç ¿©¹é */
403 hwpf.Read1b(&xpos_type, 1);
404 hwpf.Read1b(&ypos_type, 1);
405 hwpf.Read1b(&smart_linesp, 1); /* ÁÙ°£°Ý º¸È£ : 0 ¹Ìº¸È£, 1 º¸È£ */
406 hwpf.Read1b(&reserved1, 1);
407 hwpf.Read2b(&pgx, 1); /* ½ÇÁ¦ °è»êµÈ ¹Ú½º °¡·Î */
408 hwpf.Read2b(&pgy, 1); /* ¼¼·Î */
409 hwpf.Read2b(&pgno, 1); /* ÆäÀÌÁö ¼ýÀÚ : 0ºÎÅÍ ½ÃÀÛ */
410 hwpf.Read2b(&showpg, 1); /* ¹Ú½ºº¸¿©ÁÜ */
411 hwpf.Read2b(&cap_pos, 1); /* ĸ¼ÇÀ§Ä¡ 0 - 7 ¸Þ´º¼ø¼­. */
412 hwpf.Read2b(&num, 1); /* ¹Ú½º¹øÈ£ 0ºÎÅÍ ½ÃÀÛÇؼ­ ¸Å±äÀϷùøÈ£ */
414 hwpf.Read1b(&pictype, 1); /* ±×¸²Á¾·ù */
416 skip[0] = (short) hwpf.Read2b(); /* ±×¸²¿¡¼­ ½ÇÁ¦ Ç¥½Ã¸¦ ½ÃÀÛÇÒ À§Ä¡ °¡·Î */
417 skip[1] = (short) hwpf.Read2b(); /* ¼¼·Î */
418 scale[0] = (short) hwpf.Read2b(); /* È®´ëºñÀ² : 0 °íÁ¤, ÀÌ¿Ü ÆÛ¼¾Æ® ´ÜÀ§ °¡·Î */
419 scale[1] = (short) hwpf.Read2b(); /* ¼¼·Î */
421 hwpf.Read1b(picinfo.picun.path, 256); /* ±×¸²ÆÄÀÏ À̸§ : Á¾·ù°¡ DrawingÀÌ ¾Æ´Ò¶§. */
422 hwpf.Read1b(reserved3, 9); /* ¹à±â/¸í¾Ï/±×¸²È¿°ú µî */
424 UpdateBBox(this);
425 if( pictype != PICTYPE_DRAW )
426 style.cell = reserved3;
428 if (follow_block_size != 0)
430 follow = new unsigned char[follow_block_size];
432 hwpf.Read1b(follow, follow_block_size);
433 if (pictype == PICTYPE_DRAW)
435 hmem = new HMemIODev((char *) follow, follow_block_size);
436 LoadDrawingObjectBlock(this);
437 style.cell = picinfo.picdraw.hdo;
438 delete hmem;
440 hmem = 0;
442 else
444 if ((follow[3] << 24 | follow[2] << 16 | follow[1] << 8 | follow[0]) == 0x269)
446 ishyper = true;
451 if( pictype != 3 )
452 style.boxtype = 'G';
453 else
454 style.boxtype = 'D';
455 hwpf.AddFBoxStyle(&style);
457 // cation
458 hwpf.ReadParaList(caption);
460 return !hwpf.State();
464 // line(15)
466 Line::Line():FBox(CH_LINE)
471 int Line::Read(HWPFile & hwpf)
473 hwpf.Read2b(reserved, 2);
474 hwpf.Read2b(&dummy, 1);
476 if (!(hh == dummy && CH_LINE == dummy)){
477 return hwpf.SetState(HWP_InvalidFileFormat);
479 hwpf.AddBox(this);
481 style.boxnum = fboxnum++;
482 zorder = zindex++;
483 style.boxtype = 'L';
484 hwpf.Read1b(&reserved2, 8);
485 hwpf.Read1b(&style.anchor_type, 1);
486 hwpf.Read1b(&style.txtflow, 1);
487 hwpf.Read2b(&style.xpos, 1);
488 hwpf.Read2b(&style.ypos, 1);
489 hwpf.Read2b(&option, 1);
490 hwpf.Read2b(&ctrl_ch, 1);
491 hwpf.Read2b(style.margin, 12);
492 hwpf.AddFBoxStyle(&style);
493 hwpf.Read2b(&box_xs, 1);
494 hwpf.Read2b(&box_ys, 1);
495 hwpf.Read2b(&cap_xs, 1);
496 hwpf.Read2b(&cap_ys, 1);
497 hwpf.Read2b(&style.cap_len, 1);
498 hwpf.Read2b(&xs, 1);
499 hwpf.Read2b(&ys, 1);
500 lnnumber = style.boxnum;
501 hwpf.linenumber = 1;
502 hwpf.Read2b(&boundsy, 1);
503 hwpf.Read2b(&boundey, 1);
504 hwpf.Read1b(&boundx, 1);
505 hwpf.Read1b(&draw, 1);
507 hwpf.Read2b(&pgx, 1);
508 hwpf.Read2b(&pgy, 1);
509 hwpf.Read2b(&pgno, 1);
510 hwpf.Read2b(&showpg, 1);
512 hwpf.Read2b(&sx, 1);
513 hwpf.Read2b(&sy, 1);
514 hwpf.Read2b(&ex, 1);
515 hwpf.Read2b(&sy, 1);
516 hwpf.Read2b(&width, 1);
517 hwpf.Read2b(&shade, 1);
518 hwpf.Read2b(&color, 1);
519 style.xpos = width;
521 return !hwpf.State();
525 // hidden(15)
526 Hidden::Hidden():HBox(CH_HIDDEN)
531 int Hidden::Read(HWPFile & hwpf)
533 hwpf.Read2b(reserved, 2);
534 hwpf.Read2b(&dummy, 1);
535 if (!(hh == dummy && CH_HIDDEN == dummy)){
536 return hwpf.SetState(HWP_InvalidFileFormat);
539 hwpf.Read1b(info, 8);
540 hwpf.ReadParaList(plist);
542 return !hwpf.State();
546 // header/footer(16)
547 HeaderFooter::HeaderFooter():HBox(CH_HEADER_FOOTER)
549 linenumber = 0;
553 int HeaderFooter::Read(HWPFile & hwpf)
555 hwpf.Read2b(reserved, 2);
556 hwpf.Read2b(&dummy, 1);
557 if (!(hh == dummy && CH_HEADER_FOOTER == dummy)){
558 return hwpf.SetState(HWP_InvalidFileFormat);
561 hwpf.Read1b(info, 8);
562 hwpf.Read1b(&type, 1);
563 hwpf.Read1b(&where, 1);
564 lnnumber = 0;
565 hwpf.ReadParaList(plist, CH_HEADER_FOOTER);
566 linenumber = sal::static_int_cast<unsigned char>(lnnumber);
567 m_nPageNumber = hwpf.getCurrentPage();
568 hwpf.setMaxSettedPage();
569 hwpf.AddHeaderFooter(this);
571 return !hwpf.State();
575 // footnote(17)
576 Footnote::Footnote():HBox(CH_FOOTNOTE)
581 int Footnote::Read(HWPFile & hwpf)
583 hwpf.Read2b(reserved, 2);
584 hwpf.Read2b(&dummy, 1);
585 if (!(hh == dummy && CH_FOOTNOTE == dummy)){
586 return hwpf.SetState(HWP_InvalidFileFormat);
589 hwpf.Read1b(info, 8);
590 hwpf.Read2b(&number, 1);
591 hwpf.Read2b(&type, 1);
592 width = (short) hwpf.Read2b();
593 hwpf.ReadParaList(plist, CH_FOOTNOTE);
595 return !hwpf.State();
599 // auto number(18)
600 AutoNum::AutoNum():HBox(CH_AUTO_NUM)
605 int AutoNum::Read(HWPFile & hwpf)
607 hwpf.Read2b(&type, 1);
608 hwpf.Read2b(&number, 1);
609 hwpf.Read2b(&dummy, 1);
611 if (!(hh == dummy)){
612 return hwpf.SetState(HWP_InvalidFileFormat);
614 return !hwpf.State();
618 // new number(19)
619 NewNum::NewNum():HBox(CH_NEW_NUM)
624 int NewNum::Read(HWPFile & hwpf)
626 hwpf.Read2b(&type, 1);
627 hwpf.Read2b(&number, 1);
628 hwpf.Read2b(&dummy, 1);
630 if (!(hh == dummy)){
631 return hwpf.SetState(HWP_InvalidFileFormat);
633 return !hwpf.State();
637 // show page number (20)
638 ShowPageNum::ShowPageNum():HBox(CH_SHOW_PAGE_NUM)
643 int ShowPageNum::Read(HWPFile & hwpf)
645 hwpf.Read2b(&where, 1);
646 hwpf.Read2b(&shape, 1);
647 hwpf.Read2b(&dummy, 1);
649 if (!(hh == dummy)){
650 return hwpf.SetState(HWP_InvalidFileFormat);
652 m_nPageNumber = hwpf.getCurrentPage();
653 hwpf.setMaxSettedPage();
654 hwpf.AddPageNumber(this);
655 return !hwpf.State();
659 /* Ȧ¼öÂʽÃÀÛ/°¨Ãß±â (21) */
660 PageNumCtrl::PageNumCtrl():HBox(CH_PAGE_NUM_CTRL)
665 int PageNumCtrl::Read(HWPFile & hwpf)
667 hwpf.Read2b(&kind, 1);
668 hwpf.Read2b(&what, 1);
669 hwpf.Read2b(&dummy, 1);
671 if (!(hh == dummy)){
672 return hwpf.SetState(HWP_InvalidFileFormat);
674 return !hwpf.State();
678 // mail merge(22)
679 MailMerge::MailMerge():HBox(CH_MAIL_MERGE)
684 int MailMerge::Read(HWPFile & hwpf)
686 hwpf.Read1b(field_name, 20);
687 hwpf.Read2b(&dummy, 1);
689 if (!(hh == dummy)){
690 return hwpf.SetState(HWP_InvalidFileFormat);
692 return !hwpf.State();
696 // char compositon(23)
697 Compose::Compose():HBox(CH_COMPOSE)
702 int Compose::Read(HWPFile & hwpf)
704 hwpf.Read2b(compose, 3);
705 hwpf.Read2b(&dummy, 1);
707 if (!(hh == dummy)){
708 return hwpf.SetState(HWP_InvalidFileFormat);
710 return !hwpf.State();
714 // hyphen(24)
715 Hyphen::Hyphen():HBox(CH_HYPHEN)
720 int Hyphen::Read(HWPFile & hwpf)
722 hwpf.Read2b(&width, 1);
723 hwpf.Read2b(&dummy, 1);
725 if (!(hh == dummy)){
726 return hwpf.SetState(HWP_InvalidFileFormat);
728 return !hwpf.State();
732 // toc mark(25)
733 TocMark::TocMark():HBox(CH_TOC_MARK)
738 int TocMark::Read(HWPFile & hwpf)
740 hwpf.Read2b(&kind, 1);
741 hwpf.Read2b(&dummy, 1);
743 if (!(hh == dummy)){
744 return hwpf.SetState(HWP_InvalidFileFormat);
746 return !hwpf.State();
750 // index mark(26)
751 IndexMark::IndexMark():HBox(CH_INDEX_MARK)
756 int IndexMark::Read(HWPFile & hwpf)
758 hwpf.Read2b(&keyword1, 60);
759 hwpf.Read2b(&keyword2, 60);
760 hwpf.Read2b(&pgno, 1);
761 hwpf.Read2b(&dummy, 1);
763 if (!(hh == dummy)){
764 return hwpf.SetState(HWP_InvalidFileFormat);
766 return !hwpf.State();
770 // outline(28)
771 Outline::Outline():HBox(CH_OUTLINE)
776 int Outline::Read(HWPFile & hwpf)
778 hwpf.Read2b(&kind, 1);
779 hwpf.Read1b(&shape, 1);
780 hwpf.Read1b(&level, 1);
781 hwpf.Read2b(number, 7);
782 hwpf.Read2b(user_shape, 7);
783 hwpf.Read2b(deco, 14);
784 hwpf.Read2b(&dummy, 1);
786 if (!(hh == dummy)){
787 return hwpf.SetState(HWP_InvalidFileFormat);
789 return !hwpf.State();
793 /* ¹­À½ ºóÄ­(30) */
794 KeepSpace::KeepSpace():HBox(CH_KEEP_SPACE)
799 int KeepSpace::Read(HWPFile & hwpf)
801 hwpf.Read2b(&dummy, 1);
803 if (!(hh == dummy)){
804 return hwpf.SetState(HWP_InvalidFileFormat);
806 return !hwpf.State();
810 /* °íÁ¤Æø ºóÄ­(31) */
811 FixedSpace::FixedSpace():HBox(CH_FIXED_SPACE)
816 int FixedSpace::Read(HWPFile & hwpf)
818 hwpf.Read2b(&dummy, 1);
820 if (!(hh == dummy)){
821 return hwpf.SetState(HWP_InvalidFileFormat);
823 return !hwpf.State();
826 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */