LCOV - code coverage report
Current view: top level - sc/source/filter/inc - stylesbuffer.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 29 32 90.6 %
Date: 2012-08-25 Functions: 42 50 84.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 30 78 38.5 %

           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 OOX_XLS_STYLESBUFFER_HXX
      30                 :            : #define OOX_XLS_STYLESBUFFER_HXX
      31                 :            : 
      32                 :            : #include <com/sun/star/awt/FontDescriptor.hpp>
      33                 :            : #include <com/sun/star/table/CellHoriJustify.hpp>
      34                 :            : #include <com/sun/star/table/CellOrientation.hpp>
      35                 :            : #include <com/sun/star/table/CellVertJustify2.hpp>
      36                 :            : #include <com/sun/star/table/BorderLine2.hpp>
      37                 :            : #include <com/sun/star/util/CellProtection.hpp>
      38                 :            : #include "oox/drawingml/color.hxx"
      39                 :            : #include "oox/helper/graphichelper.hxx"
      40                 :            : #include "oox/helper/refmap.hxx"
      41                 :            : #include "oox/helper/refvector.hxx"
      42                 :            : #include "numberformatsbuffer.hxx"
      43                 :            : #include "patattr.hxx"
      44                 :            : #include "stlsheet.hxx"
      45                 :            : #include <editeng/svxenum.hxx>
      46                 :            : #include <editeng/frmdir.hxx>
      47                 :            : 
      48                 :            : class ScMarkData;
      49                 :            : namespace com { namespace sun { namespace star {
      50                 :            :     namespace awt { struct FontDescrtiptor; }
      51                 :            : } } }
      52                 :            : 
      53                 :            : namespace oox { class PropertySet; }
      54                 :            : 
      55                 :            : namespace oox {
      56                 :            : namespace xls {
      57                 :            : 
      58                 :            : // ============================================================================
      59                 :            : 
      60                 :            : const sal_Int32 OOX_COLOR_WINDOWTEXT3       = 24;       /// System window text color (BIFF3-BIFF4).
      61                 :            : const sal_Int32 OOX_COLOR_WINDOWBACK3       = 25;       /// System window background color (BIFF3-BIFF4).
      62                 :            : const sal_Int32 OOX_COLOR_WINDOWTEXT        = 64;       /// System window text color (BIFF5+).
      63                 :            : const sal_Int32 OOX_COLOR_WINDOWBACK        = 65;       /// System window background color (BIFF5+).
      64                 :            : const sal_Int32 OOX_COLOR_BUTTONBACK        = 67;       /// System button background color (face color).
      65                 :            : const sal_Int32 OOX_COLOR_CHWINDOWTEXT      = 77;       /// System window text color (BIFF8 charts).
      66                 :            : const sal_Int32 OOX_COLOR_CHWINDOWBACK      = 78;       /// System window background color (BIFF8 charts).
      67                 :            : const sal_Int32 OOX_COLOR_CHBORDERAUTO      = 79;       /// Automatic frame border (BIFF8 charts).
      68                 :            : const sal_Int32 OOX_COLOR_NOTEBACK          = 80;       /// Note background color.
      69                 :            : const sal_Int32 OOX_COLOR_NOTETEXT          = 81;       /// Note text color.
      70                 :            : const sal_Int32 OOX_COLOR_FONTAUTO          = 0x7FFF;   /// Font auto color (system window text color).
      71                 :            : 
      72                 :            : // ----------------------------------------------------------------------------
      73                 :            : 
      74                 :            : const sal_Int16 API_LINE_NONE               = 0;
      75                 :            : const sal_Int16 API_LINE_HAIR               = 2;
      76                 :            : const sal_Int16 API_LINE_THIN               = 35;
      77                 :            : const sal_Int16 API_LINE_MEDIUM             = 88;
      78                 :            : const sal_Int16 API_LINE_THICK              = 141;
      79                 :            : 
      80                 :            : const sal_Int16 API_ESCAPE_NONE             = 0;        /// No escapement.
      81                 :            : const sal_Int16 API_ESCAPE_SUPERSCRIPT      = 101;      /// Superscript: raise characters automatically (magic value 101).
      82                 :            : const sal_Int16 API_ESCAPE_SUBSCRIPT        = -101;     /// Subscript: lower characters automatically (magic value -101).
      83                 :            : 
      84                 :            : const sal_Int8 API_ESCAPEHEIGHT_NONE        = 100;      /// Relative character height if not escaped.
      85                 :            : const sal_Int8 API_ESCAPEHEIGHT_DEFAULT     = 58;       /// Relative character height if escaped.
      86                 :            : 
      87                 :            : // ============================================================================
      88                 :            : 
      89                 :            : /** Special implementation of the GraphicHelper for Excel palette and scheme
      90                 :            :     colors.
      91                 :            :  */
      92 [ +  - ][ -  + ]:         48 : class ExcelGraphicHelper : public GraphicHelper, public WorkbookHelper
      93                 :            : {
      94                 :            : public:
      95                 :            :     explicit            ExcelGraphicHelper( const WorkbookHelper& rHelper );
      96                 :            : 
      97                 :            :     /** Derived classes may implement to resolve a scheme color from the passed XML token identifier. */
      98                 :            :     virtual sal_Int32   getSchemeColor( sal_Int32 nToken ) const;
      99                 :            :     /** Derived classes may implement to resolve a palette index to an RGB color. */
     100                 :            :     virtual sal_Int32   getPaletteColor( sal_Int32 nPaletteIdx ) const;
     101                 :            : };
     102                 :            : 
     103                 :            : // ============================================================================
     104                 :            : 
     105                 :       1308 : class Color : public ::oox::drawingml::Color
     106                 :            : {
     107                 :            : public:
     108                 :            :     /** Sets the color to automatic. */
     109                 :            :     void                setAuto();
     110                 :            :     /** Sets the color to the passed RGB value. */
     111                 :            :     void                setRgb( sal_Int32 nRgbValue, double fTint = 0.0 );
     112                 :            :     /** Sets the color to the passed theme index. */
     113                 :            :     void                setTheme( sal_Int32 nThemeIdx, double fTint = 0.0 );
     114                 :            :     /** Sets the color to the passed palette index. */
     115                 :            :     void                setIndexed( sal_Int32 nPaletteIdx, double fTint = 0.0 );
     116                 :            : 
     117                 :            :     /** Imports the color from the passed attribute list. */
     118                 :            :     void                importColor( const AttributeList& rAttribs );
     119                 :            : 
     120                 :            :     /** Imports a 64-bit color from the passed binary stream. */
     121                 :            :     void                importColor( SequenceInputStream& rStrm );
     122                 :            :     /** Imports a 32-bit palette color identifier from the passed BIFF12 stream. */
     123                 :            :     void                importColorId( SequenceInputStream& rStrm );
     124                 :            : 
     125                 :            :     /** Returns true, if the color is set to automatic. */
     126                 :         60 :     inline bool         isAuto() const { return isPlaceHolder(); }
     127                 :            : };
     128                 :            : 
     129                 :            : // ----------------------------------------------------------------------------
     130                 :            : 
     131                 :            : SequenceInputStream& operator>>( SequenceInputStream& rStrm, Color& orColor );
     132                 :            : 
     133                 :            : // ============================================================================
     134                 :            : 
     135                 :            : /** Stores all colors of the color palette. */
     136         [ -  + ]:         24 : class ColorPalette : public WorkbookHelper
     137                 :            : {
     138                 :            : public:
     139                 :            :     /** Constructs the color palette with predefined color values. */
     140                 :            :     explicit            ColorPalette( const WorkbookHelper& rHelper );
     141                 :            : 
     142                 :            :     /** Appends a new color from the passed attributes. */
     143                 :            :     void                importPaletteColor( const AttributeList& rAttribs );
     144                 :            :     /** Appends a new color from the passed RGBCOLOR record. */
     145                 :            :     void                importPaletteColor( SequenceInputStream& rStrm );
     146                 :            : 
     147                 :            :     /** Rturns the RGB value of the color with the passed index. */
     148                 :            :     sal_Int32           getColor( sal_Int32 nPaletteIdx ) const;
     149                 :            : 
     150                 :            : private:
     151                 :            :     /** Appends the passed color. */
     152                 :            :     void                appendColor( sal_Int32 nRGBValue );
     153                 :            : 
     154                 :            : private:
     155                 :            :     ::std::vector< sal_Int32 > maColors;    /// List of RGB values.
     156                 :            :     size_t              mnAppendIndex;      /// Index to append a new color.
     157                 :            : };
     158                 :            : 
     159                 :            : // ============================================================================
     160                 :            : 
     161                 :            : /** Contains all XML font attributes, e.g. from a font or rPr element. */
     162 [ #  # ][ +  - ]:        576 : struct FontModel
                 [ +  - ]
     163                 :            : {
     164                 :            :     ::rtl::OUString     maName;             /// Font name.
     165                 :            :     Color               maColor;            /// Font color.
     166                 :            :     sal_Int32           mnScheme;           /// Major/minor scheme font.
     167                 :            :     sal_Int32           mnFamily;           /// Font family.
     168                 :            :     sal_Int32           mnCharSet;          /// Windows font character set.
     169                 :            :     double              mfHeight;           /// Font height in points.
     170                 :            :     sal_Int32           mnUnderline;        /// Underline style.
     171                 :            :     sal_Int32           mnEscapement;       /// Escapement style.
     172                 :            :     bool                mbBold;             /// True = bold characters.
     173                 :            :     bool                mbItalic;           /// True = italic characters.
     174                 :            :     bool                mbStrikeout;        /// True = Strike out characters.
     175                 :            :     bool                mbOutline;          /// True = outlined characters.
     176                 :            :     bool                mbShadow;           /// True = shadowed chgaracters.
     177                 :            : 
     178                 :            :     explicit            FontModel();
     179                 :            : 
     180                 :            :     void                setBiff12Scheme( sal_uInt8 nScheme );
     181                 :            :     void                setBiffHeight( sal_uInt16 nHeight );
     182                 :            :     void                setBiffWeight( sal_uInt16 nWeight );
     183                 :            :     void                setBiffUnderline( sal_uInt16 nUnderline );
     184                 :            :     void                setBiffEscapement( sal_uInt16 nEscapement );
     185                 :            : };
     186                 :            : 
     187                 :            : // ----------------------------------------------------------------------------
     188                 :            : 
     189                 :            : /** Enumerates different types of API font property sets. */
     190                 :            : enum FontPropertyType
     191                 :            : {
     192                 :            :     FONT_PROPTYPE_CELL,             /// Font properties in a spreadsheet cell (table::Cell service).
     193                 :            :     FONT_PROPTYPE_TEXT              /// Font properties in a text object (text::Text service).
     194                 :            : };
     195                 :            : 
     196                 :            : // ----------------------------------------------------------------------------
     197                 :            : 
     198                 :            : /** Contains used flags for all API font attributes. */
     199                 :            : struct ApiFontUsedFlags
     200                 :            : {
     201                 :            :     bool                mbNameUsed;         /// True = font name/family/char set are used.
     202                 :            :     bool                mbColorUsed;        /// True = font color is used.
     203                 :            :     bool                mbSchemeUsed;       /// True = font scheme is used.
     204                 :            :     bool                mbHeightUsed;       /// True = font height is used.
     205                 :            :     bool                mbUnderlineUsed;    /// True = underline style is used.
     206                 :            :     bool                mbEscapementUsed;   /// True = escapement style is used.
     207                 :            :     bool                mbWeightUsed;       /// True = font weight (boldness) is used.
     208                 :            :     bool                mbPostureUsed;      /// True = font posture (italic) is used.
     209                 :            :     bool                mbStrikeoutUsed;    /// True = strike out style is used.
     210                 :            :     bool                mbOutlineUsed;      /// True = outline style is used.
     211                 :            :     bool                mbShadowUsed;       /// True = shadow style is used.
     212                 :            : 
     213                 :            :     explicit            ApiFontUsedFlags( bool bAllUsed );
     214                 :            : };
     215                 :            : 
     216                 :            : // ----------------------------------------------------------------------------
     217                 :            : 
     218                 :            : /** Contains API font name, family, and charset for a script type. */
     219                 :       1479 : struct ApiScriptFontName
     220                 :            : {
     221                 :            :     ::rtl::OUString     maName;             /// Font name.
     222                 :            :     sal_Int16           mnFamily;           /// Font family.
     223                 :            :     sal_Int16           mnTextEnc;          /// Font text encoding.
     224                 :            : 
     225                 :            :     explicit            ApiScriptFontName();
     226                 :            : };
     227                 :            : 
     228                 :            : // ----------------------------------------------------------------------------
     229                 :            : 
     230                 :            : /** Contains all API font attributes. */
     231                 :        213 : struct ApiFontData
     232                 :            : {
     233                 :            :     typedef ::com::sun::star::awt::FontDescriptor ApiFontDescriptor;
     234                 :            : 
     235                 :            :     ApiScriptFontName   maLatinFont;        /// Font name for latin scripts.
     236                 :            :     ApiScriptFontName   maAsianFont;        /// Font name for east-asian scripts.
     237                 :            :     ApiScriptFontName   maCmplxFont;        /// Font name for complex scripts.
     238                 :            :     ApiFontDescriptor   maDesc;             /// Font descriptor (height in twips, weight in %).
     239                 :            :     sal_Int32           mnColor;            /// Font color.
     240                 :            :     sal_Int16           mnEscapement;       /// Escapement style.
     241                 :            :     sal_Int8            mnEscapeHeight;     /// Escapement font height.
     242                 :            :     bool                mbOutline;          /// True = outlined characters.
     243                 :            :     bool                mbShadow;           /// True = shadowed chgaracters.
     244                 :            : 
     245                 :            :     explicit            ApiFontData();
     246                 :            : };
     247                 :            : 
     248                 :            : // ============================================================================
     249                 :            : 
     250 [ +  - ][ -  + ]:        324 : class Font : public WorkbookHelper
     251                 :            : {
     252                 :            : public:
     253                 :            :     explicit            Font( const WorkbookHelper& rHelper, bool bDxf );
     254                 :            :     explicit            Font( const WorkbookHelper& rHelper, const FontModel& rModel );
     255                 :            : 
     256                 :            :     /** Sets font formatting attributes for the passed element. */
     257                 :            :     void                importAttribs( sal_Int32 nElement, const AttributeList& rAttribs );
     258                 :            : 
     259                 :            :     /** Imports the FONT record from the passed stream. */
     260                 :            :     void                importFont( SequenceInputStream& rStrm );
     261                 :            :     /** Imports the font name from a DXF record. */
     262                 :            :     void                importDxfName( SequenceInputStream& rStrm );
     263                 :            :     /** Imports the font color from a DXF record. */
     264                 :            :     void                importDxfColor( SequenceInputStream& rStrm );
     265                 :            :     /** Imports the font scheme from a DXF record. */
     266                 :            :     void                importDxfScheme( SequenceInputStream& rStrm );
     267                 :            :     /** Imports the font height from a DXF record. */
     268                 :            :     void                importDxfHeight( SequenceInputStream& rStrm );
     269                 :            :     /** Imports the font weight from a DXF record. */
     270                 :            :     void                importDxfWeight( SequenceInputStream& rStrm );
     271                 :            :     /** Imports the font underline style from a DXF record. */
     272                 :            :     void                importDxfUnderline( SequenceInputStream& rStrm );
     273                 :            :     /** Imports the font escapement style from a DXF record. */
     274                 :            :     void                importDxfEscapement( SequenceInputStream& rStrm );
     275                 :            :     /** Imports a font style flag from a DXF record. */
     276                 :            :     void                importDxfFlag( sal_Int32 nElement, SequenceInputStream& rStrm );
     277                 :            : 
     278                 :            :     /** Returns the font model structure. This function can be called before
     279                 :            :         finalizeImport() has been called. */
     280                 :        102 :     inline const FontModel& getModel() const { return maModel; }
     281                 :            : 
     282                 :            :     /** Final processing after import of all style settings. */
     283                 :            :     void                finalizeImport();
     284                 :            : 
     285                 :            :     /** Returns an API font descriptor with own font information. */
     286                 :            :     const ::com::sun::star::awt::FontDescriptor& getFontDescriptor() const;
     287                 :            :     /** Returns true, if the font requires rich text formatting in Calc.
     288                 :            :         @descr  Example: Font escapement is a cell attribute in Excel, but Calc
     289                 :            :         needs an rich text cell for this attribute. */
     290                 :            :     bool                needsRichTextFormat() const;
     291                 :            : 
     292                 :            :     void                fillToItemSet( SfxItemSet& rItemSet, FontPropertyType ePropType, bool bSkipPoolDefs = false ) const;
     293                 :            :     /** Writes all font attributes to the passed property map. */
     294                 :            :     void                writeToPropertyMap(
     295                 :            :                             PropertyMap& rPropMap,
     296                 :            :                             FontPropertyType ePropType ) const;
     297                 :            :     /** Writes all font attributes to the passed property set. */
     298                 :            :     void                writeToPropertySet(
     299                 :            :                             PropertySet& rPropSet,
     300                 :            :                             FontPropertyType ePropType ) const;
     301                 :            : 
     302                 :            : private:
     303                 :            :     FontModel           maModel;
     304                 :            :     ApiFontData         maApiData;
     305                 :            :     ApiFontUsedFlags    maUsedFlags;
     306                 :            :     bool                mbDxf;
     307                 :            : };
     308                 :            : 
     309                 :            : typedef ::boost::shared_ptr< Font > FontRef;
     310                 :            : 
     311                 :            : // ============================================================================
     312                 :            : 
     313                 :            : /** Contains all XML cell alignment attributes, e.g. from an alignment element. */
     314                 :            : struct AlignmentModel
     315                 :            : {
     316                 :            :     sal_Int32           mnHorAlign;         /// Horizontal alignment.
     317                 :            :     sal_Int32           mnVerAlign;         /// Vertical alignment.
     318                 :            :     sal_Int32           mnTextDir;          /// CTL text direction.
     319                 :            :     sal_Int32           mnRotation;         /// Text rotation angle.
     320                 :            :     sal_Int32           mnIndent;           /// Indentation.
     321                 :            :     bool                mbWrapText;         /// True = multi-line text.
     322                 :            :     bool                mbShrink;           /// True = shrink to fit cell size.
     323                 :            :     bool                mbJustLastLine;     /// True = justify last line in block text.
     324                 :            : 
     325                 :            :     explicit            AlignmentModel();
     326                 :            : 
     327                 :            :     /** Sets horizontal alignment from the passed BIFF data. */
     328                 :            :     void                setBiffHorAlign( sal_uInt8 nHorAlign );
     329                 :            :     /** Sets vertical alignment from the passed BIFF data. */
     330                 :            :     void                setBiffVerAlign( sal_uInt8 nVerAlign );
     331                 :            : };
     332                 :            : 
     333                 :            : // ----------------------------------------------------------------------------
     334                 :            : 
     335                 :            : /** Contains all API cell alignment attributes. */
     336                 :            : struct ApiAlignmentData
     337                 :            : {
     338                 :            :     typedef ::com::sun::star::table::CellHoriJustify ApiCellHoriJustify;
     339                 :            :     typedef ::com::sun::star::table::CellOrientation ApiCellOrientation;
     340                 :            : 
     341                 :            :     ApiCellHoriJustify  meHorJustify;       /// Horizontal alignment.
     342                 :            :     sal_Int32           mnHorJustifyMethod;
     343                 :            :     sal_Int32           mnVerJustify;       /// Vertical alignment.
     344                 :            :     sal_Int32           mnVerJustifyMethod;
     345                 :            :     ApiCellOrientation  meOrientation;      /// Normal or stacked text.
     346                 :            :     sal_Int32           mnRotation;         /// Text rotation angle.
     347                 :            :     sal_Int16           mnWritingMode;      /// CTL text direction.
     348                 :            :     sal_Int16           mnIndent;           /// Indentation.
     349                 :            :     bool                mbWrapText;         /// True = multi-line text.
     350                 :            :     bool                mbShrink;           /// True = shrink to fit cell size.
     351                 :            : 
     352                 :            :     explicit            ApiAlignmentData();
     353                 :            : };
     354                 :            : 
     355                 :            : bool operator==( const ApiAlignmentData& rLeft, const ApiAlignmentData& rRight );
     356                 :            : 
     357                 :            : // ============================================================================
     358                 :            : 
     359         [ -  + ]:        465 : class Alignment : public WorkbookHelper
     360                 :            : {
     361                 :            : public:
     362                 :            :     explicit            Alignment( const WorkbookHelper& rHelper );
     363                 :            : 
     364                 :            :     /** Sets all attributes from the alignment element. */
     365                 :            :     void                importAlignment( const AttributeList& rAttribs );
     366                 :            : 
     367                 :            :     /** Sets the alignment attributes from the passed BIFF12 XF record data. */
     368                 :            :     void                setBiff12Data( sal_uInt32 nFlags );
     369                 :            : 
     370                 :            :     /** Final processing after import of all style settings. */
     371                 :            :     void                finalizeImport();
     372                 :            : 
     373                 :            :     /** Returns the alignment model structure. */
     374                 :        411 :     inline const AlignmentModel& getModel() const { return maModel; }
     375                 :            :     /** Returns the converted API alignment data struct. */
     376                 :        297 :     inline const ApiAlignmentData& getApiData() const { return maApiData; }
     377                 :            : 
     378                 :            :     void                fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs = false ) const;
     379                 :            :     /** Writes all alignment attributes to the passed property map. */
     380                 :            :     void                writeToPropertyMap( PropertyMap& rPropMap ) const;
     381                 :            : 
     382                 :            : private:
     383                 :            :     ::SvxCellHorJustify GetScHorAlign() const;
     384                 :            :     ::SvxCellVerJustify GetScVerAlign() const;
     385                 :            :     ::SvxFrameDirection GetScFrameDir() const;
     386                 :            :     AlignmentModel      maModel;            /// Alignment model data.
     387                 :            :     ApiAlignmentData    maApiData;          /// Alignment data converted to API constants.
     388                 :            : };
     389                 :            : 
     390                 :            : typedef ::boost::shared_ptr< Alignment > AlignmentRef;
     391                 :            : 
     392                 :            : // ============================================================================
     393                 :            : 
     394                 :            : /** Contains all XML cell protection attributes, e.g. from a protection element. */
     395                 :            : struct ProtectionModel
     396                 :            : {
     397                 :            :     bool                mbLocked;           /// True = locked against editing.
     398                 :            :     bool                mbHidden;           /// True = formula is hidden.
     399                 :            : 
     400                 :            :     explicit            ProtectionModel();
     401                 :            : };
     402                 :            : 
     403                 :            : // ----------------------------------------------------------------------------
     404                 :            : 
     405                 :            : /** Contains all API cell protection attributes. */
     406                 :            : struct ApiProtectionData
     407                 :            : {
     408                 :            :     typedef ::com::sun::star::util::CellProtection ApiCellProtection;
     409                 :            : 
     410                 :            :     ApiCellProtection   maCellProt;
     411                 :            : 
     412                 :            :     explicit            ApiProtectionData();
     413                 :            : };
     414                 :            : 
     415                 :            : bool operator==( const ApiProtectionData& rLeft, const ApiProtectionData& rRight );
     416                 :            : 
     417                 :            : // ============================================================================
     418                 :            : 
     419         [ -  + ]:        465 : class Protection : public WorkbookHelper
     420                 :            : {
     421                 :            : public:
     422                 :            :     explicit            Protection( const WorkbookHelper& rHelper );
     423                 :            : 
     424                 :            :     /** Sets all attributes from the protection element. */
     425                 :            :     void                importProtection( const AttributeList& rAttribs );
     426                 :            : 
     427                 :            :     /** Sets the protection attributes from the passed BIFF12 XF record data. */
     428                 :            :     void                setBiff12Data( sal_uInt32 nFlags );
     429                 :            : 
     430                 :            :     /** Final processing after import of all style settings. */
     431                 :            :     void                finalizeImport();
     432                 :            : 
     433                 :            :     /** Returns the protection model structure. */
     434                 :            :     inline const ProtectionModel& getModel() const { return maModel; }
     435                 :            :     /** Returns the converted API protection data struct. */
     436                 :        174 :     inline const ApiProtectionData& getApiData() const { return maApiData; }
     437                 :            : 
     438                 :            :     /** Writes all protection attributes to the passed property map. */
     439                 :            :     void                writeToPropertyMap( PropertyMap& rPropMap ) const;
     440                 :            :     void                fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs = false ) const;
     441                 :            : private:
     442                 :            :     ProtectionModel     maModel;            /// Protection model data.
     443                 :            :     ApiProtectionData   maApiData;          /// Protection data converted to API constants.
     444                 :            : };
     445                 :            : 
     446                 :            : typedef ::boost::shared_ptr< Protection > ProtectionRef;
     447                 :            : 
     448                 :            : // ============================================================================
     449                 :            : 
     450                 :            : /** Contains XML attributes of a single border line. */
     451                 :        120 : struct BorderLineModel
     452                 :            : {
     453                 :            :     Color               maColor;            /// Borderline color.
     454                 :            :     sal_Int32           mnStyle;            /// Border line style.
     455                 :            :     bool                mbUsed;             /// True = line format used.
     456                 :            : 
     457                 :            :     explicit            BorderLineModel( bool bDxf );
     458                 :            : 
     459                 :            :     /** Sets the passed BIFF line style. */
     460                 :            :     void                setBiffStyle( sal_Int32 nLineStyle );
     461                 :            : };
     462                 :            : 
     463                 :            : // ----------------------------------------------------------------------------
     464                 :            : 
     465                 :            : /** Contains XML attributes of a complete cell border. */
     466 [ +  - ][ +  - ]:         24 : struct BorderModel
         [ +  - ][ +  - ]
     467                 :            : {
     468                 :            :     BorderLineModel     maLeft;             /// Left line format.
     469                 :            :     BorderLineModel     maRight;            /// Right line format.
     470                 :            :     BorderLineModel     maTop;              /// Top line format.
     471                 :            :     BorderLineModel     maBottom;           /// Bottom line format.
     472                 :            :     BorderLineModel     maDiagonal;         /// Diagonal line format.
     473                 :            :     bool                mbDiagTLtoBR;       /// True = top-left to bottom-right on.
     474                 :            :     bool                mbDiagBLtoTR;       /// True = bottom-left to top-right on.
     475                 :            : 
     476                 :            :     explicit            BorderModel( bool bDxf );
     477                 :            : };
     478                 :            : 
     479                 :            : // ----------------------------------------------------------------------------
     480                 :            : 
     481                 :            : /** Contains API attributes of a complete cell border. */
     482                 :            : struct ApiBorderData
     483                 :            : {
     484                 :            :     typedef ::com::sun::star::table::BorderLine2     ApiBorderLine;
     485                 :            : 
     486                 :            :     ApiBorderLine       maLeft;             /// Left line format
     487                 :            :     ApiBorderLine       maRight;            /// Right line format
     488                 :            :     ApiBorderLine       maTop;              /// Top line format
     489                 :            :     ApiBorderLine       maBottom;           /// Bottom line format
     490                 :            :     ApiBorderLine       maTLtoBR;           /// Diagonal top-left to bottom-right line format.
     491                 :            :     ApiBorderLine       maBLtoTR;           /// Diagonal bottom-left to top-right line format.
     492                 :            :     bool                mbBorderUsed;       /// True = left/right/top/bottom line format used.
     493                 :            :     bool                mbDiagUsed;         /// True = diagonal line format used.
     494                 :            : 
     495                 :            :     explicit            ApiBorderData();
     496                 :            : 
     497                 :            :     /** Returns true, if any of the outer border lines is visible. */
     498                 :            :     bool                hasAnyOuterBorder() const;
     499                 :            : };
     500                 :            : 
     501                 :            : bool operator==( const ApiBorderData& rLeft, const ApiBorderData& rRight );
     502                 :            : 
     503                 :            : // ============================================================================
     504                 :            : 
     505 [ +  - ][ -  + ]:         48 : class Border : public WorkbookHelper
     506                 :            : {
     507                 :            : public:
     508                 :            :     explicit            Border( const WorkbookHelper& rHelper, bool bDxf );
     509                 :            : 
     510                 :            :     /** Sets global border attributes from the border element. */
     511                 :            :     void                importBorder( const AttributeList& rAttribs );
     512                 :            :     /** Sets border attributes for the border line with the passed element identifier. */
     513                 :            :     void                importStyle( sal_Int32 nElement, const AttributeList& rAttribs );
     514                 :            :     /** Sets color attributes for the border line with the passed element identifier. */
     515                 :            :     void                importColor( sal_Int32 nElement, const AttributeList& rAttribs );
     516                 :            : 
     517                 :            :     /** Imports the BORDER record from the passed stream. */
     518                 :            :     void                importBorder( SequenceInputStream& rStrm );
     519                 :            :     /** Imports a border from a DXF record from the passed stream. */
     520                 :            :     void                importDxfBorder( sal_Int32 nElement, SequenceInputStream& rStrm );
     521                 :            : 
     522                 :            :     /** Final processing after import of all style settings. */
     523                 :            :     void                finalizeImport();
     524                 :            : 
     525                 :            :     /** Returns the border model structure. */
     526                 :            :     inline const BorderModel& getModel() const { return maModel; }
     527                 :            :     /** Returns the converted API border data struct. */
     528                 :          3 :     inline const ApiBorderData& getApiData() const { return maApiData; }
     529                 :            : 
     530                 :            :     void                fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const;
     531                 :            : 
     532                 :            :     /** Writes all border attributes to the passed property map. */
     533                 :            :     void                writeToPropertyMap( PropertyMap& rPropMap ) const;
     534                 :            : 
     535                 :            :     bool                hasBorder() const;
     536                 :            : 
     537                 :            : private:
     538                 :            :     /** Returns the border line struct specified by the passed XML token identifier. */
     539                 :            :     BorderLineModel*    getBorderLine( sal_Int32 nElement );
     540                 :            : 
     541                 :            :     /** Converts border line data to an API struct, returns true, if the line is marked as used. */
     542                 :            :     bool                convertBorderLine(
     543                 :            :                             ::com::sun::star::table::BorderLine2& rBorderLine,
     544                 :            :                             const BorderLineModel& rModel );
     545                 :            : 
     546                 :            : private:
     547                 :            :     BorderModel         maModel;
     548                 :            :     ApiBorderData       maApiData;
     549                 :            :     bool                mbDxf;
     550                 :            : };
     551                 :            : 
     552                 :            : typedef ::boost::shared_ptr< Border > BorderRef;
     553                 :            : 
     554                 :            : // ============================================================================
     555                 :            : 
     556                 :            : /** Contains XML pattern fill attributes from the patternFill element. */
     557         [ +  - ]:         51 : struct PatternFillModel
     558                 :            : {
     559                 :            :     Color               maPatternColor;     /// Pattern foreground color.
     560                 :            :     Color               maFillColor;        /// Background fill color.
     561                 :            :     sal_Int32           mnPattern;          /// Pattern identifier (e.g. solid).
     562                 :            :     bool                mbPattColorUsed;    /// True = pattern foreground color used.
     563                 :            :     bool                mbFillColorUsed;    /// True = background fill color used.
     564                 :            :     bool                mbPatternUsed;      /// True = pattern used.
     565                 :            : 
     566                 :            :     explicit            PatternFillModel( bool bDxf );
     567                 :            : 
     568                 :            :     /** Sets the passed BIFF pattern identifier. */
     569                 :            :     void                setBiffPattern( sal_Int32 nPattern );
     570                 :            : };
     571                 :            : 
     572                 :            : // ----------------------------------------------------------------------------
     573                 :            : 
     574                 :            : /** Contains XML gradient fill attributes from the gradientFill element. */
     575                 :          0 : struct GradientFillModel
     576                 :            : {
     577                 :            :     typedef ::std::map< double, Color > ColorMap;
     578                 :            : 
     579                 :            :     sal_Int32           mnType;             /// Gradient type, linear or path.
     580                 :            :     double              mfAngle;            /// Rotation angle for type linear.
     581                 :            :     double              mfLeft;             /// Left convergence for type path.
     582                 :            :     double              mfRight;            /// Right convergence for type path.
     583                 :            :     double              mfTop;              /// Top convergence for type path.
     584                 :            :     double              mfBottom;           /// Bottom convergence for type path.
     585                 :            :     ColorMap            maColors;           /// Gradient colors.
     586                 :            : 
     587                 :            :     explicit            GradientFillModel();
     588                 :            : 
     589                 :            :     /** Reads BIFF12 gradient settings from a FILL or DXF record. */
     590                 :            :     void                readGradient( SequenceInputStream& rStrm );
     591                 :            :     /** Reads BIFF12 gradient stop settings from a FILL or DXF record. */
     592                 :            :     void                readGradientStop( SequenceInputStream& rStrm, bool bDxf );
     593                 :            : };
     594                 :            : 
     595                 :            : // ----------------------------------------------------------------------------
     596                 :            : 
     597                 :            : /** Contains API fill attributes. */
     598                 :            : struct ApiSolidFillData
     599                 :            : {
     600                 :            :     sal_Int32           mnColor;            /// Fill color.
     601                 :            :     bool                mbTransparent;      /// True = transparent area.
     602                 :            :     bool                mbUsed;             /// True = fill data is valid.
     603                 :            : 
     604                 :            :     explicit            ApiSolidFillData();
     605                 :            : };
     606                 :            : 
     607                 :            : bool operator==( const ApiSolidFillData& rLeft, const ApiSolidFillData& rRight );
     608                 :            : 
     609                 :            : // ============================================================================
     610                 :            : 
     611                 :            : /** Contains cell fill attributes, either a pattern fill or a gradient fill. */
     612 [ +  - ][ +  - ]:        102 : class Fill : public WorkbookHelper
                 [ -  + ]
     613                 :            : {
     614                 :            : public:
     615                 :            :     explicit            Fill( const WorkbookHelper& rHelper, bool bDxf );
     616                 :            : 
     617                 :            :     /** Sets attributes of a patternFill element. */
     618                 :            :     void                importPatternFill( const AttributeList& rAttribs );
     619                 :            :     /** Sets the pattern color from the fgColor element. */
     620                 :            :     void                importFgColor( const AttributeList& rAttribs );
     621                 :            :     /** Sets the background color from the bgColor element. */
     622                 :            :     void                importBgColor( const AttributeList& rAttribs );
     623                 :            :     /** Sets attributes of a gradientFill element. */
     624                 :            :     void                importGradientFill( const AttributeList& rAttribs );
     625                 :            :     /** Sets a color from the color element in a gradient fill. */
     626                 :            :     void                importColor( const AttributeList& rAttribs, double fPosition );
     627                 :            : 
     628                 :            :     /** Imports the FILL record from the passed stream. */
     629                 :            :     void                importFill( SequenceInputStream& rStrm );
     630                 :            :     /** Imports the fill pattern from a DXF record. */
     631                 :            :     void                importDxfPattern( SequenceInputStream& rStrm );
     632                 :            :     /** Imports the pattern color from a DXF record. */
     633                 :            :     void                importDxfFgColor( SequenceInputStream& rStrm );
     634                 :            :     /** Imports the background color from a DXF record. */
     635                 :            :     void                importDxfBgColor( SequenceInputStream& rStrm );
     636                 :            :     /** Imports gradient settings from a DXF record. */
     637                 :            :     void                importDxfGradient( SequenceInputStream& rStrm );
     638                 :            :     /** Imports gradient stop settings from a DXF record. */
     639                 :            :     void                importDxfStop( SequenceInputStream& rStrm );
     640                 :            : 
     641                 :            :     /** Final processing after import of all style settings. */
     642                 :            :     void                finalizeImport();
     643                 :            : 
     644                 :            :     /** Returns the fill pattern model structure, if extant. */
     645                 :            :     inline const PatternFillModel* getPatternModel() const { return mxPatternModel.get(); }
     646                 :            :     /** Returns the fill gradient model structure, if extant. */
     647                 :            :     inline const GradientFillModel* getGradientModel() const { return mxGradientModel.get(); }
     648                 :            :     /** Returns the converted API fill data struct. */
     649                 :          0 :     inline const ApiSolidFillData& getApiData() const { return maApiData; }
     650                 :            : 
     651                 :            :     void                fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs = false ) const;
     652                 :            :     /** Writes all fill attributes to the passed property map. */
     653                 :            :     void                writeToPropertyMap( PropertyMap& rPropMap ) const;
     654                 :            : 
     655                 :            : private:
     656                 :            :     typedef ::boost::shared_ptr< PatternFillModel >   PatternModelRef;
     657                 :            :     typedef ::boost::shared_ptr< GradientFillModel >  GradientModelRef;
     658                 :            : 
     659                 :            :     PatternModelRef     mxPatternModel;
     660                 :            :     GradientModelRef    mxGradientModel;
     661                 :            :     ApiSolidFillData    maApiData;
     662                 :            :     bool                mbDxf;
     663                 :            : };
     664                 :            : 
     665                 :            : typedef ::boost::shared_ptr< Fill > FillRef;
     666                 :            : 
     667                 :            : // ============================================================================
     668                 :            : 
     669                 :            : /** Contains all data for a cell format or cell style. */
     670                 :            : struct XfModel
     671                 :            : {
     672                 :            :     sal_Int32           mnStyleXfId;        /// Index to parent style XF.
     673                 :            :     sal_Int32           mnFontId;           /// Index to font data list.
     674                 :            :     sal_Int32           mnNumFmtId;         /// Index to number format list.
     675                 :            :     sal_Int32           mnBorderId;         /// Index to list of cell borders.
     676                 :            :     sal_Int32           mnFillId;           /// Index to list of cell areas.
     677                 :            :     bool                mbCellXf;           /// True = cell XF, false = style XF.
     678                 :            :     bool                mbFontUsed;         /// True = font index used.
     679                 :            :     bool                mbNumFmtUsed;       /// True = number format used.
     680                 :            :     bool                mbAlignUsed;        /// True = alignment used.
     681                 :            :     bool                mbProtUsed;         /// True = cell protection used.
     682                 :            :     bool                mbBorderUsed;       /// True = border data used.
     683                 :            :     bool                mbAreaUsed;         /// True = area data used.
     684                 :            : 
     685                 :            :     explicit            XfModel();
     686                 :            : };
     687                 :            : 
     688                 :            : bool operator==( const XfModel& rXfModel1,  const XfModel& rXfModel2 );
     689                 :            : 
     690                 :            : // ============================================================================
     691                 :            : 
     692                 :            : /** Represents a cell format or a cell style (called XF, extended format).
     693                 :            : 
     694                 :            :     This class stores the type (cell/style), the index to the parent style (if
     695                 :            :     it is a cell format) and all "attribute used" flags, which reflect the
     696                 :            :     state of specific attribute groups (true = user has changed the attributes)
     697                 :            :     and all formatting data.
     698                 :            :  */
     699 [ +  - ][ +  - ]:        930 : class Xf : public WorkbookHelper
         [ +  - ][ -  + ]
     700                 :            : {
     701                 :            :     friend bool operator==( const Xf& rXf1,  const Xf& rXf2 );
     702                 :            : public:
     703                 :            :     explicit            Xf( const WorkbookHelper& rHelper );
     704                 :            : 
     705                 :            :     /** Sets all attributes from the xf element. */
     706                 :            :     void                importXf( const AttributeList& rAttribs, bool bCellXf );
     707                 :            :     /** Sets all attributes from the alignment element. */
     708                 :            :     void                importAlignment( const AttributeList& rAttribs );
     709                 :            :     /** Sets all attributes from the protection element. */
     710                 :            :     void                importProtection( const AttributeList& rAttribs );
     711                 :            : 
     712                 :            :     /** Imports the XF record from the passed stream. */
     713                 :            :     void                importXf( SequenceInputStream& rStrm, bool bCellXf );
     714                 :            : 
     715                 :            :     /** Final processing after import of all style settings. */
     716                 :            :     void                finalizeImport();
     717                 :            : 
     718                 :            :     /** Returns true, if the XF is a cell XF, and false, if it is a style XF. */
     719                 :        642 :     inline bool         isCellXf() const { return maModel.mbCellXf; }
     720                 :            : 
     721                 :            :     /** Returns the referred font object. */
     722                 :            :     FontRef             getFont() const;
     723                 :            :     /** Returns the alignment data of this style. */
     724                 :        411 :     inline const Alignment& getAlignment() const { return maAlignment; }
     725                 :            :     /** Returns the cell protection data of this style. */
     726                 :            :     inline const Protection& getProtection() const { return maProtection; }
     727                 :            : 
     728                 :            :     void  writeToMarkData( ::ScMarkData& rMarkData, sal_Int32 nNumFmtId  );
     729                 :            :     /** Writes all formatting attributes to the passed property map. */
     730                 :            :     void                writeToPropertyMap( PropertyMap& rPropMap ) const;
     731                 :            :     /** Writes all formatting attributes to the passed property set. */
     732                 :            :     void                writeToPropertySet( PropertySet& rPropSet ) const;
     733                 :            : 
     734                 :            :     const ::ScPatternAttr& createPattern( bool bSkipPoolDefs = false );
     735                 :            : 
     736                 :            : private:
     737                 :            :     typedef ::std::auto_ptr< ::ScPatternAttr > ScPatternAttrPtr;
     738                 :            : 
     739                 :            :     ScPatternAttrPtr    mpPattern;          /// Calc item set.
     740                 :            : 
     741                 :            :     XfModel             maModel;            /// Cell XF or style XF model data.
     742                 :            :     Alignment           maAlignment;        /// Cell alignment data.
     743                 :            :     Protection          maProtection;       /// Cell protection data.
     744                 :            :     sal_Int32           meRotationRef;      /// Rotation reference dependent on border.
     745                 :            :     ::ScStyleSheet*       mpStyleSheet;       /// Calc cell style sheet.
     746                 :            : };
     747                 :            : 
     748                 :            : bool operator==( const Xf& rXf1,  const Xf& rXf2 );
     749                 :            : 
     750                 :            : typedef ::boost::shared_ptr< Xf > XfRef;
     751                 :            : 
     752                 :            : // ============================================================================
     753                 :            : 
     754 [ #  # ][ #  # ]:          0 : class Dxf : public WorkbookHelper
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     755                 :            : {
     756                 :            : public:
     757                 :            :     explicit            Dxf( const WorkbookHelper& rHelper );
     758                 :            : 
     759                 :            :     /** Creates a new empty font object. */
     760                 :            :     FontRef             createFont( bool bAlwaysNew = true );
     761                 :            :     /** Creates a new empty border object. */
     762                 :            :     BorderRef           createBorder( bool bAlwaysNew = true );
     763                 :            :     /** Creates a new empty fill object. */
     764                 :            :     FillRef             createFill( bool bAlwaysNew = true );
     765                 :            : 
     766                 :            :     /** Inserts a new number format code. */
     767                 :            :     void                importNumFmt( const AttributeList& rAttribs );
     768                 :            : 
     769                 :            :     /** Imports the DXF record from the passed stream. */
     770                 :            :     void                importDxf( SequenceInputStream& rStrm );
     771                 :            : 
     772                 :            :     /** Final processing after import of all style settings. */
     773                 :            :     void                finalizeImport();
     774                 :            : 
     775                 :            :     /** Writes all formatting attributes to the passed property map. */
     776                 :            :     void                writeToPropertyMap( PropertyMap& rPropMap ) const;
     777                 :            :     /** Writes all formatting attributes to the passed property set. */
     778                 :            :     void                writeToPropertySet( PropertySet& rPropSet ) const;
     779                 :            : 
     780                 :            : private:
     781                 :            :     FontRef             mxFont;             /// Font data.
     782                 :            :     NumberFormatRef     mxNumFmt;           /// Number format data.
     783                 :            :     AlignmentRef        mxAlignment;        /// Alignment data.
     784                 :            :     ProtectionRef       mxProtection;       /// Protection data.
     785                 :            :     BorderRef           mxBorder;           /// Border data.
     786                 :            :     FillRef             mxFill;             /// Fill data.
     787                 :            : };
     788                 :            : 
     789                 :            : typedef ::boost::shared_ptr< Dxf > DxfRef;
     790                 :            : 
     791                 :            : // ============================================================================
     792                 :            : 
     793                 :            : /** Contains attributes of a cell style, e.g. from the cellStyle element. */
     794                 :        126 : struct CellStyleModel
     795                 :            : {
     796                 :            :     ::rtl::OUString     maName;             /// Cell style name.
     797                 :            :     sal_Int32           mnXfId;             /// Formatting for this cell style.
     798                 :            :     sal_Int32           mnBuiltinId;        /// Identifier for builtin styles.
     799                 :            :     sal_Int32           mnLevel;            /// Level for builtin column/row styles.
     800                 :            :     bool                mbBuiltin;          /// True = builtin style.
     801                 :            :     bool                mbCustom;           /// True = customized builtin style.
     802                 :            :     bool                mbHidden;           /// True = style not visible in GUI.
     803                 :            : 
     804                 :            :     explicit            CellStyleModel();
     805                 :            : 
     806                 :            :     /** Returns true, if this style is a builtin style. */
     807                 :            :     bool                isBuiltin() const;
     808                 :            :     /** Returns true, if this style represents the default document cell style. */
     809                 :            :     bool                isDefaultStyle() const;
     810                 :            : };
     811                 :            : 
     812                 :            : // ============================================================================
     813                 :            : 
     814         [ -  + ]:        252 : class CellStyle : public WorkbookHelper
     815                 :            : {
     816                 :            : public:
     817                 :            :     explicit            CellStyle( const WorkbookHelper& rHelper );
     818                 :            : 
     819                 :            :     /** Imports passed attributes from the cellStyle element. */
     820                 :            :     void                importCellStyle( const AttributeList& rAttribs );
     821                 :            :     /** Imports style settings from a CELLSTYLE record. */
     822                 :            :     void                importCellStyle( SequenceInputStream& rStrm );
     823                 :            : 
     824                 :            :     /** Creates the style sheet in the document described by this cell style object. */
     825                 :            :     void                createCellStyle();
     826                 :            :     /** Stores tha passed final style name and creates the cell style, if it is
     827                 :            :         user-defined or modified built-in. */
     828                 :            :     void                finalizeImport( const ::rtl::OUString& rFinalName );
     829                 :            : 
     830                 :            :     /** Returns the cell style model structure. */
     831                 :        414 :     inline const CellStyleModel& getModel() const { return maModel; }
     832                 :            :     /** Returns the final style name used in the document. */
     833                 :        120 :     inline const ::rtl::OUString& getFinalStyleName() const { return maFinalName; }
     834                 :            : 
     835                 :            : private:
     836                 :            :     CellStyleModel      maModel;
     837                 :            :     ::rtl::OUString     maFinalName;        /// Final style name used in API.
     838                 :            :     bool                mbCreated;          /// True = style sheet created.
     839                 :            :     ::ScStyleSheet*     mpStyleSheet;       /// Calc cell style sheet.
     840                 :            : 
     841                 :            : };
     842                 :            : 
     843                 :            : typedef ::boost::shared_ptr< CellStyle > CellStyleRef;
     844                 :            : 
     845                 :            : // ============================================================================
     846                 :            : 
     847 [ +  - ][ -  + ]:         24 : class CellStyleBuffer : public WorkbookHelper
     848                 :            : {
     849                 :            : public:
     850                 :            :     explicit            CellStyleBuffer( const WorkbookHelper& rHelper );
     851                 :            : 
     852                 :            :     /** Appends and returns a new named cell style object. */
     853                 :            :     CellStyleRef        importCellStyle( const AttributeList& rAttribs );
     854                 :            :     /** Imports the CELLSTYLE record from the passed stream. */
     855                 :            :     CellStyleRef        importCellStyle( SequenceInputStream& rStrm );
     856                 :            : 
     857                 :            :     /** Final processing after import of all style settings. */
     858                 :            :     void                finalizeImport();
     859                 :            : 
     860                 :            :     /** Returns the XF identifier associated to the default cell style. */
     861                 :            :     sal_Int32           getDefaultXfId() const;
     862                 :            :     /** Returns the default style sheet for unused cells. */
     863                 :            :     ::rtl::OUString     getDefaultStyleName() const;
     864                 :            :     /** Creates the style sheet described by the style XF with the passed identifier. */
     865                 :            :     ::rtl::OUString     createCellStyle( sal_Int32 nXfId ) const;
     866                 :            : 
     867                 :            : private:
     868                 :            :     /** Inserts the passed cell style object into the internal maps. */
     869                 :            :     void                insertCellStyle( CellStyleRef xCellStyle );
     870                 :            :     /** Creates the style sheet described by the passed cell style object. */
     871                 :            :     ::rtl::OUString     createCellStyle( const CellStyleRef& rxCellStyle ) const;
     872                 :            : 
     873                 :            : private:
     874                 :            :     typedef RefVector< CellStyle >          CellStyleVector;
     875                 :            :     typedef RefMap< sal_Int32, CellStyle >  CellStyleXfIdMap;
     876                 :            : 
     877                 :            :     CellStyleVector     maBuiltinStyles;    /// All built-in cell styles.
     878                 :            :     CellStyleVector     maUserStyles;       /// All user defined cell styles.
     879                 :            :     CellStyleXfIdMap    maStylesByXf;       /// All cell styles, mapped by XF identifier.
     880                 :            :     CellStyleRef        mxDefStyle;         /// Default cell style.
     881                 :            : };
     882                 :            : 
     883                 :            : // ============================================================================
     884                 :            : 
     885                 :            : struct AutoFormatModel
     886                 :            : {
     887                 :            :     sal_Int32           mnAutoFormatId;     /// Index of predefined autoformatting.
     888                 :            :     bool                mbApplyNumFmt;      /// True = apply number format from autoformatting.
     889                 :            :     bool                mbApplyFont;        /// True = apply font from autoformatting.
     890                 :            :     bool                mbApplyAlignment;   /// True = apply alignment from autoformatting.
     891                 :            :     bool                mbApplyBorder;      /// True = apply border from autoformatting.
     892                 :            :     bool                mbApplyFill;        /// True = apply fill from autoformatting.
     893                 :            :     bool                mbApplyProtection;  /// True = apply protection from autoformatting.
     894                 :            : 
     895                 :            :     explicit            AutoFormatModel();
     896                 :            : };
     897                 :            : 
     898                 :            : // ============================================================================
     899                 :            : 
     900         [ +  - ]:         48 : class StylesBuffer : public WorkbookHelper
           [ +  -  #  # ]
         [ +  - ][ -  + ]
     901                 :            : {
     902                 :            : public:
     903                 :            :     explicit            StylesBuffer( const WorkbookHelper& rHelper );
     904                 :            : 
     905                 :            :     /** Creates a new empty font object.
     906                 :            :         @param opnFontId  (out-param) The identifier of the new font object. */
     907                 :            :     FontRef             createFont( sal_Int32* opnFontId = 0 );
     908                 :            :     /** Creates a number format. */
     909                 :            :     NumberFormatRef     createNumFmt( sal_Int32 nNumFmtId, const ::rtl::OUString& rFmtCode );
     910                 :            :     /** Creates a new empty border object.
     911                 :            :         @param opnBorderId  (out-param) The identifier of the new border object. */
     912                 :            :     BorderRef           createBorder( sal_Int32* opnBorderId = 0 );
     913                 :            :     /** Creates a new empty fill object.
     914                 :            :         @param opnFillId  (out-param) The identifier of the new fill object. */
     915                 :            :     FillRef             createFill( sal_Int32* opnFillId = 0 );
     916                 :            :     /** Creates a new empty cell formatting object.
     917                 :            :         @param opnXfId  (out-param) The identifier of the new XF object. */
     918                 :            :     XfRef               createCellXf( sal_Int32* opnXfId = 0 );
     919                 :            :     /** Creates a new empty style formatting object.
     920                 :            :         @param opnXfId  (out-param) The identifier of the new XF object. */
     921                 :            :     XfRef               createStyleXf( sal_Int32* opnXfId = 0 );
     922                 :            :     /** Creates a new empty differential formatting object.
     923                 :            :         @param opnDxfId  (out-param) The identifier of the new DXF object. */
     924                 :            :     DxfRef              createDxf( sal_Int32* opnDxfId = 0 );
     925                 :            : 
     926                 :            :     /** Appends a new color to the color palette. */
     927                 :            :     void                importPaletteColor( const AttributeList& rAttribs );
     928                 :            :     /** Inserts a new number format code. */
     929                 :            :     NumberFormatRef     importNumFmt( const AttributeList& rAttribs );
     930                 :            :     /** Appends and returns a new named cell style object. */
     931                 :            :     CellStyleRef        importCellStyle( const AttributeList& rAttribs );
     932                 :            : 
     933                 :            :     /** Appends a new color to the color palette. */
     934                 :            :     void                importPaletteColor( SequenceInputStream& rStrm );
     935                 :            :     /** Imports the NUMFMT record from the passed stream. */
     936                 :            :     void                importNumFmt( SequenceInputStream& rStrm );
     937                 :            :     /** Imports the CELLSTYLE record from the passed stream. */
     938                 :            :     void                importCellStyle( SequenceInputStream& rStrm );
     939                 :            : 
     940                 :            :     /** Final processing after import of all style settings. */
     941                 :            :     void                finalizeImport();
     942                 :            : 
     943                 :            :     /** Returns the palette color with the specified index. */
     944                 :            :     sal_Int32           getPaletteColor( sal_Int32 nIndex ) const;
     945                 :            :     /** Returns the specified font object. */
     946                 :            :     FontRef             getFont( sal_Int32 nFontId ) const;
     947                 :            :     /** Returns the specified border object. */
     948                 :            :     BorderRef           getBorder( sal_Int32 nBorderId ) const;
     949                 :            :     /** Returns the specified cell format object. */
     950                 :            :     XfRef               getCellXf( sal_Int32 nXfId ) const;
     951                 :            :     /** Returns the specified style format object. */
     952                 :            :     XfRef               getStyleXf( sal_Int32 nXfId ) const;
     953                 :            : 
     954                 :            :     /** Returns the font object of the specified cell XF. */
     955                 :            :     FontRef             getFontFromCellXf( sal_Int32 nXfId ) const;
     956                 :            :     /** Returns the default application font (used in the "Normal" cell style). */
     957                 :            :     FontRef             getDefaultFont() const;
     958                 :            :     /** Returns the model of the default application font (used in the "Normal" cell style). */
     959                 :            :     const FontModel&    getDefaultFontModel() const;
     960                 :            : 
     961                 :            :     /** Returns true, if the specified borders are equal. */
     962                 :            :     bool                equalBorders( sal_Int32 nBorderId1, sal_Int32 nBorderId2 ) const;
     963                 :            :     /** Returns true, if the specified fills are equal. */
     964                 :            :     bool                equalFills( sal_Int32 nFillId1, sal_Int32 nFillId2 ) const;
     965                 :            : 
     966                 :            :     /** Returns the default style sheet for unused cells. */
     967                 :            :     ::rtl::OUString     getDefaultStyleName() const;
     968                 :            :     /** Creates the style sheet described by the style XF with the passed identifier. */
     969                 :            :     ::rtl::OUString     createCellStyle( sal_Int32 nXfId ) const;
     970                 :            :     /** Creates the style sheet described by the DXF with the passed identifier. */
     971                 :            :     ::rtl::OUString     createDxfStyle( sal_Int32 nDxfId ) const;
     972                 :            : 
     973                 :            :     void                writeFontToItemSet( SfxItemSet& rItemSet, sal_Int32 nFontId, bool bSkipPoolDefs = false ) const;
     974                 :            :     /** Writes the font attributes of the specified font data to the passed property map. */
     975                 :            :     void                writeFontToPropertyMap( PropertyMap& rPropMap, sal_Int32 nFontId ) const;
     976                 :            :     void                writeNumFmtToItemSet( SfxItemSet& rItemSet, sal_Int32 nNumFmtId, bool bSkipPoolDefs = false ) const;
     977                 :            :     /** Writes the specified number format to the passed property map. */
     978                 :            :     void                writeNumFmtToPropertyMap( PropertyMap& rPropMap, sal_Int32 nNumFmtId ) const;
     979                 :            :     void                writeBorderToItemSet( SfxItemSet& rItemSet, sal_Int32 nBorderId, bool bSkipPoolDefs = false ) const;
     980                 :            :     /** Writes the border attributes of the specified border data to the passed property map. */
     981                 :            :     void                writeBorderToPropertyMap( PropertyMap& rPropMap, sal_Int32 nBorderId ) const;
     982                 :            :     /** Writes the fill attributes of the specified fill data to the passed property map. */
     983                 :            :     void                writeFillToItemSet( SfxItemSet& rItemSet, sal_Int32 nFillId, bool bSkipPoolDefs = false ) const;
     984                 :            :     void                writeFillToPropertyMap( PropertyMap& rPropMap, sal_Int32 nFillId ) const;
     985                 :            :     void                writeCellXfToMarkData( ::ScMarkData& rMark, sal_Int32 nXfId, sal_Int32 nNumFmtId );
     986                 :            : 
     987                 :            :     /** Writes the cell formatting attributes of the specified XF to the passed property set. */
     988                 :            :     void                writeCellXfToPropertySet( PropertySet& rPropSet, sal_Int32 nXfId ) const;
     989                 :            :     /** Writes the cell formatting attributes of the specified style XF to the passed property set. */
     990                 :            :     void                writeStyleXfToPropertySet( PropertySet& rPropSet, sal_Int32 nXfId ) const;
     991                 :            : 
     992                 :            :     bool                hasBorder( sal_Int32 nBorderId ) const;
     993                 :            : private:
     994                 :            :     typedef RefVector< Font >                           FontVector;
     995                 :            :     typedef RefVector< Border >                         BorderVector;
     996                 :            :     typedef RefVector< Fill >                           FillVector;
     997                 :            :     typedef RefVector< Xf >                             XfVector;
     998                 :            :     typedef RefVector< Dxf >                            DxfVector;
     999                 :            :     typedef ::std::map< sal_Int32, ::rtl::OUString >    DxfStyleMap;
    1000                 :            : 
    1001                 :            :     ColorPalette        maPalette;          /// Color palette.
    1002                 :            :     FontVector          maFonts;            /// List of font objects.
    1003                 :            :     NumberFormatsBuffer maNumFmts;          /// List of all number format codes.
    1004                 :            :     BorderVector        maBorders;          /// List of cell border objects.
    1005                 :            :     FillVector          maFills;            /// List of cell area fill objects.
    1006                 :            :     XfVector            maCellXfs;          /// List of cell formats.
    1007                 :            :     XfVector            maStyleXfs;         /// List of cell styles.
    1008                 :            :     CellStyleBuffer     maCellStyles;       /// All built-in and user defined cell styles.
    1009                 :            :     DxfVector           maDxfs;             /// List of differential cell styles.
    1010                 :            :     mutable DxfStyleMap maDxfStyles;        /// Maps DXF identifiers to Calc style sheet names.
    1011                 :            : };
    1012                 :            : 
    1013                 :            : // ============================================================================
    1014                 :            : 
    1015                 :            : } // namespace xls
    1016                 :            : } // namespace oox
    1017                 :            : 
    1018                 :            : #endif
    1019                 :            : 
    1020                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10