File: | home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx |
Warning: | line 648, column 13 3rd function call argument is an uninitialized value |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||
2 | /* | |||
3 | * This file is part of the LibreOffice project. | |||
4 | * | |||
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/. | |||
8 | * | |||
9 | * This file incorporates work covered by the following license notice: | |||
10 | * | |||
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 . | |||
18 | */ | |||
19 | ||||
20 | #include <xlstyle.hxx> | |||
21 | #include <com/sun/star/awt/FontFamily.hpp> | |||
22 | #include <com/sun/star/awt/FontSlant.hpp> | |||
23 | #include <com/sun/star/awt/FontStrikeout.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/settings.hxx> | |||
28 | #include <vcl/font.hxx> | |||
29 | #include <sal/macros.h> | |||
30 | #include <sal/log.hxx> | |||
31 | #include <rtl/tencinfo.h> | |||
32 | #include <svtools/colorcfg.hxx> | |||
33 | #include <vcl/unohelp.hxx> | |||
34 | #include <editeng/svxfont.hxx> | |||
35 | #include <global.hxx> | |||
36 | #include <xlroot.hxx> | |||
37 | #include <xltools.hxx> | |||
38 | // Color data ================================================================= | |||
39 | ||||
40 | /** Standard EGA colors, bright. */ | |||
41 | #define EXC_PALETTE_EGA_COLORS_LIGHT \ | |||
42 | Color(0x000000), Color(0xFFFFFF), Color(0xFF0000), Color(0x00FF00), Color(0x0000FF), Color(0xFFFF00), Color(0xFF00FF), Color(0x00FFFF) | |||
43 | /** Standard EGA colors, dark. */ | |||
44 | #define EXC_PALETTE_EGA_COLORS_DARK \ | |||
45 | Color(0x800000), Color(0x008000), Color(0x000080), Color(0x808000), Color(0x800080), Color(0x008080), Color(0xC0C0C0), Color(0x808080) | |||
46 | ||||
47 | /** Default color table for BIFF2. */ | |||
48 | const Color spnDefColorTable2[] = | |||
49 | { | |||
50 | /* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT | |||
51 | }; | |||
52 | ||||
53 | /** Default color table for BIFF3/BIFF4. */ | |||
54 | const Color spnDefColorTable3[] = | |||
55 | { | |||
56 | /* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT, | |||
57 | /* 8 */ EXC_PALETTE_EGA_COLORS_LIGHT, | |||
58 | /* 16 */ EXC_PALETTE_EGA_COLORS_DARK | |||
59 | }; | |||
60 | ||||
61 | /** Default color table for BIFF5/BIFF7. */ | |||
62 | const Color spnDefColorTable5[] = | |||
63 | { | |||
64 | /* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT, | |||
65 | /* 8 */ EXC_PALETTE_EGA_COLORS_LIGHT, | |||
66 | /* 16 */ EXC_PALETTE_EGA_COLORS_DARK, | |||
67 | /* 24 */ Color(0x8080FF), Color(0x802060), Color(0xFFFFC0), Color(0xA0E0E0), Color(0x600080), Color(0xFF8080), Color(0x0080C0), Color(0xC0C0FF), | |||
68 | /* 32 */ Color(0x000080), Color(0xFF00FF), Color(0xFFFF00), Color(0x00FFFF), Color(0x800080), Color(0x800000), Color(0x008080), Color(0x0000FF), | |||
69 | /* 40 */ Color(0x00CFFF), Color(0x69FFFF), Color(0xE0FFE0), Color(0xFFFF80), Color(0xA6CAF0), Color(0xDD9CB3), Color(0xB38FEE), Color(0xE3E3E3), | |||
70 | /* 48 */ Color(0x2A6FF9), Color(0x3FB8CD), Color(0x488436), Color(0x958C41), Color(0x8E5E42), Color(0xA0627A), Color(0x624FAC), Color(0x969696), | |||
71 | /* 56 */ Color(0x1D2FBE), Color(0x286676), Color(0x004500), Color(0x453E01), Color(0x6A2813), Color(0x85396A), Color(0x4A3285), Color(0x424242) | |||
72 | }; | |||
73 | ||||
74 | /** Default color table for BIFF8. */ | |||
75 | const Color spnDefColorTable8[] = | |||
76 | { | |||
77 | /* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT, | |||
78 | /* 8 */ EXC_PALETTE_EGA_COLORS_LIGHT, | |||
79 | /* 16 */ EXC_PALETTE_EGA_COLORS_DARK, | |||
80 | /* 24 */ Color(0x9999FF), Color(0x993366), Color(0xFFFFCC), Color(0xCCFFFF), Color(0x660066), Color(0xFF8080), Color(0x0066CC), Color(0xCCCCFF), | |||
81 | /* 32 */ Color(0x000080), Color(0xFF00FF), Color(0xFFFF00), Color(0x00FFFF), Color(0x800080), Color(0x800000), Color(0x008080), Color(0x0000FF), | |||
82 | /* 40 */ Color(0x00CCFF), Color(0xCCFFFF), Color(0xCCFFCC), Color(0xFFFF99), Color(0x99CCFF), Color(0xFF99CC), Color(0xCC99FF), Color(0xFFCC99), | |||
83 | /* 48 */ Color(0x3366FF), Color(0x33CCCC), Color(0x99CC00), Color(0xFFCC00), Color(0xFF9900), Color(0xFF6600), Color(0x666699), Color(0x969696), | |||
84 | /* 56 */ Color(0x003366), Color(0x339966), Color(0x003300), Color(0x333300), Color(0x993300), Color(0x993366), Color(0x333399), Color(0x333333) | |||
85 | }; | |||
86 | ||||
87 | #undef EXC_PALETTE_EGA_COLORS_LIGHT | |||
88 | #undef EXC_PALETTE_EGA_COLORS_DARK | |||
89 | ||||
90 | XclDefaultPalette::XclDefaultPalette( const XclRoot& rRoot ) : | |||
91 | mpnColorTable( nullptr ), | |||
92 | mnTableSize( 0 ) | |||
93 | { | |||
94 | const StyleSettings& rSett = Application::GetSettings().GetStyleSettings(); | |||
95 | mnWindowText = rSett.GetWindowTextColor(); | |||
96 | mnWindowBack = rSett.GetWindowColor(); | |||
97 | mnFaceColor = rSett.GetFaceColor(); | |||
98 | // Don't use the system HelpBack and HelpText colours as it causes problems | |||
99 | // with modern gnome. This is because mnNoteText and mnNoteBack are used | |||
100 | // when colour indices ( instead of real colours ) are specified. | |||
101 | // Note: That this it is not an unusual scenario that we get the Note | |||
102 | // background specified as a real colour and the text specified as a | |||
103 | // colour index. That means the text colour would be picked from | |||
104 | // the system where the note background would be picked from a real colour. | |||
105 | // Previously the note text colour was picked from the system tooltip | |||
106 | // text colour, on modern gnome(e.g. 3) that tends to be 'white' with the | |||
107 | // default theme. | |||
108 | // Using the Libreoffice defaults ( instead of system specific colours | |||
109 | // ) lessens the chance of the one colour being an unsuitable combination | |||
110 | // because by default the note text is black and the note background is | |||
111 | // a light yellow colour ( very similar to Excel's normal defaults ) | |||
112 | mnNoteText = svtools::ColorConfig::GetDefaultColor( svtools::FONTCOLOR ); | |||
113 | mnNoteBack = svtools::ColorConfig::GetDefaultColor( svtools::CALCNOTESBACKGROUND ); | |||
114 | ||||
115 | // default colors | |||
116 | switch( rRoot.GetBiff() ) | |||
117 | { | |||
118 | case EXC_BIFF2: | |||
119 | mpnColorTable = spnDefColorTable2; | |||
120 | mnTableSize = SAL_N_ELEMENTS( spnDefColorTable2 )(sizeof(sal_n_array_size(spnDefColorTable2))); | |||
121 | break; | |||
122 | case EXC_BIFF3: | |||
123 | case EXC_BIFF4: | |||
124 | mpnColorTable = spnDefColorTable3; | |||
125 | mnTableSize = SAL_N_ELEMENTS( spnDefColorTable3 )(sizeof(sal_n_array_size(spnDefColorTable3))); | |||
126 | break; | |||
127 | case EXC_BIFF5: | |||
128 | mpnColorTable = spnDefColorTable5; | |||
129 | mnTableSize = SAL_N_ELEMENTS( spnDefColorTable5 )(sizeof(sal_n_array_size(spnDefColorTable5))); | |||
130 | break; | |||
131 | case EXC_BIFF8: | |||
132 | mpnColorTable = spnDefColorTable8; | |||
133 | mnTableSize = SAL_N_ELEMENTS( spnDefColorTable8 )(sizeof(sal_n_array_size(spnDefColorTable8))); | |||
134 | break; | |||
135 | default: | |||
136 | DBG_ERROR_BIFF()do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "136" ": "), "%s", "Unknown BIFF type!"); } } while (false ); | |||
137 | } | |||
138 | } | |||
139 | ||||
140 | Color XclDefaultPalette::GetDefColor( sal_uInt16 nXclIndex ) const | |||
141 | { | |||
142 | Color nColor; | |||
143 | if( nXclIndex < mnTableSize ) | |||
144 | nColor = mpnColorTable[ nXclIndex ]; | |||
145 | else switch( nXclIndex ) | |||
146 | { | |||
147 | case EXC_COLOR_WINDOWTEXT3: | |||
148 | case EXC_COLOR_WINDOWTEXT: | |||
149 | case EXC_COLOR_CHWINDOWTEXT: nColor = mnWindowText; break; | |||
150 | case EXC_COLOR_WINDOWBACK3: | |||
151 | case EXC_COLOR_WINDOWBACK: | |||
152 | case EXC_COLOR_CHWINDOWBACK: nColor = mnWindowBack; break; | |||
153 | case EXC_COLOR_BUTTONBACK: nColor = mnFaceColor; break; | |||
154 | case EXC_COLOR_CHBORDERAUTO: nColor = COL_BLACK; break; // TODO: really always black? | |||
155 | case EXC_COLOR_NOTEBACK: nColor = mnNoteBack; break; | |||
156 | case EXC_COLOR_NOTETEXT: nColor = mnNoteText; break; | |||
157 | case EXC_COLOR_FONTAUTO: nColor = COL_AUTO; break; | |||
158 | default: | |||
159 | SAL_WARN("sc", "XclDefaultPalette::GetDefColor - unknown default color index: " << nXclIndex )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "sc")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XclDefaultPalette::GetDefColor - unknown default color index: " << nXclIndex) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sc"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "159" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XclDefaultPalette::GetDefColor - unknown default color index: " << nXclIndex), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "XclDefaultPalette::GetDefColor - unknown default color index: " << nXclIndex; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sc"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "159" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XclDefaultPalette::GetDefColor - unknown default color index: " << nXclIndex) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sc"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "159" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "XclDefaultPalette::GetDefColor - unknown default color index: " << nXclIndex), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "XclDefaultPalette::GetDefColor - unknown default color index: " << nXclIndex; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sc"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "159" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
160 | nColor = COL_AUTO; | |||
161 | } | |||
162 | return nColor; | |||
163 | } | |||
164 | ||||
165 | // Font Data ================================================================== | |||
166 | ||||
167 | namespace Awt = ::com::sun::star::awt; | |||
168 | namespace AwtFontFamily = Awt::FontFamily; | |||
169 | namespace AwtFontLineStyle = Awt::FontUnderline; | |||
170 | namespace AwtFontStrikeout = Awt::FontStrikeout; | |||
171 | ||||
172 | XclFontData::XclFontData() | |||
173 | { | |||
174 | Clear(); | |||
175 | } | |||
176 | ||||
177 | XclFontData::XclFontData( const vcl::Font& rFont ) | |||
178 | { | |||
179 | Clear(); | |||
180 | FillFromVclFont( rFont ); | |||
181 | } | |||
182 | ||||
183 | XclFontData::XclFontData( const SvxFont& rFont ) | |||
184 | { | |||
185 | FillFromSvxFont( rFont ); | |||
186 | } | |||
187 | ||||
188 | void XclFontData::Clear() | |||
189 | { | |||
190 | maName.clear(); | |||
191 | maStyle.clear(); | |||
192 | maColor = COL_AUTO; | |||
193 | mnHeight = 0; | |||
194 | mnWeight = EXC_FONTWGHT_DONTKNOW; | |||
195 | mnEscapem = EXC_FONTESC_NONE; | |||
196 | mnFamily = EXC_FONTFAM_SYSTEM; | |||
197 | mnCharSet = EXC_FONTCSET_ANSI_LATIN; | |||
198 | mnUnderline = EXC_FONTUNDERL_NONE; | |||
199 | mbItalic = mbStrikeout = mbOutline = mbShadow = false; | |||
200 | } | |||
201 | ||||
202 | void XclFontData::FillFromVclFont( const vcl::Font& rFont ) | |||
203 | { | |||
204 | maName = XclTools::GetXclFontName( rFont.GetFamilyName() ); // substitute with MS fonts | |||
205 | maStyle.clear(); | |||
206 | maColor = rFont.GetColor(); | |||
207 | SetScUnderline( rFont.GetUnderline() ); | |||
208 | mnEscapem = EXC_FONTESC_NONE; | |||
209 | SetScHeight( rFont.GetFontSize().Height() ); | |||
210 | SetScWeight( rFont.GetWeight() ); | |||
211 | SetScFamily( rFont.GetFamilyType() ); | |||
212 | SetFontEncoding( rFont.GetCharSet() ); | |||
213 | SetScPosture( rFont.GetItalic() ); | |||
214 | SetScStrikeout( rFont.GetStrikeout() ); | |||
215 | mbOutline = rFont.IsOutline(); | |||
216 | mbShadow = rFont.IsShadow(); | |||
217 | } | |||
218 | ||||
219 | void XclFontData::FillFromSvxFont( const SvxFont& rFont ) | |||
220 | { | |||
221 | FillFromVclFont( rFont ); | |||
222 | SetScEscapement( rFont.GetEscapement() ); | |||
223 | } | |||
224 | ||||
225 | // *** conversion of VCL/SVX constants *** ------------------------------------ | |||
226 | ||||
227 | FontFamily XclFontData::GetScFamily( rtl_TextEncoding eDefTextEnc ) const | |||
228 | { | |||
229 | FontFamily eScFamily; | |||
230 | // ! format differs from Windows documentation: family is in lower nibble, pitch unknown | |||
231 | switch( mnFamily & 0x0F ) | |||
232 | { | |||
233 | case EXC_FONTFAM_ROMAN: eScFamily = FAMILY_ROMAN; break; | |||
234 | case EXC_FONTFAM_SWISS: eScFamily = FAMILY_SWISS; break; | |||
235 | case EXC_FONTFAM_MODERN: eScFamily = FAMILY_MODERN; break; | |||
236 | case EXC_FONTFAM_SCRIPT: eScFamily = FAMILY_SCRIPT; break; | |||
237 | case EXC_FONTFAM_DECORATIVE: eScFamily = FAMILY_DECORATIVE; break; | |||
238 | default: | |||
239 | eScFamily = | |||
240 | ((eDefTextEnc == RTL_TEXTENCODING_APPLE_ROMAN(((rtl_TextEncoding) 2))) && | |||
241 | (maName.equalsIgnoreAsciiCase( "Geneva" ) || maName.equalsIgnoreAsciiCase( "Chicago" ))) ? | |||
242 | FAMILY_SWISS : FAMILY_DONTKNOW; | |||
243 | } | |||
244 | return eScFamily; | |||
245 | } | |||
246 | ||||
247 | rtl_TextEncoding XclFontData::GetFontEncoding() const | |||
248 | { | |||
249 | // convert Windows character set to text encoding identifier | |||
250 | return rtl_getTextEncodingFromWindowsCharset( mnCharSet ); | |||
251 | } | |||
252 | ||||
253 | FontItalic XclFontData::GetScPosture() const | |||
254 | { | |||
255 | return mbItalic ? ITALIC_NORMAL : ITALIC_NONE; | |||
256 | } | |||
257 | ||||
258 | FontWeight XclFontData::GetScWeight() const | |||
259 | { | |||
260 | FontWeight eScWeight; | |||
261 | ||||
262 | if( !mnWeight ) eScWeight = WEIGHT_DONTKNOW; | |||
263 | else if( mnWeight < 150 ) eScWeight = WEIGHT_THIN; | |||
264 | else if( mnWeight < 250 ) eScWeight = WEIGHT_ULTRALIGHT; | |||
265 | else if( mnWeight < 325 ) eScWeight = WEIGHT_LIGHT; | |||
266 | else if( mnWeight < 375 ) eScWeight = WEIGHT_SEMILIGHT; | |||
267 | else if( mnWeight < 450 ) eScWeight = WEIGHT_NORMAL; | |||
268 | else if( mnWeight < 550 ) eScWeight = WEIGHT_MEDIUM; | |||
269 | else if( mnWeight < 650 ) eScWeight = WEIGHT_SEMIBOLD; | |||
270 | else if( mnWeight < 750 ) eScWeight = WEIGHT_BOLD; | |||
271 | else if( mnWeight < 850 ) eScWeight = WEIGHT_ULTRABOLD; | |||
272 | else eScWeight = WEIGHT_BLACK; | |||
273 | ||||
274 | return eScWeight; | |||
275 | } | |||
276 | ||||
277 | FontLineStyle XclFontData::GetScUnderline() const | |||
278 | { | |||
279 | FontLineStyle eScUnderl = LINESTYLE_NONE; | |||
280 | switch( mnUnderline ) | |||
281 | { | |||
282 | case EXC_FONTUNDERL_SINGLE: | |||
283 | case EXC_FONTUNDERL_SINGLE_ACC: eScUnderl = LINESTYLE_SINGLE; break; | |||
284 | case EXC_FONTUNDERL_DOUBLE: | |||
285 | case EXC_FONTUNDERL_DOUBLE_ACC: eScUnderl = LINESTYLE_DOUBLE; break; | |||
286 | } | |||
287 | return eScUnderl; | |||
288 | } | |||
289 | ||||
290 | SvxEscapement XclFontData::GetScEscapement() const | |||
291 | { | |||
292 | SvxEscapement eScEscapem = SvxEscapement::Off; | |||
293 | switch( mnEscapem ) | |||
294 | { | |||
295 | case EXC_FONTESC_SUPER: eScEscapem = SvxEscapement::Superscript; break; | |||
296 | case EXC_FONTESC_SUB: eScEscapem = SvxEscapement::Subscript; break; | |||
297 | } | |||
298 | return eScEscapem; | |||
299 | } | |||
300 | ||||
301 | FontStrikeout XclFontData::GetScStrikeout() const | |||
302 | { | |||
303 | return mbStrikeout ? STRIKEOUT_SINGLE : STRIKEOUT_NONE; | |||
304 | } | |||
305 | ||||
306 | void XclFontData::SetScHeight( sal_Int32 nTwips ) | |||
307 | { | |||
308 | mnHeight = static_cast< sal_uInt16 >( ::std::min( nTwips, static_cast<sal_Int32>(0x7FFFL) ) ); | |||
309 | } | |||
310 | ||||
311 | void XclFontData::SetScFamily( FontFamily eScFamily ) | |||
312 | { | |||
313 | switch( eScFamily ) | |||
314 | { | |||
315 | case FAMILY_DONTKNOW: mnFamily = EXC_FONTFAM_DONTKNOW; break; | |||
316 | case FAMILY_DECORATIVE: mnFamily = EXC_FONTFAM_DECORATIVE; break; | |||
317 | case FAMILY_MODERN: mnFamily = EXC_FONTFAM_MODERN; break; | |||
318 | case FAMILY_ROMAN: mnFamily = EXC_FONTFAM_ROMAN; break; | |||
319 | case FAMILY_SCRIPT: mnFamily = EXC_FONTFAM_SCRIPT; break; | |||
320 | case FAMILY_SWISS: mnFamily = EXC_FONTFAM_SWISS; break; | |||
321 | case FAMILY_SYSTEM: mnFamily = EXC_FONTFAM_SYSTEM; break; | |||
322 | default: | |||
323 | OSL_FAIL( "XclFontData::SetScFamily - unknown font family" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "323" ": "), "%s", "XclFontData::SetScFamily - unknown font family" ); } } while (false); | |||
324 | mnFamily = EXC_FONTFAM_DONTKNOW; | |||
325 | } | |||
326 | } | |||
327 | ||||
328 | void XclFontData::SetFontEncoding( rtl_TextEncoding eFontEnc ) | |||
329 | { | |||
330 | // convert text encoding identifier to Windows character set | |||
331 | mnCharSet = rtl_getBestWindowsCharsetFromTextEncoding( eFontEnc ); | |||
332 | } | |||
333 | ||||
334 | void XclFontData::SetScPosture( FontItalic eScPosture ) | |||
335 | { | |||
336 | mbItalic = (eScPosture == ITALIC_OBLIQUE) || (eScPosture == ITALIC_NORMAL); | |||
337 | } | |||
338 | ||||
339 | void XclFontData::SetScWeight( FontWeight eScWeight ) | |||
340 | { | |||
341 | switch( eScWeight ) | |||
342 | { | |||
343 | case WEIGHT_DONTKNOW: mnWeight = EXC_FONTWGHT_DONTKNOW; break; | |||
344 | case WEIGHT_THIN: mnWeight = EXC_FONTWGHT_THIN; break; | |||
345 | case WEIGHT_ULTRALIGHT: mnWeight = EXC_FONTWGHT_ULTRALIGHT; break; | |||
346 | case WEIGHT_LIGHT: mnWeight = EXC_FONTWGHT_LIGHT; break; | |||
347 | case WEIGHT_SEMILIGHT: mnWeight = EXC_FONTWGHT_SEMILIGHT; break; | |||
348 | case WEIGHT_NORMAL: mnWeight = EXC_FONTWGHT_NORMAL; break; | |||
349 | case WEIGHT_MEDIUM: mnWeight = EXC_FONTWGHT_MEDIUM; break; | |||
350 | case WEIGHT_SEMIBOLD: mnWeight = EXC_FONTWGHT_SEMIBOLD; break; | |||
351 | case WEIGHT_BOLD: mnWeight = EXC_FONTWGHT_BOLD; break; | |||
352 | case WEIGHT_ULTRABOLD: mnWeight = EXC_FONTWGHT_ULTRABOLD; break; | |||
353 | case WEIGHT_BLACK: mnWeight = EXC_FONTWGHT_BLACK; break; | |||
354 | default: mnWeight = EXC_FONTWGHT_NORMAL; | |||
355 | } | |||
356 | } | |||
357 | ||||
358 | void XclFontData::SetScUnderline( FontLineStyle eScUnderl ) | |||
359 | { | |||
360 | switch( eScUnderl ) | |||
361 | { | |||
362 | case LINESTYLE_NONE: | |||
363 | case LINESTYLE_DONTKNOW: mnUnderline = EXC_FONTUNDERL_NONE; break; | |||
364 | case LINESTYLE_DOUBLE: | |||
365 | case LINESTYLE_DOUBLEWAVE: mnUnderline = EXC_FONTUNDERL_DOUBLE; break; | |||
366 | default: mnUnderline = EXC_FONTUNDERL_SINGLE; | |||
367 | } | |||
368 | } | |||
369 | ||||
370 | void XclFontData::SetScEscapement( short nScEscapem ) | |||
371 | { | |||
372 | if( nScEscapem > 0 ) | |||
373 | mnEscapem = EXC_FONTESC_SUPER; | |||
374 | else if( nScEscapem < 0 ) | |||
375 | mnEscapem = EXC_FONTESC_SUB; | |||
376 | else | |||
377 | mnEscapem = EXC_FONTESC_NONE; | |||
378 | } | |||
379 | ||||
380 | void XclFontData::SetScStrikeout( FontStrikeout eScStrikeout ) | |||
381 | { | |||
382 | mbStrikeout = | |||
383 | (eScStrikeout == STRIKEOUT_SINGLE) || (eScStrikeout == STRIKEOUT_DOUBLE) || | |||
384 | (eScStrikeout == STRIKEOUT_BOLD) || (eScStrikeout == STRIKEOUT_SLASH) || | |||
385 | (eScStrikeout == STRIKEOUT_X); | |||
386 | } | |||
387 | ||||
388 | // *** conversion of API constants *** ---------------------------------------- | |||
389 | ||||
390 | float XclFontData::GetApiHeight() const | |||
391 | { | |||
392 | return static_cast< float >( mnHeight / TWIPS_PER_POINT20.0 ); | |||
393 | } | |||
394 | ||||
395 | sal_Int16 XclFontData::GetApiFamily() const | |||
396 | { | |||
397 | sal_Int16 nApiFamily = AwtFontFamily::DONTKNOW; | |||
398 | switch( mnFamily ) | |||
399 | { | |||
400 | case FAMILY_DECORATIVE: nApiFamily = AwtFontFamily::DECORATIVE; break; | |||
401 | case FAMILY_MODERN: nApiFamily = AwtFontFamily::MODERN; break; | |||
402 | case FAMILY_ROMAN: nApiFamily = AwtFontFamily::ROMAN; break; | |||
403 | case FAMILY_SCRIPT: nApiFamily = AwtFontFamily::SCRIPT; break; | |||
404 | case FAMILY_SWISS: nApiFamily = AwtFontFamily::SWISS; break; | |||
405 | case FAMILY_SYSTEM: nApiFamily = AwtFontFamily::SYSTEM; break; | |||
406 | } | |||
407 | return nApiFamily; | |||
408 | } | |||
409 | ||||
410 | sal_Int16 XclFontData::GetApiFontEncoding() const | |||
411 | { | |||
412 | // API constants are equal to rtl_TextEncoding constants | |||
413 | return static_cast< sal_Int16 >( GetFontEncoding() ); | |||
414 | } | |||
415 | ||||
416 | Awt::FontSlant XclFontData::GetApiPosture() const | |||
417 | { | |||
418 | return mbItalic ? Awt::FontSlant_ITALIC : Awt::FontSlant_NONE; | |||
419 | } | |||
420 | ||||
421 | float XclFontData::GetApiWeight() const | |||
422 | { | |||
423 | return vcl::unohelper::ConvertFontWeight( GetScWeight() ); | |||
424 | } | |||
425 | ||||
426 | sal_Int16 XclFontData::GetApiUnderline() const | |||
427 | { | |||
428 | sal_Int16 nApiUnderl = AwtFontLineStyle::NONE; | |||
429 | switch( mnUnderline ) | |||
430 | { | |||
431 | case EXC_FONTUNDERL_SINGLE: | |||
432 | case EXC_FONTUNDERL_SINGLE_ACC: nApiUnderl = AwtFontLineStyle::SINGLE; break; | |||
433 | case EXC_FONTUNDERL_DOUBLE: | |||
434 | case EXC_FONTUNDERL_DOUBLE_ACC: nApiUnderl = AwtFontLineStyle::DOUBLE; break; | |||
435 | } | |||
436 | return nApiUnderl; | |||
437 | } | |||
438 | ||||
439 | sal_Int16 XclFontData::GetApiEscapement() const | |||
440 | { | |||
441 | sal_Int16 nApiEscapem = 0; | |||
442 | switch( mnEscapem ) | |||
443 | { | |||
444 | case EXC_FONTESC_SUPER: nApiEscapem = 33; break; | |||
445 | case EXC_FONTESC_SUB: nApiEscapem = -33; break; | |||
446 | } | |||
447 | return nApiEscapem; | |||
448 | } | |||
449 | ||||
450 | sal_Int16 XclFontData::GetApiStrikeout() const | |||
451 | { | |||
452 | return mbStrikeout ? AwtFontStrikeout::SINGLE : AwtFontStrikeout::NONE; | |||
453 | } | |||
454 | ||||
455 | void XclFontData::SetApiHeight( float fPoint ) | |||
456 | { | |||
457 | mnHeight = static_cast< sal_uInt16 >( ::std::min( fPoint * TWIPS_PER_POINT20.0 + 0.5, 32767.0 ) ); | |||
458 | } | |||
459 | ||||
460 | void XclFontData::SetApiFamily( sal_Int16 nApiFamily ) | |||
461 | { | |||
462 | switch( nApiFamily ) | |||
463 | { | |||
464 | case AwtFontFamily::DECORATIVE: mnFamily = FAMILY_DECORATIVE; break; | |||
465 | case AwtFontFamily::MODERN: mnFamily = FAMILY_MODERN; break; | |||
466 | case AwtFontFamily::ROMAN: mnFamily = FAMILY_ROMAN; break; | |||
467 | case AwtFontFamily::SCRIPT: mnFamily = FAMILY_SCRIPT; break; | |||
468 | case AwtFontFamily::SWISS: mnFamily = FAMILY_SWISS; break; | |||
469 | case AwtFontFamily::SYSTEM: mnFamily = FAMILY_SYSTEM; break; | |||
470 | default: mnFamily = FAMILY_DONTKNOW; | |||
471 | } | |||
472 | } | |||
473 | ||||
474 | void XclFontData::SetApiPosture( Awt::FontSlant eApiPosture ) | |||
475 | { | |||
476 | mbItalic = | |||
477 | (eApiPosture == Awt::FontSlant_OBLIQUE) || | |||
478 | (eApiPosture == Awt::FontSlant_ITALIC) || | |||
479 | (eApiPosture == Awt::FontSlant_REVERSE_OBLIQUE) || | |||
480 | (eApiPosture == Awt::FontSlant_REVERSE_ITALIC); | |||
481 | } | |||
482 | ||||
483 | void XclFontData::SetApiWeight( float fApiWeight ) | |||
484 | { | |||
485 | SetScWeight( vcl::unohelper::ConvertFontWeight( fApiWeight ) ); | |||
486 | } | |||
487 | ||||
488 | void XclFontData::SetApiUnderline( sal_Int16 nApiUnderl ) | |||
489 | { | |||
490 | switch( nApiUnderl ) | |||
491 | { | |||
492 | case AwtFontLineStyle::NONE: | |||
493 | case AwtFontLineStyle::DONTKNOW: mnUnderline = EXC_FONTUNDERL_NONE; break; | |||
494 | case AwtFontLineStyle::DOUBLE: | |||
495 | case AwtFontLineStyle::DOUBLEWAVE: mnUnderline = EXC_FONTUNDERL_DOUBLE; break; | |||
496 | default: mnUnderline = EXC_FONTUNDERL_SINGLE; | |||
497 | } | |||
498 | } | |||
499 | ||||
500 | void XclFontData::SetApiEscapement( sal_Int16 nApiEscapem ) | |||
501 | { | |||
502 | if( nApiEscapem > 0 ) | |||
503 | mnEscapem = EXC_FONTESC_SUPER; | |||
504 | else if( nApiEscapem < 0 ) | |||
505 | mnEscapem = EXC_FONTESC_SUB; | |||
506 | else | |||
507 | mnEscapem = EXC_FONTESC_NONE; | |||
508 | } | |||
509 | ||||
510 | void XclFontData::SetApiStrikeout( sal_Int16 nApiStrikeout ) | |||
511 | { | |||
512 | mbStrikeout = | |||
513 | (nApiStrikeout != AwtFontStrikeout::NONE) && | |||
514 | (nApiStrikeout != AwtFontStrikeout::DONTKNOW); | |||
515 | } | |||
516 | ||||
517 | bool operator==( const XclFontData& rLeft, const XclFontData& rRight ) | |||
518 | { | |||
519 | return | |||
520 | (rLeft.mnHeight == rRight.mnHeight) && | |||
521 | (rLeft.mnWeight == rRight.mnWeight) && | |||
522 | (rLeft.mnUnderline == rRight.mnUnderline) && | |||
523 | (rLeft.maColor == rRight.maColor) && | |||
524 | (rLeft.mnEscapem == rRight.mnEscapem) && | |||
525 | (rLeft.mnFamily == rRight.mnFamily) && | |||
526 | (rLeft.mnCharSet == rRight.mnCharSet) && | |||
527 | (rLeft.mbItalic == rRight.mbItalic) && | |||
528 | (rLeft.mbStrikeout == rRight.mbStrikeout) && | |||
529 | (rLeft.mbOutline == rRight.mbOutline) && | |||
530 | (rLeft.mbShadow == rRight.mbShadow) && | |||
531 | (rLeft.maName == rRight.maName); | |||
532 | } | |||
533 | ||||
534 | namespace { | |||
535 | ||||
536 | /** Property names for common font settings. */ | |||
537 | const char *const sppcPropNamesChCommon[] = | |||
538 | { | |||
539 | "CharUnderline", "CharStrikeout", "CharColor", "CharContoured", "CharShadowed", nullptr | |||
540 | }; | |||
541 | /** Property names for Western font settings. */ | |||
542 | const char *const sppcPropNamesChWstrn[] = | |||
543 | { | |||
544 | "CharFontName", "CharHeight", "CharPosture", "CharWeight", nullptr | |||
545 | }; | |||
546 | /** Property names for Asian font settings. */ | |||
547 | const char *const sppcPropNamesChAsian[] = | |||
548 | { | |||
549 | "CharFontNameAsian", "CharHeightAsian", "CharPostureAsian", "CharWeightAsian", nullptr | |||
550 | }; | |||
551 | /** Property names for Complex font settings. */ | |||
552 | const char *const sppcPropNamesChCmplx[] = | |||
553 | { | |||
554 | "CharFontNameComplex", "CharHeightComplex", "CharPostureComplex", "CharWeightComplex", nullptr | |||
555 | }; | |||
556 | /** Property names for escapement. */ | |||
557 | const char *const sppcPropNamesChEscapement[] = | |||
558 | { | |||
559 | "CharEscapement", "CharEscapementHeight", nullptr | |||
560 | }; | |||
561 | const sal_Int8 EXC_API_ESC_HEIGHT = 58; /// Default escapement font height. | |||
562 | ||||
563 | /** Property names for Western font settings without font name. */ | |||
564 | const char *const *const sppcPropNamesChWstrnNoName = sppcPropNamesChWstrn + 1; | |||
565 | /** Property names for Asian font settings without font name. */ | |||
566 | const char *const *const sppcPropNamesChAsianNoName = sppcPropNamesChAsian + 1; | |||
567 | /** Property names for Complex font settings without font name. */ | |||
568 | const char *const *const sppcPropNamesChCmplxNoName = sppcPropNamesChCmplx + 1; | |||
569 | ||||
570 | /** Property names for font settings in form controls. */ | |||
571 | const char *const sppcPropNamesControl[] = | |||
572 | { | |||
573 | "FontName", "FontFamily", "FontCharset", "FontHeight", "FontSlant", | |||
574 | "FontWeight", "FontLineStyle", "FontStrikeout", "TextColor", nullptr | |||
575 | }; | |||
576 | ||||
577 | /** Inserts all passed API font settings into the font data object. */ | |||
578 | void lclSetApiFontSettings( XclFontData& rFontData, | |||
579 | const OUString& rApiFontName, float fApiHeight, float fApiWeight, | |||
580 | Awt::FontSlant eApiPosture, sal_Int16 nApiUnderl, sal_Int16 nApiStrikeout ) | |||
581 | { | |||
582 | rFontData.maName = XclTools::GetXclFontName( rApiFontName ); | |||
583 | rFontData.SetApiHeight( fApiHeight ); | |||
584 | rFontData.SetApiWeight( fApiWeight ); | |||
585 | rFontData.SetApiPosture( eApiPosture ); | |||
586 | rFontData.SetApiUnderline( nApiUnderl ); | |||
587 | rFontData.SetApiStrikeout( nApiStrikeout ); | |||
588 | } | |||
589 | ||||
590 | /** Writes script dependent properties to a font property set helper. */ | |||
591 | void lclWriteChartFont( ScfPropertySet& rPropSet, | |||
592 | ScfPropSetHelper& rHlpName, ScfPropSetHelper& rHlpNoName, | |||
593 | const XclFontData& rFontData, bool bHasFontName ) | |||
594 | { | |||
595 | // select the font helper | |||
596 | ScfPropSetHelper& rPropSetHlp = bHasFontName ? rHlpName : rHlpNoName; | |||
597 | // initialize the font helper (must be called before writing any properties) | |||
598 | rPropSetHlp.InitializeWrite(); | |||
599 | // write font name | |||
600 | if( bHasFontName ) | |||
601 | rPropSetHlp << rFontData.maName; | |||
602 | // write remaining properties | |||
603 | rPropSetHlp << rFontData.GetApiHeight() << rFontData.GetApiPosture() << rFontData.GetApiWeight(); | |||
604 | // write properties to property set | |||
605 | rPropSetHlp.WriteToPropertySet( rPropSet ); | |||
606 | } | |||
607 | ||||
608 | } // namespace | |||
609 | ||||
610 | XclFontPropSetHelper::XclFontPropSetHelper() : | |||
611 | maHlpChCommon( sppcPropNamesChCommon ), | |||
612 | maHlpChWstrn( sppcPropNamesChWstrn ), | |||
613 | maHlpChAsian( sppcPropNamesChAsian ), | |||
614 | maHlpChCmplx( sppcPropNamesChCmplx ), | |||
615 | maHlpChWstrnNoName( sppcPropNamesChWstrnNoName ), | |||
616 | maHlpChAsianNoName( sppcPropNamesChAsianNoName ), | |||
617 | maHlpChCmplxNoName( sppcPropNamesChCmplxNoName ), | |||
618 | maHlpChEscapement( sppcPropNamesChEscapement ), | |||
619 | maHlpControl( sppcPropNamesControl ) | |||
620 | { | |||
621 | } | |||
622 | ||||
623 | void XclFontPropSetHelper::ReadFontProperties( XclFontData& rFontData, | |||
624 | const ScfPropertySet& rPropSet, XclFontPropSetType eType, sal_Int16 nScript ) | |||
625 | { | |||
626 | switch( eType ) | |||
| ||||
627 | { | |||
628 | case EXC_FONTPROPSET_CHART: | |||
629 | { | |||
630 | OUString aApiFontName; | |||
631 | float fApiHeight, fApiWeight; | |||
632 | sal_Int16 nApiUnderl = 0, nApiStrikeout = 0; | |||
633 | Awt::FontSlant eApiPosture; | |||
634 | ||||
635 | // read script type dependent properties | |||
636 | ScfPropSetHelper& rPropSetHlp = GetChartHelper( nScript ); | |||
637 | rPropSetHlp.ReadFromPropertySet( rPropSet ); | |||
638 | rPropSetHlp >> aApiFontName >> fApiHeight >> eApiPosture >> fApiWeight; | |||
639 | // read common properties | |||
640 | maHlpChCommon.ReadFromPropertySet( rPropSet ); | |||
641 | maHlpChCommon >> nApiUnderl | |||
642 | >> nApiStrikeout | |||
643 | >> rFontData.maColor | |||
644 | >> rFontData.mbOutline | |||
645 | >> rFontData.mbShadow; | |||
646 | ||||
647 | // convert API property values to Excel settings | |||
648 | lclSetApiFontSettings( rFontData, aApiFontName, | |||
| ||||
649 | fApiHeight, fApiWeight, eApiPosture, nApiUnderl, nApiStrikeout ); | |||
650 | ||||
651 | // font escapement | |||
652 | sal_Int16 nApiEscapement = 0; | |||
653 | sal_Int8 nApiEscHeight = 0; | |||
654 | maHlpChEscapement.ReadFromPropertySet( rPropSet ); | |||
655 | maHlpChEscapement.ReadFromPropertySet( rPropSet ); | |||
656 | maHlpChEscapement.ReadFromPropertySet( rPropSet ); | |||
657 | maHlpChEscapement >> nApiEscapement >> nApiEscHeight; | |||
658 | rFontData.SetApiEscapement( nApiEscapement ); | |||
659 | } | |||
660 | break; | |||
661 | ||||
662 | case EXC_FONTPROPSET_CONTROL: | |||
663 | { | |||
664 | OUString aApiFontName; | |||
665 | float fApiHeight(0.0), fApiWeight(0.0); | |||
666 | sal_Int16 nApiFamily(0), nApiCharSet(0), nApiPosture(0), nApiUnderl(0), nApiStrikeout(0); | |||
667 | ||||
668 | // read font properties | |||
669 | maHlpControl.ReadFromPropertySet( rPropSet ); | |||
670 | maHlpControl >> aApiFontName | |||
671 | >> nApiFamily | |||
672 | >> nApiCharSet | |||
673 | >> fApiHeight | |||
674 | >> nApiPosture | |||
675 | >> fApiWeight | |||
676 | >> nApiUnderl | |||
677 | >> nApiStrikeout | |||
678 | >> rFontData.maColor; | |||
679 | ||||
680 | // convert API property values to Excel settings | |||
681 | Awt::FontSlant eApiPosture = static_cast< Awt::FontSlant >( nApiPosture ); | |||
682 | lclSetApiFontSettings( rFontData, aApiFontName, | |||
683 | fApiHeight, fApiWeight, eApiPosture, nApiUnderl, nApiStrikeout ); | |||
684 | rFontData.SetApiFamily( nApiFamily ); | |||
685 | rFontData.SetFontEncoding( nApiCharSet ); | |||
686 | } | |||
687 | break; | |||
688 | } | |||
689 | } | |||
690 | ||||
691 | void XclFontPropSetHelper::WriteFontProperties( | |||
692 | ScfPropertySet& rPropSet, XclFontPropSetType eType, | |||
693 | const XclFontData& rFontData, bool bHasWstrn, bool bHasAsian, bool bHasCmplx, | |||
694 | const Color* pFontColor ) | |||
695 | { | |||
696 | switch( eType ) | |||
697 | { | |||
698 | case EXC_FONTPROPSET_CHART: | |||
699 | { | |||
700 | // write common properties | |||
701 | maHlpChCommon.InitializeWrite(); | |||
702 | const Color& rColor = pFontColor ? *pFontColor : rFontData.maColor; | |||
703 | maHlpChCommon << rFontData.GetApiUnderline() | |||
704 | << rFontData.GetApiStrikeout() | |||
705 | << rColor | |||
706 | << rFontData.mbOutline | |||
707 | << rFontData.mbShadow; | |||
708 | maHlpChCommon.WriteToPropertySet( rPropSet ); | |||
709 | ||||
710 | // write script type dependent properties | |||
711 | lclWriteChartFont( rPropSet, maHlpChWstrn, maHlpChWstrnNoName, rFontData, bHasWstrn ); | |||
712 | lclWriteChartFont( rPropSet, maHlpChAsian, maHlpChAsianNoName, rFontData, bHasAsian ); | |||
713 | lclWriteChartFont( rPropSet, maHlpChCmplx, maHlpChCmplxNoName, rFontData, bHasCmplx ); | |||
714 | ||||
715 | // font escapement | |||
716 | if( rFontData.GetScEscapement() != SvxEscapement::Off ) | |||
717 | { | |||
718 | maHlpChEscapement.InitializeWrite(); | |||
719 | maHlpChEscapement << rFontData.GetApiEscapement() << EXC_API_ESC_HEIGHT; | |||
720 | maHlpChEscapement.WriteToPropertySet( rPropSet ); | |||
721 | } | |||
722 | } | |||
723 | break; | |||
724 | ||||
725 | case EXC_FONTPROPSET_CONTROL: | |||
726 | { | |||
727 | maHlpControl.InitializeWrite(); | |||
728 | maHlpControl << rFontData.maName | |||
729 | << rFontData.GetApiFamily() | |||
730 | << rFontData.GetApiFontEncoding() | |||
731 | << static_cast< sal_Int16 >( rFontData.GetApiHeight() + 0.5 ) | |||
732 | << rFontData.GetApiPosture() | |||
733 | << rFontData.GetApiWeight() | |||
734 | << rFontData.GetApiUnderline() | |||
735 | << rFontData.GetApiStrikeout() | |||
736 | << rFontData.maColor; | |||
737 | maHlpControl.WriteToPropertySet( rPropSet ); | |||
738 | } | |||
739 | break; | |||
740 | } | |||
741 | } | |||
742 | ||||
743 | ScfPropSetHelper& XclFontPropSetHelper::GetChartHelper( sal_Int16 nScript ) | |||
744 | { | |||
745 | namespace ApiScriptType = ::com::sun::star::i18n::ScriptType; | |||
746 | switch( nScript ) | |||
747 | { | |||
748 | case ApiScriptType::LATIN: return maHlpChWstrn; | |||
749 | case ApiScriptType::ASIAN: return maHlpChAsian; | |||
750 | case ApiScriptType::COMPLEX: return maHlpChCmplx; | |||
751 | default: OSL_FAIL( "XclFontPropSetHelper::GetChartHelper - unknown script type" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "751" ": "), "%s", "XclFontPropSetHelper::GetChartHelper - unknown script type" ); } } while (false); | |||
752 | } | |||
753 | return maHlpChWstrn; | |||
754 | } | |||
755 | ||||
756 | // Number formats ============================================================= | |||
757 | ||||
758 | namespace { | |||
759 | ||||
760 | /** Special number format index describing a reused format. */ | |||
761 | const NfIndexTableOffset PRV_NF_INDEX_REUSE = NF_INDEX_TABLE_ENTRIES; | |||
762 | ||||
763 | /** German primary language not defined, LANGUAGE_GERMAN belongs to Germany. */ | |||
764 | constexpr LanguageType PRV_LANGUAGE_GERMAN_PRIM = primary(LANGUAGE_GERMANLanguageType(0x0407)); | |||
765 | /** French primary language not defined, LANGUAGE_FRENCH belongs to France. */ | |||
766 | constexpr LanguageType PRV_LANGUAGE_FRENCH_PRIM = primary(LANGUAGE_FRENCHLanguageType(0x040C)); | |||
767 | /** Parent language identifier for Asian languages. */ | |||
768 | constexpr LanguageType PRV_LANGUAGE_ASIAN_PRIM = primary(LANGUAGE_CHINESELanguageType(0x0804)); | |||
769 | ||||
770 | /** Stores the number format used in Calc for an Excel built-in number format. */ | |||
771 | struct XclBuiltInFormat | |||
772 | { | |||
773 | sal_uInt16 mnXclNumFmt; /// Excel built-in index. | |||
774 | const char* mpFormat; /// Format string, may be 0 (meOffset used then). | |||
775 | NfIndexTableOffset meOffset; /// SvNumberFormatter format index, if mpFormat==0. | |||
776 | sal_uInt16 mnXclReuseFmt; /// Use this Excel format, if meOffset==PRV_NF_INDEX_REUSE. | |||
777 | }; | |||
778 | ||||
779 | /** Defines a literal Excel built-in number format. */ | |||
780 | #define EXC_NUMFMT_STRING( nXclNumFmt, pcUtf8 ) \ | |||
781 | { nXclNumFmt, pcUtf8, NF_NUMBER_STANDARD, 0 } | |||
782 | ||||
783 | /** Defines an Excel built-in number format that maps to an own built-in format. */ | |||
784 | #define EXC_NUMFMT_OFFSET( nXclNumFmt, eOffset ) \ | |||
785 | { nXclNumFmt, nullptr, eOffset, 0 } | |||
786 | ||||
787 | /** Defines an Excel built-in number format that is the same as the specified. */ | |||
788 | #define EXC_NUMFMT_REUSE( nXclNumFmt, nXclReuse ) \ | |||
789 | { nXclNumFmt, nullptr, PRV_NF_INDEX_REUSE, nXclReuse } | |||
790 | ||||
791 | /** Terminates an Excel built-in number format table. */ | |||
792 | #define EXC_NUMFMT_ENDTABLE() \ | |||
793 | { EXC_FORMAT_NOTFOUND, nullptr, NF_NUMBER_STANDARD, 0 } | |||
794 | ||||
795 | // Currency unit characters | |||
796 | #define UTF8_BAHT"\340\270\277" "\340\270\277" | |||
797 | #define UTF8_EURO"\342\202\254" "\342\202\254" | |||
798 | #define UTF8_POUND_UK"\302\243" "\302\243" | |||
799 | #define UTF8_SHEQEL"\342\202\252" "\342\202\252" | |||
800 | #define UTF8_WON"\357\277\246" "\357\277\246" | |||
801 | #define UTF8_YEN_CS"\357\277\245" "\357\277\245" | |||
802 | #define UTF8_YEN_JP"\302\245" "\302\245" | |||
803 | ||||
804 | // Japanese/Chinese date/time characters | |||
805 | #define UTF8_CJ_YEAR"\345\271\264" "\345\271\264" | |||
806 | #define UTF8_CJ_MON"\346\234\210" "\346\234\210" | |||
807 | #define UTF8_CJ_DAY"\346\227\245" "\346\227\245" | |||
808 | #define UTF8_CJ_HOUR"\346\231\202" "\346\231\202" | |||
809 | #define UTF8_CJ_MIN"\345\210\206" "\345\210\206" | |||
810 | #define UTF8_CJ_SEC"\347\247\222" "\347\247\222" | |||
811 | ||||
812 | // Chinese Simplified date/time characters | |||
813 | #define UTF8_CS_HOUR"\346\227\266" "\346\227\266" | |||
814 | ||||
815 | // Korean date/time characters | |||
816 | #define UTF8_KO_YEAR"\353\205\204" "\353\205\204" | |||
817 | #define UTF8_KO_MON"\354\233\224" "\354\233\224" | |||
818 | #define UTF8_KO_DAY"\354\235\274" "\354\235\274" | |||
819 | #define UTF8_KO_HOUR"\354\213\234" "\354\213\234" | |||
820 | #define UTF8_KO_MIN"\353\266\204" "\353\266\204" | |||
821 | #define UTF8_KO_SEC"\354\264\210" "\354\264\210" | |||
822 | ||||
823 | /** Default number format table. Last parent of all other tables, used for unknown languages. */ | |||
824 | const XclBuiltInFormat spBuiltInFormats_DONTKNOW[] = | |||
825 | { | |||
826 | EXC_NUMFMT_OFFSET( 0, NF_NUMBER_STANDARD ), // General | |||
827 | EXC_NUMFMT_OFFSET( 1, NF_NUMBER_INT ), // 0 | |||
828 | EXC_NUMFMT_OFFSET( 2, NF_NUMBER_DEC2 ), // 0.00 | |||
829 | EXC_NUMFMT_OFFSET( 3, NF_NUMBER_1000INT ), // #,##0 | |||
830 | EXC_NUMFMT_OFFSET( 4, NF_NUMBER_1000DEC2 ), // #,##0.00 | |||
831 | // 5...8 contained in file | |||
832 | EXC_NUMFMT_OFFSET( 9, NF_PERCENT_INT ), // 0% | |||
833 | EXC_NUMFMT_OFFSET( 10, NF_PERCENT_DEC2 ), // 0.00% | |||
834 | EXC_NUMFMT_OFFSET( 11, NF_SCIENTIFIC_000E00 ), // 0.00E+00 | |||
835 | EXC_NUMFMT_OFFSET( 12, NF_FRACTION_1D ), // # ?/? | |||
836 | EXC_NUMFMT_OFFSET( 13, NF_FRACTION_2D ), // # ??/?? | |||
837 | ||||
838 | // 14...22 date and time formats | |||
839 | EXC_NUMFMT_OFFSET( 14, NF_DATE_SYS_DDMMYYYY ), | |||
840 | EXC_NUMFMT_OFFSET( 15, NF_DATE_SYS_DMMMYY ), | |||
841 | EXC_NUMFMT_OFFSET( 16, NF_DATE_SYS_DDMMM ), | |||
842 | EXC_NUMFMT_OFFSET( 17, NF_DATE_SYS_MMYY ), | |||
843 | EXC_NUMFMT_OFFSET( 18, NF_TIME_HHMMAMPM ), | |||
844 | EXC_NUMFMT_OFFSET( 19, NF_TIME_HHMMSSAMPM ), | |||
845 | EXC_NUMFMT_OFFSET( 20, NF_TIME_HHMM ), | |||
846 | EXC_NUMFMT_OFFSET( 21, NF_TIME_HHMMSS ), | |||
847 | EXC_NUMFMT_OFFSET( 22, NF_DATETIME_SYSTEM_SHORT_HHMM ), | |||
848 | ||||
849 | // 23...36 international formats | |||
850 | EXC_NUMFMT_REUSE( 23, 0 ), | |||
851 | EXC_NUMFMT_REUSE( 24, 0 ), | |||
852 | EXC_NUMFMT_REUSE( 25, 0 ), | |||
853 | EXC_NUMFMT_REUSE( 26, 0 ), | |||
854 | EXC_NUMFMT_REUSE( 27, 14 ), | |||
855 | EXC_NUMFMT_REUSE( 28, 14 ), | |||
856 | EXC_NUMFMT_REUSE( 29, 14 ), | |||
857 | EXC_NUMFMT_REUSE( 30, 14 ), | |||
858 | EXC_NUMFMT_REUSE( 31, 14 ), | |||
859 | EXC_NUMFMT_REUSE( 32, 21 ), | |||
860 | EXC_NUMFMT_REUSE( 33, 21 ), | |||
861 | EXC_NUMFMT_REUSE( 34, 21 ), | |||
862 | EXC_NUMFMT_REUSE( 35, 21 ), | |||
863 | EXC_NUMFMT_REUSE( 36, 14 ), | |||
864 | ||||
865 | // 37...44 accounting formats | |||
866 | // 41...44 contained in file | |||
867 | EXC_NUMFMT_STRING( 37, "#,##0;-#,##0" ), | |||
868 | EXC_NUMFMT_STRING( 38, "#,##0;[RED]-#,##0" ), | |||
869 | EXC_NUMFMT_STRING( 39, "#,##0.00;-#,##0.00" ), | |||
870 | EXC_NUMFMT_STRING( 40, "#,##0.00;[RED]-#,##0.00" ), | |||
871 | ||||
872 | // 45...49 more special formats | |||
873 | EXC_NUMFMT_STRING( 45, "mm:ss" ), | |||
874 | EXC_NUMFMT_STRING( 46, "[h]:mm:ss" ), | |||
875 | EXC_NUMFMT_STRING( 47, "mm:ss.0" ), | |||
876 | EXC_NUMFMT_STRING( 48, "##0.0E+0" ), | |||
877 | EXC_NUMFMT_OFFSET( 49, NF_TEXT ), | |||
878 | ||||
879 | // 50...81 international formats | |||
880 | EXC_NUMFMT_REUSE( 50, 14 ), | |||
881 | EXC_NUMFMT_REUSE( 51, 14 ), | |||
882 | EXC_NUMFMT_REUSE( 52, 14 ), | |||
883 | EXC_NUMFMT_REUSE( 53, 14 ), | |||
884 | EXC_NUMFMT_REUSE( 54, 14 ), | |||
885 | EXC_NUMFMT_REUSE( 55, 14 ), | |||
886 | EXC_NUMFMT_REUSE( 56, 14 ), | |||
887 | EXC_NUMFMT_REUSE( 57, 14 ), | |||
888 | EXC_NUMFMT_REUSE( 58, 14 ), | |||
889 | EXC_NUMFMT_REUSE( 59, 1 ), | |||
890 | EXC_NUMFMT_REUSE( 60, 2 ), | |||
891 | EXC_NUMFMT_REUSE( 61, 3 ), | |||
892 | EXC_NUMFMT_REUSE( 62, 4 ), | |||
893 | EXC_NUMFMT_REUSE( 67, 9 ), | |||
894 | EXC_NUMFMT_REUSE( 68, 10 ), | |||
895 | EXC_NUMFMT_REUSE( 69, 12 ), | |||
896 | EXC_NUMFMT_REUSE( 70, 13 ), | |||
897 | EXC_NUMFMT_REUSE( 71, 14 ), | |||
898 | EXC_NUMFMT_REUSE( 72, 14 ), | |||
899 | EXC_NUMFMT_REUSE( 73, 15 ), | |||
900 | EXC_NUMFMT_REUSE( 74, 16 ), | |||
901 | EXC_NUMFMT_REUSE( 75, 17 ), | |||
902 | EXC_NUMFMT_REUSE( 76, 20 ), | |||
903 | EXC_NUMFMT_REUSE( 77, 21 ), | |||
904 | EXC_NUMFMT_REUSE( 78, 22 ), | |||
905 | EXC_NUMFMT_REUSE( 79, 45 ), | |||
906 | EXC_NUMFMT_REUSE( 80, 46 ), | |||
907 | EXC_NUMFMT_REUSE( 81, 47 ), | |||
908 | ||||
909 | // 82...163 not used, must not occur in a file (Excel may crash) | |||
910 | ||||
911 | EXC_NUMFMT_ENDTABLE() | |||
912 | }; | |||
913 | ||||
914 | // ENGLISH -------------------------------------------------------------------- | |||
915 | ||||
916 | /** Base table for English locales. */ | |||
917 | const XclBuiltInFormat spBuiltInFormats_ENGLISH[] = | |||
918 | { | |||
919 | EXC_NUMFMT_STRING( 15, "DD-MMM-YY" ), | |||
920 | EXC_NUMFMT_STRING( 16, "DD-MMM" ), | |||
921 | EXC_NUMFMT_STRING( 17, "MMM-YY" ), | |||
922 | EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ), | |||
923 | EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ), | |||
924 | EXC_NUMFMT_STRING( 22, "DD/MM/YYYY hh:mm" ), | |||
925 | EXC_NUMFMT_ENDTABLE() | |||
926 | }; | |||
927 | ||||
928 | const XclBuiltInFormat spBuiltInFormats_ENGLISH_UK[] = | |||
929 | { | |||
930 | EXC_NUMFMT_STRING( 63, UTF8_POUND_UK"\302\243" "#,##0;-" UTF8_POUND_UK"\302\243" "#,##0" ), | |||
931 | EXC_NUMFMT_STRING( 64, UTF8_POUND_UK"\302\243" "#,##0;[RED]-" UTF8_POUND_UK"\302\243" "#,##0" ), | |||
932 | EXC_NUMFMT_STRING( 65, UTF8_POUND_UK"\302\243" "#,##0.00;-" UTF8_POUND_UK"\302\243" "#,##0.00" ), | |||
933 | EXC_NUMFMT_STRING( 66, UTF8_POUND_UK"\302\243" "#,##0.00;[RED]-" UTF8_POUND_UK"\302\243" "#,##0.00" ), | |||
934 | EXC_NUMFMT_ENDTABLE() | |||
935 | }; | |||
936 | ||||
937 | const XclBuiltInFormat spBuiltInFormats_ENGLISH_EIRE[] = | |||
938 | { | |||
939 | EXC_NUMFMT_STRING( 63, UTF8_EURO"\342\202\254" "#,##0;-" UTF8_EURO"\342\202\254" "#,##0" ), | |||
940 | EXC_NUMFMT_STRING( 64, UTF8_EURO"\342\202\254" "#,##0;[RED]-" UTF8_EURO"\342\202\254" "#,##0" ), | |||
941 | EXC_NUMFMT_STRING( 65, UTF8_EURO"\342\202\254" "#,##0.00;-" UTF8_EURO"\342\202\254" "#,##0.00" ), | |||
942 | EXC_NUMFMT_STRING( 66, UTF8_EURO"\342\202\254" "#,##0.00;[RED]-" UTF8_EURO"\342\202\254" "#,##0.00" ), | |||
943 | EXC_NUMFMT_ENDTABLE() | |||
944 | }; | |||
945 | ||||
946 | const XclBuiltInFormat spBuiltInFormats_ENGLISH_US[] = | |||
947 | { | |||
948 | EXC_NUMFMT_STRING( 14, "M/D/YYYY" ), | |||
949 | EXC_NUMFMT_STRING( 15, "D-MMM-YY" ), | |||
950 | EXC_NUMFMT_STRING( 16, "D-MMM" ), | |||
951 | EXC_NUMFMT_STRING( 20, "h:mm" ), | |||
952 | EXC_NUMFMT_STRING( 21, "h:mm:ss" ), | |||
953 | EXC_NUMFMT_STRING( 22, "M/D/YYYY h:mm" ), | |||
954 | EXC_NUMFMT_STRING( 37, "#,##0_);(#,##0)" ), | |||
955 | EXC_NUMFMT_STRING( 38, "#,##0_);[RED](#,##0)" ), | |||
956 | EXC_NUMFMT_STRING( 39, "#,##0.00_);(#,##0.00)" ), | |||
957 | EXC_NUMFMT_STRING( 40, "#,##0.00_);[RED](#,##0.00)" ), | |||
958 | EXC_NUMFMT_STRING( 63, "$#,##0_);($#,##0)" ), | |||
959 | EXC_NUMFMT_STRING( 64, "$#,##0_);[RED]($#,##0)" ), | |||
960 | EXC_NUMFMT_STRING( 65, "$#,##0.00_);($#,##0.00)" ), | |||
961 | EXC_NUMFMT_STRING( 66, "$#,##0.00_);[RED]($#,##0.00)" ), | |||
962 | EXC_NUMFMT_ENDTABLE() | |||
963 | }; | |||
964 | ||||
965 | const XclBuiltInFormat spBuiltInFormats_ENGLISH_CAN[] = | |||
966 | { | |||
967 | EXC_NUMFMT_STRING( 20, "h:mm" ), | |||
968 | EXC_NUMFMT_STRING( 21, "h:mm:ss" ), | |||
969 | EXC_NUMFMT_STRING( 22, "DD/MM/YYYY h:mm" ), | |||
970 | EXC_NUMFMT_STRING( 63, "$#,##0;-$#,##0" ), | |||
971 | EXC_NUMFMT_STRING( 64, "$#,##0;[RED]-$#,##0" ), | |||
972 | EXC_NUMFMT_STRING( 65, "$#,##0.00;-$#,##0.00" ), | |||
973 | EXC_NUMFMT_STRING( 66, "$#,##0.00;[RED]-$#,##0.00" ), | |||
974 | EXC_NUMFMT_ENDTABLE() | |||
975 | }; | |||
976 | ||||
977 | const XclBuiltInFormat spBuiltInFormats_ENGLISH_AUS[] = | |||
978 | { | |||
979 | EXC_NUMFMT_STRING( 14, "D/MM/YYYY" ), | |||
980 | EXC_NUMFMT_STRING( 15, "D-MMM-YY" ), | |||
981 | EXC_NUMFMT_STRING( 16, "D-MMM" ), | |||
982 | EXC_NUMFMT_STRING( 20, "h:mm" ), | |||
983 | EXC_NUMFMT_STRING( 21, "h:mm:ss" ), | |||
984 | EXC_NUMFMT_STRING( 22, "D/MM/YYYY h:mm" ), | |||
985 | EXC_NUMFMT_STRING( 63, "$#,##0;-$#,##0" ), | |||
986 | EXC_NUMFMT_STRING( 64, "$#,##0;[RED]-$#,##0" ), | |||
987 | EXC_NUMFMT_STRING( 65, "$#,##0.00;-$#,##0.00" ), | |||
988 | EXC_NUMFMT_STRING( 66, "$#,##0.00;[RED]-$#,##0.00" ), | |||
989 | EXC_NUMFMT_ENDTABLE() | |||
990 | }; | |||
991 | ||||
992 | const XclBuiltInFormat spBuiltInFormats_ENGLISH_SAFRICA[] = | |||
993 | { | |||
994 | EXC_NUMFMT_STRING( 14, "YYYY/MM/DD" ), | |||
995 | EXC_NUMFMT_OFFSET( 18, NF_TIME_HHMMAMPM ), | |||
996 | EXC_NUMFMT_OFFSET( 19, NF_TIME_HHMMSSAMPM ), | |||
997 | EXC_NUMFMT_STRING( 22, "YYYY/MM/DD hh:mm" ), | |||
998 | EXC_NUMFMT_STRING( 63, "\\R #,##0;\\R -#,##0" ), | |||
999 | EXC_NUMFMT_STRING( 64, "\\R #,##0;[RED]\\R -#,##0" ), | |||
1000 | EXC_NUMFMT_STRING( 65, "\\R #,##0.00;\\R -#,##0.00" ), | |||
1001 | EXC_NUMFMT_STRING( 66, "\\R #,##0.00;[RED]\\R -#,##0.00" ), | |||
1002 | EXC_NUMFMT_ENDTABLE() | |||
1003 | }; | |||
1004 | ||||
1005 | // FRENCH --------------------------------------------------------------------- | |||
1006 | ||||
1007 | /** Base table for French locales. */ | |||
1008 | const XclBuiltInFormat spBuiltInFormats_FRENCH[] = | |||
1009 | { | |||
1010 | EXC_NUMFMT_STRING( 15, "DD-MMM-YY" ), | |||
1011 | EXC_NUMFMT_STRING( 16, "DD-MMM" ), | |||
1012 | EXC_NUMFMT_STRING( 17, "MMM-YY" ), | |||
1013 | EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ), | |||
1014 | EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ), | |||
1015 | EXC_NUMFMT_ENDTABLE() | |||
1016 | }; | |||
1017 | ||||
1018 | const XclBuiltInFormat spBuiltInFormats_FRENCH_FRANCE[] = | |||
1019 | { | |||
1020 | EXC_NUMFMT_STRING( 22, "DD/MM/YYYY hh:mm" ), | |||
1021 | EXC_NUMFMT_STRING( 37, "#,##0\\ _" UTF8_EURO"\342\202\254" ";-#,##0\\ _" UTF8_EURO"\342\202\254" ), | |||
1022 | EXC_NUMFMT_STRING( 38, "#,##0\\ _" UTF8_EURO"\342\202\254" ";[RED]-#,##0\\ _" UTF8_EURO"\342\202\254" ), | |||
1023 | EXC_NUMFMT_STRING( 39, "#,##0.00\\ _" UTF8_EURO"\342\202\254" ";-#,##0.00\\ _" UTF8_EURO"\342\202\254" ), | |||
1024 | EXC_NUMFMT_STRING( 40, "#,##0.00\\ _" UTF8_EURO"\342\202\254" ";[RED]-#,##0.00\\ _" UTF8_EURO"\342\202\254" ), | |||
1025 | EXC_NUMFMT_STRING( 63, "#,##0\\ " UTF8_EURO"\342\202\254" ";-#,##0\\ " UTF8_EURO"\342\202\254" ), | |||
1026 | EXC_NUMFMT_STRING( 64, "#,##0\\ " UTF8_EURO"\342\202\254" ";[RED]-#,##0\\ " UTF8_EURO"\342\202\254" ), | |||
1027 | EXC_NUMFMT_STRING( 65, "#,##0.00\\ " UTF8_EURO"\342\202\254" ";-#,##0.00\\ " UTF8_EURO"\342\202\254" ), | |||
1028 | EXC_NUMFMT_STRING( 66, "#,##0.00\\ " UTF8_EURO"\342\202\254" ";[RED]-#,##0.00\\ " UTF8_EURO"\342\202\254" ), | |||
1029 | EXC_NUMFMT_ENDTABLE() | |||
1030 | }; | |||
1031 | ||||
1032 | const XclBuiltInFormat spBuiltInFormats_FRENCH_CANADIAN[] = | |||
1033 | { | |||
1034 | EXC_NUMFMT_STRING( 22, "YYYY-MM-DD hh:mm" ), | |||
1035 | EXC_NUMFMT_STRING( 37, "#,##0\\ _$_-;#,##0\\ _$-" ), | |||
1036 | EXC_NUMFMT_STRING( 38, "#,##0\\ _$_-;[RED]#,##0\\ _$-" ), | |||
1037 | EXC_NUMFMT_STRING( 39, "#,##0.00\\ _$_-;#,##0.00\\ _$-" ), | |||
1038 | EXC_NUMFMT_STRING( 40, "#,##0.00\\ _$_-;[RED]#,##0.00\\ _$-" ), | |||
1039 | EXC_NUMFMT_STRING( 63, "#,##0\\ $_-;#,##0\\ $-" ), | |||
1040 | EXC_NUMFMT_STRING( 64, "#,##0\\ $_-;[RED]#,##0\\ $-" ), | |||
1041 | EXC_NUMFMT_STRING( 65, "#,##0.00\\ $_-;#,##0.00\\ $-" ), | |||
1042 | EXC_NUMFMT_STRING( 66, "#,##0.00\\ $_-;[RED]#,##0.00\\ $-" ), | |||
1043 | EXC_NUMFMT_ENDTABLE() | |||
1044 | }; | |||
1045 | ||||
1046 | const XclBuiltInFormat spBuiltInFormats_FRENCH_SWISS[] = | |||
1047 | { | |||
1048 | EXC_NUMFMT_STRING( 15, "DD.MMM.YY" ), | |||
1049 | EXC_NUMFMT_STRING( 16, "DD.MMM" ), | |||
1050 | EXC_NUMFMT_STRING( 17, "MMM.YY" ), | |||
1051 | EXC_NUMFMT_STRING( 22, "DD.MM.YYYY hh:mm" ), | |||
1052 | EXC_NUMFMT_STRING( 63, "\"SFr. \"#,##0;\"SFr. \"-#,##0" ), | |||
1053 | EXC_NUMFMT_STRING( 64, "\"SFr. \"#,##0;[RED]\"SFr. \"-#,##0" ), | |||
1054 | EXC_NUMFMT_STRING( 65, "\"SFr. \"#,##0.00;\"SFr. \"-#,##0.00" ), | |||
1055 | EXC_NUMFMT_STRING( 66, "\"SFr. \"#,##0.00;[RED]\"SFr. \"-#,##0.00" ), | |||
1056 | EXC_NUMFMT_ENDTABLE() | |||
1057 | }; | |||
1058 | ||||
1059 | const XclBuiltInFormat spBuiltInFormats_FRENCH_BELGIAN[] = | |||
1060 | { | |||
1061 | EXC_NUMFMT_STRING( 14, "D/MM/YYYY" ), | |||
1062 | EXC_NUMFMT_STRING( 15, "D-MMM-YY" ), | |||
1063 | EXC_NUMFMT_STRING( 16, "D-MMM" ), | |||
1064 | EXC_NUMFMT_STRING( 20, "h:mm" ), | |||
1065 | EXC_NUMFMT_STRING( 21, "h:mm:ss" ), | |||
1066 | EXC_NUMFMT_STRING( 22, "D/MM/YYYY h:mm" ), | |||
1067 | EXC_NUMFMT_ENDTABLE() | |||
1068 | }; | |||
1069 | ||||
1070 | // GERMAN --------------------------------------------------------------------- | |||
1071 | ||||
1072 | /** Base table for German locales. */ | |||
1073 | const XclBuiltInFormat spBuiltInFormats_GERMAN[] = | |||
1074 | { | |||
1075 | EXC_NUMFMT_STRING( 15, "DD. MMM YY" ), | |||
1076 | EXC_NUMFMT_STRING( 16, "DD. MMM" ), | |||
1077 | EXC_NUMFMT_STRING( 17, "MMM YY" ), | |||
1078 | EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ), | |||
1079 | EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ), | |||
1080 | EXC_NUMFMT_STRING( 22, "DD.MM.YYYY hh:mm" ), | |||
1081 | EXC_NUMFMT_ENDTABLE() | |||
1082 | }; | |||
1083 | ||||
1084 | const XclBuiltInFormat spBuiltInFormats_GERMAN_GERMANY[] = | |||
1085 | { | |||
1086 | EXC_NUMFMT_STRING( 37, "#,##0 _" UTF8_EURO"\342\202\254" ";-#,##0 _" UTF8_EURO"\342\202\254" ), | |||
1087 | EXC_NUMFMT_STRING( 38, "#,##0 _" UTF8_EURO"\342\202\254" ";[RED]-#,##0 _" UTF8_EURO"\342\202\254" ), | |||
1088 | EXC_NUMFMT_STRING( 39, "#,##0.00 _" UTF8_EURO"\342\202\254" ";-#,##0.00 _" UTF8_EURO"\342\202\254" ), | |||
1089 | EXC_NUMFMT_STRING( 40, "#,##0.00 _" UTF8_EURO"\342\202\254" ";[RED]-#,##0.00 _" UTF8_EURO"\342\202\254" ), | |||
1090 | EXC_NUMFMT_STRING( 63, "#,##0 " UTF8_EURO"\342\202\254" ";-#,##0 " UTF8_EURO"\342\202\254" ), | |||
1091 | EXC_NUMFMT_STRING( 64, "#,##0 " UTF8_EURO"\342\202\254" ";[RED]-#,##0 " UTF8_EURO"\342\202\254" ), | |||
1092 | EXC_NUMFMT_STRING( 65, "#,##0.00 " UTF8_EURO"\342\202\254" ";-#,##0.00 " UTF8_EURO"\342\202\254" ), | |||
1093 | EXC_NUMFMT_STRING( 66, "#,##0.00 " UTF8_EURO"\342\202\254" ";[RED]-#,##0.00 " UTF8_EURO"\342\202\254" ), | |||
1094 | EXC_NUMFMT_ENDTABLE() | |||
1095 | }; | |||
1096 | ||||
1097 | const XclBuiltInFormat spBuiltInFormats_GERMAN_AUSTRIAN[] = | |||
1098 | { | |||
1099 | EXC_NUMFMT_STRING( 15, "DD.MMM.YY" ), | |||
1100 | EXC_NUMFMT_STRING( 16, "DD.MMM" ), | |||
1101 | EXC_NUMFMT_STRING( 17, "MMM.YY" ), | |||
1102 | EXC_NUMFMT_STRING( 63, UTF8_EURO"\342\202\254" " #,##0;-" UTF8_EURO"\342\202\254" " #,##0" ), | |||
1103 | EXC_NUMFMT_STRING( 64, UTF8_EURO"\342\202\254" " #,##0;[RED]-" UTF8_EURO"\342\202\254" " #,##0" ), | |||
1104 | EXC_NUMFMT_STRING( 65, UTF8_EURO"\342\202\254" " #,##0.00;-" UTF8_EURO"\342\202\254" " #,##0.00" ), | |||
1105 | EXC_NUMFMT_STRING( 66, UTF8_EURO"\342\202\254" " #,##0.00;[RED]-" UTF8_EURO"\342\202\254" " #,##0.00" ), | |||
1106 | EXC_NUMFMT_ENDTABLE() | |||
1107 | }; | |||
1108 | ||||
1109 | const XclBuiltInFormat spBuiltInFormats_GERMAN_SWISS[] = | |||
1110 | { | |||
1111 | EXC_NUMFMT_STRING( 63, "\"SFr. \"#,##0;\"SFr. \"-#,##0" ), | |||
1112 | EXC_NUMFMT_STRING( 64, "\"SFr. \"#,##0;[RED]\"SFr. \"-#,##0" ), | |||
1113 | EXC_NUMFMT_STRING( 65, "\"SFr. \"#,##0.00;\"SFr. \"-#,##0.00" ), | |||
1114 | EXC_NUMFMT_STRING( 66, "\"SFr. \"#,##0.00;[RED]\"SFr. \"-#,##0.00" ), | |||
1115 | EXC_NUMFMT_ENDTABLE() | |||
1116 | }; | |||
1117 | ||||
1118 | const XclBuiltInFormat spBuiltInFormats_GERMAN_LUXEMBOURG[] = | |||
1119 | { | |||
1120 | EXC_NUMFMT_STRING( 15, "DD.MMM.YY" ), | |||
1121 | EXC_NUMFMT_STRING( 16, "DD.MMM" ), | |||
1122 | EXC_NUMFMT_STRING( 17, "MMM.YY" ), | |||
1123 | EXC_NUMFMT_STRING( 37, "#,##0 _" UTF8_EURO"\342\202\254" ";-#,##0 _" UTF8_EURO"\342\202\254" ), | |||
1124 | EXC_NUMFMT_STRING( 38, "#,##0 _" UTF8_EURO"\342\202\254" ";[RED]-#,##0 _" UTF8_EURO"\342\202\254" ), | |||
1125 | EXC_NUMFMT_STRING( 39, "#,##0.00 _" UTF8_EURO"\342\202\254" ";-#,##0.00 _" UTF8_EURO"\342\202\254" ), | |||
1126 | EXC_NUMFMT_STRING( 40, "#,##0.00 _" UTF8_EURO"\342\202\254" ";[RED]-#,##0.00 _" UTF8_EURO"\342\202\254" ), | |||
1127 | EXC_NUMFMT_STRING( 63, "#,##0 " UTF8_EURO"\342\202\254" ";-#,##0 " UTF8_EURO"\342\202\254" ), | |||
1128 | EXC_NUMFMT_STRING( 64, "#,##0 " UTF8_EURO"\342\202\254" ";[RED]-#,##0 " UTF8_EURO"\342\202\254" ), | |||
1129 | EXC_NUMFMT_STRING( 65, "#,##0.00 " UTF8_EURO"\342\202\254" ";-#,##0.00 " UTF8_EURO"\342\202\254" ), | |||
1130 | EXC_NUMFMT_STRING( 66, "#,##0.00 " UTF8_EURO"\342\202\254" ";[RED]-#,##0.00 " UTF8_EURO"\342\202\254" ), | |||
1131 | EXC_NUMFMT_ENDTABLE() | |||
1132 | }; | |||
1133 | ||||
1134 | const XclBuiltInFormat spBuiltInFormats_GERMAN_LIECHTENSTEIN[] = | |||
1135 | { | |||
1136 | EXC_NUMFMT_STRING( 63, "\"CHF \"#,##0;\"CHF \"-#,##0" ), | |||
1137 | EXC_NUMFMT_STRING( 64, "\"CHF \"#,##0;[RED]\"CHF \"-#,##0" ), | |||
1138 | EXC_NUMFMT_STRING( 65, "\"CHF \"#,##0.00;\"CHF \"-#,##0.00" ), | |||
1139 | EXC_NUMFMT_STRING( 66, "\"CHF \"#,##0.00;[RED]\"CHF \"-#,##0.00" ), | |||
1140 | EXC_NUMFMT_ENDTABLE() | |||
1141 | }; | |||
1142 | ||||
1143 | // ITALIAN -------------------------------------------------------------------- | |||
1144 | ||||
1145 | const XclBuiltInFormat spBuiltInFormats_ITALIAN_ITALY[] = | |||
1146 | { | |||
1147 | EXC_NUMFMT_STRING( 15, "DD-MMM-YY" ), | |||
1148 | EXC_NUMFMT_STRING( 16, "DD-MMM" ), | |||
1149 | EXC_NUMFMT_STRING( 17, "MMM-YY" ), | |||
1150 | EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ), | |||
1151 | EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ), | |||
1152 | EXC_NUMFMT_STRING( 20, "h:mm" ), | |||
1153 | EXC_NUMFMT_STRING( 21, "h:mm:ss" ), | |||
1154 | EXC_NUMFMT_STRING( 22, "DD/MM/YYYY h:mm" ), | |||
1155 | EXC_NUMFMT_STRING( 63, UTF8_EURO"\342\202\254" " #,##0;-" UTF8_EURO"\342\202\254" " #,##0" ), | |||
1156 | EXC_NUMFMT_STRING( 64, UTF8_EURO"\342\202\254" " #,##0;[RED]-" UTF8_EURO"\342\202\254" " #,##0" ), | |||
1157 | EXC_NUMFMT_STRING( 65, UTF8_EURO"\342\202\254" " #,##0.00;-" UTF8_EURO"\342\202\254" " #,##0.00" ), | |||
1158 | EXC_NUMFMT_STRING( 66, UTF8_EURO"\342\202\254" " #,##0.00;[RED]-" UTF8_EURO"\342\202\254" " #,##0.00" ), | |||
1159 | EXC_NUMFMT_ENDTABLE() | |||
1160 | }; | |||
1161 | ||||
1162 | const XclBuiltInFormat spBuiltInFormats_ITALIAN_SWISS[] = | |||
1163 | { | |||
1164 | EXC_NUMFMT_STRING( 15, "DD.MMM.YY" ), | |||
1165 | EXC_NUMFMT_STRING( 16, "DD.MMM" ), | |||
1166 | EXC_NUMFMT_STRING( 17, "MMM.YY" ), | |||
1167 | EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ), | |||
1168 | EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ), | |||
1169 | EXC_NUMFMT_STRING( 22, "DD.MM.YYYY hh:mm" ), | |||
1170 | EXC_NUMFMT_STRING( 63, "\"SFr. \"#,##0;\"SFr. \"-#,##0" ), | |||
1171 | EXC_NUMFMT_STRING( 64, "\"SFr. \"#,##0;[RED]\"SFr. \"-#,##0" ), | |||
1172 | EXC_NUMFMT_STRING( 65, "\"SFr. \"#,##0.00;\"SFr. \"-#,##0.00" ), | |||
1173 | EXC_NUMFMT_STRING( 66, "\"SFr. \"#,##0.00;[RED]\"SFr. \"-#,##0.00" ), | |||
1174 | EXC_NUMFMT_ENDTABLE() | |||
1175 | }; | |||
1176 | ||||
1177 | // SWEDISH -------------------------------------------------------------------- | |||
1178 | ||||
1179 | const XclBuiltInFormat spBuiltInFormats_SWEDISH_SWEDEN[] = | |||
1180 | { | |||
1181 | EXC_NUMFMT_STRING( 15, "DD-MMM-YY" ), | |||
1182 | EXC_NUMFMT_STRING( 16, "DD-MMM" ), | |||
1183 | EXC_NUMFMT_STRING( 17, "MMM-YY" ), | |||
1184 | EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ), | |||
1185 | EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ), | |||
1186 | EXC_NUMFMT_STRING( 22, "YYYY-MM-DD hh:mm" ), | |||
1187 | EXC_NUMFMT_STRING( 37, "#,##0 _k_r;-#,##0 _k_r" ), | |||
1188 | EXC_NUMFMT_STRING( 38, "#,##0 _k_r;[RED]-#,##0 _k_r" ), | |||
1189 | EXC_NUMFMT_STRING( 39, "#,##0.00 _k_r;-#,##0.00 _k_r" ), | |||
1190 | EXC_NUMFMT_STRING( 40, "#,##0.00 _k_r;[RED]-#,##0.00 _k_r" ), | |||
1191 | EXC_NUMFMT_STRING( 63, "#,##0 \"kr\";-#,##0 \"kr\"" ), | |||
1192 | EXC_NUMFMT_STRING( 64, "#,##0 \"kr\";[RED]-#,##0 \"kr\"" ), | |||
1193 | EXC_NUMFMT_STRING( 65, "#,##0.00 \"kr\";-#,##0.00 \"kr\"" ), | |||
1194 | EXC_NUMFMT_STRING( 66, "#,##0.00 \"kr\";[RED]-#,##0.00 \"kr\"" ), | |||
1195 | EXC_NUMFMT_ENDTABLE() | |||
1196 | }; | |||
1197 | ||||
1198 | const XclBuiltInFormat spBuiltInFormats_SWEDISH_FINLAND[] = | |||
1199 | { | |||
1200 | EXC_NUMFMT_STRING( 9, "0 %" ), | |||
1201 | EXC_NUMFMT_STRING( 10, "0.00 %" ), | |||
1202 | EXC_NUMFMT_STRING( 15, "DD.MMM.YY" ), | |||
1203 | EXC_NUMFMT_STRING( 16, "DD.MMM" ), | |||
1204 | EXC_NUMFMT_STRING( 17, "MMM.YY" ), | |||
1205 | EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ), | |||
1206 | EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ), | |||
1207 | EXC_NUMFMT_STRING( 22, "D.M.YYYY hh:mm" ), | |||
1208 | EXC_NUMFMT_STRING( 37, "#,##0 _" UTF8_EURO"\342\202\254" ";-#,##0 _" UTF8_EURO"\342\202\254" ), | |||
1209 | EXC_NUMFMT_STRING( 38, "#,##0 _" UTF8_EURO"\342\202\254" ";[RED]-#,##0 _" UTF8_EURO"\342\202\254" ), | |||
1210 | EXC_NUMFMT_STRING( 39, "#,##0.00 _" UTF8_EURO"\342\202\254" ";-#,##0.00 _" UTF8_EURO"\342\202\254" ), | |||
1211 | EXC_NUMFMT_STRING( 40, "#,##0.00 _" UTF8_EURO"\342\202\254" ";[RED]-#,##0.00 _" UTF8_EURO"\342\202\254" ), | |||
1212 | EXC_NUMFMT_STRING( 63, "#,##0 " UTF8_EURO"\342\202\254" ";-#,##0 " UTF8_EURO"\342\202\254" ), | |||
1213 | EXC_NUMFMT_STRING( 64, "#,##0 " UTF8_EURO"\342\202\254" ";[RED]-#,##0 " UTF8_EURO"\342\202\254" ), | |||
1214 | EXC_NUMFMT_STRING( 65, "#,##0.00 " UTF8_EURO"\342\202\254" ";-#,##0.00 " UTF8_EURO"\342\202\254" ), | |||
1215 | EXC_NUMFMT_STRING( 66, "#,##0.00 " UTF8_EURO"\342\202\254" ";[RED]-#,##0.00 " UTF8_EURO"\342\202\254" ), | |||
1216 | EXC_NUMFMT_ENDTABLE() | |||
1217 | }; | |||
1218 | ||||
1219 | // ASIAN ---------------------------------------------------------------------- | |||
1220 | ||||
1221 | /** Base table for Asian locales. */ | |||
1222 | const XclBuiltInFormat spBuiltInFormats_ASIAN[] = | |||
1223 | { | |||
1224 | EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ), | |||
1225 | EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ), | |||
1226 | EXC_NUMFMT_STRING( 20, "h:mm" ), | |||
1227 | EXC_NUMFMT_STRING( 21, "h:mm:ss" ), | |||
1228 | EXC_NUMFMT_STRING( 23, "$#,##0_);($#,##0)" ), | |||
1229 | EXC_NUMFMT_STRING( 24, "$#,##0_);[RED]($#,##0)" ), | |||
1230 | EXC_NUMFMT_STRING( 25, "$#,##0.00_);($#,##0.00)" ), | |||
1231 | EXC_NUMFMT_STRING( 26, "$#,##0.00_);[RED]($#,##0.00)" ), | |||
1232 | EXC_NUMFMT_REUSE( 29, 28 ), | |||
1233 | EXC_NUMFMT_REUSE( 36, 27 ), | |||
1234 | EXC_NUMFMT_REUSE( 50, 27 ), | |||
1235 | EXC_NUMFMT_REUSE( 51, 28 ), | |||
1236 | EXC_NUMFMT_REUSE( 52, 34 ), | |||
1237 | EXC_NUMFMT_REUSE( 53, 35 ), | |||
1238 | EXC_NUMFMT_REUSE( 54, 28 ), | |||
1239 | EXC_NUMFMT_REUSE( 55, 34 ), | |||
1240 | EXC_NUMFMT_REUSE( 56, 35 ), | |||
1241 | EXC_NUMFMT_REUSE( 57, 27 ), | |||
1242 | EXC_NUMFMT_REUSE( 58, 28 ), | |||
1243 | EXC_NUMFMT_ENDTABLE() | |||
1244 | }; | |||
1245 | ||||
1246 | const XclBuiltInFormat spBuiltInFormats_JAPANESE[] = | |||
1247 | { | |||
1248 | EXC_NUMFMT_STRING( 14, "YYYY/M/D" ), | |||
1249 | EXC_NUMFMT_STRING( 15, "D-MMM-YY" ), | |||
1250 | EXC_NUMFMT_STRING( 16, "D-MMM" ), | |||
1251 | EXC_NUMFMT_STRING( 17, "MMM-YY" ), | |||
1252 | EXC_NUMFMT_STRING( 22, "YYYY/M/D h:mm" ), | |||
1253 | EXC_NUMFMT_STRING( 27, "[$-0411]GE.M.D" ), | |||
1254 | EXC_NUMFMT_STRING( 28, "[$-0411]GGGE" UTF8_CJ_YEAR"\345\271\264" "M" UTF8_CJ_MON"\346\234\210" "D" UTF8_CJ_DAY"\346\227\245" ), | |||
1255 | EXC_NUMFMT_STRING( 30, "[$-0411]M/D/YY" ), | |||
1256 | EXC_NUMFMT_STRING( 31, "[$-0411]YYYY" UTF8_CJ_YEAR"\345\271\264" "M" UTF8_CJ_MON"\346\234\210" "D" UTF8_CJ_DAY"\346\227\245" ), | |||
1257 | EXC_NUMFMT_STRING( 32, "[$-0411]h" UTF8_CJ_HOUR"\346\231\202" "mm" UTF8_CJ_MIN"\345\210\206" ), | |||
1258 | EXC_NUMFMT_STRING( 33, "[$-0411]h" UTF8_CJ_HOUR"\346\231\202" "mm" UTF8_CJ_MIN"\345\210\206" "ss" UTF8_CJ_SEC"\347\247\222" ), | |||
1259 | EXC_NUMFMT_STRING( 34, "[$-0411]YYYY" UTF8_CJ_YEAR"\345\271\264" "M" UTF8_CJ_MON"\346\234\210" ), | |||
1260 | EXC_NUMFMT_STRING( 35, "[$-0411]M" UTF8_CJ_MON"\346\234\210" "D" UTF8_CJ_DAY"\346\227\245" ), | |||
1261 | EXC_NUMFMT_STRING( 63, UTF8_YEN_JP"\302\245" "#,##0;-" UTF8_YEN_JP"\302\245" "#,##0" ), | |||
1262 | EXC_NUMFMT_STRING( 64, UTF8_YEN_JP"\302\245" "#,##0;[RED]-" UTF8_YEN_JP"\302\245" "#,##0" ), | |||
1263 | EXC_NUMFMT_STRING( 65, UTF8_YEN_JP"\302\245" "#,##0.00;-" UTF8_YEN_JP"\302\245" "#,##0.00" ), | |||
1264 | EXC_NUMFMT_STRING( 66, UTF8_YEN_JP"\302\245" "#,##0.00;[RED]-" UTF8_YEN_JP"\302\245" "#,##0.00" ), | |||
1265 | EXC_NUMFMT_ENDTABLE() | |||
1266 | }; | |||
1267 | ||||
1268 | const XclBuiltInFormat spBuiltInFormats_KOREAN[] = | |||
1269 | { | |||
1270 | EXC_NUMFMT_STRING( 14, "YYYY-MM-DD" ), | |||
1271 | EXC_NUMFMT_STRING( 15, "DD-MMM-YY" ), | |||
1272 | EXC_NUMFMT_STRING( 16, "DD-MMM" ), | |||
1273 | EXC_NUMFMT_STRING( 17, "MMM-YY" ), | |||
1274 | EXC_NUMFMT_STRING( 22, "YYYY-MM-DD h:mm" ), | |||
1275 | EXC_NUMFMT_STRING( 27, "[$-0412]YYYY" UTF8_CJ_YEAR"\345\271\264" " MM" UTF8_CJ_MON"\346\234\210" " DD" UTF8_CJ_DAY"\346\227\245" ), | |||
1276 | EXC_NUMFMT_STRING( 28, "[$-0412]MM-DD" ), | |||
1277 | EXC_NUMFMT_STRING( 30, "[$-0412]MM-DD-YY" ), | |||
1278 | EXC_NUMFMT_STRING( 31, "[$-0412]YYYY" UTF8_KO_YEAR"\353\205\204" " MM" UTF8_KO_MON"\354\233\224" " DD" UTF8_KO_DAY"\354\235\274" ), | |||
1279 | EXC_NUMFMT_STRING( 32, "[$-0412]h" UTF8_KO_HOUR"\354\213\234" " mm" UTF8_KO_MIN"\353\266\204" ), | |||
1280 | EXC_NUMFMT_STRING( 33, "[$-0412]h" UTF8_KO_HOUR"\354\213\234" " mm" UTF8_KO_MIN"\353\266\204" " ss" UTF8_KO_SEC"\354\264\210" ), | |||
1281 | EXC_NUMFMT_STRING( 34, "[$-0412]YYYY\"/\"MM\"/\"DD" ), | |||
1282 | EXC_NUMFMT_STRING( 35, "[$-0412]YYYY-MM-DD" ), | |||
1283 | EXC_NUMFMT_STRING( 63, UTF8_WON"\357\277\246" "#,##0;-" UTF8_WON"\357\277\246" "#,##0" ), | |||
1284 | EXC_NUMFMT_STRING( 64, UTF8_WON"\357\277\246" "#,##0;[RED]-" UTF8_WON"\357\277\246" "#,##0" ), | |||
1285 | EXC_NUMFMT_STRING( 65, UTF8_WON"\357\277\246" "#,##0.00;-" UTF8_WON"\357\277\246" "#,##0.00" ), | |||
1286 | EXC_NUMFMT_STRING( 66, UTF8_WON"\357\277\246" "#,##0.00;[RED]-" UTF8_WON"\357\277\246" "#,##0.00" ), | |||
1287 | EXC_NUMFMT_ENDTABLE() | |||
1288 | }; | |||
1289 | ||||
1290 | const XclBuiltInFormat spBuiltInFormats_CHINESE_SIMPLIFIED[] = | |||
1291 | { | |||
1292 | EXC_NUMFMT_STRING( 14, "YYYY-M-D" ), | |||
1293 | EXC_NUMFMT_STRING( 15, "D-MMM-YY" ), | |||
1294 | EXC_NUMFMT_STRING( 16, "D-MMM" ), | |||
1295 | EXC_NUMFMT_STRING( 17, "MMM-YY" ), | |||
1296 | EXC_NUMFMT_STRING( 22, "YYYY-M-D h:mm" ), | |||
1297 | EXC_NUMFMT_STRING( 27, "[$-0804]YYYY" UTF8_CJ_YEAR"\345\271\264" "M" UTF8_CJ_MON"\346\234\210" ), | |||
1298 | EXC_NUMFMT_STRING( 28, "[$-0804]M" UTF8_CJ_MON"\346\234\210" "D" UTF8_CJ_DAY"\346\227\245" ), | |||
1299 | EXC_NUMFMT_STRING( 30, "[$-0804]M-D-YY" ), | |||
1300 | EXC_NUMFMT_STRING( 31, "[$-0804]YYYY" UTF8_CJ_YEAR"\345\271\264" "M" UTF8_CJ_MON"\346\234\210" "D" UTF8_CJ_DAY"\346\227\245" ), | |||
1301 | EXC_NUMFMT_STRING( 32, "[$-0804]h" UTF8_CS_HOUR"\346\227\266" "mm" UTF8_CJ_MIN"\345\210\206" ), | |||
1302 | EXC_NUMFMT_STRING( 33, "[$-0804]h" UTF8_CS_HOUR"\346\227\266" "mm" UTF8_CJ_MIN"\345\210\206" "ss" UTF8_CJ_SEC"\347\247\222" ), | |||
1303 | EXC_NUMFMT_STRING( 34, "[$-0804]AM/PMh" UTF8_CS_HOUR"\346\227\266" "mm" UTF8_CJ_MIN"\345\210\206" ), | |||
1304 | EXC_NUMFMT_STRING( 35, "[$-0804]AM/PMh" UTF8_CS_HOUR"\346\227\266" "mm" UTF8_CJ_MIN"\345\210\206" "ss" UTF8_CJ_SEC"\347\247\222" ), | |||
1305 | EXC_NUMFMT_REUSE( 52, 27 ), | |||
1306 | EXC_NUMFMT_REUSE( 53, 28 ), | |||
1307 | EXC_NUMFMT_STRING( 63, UTF8_YEN_CS"\357\277\245" "#,##0;-" UTF8_YEN_CS"\357\277\245" "#,##0" ), | |||
1308 | EXC_NUMFMT_STRING( 64, UTF8_YEN_CS"\357\277\245" "#,##0;[RED]-" UTF8_YEN_CS"\357\277\245" "#,##0" ), | |||
1309 | EXC_NUMFMT_STRING( 65, UTF8_YEN_CS"\357\277\245" "#,##0.00;-" UTF8_YEN_CS"\357\277\245" "#,##0.00" ), | |||
1310 | EXC_NUMFMT_STRING( 66, UTF8_YEN_CS"\357\277\245" "#,##0.00;[RED]-" UTF8_YEN_CS"\357\277\245" "#,##0.00" ), | |||
1311 | EXC_NUMFMT_ENDTABLE() | |||
1312 | }; | |||
1313 | ||||
1314 | const XclBuiltInFormat spBuiltInFormats_CHINESE_TRADITIONAL[] = | |||
1315 | { | |||
1316 | EXC_NUMFMT_STRING( 15, "D-MMM-YY" ), | |||
1317 | EXC_NUMFMT_STRING( 16, "D-MMM" ), | |||
1318 | EXC_NUMFMT_STRING( 17, "MMM-YY" ), | |||
1319 | EXC_NUMFMT_STRING( 18, "hh:mm AM/PM" ), | |||
1320 | EXC_NUMFMT_STRING( 19, "hh:mm:ss AM/PM" ), | |||
1321 | EXC_NUMFMT_OFFSET( 20, NF_TIME_HHMM ), | |||
1322 | EXC_NUMFMT_OFFSET( 21, NF_TIME_HHMMSS ), | |||
1323 | EXC_NUMFMT_STRING( 22, "YYYY/M/D hh:mm" ), | |||
1324 | EXC_NUMFMT_STRING( 23, "US$#,##0_);(US$#,##0)" ), | |||
1325 | EXC_NUMFMT_STRING( 24, "US$#,##0_);[RED](US$#,##0)" ), | |||
1326 | EXC_NUMFMT_STRING( 25, "US$#,##0.00_);(US$#,##0.00)" ), | |||
1327 | EXC_NUMFMT_STRING( 26, "US$#,##0.00_);[RED](US$#,##0.00)" ), | |||
1328 | EXC_NUMFMT_STRING( 27, "[$-0404]E/M/D" ), | |||
1329 | EXC_NUMFMT_STRING( 28, "[$-0404]E" UTF8_CJ_YEAR"\345\271\264" "M" UTF8_CJ_MON"\346\234\210" "D" UTF8_CJ_DAY"\346\227\245" ), | |||
1330 | EXC_NUMFMT_STRING( 30, "[$-0404]M/D/YY" ), | |||
1331 | EXC_NUMFMT_STRING( 31, "[$-0404]YYYY" UTF8_CJ_YEAR"\345\271\264" "M" UTF8_CJ_MON"\346\234\210" "D" UTF8_CJ_DAY"\346\227\245" ), | |||
1332 | EXC_NUMFMT_STRING( 32, "[$-0404]hh" UTF8_CJ_HOUR"\346\231\202" "mm" UTF8_CJ_MIN"\345\210\206" ), | |||
1333 | EXC_NUMFMT_STRING( 33, "[$-0404]hh" UTF8_CJ_HOUR"\346\231\202" "mm" UTF8_CJ_MIN"\345\210\206" "ss" UTF8_CJ_SEC"\347\247\222" ), | |||
1334 | EXC_NUMFMT_STRING( 34, "[$-0404]AM/PMhh" UTF8_CJ_HOUR"\346\231\202" "mm" UTF8_CJ_MIN"\345\210\206" ), | |||
1335 | EXC_NUMFMT_STRING( 35, "[$-0404]AM/PMhh" UTF8_CJ_HOUR"\346\231\202" "mm" UTF8_CJ_MIN"\345\210\206" "ss" UTF8_CJ_SEC"\347\247\222" ), | |||
1336 | EXC_NUMFMT_STRING( 63, "$#,##0;-$#,##0" ), | |||
1337 | EXC_NUMFMT_STRING( 64, "$#,##0;[RED]-$#,##0" ), | |||
1338 | EXC_NUMFMT_STRING( 65, "$#,##0.00;-$#,##0.00" ), | |||
1339 | EXC_NUMFMT_STRING( 66, "$#,##0.00;[RED]-$#,##0.00" ), | |||
1340 | EXC_NUMFMT_ENDTABLE() | |||
1341 | }; | |||
1342 | ||||
1343 | // OTHER ---------------------------------------------------------------------- | |||
1344 | ||||
1345 | const XclBuiltInFormat spBuiltInFormats_HEBREW[] = | |||
1346 | { | |||
1347 | EXC_NUMFMT_STRING( 15, "DD-MMMM-YY" ), | |||
1348 | EXC_NUMFMT_STRING( 16, "DD-MMMM" ), | |||
1349 | EXC_NUMFMT_STRING( 17, "MMMM-YY" ), | |||
1350 | EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ), | |||
1351 | EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ), | |||
1352 | EXC_NUMFMT_STRING( 63, UTF8_SHEQEL"\342\202\252" " #,##0;" UTF8_SHEQEL"\342\202\252" " -#,##0" ), | |||
1353 | EXC_NUMFMT_STRING( 64, UTF8_SHEQEL"\342\202\252" " #,##0;[RED]" UTF8_SHEQEL"\342\202\252" " -#,##0" ), | |||
1354 | EXC_NUMFMT_STRING( 65, UTF8_SHEQEL"\342\202\252" " #,##0.00;" UTF8_SHEQEL"\342\202\252" " -#,##0.00" ), | |||
1355 | EXC_NUMFMT_STRING( 66, UTF8_SHEQEL"\342\202\252" " #,##0.00;[RED]" UTF8_SHEQEL"\342\202\252" " -#,##0.00" ), | |||
1356 | EXC_NUMFMT_ENDTABLE() | |||
1357 | }; | |||
1358 | ||||
1359 | const XclBuiltInFormat spBuiltInFormats_THAI[] = | |||
1360 | { | |||
1361 | EXC_NUMFMT_STRING( 14, "D/M/YYYY" ), | |||
1362 | EXC_NUMFMT_STRING( 15, "D-MMM-YY" ), | |||
1363 | EXC_NUMFMT_STRING( 16, "D-MMM" ), | |||
1364 | EXC_NUMFMT_STRING( 17, "MMM-YY" ), | |||
1365 | EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ), | |||
1366 | EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ), | |||
1367 | EXC_NUMFMT_STRING( 22, "D/M/YYYY h:mm" ), | |||
1368 | EXC_NUMFMT_STRING( 59, "t0" ), | |||
1369 | EXC_NUMFMT_STRING( 60, "t0.00" ), | |||
1370 | EXC_NUMFMT_STRING( 61, "t#,##0" ), | |||
1371 | EXC_NUMFMT_STRING( 62, "t#,##0.00" ), | |||
1372 | EXC_NUMFMT_STRING( 63, "t" UTF8_BAHT"\340\270\277" "#,##0_);t(" UTF8_BAHT"\340\270\277" "#,##0)" ), | |||
1373 | EXC_NUMFMT_STRING( 64, "t" UTF8_BAHT"\340\270\277" "#,##0_);[RED]t(" UTF8_BAHT"\340\270\277" "#,##0)" ), | |||
1374 | EXC_NUMFMT_STRING( 65, "t" UTF8_BAHT"\340\270\277" "#,##0.00_);t(" UTF8_BAHT"\340\270\277" "#,##0.00)" ), | |||
1375 | EXC_NUMFMT_STRING( 66, "t" UTF8_BAHT"\340\270\277" "#,##0.00_);[RED]t(" UTF8_BAHT"\340\270\277" "#,##0.00)" ), | |||
1376 | EXC_NUMFMT_STRING( 67, "t0%" ), | |||
1377 | EXC_NUMFMT_STRING( 68, "t0.00%" ), | |||
1378 | EXC_NUMFMT_STRING( 69, "t# ?/?" ), | |||
1379 | EXC_NUMFMT_STRING( 70, "t# ?\?/?\?" ), | |||
1380 | EXC_NUMFMT_STRING( 71, "tD/M/EE" ), | |||
1381 | EXC_NUMFMT_STRING( 72, "tD-MMM-E" ), | |||
1382 | EXC_NUMFMT_STRING( 73, "tD-MMM" ), | |||
1383 | EXC_NUMFMT_STRING( 74, "tMMM-E" ), | |||
1384 | EXC_NUMFMT_STRING( 75, "th:mm" ), | |||
1385 | EXC_NUMFMT_STRING( 76, "th:mm:ss" ), | |||
1386 | EXC_NUMFMT_STRING( 77, "tD/M/EE h:mm" ), | |||
1387 | EXC_NUMFMT_STRING( 78, "tmm:ss" ), | |||
1388 | EXC_NUMFMT_STRING( 79, "t[h]:mm:ss" ), | |||
1389 | EXC_NUMFMT_STRING( 80, "tmm:ss.0" ), | |||
1390 | EXC_NUMFMT_STRING( 81, "D/M/E" ), | |||
1391 | EXC_NUMFMT_ENDTABLE() | |||
1392 | }; | |||
1393 | ||||
1394 | #undef EXC_NUMFMT_ENDTABLE | |||
1395 | #undef EXC_NUMFMT_REUSE | |||
1396 | #undef EXC_NUMFMT_OFFSET | |||
1397 | #undef EXC_NUMFMT_STRING | |||
1398 | ||||
1399 | /** Specifies a number format table for a specific language. */ | |||
1400 | struct XclBuiltInFormatTable | |||
1401 | { | |||
1402 | LanguageType meLanguage; /// The language of this table. | |||
1403 | LanguageType meParentLang; /// The language of the parent table. | |||
1404 | const XclBuiltInFormat* mpFormats; /// The number format table. | |||
1405 | }; | |||
1406 | ||||
1407 | const XclBuiltInFormatTable spBuiltInFormatTables[] = | |||
1408 | { // language parent language format table | |||
1409 | { LANGUAGE_DONTKNOWLanguageType(0x03FF), LANGUAGE_NONELanguageType(0x00FF), spBuiltInFormats_DONTKNOW }, | |||
1410 | ||||
1411 | { LANGUAGE_ENGLISHLanguageType(0x0009), LANGUAGE_DONTKNOWLanguageType(0x03FF), spBuiltInFormats_ENGLISH }, | |||
1412 | { LANGUAGE_ENGLISH_UKLanguageType(0x0809), LANGUAGE_ENGLISHLanguageType(0x0009), spBuiltInFormats_ENGLISH_UK }, | |||
1413 | { LANGUAGE_ENGLISH_EIRELanguageType(0x1809), LANGUAGE_ENGLISHLanguageType(0x0009), spBuiltInFormats_ENGLISH_EIRE }, | |||
1414 | { LANGUAGE_ENGLISH_USLanguageType(0x0409), LANGUAGE_ENGLISHLanguageType(0x0009), spBuiltInFormats_ENGLISH_US }, | |||
1415 | { LANGUAGE_ENGLISH_CANLanguageType(0x1009), LANGUAGE_ENGLISHLanguageType(0x0009), spBuiltInFormats_ENGLISH_CAN }, | |||
1416 | { LANGUAGE_ENGLISH_AUSLanguageType(0x0C09), LANGUAGE_ENGLISHLanguageType(0x0009), spBuiltInFormats_ENGLISH_AUS }, | |||
1417 | { LANGUAGE_ENGLISH_SAFRICALanguageType(0x1C09), LANGUAGE_ENGLISHLanguageType(0x0009), spBuiltInFormats_ENGLISH_SAFRICA }, | |||
1418 | { LANGUAGE_ENGLISH_NZLanguageType(0x1409), LANGUAGE_ENGLISH_AUSLanguageType(0x0C09), nullptr }, | |||
1419 | ||||
1420 | { PRV_LANGUAGE_FRENCH_PRIM, LANGUAGE_DONTKNOWLanguageType(0x03FF), spBuiltInFormats_FRENCH }, | |||
1421 | { LANGUAGE_FRENCHLanguageType(0x040C), PRV_LANGUAGE_FRENCH_PRIM, spBuiltInFormats_FRENCH_FRANCE }, | |||
1422 | { LANGUAGE_FRENCH_CANADIANLanguageType(0x0C0C), PRV_LANGUAGE_FRENCH_PRIM, spBuiltInFormats_FRENCH_CANADIAN }, | |||
1423 | { LANGUAGE_FRENCH_SWISSLanguageType(0x100C), PRV_LANGUAGE_FRENCH_PRIM, spBuiltInFormats_FRENCH_SWISS }, | |||
1424 | { LANGUAGE_FRENCH_BELGIANLanguageType(0x080C), LANGUAGE_FRENCHLanguageType(0x040C), spBuiltInFormats_FRENCH_BELGIAN }, | |||
1425 | { LANGUAGE_FRENCH_LUXEMBOURGLanguageType(0x140C), LANGUAGE_FRENCHLanguageType(0x040C), nullptr }, | |||
1426 | { LANGUAGE_FRENCH_MONACOLanguageType(0x180C), LANGUAGE_FRENCHLanguageType(0x040C), nullptr }, | |||
1427 | ||||
1428 | { PRV_LANGUAGE_GERMAN_PRIM, LANGUAGE_DONTKNOWLanguageType(0x03FF), spBuiltInFormats_GERMAN }, | |||
1429 | { LANGUAGE_GERMANLanguageType(0x0407), PRV_LANGUAGE_GERMAN_PRIM, spBuiltInFormats_GERMAN_GERMANY }, | |||
1430 | { LANGUAGE_GERMAN_AUSTRIANLanguageType(0x0C07), PRV_LANGUAGE_GERMAN_PRIM, spBuiltInFormats_GERMAN_AUSTRIAN }, | |||
1431 | { LANGUAGE_GERMAN_SWISSLanguageType(0x0807), PRV_LANGUAGE_GERMAN_PRIM, spBuiltInFormats_GERMAN_SWISS }, | |||
1432 | { LANGUAGE_GERMAN_LUXEMBOURGLanguageType(0x1007), PRV_LANGUAGE_GERMAN_PRIM, spBuiltInFormats_GERMAN_LUXEMBOURG }, | |||
1433 | { LANGUAGE_GERMAN_LIECHTENSTEINLanguageType(0x1407), PRV_LANGUAGE_GERMAN_PRIM, spBuiltInFormats_GERMAN_LIECHTENSTEIN }, | |||
1434 | ||||
1435 | { LANGUAGE_ITALIANLanguageType(0x0410), LANGUAGE_DONTKNOWLanguageType(0x03FF), spBuiltInFormats_ITALIAN_ITALY }, | |||
1436 | { LANGUAGE_ITALIAN_SWISSLanguageType(0x0810), LANGUAGE_DONTKNOWLanguageType(0x03FF), spBuiltInFormats_ITALIAN_SWISS }, | |||
1437 | ||||
1438 | { LANGUAGE_SWEDISHLanguageType(0x041D), LANGUAGE_DONTKNOWLanguageType(0x03FF), spBuiltInFormats_SWEDISH_SWEDEN }, | |||
1439 | { LANGUAGE_SWEDISH_FINLANDLanguageType(0x081D), LANGUAGE_DONTKNOWLanguageType(0x03FF), spBuiltInFormats_SWEDISH_FINLAND }, | |||
1440 | ||||
1441 | { PRV_LANGUAGE_ASIAN_PRIM, LANGUAGE_DONTKNOWLanguageType(0x03FF), spBuiltInFormats_ASIAN }, | |||
1442 | { LANGUAGE_JAPANESELanguageType(0x0411), PRV_LANGUAGE_ASIAN_PRIM, spBuiltInFormats_JAPANESE }, | |||
1443 | { LANGUAGE_KOREANLanguageType(0x0412), PRV_LANGUAGE_ASIAN_PRIM, spBuiltInFormats_KOREAN }, | |||
1444 | { LANGUAGE_CHINESE_SIMPLIFIEDLanguageType(0x0804), PRV_LANGUAGE_ASIAN_PRIM, spBuiltInFormats_CHINESE_SIMPLIFIED }, | |||
1445 | { LANGUAGE_CHINESE_TRADITIONALLanguageType(0x0404), PRV_LANGUAGE_ASIAN_PRIM, spBuiltInFormats_CHINESE_TRADITIONAL }, | |||
1446 | ||||
1447 | { LANGUAGE_HEBREWLanguageType(0x040D), LANGUAGE_DONTKNOWLanguageType(0x03FF), spBuiltInFormats_HEBREW }, | |||
1448 | { LANGUAGE_THAILanguageType(0x041E), LANGUAGE_DONTKNOWLanguageType(0x03FF), spBuiltInFormats_THAI } | |||
1449 | }; | |||
1450 | ||||
1451 | } // namespace | |||
1452 | ||||
1453 | XclNumFmtBuffer::XclNumFmtBuffer( const XclRoot& rRoot ) : | |||
1454 | meSysLang( rRoot.GetSysLanguage() ), | |||
1455 | mnStdScNumFmt( rRoot.GetFormatter().GetStandardIndex( ScGlobal::eLnge ) ) | |||
1456 | { | |||
1457 | // *** insert default formats (BIFF5+ only)*** | |||
1458 | ||||
1459 | if( rRoot.GetBiff() >= EXC_BIFF5 ) | |||
1460 | InsertBuiltinFormats(); | |||
1461 | } | |||
1462 | ||||
1463 | void XclNumFmtBuffer::InitializeImport() | |||
1464 | { | |||
1465 | maFmtMap.clear(); | |||
1466 | } | |||
1467 | ||||
1468 | void XclNumFmtBuffer::InsertFormat( sal_uInt16 nXclNumFmt, const OUString& rFormat ) | |||
1469 | { | |||
1470 | XclNumFmt& rNumFmt = maFmtMap[ nXclNumFmt ]; | |||
1471 | rNumFmt.maFormat = rFormat; | |||
1472 | // #i62053# rFormat may be an empty string, meOffset must be initialized | |||
1473 | rNumFmt.meOffset = NF_NUMBER_STANDARD; | |||
1474 | rNumFmt.meLanguage = LANGUAGE_SYSTEMLanguageType(0x0000); | |||
1475 | } | |||
1476 | ||||
1477 | void XclNumFmtBuffer::InsertBuiltinFormats() | |||
1478 | { | |||
1479 | // build a map containing tables for all languages | |||
1480 | typedef ::std::map< LanguageType, const XclBuiltInFormatTable* > XclBuiltInMap; | |||
1481 | XclBuiltInMap aBuiltInMap; | |||
1482 | for(const auto &rTable : spBuiltInFormatTables) | |||
1483 | aBuiltInMap[ rTable.meLanguage ] = &rTable; | |||
1484 | ||||
1485 | // build a list of table pointers for the current language, with all parent tables | |||
1486 | typedef ::std::vector< const XclBuiltInFormatTable* > XclBuiltInVec; | |||
1487 | XclBuiltInVec aBuiltInVec; | |||
1488 | for( XclBuiltInMap::const_iterator aMIt = aBuiltInMap.find( meSysLang ), aMEnd = aBuiltInMap.end(); | |||
1489 | aMIt != aMEnd; aMIt = aBuiltInMap.find( aMIt->second->meParentLang ) ) | |||
1490 | aBuiltInVec.push_back( aMIt->second ); | |||
1491 | // language not supported | |||
1492 | if( aBuiltInVec.empty() ) | |||
1493 | { | |||
1494 | SAL_WARN("sc", "XclNumFmtBuffer::InsertBuiltinFormats - language not supported (#i29949#) 0x" << std::hex << meSysLang )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "sc")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XclNumFmtBuffer::InsertBuiltinFormats - language not supported (#i29949#) 0x" << std::hex << meSysLang) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sc"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "1494" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XclNumFmtBuffer::InsertBuiltinFormats - language not supported (#i29949#) 0x" << std::hex << meSysLang), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XclNumFmtBuffer::InsertBuiltinFormats - language not supported (#i29949#) 0x" << std::hex << meSysLang; ::sal::detail::log( (:: SAL_DETAIL_LOG_LEVEL_WARN), ("sc"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "1494" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "XclNumFmtBuffer::InsertBuiltinFormats - language not supported (#i29949#) 0x" << std::hex << meSysLang) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sc"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "1494" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "XclNumFmtBuffer::InsertBuiltinFormats - language not supported (#i29949#) 0x" << std::hex << meSysLang), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "XclNumFmtBuffer::InsertBuiltinFormats - language not supported (#i29949#) 0x" << std::hex << meSysLang; ::sal::detail::log( (:: SAL_DETAIL_LOG_LEVEL_WARN), ("sc"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "1494" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1495 | XclBuiltInMap::const_iterator aMIt = aBuiltInMap.find( LANGUAGE_DONTKNOWLanguageType(0x03FF) ); | |||
1496 | OSL_ENSURE( aMIt != aBuiltInMap.end(), "XclNumFmtBuffer::InsertBuiltinFormats - default map not found" )do { if (true && (!(aMIt != aBuiltInMap.end()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "1496" ": "), "%s", "XclNumFmtBuffer::InsertBuiltinFormats - default map not found" ); } } while (false); | |||
1497 | if( aMIt != aBuiltInMap.end() ) | |||
1498 | aBuiltInVec.push_back( aMIt->second ); | |||
1499 | } | |||
1500 | ||||
1501 | // insert the default formats in the format map, from root parent to system language | |||
1502 | std::map< sal_uInt16, sal_uInt16 > aReuseMap; | |||
1503 | for( XclBuiltInVec::reverse_iterator aVIt = aBuiltInVec.rbegin(), aVEnd = aBuiltInVec.rend(); aVIt != aVEnd; ++aVIt ) | |||
1504 | { | |||
1505 | // put LANGUAGE_SYSTEM for all entries in default table | |||
1506 | LanguageType eLang = ((*aVIt)->meLanguage == LANGUAGE_DONTKNOWLanguageType(0x03FF)) ? LANGUAGE_SYSTEMLanguageType(0x0000) : meSysLang; | |||
1507 | for( const XclBuiltInFormat* pBuiltIn = (*aVIt)->mpFormats; pBuiltIn && (pBuiltIn->mnXclNumFmt != EXC_FORMAT_NOTFOUND); ++pBuiltIn ) | |||
1508 | { | |||
1509 | XclNumFmt& rNumFmt = maFmtMap[ pBuiltIn->mnXclNumFmt ]; | |||
1510 | ||||
1511 | rNumFmt.meOffset = pBuiltIn->meOffset; | |||
1512 | rNumFmt.meLanguage = eLang; | |||
1513 | ||||
1514 | if( pBuiltIn->mpFormat ) | |||
1515 | rNumFmt.maFormat = OUString( pBuiltIn->mpFormat, strlen(pBuiltIn->mpFormat), RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ); | |||
1516 | else | |||
1517 | rNumFmt.maFormat = EMPTY_OUSTRINGScGlobal::GetEmptyOUString(); | |||
1518 | ||||
1519 | if( pBuiltIn->meOffset == PRV_NF_INDEX_REUSE ) | |||
1520 | aReuseMap[ pBuiltIn->mnXclNumFmt ] = pBuiltIn->mnXclReuseFmt; | |||
1521 | else | |||
1522 | aReuseMap.erase( pBuiltIn->mnXclNumFmt ); | |||
1523 | } | |||
1524 | } | |||
1525 | ||||
1526 | // copy reused number formats | |||
1527 | for( const auto& [rXclNumFmt, rXclReuseFmt] : aReuseMap ) | |||
1528 | maFmtMap[ rXclNumFmt ] = maFmtMap[ rXclReuseFmt ]; | |||
1529 | } | |||
1530 | ||||
1531 | // Cell formatting data (XF) ================================================== | |||
1532 | ||||
1533 | XclCellProt::XclCellProt() : | |||
1534 | mbLocked( true ), // default in Excel and Calc | |||
1535 | mbHidden( false ) | |||
1536 | { | |||
1537 | } | |||
1538 | ||||
1539 | bool operator==( const XclCellProt& rLeft, const XclCellProt& rRight ) | |||
1540 | { | |||
1541 | return (rLeft.mbLocked == rRight.mbLocked) && (rLeft.mbHidden == rRight.mbHidden); | |||
1542 | } | |||
1543 | ||||
1544 | XclCellAlign::XclCellAlign() : | |||
1545 | mnHorAlign( EXC_XF_HOR_GENERAL ), | |||
1546 | mnVerAlign( EXC_XF_VER_BOTTOM ), | |||
1547 | mnOrient( EXC_ORIENT_NONE ), | |||
1548 | mnTextDir( EXC_XF_TEXTDIR_CONTEXT ), | |||
1549 | mnRotation( EXC_ROT_NONE ), | |||
1550 | mnIndent( 0 ), | |||
1551 | mbLineBreak( false ), | |||
1552 | mbShrink( false ) | |||
1553 | { | |||
1554 | } | |||
1555 | ||||
1556 | SvxCellHorJustify XclCellAlign::GetScHorAlign() const | |||
1557 | { | |||
1558 | SvxCellHorJustify eHorJust = SvxCellHorJustify::Standard; | |||
1559 | switch( mnHorAlign ) | |||
1560 | { | |||
1561 | case EXC_XF_HOR_GENERAL: eHorJust = SvxCellHorJustify::Standard; break; | |||
1562 | case EXC_XF_HOR_LEFT: eHorJust = SvxCellHorJustify::Left; break; | |||
1563 | case EXC_XF_HOR_CENTER_AS: | |||
1564 | case EXC_XF_HOR_CENTER: eHorJust = SvxCellHorJustify::Center; break; | |||
1565 | case EXC_XF_HOR_RIGHT: eHorJust = SvxCellHorJustify::Right; break; | |||
1566 | case EXC_XF_HOR_FILL: eHorJust = SvxCellHorJustify::Repeat; break; | |||
1567 | case EXC_XF_HOR_JUSTIFY: | |||
1568 | case EXC_XF_HOR_DISTRIB: eHorJust = SvxCellHorJustify::Block; break; | |||
1569 | default: OSL_FAIL( "XclCellAlign::GetScHorAlign - unknown horizontal alignment" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "1569" ": "), "%s", "XclCellAlign::GetScHorAlign - unknown horizontal alignment" ); } } while (false); | |||
1570 | } | |||
1571 | return eHorJust; | |||
1572 | } | |||
1573 | ||||
1574 | SvxCellJustifyMethod XclCellAlign::GetScHorJustifyMethod() const | |||
1575 | { | |||
1576 | return (mnHorAlign == EXC_XF_HOR_DISTRIB) ? SvxCellJustifyMethod::Distribute : SvxCellJustifyMethod::Auto; | |||
1577 | } | |||
1578 | ||||
1579 | SvxCellVerJustify XclCellAlign::GetScVerAlign() const | |||
1580 | { | |||
1581 | SvxCellVerJustify eVerJust = SvxCellVerJustify::Standard; | |||
1582 | switch( mnVerAlign ) | |||
1583 | { | |||
1584 | case EXC_XF_VER_TOP: eVerJust = SvxCellVerJustify::Top; break; | |||
1585 | case EXC_XF_VER_CENTER: eVerJust = SvxCellVerJustify::Center; break; | |||
1586 | case EXC_XF_VER_BOTTOM: eVerJust = SvxCellVerJustify::Standard; break; | |||
1587 | case EXC_XF_VER_JUSTIFY: | |||
1588 | case EXC_XF_VER_DISTRIB: eVerJust = SvxCellVerJustify::Block; break; | |||
1589 | default: OSL_FAIL( "XclCellAlign::GetScVerAlign - unknown vertical alignment" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "1589" ": "), "%s", "XclCellAlign::GetScVerAlign - unknown vertical alignment" ); } } while (false); | |||
1590 | } | |||
1591 | return eVerJust; | |||
1592 | } | |||
1593 | ||||
1594 | SvxCellJustifyMethod XclCellAlign::GetScVerJustifyMethod() const | |||
1595 | { | |||
1596 | return (mnVerAlign == EXC_XF_VER_DISTRIB) ? SvxCellJustifyMethod::Distribute : SvxCellJustifyMethod::Auto; | |||
1597 | } | |||
1598 | ||||
1599 | SvxFrameDirection XclCellAlign::GetScFrameDir() const | |||
1600 | { | |||
1601 | SvxFrameDirection eFrameDir = SvxFrameDirection::Environment; | |||
1602 | switch( mnTextDir ) | |||
1603 | { | |||
1604 | case EXC_XF_TEXTDIR_CONTEXT: eFrameDir = SvxFrameDirection::Environment; break; | |||
1605 | case EXC_XF_TEXTDIR_LTR: eFrameDir = SvxFrameDirection::Horizontal_LR_TB; break; | |||
1606 | case EXC_XF_TEXTDIR_RTL: eFrameDir = SvxFrameDirection::Horizontal_RL_TB; break; | |||
1607 | default: OSL_FAIL( "XclCellAlign::GetScFrameDir - unknown CTL text direction" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "1607" ": "), "%s", "XclCellAlign::GetScFrameDir - unknown CTL text direction" ); } } while (false); | |||
1608 | } | |||
1609 | return eFrameDir; | |||
1610 | } | |||
1611 | ||||
1612 | void XclCellAlign::SetScHorAlign( SvxCellHorJustify eHorJust ) | |||
1613 | { | |||
1614 | switch( eHorJust ) | |||
1615 | { | |||
1616 | case SvxCellHorJustify::Standard: mnHorAlign = EXC_XF_HOR_GENERAL; break; | |||
1617 | case SvxCellHorJustify::Left: mnHorAlign = EXC_XF_HOR_LEFT; break; | |||
1618 | case SvxCellHorJustify::Center: mnHorAlign = EXC_XF_HOR_CENTER; break; | |||
1619 | case SvxCellHorJustify::Right: mnHorAlign = EXC_XF_HOR_RIGHT; break; | |||
1620 | case SvxCellHorJustify::Block: mnHorAlign = EXC_XF_HOR_JUSTIFY; break; | |||
1621 | case SvxCellHorJustify::Repeat: mnHorAlign = EXC_XF_HOR_FILL; break; | |||
1622 | default: mnHorAlign = EXC_XF_HOR_GENERAL; | |||
1623 | OSL_FAIL( "XclCellAlign::SetScHorAlign - unknown horizontal alignment" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "1623" ": "), "%s", "XclCellAlign::SetScHorAlign - unknown horizontal alignment" ); } } while (false); | |||
1624 | } | |||
1625 | } | |||
1626 | ||||
1627 | void XclCellAlign::SetScVerAlign( SvxCellVerJustify eVerJust ) | |||
1628 | { | |||
1629 | switch( eVerJust ) | |||
1630 | { | |||
1631 | case SvxCellVerJustify::Standard: mnVerAlign = EXC_XF_VER_BOTTOM; break; | |||
1632 | case SvxCellVerJustify::Top: mnVerAlign = EXC_XF_VER_TOP; break; | |||
1633 | case SvxCellVerJustify::Center: mnVerAlign = EXC_XF_VER_CENTER; break; | |||
1634 | case SvxCellVerJustify::Bottom: mnVerAlign = EXC_XF_VER_BOTTOM; break; | |||
1635 | default: mnVerAlign = EXC_XF_VER_BOTTOM; | |||
1636 | OSL_FAIL( "XclCellAlign::SetScVerAlign - unknown vertical alignment" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "1636" ": "), "%s", "XclCellAlign::SetScVerAlign - unknown vertical alignment" ); } } while (false); | |||
1637 | } | |||
1638 | } | |||
1639 | ||||
1640 | void XclCellAlign::SetScFrameDir( SvxFrameDirection eFrameDir ) | |||
1641 | { | |||
1642 | switch( eFrameDir ) | |||
1643 | { | |||
1644 | case SvxFrameDirection::Environment: mnTextDir = EXC_XF_TEXTDIR_CONTEXT; break; | |||
1645 | case SvxFrameDirection::Horizontal_LR_TB: mnTextDir = EXC_XF_TEXTDIR_LTR; break; | |||
1646 | case SvxFrameDirection::Horizontal_RL_TB: mnTextDir = EXC_XF_TEXTDIR_RTL; break; | |||
1647 | default: mnTextDir = EXC_XF_TEXTDIR_CONTEXT; | |||
1648 | OSL_FAIL( "XclCellAlign::SetScFrameDir - unknown CTL text direction" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/filter/excel/xlstyle.cxx" ":" "1648" ": "), "%s", "XclCellAlign::SetScFrameDir - unknown CTL text direction" ); } } while (false); | |||
1649 | } | |||
1650 | } | |||
1651 | ||||
1652 | bool operator==( const XclCellAlign& rLeft, const XclCellAlign& rRight ) | |||
1653 | { | |||
1654 | return | |||
1655 | (rLeft.mnHorAlign == rRight.mnHorAlign) && (rLeft.mnVerAlign == rRight.mnVerAlign) && | |||
1656 | (rLeft.mnTextDir == rRight.mnTextDir) && (rLeft.mnOrient == rRight.mnOrient) && | |||
1657 | (rLeft.mnRotation == rRight.mnRotation) && (rLeft.mnIndent == rRight.mnIndent) && | |||
1658 | (rLeft.mbLineBreak == rRight.mbLineBreak) && (rLeft.mbShrink == rRight.mbShrink); | |||
1659 | } | |||
1660 | ||||
1661 | XclCellBorder::XclCellBorder() : | |||
1662 | mnLeftColor( 0 ), | |||
1663 | mnRightColor( 0 ), | |||
1664 | mnTopColor( 0 ), | |||
1665 | mnBottomColor( 0 ), | |||
1666 | mnDiagColor( 0 ), | |||
1667 | mnLeftLine( EXC_LINE_NONE ), | |||
1668 | mnRightLine( EXC_LINE_NONE ), | |||
1669 | mnTopLine( EXC_LINE_NONE ), | |||
1670 | mnBottomLine( EXC_LINE_NONE ), | |||
1671 | mnDiagLine( EXC_LINE_NONE ), | |||
1672 | mbDiagTLtoBR( false ), | |||
1673 | mbDiagBLtoTR( false ) | |||
1674 | { | |||
1675 | } | |||
1676 | ||||
1677 | bool operator==( const XclCellBorder& rLeft, const XclCellBorder& rRight ) | |||
1678 | { | |||
1679 | return | |||
1680 | (rLeft.mnLeftColor == rRight.mnLeftColor) && (rLeft.mnRightColor == rRight.mnRightColor) && | |||
1681 | (rLeft.mnTopColor == rRight.mnTopColor) && (rLeft.mnBottomColor == rRight.mnBottomColor) && | |||
1682 | (rLeft.mnLeftLine == rRight.mnLeftLine) && (rLeft.mnRightLine == rRight.mnRightLine) && | |||
1683 | (rLeft.mnTopLine == rRight.mnTopLine) && (rLeft.mnBottomLine == rRight.mnBottomLine) && | |||
1684 | (rLeft.mnDiagColor == rRight.mnDiagColor) && (rLeft.mnDiagLine == rRight.mnDiagLine) && | |||
1685 | (rLeft.mbDiagTLtoBR == rRight.mbDiagTLtoBR) && (rLeft.mbDiagBLtoTR == rRight.mbDiagBLtoTR); | |||
1686 | } | |||
1687 | ||||
1688 | XclCellArea::XclCellArea() : | |||
1689 | mnForeColor( EXC_COLOR_WINDOWTEXT ), | |||
1690 | mnBackColor( EXC_COLOR_WINDOWBACK ), | |||
1691 | mnPattern( EXC_PATT_NONE ) | |||
1692 | { | |||
1693 | } | |||
1694 | ||||
1695 | bool XclCellArea::IsTransparent() const | |||
1696 | { | |||
1697 | return (mnPattern == EXC_PATT_NONE) && (mnBackColor == EXC_COLOR_WINDOWBACK); | |||
1698 | } | |||
1699 | ||||
1700 | bool operator==( const XclCellArea& rLeft, const XclCellArea& rRight ) | |||
1701 | { | |||
1702 | return | |||
1703 | (rLeft.mnForeColor == rRight.mnForeColor) && (rLeft.mnBackColor == rRight.mnBackColor) && | |||
1704 | (rLeft.mnPattern == rRight.mnPattern); | |||
1705 | } | |||
1706 | ||||
1707 | XclXFBase::XclXFBase( bool bCellXF ) : | |||
1708 | mnParent( bCellXF ? EXC_XF_DEFAULTSTYLE : EXC_XF_STYLEPARENT ), | |||
1709 | mbCellXF( bCellXF ) | |||
1710 | { | |||
1711 | SetAllUsedFlags( false ); | |||
1712 | } | |||
1713 | ||||
1714 | XclXFBase::~XclXFBase() | |||
1715 | { | |||
1716 | } | |||
1717 | ||||
1718 | void XclXFBase::SetAllUsedFlags( bool bUsed ) | |||
1719 | { | |||
1720 | mbProtUsed = mbFontUsed = mbFmtUsed = mbAlignUsed = mbBorderUsed = mbAreaUsed = bUsed; | |||
1721 | } | |||
1722 | ||||
1723 | bool XclXFBase::HasUsedFlags() const | |||
1724 | { | |||
1725 | return mbProtUsed || mbFontUsed || mbFmtUsed || mbAlignUsed || mbBorderUsed || mbAreaUsed; | |||
1726 | } | |||
1727 | ||||
1728 | bool XclXFBase::Equals( const XclXFBase& rCmp ) const | |||
1729 | { | |||
1730 | return | |||
1731 | (mbCellXF == rCmp.mbCellXF) && (mnParent == rCmp.mnParent) && | |||
1732 | (mbProtUsed == rCmp.mbProtUsed) && (mbFontUsed == rCmp.mbFontUsed) && | |||
1733 | (mbFmtUsed == rCmp.mbFmtUsed) && (mbAlignUsed == rCmp.mbAlignUsed) && | |||
1734 | (mbBorderUsed == rCmp.mbBorderUsed) && (mbAreaUsed == rCmp.mbAreaUsed); | |||
1735 | } | |||
1736 | ||||
1737 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | /* |
3 | * This file is part of the LibreOffice project. |
4 | * |
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/. |
8 | * |
9 | * This file incorporates work covered by the following license notice: |
10 | * |
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 . |
18 | */ |
19 | |
20 | #ifndef INCLUDED_SC_SOURCE_FILTER_INC_FAPIHELPER_HXX |
21 | #define INCLUDED_SC_SOURCE_FILTER_INC_FAPIHELPER_HXX |
22 | |
23 | #include <com/sun/star/uno/Any.hxx> |
24 | #include <com/sun/star/uno/Reference.hxx> |
25 | #include <com/sun/star/uno/Sequence.hxx> |
26 | #include <osl/diagnose.h> |
27 | #include <tools/color.hxx> |
28 | #include "ftools.hxx" |
29 | |
30 | namespace com::sun::star { |
31 | namespace lang { class XMultiServiceFactory; } |
32 | } |
33 | |
34 | namespace com::sun::star::beans { struct NamedValue; } |
35 | namespace com::sun::star::beans { class XPropertySet; } |
36 | namespace com::sun::star::beans { class XMultiPropertySet; } |
37 | |
38 | namespace comphelper { class IDocPasswordVerifier; } |
39 | |
40 | // Static helper functions ==================================================== |
41 | |
42 | class SfxMedium; |
43 | class SfxObjectShell; |
44 | |
45 | /** Static API helper functions. */ |
46 | class ScfApiHelper |
47 | { |
48 | public: |
49 | /** Converts a non-empty vector into a UNO sequence containing elements of the same type. */ |
50 | template< typename Type > |
51 | static css::uno::Sequence< Type > |
52 | VectorToSequence( const ::std::vector< Type >& rVector ); |
53 | |
54 | /** Returns the service name provided via the XServiceName interface, or an empty string on error. */ |
55 | static OUString GetServiceName( const css::uno::Reference< css::uno::XInterface >& xInt ); |
56 | |
57 | /** Returns the multi service factory from a document shell. */ |
58 | static css::uno::Reference< css::lang::XMultiServiceFactory > GetServiceFactory( const SfxObjectShell* pShell ); |
59 | |
60 | /** Creates an instance from the passed service name, using the passed service factory. */ |
61 | static css::uno::Reference< css::uno::XInterface > CreateInstance( |
62 | const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory, |
63 | const OUString& rServiceName ); |
64 | |
65 | /** Creates an instance from the passed service name, using the service factory of the passed object. */ |
66 | static css::uno::Reference< css::uno::XInterface > CreateInstance( |
67 | const SfxObjectShell* pShell, |
68 | const OUString& rServiceName ); |
69 | |
70 | /** Creates an instance from the passed service name, using the process service factory. */ |
71 | static css::uno::Reference< css::uno::XInterface > CreateInstance( const OUString& rServiceName ); |
72 | |
73 | /** Opens a password dialog and returns the encryption data. |
74 | @return The encryption data or an empty sequence on 'Cancel' or any error. */ |
75 | static css::uno::Sequence< css::beans::NamedValue > QueryEncryptionDataForMedium( SfxMedium& rMedium, |
76 | ::comphelper::IDocPasswordVerifier& rVerifier, |
77 | const ::std::vector< OUString >* pDefaultPasswords ); |
78 | }; |
79 | |
80 | template< typename Type > |
81 | css::uno::Sequence< Type > ScfApiHelper::VectorToSequence( const ::std::vector< Type >& rVector ) |
82 | { |
83 | OSL_ENSURE( !rVector.empty(), "ScfApiHelper::VectorToSequence - vector is empty" )do { if (true && (!(!rVector.empty()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/filter/inc/fapihelper.hxx" ":" "83" ": "), "%s", "ScfApiHelper::VectorToSequence - vector is empty" ); } } while (false); |
84 | return css::uno::Sequence<Type>(rVector.data(), static_cast< sal_Int32 >(rVector.size())); |
85 | } |
86 | |
87 | // Property sets ============================================================== |
88 | |
89 | /** A wrapper for a UNO property set. |
90 | |
91 | This class provides functions to silently get and set properties (without |
92 | exceptions, without the need to check validity of the UNO property set). |
93 | |
94 | An instance is constructed with the reference to a UNO property set or any |
95 | other interface (the constructor will query for the XPropertySet interface |
96 | then). The reference to the property set will be kept as long as the |
97 | instance of this class is alive. |
98 | |
99 | The functions GetProperties() and SetProperties() try to handle all passed |
100 | values at once, using the XMultiPropertySet interface. If the |
101 | implementation does not support the XMultiPropertySet interface, all |
102 | properties are handled separately in a loop. |
103 | */ |
104 | class ScfPropertySet |
105 | { |
106 | public: |
107 | explicit ScfPropertySet() {} |
108 | /** Constructs a property set wrapper with the passed UNO property set. */ |
109 | explicit ScfPropertySet( const css::uno::Reference< css::beans::XPropertySet > & xPropSet ) { Set( xPropSet ); } |
110 | /** Constructs a property set wrapper after querying the XPropertySet interface. */ |
111 | template< typename InterfaceType > |
112 | explicit ScfPropertySet( const css::uno::Reference< InterfaceType >& xInterface ) { Set( xInterface ); } |
113 | |
114 | ~ScfPropertySet(); |
115 | //TODO: |
116 | ScfPropertySet(ScfPropertySet const &) = default; |
117 | ScfPropertySet(ScfPropertySet &&) = default; |
118 | ScfPropertySet & operator =(ScfPropertySet const &) = default; |
119 | ScfPropertySet & operator =(ScfPropertySet &&) = default; |
120 | |
121 | /** Sets the passed UNO property set and releases the old UNO property set. */ |
122 | void Set( css::uno::Reference< css::beans::XPropertySet > const & xPropSet ); |
123 | /** Queries the passed interface for an XPropertySet and releases the old UNO property set. */ |
124 | template< typename InterfaceType > |
125 | void Set( css::uno::Reference< InterfaceType > xInterface ) |
126 | { Set( css::uno::Reference< css::beans::XPropertySet >( xInterface, css::uno::UNO_QUERY ) ); } |
127 | |
128 | /** Returns true, if the contained XPropertySet interface is valid. */ |
129 | bool Is() const { return mxPropSet.is(); } |
130 | |
131 | /** Returns the contained XPropertySet interface. */ |
132 | const css::uno::Reference< css::beans::XPropertySet >& GetApiPropertySet() const { return mxPropSet; } |
133 | |
134 | /** Returns the service name provided via the XServiceName interface, or an empty string on error. */ |
135 | OUString GetServiceName() const; |
136 | |
137 | // Get properties --------------------------------------------------------- |
138 | |
139 | /** Returns true, if the property set contains the specified property. */ |
140 | bool HasProperty( const OUString& rPropName ) const; |
141 | |
142 | /** Gets the specified property from the property set. |
143 | @return true, if the Any could be filled with the property value. */ |
144 | bool GetAnyProperty( css::uno::Any& rValue, const OUString& rPropName ) const; |
145 | |
146 | /** Gets the specified property from the property set. |
147 | @return true, if the passed variable could be filled with the property value. */ |
148 | template< typename Type > |
149 | bool GetProperty( Type& rValue, const OUString& rPropName ) const |
150 | { css::uno::Any aAny; return GetAnyProperty( aAny, rPropName ) && (aAny >>= rValue); } |
151 | |
152 | /** Gets the specified Boolean property from the property set. |
153 | @return true = property contains true; false = property contains false or error occurred. */ |
154 | bool GetBoolProperty( const OUString& rPropName ) const; |
155 | |
156 | /** Gets the specified Boolean property from the property set. */ |
157 | OUString GetStringProperty( const OUString& rPropName ) const; |
158 | |
159 | /** Gets the specified color property from the property set. |
160 | @return true, if the passed color variable could be filled with the property value. */ |
161 | bool GetColorProperty( Color& rColor, const OUString& rPropName ) const; |
162 | |
163 | /** Gets the specified properties from the property set. Tries to use the XMultiPropertySet interface. |
164 | @param rPropNames The property names. MUST be ordered alphabetically. |
165 | @param rValues The related property values. */ |
166 | void GetProperties( css::uno::Sequence< css::uno::Any >& rValues, const css::uno::Sequence< OUString >& rPropNames ) const; |
167 | |
168 | // Set properties --------------------------------------------------------- |
169 | |
170 | /** Puts the passed Any into the property set. */ |
171 | void SetAnyProperty( const OUString& rPropName, const css::uno::Any& rValue ); |
172 | |
173 | /** Puts the passed value into the property set. */ |
174 | template< typename Type > |
175 | void SetProperty( const OUString& rPropName, const Type& rValue ) |
176 | { SetAnyProperty( rPropName, css::uno::makeAny( rValue ) ); } |
177 | |
178 | /** Puts the passed Boolean value into the property set. */ |
179 | void SetBoolProperty( const OUString& rPropName, bool bValue ) |
180 | { SetAnyProperty( rPropName, css::uno::Any( bValue ) ); } |
181 | |
182 | /** Puts the passed string into the property set. */ |
183 | void SetStringProperty( const OUString& rPropName, const OUString& rValue ) |
184 | { SetProperty( rPropName, rValue ); } |
185 | |
186 | /** Puts the passed color into the property set. */ |
187 | void SetColorProperty( const OUString& rPropName, const Color& rColor ) |
188 | { SetProperty( rPropName, sal_Int32( rColor ) ); } |
189 | |
190 | /** Puts the passed properties into the property set. Tries to use the XMultiPropertySet interface. |
191 | @param rPropNames The property names. MUST be ordered alphabetically. |
192 | @param rValues The related property values. */ |
193 | void SetProperties( const css::uno::Sequence< OUString > & rPropNames, const css::uno::Sequence< css::uno::Any >& rValues ); |
194 | |
195 | private: |
196 | css::uno::Reference< css::beans::XPropertySet > mxPropSet; /// The mandatory property set interface. |
197 | css::uno::Reference< css::beans::XMultiPropertySet > mxMultiPropSet; /// The optional multi property set interface. |
198 | }; |
199 | |
200 | /** Generic helper class for reading from and writing to property sets. |
201 | |
202 | Usage: |
203 | 1) Call the constructor with a null-terminated array of ASCII strings. |
204 | 2a) Read properties from a property set: Call the ReadFromPropertySet() |
205 | function, then get the properties with the ReadValue() functions or the |
206 | operator>> stream operator. The properties are returned in order of the |
207 | array of property names passed in the constructor. |
208 | 2b) Write properties to a property set: Call InitializeWrite() to start a |
209 | new cycle. Set the values with the WriteValue() functions or the |
210 | operator<< stream operator. The order of the properties is equal to the |
211 | array of property names passed in the constructor. Finally, call the |
212 | WriteToPropertySet() function. |
213 | */ |
214 | class ScfPropSetHelper |
215 | { |
216 | public: |
217 | /** @param ppPropNames A null-terminated array of ASCII property names. */ |
218 | explicit ScfPropSetHelper( const char* const* ppcPropNames ); |
219 | |
220 | // read properties -------------------------------------------------------- |
221 | |
222 | /** Reads all values from the passed property set. */ |
223 | void ReadFromPropertySet( const ScfPropertySet& rPropSet ); |
224 | |
225 | /** Reads the next value from the value sequence. */ |
226 | template< typename Type > |
227 | void ReadValue( Type& rValue ); |
228 | /** Reads an Any from the value sequence. */ |
229 | void ReadValue( css::uno::Any& rAny ); |
230 | /** Reads a color value from the value sequence. */ |
231 | void ReadValue( Color& rColor ); |
232 | /** Reads a C++ boolean value from the value sequence. */ |
233 | void ReadValue( bool& rbValue ); |
234 | |
235 | // write properties ------------------------------------------------------- |
236 | |
237 | /** Must be called before reading or storing property values in the helper. */ |
238 | void InitializeWrite(); |
239 | |
240 | /** Writes the next value to the value sequence. */ |
241 | template< typename Type > |
242 | void WriteValue( const Type& rValue ); |
243 | /** Writes an Any to the value sequence. */ |
244 | void WriteValue( const css::uno::Any& rAny ); |
245 | /** Writes a color value to the value sequence. */ |
246 | void WriteValue( const Color& rColor ) |
247 | { WriteValue( sal_Int32( rColor ) ); } |
248 | /** Writes a C++ boolean value to the value sequence. */ |
249 | void WriteValue( bool rbValue ); |
250 | |
251 | /** Writes all values to the passed property set. */ |
252 | void WriteToPropertySet( ScfPropertySet& rPropSet ) const; |
253 | |
254 | private: |
255 | /** Returns a pointer to the next Any to be written to. */ |
256 | css::uno::Any* GetNextAny(); |
257 | |
258 | private: |
259 | css::uno::Sequence< OUString > maNameSeq; /// Sequence of property names. |
260 | css::uno::Sequence< css::uno::Any > maValueSeq; /// Sequence of property values. |
261 | ScfInt32Vec maNameOrder; /// Maps initial order to alphabetical order. |
262 | size_t mnNextIdx; /// Counter for next Any to be processed. |
263 | }; |
264 | |
265 | template< typename Type > |
266 | void ScfPropSetHelper::ReadValue( Type& rValue ) |
267 | { |
268 | css::uno::Any* pAny = GetNextAny(); |
269 | if (pAny) |
270 | *pAny >>= rValue; |
271 | } |
272 | |
273 | template< typename Type > |
274 | void ScfPropSetHelper::WriteValue( const Type& rValue ) |
275 | { |
276 | css::uno::Any* pAny = GetNextAny(); |
277 | if( pAny ) |
278 | *pAny <<= rValue; |
279 | } |
280 | |
281 | template< typename Type > |
282 | ScfPropSetHelper& operator>>( ScfPropSetHelper& rPropSetHelper, Type& rValue ) |
283 | { |
284 | rPropSetHelper.ReadValue( rValue ); |
285 | return rPropSetHelper; |
286 | } |
287 | |
288 | template< typename Type > |
289 | ScfPropSetHelper& operator<<( ScfPropSetHelper& rPropSetHelper, const Type& rValue ) |
290 | { |
291 | rPropSetHelper.WriteValue( rValue ); |
292 | return rPropSetHelper; |
293 | } |
294 | |
295 | #endif |
296 | |
297 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |