1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 /* $Id: hbox.h,v 1.6 2008-06-04 09:56:30 vg Exp $ */
44 * The HBox class is the base class for all date classes in hwp document.
45 * For example, there are special character, table, image, etc.
46 * It has one character. The ascii code value of special characters are smaller than 32. General character is greater than 32.
48 * @short Base class for characters
56 * Construct a HBox object with parameter hch.
57 * @param hch 16bit character being able to have Korean character.
62 * @returns The Size of HBox object
66 * @returns The Height of HBox object as hunit value.
68 virtual hunit
Height(CharShape
*csty
);
70 * Read properties from HIODevice object like stream, file, memory.
72 * @param hwpf HWPFile Object having all information for a hwp file.
73 * @returns True if reading from stream is successful.
75 virtual int Read(HWPFile
&hwpf
);
77 * @param hstr Buffer to save string
78 * @param slen Size of buffer
79 * @returns The string having each proper format by pointer
81 virtual int GetString(hchar
*hstr
, int slen
= 255);
87 * @short Class for saving data to be skipped.
89 struct SkipBlock
: public HBox
97 virtual int Read(HWPFile
&hwpf
);
100 struct FieldCode
: public HBox
102 uchar type
[2]; /* 2/0 - °è»ê½Ä, 3/0-¹®¼¿ä¾à, 3/1-°³ÀÎÁ¤º¸, 3/2-¸¸µç³¯Â¥, 4/0-´©¸§Æ² */
104 unsigned short location_info
; /* 0 - ³¡ÄÚµå, 1 - ½ÃÀÛÄÚµå */
114 virtual ~FieldCode();
115 virtual int Read(HWPFile
&hwpf
);
127 #define BMK_COMMENT_LEN 15
130 * @short Class for BOOKMARK
132 struct Bookmark
: public HBox
135 hchar id
[BMK_COMMENT_LEN
+ 1];
140 virtual int Read(HWPFile
&hwpf
);
144 const int DATE_SIZE
= 40;
147 * @short Class for saving date format made by user
149 struct DateFormat
: public HBox
151 hchar format
[DATE_SIZE
];
155 virtual int Read(HWPFile
&hwpf
);
159 * @short Class for current date and time with specified format.
161 struct DateCode
: public HBox
165 YEAR
, MONTH
, WEEK
, DAY
, HOUR
, MIN
168 hchar format
[DATE_SIZE
];
170 * year/month/week/day/hour/minute
177 virtual int Read(HWPFile
&hwpf
);
179 * @returns Length of date string
181 virtual int GetString(hchar
*hstr
, int slen
= 255);
187 struct Tab
: public HBox
190 unsigned short leader
;
194 virtual int Read(HWPFile
&hwpf
);
197 // tbox(10) TABLE BOX MATH BUTTON HYPERTEXT
199 enum ttype
{ TBL_TYPE
, TXT_TYPE
, EQU_TYPE
, BUTTON_TYPE
, HYPERTEXT_TYPE
};
200 enum /* TxtBox->margin[n][?] */
204 enum /* TxtBox->margin[?][n] */
208 enum anchor
{ CHAR_ANCHOR
, PARA_ANCHOR
, PAGE_ANCHOR
, PAPER_ANCHOR
};
209 enum { TF_OCCUPY_SPACE
, TF_TRANSPARENT
,TF_ARROUND_TEXT
};
212 CAP_OUT_BOT
, CAP_OUT_TOP
, CAP_IN_BOT
, CAP_IN_TOP
,
213 CAP_LEFT_BOT
, CAP_LEFT_TOP
, CAP_RIGHT_BOT
, CAP_RIGHT_TOP
,
218 * Definitions for frame's common 'option' member.
220 #define DRAW_FRAME 1 /* <-> no frame, bit 0 */
221 #define NORMAL_PIC 2 /* <-> reverse, bit 1 */
222 #define FIT_TO_COLUMN 4 /* fig_xs is columnlen */
223 #define UNKNOWN_FILE 8 /* need check reverse for pcx mono */
224 #define HYPERTEXT_FLAG 16
225 #define UNKNOWN_SIZE 32
226 #define FOPT_TEMP_BIT 0x00010000 /* temporary starts from 16th bits */
231 unsigned char top
; // 0 - ¶óÀξøÀ½, 1-single, 2-thick, 3-double
232 unsigned char bottom
;
235 short color
; // cell color
236 unsigned char shade
; // <100%
239 * A cell has four properties to specify the position for itself in hwp.
240 * @li xpos - distance between left border of cell and left border of table
241 * @li ypos - distance between top border of cell and top border of table
242 * @li width - distance between left border of cell and right border of cell
243 * @li height - distance between top border of cell and bottom border of table
244 * This is differ from the format of other office in fact cell has two properties
245 * - rowindex and column index.
251 unsigned char key
; // Index value of border style
253 short color
; // cell color
254 short x
, y
; // [x,y] cell pos
255 short w
, h
; // [x,y] cell size
256 short txthigh
, cellhigh
; // used maximum
257 unsigned char flag
, changed
, used
; // unused(file)
258 unsigned char ver_align
; // vertical align {1=center}
259 unsigned char linetype
[4]; // [left,right,top,bottom]
260 unsigned char shade
; // <100%
261 unsigned char diagonal
; // { 0=none,\=1,/=2,X=3}
262 unsigned char protect
;
264 void Read( HWPFile
&hwpf
);
268 * @short Style for floating object
273 * Anchor type : paragraph , page, char
275 unsigned char anchor_type
;
279 unsigned char txtflow
; /* ±×¸²ÇÇÇÔ. 0-2(ÀÚ¸®Â÷Áö,Åõ¸í,¾î¿ï¸²) */
281 * Horizontal alignment
283 short xpos
; // left, right, center, xx
287 short ypos
; // page top, bottom, yy
289 * Every margin of border
290 * [0-2][] : out/in/cell margin
291 * [][0-3] : left/right/top/bottom
293 short margin
[3][4]; // out : left, right, top, bottom
295 * Index of floating object
297 short boxnum
; /* ½ºÅ¸¿ÀÇǽº¿¡¼ ½ºÅ¸ÀÏ À̸§À¸·Î »ç¿ëµÉ ¼ýÀÚ */
299 * Type of floating object : line, txtbox, image, table, equalizer and button
301 unsigned char boxtype
; // (L)ine, t(X)tbox, Picture - (G)
302 short cap_len
; /* ĸ¼ÇÀÇ ±æÀÌ */
309 * This object is for floating object like table, image, line and so on.
311 * @short floating object
313 struct FBox
: public HBox
316 short option
; // draw frame
320 short box_xs
, box_ys
;
321 short cap_xs
, cap_ys
;
322 short xs
, ys
; // ys = fig_ys + cap_ys + margin
323 // xs = fig_xs + cap_xs + margin
325 char xpos_type
, ypos_type
;
326 unsigned char smart_linesp
;
328 /* ÀÌ ÀÚ·á´Â tbox³ª pic¿¡¼´Â ÆÄÀÏ¿¡ ±â·ÏÇÏÁö ¾Ê°í ½ÇÇà½Ã¸¸ ÀÖÀ¸¸ç,
329 line¿¡¼´Â ÆÄÀÏ¿¡ ±â·ÏÇÑ´Ù.
331 short boundsy
, boundey
;
332 unsigned char boundx
, draw
;
335 * Physical x,y position.
337 short pgx
, pgy
; // physical xpos, ypos
338 short pgno
, showpg
; // pageno where code is
348 * The TxtBox class saves object properties about table, textbox, equalizer or button
350 struct TxtBox
: public FBox
355 short dummy1
; // to not change structure size */
358 short dummy2
; // to not change structure size */
359 unsigned char reserved1
;
363 short cap_pos
; // caption pos
364 short num
; // numbering
367 short baseline
; //(for equ)
370 * The value of type indicates as the below: zero is table, one is
371 * textbox, two is equalizer and three is button.
373 short type
; // 0-table, 1-textbox, 2-¼ö½Ä, 3-button
375 * nCell is greater than one only for table, otherwise it is 1.
377 short nCell
; //:=1 offset 80
379 * If value of protect is 1, size of cell cann't change.
381 short protect
; //1=size lock
388 LinkedList
<HWPPara
> *plists
;
392 LinkedList
<HWPPara
> caption
;
398 * @returns Count of cell.
400 virtual int NCell() { return nCell
; }
402 * This is one of table, text-box, equalizer and button
403 * @returns Type of this object.
405 virtual int Type() { return type
; }
407 virtual int Read(HWPFile
&hwpf
);
409 virtual hunit
Height(CharShape
*csty
);
412 #define ALLOWED_GAP 5
414 #define ADD_AMOUNT 10
424 data
= new int[nTotal
];
426 ~Columns(){ delete[] data
; }
428 void AddColumnsSize(){
430 data
= new int[nTotal
+ ADD_AMOUNT
];
431 for( int i
= 0 ; i
< nTotal
; i
++ )
433 nTotal
+= ADD_AMOUNT
;
437 void insert(int pos
){
439 data
[nCount
++] = pos
;
442 for( int i
= 0 ; i
< nCount
; i
++ ){
443 if( pos
< data
[i
] + ALLOWED_GAP
&& pos
> data
[i
] - ALLOWED_GAP
)
444 return; // Already exist;
446 if( nCount
== nTotal
)
448 for( int j
= nCount
; j
> i
; j
-- )
456 if( nCount
== nTotal
)
458 data
[nCount
++] = pos
;
461 int getIndex(int pos
)
465 for( int i
= 0 ; i
< nCount
; i
++){
466 if( pos
< data
[i
] + ALLOWED_GAP
&& pos
> data
[i
] - ALLOWED_GAP
)
481 data
= new int[nTotal
];
483 ~Rows(){ delete[] data
; }
487 data
= new int[nTotal
+ ADD_AMOUNT
];
488 for( int i
= 0 ; i
< nTotal
; i
++ )
490 nTotal
+= ADD_AMOUNT
;
494 void insert(int pos
){
496 data
[nCount
++] = pos
;
499 for( int i
= 0 ; i
< nCount
; i
++ ){
500 if( pos
< data
[i
] + ALLOWED_GAP
&& pos
> data
[i
] - ALLOWED_GAP
)
501 return; // Already exist;
503 if( nCount
== nTotal
)
505 for( int j
= nCount
; j
> i
; j
-- )
513 if( nCount
== nTotal
)
515 data
[nCount
++] = pos
;
518 int getIndex(int pos
)
522 for( int i
= 0 ; i
< nCount
; i
++){
523 if( pos
< data
[i
] + ALLOWED_GAP
&& pos
> data
[i
] - ALLOWED_GAP
)
543 LinkedListIterator
<TCell
> it(&cells
);
544 for( ; it
.current(); it
++)
549 LinkedList
<TCell
> cells
;
553 /* picture (11) ±×¸², OLE±×¸², »ðÀԱ׸², ±×¸®±â */
556 PICTYPE_FILE
, PICTYPE_OLE
, PICTYPE_EMBED
,
557 PICTYPE_DRAW
, PICTYPE_UNKNOWN
560 * @short External image file
570 * @short Embeded image file
578 * @short Win32 ole object
587 * @short Drawing object of hwp
598 * @short For using common case
608 PicDefEmbed picembed
;
614 #define PIC_INFO_LEN 348
616 * There are four kinds of image.
619 * @li Win32 ole object
620 * @li Drawing object of hwp
622 * @short Image object
624 struct Picture
: public FBox
629 * follow_block_size is the size information of the Drawing object of hwp.
630 * It's value is greater than 0 if the pictype is PICTYPE_DRAW.
632 ulong follow_block_size
; /* Ãß°¡Á¤º¸ ±æÀÌ. */
633 short dummy1
; // to not change structure size */
634 short dummy2
; // to not change structure size */
637 * Position of caption
639 short cap_pos
; // caption pos
641 * Index of current Picture object
643 short num
; // numbering
646 * Type of this object
647 * It is one of external/ole/embeded/drawing picture
652 * Ratio of magnification or reduction.
658 LinkedList
<HWPPara
> caption
;
660 * It's for the Drawing object
662 unsigned char *follow
; /* ±×¸²Á¾·ù°¡ drawingÀ϶§, Ãß°¡Á¤º¸. */
670 virtual int Read (HWPFile
&hwpf
);
672 virtual hunit
Height (CharShape
*sty
);
679 struct Line
: public FBox
686 short sx
, sy
, ex
, ey
;
687 short width
, shade
, color
;
691 virtual int Read(HWPFile
&hwpf
);
696 * @short Hidden section
698 struct Hidden
: public HBox
703 unsigned char info
[8]; // h, next, dummy
704 LinkedList
<HWPPara
> plist
;
709 virtual int Read(HWPFile
&hwpf
);
713 * @short Header or footer
715 struct HeaderFooter
: public HBox
720 unsigned char info
[8];
726 unsigned char linenumber
;
728 unsigned int m_nPageNumber
;
731 * Paragraph list of header or footer
733 LinkedList
<HWPPara
> plist
;
736 virtual ~HeaderFooter();
738 virtual int Read(HWPFile
&hwpf
);
742 * 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.
743 * @short Footnote or endnote
745 struct Footnote
: public HBox
750 unsigned char info
[8];
752 * The number of current footnote/endnote
754 unsigned short number
;
756 * Set the type of Footnote either footnote or endnote.
760 * The width of the Footnote object.
764 * Paragraph list of Footnote objects
766 LinkedList
<HWPPara
> plist
;
771 virtual int Read(HWPFile
&hwpf
);
776 * Kind of auto input number
789 * @short Input current index of page,comment,table and picture.
791 struct AutoNum
: public HBox
794 unsigned short number
;
799 virtual int Read(HWPFile
&hwpf
);
803 * @short Input new number as current index of page,comment,table and picture.
805 struct NewNum
: public HBox
808 unsigned short number
;
813 virtual int Read(HWPFile
&hwpf
);
818 * @short Input page index in footer or header
820 struct ShowPageNum
: public HBox
823 * Location of page number to be inserted.
825 unsigned short where
;
826 unsigned int m_nPageNumber
;
828 * Shape of page number to be inserted.
830 unsigned short shape
;
835 virtual int Read(HWPFile
&hwpf
);
838 /* Ȧ¼öÂʽÃÀÛ (21) */
839 #define HIDE_HD 1 /* bit 0 */
840 #define HIDE_FT 2 /* bit 1 */
841 #define HIDE_PGNUM 4 /* bit 2 */
842 #define HIDE_FRAME 8 /* bit 3 */
844 * Controls the display of page number, header, footer and border.
846 struct PageNumCtrl
: public HBox
860 virtual int Read(HWPFile
&hwpf
);
865 * Generates the mailing list automatically using address book and mail body format.
866 * @short Generates mailing list
868 struct MailMerge
: public HBox
870 unsigned char field_name
[20];
875 virtual int Read(HWPFile
&hwpf
);
876 virtual int GetString(hchar
*, int slen
= 255);
879 // char compositon(23)
881 * The compose struct displays characters at position. The maximum character count for composition is three.
882 * @short Composition several characters
884 struct Compose
: public HBox
891 virtual int Read(HWPFile
&hwpf
);
898 struct Hyphen
: public HBox
908 virtual int Read(HWPFile
&hwpf
);
913 * The TocMark class is for making the content of a table.
914 * When you set TocMark on current position, hwp makes it as toc automatically.
915 * @short Table of contents
917 struct TocMark
: public HBox
924 virtual int Read(HWPFile
&hwpf
);
929 * IndexMark marks the table of search.
930 * If you set IndexMark at current position, hwp make it as search index.
931 * @short Table of search
933 struct IndexMark
: public HBox
942 virtual int Read(HWPFile
&hwpf
);
946 #define MAX_OUTLINE_LEVEL 7
964 // value is in style->userchar[level];
982 * Number and format of title.
983 * @short Number and format of title
985 class Outline
: public HBox
989 * kind of numbering format
994 * level of number, Ex) The level of 1.3.2.4 is four
1000 unsigned short number
[MAX_OUTLINE_LEVEL
];
1004 hchar user_shape
[MAX_OUTLINE_LEVEL
];
1006 * decoration charactor for the level type
1008 hchar deco
[MAX_OUTLINE_LEVEL
][2]; /* »ç¿ëÀÚ Á¤Àǽà ¾ÕµÚ ¹®ÀÚ */
1013 virtual int Read(HWPFile
&hwpf
);
1014 hchar
*GetUnicode(hchar
*, int slen
= 255);
1019 * The Special space to be treated non-space when a string is
1020 * cut at the end of line
1021 * @short Special space
1023 struct KeepSpace
: public HBox
1029 virtual int Read(HWPFile
&hwpf
);
1032 /* °íÁ¤Æø ºóÄ(31) */
1034 * @short Space with always same width not relation with fonts.
1036 struct FixedSpace
: public HBox
1042 virtual int Read(HWPFile
&hwpf
);
1044 #endif /* _HBOX_H_ */