1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_STYLESBUFFER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_STYLESBUFFER_HXX
24 #include <com/sun/star/awt/FontDescriptor.hpp>
25 #include <com/sun/star/table/CellHoriJustify.hpp>
26 #include <com/sun/star/table/CellOrientation.hpp>
27 #include <com/sun/star/table/BorderLine2.hpp>
28 #include <com/sun/star/util/CellProtection.hpp>
29 #include <oox/drawingml/color.hxx>
30 #include <oox/helper/graphichelper.hxx>
31 #include <oox/helper/refmap.hxx>
32 #include <oox/helper/refvector.hxx>
33 #include "numberformatsbuffer.hxx"
34 #include <editeng/svxenum.hxx>
35 #include <editeng/frmdir.hxx>
36 #include <attarray.hxx>
39 namespace oox
{ class SequenceInputStream
; }
41 namespace oox
{ class PropertySet
;
43 class AttributeList
; }
48 const sal_Int32 OOX_COLOR_WINDOWTEXT3
= 24; /// System window text color (BIFF3-BIFF4).
49 const sal_Int32 OOX_COLOR_WINDOWBACK3
= 25; /// System window background color (BIFF3-BIFF4).
50 const sal_Int32 OOX_COLOR_WINDOWTEXT
= 64; /// System window text color (BIFF5+).
51 const sal_Int32 OOX_COLOR_WINDOWBACK
= 65; /// System window background color (BIFF5+).
52 const sal_Int32 OOX_COLOR_BUTTONBACK
= 67; /// System button background color (face color).
53 const sal_Int32 OOX_COLOR_CHWINDOWTEXT
= 77; /// System window text color (BIFF8 charts).
54 const sal_Int32 OOX_COLOR_CHWINDOWBACK
= 78; /// System window background color (BIFF8 charts).
55 const sal_Int32 OOX_COLOR_CHBORDERAUTO
= 79; /// Automatic frame border (BIFF8 charts).
56 const sal_Int32 OOX_COLOR_NOTEBACK
= 80; /// Note background color.
57 const sal_Int32 OOX_COLOR_NOTETEXT
= 81; /// Note text color.
58 const sal_Int32 OOX_COLOR_FONTAUTO
= 0x7FFF; /// Font auto color (system window text color).
60 const sal_Int16 API_LINE_NONE
= 0;
61 const sal_Int16 API_LINE_HAIR
= 1;
62 const sal_Int16 API_LINE_THIN
= 15;
63 const sal_Int16 API_LINE_MEDIUM
= 35;
64 const sal_Int16 API_LINE_THICK
= 50;
66 const sal_Int16 API_ESCAPE_NONE
= 0; /// No escapement.
67 const sal_Int16 API_ESCAPE_SUPERSCRIPT
= 101; /// Superscript: raise characters automatically (magic value 101).
68 const sal_Int16 API_ESCAPE_SUBSCRIPT
= -101; /// Subscript: lower characters automatically (magic value -101).
70 const sal_Int8 API_ESCAPEHEIGHT_NONE
= 100; /// Relative character height if not escaped.
71 const sal_Int8 API_ESCAPEHEIGHT_DEFAULT
= 58; /// Relative character height if escaped.
73 /** Special implementation of the GraphicHelper for Excel palette and scheme
76 class ExcelGraphicHelper
: public GraphicHelper
, public WorkbookHelper
79 explicit ExcelGraphicHelper( const WorkbookHelper
& rHelper
);
81 /** Derived classes may implement to resolve a scheme color from the passed XML token identifier. */
82 virtual ::Color
getSchemeColor( sal_Int32 nToken
) const override
;
83 /** Derived classes may implement to resolve a palette index to an RGB color. */
84 virtual ::Color
getPaletteColor( sal_Int32 nPaletteIdx
) const override
;
87 class Color
: public ::oox::drawingml::Color
90 /** Sets the color to automatic. */
92 /** Sets the color to the passed RGB value. */
93 void setRgb( ::Color nRgbValue
, double fTint
= 0.0 );
94 /** Sets the color to the passed theme index. */
95 void setTheme( sal_Int32 nThemeIdx
, double fTint
= 0.0 );
96 /** Sets the color to the passed palette index. */
97 void setIndexed( sal_Int32 nPaletteIdx
, double fTint
= 0.0 );
99 /** Imports the color from the passed attribute list. */
100 void importColor( const AttributeList
& rAttribs
);
102 /** Imports a 64-bit color from the passed binary stream. */
103 void importColor( SequenceInputStream
& rStrm
);
104 /** Imports a 32-bit palette color identifier from the passed BIFF12 stream. */
105 void importColorId( SequenceInputStream
& rStrm
);
107 /** Returns true, if the color is set to automatic. */
108 bool isAuto() const { return isPlaceHolder(); }
111 SequenceInputStream
& operator>>( SequenceInputStream
& rStrm
, Color
& orColor
);
113 /** Stores all colors of the color palette. */
114 class ColorPalette
: public WorkbookHelper
117 /** Constructs the color palette with predefined color values. */
118 explicit ColorPalette( const WorkbookHelper
& rHelper
);
120 /** Appends a new color from the passed attributes. */
121 void importPaletteColor( const AttributeList
& rAttribs
);
122 /** Appends a new color from the passed RGBCOLOR record. */
123 void importPaletteColor( SequenceInputStream
& rStrm
);
125 /** Returns the RGB value of the color with the passed index. */
126 ::Color
getColor( sal_Int32 nPaletteIdx
) const;
129 /** Appends the passed color. */
130 void appendColor( ::Color nRGBValue
);
133 ::std::vector
< ::Color
> maColors
; /// List of RGB values.
134 size_t mnAppendIndex
; /// Index to append a new color.
137 /** Contains all XML font attributes, e.g. from a font or rPr element. */
140 OUString maName
; /// Font name.
141 Color maColor
; /// Font color.
142 sal_Int32 mnScheme
; /// Major/minor scheme font.
143 sal_Int32 mnFamily
; /// Font family.
144 sal_Int32 mnCharSet
; /// Windows font character set.
145 double mfHeight
; /// Font height in points.
146 sal_Int32 mnUnderline
; /// Underline style.
147 sal_Int32 mnEscapement
; /// Escapement style.
148 bool mbBold
; /// True = bold characters.
149 bool mbItalic
; /// True = italic characters.
150 bool mbStrikeout
; /// True = Strike out characters.
151 bool mbOutline
; /// True = outlined characters.
152 bool mbShadow
; /// True = shadowed chgaracters.
154 explicit FontModel();
156 void setBiff12Scheme( sal_uInt8 nScheme
);
157 void setBiffHeight( sal_uInt16 nHeight
);
158 void setBiffWeight( sal_uInt16 nWeight
);
159 void setBiffUnderline( sal_uInt16 nUnderline
);
160 void setBiffEscapement( sal_uInt16 nEscapement
);
163 /** Contains used flags for all API font attributes. */
164 struct ApiFontUsedFlags
166 bool mbNameUsed
; /// True = font name/family/char set are used.
167 bool mbColorUsed
; /// True = font color is used.
168 bool mbSchemeUsed
; /// True = font scheme is used.
169 bool mbHeightUsed
; /// True = font height is used.
170 bool mbUnderlineUsed
; /// True = underline style is used.
171 bool mbEscapementUsed
; /// True = escapement style is used.
172 bool mbWeightUsed
; /// True = font weight (boldness) is used.
173 bool mbPostureUsed
; /// True = font posture (italic) is used.
174 bool mbStrikeoutUsed
; /// True = strike out style is used.
175 bool mbOutlineUsed
; /// True = outline style is used.
176 bool mbShadowUsed
; /// True = shadow style is used.
178 explicit ApiFontUsedFlags( bool bAllUsed
);
181 /** Contains API font name, family, and charset for a script type. */
182 struct ApiScriptFontName
184 OUString maName
; /// Font name.
185 sal_Int16 mnFamily
; /// Font family.
186 sal_Int16 mnTextEnc
; /// Font text encoding.
188 explicit ApiScriptFontName();
191 /** Contains all API font attributes. */
194 ApiScriptFontName maLatinFont
; /// Font name for latin scripts.
195 ApiScriptFontName maAsianFont
; /// Font name for east-asian scripts.
196 ApiScriptFontName maCmplxFont
; /// Font name for complex scripts.
197 css::awt::FontDescriptor maDesc
; /// Font descriptor (height in twips, weight in %).
198 ::Color mnColor
; /// Font color.
199 sal_Int16 mnEscapement
; /// Escapement style.
200 sal_Int8 mnEscapeHeight
; /// Escapement font height.
201 bool mbOutline
; /// True = outlined characters.
202 bool mbShadow
; /// True = shadowed chgaracters.
204 explicit ApiFontData();
207 class Font
: public WorkbookHelper
210 explicit Font( const WorkbookHelper
& rHelper
, bool bDxf
);
211 explicit Font( const WorkbookHelper
& rHelper
, const FontModel
& rModel
);
213 /** Sets font formatting attributes for the passed element. */
214 void importAttribs( sal_Int32 nElement
, const AttributeList
& rAttribs
);
216 /** Imports the FONT record from the passed stream. */
217 void importFont( SequenceInputStream
& rStrm
);
218 /** Imports the font name from a DXF record. */
219 void importDxfName( SequenceInputStream
& rStrm
);
220 /** Imports the font color from a DXF record. */
221 void importDxfColor( SequenceInputStream
& rStrm
);
222 /** Imports the font scheme from a DXF record. */
223 void importDxfScheme( SequenceInputStream
& rStrm
);
224 /** Imports the font height from a DXF record. */
225 void importDxfHeight( SequenceInputStream
& rStrm
);
226 /** Imports the font weight from a DXF record. */
227 void importDxfWeight( SequenceInputStream
& rStrm
);
228 /** Imports the font underline style from a DXF record. */
229 void importDxfUnderline( SequenceInputStream
& rStrm
);
230 /** Imports the font escapement style from a DXF record. */
231 void importDxfEscapement( SequenceInputStream
& rStrm
);
232 /** Imports a font style flag from a DXF record. */
233 void importDxfFlag( sal_Int32 nElement
, SequenceInputStream
& rStrm
);
235 /** Returns the font model structure. This function can be called before
236 finalizeImport() has been called. */
237 const FontModel
& getModel() const { return maModel
; }
239 /** Final processing after import of all style settings. */
240 void finalizeImport();
242 /** Returns an API font descriptor with own font information. */
243 const css::awt::FontDescriptor
& getFontDescriptor() const { return maApiData
.maDesc
;}
244 /** Returns true, if the font requires rich text formatting in Calc.
245 @descr Example: Font escapement is a cell attribute in Excel, but Calc
246 needs a rich text cell for this attribute. */
247 bool needsRichTextFormat() const;
249 void fillToItemSet( SfxItemSet
& rItemSet
, bool bEditEngineText
, bool bSkipPoolDefs
= false ) const;
250 /** Writes all font attributes to the passed property map. */
251 void writeToPropertyMap(
252 PropertyMap
& rPropMap
) const;
253 /** Writes all font attributes to the passed property set. */
254 void writeToPropertySet(
255 PropertySet
& rPropSet
) const;
259 ApiFontData maApiData
;
260 ApiFontUsedFlags maUsedFlags
;
264 typedef std::shared_ptr
< Font
> FontRef
;
266 /** Contains all XML cell alignment attributes, e.g. from an alignment element. */
267 struct AlignmentModel
269 sal_Int32 mnHorAlign
; /// Horizontal alignment.
270 sal_Int32 mnVerAlign
; /// Vertical alignment.
271 sal_Int32 mnTextDir
; /// CTL text direction.
272 sal_Int32 mnRotation
; /// Text rotation angle.
273 sal_Int32 mnIndent
; /// Indentation.
274 bool mbWrapText
; /// True = multi-line text.
275 bool mbShrink
; /// True = shrink to fit cell size.
276 bool mbJustLastLine
; /// True = justify last line in block text.
278 explicit AlignmentModel();
280 /** Sets horizontal alignment from the passed BIFF data. */
281 void setBiffHorAlign( sal_uInt8 nHorAlign
);
282 /** Sets vertical alignment from the passed BIFF data. */
283 void setBiffVerAlign( sal_uInt8 nVerAlign
);
286 /** Contains all API cell alignment attributes. */
287 struct ApiAlignmentData
289 css::table::CellHoriJustify meHorJustify
; /// Horizontal alignment.
290 sal_Int32 mnHorJustifyMethod
;
291 sal_Int32 mnVerJustify
; /// Vertical alignment.
292 sal_Int32 mnVerJustifyMethod
;
293 css::table::CellOrientation meOrientation
; /// Normal or stacked text.
294 sal_Int32 mnRotation
; /// Text rotation angle.
295 sal_Int16 mnWritingMode
; /// CTL text direction.
296 sal_Int16 mnIndent
; /// Indentation.
297 bool mbWrapText
; /// True = multi-line text.
298 bool mbShrink
; /// True = shrink to fit cell size.
300 explicit ApiAlignmentData();
303 bool operator==( const ApiAlignmentData
& rLeft
, const ApiAlignmentData
& rRight
);
305 class Alignment
: public WorkbookHelper
308 explicit Alignment( const WorkbookHelper
& rHelper
);
310 /** Sets all attributes from the alignment element. */
311 void importAlignment( const AttributeList
& rAttribs
);
313 /** Sets the alignment attributes from the passed BIFF12 XF record data. */
314 void setBiff12Data( sal_uInt32 nFlags
);
316 /** Final processing after import of all style settings. */
317 void finalizeImport();
319 /** Returns the alignment model structure. */
320 const AlignmentModel
& getModel() const { return maModel
; }
321 /** Returns the converted API alignment data struct. */
322 const ApiAlignmentData
& getApiData() const { return maApiData
; }
324 void fillToItemSet( SfxItemSet
& rItemSet
, bool bSkipPoolDefs
= false ) const;
327 ::SvxCellHorJustify
GetScHorAlign() const;
328 ::SvxCellVerJustify
GetScVerAlign() const;
329 ::SvxFrameDirection
GetScFrameDir() const;
330 AlignmentModel maModel
; /// Alignment model data.
331 ApiAlignmentData maApiData
; /// Alignment data converted to API constants.
334 /** Contains all XML cell protection attributes, e.g. from a protection element. */
335 struct ProtectionModel
337 bool mbLocked
; /// True = locked against editing.
338 bool mbHidden
; /// True = formula is hidden.
340 explicit ProtectionModel();
343 /** Contains all API cell protection attributes. */
344 struct ApiProtectionData
346 typedef css::util::CellProtection ApiCellProtection
;
348 ApiCellProtection maCellProt
;
350 explicit ApiProtectionData();
353 bool operator==( const ApiProtectionData
& rLeft
, const ApiProtectionData
& rRight
);
355 class Protection
: public WorkbookHelper
358 explicit Protection( const WorkbookHelper
& rHelper
);
360 /** Sets all attributes from the protection element. */
361 void importProtection( const AttributeList
& rAttribs
);
363 /** Sets the protection attributes from the passed BIFF12 XF record data. */
364 void setBiff12Data( sal_uInt32 nFlags
);
366 /** Final processing after import of all style settings. */
367 void finalizeImport();
369 /** Returns the converted API protection data struct. */
370 const ApiProtectionData
& getApiData() const { return maApiData
; }
372 void fillToItemSet( SfxItemSet
& rItemSet
, bool bSkipPoolDefs
= false ) const;
374 ProtectionModel maModel
; /// Protection model data.
375 ApiProtectionData maApiData
; /// Protection data converted to API constants.
378 /** Contains XML attributes of a single border line. */
379 struct BorderLineModel
381 Color maColor
; /// Borderline color.
382 sal_Int32 mnStyle
; /// Border line style.
383 bool mbUsed
; /// True = line format used.
385 explicit BorderLineModel( bool bDxf
);
387 /** Sets the passed BIFF line style. */
388 void setBiffStyle( sal_Int32 nLineStyle
);
391 /** Contains XML attributes of a complete cell border. */
394 BorderLineModel maLeft
; /// Left line format.
395 BorderLineModel maRight
; /// Right line format.
396 BorderLineModel maTop
; /// Top line format.
397 BorderLineModel maBottom
; /// Bottom line format.
398 BorderLineModel maDiagonal
; /// Diagonal line format.
399 bool mbDiagTLtoBR
; /// True = top-left to bottom-right on.
400 bool mbDiagBLtoTR
; /// True = bottom-left to top-right on.
402 explicit BorderModel( bool bDxf
);
405 /** Contains API attributes of a complete cell border. */
408 typedef css::table::BorderLine2 ApiBorderLine
;
410 ApiBorderLine maLeft
; /// Left line format
411 ApiBorderLine maRight
; /// Right line format
412 ApiBorderLine maTop
; /// Top line format
413 ApiBorderLine maBottom
; /// Bottom line format
414 ApiBorderLine maTLtoBR
; /// Diagonal top-left to bottom-right line format.
415 ApiBorderLine maBLtoTR
; /// Diagonal bottom-left to top-right line format.
416 bool mbBorderUsed
; /// True = left/right/top/bottom line format used.
417 bool mbDiagUsed
; /// True = diagonal line format used.
419 explicit ApiBorderData();
421 /** Returns true, if any of the outer border lines is visible. */
422 bool hasAnyOuterBorder() const;
425 class Border
: public WorkbookHelper
428 explicit Border( const WorkbookHelper
& rHelper
, bool bDxf
);
430 /** Sets global border attributes from the border element. */
431 void importBorder( const AttributeList
& rAttribs
);
432 /** Sets border attributes for the border line with the passed element identifier. */
433 void importStyle( sal_Int32 nElement
, const AttributeList
& rAttribs
);
434 /** Sets color attributes for the border line with the passed element identifier. */
435 void importColor( sal_Int32 nElement
, const AttributeList
& rAttribs
);
437 /** Imports the BORDER record from the passed stream. */
438 void importBorder( SequenceInputStream
& rStrm
);
439 /** Imports a border from a DXF record from the passed stream. */
440 void importDxfBorder( sal_Int32 nElement
, SequenceInputStream
& rStrm
);
442 /** Final processing after import of all style settings. */
443 void finalizeImport( bool bRTL
);
445 /** Returns the converted API border data struct. */
446 const ApiBorderData
& getApiData() const { return maApiData
; }
448 void fillToItemSet( SfxItemSet
& rItemSet
, bool bSkipPoolDefs
= false ) const;
451 /** Returns the border line struct specified by the passed XML token identifier. */
452 BorderLineModel
* getBorderLine( sal_Int32 nElement
);
454 /** Converts border line data to an API struct, returns true, if the line is marked as used. */
455 bool convertBorderLine(
456 css::table::BorderLine2
& rBorderLine
,
457 const BorderLineModel
& rModel
);
461 ApiBorderData maApiData
;
465 typedef std::shared_ptr
< Border
> BorderRef
;
467 /** Contains XML pattern fill attributes from the patternFill element. */
468 struct PatternFillModel
470 Color maPatternColor
; /// Pattern foreground color.
471 Color maFillColor
; /// Background fill color.
472 sal_Int32 mnPattern
; /// Pattern identifier (e.g. solid).
473 bool mbPattColorUsed
; /// True = pattern foreground color used.
474 bool mbFillColorUsed
; /// True = background fill color used.
475 bool mbPatternUsed
; /// True = pattern used.
477 explicit PatternFillModel( bool bDxf
);
479 /** Sets the passed BIFF pattern identifier. */
480 void setBiffPattern( sal_Int32 nPattern
);
483 /** Contains XML gradient fill attributes from the gradientFill element. */
484 struct GradientFillModel
486 typedef ::std::map
< double, Color
> ColorMap
;
488 sal_Int32 mnType
; /// Gradient type, linear or path.
489 double mfAngle
; /// Rotation angle for type linear.
490 double mfLeft
; /// Left convergence for type path.
491 double mfRight
; /// Right convergence for type path.
492 double mfTop
; /// Top convergence for type path.
493 double mfBottom
; /// Bottom convergence for type path.
494 ColorMap maColors
; /// Gradient colors.
496 explicit GradientFillModel();
498 /** Reads BIFF12 gradient settings from a FILL or DXF record. */
499 void readGradient( SequenceInputStream
& rStrm
);
500 /** Reads BIFF12 gradient stop settings from a FILL or DXF record. */
501 void readGradientStop( SequenceInputStream
& rStrm
, bool bDxf
);
504 /** Contains API fill attributes. */
505 struct ApiSolidFillData
507 ::Color mnColor
; /// Fill color.
508 bool mbTransparent
; /// True = transparent area.
509 bool mbUsed
; /// True = fill data is valid.
511 explicit ApiSolidFillData();
514 /** Contains cell fill attributes, either a pattern fill or a gradient fill. */
515 class Fill
: public WorkbookHelper
518 explicit Fill( const WorkbookHelper
& rHelper
, bool bDxf
);
520 /** Sets attributes of a patternFill element. */
521 void importPatternFill( const AttributeList
& rAttribs
);
522 /** Sets the pattern color from the fgColor element. */
523 void importFgColor( const AttributeList
& rAttribs
);
524 /** Sets the background color from the bgColor element. */
525 void importBgColor( const AttributeList
& rAttribs
);
526 /** Sets attributes of a gradientFill element. */
527 void importGradientFill( const AttributeList
& rAttribs
);
528 /** Sets a color from the color element in a gradient fill. */
529 void importColor( const AttributeList
& rAttribs
, double fPosition
);
531 /** Imports the FILL record from the passed stream. */
532 void importFill( SequenceInputStream
& rStrm
);
533 /** Imports the fill pattern from a DXF record. */
534 void importDxfPattern( SequenceInputStream
& rStrm
);
535 /** Imports the pattern color from a DXF record. */
536 void importDxfFgColor( SequenceInputStream
& rStrm
);
537 /** Imports the background color from a DXF record. */
538 void importDxfBgColor( SequenceInputStream
& rStrm
);
539 /** Imports gradient settings from a DXF record. */
540 void importDxfGradient( SequenceInputStream
& rStrm
);
541 /** Imports gradient stop settings from a DXF record. */
542 void importDxfStop( SequenceInputStream
& rStrm
);
544 /** Final processing after import of all style settings. */
545 void finalizeImport();
547 void fillToItemSet( SfxItemSet
& rItemSet
, bool bSkipPoolDefs
= false ) const;
550 typedef std::shared_ptr
< PatternFillModel
> PatternModelRef
;
551 typedef std::shared_ptr
< GradientFillModel
> GradientModelRef
;
553 PatternModelRef mxPatternModel
;
554 GradientModelRef mxGradientModel
;
555 ApiSolidFillData maApiData
;
559 typedef std::shared_ptr
< Fill
> FillRef
;
561 /** Contains all data for a cell format or cell style. */
564 sal_Int32 mnStyleXfId
; /// Index to parent style XF.
565 sal_Int32 mnFontId
; /// Index to font data list.
566 sal_Int32 mnNumFmtId
; /// Index to number format list.
567 sal_Int32 mnBorderId
; /// Index to list of cell borders.
568 sal_Int32 mnFillId
; /// Index to list of cell areas.
569 bool mbCellXf
; /// True = cell XF, false = style XF.
570 bool mbFontUsed
; /// True = font index used.
571 bool mbNumFmtUsed
; /// True = number format used.
572 bool mbAlignUsed
; /// True = alignment used.
573 bool mbProtUsed
; /// True = cell protection used.
574 bool mbBorderUsed
; /// True = border data used.
575 bool mbAreaUsed
; /// True = area data used.
580 bool operator==( const XfModel
& rXfModel1
, const XfModel
& rXfModel2
);
582 /** Represents a cell format or a cell style (called XF, extended format).
584 This class stores the type (cell/style), the index to the parent style (if
585 it is a cell format) and all "attribute used" flags, which reflect the
586 state of specific attribute groups (true = user has changed the attributes)
587 and all formatting data.
589 class Xf
: public WorkbookHelper
591 friend bool operator==( const Xf
& rXf1
, const Xf
& rXf2
);
595 std::vector
<ScAttrEntry
> maAttrs
;
596 bool mbLatinNumFmtOnly
;
597 const ScPatternAttr
* mpDefPattern
;
599 AttrList(const ScPatternAttr
* pDefPatternAttr
);
602 explicit Xf( const WorkbookHelper
& rHelper
);
604 /** Sets all attributes from the xf element. */
605 void importXf( const AttributeList
& rAttribs
, bool bCellXf
);
606 /** Sets all attributes from the alignment element. */
607 void importAlignment( const AttributeList
& rAttribs
);
608 /** Sets all attributes from the protection element. */
609 void importProtection( const AttributeList
& rAttribs
);
611 /** Imports the XF record from the passed stream. */
612 void importXf( SequenceInputStream
& rStrm
, bool bCellXf
);
614 /** Final processing after import of all style settings. */
615 void finalizeImport();
617 /** Returns true, if the XF is a cell XF, and false, if it is a style XF. */
618 bool isCellXf() const { return maModel
.mbCellXf
; }
620 /** Returns the referred font object. */
621 FontRef
getFont() const;
622 /** Returns the alignment data of this style. */
623 const Alignment
& getAlignment() const { return maAlignment
; }
625 void applyPatternToAttrList(
626 AttrList
& rAttrs
, SCROW nRow1
, SCROW nRow2
, sal_Int32 nForceScNumFmt
);
628 void writeToDoc( ScDocumentImport
& rDoc
, const ScRange
& rRange
);
630 const ::ScPatternAttr
& createPattern( bool bSkipPoolDefs
= false );
633 typedef ::std::unique_ptr
< ::ScPatternAttr
> ScPatternAttrPtr
;
635 ScPatternAttrPtr mpPattern
; /// Calc item set.
636 sal_uInt32 mnScNumFmt
; /// Calc number format.
638 XfModel maModel
; /// Cell XF or style XF model data.
639 Alignment maAlignment
; /// Cell alignment data.
640 Protection maProtection
; /// Cell protection data.
641 sal_Int32 meRotationRef
; /// Rotation reference dependent on border.
642 ::ScStyleSheet
* mpStyleSheet
; /// Calc cell style sheet.
645 bool operator==( const Xf
& rXf1
, const Xf
& rXf2
);
647 typedef std::shared_ptr
< Xf
> XfRef
;
649 class Dxf
: public WorkbookHelper
652 explicit Dxf( const WorkbookHelper
& rHelper
);
654 /** Creates a new empty font object. */
655 FontRef
const & createFont( bool bAlwaysNew
= true );
656 /** Creates a new empty border object. */
657 BorderRef
const & createBorder( bool bAlwaysNew
= true );
658 /** Creates a new empty fill object. */
659 FillRef
const & createFill( bool bAlwaysNew
= true );
661 /** Inserts a new number format code. */
662 void importNumFmt( const AttributeList
& rAttribs
);
664 /** Imports the DXF record from the passed stream. */
665 void importDxf( SequenceInputStream
& rStrm
);
667 /** Final processing after import of all style settings. */
668 void finalizeImport();
670 void fillToItemSet( SfxItemSet
& rSet
) const;
673 FontRef mxFont
; /// Font data.
674 NumberFormatRef mxNumFmt
; /// Number format data.
675 std::shared_ptr
< Alignment
>
676 mxAlignment
; /// Alignment data.
677 std::shared_ptr
< Protection
>
678 mxProtection
; /// Protection data.
679 BorderRef mxBorder
; /// Border data.
680 FillRef mxFill
; /// Fill data.
683 typedef std::shared_ptr
< Dxf
> DxfRef
;
685 /** Contains attributes of a cell style, e.g. from the cellStyle element. */
686 struct CellStyleModel
688 OUString maName
; /// Cell style name.
689 sal_Int32 mnXfId
; /// Formatting for this cell style.
690 sal_Int32 mnBuiltinId
; /// Identifier for builtin styles.
691 sal_Int32 mnLevel
; /// Level for builtin column/row styles.
692 bool mbBuiltin
; /// True = builtin style.
693 bool mbCustom
; /// True = customized builtin style.
694 bool mbHidden
; /// True = style not visible in GUI.
696 explicit CellStyleModel();
698 /** Returns true, if this style is a builtin style. */
699 bool isBuiltin() const;
700 /** Returns true, if this style represents the default document cell style. */
701 bool isDefaultStyle() const;
704 class CellStyle
: public WorkbookHelper
707 explicit CellStyle( const WorkbookHelper
& rHelper
);
709 /** Imports passed attributes from the cellStyle element. */
710 void importCellStyle( const AttributeList
& rAttribs
);
711 /** Imports style settings from a CELLSTYLE record. */
712 void importCellStyle( SequenceInputStream
& rStrm
);
714 /** Creates the style sheet in the document described by this cell style object. */
715 void createCellStyle();
716 /** Stores the passed final style name and creates the cell style, if it is
717 user-defined or modified built-in. */
718 void finalizeImport( const OUString
& rFinalName
);
720 /** Returns the cell style model structure. */
721 const CellStyleModel
& getModel() const { return maModel
; }
722 /** Returns the final style name used in the document. */
723 const OUString
& getFinalStyleName() const { return maFinalName
; }
724 ::ScStyleSheet
* getStyleSheet() { return mpStyleSheet
; }
726 CellStyleModel maModel
;
727 OUString maFinalName
; /// Final style name used in API.
728 bool mbCreated
; /// True = style sheet created.
729 ::ScStyleSheet
* mpStyleSheet
; /// Calc cell style sheet.
733 typedef std::shared_ptr
< CellStyle
> CellStyleRef
;
735 class CellStyleBuffer
: public WorkbookHelper
738 explicit CellStyleBuffer( const WorkbookHelper
& rHelper
);
740 /** Appends and returns a new named cell style object. */
741 CellStyleRef
importCellStyle( const AttributeList
& rAttribs
);
742 /** Imports the CELLSTYLE record from the passed stream. */
743 CellStyleRef
importCellStyle( SequenceInputStream
& rStrm
);
745 /** Final processing after import of all style settings. */
746 void finalizeImport();
748 /** Returns the XF identifier associated to the default cell style. */
749 sal_Int32
getDefaultXfId() const;
750 /** Returns the default style sheet for unused cells. */
751 OUString
getDefaultStyleName() const;
752 /** Creates the style sheet described by the style XF with the passed identifier. */
753 OUString
createCellStyle( sal_Int32 nXfId
) const;
754 ::ScStyleSheet
* getCellStyleSheet( sal_Int32 nXfId
) const;
757 /** Inserts the passed cell style object into the internal maps. */
758 void insertCellStyle( CellStyleRef
const & xCellStyle
);
759 /** Creates the style sheet described by the passed cell style object. */
760 static OUString
createCellStyle( const CellStyleRef
& rxCellStyle
);
761 static ::ScStyleSheet
* getCellStyleSheet( const CellStyleRef
& rxCellStyle
);
764 typedef RefVector
< CellStyle
> CellStyleVector
;
765 typedef RefMap
< sal_Int32
, CellStyle
> CellStyleXfIdMap
;
767 CellStyleVector maBuiltinStyles
; /// All built-in cell styles.
768 CellStyleVector maUserStyles
; /// All user defined cell styles.
769 CellStyleXfIdMap maStylesByXf
; /// All cell styles, mapped by XF identifier.
770 CellStyleRef mxDefStyle
; /// Default cell style.
773 struct AutoFormatModel
775 sal_Int32 mnAutoFormatId
; /// Index of predefined autoformatting.
776 bool mbApplyNumFmt
; /// True = apply number format from autoformatting.
777 bool mbApplyFont
; /// True = apply font from autoformatting.
778 bool mbApplyAlignment
; /// True = apply alignment from autoformatting.
779 bool mbApplyBorder
; /// True = apply border from autoformatting.
780 bool mbApplyFill
; /// True = apply fill from autoformatting.
781 bool mbApplyProtection
; /// True = apply protection from autoformatting.
783 explicit AutoFormatModel();
786 class StylesBuffer
: public WorkbookHelper
789 explicit StylesBuffer( const WorkbookHelper
& rHelper
);
791 /** Creates a new empty font object. */
792 FontRef
createFont();
793 /** Creates a number format. */
794 NumberFormatRef
createNumFmt( sal_Int32 nNumFmtId
, const OUString
& rFmtCode
);
795 sal_Int32
nextFreeNumFmtId();
796 /** Creates a new empty border object. */
797 BorderRef
createBorder();
798 /** Creates a new empty fill object. */
799 FillRef
createFill();
800 /** Creates a new empty cell formatting object. */
801 XfRef
createCellXf();
802 /** Creates a new empty style formatting object. */
803 XfRef
createStyleXf();
804 /** Creates a new empty differential formatting object. */
806 DxfRef
createExtDxf();
808 /** Appends a new color to the color palette. */
809 void importPaletteColor( const AttributeList
& rAttribs
);
810 /** Inserts a new number format code. */
811 NumberFormatRef
importNumFmt( const AttributeList
& rAttribs
);
812 /** Appends and returns a new named cell style object. */
813 CellStyleRef
importCellStyle( const AttributeList
& rAttribs
);
815 /** Appends a new color to the color palette. */
816 void importPaletteColor( SequenceInputStream
& rStrm
);
817 /** Imports the NUMFMT record from the passed stream. */
818 void importNumFmt( SequenceInputStream
& rStrm
);
819 /** Imports the CELLSTYLE record from the passed stream. */
820 void importCellStyle( SequenceInputStream
& rStrm
);
822 /** Final processing after import of all style settings. */
823 void finalizeImport();
825 /** Returns the palette color with the specified index. */
826 ::Color
getPaletteColor( sal_Int32 nIndex
) const;
827 /** Returns the specified font object. */
828 FontRef
getFont( sal_Int32 nFontId
) const;
829 /** Returns the specified border object. */
830 BorderRef
getBorder( sal_Int32 nBorderId
) const;
831 /** Returns the specified cell format object. */
832 XfRef
getCellXf( sal_Int32 nXfId
) const;
833 /** Returns the specified style format object. */
834 XfRef
getStyleXf( sal_Int32 nXfId
) const;
836 /** Returns the font object of the specified cell XF. */
837 FontRef
getFontFromCellXf( sal_Int32 nXfId
) const;
838 /** Returns the default application font (used in the "Normal" cell style). */
839 FontRef
getDefaultFont() const;
840 /** Returns the model of the default application font (used in the "Normal" cell style). */
841 const FontModel
& getDefaultFontModel() const;
843 /** Returns true, if the specified borders are equal. */
844 static bool equalBorders( sal_Int32 nBorderId1
, sal_Int32 nBorderId2
);
845 /** Returns true, if the specified fills are equal. */
846 static bool equalFills( sal_Int32 nFillId1
, sal_Int32 nFillId2
);
848 /** Returns the default style sheet for unused cells. */
849 OUString
getDefaultStyleName() const;
850 /** Creates the style sheet described by the style XF with the passed identifier. */
851 OUString
createCellStyle( sal_Int32 nXfId
) const;
852 ::ScStyleSheet
* getCellStyleSheet( sal_Int32 nXfId
) const;
853 /** Creates the style sheet described by the DXF with the passed identifier. */
854 OUString
createDxfStyle( sal_Int32 nDxfId
) const;
855 OUString
createExtDxfStyle( sal_Int32 nDxfId
) const;
857 void writeFontToItemSet( SfxItemSet
& rItemSet
, sal_Int32 nFontId
, bool bSkipPoolDefs
) const;
858 sal_uInt32
writeNumFmtToItemSet( SfxItemSet
& rItemSet
, sal_uInt32 nNumFmtId
, bool bSkipPoolDefs
) const;
859 /** Writes the specified number format to the passed property map. */
860 void writeBorderToItemSet( SfxItemSet
& rItemSet
, sal_Int32 nBorderId
, bool bSkipPoolDefs
) const;
861 /** Writes the fill attributes of the specified fill data to the passed property map. */
862 void writeFillToItemSet( SfxItemSet
& rItemSet
, sal_Int32 nFillId
, bool bSkipPoolDefs
) const;
864 /** Writes the cell formatting attributes of the specified XF to the passed property set. */
865 void writeCellXfToDoc( ScDocumentImport
& rDoc
, const ScRange
& rRange
, sal_Int32 nXfId
) const;
866 const RefVector
< Dxf
>& getExtDxfs() const { return maExtDxfs
; }
869 typedef RefVector
< Font
> FontVector
;
870 typedef RefVector
< Border
> BorderVector
;
871 typedef RefVector
< Fill
> FillVector
;
872 typedef RefVector
< Xf
> XfVector
;
873 typedef RefVector
< Dxf
> DxfVector
;
874 typedef ::std::map
< sal_Int32
, OUString
> DxfStyleMap
;
876 ColorPalette maPalette
; /// Color palette.
877 FontVector maFonts
; /// List of font objects.
878 NumberFormatsBuffer maNumFmts
; /// List of all number format codes.
879 BorderVector maBorders
; /// List of cell border objects.
880 FillVector maFills
; /// List of cell area fill objects.
881 XfVector maCellXfs
; /// List of cell formats.
882 XfVector maStyleXfs
; /// List of cell styles.
883 CellStyleBuffer maCellStyles
; /// All built-in and user defined cell styles.
884 DxfVector maDxfs
; /// List of differential cell styles.
885 DxfVector maExtDxfs
; /// List of differential extlst cell styles.
886 mutable DxfStyleMap maDxfStyles
; /// Maps DXF identifiers to Calc style sheet names.
894 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */