fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / hwpfilter / source / hwpread.cxx
blobca8e3ea9e40dad927e2785bde681e17afb311843
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 bool HBox::Read(HWPFile & )
39 // already read
40 return true;
44 // skip block
46 bool 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 bool FieldCode::Read(HWPFile & hwpf)
64 uint size;
65 hchar dummy;
66 uint len1; /* hchar타입의 문자열 테이터 #1의 길이 */
67 uint len2; /* hchar타입의 문자열 테이터 #2의 길이 */
68 uint len3; /* hchar타입의 문자열 테이터 #3의 길이 */
69 uint 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 uint const len1_ = ((len1 > 1024) ? 1024 : len1) / sizeof(hchar);
83 uint const len2_ = ((len2 > 1024) ? 1024 : len2) / sizeof(hchar);
84 uint 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;
117 // book mark(6)
118 bool Bookmark::Read(HWPFile & hwpf)
120 long len;
122 hwpf.Read4b(&len, 1);
123 if (!hwpf.Read2b(dummy))
124 return false;
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 true;
139 // date format(7)
140 bool DateFormat::Read(HWPFile & hwpf)
142 hwpf.Read2b(format, DATE_SIZE);
143 if (!hwpf.Read2b(dummy))
144 return false;
145 if (!(hh == dummy && CH_DATE_FORM == dummy)){
146 return hwpf.SetState(HWP_InvalidFileFormat);
148 return true;
151 // date code(8)
152 bool DateCode::Read(HWPFile & hwpf)
154 hwpf.Read2b(format, DATE_SIZE);
155 hwpf.Read2b(date, 6);
156 if (!hwpf.Read2b(dummy))
157 return false;
158 if (!(hh == dummy && CH_DATE_CODE == dummy)){
159 return hwpf.SetState(HWP_InvalidFileFormat);
161 hwpf.AddDateFormat(this);
162 return true;
165 // tab(9)
166 bool Tab::Read(HWPFile & hwpf)
168 unsigned short tmp16;
169 if (!hwpf.Read2b(tmp16))
170 return false;
171 width = tmp16;
172 if (!hwpf.Read2b(leader))
173 return false;
174 if (!hwpf.Read2b(dummy))
175 return false;
176 if (!(hh == dummy && CH_TAB == dummy)){
177 return hwpf.SetState(HWP_InvalidFileFormat);
179 return true;
182 // tbox(10) TABLE BOX MATH BUTTON HYPERTEXT
183 static void UpdateBBox(FBox * fbox)
185 fbox->boundsy = fbox->pgy;
186 fbox->boundey = fbox->pgy + fbox->ys - 1;
189 void Cell::Read(HWPFile & hwpf)
191 hwpf.Read2b(&p, 1);
192 hwpf.Read2b(&color, 1);
193 hwpf.Read2b(&x, 1);
194 hwpf.Read2b(&y, 1);
195 hwpf.Read2b(&w, 1);
196 hwpf.Read2b(&h, 1);
197 hwpf.Read2b(&txthigh, 1);
198 hwpf.Read2b(&cellhigh, 1);
200 hwpf.Read1b(&flag, 1);
201 hwpf.Read1b(&changed, 1);
202 hwpf.Read1b(&used, 1);
203 hwpf.Read1b(&ver_align, 1);
204 hwpf.Read1b(linetype, 4);
205 hwpf.Read1b(&shade, 1);
206 hwpf.Read1b(&diagonal, 1);
207 hwpf.Read1b(&protect, 1);
211 bool TxtBox::Read(HWPFile & hwpf)
213 int ii, ncell;
215 hwpf.Read2b(reserved, 2);
216 hwpf.Read2b(&dummy, 1);
218 if (!(hh == dummy && CH_TEXT_BOX == dummy)){
219 return hwpf.SetState(HWP_InvalidFileFormat);
221 hwpf.AddBox(this);
222 hwpf.Read2b(&style.cap_len, 1);
223 hwpf.Read2b(&dummy1, 1);
224 hwpf.Read2b(&next, 1);
225 hwpf.Read2b(&dummy2, 1);
227 style.boxnum = fboxnum++;
228 zorder = zindex++;
229 hwpf.Read1b(&style.anchor_type, 1);
230 hwpf.Read1b(&style.txtflow, 1);
231 hwpf.Read2b(&style.xpos, 1);
232 hwpf.Read2b(&style.ypos, 1);
233 hwpf.Read2b(&option, 1);
234 hwpf.Read2b(&ctrl_ch, 1);
235 hwpf.Read2b(style.margin, 12);
236 hwpf.AddFBoxStyle(&style);
237 hwpf.Read2b(&box_xs, 1);
238 hwpf.Read2b(&box_ys, 1);
239 hwpf.Read2b(&cap_xs, 1);
240 hwpf.Read2b(&cap_ys, 1);
241 hwpf.Read2b(&style.cap_len, 1);
242 hwpf.Read2b(&xs, 1);
243 hwpf.Read2b(&ys, 1);
244 hwpf.Read2b(&cap_margin, 1);
245 hwpf.Read1b(&xpos_type, 1);
246 hwpf.Read1b(&ypos_type, 1);
247 hwpf.Read1b(&smart_linesp, 1);
248 hwpf.Read1b(&reserved1, 1);
249 hwpf.Read2b(&pgx, 1);
250 hwpf.Read2b(&pgy, 1);
251 hwpf.Read2b(&pgno, 1);
252 if( ( pgno +1 ) != hwpf.getCurrentPage() )
253 pgno = sal::static_int_cast<short>(hwpf.getCurrentPage() -1) ;
255 hwpf.Read2b(&showpg, 1);
256 hwpf.Read2b(&cap_pos, 1);
257 hwpf.Read2b(&num, 1);
258 hwpf.Read2b(&dummy3, 1);
259 hwpf.Read2b(&baseline, 1);
260 hwpf.Read2b(&type, 1);
261 hwpf.Read2b(&nCell, 1);
262 hwpf.Read2b(&protect, 1);
263 switch (type)
265 case 0: //table
266 style.boxtype = 'T';
267 break;
268 case 1: // text-box
269 style.boxtype = 'X';
270 break;
271 case 2: // equation
272 style.boxtype = 'E';
273 break;
274 case 3: // button
275 style.boxtype = 'B';
276 break;
277 default: // other
278 style.boxtype = 'O';
279 break;
282 UpdateBBox(this);
284 ncell = NCell();
285 if (!(ncell > 0)){
286 return hwpf.SetState(HWP_InvalidFileFormat);
289 cell = ::comphelper::newArray_null<Cell>(ncell);
290 if (!cell) {
291 return hwpf.SetState(HWP_InvalidFileFormat);
293 for (ii = 0; ii < ncell; ii++)
295 cell[ii].Read(hwpf);
296 cell[ii].key = sal::static_int_cast<unsigned char>(ii);
298 if (ncell == 1)
299 style.cell = &cell[0];
300 plists = ::comphelper::newArray_null< std::list< HWPPara* > >(ncell);
301 if (!plists) {
302 return hwpf.SetState(HWP_InvalidFileFormat);
304 for (ii = 0; ii < ncell; ii++)
305 hwpf.ReadParaList(plists[ii]);
306 // caption
307 hwpf.ReadParaList(caption);
309 if( type == 0 ){ // if table?
310 TCell* *pArr = ::comphelper::newArray_null<TCell *>(ncell);
311 if (!pArr) {
312 return hwpf.SetState(HWP_InvalidFileFormat);
314 Table *tbl = new Table;
315 for( ii = 0 ; ii < ncell; ii++)
317 tbl->columns.insert(cell[ii].x);
318 tbl->columns.insert(cell[ii].x + cell[ii].w);
319 tbl->rows.insert(cell[ii].y);
320 tbl->rows.insert(cell[ii].y + cell[ii].h);
322 for( ii = 0 ; ii < ncell; ii++)
324 TCell *tcell = new TCell;
325 tcell->nColumnIndex = tbl->columns.getIndex(cell[ii].x);
326 tcell->nColumnSpan = tbl->columns.getIndex(cell[ii].x + cell[ii].w) -
327 tcell->nColumnIndex;
328 tcell->nRowIndex = tbl->rows.getIndex(cell[ii].y);
329 tcell->nRowSpan = tbl->rows.getIndex(cell[ii].y + cell[ii].h) -
330 tcell->nRowIndex;
331 tcell->pCell = &cell[ii];
332 pArr[ii] = tcell;
334 TCell *tmp;
335 // Sort by row and column
336 for( ii = 0 ; ii < ncell - 1; ii++ ){
337 for( int jj = ii ; jj < ncell ; jj++){
338 if( pArr[ii]->nRowIndex > pArr[jj]->nRowIndex ){
339 tmp = pArr[ii];
340 pArr[ii] = pArr[jj];
341 pArr[jj] = tmp;
344 for( int kk = ii ; kk > 0 ; kk--){
345 if( ( pArr[kk]->nRowIndex == pArr[kk-1]->nRowIndex ) &&
346 (pArr[kk]->nColumnIndex < pArr[kk-1]->nColumnIndex )){
347 tmp = pArr[kk];
348 pArr[kk] = pArr[kk-1];
349 pArr[kk-1] = tmp;
353 for( ii = 0 ; ii < ncell ; ii++ ){
354 tbl->cells.push_back(pArr[ii]);
356 tbl->box = this;
357 hwpf.AddTable(tbl);
358 m_pTable = tbl;
359 delete[] pArr;
361 else
362 m_pTable = 0L;
364 return !hwpf.State();
368 // picture(11)
369 bool Picture::Read(HWPFile & hwpf)
371 hwpf.Read2b(reserved, 2);
372 hwpf.Read2b(&dummy, 1);
374 if (!(hh == dummy && CH_PICTURE == dummy)){
375 return hwpf.SetState(HWP_InvalidFileFormat);
377 hwpf.AddBox(this);
379 hwpf.Read4b(&follow_block_size, 1);
380 hwpf.Read2b(&dummy1, 1); /* 예약 4바이트 */
381 hwpf.Read2b(&dummy2, 1);
383 style.boxnum = fboxnum++;
384 zorder = zindex++;
385 hwpf.Read1b(&style.anchor_type, 1); /* 기준위치 */
386 hwpf.Read1b(&style.txtflow, 1); /* 그림피함. 0-2(자리차지,투명,어울림) */
387 hwpf.Read2b(&style.xpos, 1); /* 가로위치 : 1 왼쪽, 2오른쪽, 3 가운데, 이외 = 임의 */
388 hwpf.Read2b(&style.ypos, 1); /* 세로위치 : 1 위, 2 아래, 3 가운데, 이외 임의 */
389 hwpf.Read2b(&option, 1); /* 기타옵션 : 테두리,그림반전,등. bit로 저장. */
390 hwpf.Read2b(&ctrl_ch, 1); /* 항상 11 */
391 hwpf.Read2b(style.margin, 12); /* 여백 : [0-2][] out/in/셀,[][0-3] 왼/오른/위/아래 여백 */
392 hwpf.Read2b(&box_xs, 1); /* 박스크기 가로 */
393 hwpf.Read2b(&box_ys, 1); /* 세로 */
394 hwpf.Read2b(&cap_xs, 1); /* 캡션 크기 가로 */
395 hwpf.Read2b(&cap_ys, 1); /* 세로 */
396 hwpf.Read2b(&style.cap_len, 1); /* 길이 */
397 hwpf.Read2b(&xs, 1); /* 전체 크기(박스 크기 + 캡션 + 여백) 가로 */
398 hwpf.Read2b(&ys, 1); /* 세로 */
399 hwpf.Read2b(&cap_margin, 1); /* 캡션 여백 */
400 hwpf.Read1b(&xpos_type, 1);
401 hwpf.Read1b(&ypos_type, 1);
402 hwpf.Read1b(&smart_linesp, 1); /* 줄간격 보호 : 0 미보호, 1 보호 */
403 hwpf.Read1b(&reserved1, 1);
404 hwpf.Read2b(&pgx, 1); /* 실제 계산된 박스 가로 */
405 hwpf.Read2b(&pgy, 1); /* 세로 */
406 hwpf.Read2b(&pgno, 1); /* 페이지 숫자 : 0부터 시작 */
407 hwpf.Read2b(&showpg, 1); /* 박스보여줌 */
408 hwpf.Read2b(&cap_pos, 1); /* 캡션위치 0 - 7 메뉴순서. */
409 hwpf.Read2b(&num, 1); /* 박스번호 0부터 시작해서 매긴일련번호 */
411 hwpf.Read1b(&pictype, 1); /* 그림종류 */
413 unsigned short tmp16;
414 if (!hwpf.Read2b(tmp16)) /* 그림에서 실제 표시를 시작할 위치 가로 */
415 return false;
416 skip[0] = tmp16;
417 if (!hwpf.Read2b(tmp16)) /* 세로 */
418 return false;
419 skip[1] = tmp16;
420 if (!hwpf.Read2b(tmp16)) /* 확대비율 : 0 고정, 이외 퍼센트 단위 가로 */
421 return false;
422 scale[0] = tmp16;
423 if (!hwpf.Read2b(tmp16)) /* 세로 */
424 return false;
425 scale[1] = tmp16;
427 hwpf.Read1b(picinfo.picun.path, 256); /* 그림파일 이름 : 종류가 Drawing이 아닐때. */
428 hwpf.Read1b(reserved3, 9); /* 밝기/명암/그림효과 등 */
430 UpdateBBox(this);
431 if( pictype != PICTYPE_DRAW )
432 style.cell = reserved3;
434 if (follow_block_size != 0)
436 follow = new unsigned char[follow_block_size];
438 hwpf.Read1b(follow, follow_block_size);
439 if (pictype == PICTYPE_DRAW)
441 hmem = new HMemIODev(reinterpret_cast<char *>(follow), follow_block_size);
442 LoadDrawingObjectBlock(this);
443 style.cell = picinfo.picdraw.hdo;
444 delete hmem;
446 hmem = 0;
448 else
450 if ((follow[3] << 24 | follow[2] << 16 | follow[1] << 8 | follow[0]) == 0x269)
452 ishyper = true;
457 if( pictype != 3 )
458 style.boxtype = 'G';
459 else
460 style.boxtype = 'D';
461 hwpf.AddFBoxStyle(&style);
463 // cation
464 hwpf.ReadParaList(caption);
466 return !hwpf.State();
469 // line(15)
470 Line::Line()
471 : FBox(CH_LINE)
472 , dummy(0)
473 , sx(0)
474 , sy(0)
475 , ex(0)
476 , ey(0)
477 , width(0)
478 , shade(0)
479 , color(0)
483 bool Line::Read(HWPFile & hwpf)
485 hwpf.Read2b(reserved, 2);
486 hwpf.Read2b(&dummy, 1);
488 if (!(hh == dummy && CH_LINE == dummy)){
489 return hwpf.SetState(HWP_InvalidFileFormat);
491 hwpf.AddBox(this);
493 style.boxnum = fboxnum++;
494 zorder = zindex++;
495 style.boxtype = 'L';
496 hwpf.Read1b(&reserved2, 8);
497 hwpf.Read1b(&style.anchor_type, 1);
498 hwpf.Read1b(&style.txtflow, 1);
499 hwpf.Read2b(&style.xpos, 1);
500 hwpf.Read2b(&style.ypos, 1);
501 hwpf.Read2b(&option, 1);
502 hwpf.Read2b(&ctrl_ch, 1);
503 hwpf.Read2b(style.margin, 12);
504 hwpf.AddFBoxStyle(&style);
505 hwpf.Read2b(&box_xs, 1);
506 hwpf.Read2b(&box_ys, 1);
507 hwpf.Read2b(&cap_xs, 1);
508 hwpf.Read2b(&cap_ys, 1);
509 hwpf.Read2b(&style.cap_len, 1);
510 hwpf.Read2b(&xs, 1);
511 hwpf.Read2b(&ys, 1);
512 lnnumber = style.boxnum;
513 hwpf.linenumber = 1;
514 hwpf.Read2b(&boundsy, 1);
515 hwpf.Read2b(&boundey, 1);
516 hwpf.Read1b(&boundx, 1);
517 hwpf.Read1b(&draw, 1);
519 hwpf.Read2b(&pgx, 1);
520 hwpf.Read2b(&pgy, 1);
521 hwpf.Read2b(&pgno, 1);
522 hwpf.Read2b(&showpg, 1);
524 hwpf.Read2b(&sx, 1);
525 hwpf.Read2b(&sy, 1);
526 hwpf.Read2b(&ex, 1);
527 hwpf.Read2b(&sy, 1);
528 hwpf.Read2b(&width, 1);
529 hwpf.Read2b(&shade, 1);
530 hwpf.Read2b(&color, 1);
531 style.xpos = width;
533 return !hwpf.State();
536 // hidden(15)
537 Hidden::Hidden()
538 : HBox(CH_HIDDEN)
539 , dummy(0)
543 bool Hidden::Read(HWPFile & hwpf)
545 hwpf.Read2b(reserved, 2);
546 hwpf.Read2b(&dummy, 1);
547 if (!(hh == dummy && CH_HIDDEN == dummy)){
548 return hwpf.SetState(HWP_InvalidFileFormat);
551 hwpf.Read1b(info, 8);
552 hwpf.ReadParaList(plist);
554 return !hwpf.State();
557 // header/footer(16)
558 HeaderFooter::HeaderFooter()
559 : HBox(CH_HEADER_FOOTER)
560 , dummy(0)
561 , type(0)
562 , where(0)
563 , linenumber(0)
564 , m_nPageNumber(0)
568 bool HeaderFooter::Read(HWPFile & hwpf)
570 hwpf.Read2b(reserved, 2);
571 hwpf.Read2b(&dummy, 1);
572 if (!(hh == dummy && CH_HEADER_FOOTER == dummy)){
573 return hwpf.SetState(HWP_InvalidFileFormat);
576 hwpf.Read1b(info, 8);
577 hwpf.Read1b(&type, 1);
578 hwpf.Read1b(&where, 1);
579 lnnumber = 0;
580 hwpf.ReadParaList(plist, CH_HEADER_FOOTER);
581 linenumber = sal::static_int_cast<unsigned char>(lnnumber);
582 m_nPageNumber = hwpf.getCurrentPage();
583 hwpf.setMaxSettedPage();
584 hwpf.AddHeaderFooter(this);
586 return !hwpf.State();
590 // footnote(17)
591 Footnote::Footnote()
592 : HBox(CH_FOOTNOTE)
593 , dummy(0)
594 , number(0)
595 , type(0)
596 , width(0)
600 bool Footnote::Read(HWPFile & hwpf)
602 hwpf.Read2b(reserved, 2);
603 hwpf.Read2b(&dummy, 1);
604 if (!(hh == dummy && CH_FOOTNOTE == dummy)){
605 return hwpf.SetState(HWP_InvalidFileFormat);
608 hwpf.Read1b(info, 8);
609 hwpf.Read2b(&number, 1);
610 hwpf.Read2b(&type, 1);
611 unsigned short tmp16;
612 if (!hwpf.Read2b(tmp16))
613 return false;
614 width = tmp16;
615 hwpf.ReadParaList(plist, CH_FOOTNOTE);
617 return !hwpf.State();
620 // auto number(18)
621 AutoNum::AutoNum()
622 : HBox(CH_AUTO_NUM)
623 , type(0)
624 , number(0)
625 , dummy(0)
629 bool AutoNum::Read(HWPFile & hwpf)
631 hwpf.Read2b(&type, 1);
632 hwpf.Read2b(&number, 1);
633 hwpf.Read2b(&dummy, 1);
635 if (!(hh == dummy)){
636 return hwpf.SetState(HWP_InvalidFileFormat);
638 return !hwpf.State();
642 // new number(19)
643 NewNum::NewNum()
644 : HBox(CH_NEW_NUM)
645 , type(0)
646 , number(0)
647 , dummy(0)
652 bool NewNum::Read(HWPFile & hwpf)
654 hwpf.Read2b(&type, 1);
655 hwpf.Read2b(&number, 1);
656 hwpf.Read2b(&dummy, 1);
658 if (!(hh == dummy)){
659 return hwpf.SetState(HWP_InvalidFileFormat);
661 return !hwpf.State();
664 // show page number (20)
665 ShowPageNum::ShowPageNum()
666 : HBox(CH_SHOW_PAGE_NUM)
667 , where(0)
668 , m_nPageNumber(0)
669 , shape(0)
670 , dummy(0)
674 bool ShowPageNum::Read(HWPFile & hwpf)
676 hwpf.Read2b(&where, 1);
677 hwpf.Read2b(&shape, 1);
678 hwpf.Read2b(&dummy, 1);
680 if (!(hh == dummy)){
681 return hwpf.SetState(HWP_InvalidFileFormat);
683 m_nPageNumber = hwpf.getCurrentPage();
684 hwpf.setMaxSettedPage();
685 hwpf.AddPageNumber(this);
686 return !hwpf.State();
689 /* 홀수쪽시작/감추기 (21) */
690 PageNumCtrl::PageNumCtrl()
691 : HBox(CH_PAGE_NUM_CTRL)
692 , kind(0)
693 , what(0)
694 , dummy(0)
698 bool PageNumCtrl::Read(HWPFile & hwpf)
700 hwpf.Read2b(&kind, 1);
701 hwpf.Read2b(&what, 1);
702 hwpf.Read2b(&dummy, 1);
704 if (!(hh == dummy)){
705 return hwpf.SetState(HWP_InvalidFileFormat);
707 return !hwpf.State();
710 // mail merge(22)
711 MailMerge::MailMerge()
712 : HBox(CH_MAIL_MERGE)
713 , dummy(0)
715 memset(field_name, 0, sizeof(field_name));
718 bool MailMerge::Read(HWPFile & hwpf)
720 hwpf.Read1b(field_name, 20);
721 hwpf.Read2b(&dummy, 1);
723 if (!(hh == dummy)){
724 return hwpf.SetState(HWP_InvalidFileFormat);
726 return !hwpf.State();
729 // char compositon(23)
730 Compose::Compose()
731 : HBox(CH_COMPOSE)
732 , dummy(0)
736 bool Compose::Read(HWPFile & hwpf)
738 hwpf.Read2b(compose, 3);
739 hwpf.Read2b(&dummy, 1);
741 if (!(hh == dummy)){
742 return hwpf.SetState(HWP_InvalidFileFormat);
744 return !hwpf.State();
747 // hyphen(24)
748 Hyphen::Hyphen()
749 : HBox(CH_HYPHEN)
750 , width(0)
751 , dummy(0)
755 bool Hyphen::Read(HWPFile & hwpf)
757 hwpf.Read2b(&width, 1);
758 hwpf.Read2b(&dummy, 1);
760 if (!(hh == dummy)){
761 return hwpf.SetState(HWP_InvalidFileFormat);
763 return !hwpf.State();
767 // toc mark(25)
768 TocMark::TocMark()
769 : HBox(CH_TOC_MARK)
770 , kind(0)
771 , dummy(0)
776 bool TocMark::Read(HWPFile & hwpf)
778 hwpf.Read2b(&kind, 1);
779 hwpf.Read2b(&dummy, 1);
781 if (!(hh == dummy)){
782 return hwpf.SetState(HWP_InvalidFileFormat);
784 return !hwpf.State();
787 // index mark(26)
788 IndexMark::IndexMark()
789 : HBox(CH_INDEX_MARK)
790 , pgno(0)
791 , dummy(0)
793 memset(keyword1, 0, sizeof(keyword1));
794 memset(keyword2, 0, sizeof(keyword2));
797 bool IndexMark::Read(HWPFile & hwpf)
799 hwpf.Read2b(&keyword1, 60);
800 hwpf.Read2b(&keyword2, 60);
801 hwpf.Read2b(&pgno, 1);
802 hwpf.Read2b(&dummy, 1);
804 if (!(hh == dummy)){
805 return hwpf.SetState(HWP_InvalidFileFormat);
807 return !hwpf.State();
810 // outline(28)
811 Outline::Outline()
812 : HBox(CH_OUTLINE)
813 , kind(0)
814 , shape(0)
815 , level(0)
816 , dummy(0)
820 bool Outline::Read(HWPFile & hwpf)
822 hwpf.Read2b(&kind, 1);
823 hwpf.Read1b(&shape, 1);
824 hwpf.Read1b(&level, 1);
825 hwpf.Read2b(number, 7);
826 hwpf.Read2b(user_shape, 7);
827 hwpf.Read2b(deco, 14);
828 hwpf.Read2b(&dummy, 1);
830 if (!(hh == dummy)){
831 return hwpf.SetState(HWP_InvalidFileFormat);
833 return !hwpf.State();
837 /* 묶음 빈칸(30) */
838 KeepSpace::KeepSpace()
839 : HBox(CH_KEEP_SPACE)
840 , dummy(0)
845 bool KeepSpace::Read(HWPFile & hwpf)
847 hwpf.Read2b(&dummy, 1);
849 if (!(hh == dummy)){
850 return hwpf.SetState(HWP_InvalidFileFormat);
852 return !hwpf.State();
856 /* 고정폭 빈칸(31) */
857 FixedSpace::FixedSpace()
858 : HBox(CH_FIXED_SPACE)
859 , dummy(0)
864 bool FixedSpace::Read(HWPFile & hwpf)
866 hwpf.Read2b(&dummy, 1);
868 if (!(hh == dummy)){
869 return hwpf.SetState(HWP_InvalidFileFormat);
871 return !hwpf.State();
874 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */