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 .
31 * The HBox class is the base class for all date classes in hwp document.
32 * For example, there are special character, table, image, etc.
33 * It has one character. The ascii code value of special characters are smaller than 32. General character is greater than 32.
35 * @short Base class for characters
43 * Construct a HBox object with parameter hch.
44 * @param hch 16bit character being able to have Korean character.
49 * @returns The Size of HBox object
53 * @returns The Height of HBox object as hunit value.
55 virtual hunit
Height(CharShape
*csty
);
57 * Read properties from HIODevice object like stream, file, memory.
59 * @param hwpf HWPFile Object having all information for a hwp file.
60 * @returns True if reading from stream is successful.
62 virtual int Read(HWPFile
&hwpf
);
64 virtual hchar_string
GetString();
70 * @short Class for saving data to be skipped.
72 struct SkipData
: public HBox
80 virtual int Read(HWPFile
&hwpf
);
83 struct FieldCode
: public HBox
85 uchar type
[2]; /* 2/0 - °è»ê½Ä, 3/0-¹®¼¿ä¾à, 3/1-°³ÀÎÁ¤º¸, 3/2-¸¸µç³¯Â¥, 4/0-´©¸§Æ² */
87 unsigned short location_info
; /* 0 - ³¡ÄÚµå, 1 - ½ÃÀÛÄÚµå */
98 virtual int Read(HWPFile
&hwpf
);
110 #define BMK_COMMENT_LEN 15
113 * @short Class for BOOKMARK
115 struct Bookmark
: public HBox
118 hchar id
[BMK_COMMENT_LEN
+ 1];
123 virtual int Read(HWPFile
&hwpf
);
127 const int DATE_SIZE
= 40;
130 * @short Class for saving date format made by user
132 struct DateFormat
: public HBox
134 hchar format
[DATE_SIZE
];
138 virtual int Read(HWPFile
&hwpf
);
142 * @short Class for current date and time with specified format.
144 struct DateCode
: public HBox
148 YEAR
, MONTH
, WEEK
, DAY
, HOUR
, MIN
151 hchar format
[DATE_SIZE
];
153 * year/month/week/day/hour/minute
160 virtual int Read(HWPFile
&hwpf
);
162 virtual hchar_string
GetString();
168 struct Tab
: public HBox
171 unsigned short leader
;
175 virtual int Read(HWPFile
&hwpf
);
178 // tbox(10) TABLE BOX MATH BUTTON HYPERTEXT
180 enum ttype
{ TBL_TYPE
, TXT_TYPE
, EQU_TYPE
, BUTTON_TYPE
, HYPERTEXT_TYPE
};
181 enum /* TxtBox->margin[n][?] */
185 enum /* TxtBox->margin[?][n] */
189 enum anchor
{ CHAR_ANCHOR
, PARA_ANCHOR
, PAGE_ANCHOR
, PAPER_ANCHOR
};
190 enum { TF_OCCUPY_SPACE
, TF_TRANSPARENT
,TF_ARROUND_TEXT
};
193 CAP_OUT_BOT
, CAP_OUT_TOP
, CAP_IN_BOT
, CAP_IN_TOP
,
194 CAP_LEFT_BOT
, CAP_LEFT_TOP
, CAP_RIGHT_BOT
, CAP_RIGHT_TOP
,
199 * Definitions for frame's common 'option' member.
201 #define DRAW_FRAME 1 /* <-> no frame, bit 0 */
202 #define NORMAL_PIC 2 /* <-> reverse, bit 1 */
203 #define FIT_TO_COLUMN 4 /* fig_xs is columnlen */
204 #define UNKNOWN_FILE 8 /* need check reverse for pcx mono */
205 #define HYPERTEXT_FLAG 16
206 #define UNKNOWN_SIZE 32
207 #define FOPT_TEMP_BIT 0x00010000 /* temporary starts from 16th bits */
212 unsigned char top
; // 0 - ¶óÀξøÀ½, 1-single, 2-thick, 3-double
213 unsigned char bottom
;
216 short color
; // cell color
217 unsigned char shade
; // <100%
220 * A cell has four properties to specify the position for itself in hwp.
221 * @li xpos - distance between left border of cell and left border of table
222 * @li ypos - distance between top border of cell and top border of table
223 * @li width - distance between left border of cell and right border of cell
224 * @li height - distance between top border of cell and bottom border of table
225 * This is differ from the format of other office in fact cell has two properties
226 * - rowindex and column index.
232 unsigned char key
; // Index value of border style
234 short color
; // cell color
235 short x
, y
; // [x,y] cell pos
236 short w
, h
; // [x,y] cell size
237 short txthigh
, cellhigh
; // used maximum
238 unsigned char flag
, changed
, used
; // unused(file)
239 unsigned char ver_align
; // vertical align {1=center}
240 unsigned char linetype
[4]; // [left,right,top,bottom]
241 unsigned char shade
; // <100%
242 unsigned char diagonal
; // { 0=none,\=1,/=2,X=3}
243 unsigned char protect
;
245 void Read( HWPFile
&hwpf
);
249 * @short Style for floating object
254 * Anchor type : paragraph , page, char
256 unsigned char anchor_type
;
260 unsigned char txtflow
; /* ±×¸²ÇÇÇÔ. 0-2(ÀÚ¸®Â÷Áö,Åõ¸í,¾î¿ï¸²) */
262 * Horizontal alignment
264 short xpos
; // left, right, center, xx
268 short ypos
; // page top, bottom, yy
270 * Every margin of border
271 * [0-2][] : out/in/cell margin
272 * [][0-3] : left/right/top/bottom
274 short margin
[3][4]; // out : left, right, top, bottom
276 * Index of floating object
278 short boxnum
; /* ½ºÅ¸¿ÀÇǽº¿¡¼ ½ºÅ¸ÀÏ À̸§À¸·Î »ç¿ëµÉ ¼ýÀÚ */
280 * Type of floating object : line, txtbox, image, table, equalizer and button
282 unsigned char boxtype
; // (L)ine, t(X)tbox, Picture - (G)
283 short cap_len
; /* ĸ¼ÇÀÇ ±æÀÌ */
290 * This object is for floating object like table, image, line and so on.
292 * @short floating object
294 struct FBox
: public HBox
297 short option
; // draw frame
301 short box_xs
, box_ys
;
302 short cap_xs
, cap_ys
;
303 short xs
, ys
; // ys = fig_ys + cap_ys + margin
304 // xs = fig_xs + cap_xs + margin
306 char xpos_type
, ypos_type
;
307 unsigned char smart_linesp
;
309 /* ÀÌ ÀÚ·á´Â tbox³ª pic¿¡¼´Â ÆÄÀÏ¿¡ ±â·ÏÇÏÁö ¾Ê°í ½ÇÇà½Ã¸¸ ÀÖÀ¸¸ç,
310 line¿¡¼´Â ÆÄÀÏ¿¡ ±â·ÏÇÑ´Ù.
312 short boundsy
, boundey
;
313 unsigned char boundx
, draw
;
316 * Physical x,y position.
318 short pgx
, pgy
; // physical xpos, ypos
319 short pgno
, showpg
; // pageno where code is
329 * The TxtBox class saves object properties about table, textbox, equalizer or button
331 struct TxtBox
: public FBox
336 short dummy1
; // to not change structure size */
339 short dummy2
; // to not change structure size */
340 unsigned char reserved1
;
344 short cap_pos
; // caption pos
345 short num
; // numbering
348 short baseline
; //(for equ)
351 * The value of type indicates as the below: zero is table, one is
352 * textbox, two is equalizer and three is button.
354 short type
; // 0-table, 1-textbox, 2-¼ö½Ä, 3-button
356 * nCell is greater than one only for table, otherwise it is 1.
358 short nCell
; //:=1 offset 80
360 * If value of protect is 1, size of cell cann't change.
362 short protect
; //1=size lock
369 std::list
<HWPPara
*> *plists
;
373 std::list
<HWPPara
*> caption
;
379 * @returns Count of cell.
381 virtual int NCell() { return nCell
; }
383 * This is one of table, text-box, equalizer and button
384 * @returns Type of this object.
386 virtual int Type() { return type
; }
388 virtual int Read(HWPFile
&hwpf
);
390 virtual hunit
Height(CharShape
*csty
);
393 #define ALLOWED_GAP 5
395 #define ADD_AMOUNT 10
405 data
= new int[nTotal
];
407 ~Columns(){ delete[] data
; }
409 void AddColumnsSize(){
411 if (nTotal
+ ADD_AMOUNT
< nTotal
) // overflow
413 throw ::std::bad_alloc();
415 data
= new int[nTotal
+ ADD_AMOUNT
];
416 for (size_t i
= 0 ; i
< nTotal
; i
++)
418 nTotal
+= ADD_AMOUNT
;
422 void insert(int pos
){
424 data
[nCount
++] = pos
;
427 for (size_t i
= 0 ; i
< nCount
; i
++ ) {
428 if( pos
< data
[i
] + ALLOWED_GAP
&& pos
> data
[i
] - ALLOWED_GAP
)
429 return; // Already exist;
431 if( nCount
== nTotal
)
433 for (size_t j
= nCount
; j
> i
; j
--)
441 if( nCount
== nTotal
)
443 data
[nCount
++] = pos
;
446 int getIndex(int pos
)
450 for (size_t i
= 0 ; i
< nCount
; i
++) {
451 if( pos
< data
[i
] + ALLOWED_GAP
&& pos
> data
[i
] - ALLOWED_GAP
)
466 data
= new int[nTotal
];
468 ~Rows(){ delete[] data
; }
472 if (nTotal
+ ADD_AMOUNT
< nTotal
) // overflow
474 throw ::std::bad_alloc();
476 data
= new int[nTotal
+ ADD_AMOUNT
];
477 for (size_t i
= 0 ; i
< nTotal
; i
++)
479 nTotal
+= ADD_AMOUNT
;
483 void insert(int pos
){
485 data
[nCount
++] = pos
;
488 for (size_t i
= 0 ; i
< nCount
; i
++) {
489 if( pos
< data
[i
] + ALLOWED_GAP
&& pos
> data
[i
] - ALLOWED_GAP
)
490 return; // Already exist;
492 if( nCount
== nTotal
)
494 for (size_t j
= nCount
; j
> i
; j
--)
502 if( nCount
== nTotal
)
504 data
[nCount
++] = pos
;
507 int getIndex(int pos
)
511 for (size_t i
= 0 ; i
< nCount
; i
++) {
512 if( pos
< data
[i
] + ALLOWED_GAP
&& pos
> data
[i
] - ALLOWED_GAP
)
532 std::list
<TCell
*>::iterator it
= cells
.begin();
533 for( ; it
!= cells
.end(); ++it
)
538 std::list
<TCell
*> cells
;
542 /* picture (11) ±×¸², OLE±×¸², »ðÀԱ׸², ±×¸®±â */
545 PICTYPE_FILE
, PICTYPE_OLE
, PICTYPE_EMBED
,
546 PICTYPE_DRAW
, PICTYPE_UNKNOWN
549 * @short External image file
559 * @short Embeded image file
567 * @short Win32 ole object
576 * @short Drawing object of hwp
587 * @short For using common case
597 PicDefEmbed picembed
;
603 #define PIC_INFO_LEN 348
605 * There are four kinds of image.
608 * @li Win32 ole object
609 * @li Drawing object of hwp
611 * @short Image object
613 struct Picture
: public FBox
618 * follow_block_size is the size information of the Drawing object of hwp.
619 * It's value is greater than 0 if the pictype is PICTYPE_DRAW.
621 ulong follow_block_size
; /* Ãß°¡Á¤º¸ ±æÀÌ. */
622 short dummy1
; // to not change structure size */
623 short dummy2
; // to not change structure size */
626 * Position of caption
628 short cap_pos
; // caption pos
630 * Index of current Picture object
632 short num
; // numbering
635 * Type of this object
636 * It is one of external/ole/embeded/drawing picture
641 * Ratio of magnification or reduction.
647 std::list
<HWPPara
*> caption
;
649 * It's for the Drawing object
651 unsigned char *follow
; /* ±×¸²Á¾·ù°¡ drawingÀ϶§, Ãß°¡Á¤º¸. */
659 virtual int Read (HWPFile
&hwpf
);
661 virtual hunit
Height (CharShape
*sty
);
668 struct Line
: public FBox
675 short sx
, sy
, ex
, ey
;
676 short width
, shade
, color
;
680 virtual int Read(HWPFile
&hwpf
);
685 * @short Hidden section
687 struct Hidden
: public HBox
692 unsigned char info
[8]; // h, next, dummy
693 std::list
<HWPPara
*> plist
;
698 virtual int Read(HWPFile
&hwpf
);
702 * @short Header or footer
704 struct HeaderFooter
: public HBox
709 unsigned char info
[8];
715 unsigned char linenumber
;
717 unsigned int m_nPageNumber
;
720 * Paragraph list of header or footer
722 std::list
<HWPPara
*> plist
;
725 virtual ~HeaderFooter();
727 virtual int Read(HWPFile
&hwpf
);
731 * Both footnote and endnote are comment. Footnote is located at the end of paragraph; endnote is located at the end of page. The Footnote class represents footnote and endnote.
732 * @short Footnote or endnote
734 struct Footnote
: public HBox
739 unsigned char info
[8];
741 * The number of current footnote/endnote
743 unsigned short number
;
745 * Set the type of Footnote either footnote or endnote.
749 * The width of the Footnote object.
753 * Paragraph list of Footnote objects
755 std::list
<HWPPara
*> plist
;
760 virtual int Read(HWPFile
&hwpf
);
765 * Kind of auto input number
778 * @short Input current index of page,comment,table and picture.
780 struct AutoNum
: public HBox
783 unsigned short number
;
788 virtual int Read(HWPFile
&hwpf
);
792 * @short Input new number as current index of page,comment,table and picture.
794 struct NewNum
: public HBox
797 unsigned short number
;
802 virtual int Read(HWPFile
&hwpf
);
807 * @short Input page index in footer or header
809 struct ShowPageNum
: public HBox
812 * Location of page number to be inserted.
814 unsigned short where
;
815 unsigned int m_nPageNumber
;
817 * Shape of page number to be inserted.
819 unsigned short shape
;
824 virtual int Read(HWPFile
&hwpf
);
827 /* Ȧ¼öÂʽÃÀÛ (21) */
828 #define HIDE_HD 1 /* bit 0 */
829 #define HIDE_FT 2 /* bit 1 */
830 #define HIDE_PGNUM 4 /* bit 2 */
831 #define HIDE_FRAME 8 /* bit 3 */
833 * Controls the display of page number, header, footer and border.
835 struct PageNumCtrl
: public HBox
849 virtual int Read(HWPFile
&hwpf
);
854 * Generates the mailing list automatically using address book and mail body format.
855 * @short Generates mailing list
857 struct MailMerge
: public HBox
859 unsigned char field_name
[20];
864 virtual int Read(HWPFile
&hwpf
);
865 virtual hchar_string
GetString();
868 // char compositon(23)
870 * The compose struct displays characters at position. The maximum character count for composition is three.
871 * @short Composition several characters
873 struct Compose
: public HBox
880 virtual int Read(HWPFile
&hwpf
);
887 struct Hyphen
: public HBox
897 virtual int Read(HWPFile
&hwpf
);
902 * The TocMark class is for making the content of a table.
903 * When you set TocMark on current position, hwp makes it as toc automatically.
904 * @short Table of contents
906 struct TocMark
: public HBox
913 virtual int Read(HWPFile
&hwpf
);
918 * IndexMark marks the table of search.
919 * If you set IndexMark at current position, hwp make it as search index.
920 * @short Table of search
922 struct IndexMark
: public HBox
931 virtual int Read(HWPFile
&hwpf
);
935 #define MAX_OUTLINE_LEVEL 7
953 // value is in style->userchar[level];
971 * Number and format of title.
972 * @short Number and format of title
974 class Outline
: public HBox
978 * kind of numbering format
983 * level of number, Ex) The level of 1.3.2.4 is four
989 unsigned short number
[MAX_OUTLINE_LEVEL
];
993 hchar user_shape
[MAX_OUTLINE_LEVEL
];
995 * decoration character for the level type
997 hchar deco
[MAX_OUTLINE_LEVEL
][2]; /* »ç¿ëÀÚ Á¤Àǽà ¾ÕµÚ ¹®ÀÚ */
1002 virtual int Read(HWPFile
&hwpf
);
1003 hchar_string
GetUnicode() const;
1008 * The Special space to be treated non-space when a string is
1009 * cut at the end of line
1010 * @short Special space
1012 struct KeepSpace
: public HBox
1018 virtual int Read(HWPFile
&hwpf
);
1021 /* °íÁ¤Æø ºóÄ(31) */
1023 * @short Space with always same width not relation with fonts.
1025 struct FixedSpace
: public HBox
1031 virtual int Read(HWPFile
&hwpf
);
1033 #endif /* _HBOX_H_ */
1035 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */