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
)
80 SkipData::SkipData(hchar hch
)
95 FieldCode::FieldCode()
104 reserved1
= new char[4];
105 reserved2
= new char[22];
108 FieldCode::~FieldCode()
127 Bookmark::~Bookmark()
132 DateFormat::DateFormat()
146 #define _DATECODE_WEEK_DEFINES_
147 #include "datecode.h"
149 hchar_string
DateCode::GetString()
156 bool is_pm
, add_zero
;
159 format
[DATE_SIZE
- 1] = 0;
160 fmt
= format
[0] ? format
: defaultform
;
162 for (; *fmt
&& ((int) ret
.size() < DATE_SIZE
); fmt
++)
164 form
= (add_zero
) ? "%02d" : "%d";
167 is_pm
= (date
[HOUR
] >= 12);
181 num
= date
[YEAR
] % 100;
187 memcpy(cbuf
, eng_mon
+ (date
[MONTH
] - 1) * 3, 3);
192 strncat(cbuf
, en_mon
[date
[MONTH
] - 1], sizeof(cbuf
) - strlen(cbuf
) - 1);
194 case '3': /* 'D' is day of korean */
199 switch (date
[DAY
] % 10)
216 num
= date
[HOUR
] - ((date
[HOUR
] > 12) ? 12 : 0);
226 ret
.push_back(kor_week
[date
[WEEK
]]);
229 memcpy(cbuf
, eng_week
+ date
[WEEK
] * 3, 3);
234 strncat(cbuf
, en_week
[date
[WEEK
]], sizeof(cbuf
) - strlen(cbuf
) - 1);
237 ret
.push_back(0xB5A1);
238 ret
.push_back((is_pm
) ? 0xD281 : 0xB8E5);
241 strncat(cbuf
, (is_pm
) ? "p.m." : "a.m.", sizeof(cbuf
) - strlen(cbuf
) - 1);
244 strncat(cbuf
, (is_pm
) ? "P.M." : "A.M.", sizeof(cbuf
) - strlen(cbuf
) - 1);
246 case '8': // 2.5 feature
250 mkcurfilename(cbuf
, *fmt
);
251 for (i
= 0; cbuf
[i
] != 0 && slen
> 1; i
++)
252 { //for hangle filename
253 if (cbuf
[i
] & 0x80 && cbuf
[i
+ 1] != 0)
255 *d
++ = (cbuf
[i
] << 8) | cbuf
[i
+ 1];
265 case '~': // 3.0b feature
271 ret
.push_back(china_week
[date
[WEEK
]]);
276 if (*fmt
== '\\' && *++fmt
== 0)
281 sprintf(cbuf
, form
, num
);
282 for (i
= 0; 0 != cbuf
[i
]; i
++)
284 ret
.push_back(*(cbuf
+ i
));
301 FBox::FBox(hchar hch
)
333 // tbox(10) TABLE BOX MATH BUTTON HYPERTEXT
353 reserved
[0] = reserved
[1] = 0;
360 for (int ii
= 0; ii
< nCell
; ++ii
)
362 std::list
< HWPPara
* >::iterator it
= plists
[ii
].begin();
363 for (; it
!= plists
[ii
].end(); ++it
)
365 HWPPara
* pPara
= *it
;
370 std::list
< HWPPara
* >::iterator it
= caption
.begin();
371 for (; it
!= caption
.end(); ++it
)
373 HWPPara
* pPara
= *it
;
381 hunit
TxtBox::Height(CharShape
* csty
)
383 return (style
.anchor_type
== CHAR_ANCHOR
) ? box_ys
: csty
->size
;
392 , follow_block_size(0)
407 if( pictype
== PICTYPE_DRAW
&& picinfo
.picdraw
.hdo
)
408 delete static_cast<HWPDrawingObject
*>(picinfo
.picdraw
.hdo
);
410 std::list
< HWPPara
* >::iterator it
= caption
.begin();
411 for (; it
!= caption
.end(); ++it
)
413 HWPPara
* pPara
= *it
;
425 hunit
Picture::Height(CharShape
* sty
)
427 return (style
.anchor_type
== CHAR_ANCHOR
) ? box_ys
: sty
->size
;
435 std::list
< HWPPara
* >::iterator it
= plist
.begin();
436 for (; it
!= plist
.end(); ++it
)
438 HWPPara
* pPara
= *it
;
445 HeaderFooter::~HeaderFooter()
447 std::list
< HWPPara
* >::iterator it
= plist
.begin();
448 for (; it
!= plist
.end(); ++it
)
450 HWPPara
* pPara
= *it
;
457 Footnote::~Footnote()
459 std::list
< HWPPara
* >::iterator it
= plist
.begin();
460 for (; it
!= plist
.end(); ++it
)
462 HWPPara
* pPara
= *it
;
470 // show page number (20)
474 hchar_string
MailMerge::GetString()
476 return hchar_string();
480 // character compositon(23)
486 #define OL_HANGL_JASO 0
487 #define OL_HANGL_KANATA 1
489 static hchar
olHanglJaso(int num
, int type
)
491 static const unsigned char han_init
[] =
492 { 0x88, 0x90, 0x94, 0x9c, 0xa0, 0xa4, 0xac, 0xb4, 0xb8, 0xc0, 0xc4, 0xc8, 0xcc, 0xd0 };
493 static const unsigned char jung
[] = { 3, 5, 7, 11, 13, 19, 20, 26, 27, 29, 30 };
494 static const unsigned char jung2
[] = { 3, 7, 13, 20, 27, 29, 30 };
498 if (type
== OL_HANGL_JASO
)
500 num
= num
% (14 + (sizeof(jung
) / sizeof(char)));
503 hh
= (han_init
[num
] << 8) | 'A';
505 hh
= (jung
[num
- 14] << 5) | 0x8401;
510 hh
= (han_init
[num
] << 8) | 'a';
513 int j
= (num
/ 14) % (sizeof(jung2
) / sizeof(char));
516 hh
= (han_init
[num
] << 8) | (jung2
[j
] << 5) | 1;
523 static const hchar
*GetOutlineStyleChars(int style
)
525 static const hchar out_bul_style_entry
[5][8] = // extern
528 0x2f18, 0x2f12, 0x2f08, 0x2f02, 0x2f06, 0x2f00, 0x2043, 0x0000
531 0x2f18, 0x2f12, 0x2f06, 0x2f00, 0x2f36, 0x2f30, 0x2043, 0x0000
534 0x2f26, 0x2f20, 0x2f06, 0x2f00, 0x2f16, 0x2f10, 0x2043, 0x0000
537 0x2f18, 0x2f16, 0x2f12, 0x2f10, 0x2f06, 0x2f00, 0x2043, 0x0000
540 0xAC61, 0xB677, 0xB861, 0xB8F7, 0xB781, 0x0000
543 if (style
>= OLSTY_BULLET1
&& style
<= OLSTY_BULLET5
)
544 return out_bul_style_entry
[style
- OLSTY_BULLET1
];
549 static void getOutlineNumStr(int style
, int level
, int num
, hchar
* hstr
)
553 U_ROM
= 0x01, L_ROM
= 0x02, U_ENG
= 0x04, L_ENG
= 0x08,
554 HAN
= 0x10, NUM
= 0x20, L_BR
= 0x40, R_BR
= 0x80
556 static const unsigned char type_tbl
[][MAX_OUTLINE_LEVEL
] =
559 U_ROM
, HAN
, NUM
, HAN
| R_BR
, L_BR
| NUM
| R_BR
,
560 L_BR
| HAN
| R_BR
, L_ROM
| R_BR
563 U_ROM
, U_ENG
, NUM
, L_ENG
| R_BR
, L_BR
| NUM
| R_BR
,
564 L_BR
| L_ENG
| R_BR
, L_ROM
| R_BR
567 NUM
, HAN
, L_BR
| NUM
| R_BR
, L_BR
| HAN
| R_BR
, NUM
|
568 R_BR
, HAN
| R_BR
, L_ENG
571 char fmt
= type_tbl
[style
- OLSTY_NUMSIG1
][level
];
580 sprintf(buf
, "%d", num
);
584 else if (fmt
& (U_ROM
| L_ROM
))
592 *ptr
= sal::static_int_cast
<char>(toupper(*ptr
));
601 num
= (num
- 1) % 26;
603 *hstr
++ = sal::static_int_cast
<hchar
>('A' + num
);
604 else if (fmt
& L_ENG
)
605 *hstr
++ = sal::static_int_cast
<hchar
>('a' + num
);
607 *hstr
++ = olHanglJaso(num
, OL_HANGL_KANATA
);
609 *hstr
++ = (fmt
& R_BR
) ? ')' : '.';
615 { OUTLINE_ON
, OUTLINE_NUM
};
617 /* level 은 0부터 시작. 즉 1.1.1. 의 레벨은 2이다.
618 number는 값이 그대로 들어가 있다. 즉, 1.2.1에는 1,2,1이 들어가 있다.
619 style 은 1부터 값이 들어가 있다. hbox.h에 정의된 데로..
621 hchar_string
Outline::GetUnicode() const
627 if (kind
== OUTLINE_NUM
)
635 char cur_num_str
[10], buf
[80];
639 for (i
= 0; i
<= level
; i
++)
641 levelnum
= ((number
[i
] < 1) ? 1 : number
[i
]);
642 if (shape
== OLSTY_NUMS2
&& i
&& i
== level
)
643 sprintf(cur_num_str
, "%d%c", levelnum
, 0);
645 sprintf(cur_num_str
, "%d%c", levelnum
, '.');
646 strcat(buf
, cur_num_str
);
648 str2hstr(buf
, buffer
);
649 return hstr2ucsstr(buffer
);
655 getOutlineNumStr(shape
, level
, number
[level
], buffer
);
656 return hstr2ucsstr(buffer
);
664 p
= GetOutlineStyleChars(shape
);
665 buffer
[0] = p
[level
];
667 return hstr2ucsstr(buffer
);
676 buffer
[l
++] = deco
[i
][0];
678 /* level 은 0부터 시작. 즉 1.1.1. 의 레벨은 2이다.
679 number는 값이 그대로 들어가 있다. 즉, 1.2.1에는 1,2,1이 들어가 있다.
680 style 은 1부터 값이 들어가 있다. hbox.h에 정의된 데로..
682 switch( user_shape
[i
] )
685 buffer
[l
++] = '1' + number
[i
] - 1;
689 num2roman(number
[i
], dest
);
690 if( user_shape
[i
] == 1 ){
694 *ptr
= sal::static_int_cast
<char>(toupper(*ptr
));
698 str2hstr(dest
, buffer
+ l
);
702 buffer
[l
++] = 'A' + number
[i
] -1;
705 buffer
[l
++] = 'a' + number
[i
] -1;
708 buffer
[l
++] = olHanglJaso(number
[i
] -1, OL_HANGL_KANATA
);
711 buffer
[l
++] = olHanglJaso(number
[i
] -1, OL_HANGL_JASO
);
713 case 7: /* 한자 숫자 : 일반 숫자로 표현 */
714 buffer
[l
++] = '1' + number
[i
] -1;
717 buffer
[l
++] = 0x2e00 + number
[i
];
719 case 9: /* 원 알파벳 소문자 */
720 buffer
[l
++] = 0x2c20 + number
[i
];
723 buffer
[l
++] = 0x2c50 + number
[i
] -1;
726 buffer
[l
++] = 0x2c40 + number
[i
] -1;
728 case 12: /* 이어진 숫자. */
730 char cur_num_str
[10],buf
[80];
733 for (j
= 0; j
<= level
; j
++)
735 levelnum
= ((number
[j
] < 1) ? 1 : number
[j
]);
736 if ((j
&& j
== level
) || (j
== level
&& deco
[i
][1]))
737 sprintf(cur_num_str
, "%d%c", levelnum
, 0);
739 sprintf(cur_num_str
, "%d%c", levelnum
, '.');
740 strcat(buf
, cur_num_str
);
742 str2hstr(buf
, buffer
+ l
);
747 buffer
[l
++] = user_shape
[i
];
751 buffer
[l
++] = deco
[i
][1];
754 return hstr2ucsstr(buffer
);
758 return hstr2ucsstr(buffer
);
765 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */