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