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