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 .
20 #include "precompile.h"
24 #include <osl/diagnose.h>
34 int HBox::boxCount
= 0;
51 static const int wsize
[32] =
53 1, 4, 4, 4, 4, 4, 4, 42, /* dateform */
54 48, 4, 4, 4, 4, 1, 4, 4, /* hidden */
55 4, 4, 4, 4, 4, 4, 12, 5, /* chcompose */
56 3, 3, 123, 4, 32, 4, 2, 2
66 hchar_string
HBox::GetString()
74 hunit
HBox::Height(CharShape
*csty
)
81 SkipData::SkipData(hchar hch
):HBox(hch
)
87 SkipData::~SkipData(void)
94 FieldCode::FieldCode(void) : HBox(CH_FIELD
)
100 reserved1
= new char[4];
101 reserved2
= new char[22];
106 FieldCode::~FieldCode(void)
120 Bookmark::Bookmark(void):HBox(CH_BOOKMARK
)
125 Bookmark::~Bookmark(void)
131 DateFormat::DateFormat(void):HBox(CH_DATE_FORM
)
138 DateCode::DateCode(void):HBox(CH_DATE_CODE
)
143 #define _DATECODE_WEEK_DEFINES_
144 #include "datecode.h"
146 hchar_string
DateCode::GetString()
153 bool is_pm
, add_zero
;
156 format
[DATE_SIZE
- 1] = 0;
157 fmt
= format
[0] ? format
: defaultform
;
159 for (; *fmt
&& ((int) ret
.size() < DATE_SIZE
); fmt
++)
161 form
= (add_zero
) ? "%02d" : "%d";
164 is_pm
= (date
[HOUR
] >= 12);
178 num
= date
[YEAR
] % 100;
184 memcpy(cbuf
, eng_mon
+ (date
[MONTH
] - 1) * 3, 3);
189 strcpy(cbuf
, en_mon
[date
[MONTH
] - 1]);
191 case '3': /* 'D' is day of korean */
196 switch (date
[DAY
] % 10)
213 num
= date
[HOUR
] - ((date
[HOUR
] > 12) ? 12 : 0);
223 ret
.push_back(kor_week
[date
[WEEK
]]);
226 memcpy(cbuf
, eng_week
+ date
[WEEK
] * 3, 3);
231 strcpy(cbuf
, en_week
[date
[WEEK
]]);
234 ret
.push_back(0xB5A1);
235 ret
.push_back((is_pm
) ? 0xD281 : 0xB8E5);
238 strcpy(cbuf
, (is_pm
) ? "p.m." : "a.m.");
241 strcpy(cbuf
, (is_pm
) ? "P.M." : "A.M.");
243 case '8': // 2.5 feature
247 mkcurfilename(cbuf
, *fmt
);
248 for (i
= 0; cbuf
[i
] != 0 && slen
> 1; i
++)
249 { //for hangle filename
250 if (cbuf
[i
] & 0x80 && cbuf
[i
+ 1] != 0)
252 *d
++ = (cbuf
[i
] << 8) | cbuf
[i
+ 1];
262 case '~': // 3.0b feature
268 ret
.push_back(china_week
[date
[WEEK
]]);
273 if (*fmt
== '\\' && *++fmt
== 0)
278 sprintf(cbuf
, form
, num
);
279 for (i
= 0; 0 != cbuf
[i
]; i
++)
281 ret
.push_back(*(cbuf
+ i
));
291 Tab::Tab(void):HBox(CH_TAB
)
297 FBox::FBox(hchar hch
):HBox(hch
)
309 // tbox(10) TABLE BOX MATH BUTTON HYPERTEXT
311 TxtBox::TxtBox(void):FBox(CH_TEXT_BOX
), cell(0), plists(0)
316 TxtBox::~TxtBox(void)
320 for (int ii
= 0; ii
< nCell
; ++ii
)
322 std::list
< HWPPara
* >::iterator it
= plists
[ii
].begin();
323 for (; it
!= plists
[ii
].end(); ++it
)
325 HWPPara
* pPara
= *it
;
330 std::list
< HWPPara
* >::iterator it
= caption
.begin();
331 for (; it
!= caption
.end(); ++it
)
333 HWPPara
* pPara
= *it
;
341 hunit
TxtBox::Height(CharShape
* csty
)
343 return (style
.anchor_type
== CHAR_ANCHOR
) ? box_ys
: csty
->size
;
349 Picture::Picture(void):FBox(CH_PICTURE
)
356 Picture::~Picture(void)
359 if( pictype
== PICTYPE_DRAW
&& picinfo
.picdraw
.hdo
)
360 delete (HWPDrawingObject
*) picinfo
.picdraw
.hdo
;
362 std::list
< HWPPara
* >::iterator it
= caption
.begin();
363 for (; it
!= caption
.end(); ++it
)
365 HWPPara
* pPara
= *it
;
377 hunit
Picture::Height(CharShape
* sty
)
379 return (style
.anchor_type
== CHAR_ANCHOR
) ? box_ys
: sty
->size
;
385 Hidden::~Hidden(void)
387 std::list
< HWPPara
* >::iterator it
= plist
.begin();
388 for (; it
!= plist
.end(); ++it
)
390 HWPPara
* pPara
= *it
;
397 HeaderFooter::~HeaderFooter(void)
399 std::list
< HWPPara
* >::iterator it
= plist
.begin();
400 for (; it
!= plist
.end(); ++it
)
402 HWPPara
* pPara
= *it
;
409 Footnote::~Footnote(void)
411 std::list
< HWPPara
* >::iterator it
= plist
.begin();
412 for (; it
!= plist
.end(); ++it
)
414 HWPPara
* pPara
= *it
;
422 // show page number (20)
423 // Ȧ¼öÂʽÃÀÛ/°¨Ãß±â (21)
426 hchar_string
MailMerge::GetString()
428 return hchar_string();
432 // character compositon(23)
438 #define OL_HANGL_JASO 0
439 #define OL_HANGL_KANATA 1
441 static hchar
olHanglJaso(int num
, int type
)
443 static const unsigned char han_init
[] =
444 { 0x88, 0x90, 0x94, 0x9c, 0xa0, 0xa4, 0xac, 0xb4, 0xb8, 0xc0, 0xc4, 0xc8, 0xcc, 0xd0 };
445 static const unsigned char jung
[] = { 3, 5, 7, 11, 13, 19, 20, 26, 27, 29, 30 };
446 static const unsigned char jung2
[] = { 3, 7, 13, 20, 27, 29, 30 };
450 if (type
== OL_HANGL_JASO
)
452 num
= num
% (14 + (sizeof(jung
) / sizeof(char)));
455 hh
= (han_init
[num
] << 8) | 'A';
457 hh
= (jung
[num
- 14] << 5) | 0x8401;
462 hh
= (han_init
[num
] << 8) | 'a';
465 int j
= (num
/ 14) % (sizeof(jung2
) / sizeof(char));
468 hh
= (han_init
[num
] << 8) | (jung2
[j
] << 5) | 1;
475 static const hchar
*GetOutlineStyleChars(int style
)
477 static const hchar out_bul_style_entry
[5][8] = // extern
480 0x2f18, 0x2f12, 0x2f08, 0x2f02, 0x2f06, 0x2f00, 0x2043, 0x0000
483 0x2f18, 0x2f12, 0x2f06, 0x2f00, 0x2f36, 0x2f30, 0x2043, 0x0000
486 0x2f26, 0x2f20, 0x2f06, 0x2f00, 0x2f16, 0x2f10, 0x2043, 0x0000
489 0x2f18, 0x2f16, 0x2f12, 0x2f10, 0x2f06, 0x2f00, 0x2043, 0x0000
492 0xAC61, 0xB677, 0xB861, 0xB8F7, 0xB781, 0x0000
495 if (style
>= OLSTY_BULLET1
&& style
<= OLSTY_BULLET5
)
496 return out_bul_style_entry
[style
- OLSTY_BULLET1
];
501 static void getOutlineNumStr(int style
, int level
, int num
, hchar
* hstr
)
505 U_ROM
= 0x01, L_ROM
= 0x02, U_ENG
= 0x04, L_ENG
= 0x08,
506 HAN
= 0x10, NUM
= 0x20, L_BR
= 0x40, R_BR
= 0x80
508 static const unsigned char type_tbl
[][MAX_OUTLINE_LEVEL
] =
511 U_ROM
, HAN
, NUM
, HAN
| R_BR
, L_BR
| NUM
| R_BR
,
512 L_BR
| HAN
| R_BR
, L_ROM
| R_BR
515 U_ROM
, U_ENG
, NUM
, L_ENG
| R_BR
, L_BR
| NUM
| R_BR
,
516 L_BR
| L_ENG
| R_BR
, L_ROM
| R_BR
519 NUM
, HAN
, L_BR
| NUM
| R_BR
, L_BR
| HAN
| R_BR
, NUM
|
520 R_BR
, HAN
| R_BR
, L_ENG
523 char fmt
= type_tbl
[style
- OLSTY_NUMSIG1
][level
];
532 sprintf(buf
, "%d", num
);
536 else if (fmt
& (U_ROM
| L_ROM
))
544 *ptr
= sal::static_int_cast
<char>(toupper(*ptr
));
553 num
= (num
- 1) % 26;
555 *hstr
++ = sal::static_int_cast
<hchar
>('A' + num
);
556 else if (fmt
& L_ENG
)
557 *hstr
++ = sal::static_int_cast
<hchar
>('a' + num
);
559 *hstr
++ = olHanglJaso(num
, OL_HANGL_KANATA
);
561 *hstr
++ = (fmt
& R_BR
) ? ')' : '.';
567 { OUTLINE_ON
, OUTLINE_NUM
};
569 /* level Àº 0ºÎÅÍ ½ÃÀÛ. Áï 1.1.1. ÀÇ ·¹º§Àº 2ÀÌ´Ù.
570 number´Â °ªÀÌ ±×´ë·Î µé¾î°¡ ÀÖ´Ù. Áï, 1.2.1¿¡´Â 1,2,1ÀÌ µé¾î°¡ ÀÖ´Ù.
571 style Àº 1ºÎÅÍ °ªÀÌ µé¾î°¡ ÀÖ´Ù. hbox.h¿¡ Á¤ÀÇµÈ µ¥·Î..
573 hchar_string
Outline::GetUnicode() const
579 if (kind
== OUTLINE_NUM
)
587 char cur_num_str
[10], buf
[80];
591 for (i
= 0; i
<= level
; i
++)
593 levelnum
= ((number
[i
] < 1) ? 1 : number
[i
]);
594 if (shape
== OLSTY_NUMS2
&& i
&& i
== level
)
595 sprintf(cur_num_str
, "%d%c", levelnum
, 0);
597 sprintf(cur_num_str
, "%d%c", levelnum
, '.');
598 strcat(buf
, cur_num_str
);
600 str2hstr(buf
, buffer
);
601 return hstr2ucsstr(buffer
);
607 getOutlineNumStr(shape
, level
, number
[level
], buffer
);
608 return hstr2ucsstr(buffer
);
616 p
= GetOutlineStyleChars(shape
);
617 buffer
[0] = p
[level
];
619 return hstr2ucsstr(buffer
);
628 buffer
[l
++] = deco
[i
][0];
630 /* level Àº 0ºÎÅÍ ½ÃÀÛ. Áï 1.1.1. ÀÇ ·¹º§Àº 2ÀÌ´Ù.
631 number´Â °ªÀÌ ±×´ë·Î µé¾î°¡ ÀÖ´Ù. Áï, 1.2.1¿¡´Â 1,2,1ÀÌ µé¾î°¡ ÀÖ´Ù.
632 style Àº 1ºÎÅÍ °ªÀÌ µé¾î°¡ ÀÖ´Ù. hbox.h¿¡ Á¤ÀÇµÈ µ¥·Î..
634 switch( user_shape
[i
] )
637 buffer
[l
++] = '1' + number
[i
] - 1;
639 case 1: /* ´ë¹®Àڷθ¶ */
640 case 2: /* ¼Ò¹®Àڷθ¶ */
641 num2roman(number
[i
], dest
);
642 if( user_shape
[i
] == 1 ){
646 *ptr
= sal::static_int_cast
<char>(toupper(*ptr
));
650 str2hstr(dest
, buffer
+ l
);
654 buffer
[l
++] = 'A' + number
[i
] -1;
657 buffer
[l
++] = 'a' + number
[i
] -1;
660 buffer
[l
++] = olHanglJaso(number
[i
] -1, OL_HANGL_KANATA
);
663 buffer
[l
++] = olHanglJaso(number
[i
] -1, OL_HANGL_JASO
);
665 case 7: /* ÇÑÀÚ ¼ýÀÚ : ÀÏ¹Ý ¼ýÀڷΠǥÇö */
666 buffer
[l
++] = '1' + number
[i
] -1;
669 buffer
[l
++] = 0x2e00 + number
[i
];
671 case 9: /* ¿ø ¾ËÆĺª ¼Ò¹®ÀÚ */
672 buffer
[l
++] = 0x2c20 + number
[i
];
674 case 10: /* ¿ø °¡³ª´Ù */
675 buffer
[l
++] = 0x2c50 + number
[i
] -1;
677 case 11: /* ¿ø ¤¡ ¤¤ */
678 buffer
[l
++] = 0x2c40 + number
[i
] -1;
680 case 12: /* À̾îÁø ¼ýÀÚ. */
682 char cur_num_str
[10],buf
[80];
685 for (j
= 0; j
<= level
; j
++)
687 levelnum
= ((number
[j
] < 1) ? 1 : number
[j
]);
688 if ((j
&& j
== level
) || (j
== level
&& deco
[i
][1]))
689 sprintf(cur_num_str
, "%d%c", levelnum
, 0);
691 sprintf(cur_num_str
, "%d%c", levelnum
, '.');
692 strcat(buf
, cur_num_str
);
694 str2hstr(buf
, buffer
+ l
);
699 buffer
[l
++] = user_shape
[i
];
703 buffer
[l
++] = deco
[i
][1];
706 return hstr2ucsstr(buffer
);
710 return hstr2ucsstr(buffer
);
715 /* °íÁ¤Æø ºóÄ(31) */
717 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */