1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
40 * The HBox class is the base class for all date classes in hwp document.
41 * For example, there are special character, table, image, etc.
42 * It has one character. The ascii code value of special characters are smaller than 32. General character is greater than 32.
44 * @short Base class for characters
52 * Construct a HBox object with parameter hch.
53 * @param hch 16bit character being able to have Korean character.
58 * @returns The Size of HBox object
62 * @returns The Height of HBox object as hunit value.
64 virtual hunit
Height(CharShape
*csty
);
66 * Read properties from HIODevice object like stream, file, memory.
68 * @param hwpf HWPFile Object having all information for a hwp file.
69 * @returns True if reading from stream is successful.
71 virtual int Read(HWPFile
&hwpf
);
73 virtual hchar_string
GetString();
79 * @short Class for saving data to be skipped.
81 struct SkipData
: public HBox
89 virtual int Read(HWPFile
&hwpf
);
92 struct FieldCode
: public HBox
94 uchar type
[2]; /* 2/0 - °è»ê½Ä, 3/0-¹®¼¿ä¾à, 3/1-°³ÀÎÁ¤º¸, 3/2-¸¸µç³¯Â¥, 4/0-´©¸§Æ² */
96 unsigned short location_info
; /* 0 - ³¡ÄÚµå, 1 - ½ÃÀÛÄÚµå */
106 virtual ~FieldCode();
107 virtual int Read(HWPFile
&hwpf
);
119 #define BMK_COMMENT_LEN 15
122 * @short Class for BOOKMARK
124 struct Bookmark
: public HBox
127 hchar id
[BMK_COMMENT_LEN
+ 1];
132 virtual int Read(HWPFile
&hwpf
);
136 const int DATE_SIZE
= 40;
139 * @short Class for saving date format made by user
141 struct DateFormat
: public HBox
143 hchar format
[DATE_SIZE
];
147 virtual int Read(HWPFile
&hwpf
);
151 * @short Class for current date and time with specified format.
153 struct DateCode
: public HBox
157 YEAR
, MONTH
, WEEK
, DAY
, HOUR
, MIN
160 hchar format
[DATE_SIZE
];
162 * year/month/week/day/hour/minute
169 virtual int Read(HWPFile
&hwpf
);
171 virtual hchar_string
GetString();
177 struct Tab
: public HBox
180 unsigned short leader
;
184 virtual int Read(HWPFile
&hwpf
);
187 // tbox(10) TABLE BOX MATH BUTTON HYPERTEXT
189 enum ttype
{ TBL_TYPE
, TXT_TYPE
, EQU_TYPE
, BUTTON_TYPE
, HYPERTEXT_TYPE
};
190 enum /* TxtBox->margin[n][?] */
194 enum /* TxtBox->margin[?][n] */
198 enum anchor
{ CHAR_ANCHOR
, PARA_ANCHOR
, PAGE_ANCHOR
, PAPER_ANCHOR
};
199 enum { TF_OCCUPY_SPACE
, TF_TRANSPARENT
,TF_ARROUND_TEXT
};
202 CAP_OUT_BOT
, CAP_OUT_TOP
, CAP_IN_BOT
, CAP_IN_TOP
,
203 CAP_LEFT_BOT
, CAP_LEFT_TOP
, CAP_RIGHT_BOT
, CAP_RIGHT_TOP
,
208 * Definitions for frame's common 'option' member.
210 #define DRAW_FRAME 1 /* <-> no frame, bit 0 */
211 #define NORMAL_PIC 2 /* <-> reverse, bit 1 */
212 #define FIT_TO_COLUMN 4 /* fig_xs is columnlen */
213 #define UNKNOWN_FILE 8 /* need check reverse for pcx mono */
214 #define HYPERTEXT_FLAG 16
215 #define UNKNOWN_SIZE 32
216 #define FOPT_TEMP_BIT 0x00010000 /* temporary starts from 16th bits */
221 unsigned char top
; // 0 - ¶óÀξøÀ½, 1-single, 2-thick, 3-double
222 unsigned char bottom
;
225 short color
; // cell color
226 unsigned char shade
; // <100%
229 * A cell has four properties to specify the position for itself in hwp.
230 * @li xpos - distance between left border of cell and left border of table
231 * @li ypos - distance between top border of cell and top border of table
232 * @li width - distance between left border of cell and right border of cell
233 * @li height - distance between top border of cell and bottom border of table
234 * This is differ from the format of other office in fact cell has two properties
235 * - rowindex and column index.
241 unsigned char key
; // Index value of border style
243 short color
; // cell color
244 short x
, y
; // [x,y] cell pos
245 short w
, h
; // [x,y] cell size
246 short txthigh
, cellhigh
; // used maximum
247 unsigned char flag
, changed
, used
; // unused(file)
248 unsigned char ver_align
; // vertical align {1=center}
249 unsigned char linetype
[4]; // [left,right,top,bottom]
250 unsigned char shade
; // <100%
251 unsigned char diagonal
; // { 0=none,\=1,/=2,X=3}
252 unsigned char protect
;
254 void Read( HWPFile
&hwpf
);
258 * @short Style for floating object
263 * Anchor type : paragraph , page, char
265 unsigned char anchor_type
;
269 unsigned char txtflow
; /* ±×¸²ÇÇÇÔ. 0-2(ÀÚ¸®Â÷Áö,Åõ¸í,¾î¿ï¸²) */
271 * Horizontal alignment
273 short xpos
; // left, right, center, xx
277 short ypos
; // page top, bottom, yy
279 * Every margin of border
280 * [0-2][] : out/in/cell margin
281 * [][0-3] : left/right/top/bottom
283 short margin
[3][4]; // out : left, right, top, bottom
285 * Index of floating object
287 short boxnum
; /* ½ºÅ¸¿ÀÇǽº¿¡¼ ½ºÅ¸ÀÏ À̸§À¸·Î »ç¿ëµÉ ¼ýÀÚ */
289 * Type of floating object : line, txtbox, image, table, equalizer and button
291 unsigned char boxtype
; // (L)ine, t(X)tbox, Picture - (G)
292 short cap_len
; /* ĸ¼ÇÀÇ ±æÀÌ */
299 * This object is for floating object like table, image, line and so on.
301 * @short floating object
303 struct FBox
: public HBox
306 short option
; // draw frame
310 short box_xs
, box_ys
;
311 short cap_xs
, cap_ys
;
312 short xs
, ys
; // ys = fig_ys + cap_ys + margin
313 // xs = fig_xs + cap_xs + margin
315 char xpos_type
, ypos_type
;
316 unsigned char smart_linesp
;
318 /* ÀÌ ÀÚ·á´Â tbox³ª pic¿¡¼´Â ÆÄÀÏ¿¡ ±â·ÏÇÏÁö ¾Ê°í ½ÇÇà½Ã¸¸ ÀÖÀ¸¸ç,
319 line¿¡¼´Â ÆÄÀÏ¿¡ ±â·ÏÇÑ´Ù.
321 short boundsy
, boundey
;
322 unsigned char boundx
, draw
;
325 * Physical x,y position.
327 short pgx
, pgy
; // physical xpos, ypos
328 short pgno
, showpg
; // pageno where code is
338 * The TxtBox class saves object properties about table, textbox, equalizer or button
340 struct TxtBox
: public FBox
345 short dummy1
; // to not change structure size */
348 short dummy2
; // to not change structure size */
349 unsigned char reserved1
;
353 short cap_pos
; // caption pos
354 short num
; // numbering
357 short baseline
; //(for equ)
360 * The value of type indicates as the below: zero is table, one is
361 * textbox, two is equalizer and three is button.
363 short type
; // 0-table, 1-textbox, 2-¼ö½Ä, 3-button
365 * nCell is greater than one only for table, otherwise it is 1.
367 short nCell
; //:=1 offset 80
369 * If value of protect is 1, size of cell cann't change.
371 short protect
; //1=size lock
378 std::list
<HWPPara
*> *plists
;
382 std::list
<HWPPara
*> caption
;
388 * @returns Count of cell.
390 virtual int NCell() { return nCell
; }
392 * This is one of table, text-box, equalizer and button
393 * @returns Type of this object.
395 virtual int Type() { return type
; }
397 virtual int Read(HWPFile
&hwpf
);
399 virtual hunit
Height(CharShape
*csty
);
402 #define ALLOWED_GAP 5
404 #define ADD_AMOUNT 10
414 data
= new int[nTotal
];
416 ~Columns(){ delete[] data
; }
418 void AddColumnsSize(){
420 if (nTotal
+ ADD_AMOUNT
< nTotal
) // overflow
422 throw ::std::bad_alloc();
424 data
= new int[nTotal
+ ADD_AMOUNT
];
425 for (size_t i
= 0 ; i
< nTotal
; i
++)
427 nTotal
+= ADD_AMOUNT
;
431 void insert(int pos
){
433 data
[nCount
++] = pos
;
436 for (size_t i
= 0 ; i
< nCount
; i
++ ) {
437 if( pos
< data
[i
] + ALLOWED_GAP
&& pos
> data
[i
] - ALLOWED_GAP
)
438 return; // Already exist;
440 if( nCount
== nTotal
)
442 for (size_t j
= nCount
; j
> i
; j
--)
450 if( nCount
== nTotal
)
452 data
[nCount
++] = pos
;
455 int getIndex(int pos
)
459 for (size_t i
= 0 ; i
< nCount
; i
++) {
460 if( pos
< data
[i
] + ALLOWED_GAP
&& pos
> data
[i
] - ALLOWED_GAP
)
475 data
= new int[nTotal
];
477 ~Rows(){ delete[] data
; }
481 if (nTotal
+ ADD_AMOUNT
< nTotal
) // overflow
483 throw ::std::bad_alloc();
485 data
= new int[nTotal
+ ADD_AMOUNT
];
486 for (size_t i
= 0 ; i
< nTotal
; i
++)
488 nTotal
+= ADD_AMOUNT
;
492 void insert(int pos
){
494 data
[nCount
++] = pos
;
497 for (size_t i
= 0 ; i
< nCount
; i
++) {
498 if( pos
< data
[i
] + ALLOWED_GAP
&& pos
> data
[i
] - ALLOWED_GAP
)
499 return; // Already exist;
501 if( nCount
== nTotal
)
503 for (size_t j
= nCount
; j
> i
; j
--)
511 if( nCount
== nTotal
)
513 data
[nCount
++] = pos
;
516 int getIndex(int pos
)
520 for (size_t i
= 0 ; i
< nCount
; i
++) {
521 if( pos
< data
[i
] + ALLOWED_GAP
&& pos
> data
[i
] - ALLOWED_GAP
)
541 std::list
<TCell
*>::iterator it
= cells
.begin();
542 for( ; it
!= cells
.end(); ++it
)
547 std::list
<TCell
*> cells
;
551 /* picture (11) ±×¸², OLE±×¸², »ðÀԱ׸², ±×¸®±â */
554 PICTYPE_FILE
, PICTYPE_OLE
, PICTYPE_EMBED
,
555 PICTYPE_DRAW
, PICTYPE_UNKNOWN
558 * @short External image file
568 * @short Embeded image file
576 * @short Win32 ole object
585 * @short Drawing object of hwp
596 * @short For using common case
606 PicDefEmbed picembed
;
612 #define PIC_INFO_LEN 348
614 * There are four kinds of image.
617 * @li Win32 ole object
618 * @li Drawing object of hwp
620 * @short Image object
622 struct Picture
: public FBox
627 * follow_block_size is the size information of the Drawing object of hwp.
628 * It's value is greater than 0 if the pictype is PICTYPE_DRAW.
630 ulong follow_block_size
; /* Ãß°¡Á¤º¸ ±æÀÌ. */
631 short dummy1
; // to not change structure size */
632 short dummy2
; // to not change structure size */
635 * Position of caption
637 short cap_pos
; // caption pos
639 * Index of current Picture object
641 short num
; // numbering
644 * Type of this object
645 * It is one of external/ole/embeded/drawing picture
650 * Ratio of magnification or reduction.
656 std::list
<HWPPara
*> caption
;
658 * It's for the Drawing object
660 unsigned char *follow
; /* ±×¸²Á¾·ù°¡ drawingÀ϶§, Ãß°¡Á¤º¸. */
668 virtual int Read (HWPFile
&hwpf
);
670 virtual hunit
Height (CharShape
*sty
);
677 struct Line
: public FBox
684 short sx
, sy
, ex
, ey
;
685 short width
, shade
, color
;
689 virtual int Read(HWPFile
&hwpf
);
694 * @short Hidden section
696 struct Hidden
: public HBox
701 unsigned char info
[8]; // h, next, dummy
702 std::list
<HWPPara
*> plist
;
707 virtual int Read(HWPFile
&hwpf
);
711 * @short Header or footer
713 struct HeaderFooter
: public HBox
718 unsigned char info
[8];
724 unsigned char linenumber
;
726 unsigned int m_nPageNumber
;
729 * Paragraph list of header or footer
731 std::list
<HWPPara
*> plist
;
734 virtual ~HeaderFooter();
736 virtual int Read(HWPFile
&hwpf
);
740 * 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.
741 * @short Footnote or endnote
743 struct Footnote
: public HBox
748 unsigned char info
[8];
750 * The number of current footnote/endnote
752 unsigned short number
;
754 * Set the type of Footnote either footnote or endnote.
758 * The width of the Footnote object.
762 * Paragraph list of Footnote objects
764 std::list
<HWPPara
*> plist
;
769 virtual int Read(HWPFile
&hwpf
);
774 * Kind of auto input number
787 * @short Input current index of page,comment,table and picture.
789 struct AutoNum
: public HBox
792 unsigned short number
;
797 virtual int Read(HWPFile
&hwpf
);
801 * @short Input new number as current index of page,comment,table and picture.
803 struct NewNum
: public HBox
806 unsigned short number
;
811 virtual int Read(HWPFile
&hwpf
);
816 * @short Input page index in footer or header
818 struct ShowPageNum
: public HBox
821 * Location of page number to be inserted.
823 unsigned short where
;
824 unsigned int m_nPageNumber
;
826 * Shape of page number to be inserted.
828 unsigned short shape
;
833 virtual int Read(HWPFile
&hwpf
);
836 /* Ȧ¼öÂʽÃÀÛ (21) */
837 #define HIDE_HD 1 /* bit 0 */
838 #define HIDE_FT 2 /* bit 1 */
839 #define HIDE_PGNUM 4 /* bit 2 */
840 #define HIDE_FRAME 8 /* bit 3 */
842 * Controls the display of page number, header, footer and border.
844 struct PageNumCtrl
: public HBox
858 virtual int Read(HWPFile
&hwpf
);
863 * Generates the mailing list automatically using address book and mail body format.
864 * @short Generates mailing list
866 struct MailMerge
: public HBox
868 unsigned char field_name
[20];
873 virtual int Read(HWPFile
&hwpf
);
874 virtual hchar_string
GetString();
877 // char compositon(23)
879 * The compose struct displays characters at position. The maximum character count for composition is three.
880 * @short Composition several characters
882 struct Compose
: public HBox
889 virtual int Read(HWPFile
&hwpf
);
896 struct Hyphen
: public HBox
906 virtual int Read(HWPFile
&hwpf
);
911 * The TocMark class is for making the content of a table.
912 * When you set TocMark on current position, hwp makes it as toc automatically.
913 * @short Table of contents
915 struct TocMark
: public HBox
922 virtual int Read(HWPFile
&hwpf
);
927 * IndexMark marks the table of search.
928 * If you set IndexMark at current position, hwp make it as search index.
929 * @short Table of search
931 struct IndexMark
: public HBox
940 virtual int Read(HWPFile
&hwpf
);
944 #define MAX_OUTLINE_LEVEL 7
962 // value is in style->userchar[level];
980 * Number and format of title.
981 * @short Number and format of title
983 class Outline
: public HBox
987 * kind of numbering format
992 * level of number, Ex) The level of 1.3.2.4 is four
998 unsigned short number
[MAX_OUTLINE_LEVEL
];
1002 hchar user_shape
[MAX_OUTLINE_LEVEL
];
1004 * decoration charactor for the level type
1006 hchar deco
[MAX_OUTLINE_LEVEL
][2]; /* »ç¿ëÀÚ Á¤Àǽà ¾ÕµÚ ¹®ÀÚ */
1011 virtual int Read(HWPFile
&hwpf
);
1012 hchar_string
GetUnicode() const;
1017 * The Special space to be treated non-space when a string is
1018 * cut at the end of line
1019 * @short Special space
1021 struct KeepSpace
: public HBox
1027 virtual int Read(HWPFile
&hwpf
);
1030 /* °íÁ¤Æø ºóÄ(31) */
1032 * @short Space with always same width not relation with fonts.
1034 struct FixedSpace
: public HBox
1040 virtual int Read(HWPFile
&hwpf
);
1042 #endif /* _HBOX_H_ */
1044 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */