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 ************************************************************************/
29 #include "precompile.h"
33 #include <osl/diagnose.h>
43 int HBox::boxCount
= 0;
60 static const int wsize
[32] =
62 1, 4, 4, 4, 4, 4, 4, 42, /* dateform */
63 48, 4, 4, 4, 4, 1, 4, 4, /* hidden */
64 4, 4, 4, 4, 4, 4, 12, 5, /* chcompose */
65 3, 3, 123, 4, 32, 4, 2, 2
75 hchar_string
HBox::GetString()
83 hunit
HBox::Height(CharShape
*csty
)
90 SkipData::SkipData(hchar hch
):HBox(hch
)
96 SkipData::~SkipData(void)
103 FieldCode::FieldCode(void) : HBox(CH_FIELD
)
109 reserved1
= new char[4];
110 reserved2
= new char[22];
115 FieldCode::~FieldCode(void)
129 Bookmark::Bookmark(void):HBox(CH_BOOKMARK
)
134 Bookmark::~Bookmark(void)
140 DateFormat::DateFormat(void):HBox(CH_DATE_FORM
)
147 DateCode::DateCode(void):HBox(CH_DATE_CODE
)
152 #define _DATECODE_WEEK_DEFINES_
153 #include "datecode.h"
155 hchar_string
DateCode::GetString()
162 bool is_pm
, add_zero
;
165 format
[DATE_SIZE
- 1] = 0;
166 fmt
= format
[0] ? format
: defaultform
;
168 for (; *fmt
&& ((int) ret
.size() < DATE_SIZE
); fmt
++)
170 form
= (add_zero
) ? "%02d" : "%d";
173 is_pm
= (date
[HOUR
] >= 12);
187 num
= date
[YEAR
] % 100;
193 memcpy(cbuf
, eng_mon
+ (date
[MONTH
] - 1) * 3, 3);
198 strcpy(cbuf
, en_mon
[date
[MONTH
] - 1]);
200 case '3': /* 'D' is day of korean */
205 switch (date
[DAY
] % 10)
222 num
= date
[HOUR
] - ((date
[HOUR
] > 12) ? 12 : 0);
232 ret
.push_back(kor_week
[date
[WEEK
]]);
235 memcpy(cbuf
, eng_week
+ date
[WEEK
] * 3, 3);
240 strcpy(cbuf
, en_week
[date
[WEEK
]]);
243 ret
.push_back(0xB5A1);
244 ret
.push_back((is_pm
) ? 0xD281 : 0xB8E5);
247 strcpy(cbuf
, (is_pm
) ? "p.m." : "a.m.");
250 strcpy(cbuf
, (is_pm
) ? "P.M." : "A.M.");
252 case '8': // 2.5 feature
256 mkcurfilename(cbuf
, *fmt
);
257 for (i
= 0; cbuf
[i
] != 0 && slen
> 1; i
++)
258 { //for hangle filename
259 if (cbuf
[i
] & 0x80 && cbuf
[i
+ 1] != 0)
261 *d
++ = (cbuf
[i
] << 8) | cbuf
[i
+ 1];
271 case '~': // 3.0b feature
277 ret
.push_back(china_week
[date
[WEEK
]]);
282 if (*fmt
== '\\' && *++fmt
== 0)
287 sprintf(cbuf
, form
, num
);
288 for (i
= 0; 0 != cbuf
[i
]; i
++)
290 ret
.push_back(*(cbuf
+ i
));
300 Tab::Tab(void):HBox(CH_TAB
)
306 FBox::FBox(hchar hch
):HBox(hch
)
318 // tbox(10) TABLE BOX MATH BUTTON HYPERTEXT
320 TxtBox::TxtBox(void):FBox(CH_TEXT_BOX
), cell(0), plists(0)
325 TxtBox::~TxtBox(void)
329 for (int ii
= 0; ii
< nCell
; ++ii
)
331 std::list
< HWPPara
* >::iterator it
= plists
[ii
].begin();
332 for (; it
!= plists
[ii
].end(); ++it
)
334 HWPPara
* pPara
= *it
;
339 std::list
< HWPPara
* >::iterator it
= caption
.begin();
340 for (; it
!= caption
.end(); ++it
)
342 HWPPara
* pPara
= *it
;
350 hunit
TxtBox::Height(CharShape
* csty
)
352 return (style
.anchor_type
== CHAR_ANCHOR
) ? box_ys
: csty
->size
;
358 Picture::Picture(void):FBox(CH_PICTURE
)
365 Picture::~Picture(void)
368 if( pictype
== PICTYPE_DRAW
&& picinfo
.picdraw
.hdo
)
369 delete (HWPDrawingObject
*) picinfo
.picdraw
.hdo
;
371 std::list
< HWPPara
* >::iterator it
= caption
.begin();
372 for (; it
!= caption
.end(); ++it
)
374 HWPPara
* pPara
= *it
;
386 hunit
Picture::Height(CharShape
* sty
)
388 return (style
.anchor_type
== CHAR_ANCHOR
) ? box_ys
: sty
->size
;
394 Hidden::~Hidden(void)
396 std::list
< HWPPara
* >::iterator it
= plist
.begin();
397 for (; it
!= plist
.end(); ++it
)
399 HWPPara
* pPara
= *it
;
406 HeaderFooter::~HeaderFooter(void)
408 std::list
< HWPPara
* >::iterator it
= plist
.begin();
409 for (; it
!= plist
.end(); ++it
)
411 HWPPara
* pPara
= *it
;
418 Footnote::~Footnote(void)
420 std::list
< HWPPara
* >::iterator it
= plist
.begin();
421 for (; it
!= plist
.end(); ++it
)
423 HWPPara
* pPara
= *it
;
431 // show page number (20)
432 // Ȧ¼öÂʽÃÀÛ/°¨Ãß±â (21)
435 hchar_string
MailMerge::GetString()
437 return hchar_string();
441 // character compositon(23)
447 #define OL_HANGL_JASO 0
448 #define OL_HANGL_KANATA 1
450 static hchar
olHanglJaso(int num
, int type
)
452 static const unsigned char han_init
[] =
453 { 0x88, 0x90, 0x94, 0x9c, 0xa0, 0xa4, 0xac, 0xb4, 0xb8, 0xc0, 0xc4, 0xc8, 0xcc, 0xd0 };
454 static const unsigned char jung
[] = { 3, 5, 7, 11, 13, 19, 20, 26, 27, 29, 30 };
455 static const unsigned char jung2
[] = { 3, 7, 13, 20, 27, 29, 30 };
459 if (type
== OL_HANGL_JASO
)
461 num
= num
% (14 + (sizeof(jung
) / sizeof(char)));
464 hh
= (han_init
[num
] << 8) | 'A';
466 hh
= (jung
[num
- 14] << 5) | 0x8401;
471 hh
= (han_init
[num
] << 8) | 'a';
474 int j
= (num
/ 14) % (sizeof(jung2
) / sizeof(char));
477 hh
= (han_init
[num
] << 8) | (jung2
[j
] << 5) | 1;
484 static const hchar
*GetOutlineStyleChars(int style
)
486 static const hchar out_bul_style_entry
[5][8] = // extern
489 0x2f18, 0x2f12, 0x2f08, 0x2f02, 0x2f06, 0x2f00, 0x2043, 0x0000
492 0x2f18, 0x2f12, 0x2f06, 0x2f00, 0x2f36, 0x2f30, 0x2043, 0x0000
495 0x2f26, 0x2f20, 0x2f06, 0x2f00, 0x2f16, 0x2f10, 0x2043, 0x0000
498 0x2f18, 0x2f16, 0x2f12, 0x2f10, 0x2f06, 0x2f00, 0x2043, 0x0000
501 0xAC61, 0xB677, 0xB861, 0xB8F7, 0xB781, 0x0000
504 if (style
>= OLSTY_BULLET1
&& style
<= OLSTY_BULLET5
)
505 return out_bul_style_entry
[style
- OLSTY_BULLET1
];
510 static void getOutlineNumStr(int style
, int level
, int num
, hchar
* hstr
)
514 U_ROM
= 0x01, L_ROM
= 0x02, U_ENG
= 0x04, L_ENG
= 0x08,
515 HAN
= 0x10, NUM
= 0x20, L_BR
= 0x40, R_BR
= 0x80
517 static const unsigned char type_tbl
[][MAX_OUTLINE_LEVEL
] =
520 U_ROM
, HAN
, NUM
, HAN
| R_BR
, L_BR
| NUM
| R_BR
,
521 L_BR
| HAN
| R_BR
, L_ROM
| R_BR
524 U_ROM
, U_ENG
, NUM
, L_ENG
| R_BR
, L_BR
| NUM
| R_BR
,
525 L_BR
| L_ENG
| R_BR
, L_ROM
| R_BR
528 NUM
, HAN
, L_BR
| NUM
| R_BR
, L_BR
| HAN
| R_BR
, NUM
|
529 R_BR
, HAN
| R_BR
, L_ENG
532 char fmt
= type_tbl
[style
- OLSTY_NUMSIG1
][level
];
541 sprintf(buf
, "%d", num
);
545 else if (fmt
& (U_ROM
| L_ROM
))
553 *ptr
= sal::static_int_cast
<char>(toupper(*ptr
));
562 num
= (num
- 1) % 26;
564 *hstr
++ = sal::static_int_cast
<hchar
>('A' + num
);
565 else if (fmt
& L_ENG
)
566 *hstr
++ = sal::static_int_cast
<hchar
>('a' + num
);
568 *hstr
++ = olHanglJaso(num
, OL_HANGL_KANATA
);
570 *hstr
++ = (fmt
& R_BR
) ? ')' : '.';
576 { OUTLINE_ON
, OUTLINE_NUM
};
578 /* level Àº 0ºÎÅÍ ½ÃÀÛ. Áï 1.1.1. ÀÇ ·¹º§Àº 2ÀÌ´Ù.
579 number´Â °ªÀÌ ±×´ë·Î µé¾î°¡ ÀÖ´Ù. Áï, 1.2.1¿¡´Â 1,2,1ÀÌ µé¾î°¡ ÀÖ´Ù.
580 style Àº 1ºÎÅÍ °ªÀÌ µé¾î°¡ ÀÖ´Ù. hbox.h¿¡ Á¤ÀÇµÈ µ¥·Î..
582 hchar_string
Outline::GetUnicode() const
588 if (kind
== OUTLINE_NUM
)
596 char cur_num_str
[10], buf
[80];
600 for (i
= 0; i
<= level
; i
++)
602 levelnum
= ((number
[i
] < 1) ? 1 : number
[i
]);
603 if (shape
== OLSTY_NUMS2
&& i
&& i
== level
)
604 sprintf(cur_num_str
, "%d%c", levelnum
, 0);
606 sprintf(cur_num_str
, "%d%c", levelnum
, '.');
607 strcat(buf
, cur_num_str
);
609 str2hstr(buf
, buffer
);
610 return hstr2ucsstr(buffer
);
616 getOutlineNumStr(shape
, level
, number
[level
], buffer
);
617 return hstr2ucsstr(buffer
);
625 p
= GetOutlineStyleChars(shape
);
626 buffer
[0] = p
[level
];
628 return hstr2ucsstr(buffer
);
637 buffer
[l
++] = deco
[i
][0];
639 /* level Àº 0ºÎÅÍ ½ÃÀÛ. Áï 1.1.1. ÀÇ ·¹º§Àº 2ÀÌ´Ù.
640 number´Â °ªÀÌ ±×´ë·Î µé¾î°¡ ÀÖ´Ù. Áï, 1.2.1¿¡´Â 1,2,1ÀÌ µé¾î°¡ ÀÖ´Ù.
641 style Àº 1ºÎÅÍ °ªÀÌ µé¾î°¡ ÀÖ´Ù. hbox.h¿¡ Á¤ÀÇµÈ µ¥·Î..
643 switch( user_shape
[i
] )
646 buffer
[l
++] = '1' + number
[i
] - 1;
648 case 1: /* ´ë¹®Àڷθ¶ */
649 case 2: /* ¼Ò¹®Àڷθ¶ */
650 num2roman(number
[i
], dest
);
651 if( user_shape
[i
] == 1 ){
655 *ptr
= sal::static_int_cast
<char>(toupper(*ptr
));
659 str2hstr(dest
, buffer
+ l
);
663 buffer
[l
++] = 'A' + number
[i
] -1;
666 buffer
[l
++] = 'a' + number
[i
] -1;
669 buffer
[l
++] = olHanglJaso(number
[i
] -1, OL_HANGL_KANATA
);
672 buffer
[l
++] = olHanglJaso(number
[i
] -1, OL_HANGL_JASO
);
674 case 7: /* ÇÑÀÚ ¼ýÀÚ : ÀÏ¹Ý ¼ýÀڷΠǥÇö */
675 buffer
[l
++] = '1' + number
[i
] -1;
678 buffer
[l
++] = 0x2e00 + number
[i
];
680 case 9: /* ¿ø ¾ËÆĺª ¼Ò¹®ÀÚ */
681 buffer
[l
++] = 0x2c20 + number
[i
];
683 case 10: /* ¿ø °¡³ª´Ù */
684 buffer
[l
++] = 0x2c50 + number
[i
] -1;
686 case 11: /* ¿ø ¤¡ ¤¤ */
687 buffer
[l
++] = 0x2c40 + number
[i
] -1;
689 case 12: /* À̾îÁø ¼ýÀÚ. */
691 char cur_num_str
[10],buf
[80];
694 for (j
= 0; j
<= level
; j
++)
696 levelnum
= ((number
[j
] < 1) ? 1 : number
[j
]);
697 if ((j
&& j
== level
) || (j
== level
&& deco
[i
][1]))
698 sprintf(cur_num_str
, "%d%c", levelnum
, 0);
700 sprintf(cur_num_str
, "%d%c", levelnum
, '.');
701 strcat(buf
, cur_num_str
);
703 str2hstr(buf
, buffer
+ l
);
708 buffer
[l
++] = user_shape
[i
];
712 buffer
[l
++] = deco
[i
][1];
715 return hstr2ucsstr(buffer
);
719 return hstr2ucsstr(buffer
);
724 /* °íÁ¤Æø ºóÄ(31) */
726 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */