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