Update ooo320-m1
[ooovba.git] / sc / source / filter / inc / xlstyle.hxx
blob9613abfc8725f8945983351a7c8493d3ad065cf7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xlstyle.hxx,v $
10 * $Revision: 1.23.32.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_XLSTYLE_HXX
32 #define SC_XLSTYLE_HXX
34 #include <map>
35 #include <com/sun/star/awt/FontSlant.hpp>
36 #include <com/sun/star/awt/FontUnderline.hpp>
37 #include <com/sun/star/awt/FontStrikeout.hpp>
38 #include <tools/color.hxx>
39 #include <vcl/vclenum.hxx>
40 #include <svx/svxenum.hxx>
41 #include <svx/frmdir.hxx>
42 #include <svtools/zforlist.hxx>
43 #include "fapihelper.hxx"
45 class XclRoot;
47 // Constants and Enumerations =================================================
49 // Line styles ----------------------------------------------------------------
51 const sal_uInt8 EXC_LINE_NONE = 0x00;
52 const sal_uInt8 EXC_LINE_THIN = 0x01;
53 const sal_uInt8 EXC_LINE_MEDIUM = 0x02;
54 const sal_uInt8 EXC_LINE_THICK = 0x05;
55 const sal_uInt8 EXC_LINE_DOUBLE = 0x06;
56 const sal_uInt8 EXC_LINE_HAIR = 0x07;
58 // Background patterns --------------------------------------------------------
60 const sal_uInt8 EXC_PATT_NONE = 0x00;
61 const sal_uInt8 EXC_PATT_SOLID = 0x01;
62 const sal_uInt8 EXC_PATT_50_PERC = 0x02;
63 const sal_uInt8 EXC_PATT_75_PERC = 0x03;
64 const sal_uInt8 EXC_PATT_25_PERC = 0x04;
65 const sal_uInt8 EXC_PATT_12_5_PERC = 0x11;
66 const sal_uInt8 EXC_PATT_6_25_PERC = 0x12;
68 // (0x001E, 0x041E) FORMAT ----------------------------------------------------
70 const sal_uInt16 EXC_ID2_FORMAT = 0x001E;
71 const sal_uInt16 EXC_ID4_FORMAT = 0x041E;
73 const sal_uInt16 EXC_FORMAT_OFFSET5 = 164;
74 const sal_uInt16 EXC_FORMAT_OFFSET8 = 164;
75 const sal_uInt16 EXC_FORMAT_NOTFOUND = 0xFFFF;
77 // (0x0031) FONT --------------------------------------------------------------
79 const sal_uInt16 EXC_ID2_FONT = 0x0031;
80 const sal_uInt16 EXC_ID3_FONT = 0x0231;
82 const sal_uInt16 EXC_FONT_APP = 0; /// Application font index.
83 const sal_uInt16 EXC_FONT_NOTFOUND = 0xFFFF;
85 const size_t EXC_FONT_MAXCOUNT4 = 0x00FF;
86 const size_t EXC_FONT_MAXCOUNT5 = 0x00FF;
87 const size_t EXC_FONT_MAXCOUNT8 = 0xFFFF;
89 // families
90 const sal_uInt8 EXC_FONTFAM_DONTKNOW = 0x00;
91 const sal_uInt8 EXC_FONTFAM_ROMAN = 0x01;
92 const sal_uInt8 EXC_FONTFAM_SWISS = 0x02;
93 const sal_uInt8 EXC_FONTFAM_SYSTEM = EXC_FONTFAM_SWISS;
94 const sal_uInt8 EXC_FONTFAM_MODERN = 0x03;
95 const sal_uInt8 EXC_FONTFAM_SCRIPT = 0x04;
96 const sal_uInt8 EXC_FONTFAM_DECORATIVE = 0x05;
98 // charsets
99 const sal_uInt8 EXC_FONTCSET_ANSI_LATIN = 0x00;
101 // attributes
102 const sal_uInt16 EXC_FONTATTR_NONE = 0x0000;
103 const sal_uInt16 EXC_FONTATTR_BOLD = 0x0001;
104 const sal_uInt16 EXC_FONTATTR_ITALIC = 0x0002;
105 const sal_uInt16 EXC_FONTATTR_UNDERLINE = 0x0004;
106 const sal_uInt16 EXC_FONTATTR_STRIKEOUT = 0x0008;
107 const sal_uInt16 EXC_FONTATTR_OUTLINE = 0x0010;
108 const sal_uInt16 EXC_FONTATTR_SHADOW = 0x0020;
110 // weight
111 const sal_uInt16 EXC_FONTWGHT_DONTKNOW = 0;
112 const sal_uInt16 EXC_FONTWGHT_THIN = 100;
113 const sal_uInt16 EXC_FONTWGHT_ULTRALIGHT = 200;
114 const sal_uInt16 EXC_FONTWGHT_LIGHT = 300;
115 const sal_uInt16 EXC_FONTWGHT_SEMILIGHT = 350;
116 const sal_uInt16 EXC_FONTWGHT_NORMAL = 400;
117 const sal_uInt16 EXC_FONTWGHT_MEDIUM = 500;
118 const sal_uInt16 EXC_FONTWGHT_SEMIBOLD = 600;
119 const sal_uInt16 EXC_FONTWGHT_BOLD = 700;
120 const sal_uInt16 EXC_FONTWGHT_ULTRABOLD = 800;
121 const sal_uInt16 EXC_FONTWGHT_BLACK = 900;
123 // underline
124 const sal_uInt8 EXC_FONTUNDERL_NONE = 0x00;
125 const sal_uInt8 EXC_FONTUNDERL_SINGLE = 0x01;
126 const sal_uInt8 EXC_FONTUNDERL_DOUBLE = 0x02;
127 const sal_uInt8 EXC_FONTUNDERL_SINGLE_ACC = 0x21;
128 const sal_uInt8 EXC_FONTUNDERL_DOUBLE_ACC = 0x22;
130 // escapement
131 const sal_uInt16 EXC_FONTESC_NONE = 0x00;
132 const sal_uInt16 EXC_FONTESC_SUPER = 0x01;
133 const sal_uInt16 EXC_FONTESC_SUB = 0x02;
135 // (0x0043, 0x0243, 0x0443, 0x00E0) XF ----------------------------------------
137 const sal_uInt16 EXC_ID2_XF = 0x0043;
138 const sal_uInt16 EXC_ID3_XF = 0x0243;
139 const sal_uInt16 EXC_ID4_XF = 0x0443;
140 const sal_uInt16 EXC_ID5_XF = 0x00E0;
142 const sal_uInt32 EXC_XF_MAXCOUNT = 4050; /// Maximum number of all XF records.
143 const sal_uInt32 EXC_XF_MAXSTYLECOUNT = 1536; /// Arbitrary maximum number of style XFs.
144 const sal_uInt16 EXC_XF_DEFAULTSTYLE = 0; /// Excel index to default style XF.
145 const sal_uInt16 EXC_XF_DEFAULTCELL = 15; /// Excel index to default cell XF.
146 const sal_uInt16 EXC_XF_NOTFOUND = 0xFFFF; /// Special index for "not found" state.
148 const sal_uInt32 EXC_XFID_NOTFOUND = 0xFFFFFFFF;
150 const sal_uInt16 EXC_XF_LOCKED = 0x0001;
151 const sal_uInt16 EXC_XF_HIDDEN = 0x0002;
152 const sal_uInt16 EXC_XF_STYLE = 0x0004;
153 const sal_uInt16 EXC_XF_STYLEPARENT = 0x0FFF; /// Syles don't have a parent.
154 const sal_uInt16 EXC_XF_LINEBREAK = 0x0008; /// Automatic line break.
155 const sal_uInt16 EXC_XF_SHRINK = 0x0010; /// Shrink to fit into cell.
157 const sal_uInt8 EXC_XF_DIFF_VALFMT = 0x01;
158 const sal_uInt8 EXC_XF_DIFF_FONT = 0x02;
159 const sal_uInt8 EXC_XF_DIFF_ALIGN = 0x04;
160 const sal_uInt8 EXC_XF_DIFF_BORDER = 0x08;
161 const sal_uInt8 EXC_XF_DIFF_AREA = 0x10;
162 const sal_uInt8 EXC_XF_DIFF_PROT = 0x20;
164 const sal_uInt8 EXC_XF_HOR_GENERAL = 0x00;
165 const sal_uInt8 EXC_XF_HOR_LEFT = 0x01;
166 const sal_uInt8 EXC_XF_HOR_CENTER = 0x02;
167 const sal_uInt8 EXC_XF_HOR_RIGHT = 0x03;
168 const sal_uInt8 EXC_XF_HOR_FILL = 0x04;
169 const sal_uInt8 EXC_XF_HOR_JUSTIFY = 0x05;
170 const sal_uInt8 EXC_XF_HOR_CENTER_AS = 0x06;
171 const sal_uInt8 EXC_XF_HOR_DISTRIB = 0x07;
173 const sal_uInt8 EXC_XF_VER_TOP = 0x00;
174 const sal_uInt8 EXC_XF_VER_CENTER = 0x01;
175 const sal_uInt8 EXC_XF_VER_BOTTOM = 0x02;
176 const sal_uInt8 EXC_XF_VER_JUSTIFY = 0x03;
177 const sal_uInt8 EXC_XF_VER_DISTRIB = 0x04;
179 const sal_uInt8 EXC_XF_TEXTDIR_CONTEXT = 0x00;
180 const sal_uInt8 EXC_XF_TEXTDIR_LTR = 0x01;
181 const sal_uInt8 EXC_XF_TEXTDIR_RTL = 0x02;
183 const sal_uInt8 EXC_XF2_VALFMT_MASK = 0x3F;
184 const sal_uInt8 EXC_XF2_LOCKED = 0x40;
185 const sal_uInt8 EXC_XF2_HIDDEN = 0x80;
186 const sal_uInt8 EXC_XF2_LEFTLINE = 0x08;
187 const sal_uInt8 EXC_XF2_RIGHTLINE = 0x10;
188 const sal_uInt8 EXC_XF2_TOPLINE = 0x20;
189 const sal_uInt8 EXC_XF2_BOTTOMLINE = 0x40;
190 const sal_uInt8 EXC_XF2_BACKGROUND = 0x80;
192 const sal_uInt16 EXC_XF8_SHRINK = 0x0010; /// Shrink to fit into cell.
193 const sal_uInt16 EXC_XF8_MERGE = 0x0020;
195 const sal_uInt32 EXC_XF_DIAGONAL_TL_TO_BR = 0x40000000; /// Top-left to bottom-right.
196 const sal_uInt32 EXC_XF_DIAGONAL_BL_TO_TR = 0x80000000; /// Bottom-left to top-right.
197 const sal_uInt32 EXC_XF_DIAGONAL_BOTH = 0xC0000000; /// Both.
199 // (0x0045) EFONT -------------------------------------------------------------
201 const sal_uInt16 EXC_ID_EFONT = 0x0045;
203 // (0x0092) PALETTE -----------------------------------------------------------
205 const sal_uInt16 EXC_ID_PALETTE = 0x0092;
207 const sal_uInt16 EXC_COLOR_BIFF2_BLACK = 0;
208 const sal_uInt16 EXC_COLOR_BIFF2_WHITE = 1;
210 const sal_uInt16 EXC_COLOR_USEROFFSET = 8; /// First user defined color.
211 const sal_uInt16 EXC_COLOR_WINDOWTEXT3 = 24; /// System window text color (BIFF3-BIFF4).
212 const sal_uInt16 EXC_COLOR_WINDOWBACK3 = 25; /// System window background color (BIFF3-BIFF4).
213 const sal_uInt16 EXC_COLOR_WINDOWTEXT = 64; /// System window text color (>=BIFF5).
214 const sal_uInt16 EXC_COLOR_WINDOWBACK = 65; /// System window background color (>=BIFF5).
215 const sal_uInt16 EXC_COLOR_BUTTONBACK = 67; /// System button background color (face color).
216 const sal_uInt16 EXC_COLOR_CHWINDOWTEXT = 77; /// System window text color (BIFF8 charts).
217 const sal_uInt16 EXC_COLOR_CHWINDOWBACK = 78; /// System window background color (BIFF8 charts).
218 const sal_uInt16 EXC_COLOR_CHBORDERAUTO = 79; /// Automatic frame border for series (BIFF8 charts).
219 const sal_uInt16 EXC_COLOR_NOTEBACK = 80; /// Note background color.
220 const sal_uInt16 EXC_COLOR_NOTETEXT = 81; /// Note text color.
221 const sal_uInt16 EXC_COLOR_FONTAUTO = 0x7FFF; /// Font auto color (system window text color).
223 // (0x0293) STYLE -------------------------------------------------------------
225 const sal_uInt16 EXC_ID_STYLE = 0x0293;
227 const sal_uInt16 EXC_STYLE_BUILTIN = 0x8000;
228 const sal_uInt16 EXC_STYLE_XFMASK = 0x0FFF;
230 const sal_uInt8 EXC_STYLE_NORMAL = 0x00; /// "Normal" style.
231 const sal_uInt8 EXC_STYLE_ROWLEVEL = 0x01; /// "RowLevel_*" styles.
232 const sal_uInt8 EXC_STYLE_COLLEVEL = 0x02; /// "ColLevel_*" styles.
233 const sal_uInt8 EXC_STYLE_COMMA = 0x03; /// "Comma" style.
234 const sal_uInt8 EXC_STYLE_CURRENCY = 0x04; /// "Currency" style.
235 const sal_uInt8 EXC_STYLE_PERCENT = 0x05; /// "Percent" style.
236 const sal_uInt8 EXC_STYLE_COMMA_0 = 0x06; /// "Comma [0]" style.
237 const sal_uInt8 EXC_STYLE_CURRENCY_0 = 0x07; /// "Currency [0]" style.
238 const sal_uInt8 EXC_STYLE_HYPERLINK = 0x08; /// "Hyperlink" style.
239 const sal_uInt8 EXC_STYLE_FOLLOWED_HYPERLINK= 0x09; /// "Followed_Hyperlink" style.
240 const sal_uInt8 EXC_STYLE_USERDEF = 0xFF; /// No built-in style.
242 const sal_uInt8 EXC_STYLE_LEVELCOUNT = 7; /// Number of outline level styles.
243 const sal_uInt8 EXC_STYLE_NOLEVEL = 0xFF; /// Default value for unused level.
245 // (0x0892) STYLEEXT ----------------------------------------------------------
247 const sal_uInt16 EXC_ID_STYLEEXT = 0x0892;
249 const sal_uInt8 EXC_STYLEEXT_BUILTIN = 0x01;
250 const sal_uInt8 EXC_STYLEEXT_HIDDEN = 0x02;
251 const sal_uInt8 EXC_STYLEEXT_CUSTOM = 0x04;
253 // Structs and classes ========================================================
255 // Color data =================================================================
257 /** Stores all default colors for a specific BIFF version. */
258 class XclDefaultPalette
260 public:
261 explicit XclDefaultPalette( const XclRoot& rRoot );
263 /** Returns the color count in the current palette. */
264 inline sal_uInt32 GetColorCount() const { return mnTableSize - EXC_COLOR_USEROFFSET; }
266 /** Returns the default RGB color data for a (non-zero-based) Excel color or COL_AUTO on error. */
267 ColorData GetDefColorData( sal_uInt16 nXclIndex ) const;
268 /** Returns the default color for a (non-zero-based) Excel color or COL_AUTO on error. */
269 inline Color GetDefColor( sal_uInt16 nXclIndex ) const
270 { return Color( GetDefColorData( nXclIndex ) ); }
272 /** Returns true, if the passed Excel color index is a system color. */
273 inline bool IsSystemColor( sal_uInt16 nXclIndex ) const { return nXclIndex >= mnTableSize; }
275 private:
276 const ColorData* mpnColorTable; /// The table with RGB values.
277 ColorData mnWindowText; /// System window text color.
278 ColorData mnWindowBack; /// System window background color.
279 ColorData mnFaceColor; /// System button background color.
280 ColorData mnNoteText; /// Note text color.
281 ColorData mnNoteBack; /// Note background color.
282 sal_uInt32 mnTableSize; /// The color table size.
285 // Font data ==================================================================
287 class Font;
288 class SvxFont;
290 /** This struct helps reading and writing Excel fonts.
292 It stores all Excel compatible properties of a font. In detail this is the
293 name, family, character set, height, color, boldness, posture, script,
294 underline, strikeout, outline and shadow of the font.
296 struct XclFontData
298 String maName; /// Font name.
299 String maStyle; /// String with styles (bold, italic).
300 Color maColor; /// Font color.
301 sal_uInt16 mnHeight; /// Font height in twips (1/20 of a point).
302 sal_uInt16 mnWeight; /// Boldness: 400=normal, 700=bold.
303 sal_uInt16 mnEscapem; /// Escapement type.
304 sal_uInt8 mnFamily; /// Windows font family.
305 sal_uInt8 mnCharSet; /// Windows character set.
306 sal_uInt8 mnUnderline; /// Underline style.
307 bool mbItalic; /// true = Italic.
308 bool mbStrikeout; /// true = Struck out.
309 bool mbOutline; /// true = Outlined.
310 bool mbShadow; /// true = Shadowed.
312 /** Constructs an empty font data structure. */
313 explicit XclFontData();
314 /** Constructs a font data structure and fills it with the passed font attributes (except color). */
315 explicit XclFontData( const Font& rFont );
316 /** As directly above but also fills in the escapement member. */
317 explicit XclFontData( const SvxFont& rFont );
319 /** Resets all members to default (empty) values. */
320 void Clear();
321 /** Fills all members (except color and escapement) from the passed font. */
322 void FillFromVclFont( const Font& rFont );
323 /** Fills all members (except color) from the passed SVX font. */
324 void FillFromSvxFont( const SvxFont& rFont );
326 // *** conversion of VCL/SVX constants *** ------------------------------------
328 /** Returns the Calc font family. */
329 FontFamily GetScFamily( rtl_TextEncoding eDefTextEnc ) const;
330 /** Returns the font text encoding. */
331 rtl_TextEncoding GetFontEncoding() const;
332 /** Returns the Calc font posture. */
333 FontItalic GetScPosture() const;
334 /** Returns the Calc font weight. */
335 FontWeight GetScWeight() const;
336 /** Returns the Calc font underline style. */
337 FontUnderline GetScUnderline() const;
338 /** Returns the Calc escapement style. */
339 SvxEscapement GetScEscapement() const;
340 /** Returns the Calc strike-out style. */
341 FontStrikeout GetScStrikeout() const;
343 /** Sets the Calc font height (in twips). */
344 void SetScHeight( sal_Int32 nTwips );
345 /** Sets the Calc font family. */
346 void SetScFamily( FontFamily eScFamily );
347 /** Sets the font text encoding. */
348 void SetFontEncoding( rtl_TextEncoding eFontEnc );
349 /** Sets the Calc font posture. */
350 void SetScPosture( FontItalic eScPosture );
351 /** Sets the Calc font weight. */
352 void SetScWeight( FontWeight eScWeight );
353 /** Sets the Calc underline style. */
354 void SetScUnderline( FontUnderline eScUnderl );
355 /** Sets the Calc escapement style. */
356 void SetScEscapement( short nScEscapem );
357 /** Sets the Calc strike-out style. */
358 void SetScStrikeout( FontStrikeout eScStrikeout );
360 // *** conversion of API constants *** ----------------------------------------
362 /** Returns the API font height. */
363 float GetApiHeight() const;
364 /** Returns the API font family. */
365 sal_Int16 GetApiFamily() const;
366 /** Returns the API font text encoding. */
367 sal_Int16 GetApiFontEncoding() const;
368 /** Returns the API font posture. */
369 ::com::sun::star::awt::FontSlant GetApiPosture() const;
370 /** Returns the API font weight. */
371 float GetApiWeight() const;
372 /** Returns the API font underline style. */
373 sal_Int16 GetApiUnderline() const;
374 /** Returns the API escapement style. */
375 sal_Int16 GetApiEscapement() const;
376 /** Returns the API font strike-out style. */
377 sal_Int16 GetApiStrikeout() const;
379 /** Sets the API font height. */
380 void SetApiHeight( float fPoint );
381 /** Sets the API font family. */
382 void SetApiFamily( sal_Int16 nApiFamily );
383 //UNUSED2009-05 /** Sets the API font text encoding. */
384 //UNUSED2009-05 void SetApiFontEncoding( sal_Int16 nApiFontEnc );
385 /** Sets the API font posture. */
386 void SetApiPosture( ::com::sun::star::awt::FontSlant eApiPosture );
387 /** Sets the API font weight. */
388 void SetApiWeight( float fApiWeight );
389 /** Sets the API font underline style. */
390 void SetApiUnderline( sal_Int16 nApiUnderl );
391 /** Sets the API escapement style. */
392 void SetApiEscapement( sal_Int16 nApiEscapem );
393 /** Sets the API font strike-out style. */
394 void SetApiStrikeout( sal_Int16 nApiStrikeout );
397 bool operator==( const XclFontData& rLeft, const XclFontData& rRight );
399 // ----------------------------------------------------------------------------
401 /** Enumerates different types of Which-IDs for font items. */
402 enum XclFontItemType
404 EXC_FONTITEM_CELL, /// Use Calc Which-IDs (ATTR_*).
405 EXC_FONTITEM_EDITENG, /// Use edit engine Which-IDs (EE_CHAR_*).
406 EXC_FONTITEM_HF, /// Use header/footer edit engine Which-IDs (EE_CHAR_*).
407 EXC_FONTITEM_NOTE /// Use note edit engine Which-IDs (EE_CHAR_*), special font handling.
410 /** Enumerates different types for objects with font settings (using different property names). */
411 enum XclFontPropSetType
413 EXC_FONTPROPSET_CHART, /// All text objects in charts.
414 EXC_FONTPROPSET_CONTROL /// Text formatting in form controls.
417 // ----------------------------------------------------------------------------
419 /** Helper class for usage of property sets. */
420 class XclFontPropSetHelper
422 public:
423 explicit XclFontPropSetHelper();
425 /** Reads all font properties from the passed property set. */
426 void ReadFontProperties( XclFontData& rFontData,
427 const ScfPropertySet& rPropSet, XclFontPropSetType eType,
428 sal_Int16 nScript = -1 );
430 /** Writes all font properties to the passed property set, uses passed color as font color. */
431 void WriteFontProperties(
432 ScfPropertySet& rPropSet, XclFontPropSetType eType,
433 const XclFontData& rFontData,
434 bool bHasWstrn, bool bHasAsian, bool bHasCmplx,
435 const Color* pFontColor = 0 );
437 private:
438 /** Returns a chart property set helper according to the passed script type. */
439 ScfPropSetHelper& GetChartHelper( sal_Int16 nScript );
441 private:
442 ScfPropSetHelper maHlpChCommon; /// Chart properties for all scripts.
443 ScfPropSetHelper maHlpChWstrn; /// Chart properties for Western script.
444 ScfPropSetHelper maHlpChAsian; /// Chart properties for Asian script.
445 ScfPropSetHelper maHlpChCmplx; /// Chart properties for Complex script.
446 ScfPropSetHelper maHlpChWstrnNoName; /// Chart properties for Western script, no font name.
447 ScfPropSetHelper maHlpChAsianNoName; /// Chart properties for Asian script, no font name.
448 ScfPropSetHelper maHlpChCmplxNoName; /// Chart properties for Complex script, no font name.
449 ScfPropSetHelper maHlpChEscapement; /// Chart properties for font escapement.
450 ScfPropSetHelper maHlpControl; /// Properties for form controls.
453 // Number formats =============================================================
455 struct XclNumFmt
457 String maFormat; /// Format string, may be empty (meOffset used then).
458 NfIndexTableOffset meOffset; /// SvNumberFormatter format index, if maFormat is empty.
459 LanguageType meLanguage; /// Language type to be set with the number format.
462 // ----------------------------------------------------------------------------
464 class XclNumFmtBuffer
466 public:
467 explicit XclNumFmtBuffer( const XclRoot& rRoot );
469 /** Returns the core index of the current standard number format. */
470 inline ULONG GetStdScNumFmt() const { return mnStdScNumFmt; }
472 protected:
473 typedef ::std::map< sal_uInt16, XclNumFmt > XclNumFmtMap;
475 /** Clears all buffered data, used to set up for a new sheet. */
476 void InitializeImport();
478 /** Returns the current number format map. */
479 inline const XclNumFmtMap& GetFormatMap() const { return maFmtMap; }
481 //UNUSED2008-05 /** Returns the number format with the specified Excel format index. */
482 //UNUSED2008-05 const XclNumFmt* GetFormat( sal_uInt16 nXclNumFmt ) const;
484 /** Inserts a new number format for the specified Excel format index. */
485 void InsertFormat( sal_uInt16 nXclNumFmt, const String& rFormat );
487 private:
488 /** Inserts built-in number formats for the current system language. */
489 void InsertBuiltinFormats();
491 XclNumFmtMap maFmtMap; /// Map containing all default and user-defined formats.
492 LanguageType meSysLang; /// Current system language.
493 ULONG mnStdScNumFmt; /// Calc format key for standard number format.
496 // Cell formatting data (XF) ==================================================
498 /** Contains all cell protection attributes. */
499 struct XclCellProt
501 bool mbLocked; /// true = Locked against editing.
502 bool mbHidden; /// true = Formula is hidden.
504 explicit XclCellProt();
507 bool operator==( const XclCellProt& rLeft, const XclCellProt& rRight );
509 // ----------------------------------------------------------------------------
511 /** Contains all cell alignment attributes. */
512 struct XclCellAlign
514 sal_uInt8 mnHorAlign; /// Horizontal alignment.
515 sal_uInt8 mnVerAlign; /// Vertical alignment.
516 sal_uInt8 mnOrient; /// Text orientation.
517 sal_uInt8 mnTextDir; /// CTL text direction.
518 sal_uInt8 mnRotation; /// Text rotation angle.
519 sal_uInt8 mnIndent; /// Indentation.
520 bool mbLineBreak; /// true = Multi-line text.
521 bool mbShrink; /// true = Shrink to fit cell size.
523 explicit XclCellAlign();
525 /** Returns the Calc horizontal alignment. */
526 SvxCellHorJustify GetScHorAlign() const;
527 /** Returns the Calc vertical alignment. */
528 SvxCellVerJustify GetScVerAlign() const;
529 /** Returns the Calc frame direction. */
530 SvxFrameDirection GetScFrameDir() const;
532 /** Sets the Calc horizontal alignment. */
533 void SetScHorAlign( SvxCellHorJustify eHorJust );
534 /** Sets the Calc vertical alignment. */
535 void SetScVerAlign( SvxCellVerJustify eVerJust );
536 /** Sets the Calc frame direction. */
537 void SetScFrameDir( SvxFrameDirection eFrameDir );
540 bool operator==( const XclCellAlign& rLeft, const XclCellAlign& rRight );
542 // ----------------------------------------------------------------------------
544 /** Contains color and line style for each cell border line. */
545 struct XclCellBorder
547 sal_uInt16 mnLeftColor; /// Palette index for left line.
548 sal_uInt16 mnRightColor; /// Palette index for right line.
549 sal_uInt16 mnTopColor; /// Palette index for top line.
550 sal_uInt16 mnBottomColor; /// Palette index for bottom line.
551 sal_uInt16 mnDiagColor; /// Palette index for diagonal line(s).
552 sal_uInt8 mnLeftLine; /// Style of left line.
553 sal_uInt8 mnRightLine; /// Style of right line.
554 sal_uInt8 mnTopLine; /// Style of top line.
555 sal_uInt8 mnBottomLine; /// Style of bottom line.
556 sal_uInt8 mnDiagLine; /// Style of diagonal line(s).
557 bool mbDiagTLtoBR; /// true = Top-left to bottom-right on.
558 bool mbDiagBLtoTR; /// true = Bottom-left to top-right on.
560 explicit XclCellBorder();
563 bool operator==( const XclCellBorder& rLeft, const XclCellBorder& rRight );
565 // ----------------------------------------------------------------------------
567 /** Contains background colors and pattern for a cell. */
568 struct XclCellArea
570 sal_uInt16 mnForeColor; /// Palette index to foreground color.
571 sal_uInt16 mnBackColor; /// Palette index to background color.
572 sal_uInt8 mnPattern; /// Fill pattern.
574 explicit XclCellArea();
576 /** Returns true, if the area represents transparent state. */
577 bool IsTransparent() const;
580 bool operator==( const XclCellArea& rLeft, const XclCellArea& rRight );
582 // ----------------------------------------------------------------------------
584 /** Contains base members for XF record import/export.
585 @descr In detail this class stores the XF type (cell/style), the index to the
586 parent style XF and all "attribute used" flags, which reflect the state of
587 specific attribute groups (true = user has changed the attributes). */
588 class XclXFBase
590 public:
591 explicit XclXFBase( bool bCellXF );
592 virtual ~XclXFBase();
594 /** Sets all "attribute used" flags to the passed state. */
595 void SetAllUsedFlags( bool bUsed );
596 /** Returns true, if any "attribute used" flags are ste in this XF. */
597 bool HasUsedFlags() const;
599 /** Returns true, if this is a hard cell format. */
600 inline bool IsCellXF() const { return mbCellXF; }
601 /** Returns true, if this is a cell style. */
602 inline bool IsStyleXF() const { return !IsCellXF(); }
604 protected:
605 /** Returns true, if this object is equal to the passed. */
606 bool Equals( const XclXFBase& rCmp ) const;
608 protected:
609 sal_uInt16 mnParent; /// Index to parent style XF.
610 bool mbCellXF; /// true = cell XF, false = style XF.
611 bool mbProtUsed; /// true = cell protection used.
612 bool mbFontUsed; /// true = font index used.
613 bool mbFmtUsed; /// true = number format used.
614 bool mbAlignUsed; /// true = alignment used.
615 bool mbBorderUsed; /// true = border data used.
616 bool mbAreaUsed; /// true = area data used.
619 // ============================================================================
621 #endif