bump product version to 4.1.6.2
[LibreOffice.git] / sc / source / filter / excel / xlstyle.cxx
blobe2b3f18435199f401efa94a7498384416be83c31
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include "xlstyle.hxx"
22 #include <com/sun/star/awt/FontFamily.hpp>
23 #include <com/sun/star/awt/FontSlant.hpp>
24 #include <com/sun/star/awt/FontUnderline.hpp>
25 #include <com/sun/star/i18n/ScriptType.hpp>
26 #include <vcl/svapp.hxx>
27 #include <vcl/font.hxx>
28 #include <sal/macros.h>
29 #include <rtl/tencinfo.h>
30 #include <svtools/colorcfg.hxx>
31 #include <toolkit/unohlp.hxx>
32 #include <editeng/svxfont.hxx>
33 #include "global.hxx"
34 #include "xlroot.hxx"
35 // Color data =================================================================
37 /** Standard EGA colors, bright. */
38 #define EXC_PALETTE_EGA_COLORS_LIGHT \
39 0x000000, 0xFFFFFF, 0xFF0000, 0x00FF00, 0x0000FF, 0xFFFF00, 0xFF00FF, 0x00FFFF
40 /** Standard EGA colors, dark. */
41 #define EXC_PALETTE_EGA_COLORS_DARK \
42 0x800000, 0x008000, 0x000080, 0x808000, 0x800080, 0x008080, 0xC0C0C0, 0x808080
44 /** Default color table for BIFF2. */
45 static const ColorData spnDefColorTable2[] =
47 /* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT
50 /** Default color table for BIFF3/BIFF4. */
51 static const ColorData spnDefColorTable3[] =
53 /* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT,
54 /* 8 */ EXC_PALETTE_EGA_COLORS_LIGHT,
55 /* 16 */ EXC_PALETTE_EGA_COLORS_DARK
58 /** Default color table for BIFF5/BIFF7. */
59 static const ColorData spnDefColorTable5[] =
61 /* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT,
62 /* 8 */ EXC_PALETTE_EGA_COLORS_LIGHT,
63 /* 16 */ EXC_PALETTE_EGA_COLORS_DARK,
64 /* 24 */ 0x8080FF, 0x802060, 0xFFFFC0, 0xA0E0E0, 0x600080, 0xFF8080, 0x0080C0, 0xC0C0FF,
65 /* 32 */ 0x000080, 0xFF00FF, 0xFFFF00, 0x00FFFF, 0x800080, 0x800000, 0x008080, 0x0000FF,
66 /* 40 */ 0x00CFFF, 0x69FFFF, 0xE0FFE0, 0xFFFF80, 0xA6CAF0, 0xDD9CB3, 0xB38FEE, 0xE3E3E3,
67 /* 48 */ 0x2A6FF9, 0x3FB8CD, 0x488436, 0x958C41, 0x8E5E42, 0xA0627A, 0x624FAC, 0x969696,
68 /* 56 */ 0x1D2FBE, 0x286676, 0x004500, 0x453E01, 0x6A2813, 0x85396A, 0x4A3285, 0x424242
71 /** Default color table for BIFF8. */
72 static const ColorData spnDefColorTable8[] =
74 /* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT,
75 /* 8 */ EXC_PALETTE_EGA_COLORS_LIGHT,
76 /* 16 */ EXC_PALETTE_EGA_COLORS_DARK,
77 /* 24 */ 0x9999FF, 0x993366, 0xFFFFCC, 0xCCFFFF, 0x660066, 0xFF8080, 0x0066CC, 0xCCCCFF,
78 /* 32 */ 0x000080, 0xFF00FF, 0xFFFF00, 0x00FFFF, 0x800080, 0x800000, 0x008080, 0x0000FF,
79 /* 40 */ 0x00CCFF, 0xCCFFFF, 0xCCFFCC, 0xFFFF99, 0x99CCFF, 0xFF99CC, 0xCC99FF, 0xFFCC99,
80 /* 48 */ 0x3366FF, 0x33CCCC, 0x99CC00, 0xFFCC00, 0xFF9900, 0xFF6600, 0x666699, 0x969696,
81 /* 56 */ 0x003366, 0x339966, 0x003300, 0x333300, 0x993300, 0x993366, 0x333399, 0x333333
84 #undef EXC_PALETTE_EGA_COLORS_LIGHT
85 #undef EXC_PALETTE_EGA_COLORS_DARK
87 // ----------------------------------------------------------------------------
89 XclDefaultPalette::XclDefaultPalette( const XclRoot& rRoot ) :
90 mpnColorTable( 0 ),
91 mnTableSize( 0 )
93 const StyleSettings& rSett = Application::GetSettings().GetStyleSettings();
94 mnWindowText = rSett.GetWindowTextColor().GetColor();
95 mnWindowBack = rSett.GetWindowColor().GetColor();
96 mnFaceColor = rSett.GetFaceColor().GetColor();
97 // Don't use the system HelpBack and HelpText colours as it causes problems
98 // with modern gnome. This is because mnNoteText and mnNoteBack are used
99 // when colour indices ( instead of real colours ) are specified.
100 // Note: That this it is not an unusual scenario that we get the Note
101 // background specified as a real colour and the text specified as a
102 // colour index. That means the text colour would be picked from
103 // the system where the note background would be picked from a real colour.
104 // Previously the the note text colour was picked from the system tooltip
105 // text colour, on modern gnome(e.g. 3) that tends to be 'white' with the
106 // default theme.
107 // Using the the Libreoffice defaults ( instead of system specific colours
108 // ) lessens the chance of the one colour being an unsuitable combination
109 // because by default the note text is black and the note background is
110 // a light yellow colour ( very similar to Excel's normal defaults )
111 mnNoteText = svtools::ColorConfig::GetDefaultColor( svtools::FONTCOLOR ).GetColor();
112 mnNoteBack = svtools::ColorConfig::GetDefaultColor( svtools::CALCNOTESBACKGROUND ).GetColor();
114 // default colors
115 switch( rRoot.GetBiff() )
117 case EXC_BIFF2:
118 mpnColorTable = spnDefColorTable2;
119 mnTableSize = SAL_N_ELEMENTS( spnDefColorTable2 );
120 break;
121 case EXC_BIFF3:
122 case EXC_BIFF4:
123 mpnColorTable = spnDefColorTable3;
124 mnTableSize = SAL_N_ELEMENTS( spnDefColorTable3 );
125 break;
126 case EXC_BIFF5:
127 mpnColorTable = spnDefColorTable5;
128 mnTableSize = SAL_N_ELEMENTS( spnDefColorTable5 );
129 break;
130 case EXC_BIFF8:
131 mpnColorTable = spnDefColorTable8;
132 mnTableSize = SAL_N_ELEMENTS( spnDefColorTable8 );
133 break;
134 default:
135 DBG_ERROR_BIFF();
139 ColorData XclDefaultPalette::GetDefColorData( sal_uInt16 nXclIndex ) const
141 ColorData nColor;
142 if( nXclIndex < mnTableSize )
143 nColor = mpnColorTable[ nXclIndex ];
144 else switch( nXclIndex )
146 case EXC_COLOR_WINDOWTEXT3:
147 case EXC_COLOR_WINDOWTEXT:
148 case EXC_COLOR_CHWINDOWTEXT: nColor = mnWindowText; break;
149 case EXC_COLOR_WINDOWBACK3:
150 case EXC_COLOR_WINDOWBACK:
151 case EXC_COLOR_CHWINDOWBACK: nColor = mnWindowBack; break;
152 case EXC_COLOR_BUTTONBACK: nColor = mnFaceColor; break;
153 case EXC_COLOR_CHBORDERAUTO: nColor = COL_BLACK; break; // TODO: really always black?
154 case EXC_COLOR_NOTEBACK: nColor = mnNoteBack; break;
155 case EXC_COLOR_NOTETEXT: nColor = mnNoteText; break;
156 case EXC_COLOR_FONTAUTO: nColor = COL_AUTO; break;
157 default:
158 OSL_TRACE( "XclDefaultPalette::GetDefColorData - unknown default color index: %d", nXclIndex );
159 nColor = COL_AUTO;
161 return nColor;
164 // Font Data ==================================================================
166 namespace Awt = ::com::sun::star::awt;
167 namespace AwtFontFamily = Awt::FontFamily;
168 namespace AwtFontUnderline = Awt::FontUnderline;
169 namespace AwtFontStrikeout = Awt::FontStrikeout;
171 // ----------------------------------------------------------------------------
173 XclFontData::XclFontData()
175 Clear();
178 XclFontData::XclFontData( const Font& rFont )
180 Clear();
181 FillFromVclFont( rFont );
184 XclFontData::XclFontData( const SvxFont& rFont )
186 FillFromSvxFont( rFont );
189 void XclFontData::Clear()
191 maName.Erase();
192 maStyle.Erase();
193 maColor.SetColor( COL_AUTO );
194 mnHeight = 0;
195 mnWeight = EXC_FONTWGHT_DONTKNOW;
196 mnEscapem = EXC_FONTESC_NONE;
197 mnFamily = EXC_FONTFAM_SYSTEM;
198 mnCharSet = EXC_FONTCSET_ANSI_LATIN;
199 mnUnderline = EXC_FONTUNDERL_NONE;
200 mbItalic = mbStrikeout = mbOutline = mbShadow = false;
203 void XclFontData::FillFromVclFont( const Font& rFont )
205 maName = XclTools::GetXclFontName( rFont.GetName() ); // substitute with MS fonts
206 maStyle.Erase();
207 maColor = rFont.GetColor();
208 SetScUnderline( rFont.GetUnderline() );
209 mnEscapem = EXC_FONTESC_NONE;
210 SetScHeight( rFont.GetSize().Height() );
211 SetScWeight( rFont.GetWeight() );
212 SetScFamily( rFont.GetFamily() );
213 SetFontEncoding( rFont.GetCharSet() );
214 SetScPosture( rFont.GetItalic() );
215 SetScStrikeout( rFont.GetStrikeout() );
216 mbOutline = rFont.IsOutline();
217 mbShadow = rFont.IsShadow();
220 void XclFontData::FillFromSvxFont( const SvxFont& rFont )
222 FillFromVclFont( rFont );
223 SetScEscapement( rFont.GetEscapement() );
226 // *** conversion of VCL/SVX constants *** ------------------------------------
228 FontFamily XclFontData::GetScFamily( rtl_TextEncoding eDefTextEnc ) const
230 FontFamily eScFamily;
231 // ! format differs from Windows documentation: family is in lower nibble, pitch unknown
232 switch( mnFamily & 0x0F )
234 case EXC_FONTFAM_ROMAN: eScFamily = FAMILY_ROMAN; break;
235 case EXC_FONTFAM_SWISS: eScFamily = FAMILY_SWISS; break;
236 case EXC_FONTFAM_MODERN: eScFamily = FAMILY_MODERN; break;
237 case EXC_FONTFAM_SCRIPT: eScFamily = FAMILY_SCRIPT; break;
238 case EXC_FONTFAM_DECORATIVE: eScFamily = FAMILY_DECORATIVE; break;
239 default:
240 eScFamily =
241 ((eDefTextEnc == RTL_TEXTENCODING_APPLE_ROMAN) &&
242 (maName.EqualsIgnoreCaseAscii( "Geneva" ) || maName.EqualsIgnoreCaseAscii( "Chicago" ))) ?
243 FAMILY_SWISS : FAMILY_DONTKNOW;
245 return eScFamily;
248 rtl_TextEncoding XclFontData::GetFontEncoding() const
250 // convert Windows character set to text encoding identifier
251 return rtl_getTextEncodingFromWindowsCharset( mnCharSet );
254 FontItalic XclFontData::GetScPosture() const
256 return mbItalic ? ITALIC_NORMAL : ITALIC_NONE;
259 FontWeight XclFontData::GetScWeight() const
261 FontWeight eScWeight;
263 if( !mnWeight ) eScWeight = WEIGHT_DONTKNOW;
264 else if( mnWeight < 150 ) eScWeight = WEIGHT_THIN;
265 else if( mnWeight < 250 ) eScWeight = WEIGHT_ULTRALIGHT;
266 else if( mnWeight < 325 ) eScWeight = WEIGHT_LIGHT;
267 else if( mnWeight < 375 ) eScWeight = WEIGHT_SEMILIGHT;
268 else if( mnWeight < 450 ) eScWeight = WEIGHT_NORMAL;
269 else if( mnWeight < 550 ) eScWeight = WEIGHT_MEDIUM;
270 else if( mnWeight < 650 ) eScWeight = WEIGHT_SEMIBOLD;
271 else if( mnWeight < 750 ) eScWeight = WEIGHT_BOLD;
272 else if( mnWeight < 850 ) eScWeight = WEIGHT_ULTRABOLD;
273 else eScWeight = WEIGHT_BLACK;
275 return eScWeight;
278 FontUnderline XclFontData::GetScUnderline() const
280 FontUnderline eScUnderl = UNDERLINE_NONE;
281 switch( mnUnderline )
283 case EXC_FONTUNDERL_SINGLE:
284 case EXC_FONTUNDERL_SINGLE_ACC: eScUnderl = UNDERLINE_SINGLE; break;
285 case EXC_FONTUNDERL_DOUBLE:
286 case EXC_FONTUNDERL_DOUBLE_ACC: eScUnderl = UNDERLINE_DOUBLE; break;
288 return eScUnderl;
291 SvxEscapement XclFontData::GetScEscapement() const
293 SvxEscapement eScEscapem = SVX_ESCAPEMENT_OFF;
294 switch( mnEscapem )
296 case EXC_FONTESC_SUPER: eScEscapem = SVX_ESCAPEMENT_SUPERSCRIPT; break;
297 case EXC_FONTESC_SUB: eScEscapem = SVX_ESCAPEMENT_SUBSCRIPT; break;
299 return eScEscapem;
302 FontStrikeout XclFontData::GetScStrikeout() const
304 return mbStrikeout ? STRIKEOUT_SINGLE : STRIKEOUT_NONE;
307 void XclFontData::SetScHeight( sal_Int32 nTwips )
309 mnHeight = static_cast< sal_uInt16 >( ::std::min( nTwips, static_cast<sal_Int32>(0x7FFFL) ) );
312 void XclFontData::SetScFamily( FontFamily eScFamily )
314 switch( eScFamily )
316 case FAMILY_DONTKNOW: mnFamily = EXC_FONTFAM_DONTKNOW; break;
317 case FAMILY_DECORATIVE: mnFamily = EXC_FONTFAM_DECORATIVE; break;
318 case FAMILY_MODERN: mnFamily = EXC_FONTFAM_MODERN; break;
319 case FAMILY_ROMAN: mnFamily = EXC_FONTFAM_ROMAN; break;
320 case FAMILY_SCRIPT: mnFamily = EXC_FONTFAM_SCRIPT; break;
321 case FAMILY_SWISS: mnFamily = EXC_FONTFAM_SWISS; break;
322 case FAMILY_SYSTEM: mnFamily = EXC_FONTFAM_SYSTEM; break;
323 default:
324 OSL_FAIL( "XclFontData::SetScFamily - unknown font family" );
325 mnFamily = EXC_FONTFAM_DONTKNOW;
329 void XclFontData::SetFontEncoding( rtl_TextEncoding eFontEnc )
331 // convert text encoding identifier to Windows character set
332 mnCharSet = rtl_getBestWindowsCharsetFromTextEncoding( eFontEnc );
336 void XclFontData::SetScPosture( FontItalic eScPosture )
338 mbItalic = (eScPosture == ITALIC_OBLIQUE) || (eScPosture == ITALIC_NORMAL);
341 void XclFontData::SetScWeight( FontWeight eScWeight )
343 switch( eScWeight )
345 case WEIGHT_DONTKNOW: mnWeight = EXC_FONTWGHT_DONTKNOW; break;
346 case WEIGHT_THIN: mnWeight = EXC_FONTWGHT_THIN; break;
347 case WEIGHT_ULTRALIGHT: mnWeight = EXC_FONTWGHT_ULTRALIGHT; break;
348 case WEIGHT_LIGHT: mnWeight = EXC_FONTWGHT_LIGHT; break;
349 case WEIGHT_SEMILIGHT: mnWeight = EXC_FONTWGHT_SEMILIGHT; break;
350 case WEIGHT_NORMAL: mnWeight = EXC_FONTWGHT_NORMAL; break;
351 case WEIGHT_MEDIUM: mnWeight = EXC_FONTWGHT_MEDIUM; break;
352 case WEIGHT_SEMIBOLD: mnWeight = EXC_FONTWGHT_SEMIBOLD; break;
353 case WEIGHT_BOLD: mnWeight = EXC_FONTWGHT_BOLD; break;
354 case WEIGHT_ULTRABOLD: mnWeight = EXC_FONTWGHT_ULTRABOLD; break;
355 case WEIGHT_BLACK: mnWeight = EXC_FONTWGHT_BLACK; break;
356 default: mnWeight = EXC_FONTWGHT_NORMAL;
360 void XclFontData::SetScUnderline( FontUnderline eScUnderl )
362 switch( eScUnderl )
364 case UNDERLINE_NONE:
365 case UNDERLINE_DONTKNOW: mnUnderline = EXC_FONTUNDERL_NONE; break;
366 case UNDERLINE_DOUBLE:
367 case UNDERLINE_DOUBLEWAVE: mnUnderline = EXC_FONTUNDERL_DOUBLE; break;
368 default: mnUnderline = EXC_FONTUNDERL_SINGLE;
372 void XclFontData::SetScEscapement( short nScEscapem )
374 if( nScEscapem > 0 )
375 mnEscapem = EXC_FONTESC_SUPER;
376 else if( nScEscapem < 0 )
377 mnEscapem = EXC_FONTESC_SUB;
378 else
379 mnEscapem = EXC_FONTESC_NONE;
382 void XclFontData::SetScStrikeout( FontStrikeout eScStrikeout )
384 mbStrikeout =
385 (eScStrikeout == STRIKEOUT_SINGLE) || (eScStrikeout == STRIKEOUT_DOUBLE) ||
386 (eScStrikeout == STRIKEOUT_BOLD) || (eScStrikeout == STRIKEOUT_SLASH) ||
387 (eScStrikeout == STRIKEOUT_X);
390 // *** conversion of API constants *** ----------------------------------------
392 float XclFontData::GetApiHeight() const
394 return static_cast< float >( mnHeight / TWIPS_PER_POINT );
397 sal_Int16 XclFontData::GetApiFamily() const
399 sal_Int16 nApiFamily = AwtFontFamily::DONTKNOW;
400 switch( mnFamily )
402 case FAMILY_DECORATIVE: nApiFamily = AwtFontFamily::DECORATIVE; break;
403 case FAMILY_MODERN: nApiFamily = AwtFontFamily::MODERN; break;
404 case FAMILY_ROMAN: nApiFamily = AwtFontFamily::ROMAN; break;
405 case FAMILY_SCRIPT: nApiFamily = AwtFontFamily::SCRIPT; break;
406 case FAMILY_SWISS: nApiFamily = AwtFontFamily::SWISS; break;
407 case FAMILY_SYSTEM: nApiFamily = AwtFontFamily::SYSTEM; break;
409 return nApiFamily;
412 sal_Int16 XclFontData::GetApiFontEncoding() const
414 // API constants are equal to rtl_TextEncoding constants
415 return static_cast< sal_Int16 >( GetFontEncoding() );
418 Awt::FontSlant XclFontData::GetApiPosture() const
420 return mbItalic ? Awt::FontSlant_ITALIC : Awt::FontSlant_NONE;
423 float XclFontData::GetApiWeight() const
425 return VCLUnoHelper::ConvertFontWeight( GetScWeight() );
428 sal_Int16 XclFontData::GetApiUnderline() const
430 sal_Int16 nApiUnderl = AwtFontUnderline::NONE;
431 switch( mnUnderline )
433 case EXC_FONTUNDERL_SINGLE:
434 case EXC_FONTUNDERL_SINGLE_ACC: nApiUnderl = AwtFontUnderline::SINGLE; break;
435 case EXC_FONTUNDERL_DOUBLE:
436 case EXC_FONTUNDERL_DOUBLE_ACC: nApiUnderl = AwtFontUnderline::DOUBLE; break;
438 return nApiUnderl;
441 sal_Int16 XclFontData::GetApiEscapement() const
443 sal_Int16 nApiEscapem = 0;
444 switch( mnEscapem )
446 case EXC_FONTESC_SUPER: nApiEscapem = 33; break;
447 case EXC_FONTESC_SUB: nApiEscapem = -33; break;
449 return nApiEscapem;
452 sal_Int16 XclFontData::GetApiStrikeout() const
454 return mbStrikeout ? AwtFontStrikeout::SINGLE : AwtFontStrikeout::NONE;
457 void XclFontData::SetApiHeight( float fPoint )
459 mnHeight = static_cast< sal_uInt16 >( ::std::min( fPoint * TWIPS_PER_POINT + 0.5, 32767.0 ) );
462 void XclFontData::SetApiFamily( sal_Int16 nApiFamily )
464 switch( nApiFamily )
466 case AwtFontFamily::DECORATIVE: mnFamily = FAMILY_DECORATIVE; break;
467 case AwtFontFamily::MODERN: mnFamily = FAMILY_MODERN; break;
468 case AwtFontFamily::ROMAN: mnFamily = FAMILY_ROMAN; break;
469 case AwtFontFamily::SCRIPT: mnFamily = FAMILY_SCRIPT; break;
470 case AwtFontFamily::SWISS: mnFamily = FAMILY_SWISS; break;
471 case AwtFontFamily::SYSTEM: mnFamily = FAMILY_SYSTEM; break;
472 default: mnFamily = FAMILY_DONTKNOW;
476 void XclFontData::SetApiPosture( Awt::FontSlant eApiPosture )
478 mbItalic =
479 (eApiPosture == Awt::FontSlant_OBLIQUE) ||
480 (eApiPosture == Awt::FontSlant_ITALIC) ||
481 (eApiPosture == Awt::FontSlant_REVERSE_OBLIQUE) ||
482 (eApiPosture == Awt::FontSlant_REVERSE_ITALIC);
485 void XclFontData::SetApiWeight( float fApiWeight )
487 SetScWeight( VCLUnoHelper::ConvertFontWeight( fApiWeight ) );
490 void XclFontData::SetApiUnderline( sal_Int16 nApiUnderl )
492 switch( nApiUnderl )
494 case AwtFontUnderline::NONE:
495 case AwtFontUnderline::DONTKNOW: mnUnderline = EXC_FONTUNDERL_NONE; break;
496 case AwtFontUnderline::DOUBLE:
497 case AwtFontUnderline::DOUBLEWAVE: mnUnderline = EXC_FONTUNDERL_DOUBLE; break;
498 default: mnUnderline = EXC_FONTUNDERL_SINGLE;
502 void XclFontData::SetApiEscapement( sal_Int16 nApiEscapem )
504 if( nApiEscapem > 0 )
505 mnEscapem = EXC_FONTESC_SUPER;
506 else if( nApiEscapem < 0 )
507 mnEscapem = EXC_FONTESC_SUB;
508 else
509 mnEscapem = EXC_FONTESC_NONE;
512 void XclFontData::SetApiStrikeout( sal_Int16 nApiStrikeout )
514 mbStrikeout =
515 (nApiStrikeout != AwtFontStrikeout::NONE) &&
516 (nApiStrikeout != AwtFontStrikeout::DONTKNOW);
519 // ----------------------------------------------------------------------------
521 bool operator==( const XclFontData& rLeft, const XclFontData& rRight )
523 return
524 (rLeft.mnHeight == rRight.mnHeight) &&
525 (rLeft.mnWeight == rRight.mnWeight) &&
526 (rLeft.mnUnderline == rRight.mnUnderline) &&
527 (rLeft.maColor == rRight.maColor) &&
528 (rLeft.mnEscapem == rRight.mnEscapem) &&
529 (rLeft.mnFamily == rRight.mnFamily) &&
530 (rLeft.mnCharSet == rRight.mnCharSet) &&
531 (rLeft.mbItalic == rRight.mbItalic) &&
532 (rLeft.mbStrikeout == rRight.mbStrikeout) &&
533 (rLeft.mbOutline == rRight.mbOutline) &&
534 (rLeft.mbShadow == rRight.mbShadow) &&
535 (rLeft.maName == rRight.maName);
538 // ----------------------------------------------------------------------------
540 namespace {
542 /** Property names for common font settings. */
543 const sal_Char *const sppcPropNamesChCommon[] =
545 "CharUnderline", "CharStrikeout", "CharColor", "CharContoured", "CharShadowed", 0
547 /** Property names for Western font settings. */
548 const sal_Char *const sppcPropNamesChWstrn[] =
550 "CharFontName", "CharHeight", "CharPosture", "CharWeight", 0
552 /** Property names for Asian font settings. */
553 const sal_Char *const sppcPropNamesChAsian[] =
555 "CharFontNameAsian", "CharHeightAsian", "CharPostureAsian", "CharWeightAsian", 0
557 /** Property names for Complex font settings. */
558 const sal_Char *const sppcPropNamesChCmplx[] =
560 "CharFontNameComplex", "CharHeightComplex", "CharPostureComplex", "CharWeightComplex", 0
562 /** Property names for escapement. */
563 const sal_Char *const sppcPropNamesChEscapement[] =
565 "CharEscapement", "CharEscapementHeight", 0
567 const sal_Int8 EXC_API_ESC_HEIGHT = 58; /// Default escapement font height.
569 /** Property names for Western font settings without font name. */
570 const sal_Char *const *const sppcPropNamesChWstrnNoName = sppcPropNamesChWstrn + 1;
571 /** Property names for Asian font settings without font name. */
572 const sal_Char *const *const sppcPropNamesChAsianNoName = sppcPropNamesChAsian + 1;
573 /** Property names for Complex font settings without font name. */
574 const sal_Char *const *const sppcPropNamesChCmplxNoName = sppcPropNamesChCmplx + 1;
576 /** Property names for font settings in form controls. */
577 const sal_Char *const sppcPropNamesControl[] =
579 "FontName", "FontFamily", "FontCharset", "FontHeight", "FontSlant",
580 "FontWeight", "FontUnderline", "FontStrikeout", "TextColor", 0
583 /** Inserts all passed API font settings into the font data object. */
584 void lclSetApiFontSettings( XclFontData& rFontData,
585 const String& rApiFontName, float fApiHeight, float fApiWeight,
586 Awt::FontSlant eApiPosture, sal_Int16 nApiUnderl, sal_Int16 nApiStrikeout )
588 rFontData.maName = XclTools::GetXclFontName( rApiFontName );
589 rFontData.SetApiHeight( fApiHeight );
590 rFontData.SetApiWeight( fApiWeight );
591 rFontData.SetApiPosture( eApiPosture );
592 rFontData.SetApiUnderline( nApiUnderl );
593 rFontData.SetApiStrikeout( nApiStrikeout );
596 /** Writes script dependent properties to a font property set helper. */
597 void lclWriteChartFont( ScfPropertySet& rPropSet,
598 ScfPropSetHelper& rHlpName, ScfPropSetHelper& rHlpNoName,
599 const XclFontData& rFontData, bool bHasFontName )
601 // select the font helper
602 ScfPropSetHelper& rPropSetHlp = bHasFontName ? rHlpName : rHlpNoName;
603 // initialize the font helper (must be called before writing any properties)
604 rPropSetHlp.InitializeWrite();
605 // write font name
606 if( bHasFontName )
607 rPropSetHlp << rFontData.maName;
608 // write remaining properties
609 rPropSetHlp << rFontData.GetApiHeight() << rFontData.GetApiPosture() << rFontData.GetApiWeight();
610 // write properties to property set
611 rPropSetHlp.WriteToPropertySet( rPropSet );
614 } // namespace
616 // ----------------------------------------------------------------------------
618 XclFontPropSetHelper::XclFontPropSetHelper() :
619 maHlpChCommon( sppcPropNamesChCommon ),
620 maHlpChWstrn( sppcPropNamesChWstrn ),
621 maHlpChAsian( sppcPropNamesChAsian ),
622 maHlpChCmplx( sppcPropNamesChCmplx ),
623 maHlpChWstrnNoName( sppcPropNamesChWstrnNoName ),
624 maHlpChAsianNoName( sppcPropNamesChAsianNoName ),
625 maHlpChCmplxNoName( sppcPropNamesChCmplxNoName ),
626 maHlpChEscapement( sppcPropNamesChEscapement ),
627 maHlpControl( sppcPropNamesControl )
631 void XclFontPropSetHelper::ReadFontProperties( XclFontData& rFontData,
632 const ScfPropertySet& rPropSet, XclFontPropSetType eType, sal_Int16 nScript )
634 switch( eType )
636 case EXC_FONTPROPSET_CHART:
638 String aApiFontName;
639 float fApiHeight, fApiWeight;
640 sal_Int16 nApiUnderl = 0, nApiStrikeout = 0;
641 Awt::FontSlant eApiPosture;
643 // read script type dependent properties
644 ScfPropSetHelper& rPropSetHlp = GetChartHelper( nScript );
645 rPropSetHlp.ReadFromPropertySet( rPropSet );
646 rPropSetHlp >> aApiFontName >> fApiHeight >> eApiPosture >> fApiWeight;
647 // read common properties
648 maHlpChCommon.ReadFromPropertySet( rPropSet );
649 maHlpChCommon >> nApiUnderl
650 >> nApiStrikeout
651 >> rFontData.maColor
652 >> rFontData.mbOutline
653 >> rFontData.mbShadow;
655 // convert API property values to Excel settings
656 lclSetApiFontSettings( rFontData, aApiFontName,
657 fApiHeight, fApiWeight, eApiPosture, nApiUnderl, nApiStrikeout );
659 // font escapement
660 sal_Int16 nApiEscapement = 0;
661 sal_Int8 nApiEscHeight = 0;
662 maHlpChEscapement.ReadFromPropertySet( rPropSet );
663 maHlpChEscapement.ReadFromPropertySet( rPropSet );
664 maHlpChEscapement.ReadFromPropertySet( rPropSet );
665 maHlpChEscapement >> nApiEscapement >> nApiEscHeight;
666 rFontData.SetApiEscapement( nApiEscapement );
668 break;
670 case EXC_FONTPROPSET_CONTROL:
672 String aApiFontName;
673 float fApiHeight, fApiWeight;
674 sal_Int16 nApiFamily, nApiCharSet, nApiPosture, nApiUnderl, nApiStrikeout;
676 // read font properties
677 maHlpControl.ReadFromPropertySet( rPropSet );
678 maHlpControl >> aApiFontName
679 >> nApiFamily
680 >> nApiCharSet
681 >> fApiHeight
682 >> nApiPosture
683 >> fApiWeight
684 >> nApiUnderl
685 >> nApiStrikeout
686 >> rFontData.maColor;
688 // convert API property values to Excel settings
689 Awt::FontSlant eApiPosture = static_cast< Awt::FontSlant >( nApiPosture );
690 lclSetApiFontSettings( rFontData, aApiFontName,
691 fApiHeight, fApiWeight, eApiPosture, nApiUnderl, nApiStrikeout );
692 rFontData.SetApiFamily( nApiFamily );
693 rFontData.SetFontEncoding( nApiCharSet );
695 break;
699 void XclFontPropSetHelper::WriteFontProperties(
700 ScfPropertySet& rPropSet, XclFontPropSetType eType,
701 const XclFontData& rFontData, bool bHasWstrn, bool bHasAsian, bool bHasCmplx,
702 const Color* pFontColor )
704 switch( eType )
706 case EXC_FONTPROPSET_CHART:
708 // write common properties
709 maHlpChCommon.InitializeWrite();
710 const Color& rColor = pFontColor ? *pFontColor : rFontData.maColor;
711 maHlpChCommon << rFontData.GetApiUnderline()
712 << rFontData.GetApiStrikeout()
713 << rColor
714 << rFontData.mbOutline
715 << rFontData.mbShadow;
716 maHlpChCommon.WriteToPropertySet( rPropSet );
718 // write script type dependent properties
719 lclWriteChartFont( rPropSet, maHlpChWstrn, maHlpChWstrnNoName, rFontData, bHasWstrn );
720 lclWriteChartFont( rPropSet, maHlpChAsian, maHlpChAsianNoName, rFontData, bHasAsian );
721 lclWriteChartFont( rPropSet, maHlpChCmplx, maHlpChCmplxNoName, rFontData, bHasCmplx );
723 // font escapement
724 if( rFontData.GetScEscapement() != SVX_ESCAPEMENT_OFF )
726 maHlpChEscapement.InitializeWrite();
727 maHlpChEscapement << rFontData.GetApiEscapement() << EXC_API_ESC_HEIGHT;
728 maHlpChEscapement.WriteToPropertySet( rPropSet );
731 break;
733 case EXC_FONTPROPSET_CONTROL:
735 maHlpControl.InitializeWrite();
736 maHlpControl << rFontData.maName
737 << rFontData.GetApiFamily()
738 << rFontData.GetApiFontEncoding()
739 << static_cast< sal_Int16 >( rFontData.GetApiHeight() + 0.5 )
740 << rFontData.GetApiPosture()
741 << rFontData.GetApiWeight()
742 << rFontData.GetApiUnderline()
743 << rFontData.GetApiStrikeout()
744 << rFontData.maColor;
745 maHlpControl.WriteToPropertySet( rPropSet );
747 break;
751 ScfPropSetHelper& XclFontPropSetHelper::GetChartHelper( sal_Int16 nScript )
753 namespace ApiScriptType = ::com::sun::star::i18n::ScriptType;
754 switch( nScript )
756 case ApiScriptType::LATIN: return maHlpChWstrn;
757 case ApiScriptType::ASIAN: return maHlpChAsian;
758 case ApiScriptType::COMPLEX: return maHlpChCmplx;
759 default: OSL_FAIL( "XclFontPropSetHelper::GetChartHelper - unknown script type" );
761 return maHlpChWstrn;
764 // Number formats =============================================================
766 namespace {
768 // ----------------------------------------------------------------------------
770 /** Special number format index describing a reused format. */
771 const NfIndexTableOffset PRV_NF_INDEX_REUSE = NF_INDEX_TABLE_ENTRIES;
773 /** German primary language not defined, LANGUAGE_GERMAN belongs to Germany. */
774 const LanguageType PRV_LANGUAGE_GERMAN_PRIM = LANGUAGE_GERMAN & LANGUAGE_MASK_PRIMARY;
775 /** French primary language not defined, LANGUAGE_FRENCH belongs to France. */
776 const LanguageType PRV_LANGUAGE_FRENCH_PRIM = LANGUAGE_FRENCH & LANGUAGE_MASK_PRIMARY;
777 /** Parent language identifier for Asian languages (LANGUAGE_CHINESE is a primary only ID). */
778 const LanguageType PRV_LANGUAGE_ASIAN_PRIM = LANGUAGE_CHINESE;
780 // ----------------------------------------------------------------------------
782 /** Stores the number format used in Calc for an Excel built-in number format. */
783 struct XclBuiltInFormat
785 sal_uInt16 mnXclNumFmt; /// Excel built-in index.
786 const sal_Char* mpFormat; /// Format string, may be 0 (meOffset used then).
787 NfIndexTableOffset meOffset; /// SvNumberFormatter format index, if mpFormat==0.
788 sal_uInt16 mnXclReuseFmt; /// Use this Excel format, if meOffset==PRV_NF_INDEX_REUSE.
791 // ----------------------------------------------------------------------------
793 /** Defines a literal Excel built-in number format. */
794 #define EXC_NUMFMT_STRING( nXclNumFmt, pcUtf8 ) \
795 { nXclNumFmt, pcUtf8, NF_NUMBER_STANDARD, 0 }
797 /** Defines an Excel built-in number format that maps to an own built-in format. */
798 #define EXC_NUMFMT_OFFSET( nXclNumFmt, eOffset ) \
799 { nXclNumFmt, 0, eOffset, 0 }
801 /** Defines an Excel built-in number format that is the same as the specified. */
802 #define EXC_NUMFMT_REUSE( nXclNumFmt, nXclReuse ) \
803 { nXclNumFmt, 0, PRV_NF_INDEX_REUSE, nXclReuse }
805 /** Terminates an Excel built-in number format table. */
806 #define EXC_NUMFMT_ENDTABLE() \
807 { EXC_FORMAT_NOTFOUND, 0, NF_NUMBER_STANDARD, 0 }
809 // ----------------------------------------------------------------------------
811 // Currency unit characters
812 #define UTF8_BAHT "\340\270\277"
813 #define UTF8_EURO "\342\202\254"
814 #define UTF8_POUND_UK "\302\243"
815 #define UTF8_SHEQEL "\342\202\252"
816 #define UTF8_WON "\357\277\246"
817 #define UTF8_YEN_CS "\357\277\245"
818 #define UTF8_YEN_JP "\302\245"
820 // Japanese/Chinese date/time characters
821 #define UTF8_CJ_YEAR "\345\271\264"
822 #define UTF8_CJ_MON "\346\234\210"
823 #define UTF8_CJ_DAY "\346\227\245"
824 #define UTF8_CJ_HOUR "\346\231\202"
825 #define UTF8_CJ_MIN "\345\210\206"
826 #define UTF8_CJ_SEC "\347\247\222"
828 // Chinese Simplified date/time characters
829 #define UTF8_CS_HOUR "\346\227\266"
831 // Korean date/time characters
832 #define UTF8_KO_YEAR "\353\205\204"
833 #define UTF8_KO_MON "\354\233\224"
834 #define UTF8_KO_DAY "\354\235\274"
835 #define UTF8_KO_HOUR "\354\213\234"
836 #define UTF8_KO_MIN "\353\266\204"
837 #define UTF8_KO_SEC "\354\264\210"
839 // ----------------------------------------------------------------------------
841 /** Default number format table. Last parent of all other tables, used for unknown languages. */
842 static const XclBuiltInFormat spBuiltInFormats_DONTKNOW[] =
844 EXC_NUMFMT_OFFSET( 0, NF_NUMBER_STANDARD ), // General
845 EXC_NUMFMT_OFFSET( 1, NF_NUMBER_INT ), // 0
846 EXC_NUMFMT_OFFSET( 2, NF_NUMBER_DEC2 ), // 0.00
847 EXC_NUMFMT_OFFSET( 3, NF_NUMBER_1000INT ), // #,##0
848 EXC_NUMFMT_OFFSET( 4, NF_NUMBER_1000DEC2 ), // #,##0.00
849 // 5...8 contained in file
850 EXC_NUMFMT_OFFSET( 9, NF_PERCENT_INT ), // 0%
851 EXC_NUMFMT_OFFSET( 10, NF_PERCENT_DEC2 ), // 0.00%
852 EXC_NUMFMT_OFFSET( 11, NF_SCIENTIFIC_000E00 ), // 0.00E+00
853 EXC_NUMFMT_OFFSET( 12, NF_FRACTION_1 ), // # ?/?
854 EXC_NUMFMT_OFFSET( 13, NF_FRACTION_2 ), // # ??/??
856 // 14...22 date and time formats
857 EXC_NUMFMT_OFFSET( 14, NF_DATE_SYS_DDMMYYYY ),
858 EXC_NUMFMT_OFFSET( 15, NF_DATE_SYS_DMMMYY ),
859 EXC_NUMFMT_OFFSET( 16, NF_DATE_SYS_DDMMM ),
860 EXC_NUMFMT_OFFSET( 17, NF_DATE_SYS_MMYY ),
861 EXC_NUMFMT_OFFSET( 18, NF_TIME_HHMMAMPM ),
862 EXC_NUMFMT_OFFSET( 19, NF_TIME_HHMMSSAMPM ),
863 EXC_NUMFMT_OFFSET( 20, NF_TIME_HHMM ),
864 EXC_NUMFMT_OFFSET( 21, NF_TIME_HHMMSS ),
865 EXC_NUMFMT_OFFSET( 22, NF_DATETIME_SYSTEM_SHORT_HHMM ),
867 // 23...36 international formats
868 EXC_NUMFMT_REUSE( 23, 0 ),
869 EXC_NUMFMT_REUSE( 24, 0 ),
870 EXC_NUMFMT_REUSE( 25, 0 ),
871 EXC_NUMFMT_REUSE( 26, 0 ),
872 EXC_NUMFMT_REUSE( 27, 14 ),
873 EXC_NUMFMT_REUSE( 28, 14 ),
874 EXC_NUMFMT_REUSE( 29, 14 ),
875 EXC_NUMFMT_REUSE( 30, 14 ),
876 EXC_NUMFMT_REUSE( 31, 14 ),
877 EXC_NUMFMT_REUSE( 32, 21 ),
878 EXC_NUMFMT_REUSE( 33, 21 ),
879 EXC_NUMFMT_REUSE( 34, 21 ),
880 EXC_NUMFMT_REUSE( 35, 21 ),
881 EXC_NUMFMT_REUSE( 36, 14 ),
883 // 37...44 accounting formats
884 // 41...44 contained in file
885 EXC_NUMFMT_STRING( 37, "#,##0;-#,##0" ),
886 EXC_NUMFMT_STRING( 38, "#,##0;[RED]-#,##0" ),
887 EXC_NUMFMT_STRING( 39, "#,##0.00;-#,##0.00" ),
888 EXC_NUMFMT_STRING( 40, "#,##0.00;[RED]-#,##0.00" ),
890 // 45...49 more special formats
891 EXC_NUMFMT_STRING( 45, "mm:ss" ),
892 EXC_NUMFMT_STRING( 46, "[h]:mm:ss" ),
893 EXC_NUMFMT_STRING( 47, "mm:ss.0" ),
894 EXC_NUMFMT_STRING( 48, "##0.0E+0" ),
895 EXC_NUMFMT_OFFSET( 49, NF_TEXT ),
897 // 50...81 international formats
898 EXC_NUMFMT_REUSE( 50, 14 ),
899 EXC_NUMFMT_REUSE( 51, 14 ),
900 EXC_NUMFMT_REUSE( 52, 14 ),
901 EXC_NUMFMT_REUSE( 53, 14 ),
902 EXC_NUMFMT_REUSE( 54, 14 ),
903 EXC_NUMFMT_REUSE( 55, 14 ),
904 EXC_NUMFMT_REUSE( 56, 14 ),
905 EXC_NUMFMT_REUSE( 57, 14 ),
906 EXC_NUMFMT_REUSE( 58, 14 ),
907 EXC_NUMFMT_REUSE( 59, 1 ),
908 EXC_NUMFMT_REUSE( 60, 2 ),
909 EXC_NUMFMT_REUSE( 61, 3 ),
910 EXC_NUMFMT_REUSE( 62, 4 ),
911 EXC_NUMFMT_REUSE( 67, 9 ),
912 EXC_NUMFMT_REUSE( 68, 10 ),
913 EXC_NUMFMT_REUSE( 69, 12 ),
914 EXC_NUMFMT_REUSE( 70, 13 ),
915 EXC_NUMFMT_REUSE( 71, 14 ),
916 EXC_NUMFMT_REUSE( 72, 14 ),
917 EXC_NUMFMT_REUSE( 73, 15 ),
918 EXC_NUMFMT_REUSE( 74, 16 ),
919 EXC_NUMFMT_REUSE( 75, 17 ),
920 EXC_NUMFMT_REUSE( 76, 20 ),
921 EXC_NUMFMT_REUSE( 77, 21 ),
922 EXC_NUMFMT_REUSE( 78, 22 ),
923 EXC_NUMFMT_REUSE( 79, 45 ),
924 EXC_NUMFMT_REUSE( 80, 46 ),
925 EXC_NUMFMT_REUSE( 81, 47 ),
927 // 82...163 not used, must not occur in a file (Excel may crash)
929 EXC_NUMFMT_ENDTABLE()
932 // ENGLISH --------------------------------------------------------------------
934 /** Base table for English locales. */
935 static const XclBuiltInFormat spBuiltInFormats_ENGLISH[] =
937 EXC_NUMFMT_STRING( 15, "DD-MMM-YY" ),
938 EXC_NUMFMT_STRING( 16, "DD-MMM" ),
939 EXC_NUMFMT_STRING( 17, "MMM-YY" ),
940 EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
941 EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
942 EXC_NUMFMT_STRING( 22, "DD/MM/YYYY hh:mm" ),
943 EXC_NUMFMT_ENDTABLE()
946 static const XclBuiltInFormat spBuiltInFormats_ENGLISH_UK[] =
948 EXC_NUMFMT_STRING( 63, UTF8_POUND_UK "#,##0;-" UTF8_POUND_UK "#,##0" ),
949 EXC_NUMFMT_STRING( 64, UTF8_POUND_UK "#,##0;[RED]-" UTF8_POUND_UK "#,##0" ),
950 EXC_NUMFMT_STRING( 65, UTF8_POUND_UK "#,##0.00;-" UTF8_POUND_UK "#,##0.00" ),
951 EXC_NUMFMT_STRING( 66, UTF8_POUND_UK "#,##0.00;[RED]-" UTF8_POUND_UK "#,##0.00" ),
952 EXC_NUMFMT_ENDTABLE()
955 static const XclBuiltInFormat spBuiltInFormats_ENGLISH_EIRE[] =
957 EXC_NUMFMT_STRING( 63, UTF8_EURO "#,##0;-" UTF8_EURO "#,##0" ),
958 EXC_NUMFMT_STRING( 64, UTF8_EURO "#,##0;[RED]-" UTF8_EURO "#,##0" ),
959 EXC_NUMFMT_STRING( 65, UTF8_EURO "#,##0.00;-" UTF8_EURO "#,##0.00" ),
960 EXC_NUMFMT_STRING( 66, UTF8_EURO "#,##0.00;[RED]-" UTF8_EURO "#,##0.00" ),
961 EXC_NUMFMT_ENDTABLE()
964 static const XclBuiltInFormat spBuiltInFormats_ENGLISH_US[] =
966 EXC_NUMFMT_STRING( 14, "M/D/YYYY" ),
967 EXC_NUMFMT_STRING( 15, "D-MMM-YY" ),
968 EXC_NUMFMT_STRING( 16, "D-MMM" ),
969 EXC_NUMFMT_STRING( 20, "h:mm" ),
970 EXC_NUMFMT_STRING( 21, "h:mm:ss" ),
971 EXC_NUMFMT_STRING( 22, "M/D/YYYY h:mm" ),
972 EXC_NUMFMT_STRING( 37, "#,##0_);(#,##0)" ),
973 EXC_NUMFMT_STRING( 38, "#,##0_);[RED](#,##0)" ),
974 EXC_NUMFMT_STRING( 39, "#,##0.00_);(#,##0.00)" ),
975 EXC_NUMFMT_STRING( 40, "#,##0.00_);[RED](#,##0.00)" ),
976 EXC_NUMFMT_STRING( 63, "$#,##0_);($#,##0)" ),
977 EXC_NUMFMT_STRING( 64, "$#,##0_);[RED]($#,##0)" ),
978 EXC_NUMFMT_STRING( 65, "$#,##0.00_);($#,##0.00)" ),
979 EXC_NUMFMT_STRING( 66, "$#,##0.00_);[RED]($#,##0.00)" ),
980 EXC_NUMFMT_ENDTABLE()
983 static const XclBuiltInFormat spBuiltInFormats_ENGLISH_CAN[] =
985 EXC_NUMFMT_STRING( 20, "h:mm" ),
986 EXC_NUMFMT_STRING( 21, "h:mm:ss" ),
987 EXC_NUMFMT_STRING( 22, "DD/MM/YYYY h:mm" ),
988 EXC_NUMFMT_STRING( 63, "$#,##0;-$#,##0" ),
989 EXC_NUMFMT_STRING( 64, "$#,##0;[RED]-$#,##0" ),
990 EXC_NUMFMT_STRING( 65, "$#,##0.00;-$#,##0.00" ),
991 EXC_NUMFMT_STRING( 66, "$#,##0.00;[RED]-$#,##0.00" ),
992 EXC_NUMFMT_ENDTABLE()
995 static const XclBuiltInFormat spBuiltInFormats_ENGLISH_AUS[] =
997 EXC_NUMFMT_STRING( 14, "D/MM/YYYY" ),
998 EXC_NUMFMT_STRING( 15, "D-MMM-YY" ),
999 EXC_NUMFMT_STRING( 16, "D-MMM" ),
1000 EXC_NUMFMT_STRING( 20, "h:mm" ),
1001 EXC_NUMFMT_STRING( 21, "h:mm:ss" ),
1002 EXC_NUMFMT_STRING( 22, "D/MM/YYYY h:mm" ),
1003 EXC_NUMFMT_STRING( 63, "$#,##0;-$#,##0" ),
1004 EXC_NUMFMT_STRING( 64, "$#,##0;[RED]-$#,##0" ),
1005 EXC_NUMFMT_STRING( 65, "$#,##0.00;-$#,##0.00" ),
1006 EXC_NUMFMT_STRING( 66, "$#,##0.00;[RED]-$#,##0.00" ),
1007 EXC_NUMFMT_ENDTABLE()
1010 static const XclBuiltInFormat spBuiltInFormats_ENGLISH_SAFRICA[] =
1012 EXC_NUMFMT_STRING( 14, "YYYY/MM/DD" ),
1013 EXC_NUMFMT_OFFSET( 18, NF_TIME_HHMMAMPM ),
1014 EXC_NUMFMT_OFFSET( 19, NF_TIME_HHMMSSAMPM ),
1015 EXC_NUMFMT_STRING( 22, "YYYY/MM/DD hh:mm" ),
1016 EXC_NUMFMT_STRING( 63, "\\R #,##0;\\R -#,##0" ),
1017 EXC_NUMFMT_STRING( 64, "\\R #,##0;[RED]\\R -#,##0" ),
1018 EXC_NUMFMT_STRING( 65, "\\R #,##0.00;\\R -#,##0.00" ),
1019 EXC_NUMFMT_STRING( 66, "\\R #,##0.00;[RED]\\R -#,##0.00" ),
1020 EXC_NUMFMT_ENDTABLE()
1023 // FRENCH ---------------------------------------------------------------------
1025 /** Base table for French locales. */
1026 static const XclBuiltInFormat spBuiltInFormats_FRENCH[] =
1028 EXC_NUMFMT_STRING( 15, "DD-MMM-YY" ),
1029 EXC_NUMFMT_STRING( 16, "DD-MMM" ),
1030 EXC_NUMFMT_STRING( 17, "MMM-YY" ),
1031 EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
1032 EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
1033 EXC_NUMFMT_ENDTABLE()
1036 static const XclBuiltInFormat spBuiltInFormats_FRENCH_FRANCE[] =
1038 EXC_NUMFMT_STRING( 22, "DD/MM/YYYY hh:mm" ),
1039 EXC_NUMFMT_STRING( 37, "#,##0\\ _" UTF8_EURO ";-#,##0\\ _" UTF8_EURO ),
1040 EXC_NUMFMT_STRING( 38, "#,##0\\ _" UTF8_EURO ";[RED]-#,##0\\ _" UTF8_EURO ),
1041 EXC_NUMFMT_STRING( 39, "#,##0.00\\ _" UTF8_EURO ";-#,##0.00\\ _" UTF8_EURO ),
1042 EXC_NUMFMT_STRING( 40, "#,##0.00\\ _" UTF8_EURO ";[RED]-#,##0.00\\ _" UTF8_EURO ),
1043 EXC_NUMFMT_STRING( 63, "#,##0\\ " UTF8_EURO ";-#,##0\\ " UTF8_EURO ),
1044 EXC_NUMFMT_STRING( 64, "#,##0\\ " UTF8_EURO ";[RED]-#,##0\\ " UTF8_EURO ),
1045 EXC_NUMFMT_STRING( 65, "#,##0.00\\ " UTF8_EURO ";-#,##0.00\\ " UTF8_EURO ),
1046 EXC_NUMFMT_STRING( 66, "#,##0.00\\ " UTF8_EURO ";[RED]-#,##0.00\\ " UTF8_EURO ),
1047 EXC_NUMFMT_ENDTABLE()
1050 static const XclBuiltInFormat spBuiltInFormats_FRENCH_CANADIAN[] =
1052 EXC_NUMFMT_STRING( 22, "YYYY-MM-DD hh:mm" ),
1053 EXC_NUMFMT_STRING( 37, "#,##0\\ _$_-;#,##0\\ _$-" ),
1054 EXC_NUMFMT_STRING( 38, "#,##0\\ _$_-;[RED]#,##0\\ _$-" ),
1055 EXC_NUMFMT_STRING( 39, "#,##0.00\\ _$_-;#,##0.00\\ _$-" ),
1056 EXC_NUMFMT_STRING( 40, "#,##0.00\\ _$_-;[RED]#,##0.00\\ _$-" ),
1057 EXC_NUMFMT_STRING( 63, "#,##0\\ $_-;#,##0\\ $-" ),
1058 EXC_NUMFMT_STRING( 64, "#,##0\\ $_-;[RED]#,##0\\ $-" ),
1059 EXC_NUMFMT_STRING( 65, "#,##0.00\\ $_-;#,##0.00\\ $-" ),
1060 EXC_NUMFMT_STRING( 66, "#,##0.00\\ $_-;[RED]#,##0.00\\ $-" ),
1061 EXC_NUMFMT_ENDTABLE()
1064 static const XclBuiltInFormat spBuiltInFormats_FRENCH_SWISS[] =
1066 EXC_NUMFMT_STRING( 15, "DD.MMM.YY" ),
1067 EXC_NUMFMT_STRING( 16, "DD.MMM" ),
1068 EXC_NUMFMT_STRING( 17, "MMM.YY" ),
1069 EXC_NUMFMT_STRING( 22, "DD.MM.YYYY hh:mm" ),
1070 EXC_NUMFMT_STRING( 63, "\"SFr. \"#,##0;\"SFr. \"-#,##0" ),
1071 EXC_NUMFMT_STRING( 64, "\"SFr. \"#,##0;[RED]\"SFr. \"-#,##0" ),
1072 EXC_NUMFMT_STRING( 65, "\"SFr. \"#,##0.00;\"SFr. \"-#,##0.00" ),
1073 EXC_NUMFMT_STRING( 66, "\"SFr. \"#,##0.00;[RED]\"SFr. \"-#,##0.00" ),
1074 EXC_NUMFMT_ENDTABLE()
1077 static const XclBuiltInFormat spBuiltInFormats_FRENCH_BELGIAN[] =
1079 EXC_NUMFMT_STRING( 14, "D/MM/YYYY" ),
1080 EXC_NUMFMT_STRING( 15, "D-MMM-YY" ),
1081 EXC_NUMFMT_STRING( 16, "D-MMM" ),
1082 EXC_NUMFMT_STRING( 20, "h:mm" ),
1083 EXC_NUMFMT_STRING( 21, "h:mm:ss" ),
1084 EXC_NUMFMT_STRING( 22, "D/MM/YYYY h:mm" ),
1085 EXC_NUMFMT_ENDTABLE()
1088 // GERMAN ---------------------------------------------------------------------
1090 /** Base table for German locales. */
1091 static const XclBuiltInFormat spBuiltInFormats_GERMAN[] =
1093 EXC_NUMFMT_STRING( 15, "DD. MMM YY" ),
1094 EXC_NUMFMT_STRING( 16, "DD. MMM" ),
1095 EXC_NUMFMT_STRING( 17, "MMM YY" ),
1096 EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
1097 EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
1098 EXC_NUMFMT_STRING( 22, "DD.MM.YYYY hh:mm" ),
1099 EXC_NUMFMT_ENDTABLE()
1102 static const XclBuiltInFormat spBuiltInFormats_GERMAN_GERMANY[] =
1104 EXC_NUMFMT_STRING( 37, "#,##0 _" UTF8_EURO ";-#,##0 _" UTF8_EURO ),
1105 EXC_NUMFMT_STRING( 38, "#,##0 _" UTF8_EURO ";[RED]-#,##0 _" UTF8_EURO ),
1106 EXC_NUMFMT_STRING( 39, "#,##0.00 _" UTF8_EURO ";-#,##0.00 _" UTF8_EURO ),
1107 EXC_NUMFMT_STRING( 40, "#,##0.00 _" UTF8_EURO ";[RED]-#,##0.00 _" UTF8_EURO ),
1108 EXC_NUMFMT_STRING( 63, "#,##0 " UTF8_EURO ";-#,##0 " UTF8_EURO ),
1109 EXC_NUMFMT_STRING( 64, "#,##0 " UTF8_EURO ";[RED]-#,##0 " UTF8_EURO ),
1110 EXC_NUMFMT_STRING( 65, "#,##0.00 " UTF8_EURO ";-#,##0.00 " UTF8_EURO ),
1111 EXC_NUMFMT_STRING( 66, "#,##0.00 " UTF8_EURO ";[RED]-#,##0.00 " UTF8_EURO ),
1112 EXC_NUMFMT_ENDTABLE()
1115 static const XclBuiltInFormat spBuiltInFormats_GERMAN_AUSTRIAN[] =
1117 EXC_NUMFMT_STRING( 15, "DD.MMM.YY" ),
1118 EXC_NUMFMT_STRING( 16, "DD.MMM" ),
1119 EXC_NUMFMT_STRING( 17, "MMM.YY" ),
1120 EXC_NUMFMT_STRING( 63, UTF8_EURO " #,##0;-" UTF8_EURO " #,##0" ),
1121 EXC_NUMFMT_STRING( 64, UTF8_EURO " #,##0;[RED]-" UTF8_EURO " #,##0" ),
1122 EXC_NUMFMT_STRING( 65, UTF8_EURO " #,##0.00;-" UTF8_EURO " #,##0.00" ),
1123 EXC_NUMFMT_STRING( 66, UTF8_EURO " #,##0.00;[RED]-" UTF8_EURO " #,##0.00" ),
1124 EXC_NUMFMT_ENDTABLE()
1127 static const XclBuiltInFormat spBuiltInFormats_GERMAN_SWISS[] =
1129 EXC_NUMFMT_STRING( 63, "\"SFr. \"#,##0;\"SFr. \"-#,##0" ),
1130 EXC_NUMFMT_STRING( 64, "\"SFr. \"#,##0;[RED]\"SFr. \"-#,##0" ),
1131 EXC_NUMFMT_STRING( 65, "\"SFr. \"#,##0.00;\"SFr. \"-#,##0.00" ),
1132 EXC_NUMFMT_STRING( 66, "\"SFr. \"#,##0.00;[RED]\"SFr. \"-#,##0.00" ),
1133 EXC_NUMFMT_ENDTABLE()
1136 static const XclBuiltInFormat spBuiltInFormats_GERMAN_LUXEMBOURG[] =
1138 EXC_NUMFMT_STRING( 15, "DD.MMM.YY" ),
1139 EXC_NUMFMT_STRING( 16, "DD.MMM" ),
1140 EXC_NUMFMT_STRING( 17, "MMM.YY" ),
1141 EXC_NUMFMT_STRING( 37, "#,##0 _" UTF8_EURO ";-#,##0 _" UTF8_EURO ),
1142 EXC_NUMFMT_STRING( 38, "#,##0 _" UTF8_EURO ";[RED]-#,##0 _" UTF8_EURO ),
1143 EXC_NUMFMT_STRING( 39, "#,##0.00 _" UTF8_EURO ";-#,##0.00 _" UTF8_EURO ),
1144 EXC_NUMFMT_STRING( 40, "#,##0.00 _" UTF8_EURO ";[RED]-#,##0.00 _" UTF8_EURO ),
1145 EXC_NUMFMT_STRING( 63, "#,##0 " UTF8_EURO ";-#,##0 " UTF8_EURO ),
1146 EXC_NUMFMT_STRING( 64, "#,##0 " UTF8_EURO ";[RED]-#,##0 " UTF8_EURO ),
1147 EXC_NUMFMT_STRING( 65, "#,##0.00 " UTF8_EURO ";-#,##0.00 " UTF8_EURO ),
1148 EXC_NUMFMT_STRING( 66, "#,##0.00 " UTF8_EURO ";[RED]-#,##0.00 " UTF8_EURO ),
1149 EXC_NUMFMT_ENDTABLE()
1152 static const XclBuiltInFormat spBuiltInFormats_GERMAN_LIECHTENSTEIN[] =
1154 EXC_NUMFMT_STRING( 63, "\"CHF \"#,##0;\"CHF \"-#,##0" ),
1155 EXC_NUMFMT_STRING( 64, "\"CHF \"#,##0;[RED]\"CHF \"-#,##0" ),
1156 EXC_NUMFMT_STRING( 65, "\"CHF \"#,##0.00;\"CHF \"-#,##0.00" ),
1157 EXC_NUMFMT_STRING( 66, "\"CHF \"#,##0.00;[RED]\"CHF \"-#,##0.00" ),
1158 EXC_NUMFMT_ENDTABLE()
1161 // ITALIAN --------------------------------------------------------------------
1163 static const XclBuiltInFormat spBuiltInFormats_ITALIAN_ITALY[] =
1165 EXC_NUMFMT_STRING( 15, "DD-MMM-YY" ),
1166 EXC_NUMFMT_STRING( 16, "DD-MMM" ),
1167 EXC_NUMFMT_STRING( 17, "MMM-YY" ),
1168 EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
1169 EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
1170 EXC_NUMFMT_STRING( 20, "h:mm" ),
1171 EXC_NUMFMT_STRING( 21, "h:mm:ss" ),
1172 EXC_NUMFMT_STRING( 22, "DD/MM/YYYY h:mm" ),
1173 EXC_NUMFMT_STRING( 63, UTF8_EURO " #,##0;-" UTF8_EURO " #,##0" ),
1174 EXC_NUMFMT_STRING( 64, UTF8_EURO " #,##0;[RED]-" UTF8_EURO " #,##0" ),
1175 EXC_NUMFMT_STRING( 65, UTF8_EURO " #,##0.00;-" UTF8_EURO " #,##0.00" ),
1176 EXC_NUMFMT_STRING( 66, UTF8_EURO " #,##0.00;[RED]-" UTF8_EURO " #,##0.00" ),
1177 EXC_NUMFMT_ENDTABLE()
1180 static const XclBuiltInFormat spBuiltInFormats_ITALIAN_SWISS[] =
1182 EXC_NUMFMT_STRING( 15, "DD.MMM.YY" ),
1183 EXC_NUMFMT_STRING( 16, "DD.MMM" ),
1184 EXC_NUMFMT_STRING( 17, "MMM.YY" ),
1185 EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
1186 EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
1187 EXC_NUMFMT_STRING( 22, "DD.MM.YYYY hh:mm" ),
1188 EXC_NUMFMT_STRING( 63, "\"SFr. \"#,##0;\"SFr. \"-#,##0" ),
1189 EXC_NUMFMT_STRING( 64, "\"SFr. \"#,##0;[RED]\"SFr. \"-#,##0" ),
1190 EXC_NUMFMT_STRING( 65, "\"SFr. \"#,##0.00;\"SFr. \"-#,##0.00" ),
1191 EXC_NUMFMT_STRING( 66, "\"SFr. \"#,##0.00;[RED]\"SFr. \"-#,##0.00" ),
1192 EXC_NUMFMT_ENDTABLE()
1195 // SWEDISH --------------------------------------------------------------------
1197 static const XclBuiltInFormat spBuiltInFormats_SWEDISH_SWEDEN[] =
1199 EXC_NUMFMT_STRING( 15, "DD-MMM-YY" ),
1200 EXC_NUMFMT_STRING( 16, "DD-MMM" ),
1201 EXC_NUMFMT_STRING( 17, "MMM-YY" ),
1202 EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
1203 EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
1204 EXC_NUMFMT_STRING( 22, "YYYY-MM-DD hh:mm" ),
1205 EXC_NUMFMT_STRING( 37, "#,##0 _k_r;-#,##0 _k_r" ),
1206 EXC_NUMFMT_STRING( 38, "#,##0 _k_r;[RED]-#,##0 _k_r" ),
1207 EXC_NUMFMT_STRING( 39, "#,##0.00 _k_r;-#,##0.00 _k_r" ),
1208 EXC_NUMFMT_STRING( 40, "#,##0.00 _k_r;[RED]-#,##0.00 _k_r" ),
1209 EXC_NUMFMT_STRING( 63, "#,##0 \"kr\";-#,##0 \"kr\"" ),
1210 EXC_NUMFMT_STRING( 64, "#,##0 \"kr\";[RED]-#,##0 \"kr\"" ),
1211 EXC_NUMFMT_STRING( 65, "#,##0.00 \"kr\";-#,##0.00 \"kr\"" ),
1212 EXC_NUMFMT_STRING( 66, "#,##0.00 \"kr\";[RED]-#,##0.00 \"kr\"" ),
1213 EXC_NUMFMT_ENDTABLE()
1216 static const XclBuiltInFormat spBuiltInFormats_SWEDISH_FINLAND[] =
1218 EXC_NUMFMT_STRING( 9, "0 %" ),
1219 EXC_NUMFMT_STRING( 10, "0.00 %" ),
1220 EXC_NUMFMT_STRING( 15, "DD.MMM.YY" ),
1221 EXC_NUMFMT_STRING( 16, "DD.MMM" ),
1222 EXC_NUMFMT_STRING( 17, "MMM.YY" ),
1223 EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
1224 EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
1225 EXC_NUMFMT_STRING( 22, "D.M.YYYY hh:mm" ),
1226 EXC_NUMFMT_STRING( 37, "#,##0 _" UTF8_EURO ";-#,##0 _" UTF8_EURO ),
1227 EXC_NUMFMT_STRING( 38, "#,##0 _" UTF8_EURO ";[RED]-#,##0 _" UTF8_EURO ),
1228 EXC_NUMFMT_STRING( 39, "#,##0.00 _" UTF8_EURO ";-#,##0.00 _" UTF8_EURO ),
1229 EXC_NUMFMT_STRING( 40, "#,##0.00 _" UTF8_EURO ";[RED]-#,##0.00 _" UTF8_EURO ),
1230 EXC_NUMFMT_STRING( 63, "#,##0 " UTF8_EURO ";-#,##0 " UTF8_EURO ),
1231 EXC_NUMFMT_STRING( 64, "#,##0 " UTF8_EURO ";[RED]-#,##0 " UTF8_EURO ),
1232 EXC_NUMFMT_STRING( 65, "#,##0.00 " UTF8_EURO ";-#,##0.00 " UTF8_EURO ),
1233 EXC_NUMFMT_STRING( 66, "#,##0.00 " UTF8_EURO ";[RED]-#,##0.00 " UTF8_EURO ),
1234 EXC_NUMFMT_ENDTABLE()
1237 // ASIAN ----------------------------------------------------------------------
1239 /** Base table for Asian locales. */
1240 static const XclBuiltInFormat spBuiltInFormats_ASIAN[] =
1242 EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
1243 EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
1244 EXC_NUMFMT_STRING( 20, "h:mm" ),
1245 EXC_NUMFMT_STRING( 21, "h:mm:ss" ),
1246 EXC_NUMFMT_STRING( 23, "$#,##0_);($#,##0)" ),
1247 EXC_NUMFMT_STRING( 24, "$#,##0_);[RED]($#,##0)" ),
1248 EXC_NUMFMT_STRING( 25, "$#,##0.00_);($#,##0.00)" ),
1249 EXC_NUMFMT_STRING( 26, "$#,##0.00_);[RED]($#,##0.00)" ),
1250 EXC_NUMFMT_REUSE( 29, 28 ),
1251 EXC_NUMFMT_REUSE( 36, 27 ),
1252 EXC_NUMFMT_REUSE( 50, 27 ),
1253 EXC_NUMFMT_REUSE( 51, 28 ),
1254 EXC_NUMFMT_REUSE( 52, 34 ),
1255 EXC_NUMFMT_REUSE( 53, 35 ),
1256 EXC_NUMFMT_REUSE( 54, 28 ),
1257 EXC_NUMFMT_REUSE( 55, 34 ),
1258 EXC_NUMFMT_REUSE( 56, 35 ),
1259 EXC_NUMFMT_REUSE( 57, 27 ),
1260 EXC_NUMFMT_REUSE( 58, 28 ),
1261 EXC_NUMFMT_ENDTABLE()
1264 static const XclBuiltInFormat spBuiltInFormats_JAPANESE[] =
1266 EXC_NUMFMT_STRING( 14, "YYYY/M/D" ),
1267 EXC_NUMFMT_STRING( 15, "D-MMM-YY" ),
1268 EXC_NUMFMT_STRING( 16, "D-MMM" ),
1269 EXC_NUMFMT_STRING( 17, "MMM-YY" ),
1270 EXC_NUMFMT_STRING( 22, "YYYY/M/D h:mm" ),
1271 EXC_NUMFMT_STRING( 27, "[$-0411]GE.M.D" ),
1272 EXC_NUMFMT_STRING( 28, "[$-0411]GGGE" UTF8_CJ_YEAR "M" UTF8_CJ_MON "D" UTF8_CJ_DAY ),
1273 EXC_NUMFMT_STRING( 30, "[$-0411]M/D/YY" ),
1274 EXC_NUMFMT_STRING( 31, "[$-0411]YYYY" UTF8_CJ_YEAR "M" UTF8_CJ_MON "D" UTF8_CJ_DAY ),
1275 EXC_NUMFMT_STRING( 32, "[$-0411]h" UTF8_CJ_HOUR "mm" UTF8_CJ_MIN ),
1276 EXC_NUMFMT_STRING( 33, "[$-0411]h" UTF8_CJ_HOUR "mm" UTF8_CJ_MIN "ss" UTF8_CJ_SEC ),
1277 EXC_NUMFMT_STRING( 34, "[$-0411]YYYY" UTF8_CJ_YEAR "M" UTF8_CJ_MON ),
1278 EXC_NUMFMT_STRING( 35, "[$-0411]M" UTF8_CJ_MON "D" UTF8_CJ_DAY ),
1279 EXC_NUMFMT_STRING( 63, UTF8_YEN_JP "#,##0;-" UTF8_YEN_JP "#,##0" ),
1280 EXC_NUMFMT_STRING( 64, UTF8_YEN_JP "#,##0;[RED]-" UTF8_YEN_JP "#,##0" ),
1281 EXC_NUMFMT_STRING( 65, UTF8_YEN_JP "#,##0.00;-" UTF8_YEN_JP "#,##0.00" ),
1282 EXC_NUMFMT_STRING( 66, UTF8_YEN_JP "#,##0.00;[RED]-" UTF8_YEN_JP "#,##0.00" ),
1283 EXC_NUMFMT_ENDTABLE()
1286 static const XclBuiltInFormat spBuiltInFormats_KOREAN[] =
1288 EXC_NUMFMT_STRING( 14, "YYYY-MM-DD" ),
1289 EXC_NUMFMT_STRING( 15, "DD-MMM-YY" ),
1290 EXC_NUMFMT_STRING( 16, "DD-MMM" ),
1291 EXC_NUMFMT_STRING( 17, "MMM-YY" ),
1292 EXC_NUMFMT_STRING( 22, "YYYY-MM-DD h:mm" ),
1293 EXC_NUMFMT_STRING( 27, "[$-0412]YYYY" UTF8_CJ_YEAR " MM" UTF8_CJ_MON " DD" UTF8_CJ_DAY ),
1294 EXC_NUMFMT_STRING( 28, "[$-0412]MM-DD" ),
1295 EXC_NUMFMT_STRING( 30, "[$-0412]MM-DD-YY" ),
1296 EXC_NUMFMT_STRING( 31, "[$-0412]YYYY" UTF8_KO_YEAR " MM" UTF8_KO_MON " DD" UTF8_KO_DAY ),
1297 EXC_NUMFMT_STRING( 32, "[$-0412]h" UTF8_KO_HOUR " mm" UTF8_KO_MIN ),
1298 EXC_NUMFMT_STRING( 33, "[$-0412]h" UTF8_KO_HOUR " mm" UTF8_KO_MIN " ss" UTF8_KO_SEC ),
1299 EXC_NUMFMT_STRING( 34, "[$-0412]YYYY\"/\"MM\"/\"DD" ),
1300 EXC_NUMFMT_STRING( 35, "[$-0412]YYYY-MM-DD" ),
1301 EXC_NUMFMT_STRING( 63, UTF8_WON "#,##0;-" UTF8_WON "#,##0" ),
1302 EXC_NUMFMT_STRING( 64, UTF8_WON "#,##0;[RED]-" UTF8_WON "#,##0" ),
1303 EXC_NUMFMT_STRING( 65, UTF8_WON "#,##0.00;-" UTF8_WON "#,##0.00" ),
1304 EXC_NUMFMT_STRING( 66, UTF8_WON "#,##0.00;[RED]-" UTF8_WON "#,##0.00" ),
1305 EXC_NUMFMT_ENDTABLE()
1308 static const XclBuiltInFormat spBuiltInFormats_CHINESE_SIMPLIFIED[] =
1310 EXC_NUMFMT_STRING( 14, "YYYY-M-D" ),
1311 EXC_NUMFMT_STRING( 15, "D-MMM-YY" ),
1312 EXC_NUMFMT_STRING( 16, "D-MMM" ),
1313 EXC_NUMFMT_STRING( 17, "MMM-YY" ),
1314 EXC_NUMFMT_STRING( 22, "YYYY-M-D h:mm" ),
1315 EXC_NUMFMT_STRING( 27, "[$-0804]YYYY" UTF8_CJ_YEAR "M" UTF8_CJ_MON ),
1316 EXC_NUMFMT_STRING( 28, "[$-0804]M" UTF8_CJ_MON "D" UTF8_CJ_DAY ),
1317 EXC_NUMFMT_STRING( 30, "[$-0804]M-D-YY" ),
1318 EXC_NUMFMT_STRING( 31, "[$-0804]YYYY" UTF8_CJ_YEAR "M" UTF8_CJ_MON "D" UTF8_CJ_DAY ),
1319 EXC_NUMFMT_STRING( 32, "[$-0804]h" UTF8_CS_HOUR "mm" UTF8_CJ_MIN ),
1320 EXC_NUMFMT_STRING( 33, "[$-0804]h" UTF8_CS_HOUR "mm" UTF8_CJ_MIN "ss" UTF8_CJ_SEC ),
1321 EXC_NUMFMT_STRING( 34, "[$-0804]AM/PMh" UTF8_CS_HOUR "mm" UTF8_CJ_MIN ),
1322 EXC_NUMFMT_STRING( 35, "[$-0804]AM/PMh" UTF8_CS_HOUR "mm" UTF8_CJ_MIN "ss" UTF8_CJ_SEC ),
1323 EXC_NUMFMT_REUSE( 52, 27 ),
1324 EXC_NUMFMT_REUSE( 53, 28 ),
1325 EXC_NUMFMT_STRING( 63, UTF8_YEN_CS "#,##0;-" UTF8_YEN_CS "#,##0" ),
1326 EXC_NUMFMT_STRING( 64, UTF8_YEN_CS "#,##0;[RED]-" UTF8_YEN_CS "#,##0" ),
1327 EXC_NUMFMT_STRING( 65, UTF8_YEN_CS "#,##0.00;-" UTF8_YEN_CS "#,##0.00" ),
1328 EXC_NUMFMT_STRING( 66, UTF8_YEN_CS "#,##0.00;[RED]-" UTF8_YEN_CS "#,##0.00" ),
1329 EXC_NUMFMT_ENDTABLE()
1332 static const XclBuiltInFormat spBuiltInFormats_CHINESE_TRADITIONAL[] =
1334 EXC_NUMFMT_STRING( 15, "D-MMM-YY" ),
1335 EXC_NUMFMT_STRING( 16, "D-MMM" ),
1336 EXC_NUMFMT_STRING( 17, "MMM-YY" ),
1337 EXC_NUMFMT_STRING( 18, "hh:mm AM/PM" ),
1338 EXC_NUMFMT_STRING( 19, "hh:mm:ss AM/PM" ),
1339 EXC_NUMFMT_OFFSET( 20, NF_TIME_HHMM ),
1340 EXC_NUMFMT_OFFSET( 21, NF_TIME_HHMMSS ),
1341 EXC_NUMFMT_STRING( 22, "YYYY/M/D hh:mm" ),
1342 EXC_NUMFMT_STRING( 23, "US$#,##0_);(US$#,##0)" ),
1343 EXC_NUMFMT_STRING( 24, "US$#,##0_);[RED](US$#,##0)" ),
1344 EXC_NUMFMT_STRING( 25, "US$#,##0.00_);(US$#,##0.00)" ),
1345 EXC_NUMFMT_STRING( 26, "US$#,##0.00_);[RED](US$#,##0.00)" ),
1346 EXC_NUMFMT_STRING( 27, "[$-0404]E/M/D" ),
1347 EXC_NUMFMT_STRING( 28, "[$-0404]E" UTF8_CJ_YEAR "M" UTF8_CJ_MON "D" UTF8_CJ_DAY ),
1348 EXC_NUMFMT_STRING( 30, "[$-0404]M/D/YY" ),
1349 EXC_NUMFMT_STRING( 31, "[$-0404]YYYY" UTF8_CJ_YEAR "M" UTF8_CJ_MON "D" UTF8_CJ_DAY ),
1350 EXC_NUMFMT_STRING( 32, "[$-0404]hh" UTF8_CJ_HOUR "mm" UTF8_CJ_MIN ),
1351 EXC_NUMFMT_STRING( 33, "[$-0404]hh" UTF8_CJ_HOUR "mm" UTF8_CJ_MIN "ss" UTF8_CJ_SEC ),
1352 EXC_NUMFMT_STRING( 34, "[$-0404]AM/PMhh" UTF8_CJ_HOUR "mm" UTF8_CJ_MIN ),
1353 EXC_NUMFMT_STRING( 35, "[$-0404]AM/PMhh" UTF8_CJ_HOUR "mm" UTF8_CJ_MIN "ss" UTF8_CJ_SEC ),
1354 EXC_NUMFMT_STRING( 63, "$#,##0;-$#,##0" ),
1355 EXC_NUMFMT_STRING( 64, "$#,##0;[RED]-$#,##0" ),
1356 EXC_NUMFMT_STRING( 65, "$#,##0.00;-$#,##0.00" ),
1357 EXC_NUMFMT_STRING( 66, "$#,##0.00;[RED]-$#,##0.00" ),
1358 EXC_NUMFMT_ENDTABLE()
1361 // OTHER ----------------------------------------------------------------------
1363 static const XclBuiltInFormat spBuiltInFormats_HEBREW[] =
1365 EXC_NUMFMT_STRING( 15, "DD-MMMM-YY" ),
1366 EXC_NUMFMT_STRING( 16, "DD-MMMM" ),
1367 EXC_NUMFMT_STRING( 17, "MMMM-YY" ),
1368 EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
1369 EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
1370 EXC_NUMFMT_STRING( 63, UTF8_SHEQEL " #,##0;" UTF8_SHEQEL " -#,##0" ),
1371 EXC_NUMFMT_STRING( 64, UTF8_SHEQEL " #,##0;[RED]" UTF8_SHEQEL " -#,##0" ),
1372 EXC_NUMFMT_STRING( 65, UTF8_SHEQEL " #,##0.00;" UTF8_SHEQEL " -#,##0.00" ),
1373 EXC_NUMFMT_STRING( 66, UTF8_SHEQEL " #,##0.00;[RED]" UTF8_SHEQEL " -#,##0.00" ),
1374 EXC_NUMFMT_ENDTABLE()
1377 static const XclBuiltInFormat spBuiltInFormats_THAI[] =
1379 EXC_NUMFMT_STRING( 14, "D/M/YYYY" ),
1380 EXC_NUMFMT_STRING( 15, "D-MMM-YY" ),
1381 EXC_NUMFMT_STRING( 16, "D-MMM" ),
1382 EXC_NUMFMT_STRING( 17, "MMM-YY" ),
1383 EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
1384 EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
1385 EXC_NUMFMT_STRING( 22, "D/M/YYYY h:mm" ),
1386 EXC_NUMFMT_STRING( 59, "t0" ),
1387 EXC_NUMFMT_STRING( 60, "t0.00" ),
1388 EXC_NUMFMT_STRING( 61, "t#,##0" ),
1389 EXC_NUMFMT_STRING( 62, "t#,##0.00" ),
1390 EXC_NUMFMT_STRING( 63, "t" UTF8_BAHT "#,##0_);t(" UTF8_BAHT "#,##0)" ),
1391 EXC_NUMFMT_STRING( 64, "t" UTF8_BAHT "#,##0_);[RED]t(" UTF8_BAHT "#,##0)" ),
1392 EXC_NUMFMT_STRING( 65, "t" UTF8_BAHT "#,##0.00_);t(" UTF8_BAHT "#,##0.00)" ),
1393 EXC_NUMFMT_STRING( 66, "t" UTF8_BAHT "#,##0.00_);[RED]t(" UTF8_BAHT "#,##0.00)" ),
1394 EXC_NUMFMT_STRING( 67, "t0%" ),
1395 EXC_NUMFMT_STRING( 68, "t0.00%" ),
1396 EXC_NUMFMT_STRING( 69, "t# ?/?" ),
1397 EXC_NUMFMT_STRING( 70, "t# ?\?/?\?" ),
1398 EXC_NUMFMT_STRING( 71, "tD/M/EE" ),
1399 EXC_NUMFMT_STRING( 72, "tD-MMM-E" ),
1400 EXC_NUMFMT_STRING( 73, "tD-MMM" ),
1401 EXC_NUMFMT_STRING( 74, "tMMM-E" ),
1402 EXC_NUMFMT_STRING( 75, "th:mm" ),
1403 EXC_NUMFMT_STRING( 76, "th:mm:ss" ),
1404 EXC_NUMFMT_STRING( 77, "tD/M/EE h:mm" ),
1405 EXC_NUMFMT_STRING( 78, "tmm:ss" ),
1406 EXC_NUMFMT_STRING( 79, "t[h]:mm:ss" ),
1407 EXC_NUMFMT_STRING( 80, "tmm:ss.0" ),
1408 EXC_NUMFMT_STRING( 81, "D/M/E" ),
1409 EXC_NUMFMT_ENDTABLE()
1412 // ----------------------------------------------------------------------------
1414 #undef EXC_NUMFMT_ENDTABLE
1415 #undef EXC_NUMFMT_REUSE
1416 #undef EXC_NUMFMT_OFFSET
1417 #undef EXC_NUMFMT_STRING
1419 // ----------------------------------------------------------------------------
1421 /** Specifies a number format table for a specific langauge. */
1422 struct XclBuiltInFormatTable
1424 LanguageType meLanguage; /// The language of this table.
1425 LanguageType meParentLang; /// The language of the parent table.
1426 const XclBuiltInFormat* mpFormats; /// The number format table.
1429 static const XclBuiltInFormatTable spBuiltInFormatTables[] =
1430 { // language parent language format table
1431 { LANGUAGE_DONTKNOW, LANGUAGE_NONE, spBuiltInFormats_DONTKNOW },
1433 { LANGUAGE_ENGLISH, LANGUAGE_DONTKNOW, spBuiltInFormats_ENGLISH },
1434 { LANGUAGE_ENGLISH_UK, LANGUAGE_ENGLISH, spBuiltInFormats_ENGLISH_UK },
1435 { LANGUAGE_ENGLISH_EIRE, LANGUAGE_ENGLISH, spBuiltInFormats_ENGLISH_EIRE },
1436 { LANGUAGE_ENGLISH_US, LANGUAGE_ENGLISH, spBuiltInFormats_ENGLISH_US },
1437 { LANGUAGE_ENGLISH_CAN, LANGUAGE_ENGLISH, spBuiltInFormats_ENGLISH_CAN },
1438 { LANGUAGE_ENGLISH_AUS, LANGUAGE_ENGLISH, spBuiltInFormats_ENGLISH_AUS },
1439 { LANGUAGE_ENGLISH_SAFRICA, LANGUAGE_ENGLISH, spBuiltInFormats_ENGLISH_SAFRICA },
1440 { LANGUAGE_ENGLISH_NZ, LANGUAGE_ENGLISH_AUS, 0 },
1442 { PRV_LANGUAGE_FRENCH_PRIM, LANGUAGE_DONTKNOW, spBuiltInFormats_FRENCH },
1443 { LANGUAGE_FRENCH, PRV_LANGUAGE_FRENCH_PRIM, spBuiltInFormats_FRENCH_FRANCE },
1444 { LANGUAGE_FRENCH_CANADIAN, PRV_LANGUAGE_FRENCH_PRIM, spBuiltInFormats_FRENCH_CANADIAN },
1445 { LANGUAGE_FRENCH_SWISS, PRV_LANGUAGE_FRENCH_PRIM, spBuiltInFormats_FRENCH_SWISS },
1446 { LANGUAGE_FRENCH_BELGIAN, LANGUAGE_FRENCH, spBuiltInFormats_FRENCH_BELGIAN },
1447 { LANGUAGE_FRENCH_LUXEMBOURG, LANGUAGE_FRENCH, 0 },
1448 { LANGUAGE_FRENCH_MONACO, LANGUAGE_FRENCH, 0 },
1450 { PRV_LANGUAGE_GERMAN_PRIM, LANGUAGE_DONTKNOW, spBuiltInFormats_GERMAN },
1451 { LANGUAGE_GERMAN, PRV_LANGUAGE_GERMAN_PRIM, spBuiltInFormats_GERMAN_GERMANY },
1452 { LANGUAGE_GERMAN_AUSTRIAN, PRV_LANGUAGE_GERMAN_PRIM, spBuiltInFormats_GERMAN_AUSTRIAN },
1453 { LANGUAGE_GERMAN_SWISS, PRV_LANGUAGE_GERMAN_PRIM, spBuiltInFormats_GERMAN_SWISS },
1454 { LANGUAGE_GERMAN_LUXEMBOURG, PRV_LANGUAGE_GERMAN_PRIM, spBuiltInFormats_GERMAN_LUXEMBOURG },
1455 { LANGUAGE_GERMAN_LIECHTENSTEIN, PRV_LANGUAGE_GERMAN_PRIM, spBuiltInFormats_GERMAN_LIECHTENSTEIN },
1457 { LANGUAGE_ITALIAN, LANGUAGE_DONTKNOW, spBuiltInFormats_ITALIAN_ITALY },
1458 { LANGUAGE_ITALIAN_SWISS, LANGUAGE_DONTKNOW, spBuiltInFormats_ITALIAN_SWISS },
1460 { LANGUAGE_SWEDISH, LANGUAGE_DONTKNOW, spBuiltInFormats_SWEDISH_SWEDEN },
1461 { LANGUAGE_SWEDISH_FINLAND, LANGUAGE_DONTKNOW, spBuiltInFormats_SWEDISH_FINLAND },
1463 { PRV_LANGUAGE_ASIAN_PRIM, LANGUAGE_DONTKNOW, spBuiltInFormats_ASIAN },
1464 { LANGUAGE_JAPANESE, PRV_LANGUAGE_ASIAN_PRIM, spBuiltInFormats_JAPANESE },
1465 { LANGUAGE_KOREAN, PRV_LANGUAGE_ASIAN_PRIM, spBuiltInFormats_KOREAN },
1466 { LANGUAGE_CHINESE_SIMPLIFIED, PRV_LANGUAGE_ASIAN_PRIM, spBuiltInFormats_CHINESE_SIMPLIFIED },
1467 { LANGUAGE_CHINESE_TRADITIONAL, PRV_LANGUAGE_ASIAN_PRIM, spBuiltInFormats_CHINESE_TRADITIONAL },
1469 { LANGUAGE_HEBREW, LANGUAGE_DONTKNOW, spBuiltInFormats_HEBREW },
1470 { LANGUAGE_THAI, LANGUAGE_DONTKNOW, spBuiltInFormats_THAI }
1473 // ----------------------------------------------------------------------------
1475 } // namespace
1477 // ============================================================================
1479 XclNumFmtBuffer::XclNumFmtBuffer( const XclRoot& rRoot ) :
1480 meSysLang( rRoot.GetSysLanguage() ),
1481 mnStdScNumFmt( rRoot.GetFormatter().GetStandardFormat( ScGlobal::eLnge ) )
1483 // *** insert default formats (BIFF5+ only)***
1485 if( rRoot.GetBiff() >= EXC_BIFF5 )
1486 InsertBuiltinFormats();
1489 void XclNumFmtBuffer::InitializeImport()
1491 maFmtMap.clear();
1494 void XclNumFmtBuffer::InsertFormat( sal_uInt16 nXclNumFmt, const String& rFormat )
1496 XclNumFmt& rNumFmt = maFmtMap[ nXclNumFmt ];
1497 rNumFmt.maFormat = rFormat;
1498 // #i62053# rFormat may be an empty string, meOffset must be initialized
1499 rNumFmt.meOffset = NF_NUMBER_STANDARD;
1500 rNumFmt.meLanguage = LANGUAGE_SYSTEM;
1503 void XclNumFmtBuffer::InsertBuiltinFormats()
1505 // build a map containing tables for all languages
1506 typedef ::std::map< LanguageType, const XclBuiltInFormatTable* > XclBuiltInMap;
1507 XclBuiltInMap aBuiltInMap;
1508 for( const XclBuiltInFormatTable* pTable = spBuiltInFormatTables;
1509 pTable != STATIC_ARRAY_END( spBuiltInFormatTables ); ++pTable )
1510 aBuiltInMap[ pTable->meLanguage ] = pTable;
1512 // build a list of table pointers for the current language, with all parent tables
1513 typedef ::std::vector< const XclBuiltInFormatTable* > XclBuiltInVec;
1514 XclBuiltInVec aBuiltInVec;
1515 for( XclBuiltInMap::const_iterator aMIt = aBuiltInMap.find( meSysLang ), aMEnd = aBuiltInMap.end();
1516 aMIt != aMEnd; aMIt = aBuiltInMap.find( aMIt->second->meParentLang ) )
1517 aBuiltInVec.push_back( aMIt->second );
1518 // language not supported
1519 if( aBuiltInVec.empty() )
1521 OSL_TRACE( "XclNumFmtBuffer::InsertBuiltinFormats - language 0x%04hX not supported (#i29949#)", meSysLang );
1522 XclBuiltInMap::const_iterator aMIt = aBuiltInMap.find( LANGUAGE_DONTKNOW );
1523 OSL_ENSURE( aMIt != aBuiltInMap.end(), "XclNumFmtBuffer::InsertBuiltinFormats - default map not found" );
1524 if( aMIt != aBuiltInMap.end() )
1525 aBuiltInVec.push_back( aMIt->second );
1528 // insert the default formats in the format map, from root parent to system language
1529 typedef ::std::map< sal_uInt16, sal_uInt16 > XclReuseMap;
1530 XclReuseMap aReuseMap;
1531 for( XclBuiltInVec::reverse_iterator aVIt = aBuiltInVec.rbegin(), aVEnd = aBuiltInVec.rend(); aVIt != aVEnd; ++aVIt )
1533 // put LANGUAGE_SYSTEM for all entries in default table
1534 LanguageType eLang = ((*aVIt)->meLanguage == LANGUAGE_DONTKNOW) ? LANGUAGE_SYSTEM : meSysLang;
1535 for( const XclBuiltInFormat* pBuiltIn = (*aVIt)->mpFormats; pBuiltIn && (pBuiltIn->mnXclNumFmt != EXC_FORMAT_NOTFOUND); ++pBuiltIn )
1537 XclNumFmt& rNumFmt = maFmtMap[ pBuiltIn->mnXclNumFmt ];
1539 rNumFmt.meOffset = pBuiltIn->meOffset;
1540 rNumFmt.meLanguage = eLang;
1542 if( pBuiltIn->mpFormat )
1543 rNumFmt.maFormat = String( pBuiltIn->mpFormat, RTL_TEXTENCODING_UTF8 );
1544 else
1545 rNumFmt.maFormat = EMPTY_STRING;
1547 if( pBuiltIn->meOffset == PRV_NF_INDEX_REUSE )
1548 aReuseMap[ pBuiltIn->mnXclNumFmt ] = pBuiltIn->mnXclReuseFmt;
1549 else
1550 aReuseMap.erase( pBuiltIn->mnXclNumFmt );
1554 // copy reused number formats
1555 for( XclReuseMap::const_iterator aRIt = aReuseMap.begin(), aREnd = aReuseMap.end(); aRIt != aREnd; ++aRIt )
1556 maFmtMap[ aRIt->first ] = maFmtMap[ aRIt->second ];
1559 // Cell formatting data (XF) ==================================================
1561 XclCellProt::XclCellProt() :
1562 mbLocked( true ), // default in Excel and Calc
1563 mbHidden( false )
1567 bool operator==( const XclCellProt& rLeft, const XclCellProt& rRight )
1569 return (rLeft.mbLocked == rRight.mbLocked) && (rLeft.mbHidden == rRight.mbHidden);
1572 // ----------------------------------------------------------------------------
1574 XclCellAlign::XclCellAlign() :
1575 mnHorAlign( EXC_XF_HOR_GENERAL ),
1576 mnVerAlign( EXC_XF_VER_BOTTOM ),
1577 mnOrient( EXC_ORIENT_NONE ),
1578 mnTextDir( EXC_XF_TEXTDIR_CONTEXT ),
1579 mnRotation( EXC_ROT_NONE ),
1580 mnIndent( 0 ),
1581 mbLineBreak( false ),
1582 mbShrink( false )
1586 SvxCellHorJustify XclCellAlign::GetScHorAlign() const
1588 SvxCellHorJustify eHorJust = SVX_HOR_JUSTIFY_STANDARD;
1589 switch( mnHorAlign )
1591 case EXC_XF_HOR_GENERAL: eHorJust = SVX_HOR_JUSTIFY_STANDARD; break;
1592 case EXC_XF_HOR_LEFT: eHorJust = SVX_HOR_JUSTIFY_LEFT; break;
1593 case EXC_XF_HOR_CENTER_AS:
1594 case EXC_XF_HOR_CENTER: eHorJust = SVX_HOR_JUSTIFY_CENTER; break;
1595 case EXC_XF_HOR_RIGHT: eHorJust = SVX_HOR_JUSTIFY_RIGHT; break;
1596 case EXC_XF_HOR_FILL: eHorJust = SVX_HOR_JUSTIFY_REPEAT; break;
1597 case EXC_XF_HOR_JUSTIFY:
1598 case EXC_XF_HOR_DISTRIB: eHorJust = SVX_HOR_JUSTIFY_BLOCK; break;
1599 default: OSL_FAIL( "XclCellAlign::GetScHorAlign - unknown horizontal alignment" );
1601 return eHorJust;
1604 SvxCellJustifyMethod XclCellAlign::GetScHorJustifyMethod() const
1606 return (mnHorAlign == EXC_XF_HOR_DISTRIB) ? SVX_JUSTIFY_METHOD_DISTRIBUTE : SVX_JUSTIFY_METHOD_AUTO;
1609 SvxCellVerJustify XclCellAlign::GetScVerAlign() const
1611 SvxCellVerJustify eVerJust = SVX_VER_JUSTIFY_STANDARD;
1612 switch( mnVerAlign )
1614 case EXC_XF_VER_TOP: eVerJust = SVX_VER_JUSTIFY_TOP; break;
1615 case EXC_XF_VER_CENTER: eVerJust = SVX_VER_JUSTIFY_CENTER; break;
1616 case EXC_XF_VER_BOTTOM: eVerJust = SVX_VER_JUSTIFY_STANDARD; break;
1617 case EXC_XF_VER_JUSTIFY:
1618 case EXC_XF_VER_DISTRIB: eVerJust = SVX_VER_JUSTIFY_BLOCK; break;
1619 default: OSL_FAIL( "XclCellAlign::GetScVerAlign - unknown vertical alignment" );
1621 return eVerJust;
1624 SvxCellJustifyMethod XclCellAlign::GetScVerJustifyMethod() const
1626 return (mnVerAlign == EXC_XF_VER_DISTRIB) ? SVX_JUSTIFY_METHOD_DISTRIBUTE : SVX_JUSTIFY_METHOD_AUTO;
1629 SvxFrameDirection XclCellAlign::GetScFrameDir() const
1631 SvxFrameDirection eFrameDir = FRMDIR_ENVIRONMENT;
1632 switch( mnTextDir )
1634 case EXC_XF_TEXTDIR_CONTEXT: eFrameDir = FRMDIR_ENVIRONMENT; break;
1635 case EXC_XF_TEXTDIR_LTR: eFrameDir = FRMDIR_HORI_LEFT_TOP; break;
1636 case EXC_XF_TEXTDIR_RTL: eFrameDir = FRMDIR_HORI_RIGHT_TOP; break;
1637 default: OSL_FAIL( "XclCellAlign::GetScFrameDir - unknown CTL text direction" );
1639 return eFrameDir;
1642 void XclCellAlign::SetScHorAlign( SvxCellHorJustify eHorJust )
1644 switch( eHorJust )
1646 case SVX_HOR_JUSTIFY_STANDARD: mnHorAlign = EXC_XF_HOR_GENERAL; break;
1647 case SVX_HOR_JUSTIFY_LEFT: mnHorAlign = EXC_XF_HOR_LEFT; break;
1648 case SVX_HOR_JUSTIFY_CENTER: mnHorAlign = EXC_XF_HOR_CENTER; break;
1649 case SVX_HOR_JUSTIFY_RIGHT: mnHorAlign = EXC_XF_HOR_RIGHT; break;
1650 case SVX_HOR_JUSTIFY_BLOCK: mnHorAlign = EXC_XF_HOR_JUSTIFY; break;
1651 case SVX_HOR_JUSTIFY_REPEAT: mnHorAlign = EXC_XF_HOR_FILL; break;
1652 default: mnHorAlign = EXC_XF_HOR_GENERAL;
1653 OSL_FAIL( "XclCellAlign::SetScHorAlign - unknown horizontal alignment" );
1657 void XclCellAlign::SetScVerAlign( SvxCellVerJustify eVerJust )
1659 switch( eVerJust )
1661 case SVX_VER_JUSTIFY_STANDARD: mnVerAlign = EXC_XF_VER_BOTTOM; break;
1662 case SVX_VER_JUSTIFY_TOP: mnVerAlign = EXC_XF_VER_TOP; break;
1663 case SVX_VER_JUSTIFY_CENTER: mnVerAlign = EXC_XF_VER_CENTER; break;
1664 case SVX_VER_JUSTIFY_BOTTOM: mnVerAlign = EXC_XF_VER_BOTTOM; break;
1665 default: mnVerAlign = EXC_XF_VER_BOTTOM;
1666 OSL_FAIL( "XclCellAlign::SetScVerAlign - unknown vertical alignment" );
1670 void XclCellAlign::SetScFrameDir( SvxFrameDirection eFrameDir )
1672 switch( eFrameDir )
1674 case FRMDIR_ENVIRONMENT: mnTextDir = EXC_XF_TEXTDIR_CONTEXT; break;
1675 case FRMDIR_HORI_LEFT_TOP: mnTextDir = EXC_XF_TEXTDIR_LTR; break;
1676 case FRMDIR_HORI_RIGHT_TOP: mnTextDir = EXC_XF_TEXTDIR_RTL; break;
1677 default: mnTextDir = EXC_XF_TEXTDIR_CONTEXT;
1678 OSL_FAIL( "XclCellAlign::SetScFrameDir - unknown CTL text direction" );
1682 bool operator==( const XclCellAlign& rLeft, const XclCellAlign& rRight )
1684 return
1685 (rLeft.mnHorAlign == rRight.mnHorAlign) && (rLeft.mnVerAlign == rRight.mnVerAlign) &&
1686 (rLeft.mnTextDir == rRight.mnTextDir) && (rLeft.mnOrient == rRight.mnOrient) &&
1687 (rLeft.mnRotation == rRight.mnRotation) && (rLeft.mnIndent == rRight.mnIndent) &&
1688 (rLeft.mbLineBreak == rRight.mbLineBreak) && (rLeft.mbShrink == rRight.mbShrink);
1691 // ----------------------------------------------------------------------------
1693 XclCellBorder::XclCellBorder() :
1694 mnLeftColor( 0 ),
1695 mnRightColor( 0 ),
1696 mnTopColor( 0 ),
1697 mnBottomColor( 0 ),
1698 mnDiagColor( 0 ),
1699 mnLeftLine( EXC_LINE_NONE ),
1700 mnRightLine( EXC_LINE_NONE ),
1701 mnTopLine( EXC_LINE_NONE ),
1702 mnBottomLine( EXC_LINE_NONE ),
1703 mnDiagLine( EXC_LINE_NONE ),
1704 mbDiagTLtoBR( false ),
1705 mbDiagBLtoTR( false )
1709 bool operator==( const XclCellBorder& rLeft, const XclCellBorder& rRight )
1711 return
1712 (rLeft.mnLeftColor == rRight.mnLeftColor) && (rLeft.mnRightColor == rRight.mnRightColor) &&
1713 (rLeft.mnTopColor == rRight.mnTopColor) && (rLeft.mnBottomColor == rRight.mnBottomColor) &&
1714 (rLeft.mnLeftLine == rRight.mnLeftLine) && (rLeft.mnRightLine == rRight.mnRightLine) &&
1715 (rLeft.mnTopLine == rRight.mnTopLine) && (rLeft.mnBottomLine == rRight.mnBottomLine) &&
1716 (rLeft.mnDiagColor == rRight.mnDiagColor) && (rLeft.mnDiagLine == rRight.mnDiagLine) &&
1717 (rLeft.mbDiagTLtoBR == rRight.mbDiagTLtoBR) && (rLeft.mbDiagBLtoTR == rRight.mbDiagBLtoTR);
1720 // ----------------------------------------------------------------------------
1722 XclCellArea::XclCellArea() :
1723 mnForeColor( EXC_COLOR_WINDOWTEXT ),
1724 mnBackColor( EXC_COLOR_WINDOWBACK ),
1725 mnPattern( EXC_PATT_NONE )
1729 bool XclCellArea::IsTransparent() const
1731 return (mnPattern == EXC_PATT_NONE) && (mnBackColor == EXC_COLOR_WINDOWBACK);
1734 bool operator==( const XclCellArea& rLeft, const XclCellArea& rRight )
1736 return
1737 (rLeft.mnForeColor == rRight.mnForeColor) && (rLeft.mnBackColor == rRight.mnBackColor) &&
1738 (rLeft.mnPattern == rRight.mnPattern);
1741 // ----------------------------------------------------------------------------
1743 XclXFBase::XclXFBase( bool bCellXF ) :
1744 mnParent( bCellXF ? EXC_XF_DEFAULTSTYLE : EXC_XF_STYLEPARENT ),
1745 mbCellXF( bCellXF )
1747 SetAllUsedFlags( false );
1750 XclXFBase::~XclXFBase()
1754 void XclXFBase::SetAllUsedFlags( bool bUsed )
1756 mbProtUsed = mbFontUsed = mbFmtUsed = mbAlignUsed = mbBorderUsed = mbAreaUsed = bUsed;
1759 bool XclXFBase::HasUsedFlags() const
1761 return mbProtUsed || mbFontUsed || mbFmtUsed || mbAlignUsed || mbBorderUsed || mbAreaUsed;
1764 bool XclXFBase::Equals( const XclXFBase& rCmp ) const
1766 return
1767 (mbCellXF == rCmp.mbCellXF) && (mnParent == rCmp.mnParent) &&
1768 (mbProtUsed == rCmp.mbProtUsed) && (mbFontUsed == rCmp.mbFontUsed) &&
1769 (mbFmtUsed == rCmp.mbFmtUsed) && (mbAlignUsed == rCmp.mbAlignUsed) &&
1770 (mbBorderUsed == rCmp.mbBorderUsed) && (mbAreaUsed == rCmp.mbAreaUsed);
1773 // ============================================================================
1775 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */