LCOV - code coverage report
Current view: top level - sc/source/filter/oox - stylesbuffer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 908 1510 60.1 %
Date: 2012-08-25 Functions: 133 198 67.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 702 2019 34.8 %

           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                 :            : #include "stylesbuffer.hxx"
      30                 :            : 
      31                 :            : #include <com/sun/star/awt/FontDescriptor.hpp>
      32                 :            : #include <com/sun/star/awt/FontFamily.hpp>
      33                 :            : #include <com/sun/star/awt/FontPitch.hpp>
      34                 :            : #include <com/sun/star/awt/FontSlant.hpp>
      35                 :            : #include <com/sun/star/awt/FontStrikeout.hpp>
      36                 :            : #include <com/sun/star/awt/FontType.hpp>
      37                 :            : #include <com/sun/star/awt/FontWeight.hpp>
      38                 :            : #include <com/sun/star/awt/FontUnderline.hpp>
      39                 :            : #include <com/sun/star/awt/XDevice.hpp>
      40                 :            : #include <com/sun/star/awt/XFont2.hpp>
      41                 :            : #include <com/sun/star/container/XIndexAccess.hpp>
      42                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      43                 :            : #include <com/sun/star/style/XStyle.hpp>
      44                 :            : #include <com/sun/star/text/WritingMode2.hpp>
      45                 :            : #include <com/sun/star/text/XText.hpp>
      46                 :            : #include <com/sun/star/table/CellVertJustify2.hpp>
      47                 :            : #include <com/sun/star/table/CellJustifyMethod.hpp>
      48                 :            : #include <com/sun/star/table/TableBorder.hpp>
      49                 :            : #include <editeng/justifyitem.hxx>
      50                 :            : #include <editeng/frmdiritem.hxx>
      51                 :            : #include <editeng/fontitem.hxx>
      52                 :            : #include <editeng/postitem.hxx>
      53                 :            : #include <editeng/fhgtitem.hxx>
      54                 :            : #include <editeng/wghtitem.hxx>
      55                 :            : #include <editeng/udlnitem.hxx>
      56                 :            : #include <editeng/colritem.hxx>
      57                 :            : #include <editeng/crsditem.hxx>
      58                 :            : #include <editeng/cntritem.hxx>
      59                 :            : #include <editeng/escpitem.hxx>
      60                 :            : #include <editeng/shdditem.hxx>
      61                 :            : #include <editeng/eeitem.hxx>
      62                 :            : #include <editeng/boxitem.hxx>
      63                 :            : #include <editeng/bolnitem.hxx>
      64                 :            : #include <editeng/brshitem.hxx>
      65                 :            : #include <svx/rotmodit.hxx>
      66                 :            : #include <tools/fontenum.hxx>
      67                 :            : #include <toolkit/helper/vclunohelper.hxx>
      68                 :            : #include <rtl/tencinfo.h>
      69                 :            : #include <rtl/ustrbuf.hxx>
      70                 :            : #include <oox/core/filterbase.hxx>
      71                 :            : #include <oox/helper/attributelist.hxx>
      72                 :            : #include <oox/helper/containerhelper.hxx>
      73                 :            : #include <oox/helper/propertymap.hxx>
      74                 :            : #include <oox/helper/propertyset.hxx>
      75                 :            : #include "biffinputstream.hxx"
      76                 :            : #include "condformatbuffer.hxx"
      77                 :            : #include "excelhandlers.hxx"
      78                 :            : #include "themebuffer.hxx"
      79                 :            : #include "unitconverter.hxx"
      80                 :            : #include "document.hxx"
      81                 :            : #include "stlpool.hxx"
      82                 :            : #include "docpool.hxx"
      83                 :            : #include "ftools.hxx"
      84                 :            : #include "scitems.hxx"
      85                 :            : #include "attrib.hxx"
      86                 :            : #include "globstr.hrc"
      87                 :            : 
      88                 :            : using ::com::sun::star::table::BorderLine2;
      89                 :            : namespace oox {
      90                 :            : namespace xls {
      91                 :            : 
      92                 :            : // ============================================================================
      93                 :            : 
      94                 :            : using namespace ::com::sun::star::awt;
      95                 :            : using namespace ::com::sun::star::container;
      96                 :            : using namespace ::com::sun::star::style;
      97                 :            : using namespace ::com::sun::star::table;
      98                 :            : using namespace ::com::sun::star::text;
      99                 :            : using namespace ::com::sun::star::uno;
     100                 :            : 
     101                 :            : using ::oox::core::FilterBase;
     102                 :            : using ::rtl::OUString;
     103                 :            : using ::rtl::OUStringBuffer;
     104                 :            : 
     105                 :            : // ============================================================================
     106                 :            : 
     107                 :            : namespace {
     108                 :            : 
     109                 :            : // OOXML constants ------------------------------------------------------------
     110                 :            : 
     111                 :            : // OOXML predefined color indexes (also used in BIFF3-BIFF8)
     112                 :            : const sal_Int32 OOX_COLOR_USEROFFSET        = 0;        /// First user defined color in palette (OOXML/BIFF12).
     113                 :            : const sal_Int32 BIFF_COLOR_USEROFFSET       = 8;        /// First user defined color in palette (BIFF3-BIFF8).
     114                 :            : 
     115                 :            : // OOXML font family (also used in BIFF)
     116                 :            : const sal_Int32 OOX_FONTFAMILY_NONE         = 0;
     117                 :            : const sal_Int32 OOX_FONTFAMILY_ROMAN        = 1;
     118                 :            : const sal_Int32 OOX_FONTFAMILY_SWISS        = 2;
     119                 :            : const sal_Int32 OOX_FONTFAMILY_MODERN       = 3;
     120                 :            : const sal_Int32 OOX_FONTFAMILY_SCRIPT       = 4;
     121                 :            : const sal_Int32 OOX_FONTFAMILY_DECORATIVE   = 5;
     122                 :            : 
     123                 :            : // OOXML cell text direction (also used in BIFF)
     124                 :            : const sal_Int32 OOX_XF_TEXTDIR_CONTEXT      = 0;
     125                 :            : const sal_Int32 OOX_XF_TEXTDIR_LTR          = 1;
     126                 :            : const sal_Int32 OOX_XF_TEXTDIR_RTL          = 2;
     127                 :            : 
     128                 :            : // OOXML cell rotation (also used in BIFF)
     129                 :            : const sal_Int32 OOX_XF_ROTATION_NONE        = 0;
     130                 :            : const sal_Int32 OOX_XF_ROTATION_90CCW       = 90;
     131                 :            : const sal_Int32 OOX_XF_ROTATION_90CW        = 180;
     132                 :            : const sal_Int32 OOX_XF_ROTATION_STACKED     = 255;
     133                 :            : 
     134                 :            : // OOXML cell indentation
     135                 :            : const sal_Int32 OOX_XF_INDENT_NONE          = 0;
     136                 :            : 
     137                 :            : // OOXML built-in cell styles (also used in BIFF)
     138                 :            : const sal_Int32 OOX_STYLE_NORMAL            = 0;        /// Default cell style.
     139                 :            : const sal_Int32 OOX_STYLE_ROWLEVEL          = 1;        /// RowLevel_x cell style.
     140                 :            : const sal_Int32 OOX_STYLE_COLLEVEL          = 2;        /// ColLevel_x cell style.
     141                 :            : 
     142                 :            : const sal_Int32 OOX_STYLE_LEVELCOUNT        = 7;        /// Number of outline level styles.
     143                 :            : 
     144                 :            : // BIFF12 constants -----------------------------------------------------------
     145                 :            : 
     146                 :            : // BIFF12 color types
     147                 :            : const sal_uInt8 BIFF12_COLOR_AUTO           = 0;
     148                 :            : const sal_uInt8 BIFF12_COLOR_INDEXED        = 1;
     149                 :            : const sal_uInt8 BIFF12_COLOR_RGB            = 2;
     150                 :            : const sal_uInt8 BIFF12_COLOR_THEME          = 3;
     151                 :            : 
     152                 :            : // BIFF12 diagonal borders
     153                 :            : const sal_uInt8 BIFF12_BORDER_DIAG_TLBR     = 0x01;     /// Top-left to bottom-right.
     154                 :            : const sal_uInt8 BIFF12_BORDER_DIAG_BLTR     = 0x02;     /// Bottom-left to top-right.
     155                 :            : 
     156                 :            : // BIFF12 gradient fill
     157                 :            : const sal_Int32 BIFF12_FILL_GRADIENT        = 40;
     158                 :            : 
     159                 :            : // BIFF12 XF flags
     160                 :            : const sal_uInt32 BIFF12_XF_WRAPTEXT         = 0x00400000;
     161                 :            : const sal_uInt32 BIFF12_XF_JUSTLASTLINE     = 0x00800000;
     162                 :            : const sal_uInt32 BIFF12_XF_SHRINK           = 0x01000000;
     163                 :            : const sal_uInt32 BIFF12_XF_LOCKED           = 0x10000000;
     164                 :            : const sal_uInt32 BIFF12_XF_HIDDEN           = 0x20000000;
     165                 :            : 
     166                 :            : // BIFF12 XF attribute used flags
     167                 :            : const sal_uInt16 BIFF12_XF_NUMFMT_USED      = 0x0001;
     168                 :            : const sal_uInt16 BIFF12_XF_FONT_USED        = 0x0002;
     169                 :            : const sal_uInt16 BIFF12_XF_ALIGN_USED       = 0x0004;
     170                 :            : const sal_uInt16 BIFF12_XF_BORDER_USED      = 0x0008;
     171                 :            : const sal_uInt16 BIFF12_XF_AREA_USED        = 0x0010;
     172                 :            : const sal_uInt16 BIFF12_XF_PROT_USED        = 0x0020;
     173                 :            : 
     174                 :            : // BIFF12 DXF constants
     175                 :            : const sal_uInt16 BIFF12_DXF_FILL_PATTERN    = 0;
     176                 :            : const sal_uInt16 BIFF12_DXF_FILL_FGCOLOR    = 1;
     177                 :            : const sal_uInt16 BIFF12_DXF_FILL_BGCOLOR    = 2;
     178                 :            : const sal_uInt16 BIFF12_DXF_FILL_GRADIENT   = 3;
     179                 :            : const sal_uInt16 BIFF12_DXF_FILL_STOP       = 4;
     180                 :            : const sal_uInt16 BIFF12_DXF_FONT_COLOR      = 5;
     181                 :            : const sal_uInt16 BIFF12_DXF_BORDER_TOP      = 6;
     182                 :            : const sal_uInt16 BIFF12_DXF_BORDER_BOTTOM   = 7;
     183                 :            : const sal_uInt16 BIFF12_DXF_BORDER_LEFT     = 8;
     184                 :            : const sal_uInt16 BIFF12_DXF_BORDER_RIGHT    = 9;
     185                 :            : const sal_uInt16 BIFF12_DXF_BORDER_DIAG     = 10;
     186                 :            : const sal_uInt16 BIFF12_DXF_BORDER_VERT     = 11;
     187                 :            : const sal_uInt16 BIFF12_DXF_BORDER_HOR      = 12;
     188                 :            : const sal_uInt16 BIFF12_DXF_BORDER_DIAGUP   = 13;
     189                 :            : const sal_uInt16 BIFF12_DXF_BORDER_DIAGDOWN = 14;
     190                 :            : const sal_uInt16 BIFF12_DXF_FONT_NAME       = 24;
     191                 :            : const sal_uInt16 BIFF12_DXF_FONT_WEIGHT     = 25;
     192                 :            : const sal_uInt16 BIFF12_DXF_FONT_UNDERLINE  = 26;
     193                 :            : const sal_uInt16 BIFF12_DXF_FONT_ESCAPEMENT = 27;
     194                 :            : const sal_uInt16 BIFF12_DXF_FONT_ITALIC     = 28;
     195                 :            : const sal_uInt16 BIFF12_DXF_FONT_STRIKE     = 29;
     196                 :            : const sal_uInt16 BIFF12_DXF_FONT_OUTLINE    = 30;
     197                 :            : const sal_uInt16 BIFF12_DXF_FONT_SHADOW     = 31;
     198                 :            : const sal_uInt16 BIFF12_DXF_FONT_CONDENSE   = 32;
     199                 :            : const sal_uInt16 BIFF12_DXF_FONT_EXTEND     = 33;
     200                 :            : const sal_uInt16 BIFF12_DXF_FONT_CHARSET    = 34;
     201                 :            : const sal_uInt16 BIFF12_DXF_FONT_FAMILY     = 35;
     202                 :            : const sal_uInt16 BIFF12_DXF_FONT_HEIGHT     = 36;
     203                 :            : const sal_uInt16 BIFF12_DXF_FONT_SCHEME     = 37;
     204                 :            : const sal_uInt16 BIFF12_DXF_NUMFMT_CODE     = 38;
     205                 :            : const sal_uInt16 BIFF12_DXF_NUMFMT_ID       = 41;
     206                 :            : 
     207                 :            : // BIFF12 CELLSTYLE flags
     208                 :            : const sal_uInt16 BIFF12_CELLSTYLE_BUILTIN   = 0x0001;
     209                 :            : const sal_uInt16 BIFF12_CELLSTYLE_HIDDEN    = 0x0002;
     210                 :            : const sal_uInt16 BIFF12_CELLSTYLE_CUSTOM    = 0x0004;
     211                 :            : 
     212                 :            : // BIFF constants -------------------------------------------------------------
     213                 :            : 
     214                 :            : // BIFF predefined color indexes
     215                 :            : const sal_uInt16 BIFF2_COLOR_BLACK          = 0;        /// Black (text) in BIFF2.
     216                 :            : const sal_uInt16 BIFF2_COLOR_WHITE          = 1;        /// White (background) in BIFF2.
     217                 :            : 
     218                 :            : // BIFF font flags, also used in BIFF12
     219                 :            : const sal_uInt16 BIFF_FONTFLAG_BOLD         = 0x0001;
     220                 :            : const sal_uInt16 BIFF_FONTFLAG_ITALIC       = 0x0002;
     221                 :            : const sal_uInt16 BIFF_FONTFLAG_UNDERLINE    = 0x0004;
     222                 :            : const sal_uInt16 BIFF_FONTFLAG_STRIKEOUT    = 0x0008;
     223                 :            : const sal_uInt16 BIFF_FONTFLAG_OUTLINE      = 0x0010;
     224                 :            : const sal_uInt16 BIFF_FONTFLAG_SHADOW       = 0x0020;
     225                 :            : const sal_uInt16 BIFF_FONTFLAG_CONDENSE     = 0x0040;
     226                 :            : 
     227                 :            : // BIFF font weight
     228                 :            : const sal_uInt16 BIFF_FONTWEIGHT_BOLD       = 450;
     229                 :            : 
     230                 :            : // BIFF font underline, also used in BIFF12
     231                 :            : const sal_uInt8 BIFF_FONTUNDERL_NONE        = 0;
     232                 :            : const sal_uInt8 BIFF_FONTUNDERL_SINGLE      = 1;
     233                 :            : const sal_uInt8 BIFF_FONTUNDERL_DOUBLE      = 2;
     234                 :            : const sal_uInt8 BIFF_FONTUNDERL_SINGLE_ACC  = 33;
     235                 :            : const sal_uInt8 BIFF_FONTUNDERL_DOUBLE_ACC  = 34;
     236                 :            : 
     237                 :            : // BIFF XF flags
     238                 :            : const sal_uInt16 BIFF_XF_LOCKED             = 0x0001;
     239                 :            : const sal_uInt16 BIFF_XF_HIDDEN             = 0x0002;
     240                 :            : const sal_uInt16 BIFF_XF_STYLE              = 0x0004;
     241                 :            : const sal_uInt16 BIFF_XF_STYLEPARENT        = 0x0FFF;   /// Styles don't have a parent.
     242                 :            : const sal_uInt16 BIFF_XF_WRAPTEXT           = 0x0008;   /// Automatic line break.
     243                 :            : const sal_uInt16 BIFF_XF_JUSTLASTLINE       = 0x0080;
     244                 :            : const sal_uInt16 BIFF_XF_SHRINK             = 0x0010;   /// Shrink to fit into cell.
     245                 :            : const sal_uInt16 BIFF_XF_MERGE              = 0x0020;
     246                 :            : 
     247                 :            : // BIFF XF attribute used flags
     248                 :            : const sal_uInt8 BIFF_XF_NUMFMT_USED         = 0x01;
     249                 :            : const sal_uInt8 BIFF_XF_FONT_USED           = 0x02;
     250                 :            : const sal_uInt8 BIFF_XF_ALIGN_USED          = 0x04;
     251                 :            : const sal_uInt8 BIFF_XF_BORDER_USED         = 0x08;
     252                 :            : const sal_uInt8 BIFF_XF_AREA_USED           = 0x10;
     253                 :            : const sal_uInt8 BIFF_XF_PROT_USED           = 0x20;
     254                 :            : 
     255                 :            : // BIFF XF text orientation
     256                 :            : const sal_uInt8 BIFF_XF_ORIENT_NONE         = 0;
     257                 :            : const sal_uInt8 BIFF_XF_ORIENT_STACKED      = 1;        /// Stacked top to bottom.
     258                 :            : const sal_uInt8 BIFF_XF_ORIENT_90CCW        = 2;        /// 90 degr. counterclockwise.
     259                 :            : const sal_uInt8 BIFF_XF_ORIENT_90CW         = 3;        /// 90 degr. clockwise.
     260                 :            : 
     261                 :            : // BIFF XF line styles
     262                 :            : const sal_uInt8 BIFF_LINE_NONE              = 0;
     263                 :            : const sal_uInt8 BIFF_LINE_THIN              = 1;
     264                 :            : 
     265                 :            : // BIFF XF patterns
     266                 :            : const sal_uInt8 BIFF_PATT_NONE              = 0;
     267                 :            : const sal_uInt8 BIFF_PATT_125               = 17;
     268                 :            : 
     269                 :            : // BIFF2 XF flags
     270                 :            : const sal_uInt8 BIFF2_XF_VALFMT_MASK        = 0x3F;
     271                 :            : const sal_uInt8 BIFF2_XF_LOCKED             = 0x40;
     272                 :            : const sal_uInt8 BIFF2_XF_HIDDEN             = 0x80;
     273                 :            : const sal_uInt8 BIFF2_XF_LEFTLINE           = 0x08;
     274                 :            : const sal_uInt8 BIFF2_XF_RIGHTLINE          = 0x10;
     275                 :            : const sal_uInt8 BIFF2_XF_TOPLINE            = 0x20;
     276                 :            : const sal_uInt8 BIFF2_XF_BOTTOMLINE         = 0x40;
     277                 :            : const sal_uInt8 BIFF2_XF_BACKGROUND         = 0x80;
     278                 :            : 
     279                 :            : // BIFF8 diagonal borders
     280                 :            : const sal_uInt32 BIFF_XF_DIAG_TLBR          = 0x40000000;   /// Top-left to bottom-right.
     281                 :            : const sal_uInt32 BIFF_XF_DIAG_BLTR          = 0x80000000;   /// Bottom-left to top-right.
     282                 :            : 
     283                 :            : // BIFF STYLE flags
     284                 :            : const sal_uInt16 BIFF_STYLE_BUILTIN         = 0x8000;
     285                 :            : const sal_uInt16 BIFF_STYLE_XFMASK          = 0x0FFF;
     286                 :            : 
     287                 :            : // BIFF STYLEEXT flags
     288                 :            : const sal_uInt8 BIFF_STYLEEXT_BUILTIN       = 0x01;
     289                 :            : const sal_uInt8 BIFF_STYLEEXT_HIDDEN        = 0x02;
     290                 :            : const sal_uInt8 BIFF_STYLEEXT_CUSTOM        = 0x04;
     291                 :            : 
     292                 :            : // BIFF conditional formatting
     293                 :            : const sal_uInt32 BIFF_CFRULE_BORDER_LEFT    = 0x00000400;
     294                 :            : const sal_uInt32 BIFF_CFRULE_BORDER_RIGHT   = 0x00000800;
     295                 :            : const sal_uInt32 BIFF_CFRULE_BORDER_TOP     = 0x00001000;
     296                 :            : const sal_uInt32 BIFF_CFRULE_BORDER_BOTTOM  = 0x00002000;
     297                 :            : const sal_uInt32 BIFF_CFRULE_FILL_PATTERN   = 0x00010000;
     298                 :            : const sal_uInt32 BIFF_CFRULE_FILL_PATTCOLOR = 0x00020000;
     299                 :            : const sal_uInt32 BIFF_CFRULE_FILL_FILLCOLOR = 0x00040000;
     300                 :            : const sal_uInt32 BIFF_CFRULE_FONTBLOCK      = 0x04000000;
     301                 :            : const sal_uInt32 BIFF_CFRULE_ALIGNBLOCK     = 0x08000000;
     302                 :            : const sal_uInt32 BIFF_CFRULE_BORDERBLOCK    = 0x10000000;
     303                 :            : const sal_uInt32 BIFF_CFRULE_FILLBLOCK      = 0x20000000;
     304                 :            : const sal_uInt32 BIFF_CFRULE_PROTBLOCK      = 0x40000000;
     305                 :            : 
     306                 :            : const sal_uInt32 BIFF_CFRULE_FONT_STYLE     = 0x00000002;   /// Font posture or weight modified?
     307                 :            : const sal_uInt32 BIFF_CFRULE_FONT_OUTLINE   = 0x00000008;   /// Font outline modified?
     308                 :            : const sal_uInt32 BIFF_CFRULE_FONT_SHADOW    = 0x00000010;   /// Font shadow modified?
     309                 :            : const sal_uInt32 BIFF_CFRULE_FONT_STRIKEOUT = 0x00000080;   /// Font cancellation modified?
     310                 :            : const sal_uInt32 BIFF_CFRULE_FONT_UNDERL    = 0x00000001;   /// Font underline type modified?
     311                 :            : const sal_uInt32 BIFF_CFRULE_FONT_ESCAPEM   = 0x00000001;   /// Font escapement type modified?
     312                 :            : 
     313                 :            : // ----------------------------------------------------------------------------
     314                 :            : 
     315                 :          0 : sal_Int32 lclReadRgbColor( BinaryInputStream& rStrm )
     316                 :            : {
     317                 :            :     sal_uInt8 nR, nG, nB, nA;
     318 [ #  # ][ #  # ]:          0 :     rStrm >> nR >> nG >> nB >> nA;
         [ #  # ][ #  # ]
     319                 :          0 :     sal_Int32 nValue = nA;
     320                 :          0 :     nValue <<= 8;
     321                 :          0 :     nValue |= nR;
     322                 :          0 :     nValue <<= 8;
     323                 :          0 :     nValue |= nG;
     324                 :          0 :     nValue <<= 8;
     325                 :          0 :     nValue |= nB;
     326                 :          0 :     return nValue;
     327                 :            : }
     328                 :            : 
     329                 :            : } // namespace
     330                 :            : 
     331                 :            : // ============================================================================
     332                 :            : 
     333                 :         24 : ExcelGraphicHelper::ExcelGraphicHelper( const WorkbookHelper& rHelper ) :
     334 [ +  - ][ +  - ]:         48 :     GraphicHelper( rHelper.getBaseFilter().getComponentContext(), rHelper.getBaseFilter().getTargetFrame(), rHelper.getBaseFilter().getStorage() ),
         [ +  - ][ +  - ]
     335         [ +  - ]:         48 :     WorkbookHelper( rHelper )
     336                 :            : {
     337                 :         24 : }
     338                 :            : 
     339                 :         12 : sal_Int32 ExcelGraphicHelper::getSchemeColor( sal_Int32 nToken ) const
     340                 :            : {
     341         [ +  - ]:         12 :     if( getFilterType() == FILTER_OOXML )
     342                 :         12 :         return getTheme().getColorByToken( nToken );
     343                 :         12 :     return GraphicHelper::getSchemeColor( nToken );
     344                 :            : }
     345                 :            : 
     346                 :        144 : sal_Int32 ExcelGraphicHelper::getPaletteColor( sal_Int32 nPaletteIdx ) const
     347                 :            : {
     348                 :        144 :     return getStyles().getPaletteColor( nPaletteIdx );
     349                 :            : }
     350                 :            : 
     351                 :            : // ============================================================================
     352                 :            : 
     353                 :          0 : void Color::setAuto()
     354                 :            : {
     355                 :          0 :     clearTransformations();
     356                 :          0 :     setSchemeClr( XML_phClr );
     357                 :          0 : }
     358                 :            : 
     359                 :         12 : void Color::setRgb( sal_Int32 nRgbValue, double fTint )
     360                 :            : {
     361                 :         12 :     clearTransformations();
     362                 :         12 :     setSrgbClr( nRgbValue & 0xFFFFFF );
     363         [ -  + ]:         12 :     if( fTint != 0.0 ) addExcelTintTransformation( fTint );
     364                 :         12 : }
     365                 :            : 
     366                 :         12 : void Color::setTheme( sal_Int32 nThemeIdx, double fTint )
     367                 :            : {
     368                 :         12 :     clearTransformations();
     369                 :            :     static const sal_Int32 spnColorTokens[] = {
     370                 :            :         XML_lt1, XML_dk1, XML_lt2, XML_dk2, XML_accent1, XML_accent2,
     371                 :            :         XML_accent3, XML_accent4, XML_accent5, XML_accent6, XML_hlink, XML_folHlink };
     372         [ +  - ]:         12 :     setSchemeClr( STATIC_ARRAY_SELECT( spnColorTokens, nThemeIdx, XML_TOKEN_INVALID ) );
     373         [ -  + ]:         12 :     if( fTint != 0.0 ) addExcelTintTransformation( fTint );
     374                 :         12 : }
     375                 :            : 
     376                 :        342 : void Color::setIndexed( sal_Int32 nPaletteIdx, double fTint )
     377                 :            : {
     378                 :        342 :     clearTransformations();
     379                 :        342 :     setPaletteClr( nPaletteIdx );
     380         [ -  + ]:        342 :     if( fTint != 0.0 ) addExcelTintTransformation( fTint );
     381                 :        342 : }
     382                 :            : 
     383                 :         24 : void Color::importColor( const AttributeList& rAttribs )
     384                 :            : {
     385         [ -  + ]:         24 :     if( rAttribs.getBool( XML_auto, false ) )
     386                 :          0 :         setAuto();
     387         [ +  + ]:         24 :     else if( rAttribs.hasAttribute( XML_rgb ) )
     388                 :         12 :         setRgb( rAttribs.getIntegerHex( XML_rgb, API_RGB_TRANSPARENT ), rAttribs.getDouble( XML_tint, 0.0 ) );
     389         [ +  - ]:         12 :     else if( rAttribs.hasAttribute( XML_theme ) )
     390                 :         12 :         setTheme( rAttribs.getInteger( XML_theme, -1 ), rAttribs.getDouble( XML_tint, 0.0 ) );
     391         [ #  # ]:          0 :     else if( rAttribs.hasAttribute( XML_indexed ) )
     392                 :          0 :         setIndexed( rAttribs.getInteger( XML_indexed, -1 ), rAttribs.getDouble( XML_tint, 0.0 ) );
     393                 :            :     else
     394                 :            :     {
     395                 :            :         OSL_FAIL( "Color::importColor - unknown color type" );
     396                 :          0 :         setAuto();
     397                 :            :     }
     398                 :         24 : }
     399                 :            : 
     400                 :          0 : void Color::importColor( SequenceInputStream& rStrm )
     401                 :            : {
     402                 :            :     sal_uInt8 nFlags, nIndex;
     403                 :            :     sal_Int16 nTint;
     404 [ #  # ][ #  # ]:          0 :     rStrm >> nFlags >> nIndex >> nTint;
                 [ #  # ]
     405                 :            : 
     406                 :            :     // scale tint from signed 16-bit to double range -1.0 ... 1.0
     407                 :          0 :     double fTint = nTint;
     408         [ #  # ]:          0 :     if( nTint < 0 )
     409                 :          0 :         fTint /= -SAL_MIN_INT16;
     410         [ #  # ]:          0 :     else if( nTint > 0 )
     411                 :          0 :         fTint /= SAL_MAX_INT16;
     412                 :            : 
     413   [ #  #  #  #  :          0 :     switch( extractValue< sal_uInt8 >( nFlags, 1, 7 ) )
                      # ]
     414                 :            :     {
     415                 :            :         case BIFF12_COLOR_AUTO:
     416         [ #  # ]:          0 :             setAuto();
     417         [ #  # ]:          0 :             rStrm.skip( 4 );
     418                 :          0 :         break;
     419                 :            :         case BIFF12_COLOR_INDEXED:
     420         [ #  # ]:          0 :             setIndexed( nIndex, fTint );
     421         [ #  # ]:          0 :             rStrm.skip( 4 );
     422                 :          0 :         break;
     423                 :            :         case BIFF12_COLOR_RGB:
     424 [ #  # ][ #  # ]:          0 :             setRgb( lclReadRgbColor( rStrm ), fTint );
     425                 :          0 :         break;
     426                 :            :         case BIFF12_COLOR_THEME:
     427         [ #  # ]:          0 :             setTheme( nIndex, fTint );
     428         [ #  # ]:          0 :             rStrm.skip( 4 );
     429                 :          0 :         break;
     430                 :            :         default:
     431                 :            :             OSL_FAIL( "Color::importColor - unknown color type" );
     432         [ #  # ]:          0 :             setAuto();
     433         [ #  # ]:          0 :             rStrm.skip( 4 );
     434                 :            :     }
     435                 :          0 : }
     436                 :            : 
     437                 :          0 : void Color::importColorId( SequenceInputStream& rStrm )
     438                 :            : {
     439                 :          0 :     setIndexed( rStrm.readInt32() );
     440                 :          0 : }
     441                 :            : 
     442                 :          0 : SequenceInputStream& operator>>( SequenceInputStream& rStrm, Color& orColor )
     443                 :            : {
     444                 :          0 :     orColor.importColor( rStrm );
     445                 :          0 :     return rStrm;
     446                 :            : }
     447                 :            : 
     448                 :            : // ============================================================================
     449                 :            : 
     450                 :            : namespace {
     451                 :            : 
     452                 :            : /** Standard EGA colors, bright. */
     453                 :            : #define PALETTE_EGA_COLORS_LIGHT \
     454                 :            :             0x000000, 0xFFFFFF, 0xFF0000, 0x00FF00, 0x0000FF, 0xFFFF00, 0xFF00FF, 0x00FFFF
     455                 :            : /** Standard EGA colors, dark. */
     456                 :            : #define PALETTE_EGA_COLORS_DARK \
     457                 :            :             0x800000, 0x008000, 0x000080, 0x808000, 0x800080, 0x008080, 0xC0C0C0, 0x808080
     458                 :            : 
     459                 :            : /** Default color table for BIFF2. */
     460                 :            : static const sal_Int32 spnDefColors2[] =
     461                 :            : {
     462                 :            : /*  0 */    PALETTE_EGA_COLORS_LIGHT
     463                 :            : };
     464                 :            : 
     465                 :            : /** Default color table for BIFF3/BIFF4. */
     466                 :            : static const sal_Int32 spnDefColors3[] =
     467                 :            : {
     468                 :            : /*  0 */    PALETTE_EGA_COLORS_LIGHT,
     469                 :            : /*  8 */    PALETTE_EGA_COLORS_LIGHT,
     470                 :            : /* 16 */    PALETTE_EGA_COLORS_DARK
     471                 :            : };
     472                 :            : 
     473                 :            : /** Default color table for BIFF5. */
     474                 :            : static const sal_Int32 spnDefColors5[] =
     475                 :            : {
     476                 :            : /*  0 */    PALETTE_EGA_COLORS_LIGHT,
     477                 :            : /*  8 */    PALETTE_EGA_COLORS_LIGHT,
     478                 :            : /* 16 */    PALETTE_EGA_COLORS_DARK,
     479                 :            : /* 24 */    0x8080FF, 0x802060, 0xFFFFC0, 0xA0E0E0, 0x600080, 0xFF8080, 0x0080C0, 0xC0C0FF,
     480                 :            : /* 32 */    0x000080, 0xFF00FF, 0xFFFF00, 0x00FFFF, 0x800080, 0x800000, 0x008080, 0x0000FF,
     481                 :            : /* 40 */    0x00CFFF, 0x69FFFF, 0xE0FFE0, 0xFFFF80, 0xA6CAF0, 0xDD9CB3, 0xB38FEE, 0xE3E3E3,
     482                 :            : /* 48 */    0x2A6FF9, 0x3FB8CD, 0x488436, 0x958C41, 0x8E5E42, 0xA0627A, 0x624FAC, 0x969696,
     483                 :            : /* 56 */    0x1D2FBE, 0x286676, 0x004500, 0x453E01, 0x6A2813, 0x85396A, 0x4A3285, 0x424242
     484                 :            : };
     485                 :            : 
     486                 :            : /** Default color table for BIFF8/BIFF12/OOXML. */
     487                 :            : static const sal_Int32 spnDefColors8[] =
     488                 :            : {
     489                 :            : /*  0 */    PALETTE_EGA_COLORS_LIGHT,
     490                 :            : /*  8 */    PALETTE_EGA_COLORS_LIGHT,
     491                 :            : /* 16 */    PALETTE_EGA_COLORS_DARK,
     492                 :            : /* 24 */    0x9999FF, 0x993366, 0xFFFFCC, 0xCCFFFF, 0x660066, 0xFF8080, 0x0066CC, 0xCCCCFF,
     493                 :            : /* 32 */    0x000080, 0xFF00FF, 0xFFFF00, 0x00FFFF, 0x800080, 0x800000, 0x008080, 0x0000FF,
     494                 :            : /* 40 */    0x00CCFF, 0xCCFFFF, 0xCCFFCC, 0xFFFF99, 0x99CCFF, 0xFF99CC, 0xCC99FF, 0xFFCC99,
     495                 :            : /* 48 */    0x3366FF, 0x33CCCC, 0x99CC00, 0xFFCC00, 0xFF9900, 0xFF6600, 0x666699, 0x969696,
     496                 :            : /* 56 */    0x003366, 0x339966, 0x003300, 0x333300, 0x993300, 0x993366, 0x333399, 0x333333
     497                 :            : };
     498                 :            : 
     499                 :            : #undef PALETTE_EGA_COLORS_LIGHT
     500                 :            : #undef PALETTE_EGA_COLORS_DARK
     501                 :            : 
     502                 :            : } // namespace
     503                 :            : 
     504                 :            : // ----------------------------------------------------------------------------
     505                 :            : 
     506                 :         24 : ColorPalette::ColorPalette( const WorkbookHelper& rHelper ) :
     507         [ +  - ]:         24 :     WorkbookHelper( rHelper )
     508                 :            : {
     509                 :            :     // default colors
     510         [ +  - ]:         24 :     switch( getFilterType() )
           [ +  -  -  - ]
     511                 :            :     {
     512                 :            :         case FILTER_OOXML:
     513         [ +  - ]:         24 :             maColors.insert( maColors.begin(), spnDefColors8, STATIC_ARRAY_END( spnDefColors8 ) );
     514                 :         24 :             mnAppendIndex = OOX_COLOR_USEROFFSET;
     515                 :         24 :         break;
     516                 :            :         case FILTER_BIFF:
     517 [ #  # ][ #  #  :          0 :             switch( getBiff() )
             #  #  #  # ]
     518                 :            :             {
     519         [ #  # ]:          0 :                 case BIFF2: maColors.insert( maColors.begin(), spnDefColors2, STATIC_ARRAY_END( spnDefColors2 ) );  break;
     520                 :            :                 case BIFF3:
     521         [ #  # ]:          0 :                 case BIFF4: maColors.insert( maColors.begin(), spnDefColors3, STATIC_ARRAY_END( spnDefColors3 ) );  break;
     522         [ #  # ]:          0 :                 case BIFF5: maColors.insert( maColors.begin(), spnDefColors5, STATIC_ARRAY_END( spnDefColors5 ) );  break;
     523         [ #  # ]:          0 :                 case BIFF8: maColors.insert( maColors.begin(), spnDefColors8, STATIC_ARRAY_END( spnDefColors8 ) );  break;
     524                 :          0 :                 case BIFF_UNKNOWN: break;
     525                 :            :             }
     526                 :          0 :             mnAppendIndex = BIFF_COLOR_USEROFFSET;
     527                 :          0 :         break;
     528                 :          0 :         case FILTER_UNKNOWN: break;
     529                 :            :     }
     530                 :         24 : }
     531                 :            : 
     532                 :          0 : void ColorPalette::importPaletteColor( const AttributeList& rAttribs )
     533                 :            : {
     534                 :          0 :     appendColor( rAttribs.getIntegerHex( XML_rgb, API_RGB_WHITE ) );
     535                 :          0 : }
     536                 :            : 
     537                 :          0 : void ColorPalette::importPaletteColor( SequenceInputStream& rStrm )
     538                 :            : {
     539                 :          0 :     sal_Int32 nRgb = lclReadRgbColor( rStrm );
     540                 :          0 :     appendColor( nRgb & 0xFFFFFF );
     541                 :          0 : }
     542                 :            : 
     543                 :        144 : sal_Int32 ColorPalette::getColor( sal_Int32 nPaletteIdx ) const
     544                 :            : {
     545                 :        144 :     sal_Int32 nColor = API_RGB_TRANSPARENT;
     546         [ -  + ]:        144 :     if( const sal_Int32* pnPaletteColor = ContainerHelper::getVectorElement( maColors, nPaletteIdx ) )
     547                 :            :     {
     548                 :          0 :         nColor = *pnPaletteColor;
     549                 :            :     }
     550   [ +  +  -  -  :        144 :     else switch( nPaletteIdx )
             -  -  -  - ]
     551                 :            :     {
     552                 :            :         case OOX_COLOR_WINDOWTEXT3:
     553                 :            :         case OOX_COLOR_WINDOWTEXT:
     554                 :        120 :         case OOX_COLOR_CHWINDOWTEXT:    nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_windowText );   break;
     555                 :            :         case OOX_COLOR_WINDOWBACK3:
     556                 :            :         case OOX_COLOR_WINDOWBACK:
     557                 :         24 :         case OOX_COLOR_CHWINDOWBACK:    nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_window );       break;
     558                 :          0 :         case OOX_COLOR_BUTTONBACK:      nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_btnFace );      break;
     559                 :          0 :         case OOX_COLOR_CHBORDERAUTO:    nColor = API_RGB_BLACK; /* really always black? */                              break;
     560                 :          0 :         case OOX_COLOR_NOTEBACK:        nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_infoBk );       break;
     561                 :          0 :         case OOX_COLOR_NOTETEXT:        nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_infoText );     break;
     562                 :          0 :         case OOX_COLOR_FONTAUTO:        nColor = API_RGB_TRANSPARENT;                                                   break;
     563                 :            :         default:                        OSL_FAIL( "ColorPalette::getColor - unknown color index" );
     564                 :            :     }
     565                 :        144 :     return nColor;
     566                 :            : }
     567                 :            : 
     568                 :          0 : void ColorPalette::appendColor( sal_Int32 nRGBValue )
     569                 :            : {
     570         [ #  # ]:          0 :     if( mnAppendIndex < maColors.size() )
     571                 :          0 :         maColors[ mnAppendIndex ] = nRGBValue;
     572                 :            :     else
     573                 :          0 :         maColors.push_back( nRGBValue );
     574                 :          0 :     ++mnAppendIndex;
     575                 :          0 : }
     576                 :            : 
     577                 :            : // ============================================================================
     578                 :            : 
     579                 :            : namespace {
     580                 :            : 
     581                 :        639 : void lclSetFontName( ApiScriptFontName& rFontName, const FontDescriptor& rFontDesc, bool bHasGlyphs )
     582                 :            : {
     583         [ +  + ]:        639 :     if( bHasGlyphs )
     584                 :            :     {
     585                 :        219 :         rFontName.maName = rFontDesc.Name;
     586                 :        219 :         rFontName.mnFamily = rFontDesc.Family;
     587                 :            :         // API font descriptor contains rtl_TextEncoding constants
     588                 :        219 :         rFontName.mnTextEnc = rFontDesc.CharSet;
     589                 :            :     }
     590                 :            :     else
     591                 :            :     {
     592                 :        420 :         rFontName = ApiScriptFontName();
     593                 :            :     }
     594                 :        639 : }
     595                 :            : 
     596                 :            : } // namespace
     597                 :            : 
     598                 :            : // ----------------------------------------------------------------------------
     599                 :            : 
     600                 :         48 : FontModel::FontModel() :
     601                 :            :     mnScheme( XML_none ),
     602                 :            :     mnFamily( OOX_FONTFAMILY_NONE ),
     603                 :            :     mnCharSet( WINDOWS_CHARSET_DEFAULT ),
     604                 :            :     mfHeight( 0.0 ),
     605                 :            :     mnUnderline( XML_none ),
     606                 :            :     mnEscapement( XML_baseline ),
     607                 :            :     mbBold( false ),
     608                 :            :     mbItalic( false ),
     609                 :            :     mbStrikeout( false ),
     610                 :            :     mbOutline( false ),
     611         [ +  - ]:         48 :     mbShadow( false )
     612                 :            : {
     613                 :         48 : }
     614                 :            : 
     615                 :          0 : void FontModel::setBiff12Scheme( sal_uInt8 nScheme )
     616                 :            : {
     617                 :            :     static const sal_Int32 spnSchemes[] = { XML_none, XML_major, XML_minor };
     618         [ #  # ]:          0 :     mnScheme = STATIC_ARRAY_SELECT( spnSchemes, nScheme, XML_none );
     619                 :          0 : }
     620                 :            : 
     621                 :          0 : void FontModel::setBiffHeight( sal_uInt16 nHeight )
     622                 :            : {
     623                 :          0 :     mfHeight = nHeight / 20.0;  // convert twips to points
     624                 :          0 : }
     625                 :            : 
     626                 :          0 : void FontModel::setBiffWeight( sal_uInt16 nWeight )
     627                 :            : {
     628                 :          0 :     mbBold = nWeight >= BIFF_FONTWEIGHT_BOLD;
     629                 :          0 : }
     630                 :            : 
     631                 :          0 : void FontModel::setBiffUnderline( sal_uInt16 nUnderline )
     632                 :            : {
     633   [ #  #  #  #  :          0 :     switch( nUnderline )
                   #  # ]
     634                 :            :     {
     635                 :          0 :         case BIFF_FONTUNDERL_NONE:          mnUnderline = XML_none;             break;
     636                 :          0 :         case BIFF_FONTUNDERL_SINGLE:        mnUnderline = XML_single;           break;
     637                 :          0 :         case BIFF_FONTUNDERL_DOUBLE:        mnUnderline = XML_double;           break;
     638                 :          0 :         case BIFF_FONTUNDERL_SINGLE_ACC:    mnUnderline = XML_singleAccounting; break;
     639                 :          0 :         case BIFF_FONTUNDERL_DOUBLE_ACC:    mnUnderline = XML_doubleAccounting; break;
     640                 :          0 :         default:                            mnUnderline = XML_none;
     641                 :            :     }
     642                 :          0 : }
     643                 :            : 
     644                 :          0 : void FontModel::setBiffEscapement( sal_uInt16 nEscapement )
     645                 :            : {
     646                 :            :     static const sal_Int32 spnEscapes[] = { XML_baseline, XML_superscript, XML_subscript };
     647         [ #  # ]:          0 :     mnEscapement = STATIC_ARRAY_SELECT( spnEscapes, nEscapement, XML_baseline );
     648                 :          0 : }
     649                 :            : 
     650                 :            : // ----------------------------------------------------------------------------
     651                 :            : 
     652                 :        213 : ApiFontUsedFlags::ApiFontUsedFlags( bool bAllUsed ) :
     653                 :            :     mbNameUsed( bAllUsed ),
     654                 :            :     mbColorUsed( bAllUsed ),
     655                 :            :     mbSchemeUsed( bAllUsed ),
     656                 :            :     mbHeightUsed( bAllUsed ),
     657                 :            :     mbUnderlineUsed( bAllUsed ),
     658                 :            :     mbEscapementUsed( bAllUsed ),
     659                 :            :     mbWeightUsed( bAllUsed ),
     660                 :            :     mbPostureUsed( bAllUsed ),
     661                 :            :     mbStrikeoutUsed( bAllUsed ),
     662                 :            :     mbOutlineUsed( bAllUsed ),
     663                 :        213 :     mbShadowUsed( bAllUsed )
     664                 :            : {
     665                 :        213 : }
     666                 :            : 
     667                 :            : // ----------------------------------------------------------------------------
     668                 :            : 
     669                 :       1059 : ApiScriptFontName::ApiScriptFontName() :
     670                 :            :     mnFamily( ::com::sun::star::awt::FontFamily::DONTKNOW ),
     671                 :       1059 :     mnTextEnc( RTL_TEXTENCODING_DONTKNOW )
     672                 :            : {
     673                 :       1059 : }
     674                 :            : 
     675                 :            : // ----------------------------------------------------------------------------
     676                 :            : 
     677                 :        213 : ApiFontData::ApiFontData() :
     678                 :            :     maDesc(
     679                 :            :         CREATE_OUSTRING( "Calibri" ),
     680                 :            :         220,                                            // height 11 points
     681                 :            :         0,
     682                 :            :         OUString(),
     683                 :            :         ::com::sun::star::awt::FontFamily::DONTKNOW,
     684                 :            :         RTL_TEXTENCODING_DONTKNOW,
     685                 :            :         ::com::sun::star::awt::FontPitch::DONTKNOW,
     686                 :            :         100.0,
     687                 :            :         ::com::sun::star::awt::FontWeight::NORMAL,
     688                 :            :         ::com::sun::star::awt::FontSlant_NONE,
     689                 :            :         ::com::sun::star::awt::FontUnderline::NONE,
     690                 :            :         ::com::sun::star::awt::FontStrikeout::NONE,
     691                 :            :         0.0,
     692                 :            :         sal_False,
     693                 :            :         sal_False,
     694                 :            :         ::com::sun::star::awt::FontType::DONTKNOW ),
     695                 :            :     mnColor( API_RGB_TRANSPARENT ),
     696                 :            :     mnEscapement( API_ESCAPE_NONE ),
     697                 :            :     mnEscapeHeight( API_ESCAPEHEIGHT_NONE ),
     698                 :            :     mbOutline( false ),
     699         [ +  - ]:        213 :     mbShadow( false )
     700                 :            : {
     701                 :        213 :     maLatinFont.maName = maDesc.Name;
     702                 :        213 : }
     703                 :            : 
     704                 :            : // ============================================================================
     705                 :            : 
     706                 :        111 : Font::Font( const WorkbookHelper& rHelper, bool bDxf ) :
     707                 :            :     WorkbookHelper( rHelper ),
     708         [ +  - ]:        111 :     maModel( rHelper.getTheme().getDefaultFontModel() ),
     709                 :        111 :     maUsedFlags( !bDxf ),
     710 [ +  - ][ +  - ]:        222 :     mbDxf( bDxf )
     711                 :            : {
     712                 :        111 : }
     713                 :            : 
     714                 :        102 : Font::Font( const WorkbookHelper& rHelper, const FontModel& rModel ) :
     715                 :            :     WorkbookHelper( rHelper ),
     716                 :            :     maModel( rModel ),
     717                 :            :     maUsedFlags( true ),
     718 [ +  - ][ +  - ]:        102 :     mbDxf( false )
     719                 :            : {
     720                 :        102 : }
     721                 :            : 
     722                 :        417 : void Font::importAttribs( sal_Int32 nElement, const AttributeList& rAttribs )
     723                 :            : {
     724                 :        417 :     const FontModel& rDefModel = getTheme().getDefaultFontModel();
     725   [ +  +  +  +  :        417 :     switch( nElement )
          +  +  +  -  +  
             +  +  -  -  
                      - ]
     726                 :            :     {
     727                 :            :         case XLS_TOKEN( name ):     // when in <font> element
     728                 :            :         case XLS_TOKEN( rFont ):    // when in <rPr> element
     729         [ +  - ]:        111 :             if( rAttribs.hasAttribute( XML_val ) )
     730                 :            :             {
     731         [ +  - ]:        111 :                 maModel.maName = rAttribs.getXString( XML_val, OUString() );
     732                 :        111 :                 maUsedFlags.mbNameUsed = true;
     733                 :            :             }
     734                 :        111 :         break;
     735                 :            :         case XLS_TOKEN( scheme ):
     736                 :          3 :             maModel.mnScheme = rAttribs.getToken( XML_val, rDefModel.mnScheme );
     737                 :          3 :         break;
     738                 :            :         case XLS_TOKEN( family ):
     739                 :        111 :             maModel.mnFamily = rAttribs.getInteger( XML_val, rDefModel.mnFamily );
     740                 :        111 :         break;
     741                 :            :         case XLS_TOKEN( charset ):
     742                 :         30 :             maModel.mnCharSet = rAttribs.getInteger( XML_val, rDefModel.mnCharSet );
     743                 :         30 :         break;
     744                 :            :         case XLS_TOKEN( sz ):
     745                 :        111 :             maModel.mfHeight = rAttribs.getDouble( XML_val, rDefModel.mfHeight );
     746                 :        111 :             maUsedFlags.mbHeightUsed = true;
     747                 :        111 :         break;
     748                 :            :         case XLS_TOKEN( color ):
     749                 :         18 :             maModel.maColor.importColor( rAttribs );
     750                 :         18 :             maUsedFlags.mbColorUsed = true;
     751                 :         18 :         break;
     752                 :            :         case XLS_TOKEN( u ):
     753                 :          6 :             maModel.mnUnderline = rAttribs.getToken( XML_val, XML_single );
     754                 :          6 :             maUsedFlags.mbUnderlineUsed = true;
     755                 :          6 :         break;
     756                 :            :         case XLS_TOKEN( vertAlign ):
     757                 :          0 :             maModel.mnEscapement = rAttribs.getToken( XML_val, XML_baseline );
     758                 :          0 :             maUsedFlags.mbEscapementUsed = true;
     759                 :          0 :         break;
     760                 :            :         case XLS_TOKEN( b ):
     761                 :         12 :             maModel.mbBold = rAttribs.getBool( XML_val, true );
     762                 :         12 :             maUsedFlags.mbWeightUsed = true;
     763                 :         12 :         break;
     764                 :            :         case XLS_TOKEN( i ):
     765                 :         12 :             maModel.mbItalic = rAttribs.getBool( XML_val, true );
     766                 :         12 :             maUsedFlags.mbPostureUsed = true;
     767                 :         12 :         break;
     768                 :            :         case XLS_TOKEN( strike ):
     769                 :          3 :             maModel.mbStrikeout = rAttribs.getBool( XML_val, true );
     770                 :          3 :             maUsedFlags.mbStrikeoutUsed = true;
     771                 :          3 :         break;
     772                 :            :         case XLS_TOKEN( outline ):
     773                 :          0 :             maModel.mbOutline = rAttribs.getBool( XML_val, true );
     774                 :          0 :             maUsedFlags.mbOutlineUsed = true;
     775                 :          0 :         break;
     776                 :            :         case XLS_TOKEN( shadow ):
     777                 :          0 :             maModel.mbShadow = rAttribs.getBool( XML_val, true );
     778                 :          0 :             maUsedFlags.mbShadowUsed = true;
     779                 :          0 :         break;
     780                 :            :     }
     781                 :        417 : }
     782                 :            : 
     783                 :          0 : void Font::importFont( SequenceInputStream& rStrm )
     784                 :            : {
     785                 :            :     OSL_ENSURE( !mbDxf, "Font::importFont - unexpected conditional formatting flag" );
     786                 :            : 
     787                 :            :     sal_uInt16 nHeight, nFlags, nWeight, nEscapement;
     788                 :            :     sal_uInt8 nUnderline, nFamily, nCharSet, nScheme;
     789 [ #  # ][ #  # ]:          0 :     rStrm >> nHeight >> nFlags >> nWeight >> nEscapement >> nUnderline >> nFamily >> nCharSet;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     790         [ #  # ]:          0 :     rStrm.skip( 1 );
     791 [ #  # ][ #  # ]:          0 :     rStrm >> maModel.maColor >> nScheme >> maModel.maName;
                 [ #  # ]
     792                 :            : 
     793                 :            :     // equal constants in all BIFFs for weight, underline, and escapement
     794                 :          0 :     maModel.setBiff12Scheme( nScheme );
     795                 :          0 :     maModel.setBiffHeight( nHeight );
     796                 :          0 :     maModel.setBiffWeight( nWeight );
     797                 :          0 :     maModel.setBiffUnderline( nUnderline );
     798                 :          0 :     maModel.setBiffEscapement( nEscapement );
     799                 :          0 :     maModel.mnFamily    = nFamily;
     800                 :          0 :     maModel.mnCharSet   = nCharSet;
     801                 :            :     // equal flags in all BIFFs
     802                 :          0 :     maModel.mbItalic    = getFlag( nFlags, BIFF_FONTFLAG_ITALIC );
     803                 :          0 :     maModel.mbStrikeout = getFlag( nFlags, BIFF_FONTFLAG_STRIKEOUT );
     804                 :          0 :     maModel.mbOutline   = getFlag( nFlags, BIFF_FONTFLAG_OUTLINE );
     805                 :          0 :     maModel.mbShadow    = getFlag( nFlags, BIFF_FONTFLAG_SHADOW );
     806                 :          0 : }
     807                 :            : 
     808                 :          0 : void Font::importDxfName( SequenceInputStream& rStrm )
     809                 :            : {
     810                 :            :     OSL_ENSURE( mbDxf, "Font::importDxfName - missing conditional formatting flag" );
     811                 :          0 :     maModel.maName = BiffHelper::readString( rStrm, false );
     812                 :          0 :     maUsedFlags.mbColorUsed = true;
     813                 :          0 : }
     814                 :            : 
     815                 :          0 : void Font::importDxfColor( SequenceInputStream& rStrm )
     816                 :            : {
     817                 :            :     OSL_ENSURE( mbDxf, "Font::importDxfColor - missing conditional formatting flag" );
     818                 :          0 :     rStrm >> maModel.maColor;
     819                 :          0 :     maUsedFlags.mbColorUsed = true;
     820                 :          0 : }
     821                 :            : 
     822                 :          0 : void Font::importDxfScheme( SequenceInputStream& rStrm )
     823                 :            : {
     824                 :            :     OSL_ENSURE( mbDxf, "Font::importDxfScheme - missing conditional formatting flag" );
     825                 :          0 :     maModel.setBiff12Scheme( rStrm.readuInt8() );
     826                 :          0 :     maUsedFlags.mbSchemeUsed = true;
     827                 :          0 : }
     828                 :            : 
     829                 :          0 : void Font::importDxfHeight( SequenceInputStream& rStrm )
     830                 :            : {
     831                 :            :     OSL_ENSURE( mbDxf, "Font::importDxfHeight - missing conditional formatting flag" );
     832                 :          0 :     maModel.setBiffHeight( rStrm.readuInt16() );
     833                 :          0 :     maUsedFlags.mbHeightUsed = true;
     834                 :          0 : }
     835                 :            : 
     836                 :          0 : void Font::importDxfWeight( SequenceInputStream& rStrm )
     837                 :            : {
     838                 :            :     OSL_ENSURE( mbDxf, "Font::importDxfWeight - missing conditional formatting flag" );
     839                 :          0 :     maModel.setBiffWeight( rStrm.readuInt16() );
     840                 :          0 :     maUsedFlags.mbWeightUsed = true;
     841                 :          0 : }
     842                 :            : 
     843                 :          0 : void Font::importDxfUnderline( SequenceInputStream& rStrm )
     844                 :            : {
     845                 :            :     OSL_ENSURE( mbDxf, "Font::importDxfUnderline - missing conditional formatting flag" );
     846                 :          0 :     maModel.setBiffUnderline( rStrm.readuInt16() );
     847                 :          0 :     maUsedFlags.mbUnderlineUsed = true;
     848                 :          0 : }
     849                 :            : 
     850                 :          0 : void Font::importDxfEscapement( SequenceInputStream& rStrm )
     851                 :            : {
     852                 :            :     OSL_ENSURE( mbDxf, "Font::importDxfEscapement - missing conditional formatting flag" );
     853                 :          0 :     maModel.setBiffEscapement( rStrm.readuInt16() );
     854                 :          0 :     maUsedFlags.mbEscapementUsed = true;
     855                 :          0 : }
     856                 :            : 
     857                 :          0 : void Font::importDxfFlag( sal_Int32 nElement, SequenceInputStream& rStrm )
     858                 :            : {
     859                 :            :     OSL_ENSURE( mbDxf, "Font::importDxfFlag - missing conditional formatting flag" );
     860                 :          0 :     bool bFlag = rStrm.readuInt8() != 0;
     861   [ #  #  #  #  :          0 :     switch( nElement )
                      # ]
     862                 :            :     {
     863                 :            :         case XML_i:
     864                 :          0 :             maModel.mbItalic = bFlag;
     865                 :          0 :             maUsedFlags.mbPostureUsed = true;
     866                 :          0 :         break;
     867                 :            :         case XML_strike:
     868                 :          0 :             maModel.mbStrikeout = bFlag;
     869                 :          0 :             maUsedFlags.mbStrikeoutUsed = true;
     870                 :          0 :         break;
     871                 :            :         case XML_outline:
     872                 :          0 :             maModel.mbOutline = bFlag;
     873                 :          0 :             maUsedFlags.mbOutlineUsed = true;
     874                 :          0 :         break;
     875                 :            :         case XML_shadow:
     876                 :          0 :             maModel.mbShadow = bFlag;
     877                 :          0 :             maUsedFlags.mbShadowUsed = true;
     878                 :          0 :         break;
     879                 :            :         default:
     880                 :            :             OSL_FAIL( "Font::importDxfFlag - unexpected element identifier" );
     881                 :            :     }
     882                 :          0 : }
     883                 :            : 
     884                 :        213 : void Font::finalizeImport()
     885                 :            : {
     886                 :            :     namespace cssawt = ::com::sun::star::awt;
     887                 :            : 
     888                 :            :     // font name
     889                 :        213 :     maApiData.maDesc.Name = maModel.maName;
     890                 :            : 
     891                 :            :     // font family
     892   [ +  -  +  -  :        213 :     switch( maModel.mnFamily )
                -  -  - ]
     893                 :            :     {
     894                 :         54 :         case OOX_FONTFAMILY_NONE:           maApiData.maDesc.Family = cssawt::FontFamily::DONTKNOW;     break;
     895                 :          0 :         case OOX_FONTFAMILY_ROMAN:          maApiData.maDesc.Family = cssawt::FontFamily::ROMAN;        break;
     896                 :        159 :         case OOX_FONTFAMILY_SWISS:          maApiData.maDesc.Family = cssawt::FontFamily::SWISS;        break;
     897                 :          0 :         case OOX_FONTFAMILY_MODERN:         maApiData.maDesc.Family = cssawt::FontFamily::MODERN;       break;
     898                 :          0 :         case OOX_FONTFAMILY_SCRIPT:         maApiData.maDesc.Family = cssawt::FontFamily::SCRIPT;       break;
     899                 :          0 :         case OOX_FONTFAMILY_DECORATIVE:     maApiData.maDesc.Family = cssawt::FontFamily::DECORATIVE;   break;
     900                 :            :     }
     901                 :            : 
     902                 :            :     // character set (API font descriptor uses rtl_TextEncoding in member CharSet!)
     903 [ +  - ][ +  - ]:        213 :     if( (0 <= maModel.mnCharSet) && (maModel.mnCharSet <= SAL_MAX_UINT8) )
     904                 :            :         maApiData.maDesc.CharSet = static_cast< sal_Int16 >(
     905                 :        213 :             rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( maModel.mnCharSet ) ) );
     906                 :            : 
     907                 :            :     // color, height, weight, slant, strikeout, outline, shadow
     908                 :        213 :     maApiData.mnColor          = maModel.maColor.getColor( getBaseFilter().getGraphicHelper() );
     909                 :        213 :     maApiData.maDesc.Height    = static_cast< sal_Int16 >( maModel.mfHeight * 20.0 );
     910         [ +  + ]:        213 :     maApiData.maDesc.Weight    = maModel.mbBold ? cssawt::FontWeight::BOLD : cssawt::FontWeight::NORMAL;
     911         [ +  + ]:        213 :     maApiData.maDesc.Slant     = maModel.mbItalic ? cssawt::FontSlant_ITALIC : cssawt::FontSlant_NONE;
     912         [ +  + ]:        213 :     maApiData.maDesc.Strikeout = maModel.mbStrikeout ? cssawt::FontStrikeout::SINGLE : cssawt::FontStrikeout::NONE;
     913                 :        213 :     maApiData.mbOutline        = maModel.mbOutline;
     914                 :        213 :     maApiData.mbShadow         = maModel.mbShadow;
     915                 :            : 
     916                 :            :     // underline
     917   [ -  -  +  +  :        213 :     switch( maModel.mnUnderline )
                   -  - ]
     918                 :            :     {
     919                 :          0 :         case XML_double:            maApiData.maDesc.Underline = cssawt::FontUnderline::DOUBLE; break;
     920                 :          0 :         case XML_doubleAccounting:  maApiData.maDesc.Underline = cssawt::FontUnderline::DOUBLE; break;
     921                 :        207 :         case XML_none:              maApiData.maDesc.Underline = cssawt::FontUnderline::NONE;   break;
     922                 :          6 :         case XML_single:            maApiData.maDesc.Underline = cssawt::FontUnderline::SINGLE; break;
     923                 :          0 :         case XML_singleAccounting:  maApiData.maDesc.Underline = cssawt::FontUnderline::SINGLE; break;
     924                 :            :     }
     925                 :            : 
     926                 :            :     // escapement
     927   [ +  -  -  - ]:        213 :     switch( maModel.mnEscapement )
     928                 :            :     {
     929                 :            :         case XML_baseline:
     930                 :        213 :             maApiData.mnEscapement = API_ESCAPE_NONE;
     931                 :        213 :             maApiData.mnEscapeHeight = API_ESCAPEHEIGHT_NONE;
     932                 :        213 :         break;
     933                 :            :         case XML_superscript:
     934                 :          0 :             maApiData.mnEscapement = API_ESCAPE_SUPERSCRIPT;
     935                 :          0 :             maApiData.mnEscapeHeight = API_ESCAPEHEIGHT_DEFAULT;
     936                 :          0 :         break;
     937                 :            :         case XML_subscript:
     938                 :          0 :             maApiData.mnEscapement = API_ESCAPE_SUBSCRIPT;
     939                 :          0 :             maApiData.mnEscapeHeight = API_ESCAPEHEIGHT_DEFAULT;
     940                 :          0 :         break;
     941                 :            :     }
     942                 :            : 
     943                 :            :     // supported script types
     944         [ +  - ]:        213 :     if( maUsedFlags.mbNameUsed )
     945                 :            :     {
     946 [ +  - ][ +  - ]:        213 :         PropertySet aDocProps( getDocument() );
     947 [ +  - ][ +  - ]:        213 :         Reference< XDevice > xDevice( aDocProps.getAnyProperty( PROP_ReferenceDevice ), UNO_QUERY );
     948         [ +  - ]:        213 :         if( xDevice.is() )
     949                 :            :         {
     950 [ +  - ][ +  - ]:        213 :             Reference< XFont2 > xFont( xDevice->getFont( maApiData.maDesc ), UNO_QUERY );
                 [ +  - ]
     951         [ +  - ]:        213 :             if( xFont.is() )
     952                 :            :             {
     953                 :            :                 // #91658# CJK fonts
     954                 :            :                 bool bHasAsian =
     955 [ +  - ][ +  - ]:        426 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0x3041 ) ) ) ||    // 3040-309F: Hiragana
         [ +  - ][ #  # ]
     956 [ +  - ][ +  - ]:        426 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0x30A1 ) ) ) ||    // 30A0-30FF: Katakana
         [ +  - ][ #  # ]
     957 [ +  - ][ +  - ]:        426 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0x3111 ) ) ) ||    // 3100-312F: Bopomofo
         [ +  - ][ #  # ]
     958 [ +  - ][ +  - ]:        426 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0x3131 ) ) ) ||    // 3130-318F: Hangul Compatibility Jamo
         [ +  - ][ #  # ]
     959 [ +  - ][ +  - ]:        426 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0x3301 ) ) ) ||    // 3300-33FF: CJK Compatibility
         [ +  - ][ #  # ]
     960 [ +  - ][ +  - ]:        426 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0x3401 ) ) ) ||    // 3400-4DBF: CJK Unified Ideographs Extension A
         [ +  - ][ #  # ]
     961 [ +  - ][ +  - ]:        426 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0x4E01 ) ) ) ||    // 4E00-9FAF: CJK Unified Ideographs
         [ +  - ][ #  # ]
     962 [ +  - ][ +  - ]:        426 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0x7E01 ) ) ) ||    // 4E00-9FAF: CJK unified ideographs
         [ +  - ][ #  # ]
     963 [ +  - ][ +  - ]:        426 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0xA001 ) ) ) ||    // A001-A48F: Yi Syllables
         [ +  - ][ #  # ]
     964 [ +  - ][ +  - ]:        426 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0xAC01 ) ) ) ||    // AC00-D7AF: Hangul Syllables
         [ +  - ][ #  # ]
     965 [ +  - ][ +  - ]:        426 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0xCC01 ) ) ) ||    // AC00-D7AF: Hangul Syllables
         [ +  - ][ #  # ]
     966 [ +  - ][ +  - ]:        426 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0xF901 ) ) ) ||    // F900-FAFF: CJK Compatibility Ideographs
         [ +  - ][ #  # ]
     967 [ +  - ][ +  - ]:       2556 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0xFF71 ) ) );      // FF00-FFEF: Halfwidth/Fullwidth Forms
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ -  + ][ +  - ]
                 [ #  # ]
     968                 :            :                 // #113783# CTL fonts
     969                 :            :                 bool bHasCmplx =
     970 [ +  - ][ +  - ]:        426 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0x05D1 ) ) ) ||    // 0590-05FF: Hebrew
         [ +  - ][ #  # ]
     971 [ +  - ][ +  - ]:        420 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0x0631 ) ) ) ||    // 0600-06FF: Arabic
         [ +  + ][ #  # ]
     972 [ +  - ][ +  - ]:        420 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0x0721 ) ) ) ||    // 0700-074F: Syriac
         [ +  + ][ #  # ]
     973 [ +  - ][ +  - ]:        420 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0x0911 ) ) ) ||    // 0900-0DFF: Indic scripts
         [ +  + ][ #  # ]
     974 [ +  - ][ +  - ]:        420 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0x0E01 ) ) ) ||    // 0E00-0E7F: Thai
         [ +  + ][ #  # ]
     975 [ +  - ][ +  - ]:        420 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0xFB21 ) ) ) ||    // FB1D-FB4F: Hebrew Presentation Forms
         [ +  + ][ #  # ]
     976 [ +  - ][ +  - ]:        420 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0xFB51 ) ) ) ||    // FB50-FDFF: Arabic Presentation Forms-A
         [ +  + ][ #  # ]
     977 [ +  + ][ +  - ]:       1455 :                     xFont->hasGlyphs( OUString( sal_Unicode( 0xFE71 ) ) );      // FE70-FEFF: Arabic Presentation Forms-B
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
         [ +  + ][ #  # ]
     978                 :            :                 // Western fonts
     979                 :            :                 bool bHasLatin =
     980                 :        426 :                     (!bHasAsian && !bHasCmplx) ||
     981 [ +  - ][ +  + ]:        213 :                     xFont->hasGlyphs( OUString( sal_Unicode( 'A' ) ) );
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
                 [ #  # ]
     982                 :            : 
     983         [ +  - ]:        213 :                 lclSetFontName( maApiData.maLatinFont, maApiData.maDesc, bHasLatin );
     984         [ +  - ]:        213 :                 lclSetFontName( maApiData.maAsianFont, maApiData.maDesc, bHasAsian );
     985         [ +  - ]:        213 :                 lclSetFontName( maApiData.maCmplxFont, maApiData.maDesc, bHasCmplx );
     986                 :        213 :             }
     987         [ +  - ]:        213 :         }
     988                 :            :     }
     989                 :        213 : }
     990                 :            : 
     991                 :         24 : const FontDescriptor& Font::getFontDescriptor() const
     992                 :            : {
     993                 :         24 :     return maApiData.maDesc;
     994                 :            : }
     995                 :            : 
     996                 :        141 : bool Font::needsRichTextFormat() const
     997                 :            : {
     998                 :        141 :     return maApiData.mnEscapement != API_ESCAPE_NONE;
     999                 :            : }
    1000                 :        420 : ::FontFamily lcl_getFontFamily( sal_Int32 nFamily )
    1001                 :            : {
    1002                 :            :     namespace cssawt = ::com::sun::star::awt;
    1003                 :            : 
    1004                 :        420 :     ::FontFamily eScFamily = FAMILY_DONTKNOW;
    1005   [ +  -  +  -  :        420 :     switch( nFamily )
                -  -  - ]
    1006                 :            :     {
    1007                 :            :         case cssawt::FontFamily::DONTKNOW:
    1008                 :        162 :             eScFamily = FAMILY_DONTKNOW;
    1009                 :        162 :             break;
    1010                 :            :         case cssawt::FontFamily::ROMAN:
    1011                 :          0 :             eScFamily = FAMILY_ROMAN;
    1012                 :          0 :             break;
    1013                 :            :         case cssawt::FontFamily::SWISS:
    1014                 :        258 :             eScFamily = FAMILY_SWISS;
    1015                 :        258 :             break;
    1016                 :            :         case cssawt::FontFamily::MODERN:
    1017                 :          0 :             eScFamily = FAMILY_MODERN;
    1018                 :          0 :             break;
    1019                 :            :         case cssawt::FontFamily::SCRIPT:
    1020                 :          0 :             eScFamily = FAMILY_SCRIPT;
    1021                 :          0 :             break;
    1022                 :            :         case cssawt::FontFamily::DECORATIVE:
    1023                 :          0 :             eScFamily = FAMILY_DECORATIVE;
    1024                 :          0 :             break;
    1025                 :            :     }
    1026                 :        420 :     return eScFamily;
    1027                 :            : }
    1028                 :            : 
    1029                 :        417 : void Font::fillToItemSet( SfxItemSet& rItemSet, FontPropertyType ePropType, bool bSkipPoolDefs ) const
    1030                 :            : {
    1031                 :            :     namespace cssawt = ::com::sun::star::awt;
    1032         [ +  - ]:        417 :     if ( maUsedFlags.mbNameUsed )
    1033                 :            :     {
    1034         [ +  - ]:        417 :         if( !maApiData.maLatinFont.maName.isEmpty() )
    1035                 :            :         {
    1036                 :        417 :             rtl_TextEncoding eFontEnc = maApiData.maLatinFont.mnTextEnc;
    1037                 :            :             SvxFontItem aFontItem( lcl_getFontFamily( maApiData.maLatinFont.mnFamily ), maApiData.maLatinFont.maName, rtl::OUString(),
    1038 [ +  - ][ +  - ]:        417 :                 PITCH_DONTKNOW, eFontEnc, ATTR_FONT );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1039                 :            :         }
    1040         [ -  + ]:        417 :         if( !maApiData.maAsianFont.maName.isEmpty() )
    1041                 :            :         {
    1042                 :          0 :             rtl_TextEncoding eFontEnc = maApiData.maAsianFont.mnTextEnc;
    1043                 :            :             SvxFontItem aFontItem( lcl_getFontFamily( maApiData.maAsianFont.mnFamily ), maApiData.maAsianFont.maName, rtl::OUString(),
    1044 [ #  # ][ #  # ]:          0 :                 PITCH_DONTKNOW, eFontEnc, ATTR_FONT );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1045                 :            :         }
    1046         [ +  + ]:        417 :         if( !maApiData.maCmplxFont.maName.isEmpty() )
    1047                 :            :         {
    1048                 :          3 :             rtl_TextEncoding eFontEnc = maApiData.maCmplxFont.mnTextEnc;
    1049                 :            :             SvxFontItem aFontItem( lcl_getFontFamily( maApiData.maCmplxFont.mnFamily ), maApiData.maCmplxFont.maName, rtl::OUString(),
    1050 [ +  - ][ +  - ]:          3 :                 PITCH_DONTKNOW, eFontEnc, ATTR_FONT );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1051                 :            :         }
    1052                 :            :     }
    1053                 :            :     // font height
    1054         [ +  - ]:        417 :     if( maUsedFlags.mbHeightUsed )
    1055                 :            :     {
    1056                 :            :         // leave in twips ?
    1057         [ +  - ]:        417 :         SvxFontHeightItem aHeightItem( maApiData.maDesc.Height, 100, ATTR_FONT_HEIGHT );
    1058         [ +  - ]:        417 :         ScfTools::PutItem( rItemSet, aHeightItem, ATTR_FONT_HEIGHT, bSkipPoolDefs );
    1059         [ +  - ]:        417 :         ScfTools::PutItem( rItemSet, aHeightItem, ATTR_CJK_FONT_HEIGHT, bSkipPoolDefs );
    1060 [ +  - ][ +  - ]:        417 :         ScfTools::PutItem( rItemSet, aHeightItem, ATTR_CTL_FONT_HEIGHT, bSkipPoolDefs );
    1061                 :            :     }
    1062                 :            :     // font weight
    1063         [ +  - ]:        417 :     if( maUsedFlags.mbWeightUsed )
    1064                 :            :     {
    1065         [ +  - ]:        417 :         ::FontWeight fWeight = VCLUnoHelper::ConvertFontWeight( maApiData.maDesc.Weight );
    1066         [ +  - ]:        417 :         SvxWeightItem aWeightItem( fWeight, ATTR_FONT_WEIGHT );
    1067         [ +  - ]:        417 :         ScfTools::PutItem( rItemSet, aWeightItem, ATTR_FONT_WEIGHT, bSkipPoolDefs );
    1068         [ +  - ]:        417 :         ScfTools::PutItem( rItemSet, aWeightItem, ATTR_CTL_FONT_WEIGHT, bSkipPoolDefs );
    1069 [ +  - ][ +  - ]:        417 :         ScfTools::PutItem( rItemSet, aWeightItem, ATTR_CJK_FONT_WEIGHT, bSkipPoolDefs );
    1070                 :            :     }
    1071                 :            :     // font posture
    1072         [ +  - ]:        417 :     if( maUsedFlags.mbPostureUsed )
    1073                 :            :     {
    1074 [ +  + ][ +  - ]:        417 :         SvxPostureItem aPostItem( ( maApiData.maDesc.Slant == cssawt::FontSlant_ITALIC ) ? ITALIC_NORMAL :  ITALIC_NONE,  ATTR_FONT_POSTURE);
    1075         [ +  - ]:        417 :         ScfTools::PutItem( rItemSet, aPostItem, ATTR_FONT_POSTURE, bSkipPoolDefs );
    1076         [ +  - ]:        417 :         ScfTools::PutItem( rItemSet, aPostItem, ATTR_CJK_FONT_POSTURE, bSkipPoolDefs );
    1077 [ +  - ][ +  - ]:        417 :         ScfTools::PutItem( rItemSet, aPostItem, ATTR_CTL_FONT_POSTURE, bSkipPoolDefs );
    1078                 :            :     }
    1079                 :            :     // character color
    1080         [ +  - ]:        417 :     if( maUsedFlags.mbColorUsed )
    1081                 :            :     {
    1082 [ +  - ][ +  - ]:        417 :         ScfTools::PutItem( rItemSet,SvxColorItem( maApiData.mnColor, ATTR_FONT_COLOR  ) , bSkipPoolDefs );
                 [ +  - ]
    1083                 :            :     }
    1084                 :            :     // underline style
    1085         [ +  - ]:        417 :     if( maUsedFlags.mbUnderlineUsed )
    1086                 :            :     {
    1087                 :            :         ::FontUnderline eScUnderl;
    1088         [ -  + ]:        417 :         if ( maApiData.maDesc.Underline == cssawt::FontUnderline::DOUBLE )
    1089                 :          0 :             eScUnderl = UNDERLINE_DOUBLE;
    1090         [ +  + ]:        417 :         else if ( maApiData.maDesc.Underline == cssawt::FontUnderline::SINGLE )
    1091                 :          9 :             eScUnderl = UNDERLINE_SINGLE;
    1092                 :            :         else
    1093                 :        408 :             eScUnderl = UNDERLINE_NONE;
    1094         [ +  - ]:        417 :         SvxUnderlineItem aUnderlItem( eScUnderl, ATTR_FONT_UNDERLINE );
    1095 [ +  - ][ +  - ]:        417 :         ScfTools::PutItem( rItemSet, aUnderlItem, ATTR_FONT_UNDERLINE, bSkipPoolDefs );
    1096                 :            :     }
    1097                 :            :     // strike out style
    1098         [ +  - ]:        417 :     if( maUsedFlags.mbStrikeoutUsed )
    1099                 :            :     {
    1100 [ +  + ][ +  - ]:        417 :         ScfTools::PutItem( rItemSet, SvxCrossedOutItem( maModel.mbStrikeout ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, ATTR_FONT_CROSSEDOUT ), ATTR_FONT_CROSSEDOUT, bSkipPoolDefs );
    1101                 :            :     }
    1102                 :            : 
    1103                 :            :     // outline style
    1104         [ +  - ]:        417 :     if( maUsedFlags.mbOutlineUsed )
    1105                 :            :     {
    1106         [ +  - ]:        417 :         ScfTools::PutItem( rItemSet, SvxContourItem( maApiData.mbOutline, ATTR_FONT_CONTOUR ), ATTR_FONT_CONTOUR, bSkipPoolDefs );
    1107                 :            :     }
    1108                 :            : 
    1109                 :            :     // shadow style
    1110         [ +  - ]:        417 :     if( maUsedFlags.mbShadowUsed )
    1111                 :            :     {
    1112         [ +  - ]:        417 :         ScfTools::PutItem( rItemSet, SvxShadowedItem( maApiData.mbShadow, ATTR_FONT_SHADOWED ), ATTR_FONT_SHADOWED, bSkipPoolDefs );
    1113                 :            :     }
    1114         [ +  - ]:        417 :     if( maUsedFlags.mbEscapementUsed )
    1115                 :            :     {
    1116                 :        417 :         SvxEscapement eScEscapem = SVX_ESCAPEMENT_OFF;
    1117         [ -  + ]:        417 :         if ( maApiData.mnEscapement == API_ESCAPE_SUPERSCRIPT )
    1118                 :          0 :             eScEscapem = SVX_ESCAPEMENT_SUPERSCRIPT;
    1119         [ -  + ]:        417 :         else if ( maApiData.mnEscapement == API_ESCAPE_SUBSCRIPT )
    1120                 :          0 :             eScEscapem = SVX_ESCAPEMENT_SUBSCRIPT;
    1121         [ +  - ]:        417 :         rItemSet.Put( SvxEscapementItem( eScEscapem, EE_CHAR_ESCAPEMENT ) );
    1122                 :            :         if( ePropType == FONT_PROPTYPE_TEXT )
    1123                 :            :         {
    1124                 :            :            // #TODO handle EscapementHeight
    1125                 :            :         }
    1126                 :            :     }
    1127                 :        417 : }
    1128                 :            : 
    1129                 :        129 : void Font::writeToPropertyMap( PropertyMap& rPropMap, FontPropertyType ePropType ) const
    1130                 :            : {
    1131                 :            :     // font name properties
    1132         [ +  - ]:        129 :     if( maUsedFlags.mbNameUsed )
    1133                 :            :     {
    1134         [ +  - ]:        129 :         if( !maApiData.maLatinFont.maName.isEmpty() )
    1135                 :            :         {
    1136                 :        129 :             rPropMap[ PROP_CharFontName ]    <<= maApiData.maLatinFont.maName;
    1137                 :        129 :             rPropMap[ PROP_CharFontFamily ]  <<= maApiData.maLatinFont.mnFamily;
    1138                 :        129 :             rPropMap[ PROP_CharFontCharSet ] <<= maApiData.maLatinFont.mnTextEnc;
    1139                 :            :         }
    1140         [ -  + ]:        129 :         if( !maApiData.maAsianFont.maName.isEmpty() )
    1141                 :            :         {
    1142                 :          0 :             rPropMap[ PROP_CharFontNameAsian ]    <<= maApiData.maAsianFont.maName;
    1143                 :          0 :             rPropMap[ PROP_CharFontFamilyAsian ]  <<= maApiData.maAsianFont.mnFamily;
    1144                 :          0 :             rPropMap[ PROP_CharFontCharSetAsian ] <<= maApiData.maAsianFont.mnTextEnc;
    1145                 :            :         }
    1146         [ +  + ]:        129 :         if( !maApiData.maCmplxFont.maName.isEmpty() )
    1147                 :            :         {
    1148                 :          3 :             rPropMap[ PROP_CharFontNameComplex ]    <<= maApiData.maCmplxFont.maName;
    1149                 :          3 :             rPropMap[ PROP_CharFontFamilyComplex ]  <<= maApiData.maCmplxFont.mnFamily;
    1150                 :          3 :             rPropMap[ PROP_CharFontCharSetComplex ] <<= maApiData.maCmplxFont.mnTextEnc;
    1151                 :            :         }
    1152                 :            :     }
    1153                 :            :     // font height
    1154         [ +  - ]:        129 :     if( maUsedFlags.mbHeightUsed )
    1155                 :            :     {
    1156                 :        129 :         float fHeight = static_cast< float >( maApiData.maDesc.Height / 20.0 ); // twips to points
    1157 [ +  - ][ +  - ]:        129 :         rPropMap[ PROP_CharHeight ] <<= fHeight;
    1158 [ +  - ][ +  - ]:        129 :         rPropMap[ PROP_CharHeightAsian ] <<= fHeight;
    1159 [ +  - ][ +  - ]:        129 :         rPropMap[ PROP_CharHeightComplex ] <<= fHeight;
    1160                 :            :     }
    1161                 :            :     // font weight
    1162         [ +  - ]:        129 :     if( maUsedFlags.mbWeightUsed )
    1163                 :            :     {
    1164                 :        129 :         float fWeight = maApiData.maDesc.Weight;
    1165 [ +  - ][ +  - ]:        129 :         rPropMap[ PROP_CharWeight ] <<= fWeight;
    1166 [ +  - ][ +  - ]:        129 :         rPropMap[ PROP_CharWeightAsian ] <<= fWeight;
    1167 [ +  - ][ +  - ]:        129 :         rPropMap[ PROP_CharWeightComplex ] <<= fWeight;
    1168                 :            :     }
    1169                 :            :     // font posture
    1170         [ +  - ]:        129 :     if( maUsedFlags.mbPostureUsed )
    1171                 :            :     {
    1172                 :        129 :         rPropMap[ PROP_CharPosture ] <<= maApiData.maDesc.Slant;
    1173                 :        129 :         rPropMap[ PROP_CharPostureAsian ] <<= maApiData.maDesc.Slant;
    1174                 :        129 :         rPropMap[ PROP_CharPostureComplex ] <<= maApiData.maDesc.Slant;
    1175                 :            :     }
    1176                 :            :     // character color
    1177         [ +  - ]:        129 :     if( maUsedFlags.mbColorUsed )
    1178                 :        129 :         rPropMap[ PROP_CharColor ] <<= maApiData.mnColor;
    1179                 :            :     // underline style
    1180         [ +  - ]:        129 :     if( maUsedFlags.mbUnderlineUsed )
    1181                 :        129 :         rPropMap[ PROP_CharUnderline ] <<= maApiData.maDesc.Underline;
    1182                 :            :     // strike out style
    1183         [ +  - ]:        129 :     if( maUsedFlags.mbStrikeoutUsed )
    1184                 :        129 :         rPropMap[ PROP_CharStrikeout ] <<= maApiData.maDesc.Strikeout;
    1185                 :            :     // outline style
    1186         [ +  - ]:        129 :     if( maUsedFlags.mbOutlineUsed )
    1187                 :        129 :         rPropMap[ PROP_CharContoured ] <<= maApiData.mbOutline;
    1188                 :            :     // shadow style
    1189         [ +  - ]:        129 :     if( maUsedFlags.mbShadowUsed )
    1190                 :        129 :         rPropMap[ PROP_CharShadowed ] <<= maApiData.mbShadow;
    1191                 :            :     // escapement
    1192         [ +  - ]:        129 :     if( maUsedFlags.mbEscapementUsed )
    1193                 :            :     {
    1194                 :        129 :         rPropMap[ PROP_CharEscapement ] <<= maApiData.mnEscapement;
    1195         [ +  + ]:        129 :         if( ePropType == FONT_PROPTYPE_TEXT )
    1196                 :        105 :             rPropMap[ PROP_CharEscapementHeight ] <<= maApiData.mnEscapeHeight;
    1197                 :            :     }
    1198                 :        129 : }
    1199                 :            : 
    1200                 :        105 : void Font::writeToPropertySet( PropertySet& rPropSet, FontPropertyType ePropType ) const
    1201                 :            : {
    1202         [ +  - ]:        105 :     PropertyMap aPropMap;
    1203         [ +  - ]:        105 :     writeToPropertyMap( aPropMap, ePropType );
    1204         [ +  - ]:        105 :     rPropSet.setProperties( aPropMap );
    1205                 :        105 : }
    1206                 :            : 
    1207                 :            : // ============================================================================
    1208                 :            : 
    1209                 :        465 : AlignmentModel::AlignmentModel() :
    1210                 :            :     mnHorAlign( XML_general ),
    1211                 :            :     mnVerAlign( XML_bottom ),
    1212                 :            :     mnTextDir( OOX_XF_TEXTDIR_CONTEXT ),
    1213                 :            :     mnRotation( OOX_XF_ROTATION_NONE ),
    1214                 :            :     mnIndent( OOX_XF_INDENT_NONE ),
    1215                 :            :     mbWrapText( false ),
    1216                 :            :     mbShrink( false ),
    1217                 :        465 :     mbJustLastLine( false )
    1218                 :            : {
    1219                 :        465 : }
    1220                 :            : 
    1221                 :          0 : void AlignmentModel::setBiffHorAlign( sal_uInt8 nHorAlign )
    1222                 :            : {
    1223                 :            :     static const sal_Int32 spnHorAligns[] = {
    1224                 :            :         XML_general, XML_left, XML_center, XML_right,
    1225                 :            :         XML_fill, XML_justify, XML_centerContinuous, XML_distributed };
    1226         [ #  # ]:          0 :     mnHorAlign = STATIC_ARRAY_SELECT( spnHorAligns, nHorAlign, XML_general );
    1227                 :          0 : }
    1228                 :            : 
    1229                 :          0 : void AlignmentModel::setBiffVerAlign( sal_uInt8 nVerAlign )
    1230                 :            : {
    1231                 :            :     static const sal_Int32 spnVerAligns[] = {
    1232                 :            :         XML_top, XML_center, XML_bottom, XML_justify, XML_distributed };
    1233         [ #  # ]:          0 :     mnVerAlign = STATIC_ARRAY_SELECT( spnVerAligns, nVerAlign, XML_bottom );
    1234                 :          0 : }
    1235                 :            : 
    1236                 :            : // ----------------------------------------------------------------------------
    1237                 :            : 
    1238                 :        465 : ApiAlignmentData::ApiAlignmentData() :
    1239                 :            :     meHorJustify( ::com::sun::star::table::CellHoriJustify_STANDARD ),
    1240                 :            :     mnHorJustifyMethod( ::com::sun::star::table::CellJustifyMethod::AUTO ),
    1241                 :            :     mnVerJustify( ::com::sun::star::table::CellVertJustify2::STANDARD ),
    1242                 :            :     mnVerJustifyMethod( ::com::sun::star::table::CellJustifyMethod::AUTO ),
    1243                 :            :     meOrientation( ::com::sun::star::table::CellOrientation_STANDARD ),
    1244                 :            :     mnRotation( 0 ),
    1245                 :            :     mnWritingMode( ::com::sun::star::text::WritingMode2::PAGE ),
    1246                 :            :     mnIndent( 0 ),
    1247                 :            :     mbWrapText( false ),
    1248                 :        465 :     mbShrink( false )
    1249                 :            : {
    1250                 :        465 : }
    1251                 :            : 
    1252                 :         87 : bool operator==( const ApiAlignmentData& rLeft, const ApiAlignmentData& rRight )
    1253                 :            : {
    1254                 :            :     return
    1255                 :            :         (rLeft.meHorJustify  == rRight.meHorJustify) &&
    1256                 :            :         (rLeft.mnHorJustifyMethod == rRight.mnHorJustifyMethod) &&
    1257                 :            :         (rLeft.mnVerJustify  == rRight.mnVerJustify) &&
    1258                 :            :         (rLeft.mnVerJustifyMethod == rRight.mnVerJustifyMethod) &&
    1259                 :            :         (rLeft.meOrientation == rRight.meOrientation) &&
    1260                 :            :         (rLeft.mnRotation    == rRight.mnRotation) &&
    1261                 :            :         (rLeft.mnWritingMode == rRight.mnWritingMode) &&
    1262                 :            :         (rLeft.mnIndent      == rRight.mnIndent) &&
    1263                 :            :         (rLeft.mbWrapText    == rRight.mbWrapText) &&
    1264 [ +  + ][ +  - ]:         87 :         (rLeft.mbShrink      == rRight.mbShrink);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1265                 :            : }
    1266                 :            : 
    1267                 :            : // ============================================================================
    1268                 :            : 
    1269                 :        465 : Alignment::Alignment( const WorkbookHelper& rHelper ) :
    1270                 :        465 :     WorkbookHelper( rHelper )
    1271                 :            : {
    1272                 :        465 : }
    1273                 :            : 
    1274                 :         33 : void Alignment::importAlignment( const AttributeList& rAttribs )
    1275                 :            : {
    1276                 :         33 :     maModel.mnHorAlign     = rAttribs.getToken( XML_horizontal, XML_general );
    1277                 :         33 :     maModel.mnVerAlign     = rAttribs.getToken( XML_vertical, XML_bottom );
    1278                 :         33 :     maModel.mnTextDir      = rAttribs.getInteger( XML_readingOrder, OOX_XF_TEXTDIR_CONTEXT );
    1279                 :         33 :     maModel.mnRotation     = rAttribs.getInteger( XML_textRotation, OOX_XF_ROTATION_NONE );
    1280                 :         33 :     maModel.mnIndent       = rAttribs.getInteger( XML_indent, OOX_XF_INDENT_NONE );
    1281                 :         33 :     maModel.mbWrapText     = rAttribs.getBool( XML_wrapText, false );
    1282                 :         33 :     maModel.mbShrink       = rAttribs.getBool( XML_shrinkToFit, false );
    1283                 :         33 :     maModel.mbJustLastLine = rAttribs.getBool( XML_justifyLastLine, false );
    1284                 :         33 : }
    1285                 :            : 
    1286                 :          0 : void Alignment::setBiff12Data( sal_uInt32 nFlags )
    1287                 :            : {
    1288                 :          0 :     maModel.setBiffHorAlign( extractValue< sal_uInt8 >( nFlags, 16, 3 ) );
    1289                 :          0 :     maModel.setBiffVerAlign( extractValue< sal_uInt8 >( nFlags, 19, 3 ) );
    1290                 :          0 :     maModel.mnTextDir      = extractValue< sal_Int32 >( nFlags, 26, 2 );
    1291                 :          0 :     maModel.mnRotation     = extractValue< sal_Int32 >( nFlags, 0, 8 );
    1292                 :          0 :     maModel.mnIndent       = extractValue< sal_uInt8 >( nFlags, 8, 8 );
    1293                 :          0 :     maModel.mbWrapText     = getFlag( nFlags, BIFF12_XF_WRAPTEXT );
    1294                 :          0 :     maModel.mbShrink       = getFlag( nFlags, BIFF12_XF_SHRINK );
    1295                 :          0 :     maModel.mbJustLastLine = getFlag( nFlags, BIFF12_XF_JUSTLASTLINE );
    1296                 :          0 : }
    1297                 :            : 
    1298                 :        465 : void Alignment::finalizeImport()
    1299                 :            : {
    1300                 :            :     namespace csstab = ::com::sun::star::table;
    1301                 :            :     namespace csstxt = ::com::sun::star::text;
    1302                 :            : 
    1303                 :            :     // horizontal alignment
    1304   [ +  -  -  -  :        465 :     switch( maModel.mnHorAlign )
             +  +  -  +  
                      - ]
    1305                 :            :     {
    1306                 :          9 :         case XML_center:            maApiData.meHorJustify = csstab::CellHoriJustify_CENTER;    break;
    1307                 :          0 :         case XML_centerContinuous:  maApiData.meHorJustify = csstab::CellHoriJustify_CENTER;    break;
    1308                 :          0 :         case XML_distributed:       maApiData.meHorJustify = csstab::CellHoriJustify_BLOCK;     break;
    1309                 :          0 :         case XML_fill:              maApiData.meHorJustify = csstab::CellHoriJustify_REPEAT;    break;
    1310                 :        450 :         case XML_general:           maApiData.meHorJustify = csstab::CellHoriJustify_STANDARD;  break;
    1311                 :          3 :         case XML_justify:           maApiData.meHorJustify = csstab::CellHoriJustify_BLOCK;     break;
    1312                 :          0 :         case XML_left:              maApiData.meHorJustify = csstab::CellHoriJustify_LEFT;      break;
    1313                 :          3 :         case XML_right:             maApiData.meHorJustify = csstab::CellHoriJustify_RIGHT;     break;
    1314                 :            :     }
    1315                 :            : 
    1316         [ -  + ]:        465 :     if (maModel.mnHorAlign == XML_distributed)
    1317                 :          0 :         maApiData.mnHorJustifyMethod = csstab::CellJustifyMethod::DISTRIBUTE;
    1318                 :            : 
    1319                 :            :     // vertical alignment
    1320   [ +  -  -  -  :        465 :     switch( maModel.mnVerAlign )
                   -  - ]
    1321                 :            :     {
    1322                 :        465 :         case XML_bottom:        maApiData.mnVerJustify = csstab::CellVertJustify2::BOTTOM;    break;
    1323                 :          0 :         case XML_center:        maApiData.mnVerJustify = csstab::CellVertJustify2::CENTER;    break;
    1324                 :          0 :         case XML_distributed:   maApiData.mnVerJustify = csstab::CellVertJustify2::BLOCK;     break;
    1325                 :          0 :         case XML_justify:       maApiData.mnVerJustify = csstab::CellVertJustify2::BLOCK;     break;
    1326                 :          0 :         case XML_top:           maApiData.mnVerJustify = csstab::CellVertJustify2::TOP;       break;
    1327                 :            :     }
    1328                 :            : 
    1329         [ -  + ]:        465 :     if (maModel.mnVerAlign == XML_distributed)
    1330                 :          0 :         maApiData.mnVerJustifyMethod = csstab::CellJustifyMethod::DISTRIBUTE;
    1331                 :            : 
    1332                 :            :     /*  indentation: expressed as number of blocks of 3 space characters in
    1333                 :            :         OOXML/BIFF12, and as multiple of 10 points in BIFF8. */
    1334                 :        465 :     sal_Int32 nIndent = 0;
    1335   [ +  -  -  - ]:        465 :     switch( getFilterType() )
    1336                 :            :     {
    1337                 :        465 :         case FILTER_OOXML:  nIndent = getUnitConverter().scaleToMm100( 3.0 * maModel.mnIndent, UNIT_SPACE );  break;
    1338                 :          0 :         case FILTER_BIFF:   nIndent = getUnitConverter().scaleToMm100( 10.0 * maModel.mnIndent, UNIT_POINT ); break;
    1339                 :          0 :         case FILTER_UNKNOWN: break;
    1340                 :            :     }
    1341 [ +  - ][ +  - ]:        465 :     if( (0 <= nIndent) && (nIndent <= SAL_MAX_INT16) )
    1342                 :        465 :         maApiData.mnIndent = static_cast< sal_Int16 >( nIndent );
    1343                 :            : 
    1344                 :            :     // complex text direction
    1345   [ +  -  -  - ]:        465 :     switch( maModel.mnTextDir )
    1346                 :            :     {
    1347                 :        465 :         case OOX_XF_TEXTDIR_CONTEXT:    maApiData.mnWritingMode = csstxt::WritingMode2::PAGE;   break;
    1348                 :          0 :         case OOX_XF_TEXTDIR_LTR:        maApiData.mnWritingMode = csstxt::WritingMode2::LR_TB;  break;
    1349                 :          0 :         case OOX_XF_TEXTDIR_RTL:        maApiData.mnWritingMode = csstxt::WritingMode2::RL_TB;  break;
    1350                 :            :     }
    1351                 :            : 
    1352                 :            :     // rotation: 0-90 means 0 to 90 degrees ccw, 91-180 means 1 to 90 degrees cw, 255 means stacked
    1353                 :        465 :     sal_Int32 nOoxRot = maModel.mnRotation;
    1354                 :            :     maApiData.mnRotation = ((0 <= nOoxRot) && (nOoxRot <= 90)) ?
    1355                 :            :         (100 * nOoxRot) :
    1356 [ +  - ][ +  - ]:        465 :         (((91 <= nOoxRot) && (nOoxRot <= 180)) ? (100 * (450 - nOoxRot)) : 0);
         [ #  # ][ #  # ]
    1357                 :            : 
    1358                 :            :     // "Orientation" property used for character stacking
    1359                 :            :     maApiData.meOrientation = (nOoxRot == OOX_XF_ROTATION_STACKED) ?
    1360         [ -  + ]:        465 :         csstab::CellOrientation_STACKED : csstab::CellOrientation_STANDARD;
    1361                 :            : 
    1362                 :            :     // alignment flags (#i84960 automatic line break, if vertically justified/distributed)
    1363 [ +  - ][ +  - ]:        465 :     maApiData.mbWrapText = maModel.mbWrapText || (maModel.mnVerAlign == XML_distributed) || (maModel.mnVerAlign == XML_justify);
                 [ -  + ]
    1364                 :        465 :     maApiData.mbShrink = maModel.mbShrink;
    1365                 :            : 
    1366                 :        465 : }
    1367                 :            : 
    1368                 :         45 : ::SvxCellVerJustify Alignment::GetScVerAlign() const
    1369                 :            : {
    1370                 :            :     namespace csstab = ::com::sun::star::table;
    1371                 :         45 :     ::SvxCellVerJustify nVert = ::SVX_VER_JUSTIFY_STANDARD;
    1372   [ +  -  -  -  :         45 :     switch ( maApiData.mnVerJustify )
                      - ]
    1373                 :            :     {
    1374                 :            :         case csstab::CellVertJustify2::BOTTOM:
    1375                 :         45 :             nVert = ::SVX_VER_JUSTIFY_BOTTOM;
    1376                 :         45 :             break;
    1377                 :            :         case csstab::CellVertJustify2::CENTER:
    1378                 :          0 :             nVert = ::SVX_VER_JUSTIFY_CENTER;
    1379                 :          0 :             break;
    1380                 :            :         case csstab::CellVertJustify2::TOP:
    1381                 :          0 :             nVert = ::SVX_VER_JUSTIFY_TOP;
    1382                 :          0 :             break;
    1383                 :            :         case csstab::CellVertJustify2::BLOCK:
    1384                 :          0 :             nVert = ::SVX_VER_JUSTIFY_BLOCK;
    1385                 :          0 :             break;
    1386                 :            :         case csstab::CellVertJustify2::STANDARD:
    1387                 :            :         default:
    1388                 :          0 :             nVert = ::SVX_VER_JUSTIFY_STANDARD;
    1389                 :          0 :             break;
    1390                 :            :     }
    1391                 :         45 :     return nVert;
    1392                 :            : }
    1393                 :            : 
    1394                 :         45 : ::SvxCellHorJustify Alignment::GetScHorAlign() const
    1395                 :            : {
    1396                 :            :     namespace csstab = ::com::sun::star::table;
    1397                 :         45 :     ::SvxCellHorJustify nHori = ::SVX_HOR_JUSTIFY_STANDARD;
    1398   [ -  +  +  +  :         45 :     switch( maApiData.meHorJustify )
                   -  + ]
    1399                 :            :     {
    1400                 :            :         case csstab::CellHoriJustify_LEFT:
    1401                 :          0 :             nHori = ::SVX_HOR_JUSTIFY_LEFT;
    1402                 :          0 :             break;
    1403                 :            :         case csstab::CellHoriJustify_CENTER:
    1404                 :          9 :             nHori = ::SVX_HOR_JUSTIFY_CENTER;
    1405                 :          9 :             break;
    1406                 :            :         case csstab::CellHoriJustify_RIGHT:
    1407                 :          3 :             nHori = ::SVX_HOR_JUSTIFY_RIGHT;
    1408                 :          3 :             break;
    1409                 :            :         case csstab::CellHoriJustify_BLOCK:
    1410                 :          3 :             nHori = ::SVX_HOR_JUSTIFY_BLOCK;
    1411                 :          3 :             break;
    1412                 :            :         case csstab::CellHoriJustify_REPEAT:
    1413                 :          0 :             nHori = ::SVX_HOR_JUSTIFY_REPEAT;
    1414                 :          0 :             break;
    1415                 :            :         case csstab::CellHoriJustify_STANDARD:
    1416                 :            :         default:
    1417                 :         30 :             nHori = ::SVX_HOR_JUSTIFY_STANDARD;
    1418                 :         30 :             break;
    1419                 :            :     }
    1420                 :         45 :     return nHori;
    1421                 :            : }
    1422                 :            : 
    1423                 :         45 : ::SvxFrameDirection Alignment::GetScFrameDir() const
    1424                 :            : {
    1425                 :            :     namespace csstxt = ::com::sun::star::text;
    1426                 :         45 :     ::SvxFrameDirection eFrameDir = ::FRMDIR_ENVIRONMENT;
    1427   [ +  -  -  - ]:         45 :     switch( maApiData.mnWritingMode )
    1428                 :            :     {
    1429                 :            :         case csstxt::WritingMode2::PAGE:
    1430                 :         45 :             eFrameDir = ::FRMDIR_ENVIRONMENT;
    1431                 :         45 :             break;
    1432                 :            :         case csstxt::WritingMode2::LR_TB:
    1433                 :          0 :             eFrameDir = ::FRMDIR_HORI_LEFT_TOP;
    1434                 :          0 :             break;
    1435                 :            :         case csstxt::WritingMode2::RL_TB:
    1436                 :          0 :             eFrameDir = ::FRMDIR_HORI_RIGHT_TOP;
    1437                 :          0 :             break;
    1438                 :            :         default:
    1439                 :            :             OSL_FAIL( "GetScFrameDir - unknown CTL text direction" );
    1440                 :            :     }
    1441                 :         45 :     return eFrameDir;
    1442                 :            : }
    1443                 :            : 
    1444                 :         45 : void Alignment::fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
    1445                 :            : {
    1446                 :            :     namespace csstab = ::com::sun::star::table;
    1447                 :            :     // horizontal alignment
    1448         [ +  - ]:         45 :     ScfTools::PutItem( rItemSet, SvxHorJustifyItem( GetScHorAlign(), ATTR_HOR_JUSTIFY ), bSkipPoolDefs );
    1449 [ +  - ][ -  + ]:         45 :     ScfTools::PutItem( rItemSet, SvxJustifyMethodItem( ( maApiData.mnHorJustifyMethod == csstab::CellJustifyMethod::DISTRIBUTE ) ? ::SVX_JUSTIFY_METHOD_DISTRIBUTE : ::SVX_JUSTIFY_METHOD_AUTO, ATTR_HOR_JUSTIFY_METHOD ), bSkipPoolDefs );
    1450         [ +  - ]:         45 :     ScfTools::PutItem( rItemSet, SvxVerJustifyItem( GetScVerAlign(), ATTR_VER_JUSTIFY ), bSkipPoolDefs );
    1451                 :            :     // vertical alignment
    1452 [ +  - ][ -  + ]:         45 :     ScfTools::PutItem( rItemSet, SvxJustifyMethodItem( ( maApiData.mnVerJustifyMethod == csstab::CellJustifyMethod::DISTRIBUTE ) ? ::SVX_JUSTIFY_METHOD_DISTRIBUTE : ::SVX_JUSTIFY_METHOD_AUTO, ATTR_VER_JUSTIFY_METHOD ), bSkipPoolDefs );
    1453                 :            : 
    1454                 :            :     // CTL text direction
    1455         [ +  - ]:         45 :     ScfTools::PutItem( rItemSet, SvxFrameDirectionItem( GetScFrameDir(), ATTR_WRITINGDIR ), bSkipPoolDefs );
    1456                 :            :     // set an angle in the range from -90 to 90 degrees
    1457         [ +  - ]:         45 :     ScfTools::PutItem( rItemSet, SfxInt32Item( ATTR_ROTATE_VALUE, maApiData.mnRotation ), bSkipPoolDefs );
    1458                 :            :     // Orientation
    1459         [ +  - ]:         45 :     ScfTools::PutItem( rItemSet, SfxBoolItem( ATTR_STACKED, maApiData.meOrientation == csstab::CellOrientation_STACKED ), bSkipPoolDefs );
    1460                 :            :     // indent
    1461         [ +  - ]:         45 :     ScfTools::PutItem( rItemSet, SfxUInt16Item( ATTR_INDENT, maApiData.mnIndent ), bSkipPoolDefs );
    1462                 :            :     // line wrap
    1463         [ +  - ]:         45 :     ScfTools::PutItem( rItemSet, SfxBoolItem( ATTR_LINEBREAK, maApiData.mbWrapText ), bSkipPoolDefs );
    1464         [ +  - ]:         45 :     ScfTools::PutItem( rItemSet, SfxBoolItem( ATTR_SHRINKTOFIT, maApiData.mbShrink ), bSkipPoolDefs );
    1465                 :         45 : }
    1466                 :            : 
    1467                 :         24 : void Alignment::writeToPropertyMap( PropertyMap& rPropMap ) const
    1468                 :            : {
    1469                 :         24 :     rPropMap[ PROP_HoriJustify ]     <<= maApiData.meHorJustify;
    1470                 :         24 :     rPropMap[ PROP_HoriJustifyMethod ] <<= maApiData.mnHorJustifyMethod;
    1471                 :         24 :     rPropMap[ PROP_VertJustify ]     <<= maApiData.mnVerJustify;
    1472                 :         24 :     rPropMap[ PROP_VertJustifyMethod ] <<= maApiData.mnVerJustifyMethod;
    1473                 :         24 :     rPropMap[ PROP_WritingMode ]     <<= maApiData.mnWritingMode;
    1474                 :         24 :     rPropMap[ PROP_RotateAngle ]     <<= maApiData.mnRotation;
    1475                 :         24 :     rPropMap[ PROP_Orientation ]     <<= maApiData.meOrientation;
    1476                 :         24 :     rPropMap[ PROP_ParaIndent ]      <<= maApiData.mnIndent;
    1477                 :         24 :     rPropMap[ PROP_IsTextWrapped ]   <<= maApiData.mbWrapText;
    1478                 :         24 :     rPropMap[ PROP_ShrinkToFit ]     <<= maApiData.mbShrink;
    1479                 :         24 : }
    1480                 :            : 
    1481                 :            : // ============================================================================
    1482                 :            : 
    1483                 :        465 : ProtectionModel::ProtectionModel() :
    1484                 :            :     mbLocked( true ),   // default in Excel and Calc
    1485                 :        465 :     mbHidden( false )
    1486                 :            : {
    1487                 :        465 : }
    1488                 :            : 
    1489                 :            : // ----------------------------------------------------------------------------
    1490                 :            : 
    1491                 :        465 : ApiProtectionData::ApiProtectionData() :
    1492                 :        465 :     maCellProt( sal_True, sal_False, sal_False, sal_False )
    1493                 :            : {
    1494                 :        465 : }
    1495                 :            : 
    1496                 :         87 : bool operator==( const ApiProtectionData& rLeft, const ApiProtectionData& rRight )
    1497                 :            : {
    1498                 :            :     return
    1499                 :            :         (rLeft.maCellProt.IsLocked        == rRight.maCellProt.IsLocked) &&
    1500                 :            :         (rLeft.maCellProt.IsFormulaHidden == rRight.maCellProt.IsFormulaHidden) &&
    1501                 :            :         (rLeft.maCellProt.IsHidden        == rRight.maCellProt.IsHidden) &&
    1502 [ +  - ][ +  - ]:         87 :         (rLeft.maCellProt.IsPrintHidden   == rRight.maCellProt.IsPrintHidden);
         [ +  - ][ +  - ]
    1503                 :            : }
    1504                 :            : 
    1505                 :            : // ============================================================================
    1506                 :            : 
    1507                 :        465 : Protection::Protection( const WorkbookHelper& rHelper ) :
    1508                 :        465 :     WorkbookHelper( rHelper )
    1509                 :            : {
    1510                 :        465 : }
    1511                 :            : 
    1512                 :         18 : void Protection::importProtection( const AttributeList& rAttribs )
    1513                 :            : {
    1514                 :         18 :     maModel.mbLocked = rAttribs.getBool( XML_locked, true );
    1515                 :         18 :     maModel.mbHidden = rAttribs.getBool( XML_hidden, false );
    1516                 :         18 : }
    1517                 :            : 
    1518                 :          0 : void Protection::setBiff12Data( sal_uInt32 nFlags )
    1519                 :            : {
    1520                 :          0 :     maModel.mbLocked = getFlag( nFlags, BIFF12_XF_LOCKED );
    1521                 :          0 :     maModel.mbHidden = getFlag( nFlags, BIFF12_XF_HIDDEN );
    1522                 :          0 : }
    1523                 :            : 
    1524                 :        465 : void Protection::finalizeImport()
    1525                 :            : {
    1526                 :        465 :     maApiData.maCellProt.IsLocked = maModel.mbLocked;
    1527                 :        465 :     maApiData.maCellProt.IsFormulaHidden = maModel.mbHidden;
    1528                 :        465 : }
    1529                 :            : 
    1530                 :         24 : void Protection::writeToPropertyMap( PropertyMap& rPropMap ) const
    1531                 :            : {
    1532                 :         24 :     rPropMap[ PROP_CellProtection ] <<= maApiData.maCellProt;
    1533                 :         24 : }
    1534                 :            : 
    1535                 :         36 : void Protection::fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
    1536                 :            : {
    1537         [ +  - ]:         36 :     ScfTools::PutItem( rItemSet, ScProtectionAttr( maApiData.maCellProt.IsLocked, maApiData.maCellProt.IsFormulaHidden ), bSkipPoolDefs );
    1538                 :         36 : }
    1539                 :            : 
    1540                 :            : // ============================================================================
    1541                 :            : 
    1542                 :            : namespace {
    1543                 :            : 
    1544                 :        108 : bool lcl_isBorder(const ::com::sun::star::table::BorderLine& rBorder)
    1545                 :            : {
    1546 [ +  - ][ -  + ]:        108 :     return (rBorder.InnerLineWidth > 0) || (rBorder.OuterLineWidth > 0);
    1547                 :            : }
    1548                 :            : 
    1549                 :            : }
    1550                 :            : 
    1551                 :        120 : BorderLineModel::BorderLineModel( bool bDxf ) :
    1552                 :            :     mnStyle( XML_none ),
    1553                 :        120 :     mbUsed( !bDxf )
    1554                 :            : {
    1555         [ +  - ]:        120 :     maColor.setIndexed( OOX_COLOR_WINDOWTEXT );
    1556                 :        120 : }
    1557                 :            : 
    1558                 :          0 : void BorderLineModel::setBiffStyle( sal_Int32 nLineStyle )
    1559                 :            : {
    1560                 :            :     static const sal_Int32 spnStyleIds[] = {
    1561                 :            :         XML_none, XML_thin, XML_medium, XML_dashed,
    1562                 :            :         XML_dotted, XML_thick, XML_double, XML_hair,
    1563                 :            :         XML_mediumDashed, XML_dashDot, XML_mediumDashDot, XML_dashDotDot,
    1564                 :            :         XML_mediumDashDotDot, XML_slantDashDot };
    1565         [ #  # ]:          0 :     mnStyle = STATIC_ARRAY_SELECT( spnStyleIds, nLineStyle, XML_none );
    1566                 :          0 : }
    1567                 :            : 
    1568                 :            : // ----------------------------------------------------------------------------
    1569                 :            : 
    1570                 :         24 : BorderModel::BorderModel( bool bDxf ) :
    1571                 :            :     maLeft( bDxf ),
    1572                 :            :     maRight( bDxf ),
    1573                 :            :     maTop( bDxf ),
    1574                 :            :     maBottom( bDxf ),
    1575                 :            :     maDiagonal( bDxf ),
    1576                 :            :     mbDiagTLtoBR( false ),
    1577 [ +  - ][ +  - ]:         24 :     mbDiagBLtoTR( false )
         [ +  - ][ +  - ]
    1578                 :            : {
    1579                 :         24 : }
    1580                 :            : 
    1581                 :            : // ----------------------------------------------------------------------------
    1582                 :            : 
    1583                 :         24 : ApiBorderData::ApiBorderData() :
    1584                 :            :     mbBorderUsed( false ),
    1585                 :         24 :     mbDiagUsed( false )
    1586                 :            : {
    1587                 :         24 : }
    1588                 :            : 
    1589                 :          3 : bool ApiBorderData::hasAnyOuterBorder() const
    1590                 :            : {
    1591                 :            :     return
    1592                 :          3 :         ( ( lcl_isBorder( maTop ) &&  maTop.OuterLineWidth > 0 ) ) ||
    1593                 :          3 :         ( ( lcl_isBorder( maBottom ) && maBottom.OuterLineWidth > 0 ) ) ||
    1594                 :          3 :         ( ( lcl_isBorder( maLeft ) && maLeft.OuterLineWidth > 0 ) ) ||
    1595   [ #  #  -  + ]:          9 :         ( ( lcl_isBorder( maRight ) && maRight.OuterLineWidth > 0 ) );
           [ #  #  -  + ]
         [ #  # ][ -  + ]
         [ #  # ][ -  + ]
    1596                 :            : }
    1597                 :            : 
    1598                 :            : namespace {
    1599                 :            : 
    1600                 :          0 : bool operator==( const BorderLine& rLeft, const BorderLine& rRight )
    1601                 :            : {
    1602                 :            :     return
    1603                 :            :         (rLeft.Color          == rRight.Color) &&
    1604                 :            :         (rLeft.InnerLineWidth == rRight.InnerLineWidth) &&
    1605                 :            :         (rLeft.OuterLineWidth == rRight.OuterLineWidth) &&
    1606 [ #  # ][ #  # ]:          0 :         (rLeft.LineDistance   == rRight.LineDistance);
         [ #  # ][ #  # ]
    1607                 :            : }
    1608                 :            : 
    1609                 :            : } // namespace
    1610                 :            : 
    1611                 :          0 : bool operator==( const ApiBorderData& rLeft, const ApiBorderData& rRight )
    1612                 :            : {
    1613                 :            :     return
    1614                 :          0 :         (rLeft.maLeft       == rRight.maLeft)   &&
    1615                 :          0 :         (rLeft.maRight      == rRight.maRight)  &&
    1616                 :          0 :         (rLeft.maTop        == rRight.maTop)    &&
    1617                 :          0 :         (rLeft.maBottom     == rRight.maBottom) &&
    1618                 :          0 :         (rLeft.maTLtoBR     == rRight.maTLtoBR) &&
    1619                 :          0 :         (rLeft.maBLtoTR     == rRight.maBLtoTR) &&
    1620                 :            :         (rLeft.mbBorderUsed == rRight.mbBorderUsed) &&
    1621 [ #  # ][ #  # ]:          0 :         (rLeft.mbDiagUsed   == rRight.mbDiagUsed);
           [ #  #  #  #  
          #  #  #  #  #  
                #  #  # ]
    1622                 :            : }
    1623                 :            : 
    1624                 :            : // ============================================================================
    1625                 :            : 
    1626                 :            : namespace {
    1627                 :            : 
    1628                 :         96 : inline void lclSetBorderLineWidth( BorderLine& rBorderLine,
    1629                 :            :         sal_Int16 nOuter, sal_Int16 nDist = API_LINE_NONE, sal_Int16 nInner = API_LINE_NONE )
    1630                 :            : {
    1631                 :         96 :     rBorderLine.OuterLineWidth = nOuter;
    1632                 :         96 :     rBorderLine.LineDistance = nDist;
    1633                 :         96 :     rBorderLine.InnerLineWidth = nInner;
    1634                 :         96 : }
    1635                 :            : 
    1636                 :            : } // namespace
    1637                 :            : 
    1638                 :            : // ----------------------------------------------------------------------------
    1639                 :            : 
    1640                 :         24 : Border::Border( const WorkbookHelper& rHelper, bool bDxf ) :
    1641                 :            :     WorkbookHelper( rHelper ),
    1642                 :            :     maModel( bDxf ),
    1643         [ +  - ]:         24 :     mbDxf( bDxf )
    1644                 :            : {
    1645                 :         24 : }
    1646                 :            : 
    1647                 :         24 : void Border::importBorder( const AttributeList& rAttribs )
    1648                 :            : {
    1649                 :         24 :     maModel.mbDiagTLtoBR = rAttribs.getBool( XML_diagonalDown, false );
    1650                 :         24 :     maModel.mbDiagBLtoTR = rAttribs.getBool( XML_diagonalUp, false );
    1651                 :         24 : }
    1652                 :            : 
    1653                 :        120 : void Border::importStyle( sal_Int32 nElement, const AttributeList& rAttribs )
    1654                 :            : {
    1655         [ +  - ]:        120 :     if( BorderLineModel* pBorderLine = getBorderLine( nElement ) )
    1656                 :            :     {
    1657                 :        120 :         pBorderLine->mnStyle = rAttribs.getToken( XML_style, XML_none );
    1658                 :        120 :         pBorderLine->mbUsed = true;
    1659                 :            :     }
    1660                 :        120 : }
    1661                 :            : 
    1662                 :          0 : void Border::importColor( sal_Int32 nElement, const AttributeList& rAttribs )
    1663                 :            : {
    1664         [ #  # ]:          0 :     if( BorderLineModel* pBorderLine = getBorderLine( nElement ) )
    1665                 :          0 :         pBorderLine->maColor.importColor( rAttribs );
    1666                 :          0 : }
    1667                 :            : 
    1668                 :          0 : void Border::importBorder( SequenceInputStream& rStrm )
    1669                 :            : {
    1670                 :          0 :     sal_uInt8 nFlags = rStrm.readuInt8();
    1671                 :          0 :     maModel.mbDiagTLtoBR = getFlag( nFlags, BIFF12_BORDER_DIAG_TLBR );
    1672                 :          0 :     maModel.mbDiagBLtoTR = getFlag( nFlags, BIFF12_BORDER_DIAG_BLTR );
    1673                 :          0 :     maModel.maTop.setBiffStyle( rStrm.readuInt16() );
    1674                 :          0 :     rStrm >> maModel.maTop.maColor;
    1675                 :          0 :     maModel.maBottom.setBiffStyle( rStrm.readuInt16() );
    1676                 :          0 :     rStrm >> maModel.maBottom.maColor;
    1677                 :          0 :     maModel.maLeft.setBiffStyle( rStrm.readuInt16() );
    1678                 :          0 :     rStrm >> maModel.maLeft.maColor;
    1679                 :          0 :     maModel.maRight.setBiffStyle( rStrm.readuInt16() );
    1680                 :          0 :     rStrm >> maModel.maRight.maColor;
    1681                 :          0 :     maModel.maDiagonal.setBiffStyle( rStrm.readuInt16() );
    1682                 :          0 :     rStrm >> maModel.maDiagonal.maColor;
    1683                 :          0 : }
    1684                 :            : 
    1685                 :          0 : void Border::importDxfBorder( sal_Int32 nElement, SequenceInputStream& rStrm )
    1686                 :            : {
    1687                 :            :     OSL_ENSURE( mbDxf, "Border::importDxfBorder - missing conditional formatting flag" );
    1688         [ #  # ]:          0 :     if( BorderLineModel* pBorderLine = getBorderLine( nElement ) )
    1689                 :            :     {
    1690                 :            :         sal_uInt16 nStyle;
    1691 [ #  # ][ #  # ]:          0 :         rStrm >> pBorderLine->maColor >> nStyle;
    1692                 :          0 :         pBorderLine->setBiffStyle( nStyle );
    1693                 :          0 :         pBorderLine->mbUsed = true;
    1694                 :            :     }
    1695                 :          0 : }
    1696                 :            : 
    1697                 :         24 : void Border::finalizeImport()
    1698                 :            : {
    1699 [ -  + ][ #  # ]:         24 :     maApiData.mbBorderUsed = maModel.maLeft.mbUsed || maModel.maRight.mbUsed || maModel.maTop.mbUsed || maModel.maBottom.mbUsed;
         [ #  # ][ #  # ]
    1700                 :         24 :     maApiData.mbDiagUsed   = maModel.maDiagonal.mbUsed;
    1701                 :            : 
    1702                 :         24 :     convertBorderLine( maApiData.maLeft,   maModel.maLeft );
    1703                 :         24 :     convertBorderLine( maApiData.maRight,  maModel.maRight );
    1704                 :         24 :     convertBorderLine( maApiData.maTop,    maModel.maTop );
    1705                 :         24 :     convertBorderLine( maApiData.maBottom, maModel.maBottom );
    1706                 :            : 
    1707         [ -  + ]:         24 :     if( maModel.mbDiagTLtoBR )
    1708                 :          0 :         convertBorderLine( maApiData.maTLtoBR, maModel.maDiagonal );
    1709         [ -  + ]:         24 :     if( maModel.mbDiagBLtoTR )
    1710                 :          0 :         convertBorderLine( maApiData.maBLtoTR, maModel.maDiagonal );
    1711                 :         24 : }
    1712                 :            : 
    1713                 :         36 : void Border::fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
    1714                 :            : {
    1715         [ +  - ]:         36 :     if( maApiData.mbBorderUsed )
    1716                 :            :     {
    1717         [ +  - ]:         36 :          SvxBoxItem aBoxItem( ATTR_BORDER );
    1718         [ +  - ]:         36 :          ::editeng::SvxBorderLine aLine;
    1719                 :            : 
    1720 [ +  - ][ -  + ]:         36 :          if ( SvxBoxItem::LineToSvxLine(maApiData.maLeft, aLine, true ) )
    1721                 :            :          {
    1722         [ #  # ]:          0 :              aBoxItem.SetLine( &aLine, BOX_LINE_LEFT );
    1723                 :            :          }
    1724 [ +  - ][ -  + ]:         36 :          if ( SvxBoxItem::LineToSvxLine(maApiData.maRight, aLine, true ) )
    1725                 :            :          {
    1726         [ #  # ]:          0 :              aBoxItem.SetLine( &aLine, BOX_LINE_RIGHT );
    1727                 :            :          }
    1728 [ +  - ][ -  + ]:         36 :          if ( SvxBoxItem::LineToSvxLine(maApiData.maTop, aLine, true ) )
    1729                 :            :          {
    1730         [ #  # ]:          0 :              aBoxItem.SetLine( &aLine, BOX_LINE_TOP );
    1731                 :            :          }
    1732 [ +  - ][ -  + ]:         36 :          if ( SvxBoxItem::LineToSvxLine(maApiData.maBottom, aLine, true ) )
    1733                 :            :          {
    1734         [ #  # ]:          0 :              aBoxItem.SetLine( &aLine, BOX_LINE_BOTTOM );
    1735                 :            :          }
    1736 [ +  - ][ +  - ]:         36 :          ScfTools::PutItem( rItemSet, aBoxItem, bSkipPoolDefs );
    1737                 :            :     }
    1738         [ +  - ]:         36 :     if ( maApiData.mbDiagUsed )
    1739                 :            :     {
    1740         [ +  - ]:         36 :         SvxLineItem aTLBRItem( ATTR_BORDER_TLBR );
    1741         [ +  - ]:         36 :         SvxLineItem aBLTRItem( ATTR_BORDER_BLTR );
    1742         [ +  - ]:         36 :         ::editeng::SvxBorderLine aLine;
    1743 [ +  - ][ -  + ]:         36 :         if ( SvxBoxItem::LineToSvxLine(maApiData.maTLtoBR, aLine, true ) )
    1744                 :            :         {
    1745         [ #  # ]:          0 :             aTLBRItem.SetLine( &aLine );
    1746                 :            :         }
    1747 [ +  - ][ -  + ]:         36 :         if ( SvxBoxItem::LineToSvxLine(maApiData.maBLtoTR, aLine, true ) )
    1748                 :            :         {
    1749         [ #  # ]:          0 :             aBLTRItem.SetLine( &aLine );
    1750                 :            :         }
    1751         [ +  - ]:         36 :         ScfTools::PutItem( rItemSet, aTLBRItem, bSkipPoolDefs );
    1752 [ +  - ][ +  - ]:         36 :         ScfTools::PutItem( rItemSet, aBLTRItem, bSkipPoolDefs );
                 [ +  - ]
    1753                 :            :     }
    1754                 :         36 : }
    1755                 :            : 
    1756                 :         24 : void Border::writeToPropertyMap( PropertyMap& rPropMap ) const
    1757                 :            : {
    1758         [ +  - ]:         24 :     if( maApiData.mbBorderUsed )
    1759                 :            :     {
    1760                 :         24 :         rPropMap[ PROP_LeftBorder ]   <<= maApiData.maLeft;
    1761                 :         24 :         rPropMap[ PROP_RightBorder ]  <<= maApiData.maRight;
    1762                 :         24 :         rPropMap[ PROP_TopBorder ]    <<= maApiData.maTop;
    1763                 :         24 :         rPropMap[ PROP_BottomBorder ] <<= maApiData.maBottom;
    1764                 :            :     }
    1765         [ +  - ]:         24 :     if( maApiData.mbDiagUsed )
    1766                 :            :     {
    1767                 :         24 :         rPropMap[ PROP_DiagonalTLBR ] <<= maApiData.maTLtoBR;
    1768                 :         24 :         rPropMap[ PROP_DiagonalBLTR ] <<= maApiData.maBLtoTR;
    1769                 :            :     }
    1770                 :         24 : }
    1771                 :            : 
    1772                 :         24 : bool Border::hasBorder() const
    1773                 :            : {
    1774         [ -  + ]:         24 :     if (lcl_isBorder(maApiData.maBottom))
    1775                 :          0 :         return true;
    1776                 :            : 
    1777         [ -  + ]:         24 :     if (lcl_isBorder(maApiData.maTop))
    1778                 :          0 :         return true;
    1779                 :            : 
    1780         [ -  + ]:         24 :     if (lcl_isBorder(maApiData.maLeft))
    1781                 :          0 :         return true;
    1782                 :            : 
    1783         [ -  + ]:         24 :     if (lcl_isBorder(maApiData.maRight))
    1784                 :          0 :         return true;
    1785                 :            : 
    1786                 :         24 :     return false;
    1787                 :            : }
    1788                 :            : 
    1789                 :        120 : BorderLineModel* Border::getBorderLine( sal_Int32 nElement )
    1790                 :            : {
    1791   [ +  +  +  +  :        120 :     switch( nElement )
                   +  - ]
    1792                 :            :     {
    1793                 :         24 :         case XLS_TOKEN( left ):     return &maModel.maLeft;
    1794                 :         24 :         case XLS_TOKEN( right ):    return &maModel.maRight;
    1795                 :         24 :         case XLS_TOKEN( top ):      return &maModel.maTop;
    1796                 :         24 :         case XLS_TOKEN( bottom ):   return &maModel.maBottom;
    1797                 :         24 :         case XLS_TOKEN( diagonal ): return &maModel.maDiagonal;
    1798                 :            :     }
    1799                 :        120 :     return 0;
    1800                 :            : }
    1801                 :            : 
    1802                 :         96 : bool Border::convertBorderLine( BorderLine2& rBorderLine, const BorderLineModel& rModel )
    1803                 :            : {
    1804                 :         96 :     rBorderLine.Color = rModel.maColor.getColor( getBaseFilter().getGraphicHelper(), API_RGB_BLACK );
    1805   [ -  -  -  -  :         96 :     switch( rModel.mnStyle )
          -  -  -  -  -  
          -  +  -  -  -  
                      - ]
    1806                 :            :     {
    1807                 :          0 :         case XML_dashDot:           lclSetBorderLineWidth( rBorderLine, API_LINE_THIN );    break;
    1808                 :          0 :         case XML_dashDotDot:        lclSetBorderLineWidth( rBorderLine, API_LINE_THIN );    break;
    1809                 :            :         case XML_dashed:
    1810                 :            :         {
    1811                 :          0 :                                     lclSetBorderLineWidth( rBorderLine, API_LINE_THIN );
    1812                 :          0 :                                     rBorderLine.LineStyle = API_LINE_DASHED;
    1813                 :          0 :                                     break;
    1814                 :            :         }
    1815                 :            :         case XML_dotted:
    1816                 :            :         {
    1817                 :          0 :                                     lclSetBorderLineWidth( rBorderLine, API_LINE_THIN );
    1818                 :          0 :                                     rBorderLine.LineStyle = API_LINE_DOTTED;
    1819                 :          0 :                                     break;
    1820                 :            :         }
    1821                 :          0 :         case XML_double:            lclSetBorderLineWidth( rBorderLine, API_LINE_THIN, API_LINE_THIN, API_LINE_THIN ); break;
    1822                 :          0 :         case XML_hair:              lclSetBorderLineWidth( rBorderLine, API_LINE_HAIR );    break;
    1823                 :          0 :         case XML_medium:            lclSetBorderLineWidth( rBorderLine, API_LINE_MEDIUM );  break;
    1824                 :          0 :         case XML_mediumDashDot:     lclSetBorderLineWidth( rBorderLine, API_LINE_MEDIUM );  break;
    1825                 :          0 :         case XML_mediumDashDotDot:  lclSetBorderLineWidth( rBorderLine, API_LINE_MEDIUM );  break;
    1826                 :          0 :         case XML_mediumDashed:      lclSetBorderLineWidth( rBorderLine, API_LINE_MEDIUM );  break;
    1827                 :         96 :         case XML_none:              lclSetBorderLineWidth( rBorderLine, API_LINE_NONE );    break;
    1828                 :          0 :         case XML_slantDashDot:      lclSetBorderLineWidth( rBorderLine, API_LINE_MEDIUM );  break;
    1829                 :          0 :         case XML_thick:             lclSetBorderLineWidth( rBorderLine, API_LINE_THICK );   break;
    1830                 :          0 :         case XML_thin:              lclSetBorderLineWidth( rBorderLine, API_LINE_THIN );    break;
    1831                 :          0 :         default:                    lclSetBorderLineWidth( rBorderLine, API_LINE_NONE );    break;
    1832                 :            :     }
    1833                 :         96 :     return rModel.mbUsed;
    1834                 :            : }
    1835                 :            : 
    1836                 :            : 
    1837                 :            : // ============================================================================
    1838                 :            : 
    1839                 :         51 : PatternFillModel::PatternFillModel( bool bDxf ) :
    1840                 :            :     mnPattern( XML_none ),
    1841                 :         51 :     mbPattColorUsed( !bDxf ),
    1842                 :         51 :     mbFillColorUsed( !bDxf ),
    1843         [ +  - ]:         51 :     mbPatternUsed( !bDxf )
    1844                 :            : {
    1845         [ +  - ]:         51 :     maPatternColor.setIndexed( OOX_COLOR_WINDOWTEXT );
    1846         [ +  - ]:         51 :     maFillColor.setIndexed( OOX_COLOR_WINDOWBACK );
    1847                 :         51 : }
    1848                 :            : 
    1849                 :          0 : void PatternFillModel::setBiffPattern( sal_Int32 nPattern )
    1850                 :            : {
    1851                 :            :     static const sal_Int32 spnPatternIds[] = {
    1852                 :            :         XML_none, XML_solid, XML_mediumGray, XML_darkGray,
    1853                 :            :         XML_lightGray, XML_darkHorizontal, XML_darkVertical, XML_darkDown,
    1854                 :            :         XML_darkUp, XML_darkGrid, XML_darkTrellis, XML_lightHorizontal,
    1855                 :            :         XML_lightVertical, XML_lightDown, XML_lightUp, XML_lightGrid,
    1856                 :            :         XML_lightTrellis, XML_gray125, XML_gray0625 };
    1857         [ #  # ]:          0 :     mnPattern = STATIC_ARRAY_SELECT( spnPatternIds, nPattern, XML_none );
    1858                 :          0 : }
    1859                 :            : 
    1860                 :            : // ----------------------------------------------------------------------------
    1861                 :            : 
    1862                 :          0 : GradientFillModel::GradientFillModel() :
    1863                 :            :     mnType( XML_linear ),
    1864                 :            :     mfAngle( 0.0 ),
    1865                 :            :     mfLeft( 0.0 ),
    1866                 :            :     mfRight( 0.0 ),
    1867                 :            :     mfTop( 0.0 ),
    1868                 :          0 :     mfBottom( 0.0 )
    1869                 :            : {
    1870                 :          0 : }
    1871                 :            : 
    1872                 :          0 : void GradientFillModel::readGradient( SequenceInputStream& rStrm )
    1873                 :            : {
    1874                 :            :     sal_Int32 nType;
    1875 [ #  # ][ #  # ]:          0 :     rStrm >> nType >> mfAngle >> mfLeft >> mfRight >> mfTop >> mfBottom;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1876                 :            :     static const sal_Int32 spnTypes[] = { XML_linear, XML_path };
    1877         [ #  # ]:          0 :     mnType = STATIC_ARRAY_SELECT( spnTypes, nType, XML_TOKEN_INVALID );
    1878                 :          0 : }
    1879                 :            : 
    1880                 :          0 : void GradientFillModel::readGradientStop( SequenceInputStream& rStrm, bool bDxf )
    1881                 :            : {
    1882         [ #  # ]:          0 :     Color aColor;
    1883                 :            :     double fPosition;
    1884         [ #  # ]:          0 :     if( bDxf )
    1885                 :            :     {
    1886         [ #  # ]:          0 :         rStrm.skip( 2 );
    1887 [ #  # ][ #  # ]:          0 :         rStrm >> fPosition >> aColor;
    1888                 :            :     }
    1889                 :            :     else
    1890                 :            :     {
    1891 [ #  # ][ #  # ]:          0 :         rStrm >> aColor >> fPosition;
    1892                 :            :     }
    1893 [ #  # ][ #  # ]:          0 :     if( !rStrm.isEof() && (fPosition >= 0.0) )
                 [ #  # ]
    1894 [ #  # ][ #  # ]:          0 :         maColors[ fPosition ] = aColor;
                 [ #  # ]
    1895                 :          0 : }
    1896                 :            : 
    1897                 :            : // ----------------------------------------------------------------------------
    1898                 :            : 
    1899                 :         51 : ApiSolidFillData::ApiSolidFillData() :
    1900                 :            :     mnColor( API_RGB_TRANSPARENT ),
    1901                 :            :     mbTransparent( true ),
    1902                 :         51 :     mbUsed( false )
    1903                 :            : {
    1904                 :         51 : }
    1905                 :            : 
    1906                 :          0 : bool operator==( const ApiSolidFillData& rLeft, const ApiSolidFillData& rRight )
    1907                 :            : {
    1908                 :            :     return
    1909                 :            :         (rLeft.mnColor       == rRight.mnColor) &&
    1910                 :            :         (rLeft.mbTransparent == rRight.mbTransparent) &&
    1911 [ #  # ][ #  # ]:          0 :         (rLeft.mbUsed        == rRight.mbUsed);
                 [ #  # ]
    1912                 :            : }
    1913                 :            : 
    1914                 :            : // ============================================================================
    1915                 :            : 
    1916                 :            : namespace {
    1917                 :            : 
    1918                 :         81 : inline sal_Int32 lclGetMixedColorComp( sal_Int32 nPatt, sal_Int32 nFill, sal_Int32 nAlpha )
    1919                 :            : {
    1920                 :         81 :     return ((nPatt - nFill) * nAlpha) / 0x80 + nFill;
    1921                 :            : }
    1922                 :            : 
    1923                 :         27 : sal_Int32 lclGetMixedColor( sal_Int32 nPattColor, sal_Int32 nFillColor, sal_Int32 nAlpha )
    1924                 :            : {
    1925                 :            :     return
    1926                 :         27 :         (lclGetMixedColorComp( nPattColor & 0xFF0000, nFillColor & 0xFF0000, nAlpha ) & 0xFF0000) |
    1927                 :         27 :         (lclGetMixedColorComp( nPattColor & 0x00FF00, nFillColor & 0x00FF00, nAlpha ) & 0x00FF00) |
    1928                 :         27 :         (lclGetMixedColorComp( nPattColor & 0x0000FF, nFillColor & 0x0000FF, nAlpha ) & 0x0000FF);
    1929                 :            : }
    1930                 :            : 
    1931                 :            : } // namespace
    1932                 :            : 
    1933                 :            : // ----------------------------------------------------------------------------
    1934                 :            : 
    1935                 :         51 : Fill::Fill( const WorkbookHelper& rHelper, bool bDxf ) :
    1936                 :            :     WorkbookHelper( rHelper ),
    1937 [ +  - ][ +  - ]:         51 :     mbDxf( bDxf )
    1938                 :            : {
    1939                 :         51 : }
    1940                 :            : 
    1941                 :         51 : void Fill::importPatternFill( const AttributeList& rAttribs )
    1942                 :            : {
    1943         [ +  - ]:         51 :     mxPatternModel.reset( new PatternFillModel( mbDxf ) );
    1944                 :         51 :     mxPatternModel->mnPattern = rAttribs.getToken( XML_patternType, XML_none );
    1945         [ -  + ]:         51 :     if( mbDxf )
    1946                 :          0 :         mxPatternModel->mbPatternUsed = rAttribs.hasAttribute( XML_patternType );
    1947                 :         51 : }
    1948                 :            : 
    1949                 :          3 : void Fill::importFgColor( const AttributeList& rAttribs )
    1950                 :            : {
    1951                 :            :     OSL_ENSURE( mxPatternModel.get(), "Fill::importFgColor - missing pattern data" );
    1952         [ +  - ]:          3 :     if( mxPatternModel.get() )
    1953                 :            :     {
    1954                 :          3 :         mxPatternModel->maPatternColor.importColor( rAttribs );
    1955                 :          3 :         mxPatternModel->mbPattColorUsed = true;
    1956                 :            :     }
    1957                 :          3 : }
    1958                 :            : 
    1959                 :          3 : void Fill::importBgColor( const AttributeList& rAttribs )
    1960                 :            : {
    1961                 :            :     OSL_ENSURE( mxPatternModel.get(), "Fill::importBgColor - missing pattern data" );
    1962         [ +  - ]:          3 :     if( mxPatternModel.get() )
    1963                 :            :     {
    1964                 :          3 :         mxPatternModel->maFillColor.importColor( rAttribs );
    1965                 :          3 :         mxPatternModel->mbFillColorUsed = true;
    1966                 :            :     }
    1967                 :          3 : }
    1968                 :            : 
    1969                 :          0 : void Fill::importGradientFill( const AttributeList& rAttribs )
    1970                 :            : {
    1971         [ #  # ]:          0 :     mxGradientModel.reset( new GradientFillModel );
    1972                 :          0 :     mxGradientModel->mnType = rAttribs.getToken( XML_type, XML_linear );
    1973                 :          0 :     mxGradientModel->mfAngle = rAttribs.getDouble( XML_degree, 0.0 );
    1974                 :          0 :     mxGradientModel->mfLeft = rAttribs.getDouble( XML_left, 0.0 );
    1975                 :          0 :     mxGradientModel->mfRight = rAttribs.getDouble( XML_right, 0.0 );
    1976                 :          0 :     mxGradientModel->mfTop = rAttribs.getDouble( XML_top, 0.0 );
    1977                 :          0 :     mxGradientModel->mfBottom = rAttribs.getDouble( XML_bottom, 0.0 );
    1978                 :          0 : }
    1979                 :            : 
    1980                 :          0 : void Fill::importColor( const AttributeList& rAttribs, double fPosition )
    1981                 :            : {
    1982                 :            :     OSL_ENSURE( mxGradientModel.get(), "Fill::importColor - missing gradient data" );
    1983 [ #  # ][ #  # ]:          0 :     if( mxGradientModel.get() && (fPosition >= 0.0) )
                 [ #  # ]
    1984                 :          0 :         mxGradientModel->maColors[ fPosition ].importColor( rAttribs );
    1985                 :          0 : }
    1986                 :            : 
    1987                 :          0 : void Fill::importFill( SequenceInputStream& rStrm )
    1988                 :            : {
    1989                 :            :     OSL_ENSURE( !mbDxf, "Fill::importFill - unexpected conditional formatting flag" );
    1990                 :          0 :     sal_Int32 nPattern = rStrm.readInt32();
    1991         [ #  # ]:          0 :     if( nPattern == BIFF12_FILL_GRADIENT )
    1992                 :            :     {
    1993 [ #  # ][ #  # ]:          0 :         mxGradientModel.reset( new GradientFillModel );
                 [ #  # ]
    1994                 :            :         sal_Int32 nStopCount;
    1995         [ #  # ]:          0 :         rStrm.skip( 16 );
    1996         [ #  # ]:          0 :         mxGradientModel->readGradient( rStrm );
    1997         [ #  # ]:          0 :         rStrm >> nStopCount;
    1998 [ #  # ][ #  # ]:          0 :         for( sal_Int32 nStop = 0; (nStop < nStopCount) && !rStrm.isEof(); ++nStop )
                 [ #  # ]
    1999         [ #  # ]:          0 :             mxGradientModel->readGradientStop( rStrm, false );
    2000                 :            :     }
    2001                 :            :     else
    2002                 :            :     {
    2003         [ #  # ]:          0 :         mxPatternModel.reset( new PatternFillModel( mbDxf ) );
    2004                 :          0 :         mxPatternModel->setBiffPattern( nPattern );
    2005                 :          0 :         rStrm >> mxPatternModel->maPatternColor >> mxPatternModel->maFillColor;
    2006                 :            :     }
    2007                 :          0 : }
    2008                 :            : 
    2009                 :          0 : void Fill::importDxfPattern( SequenceInputStream& rStrm )
    2010                 :            : {
    2011                 :            :     OSL_ENSURE( mbDxf, "Fill::importDxfPattern - missing conditional formatting flag" );
    2012         [ #  # ]:          0 :     if( !mxPatternModel )
    2013         [ #  # ]:          0 :         mxPatternModel.reset( new PatternFillModel( mbDxf ) );
    2014                 :          0 :     mxPatternModel->setBiffPattern( rStrm.readuInt8() );
    2015                 :          0 :     mxPatternModel->mbPatternUsed = true;
    2016                 :          0 : }
    2017                 :            : 
    2018                 :          0 : void Fill::importDxfFgColor( SequenceInputStream& rStrm )
    2019                 :            : {
    2020                 :            :     OSL_ENSURE( mbDxf, "Fill::importDxfFgColor - missing conditional formatting flag" );
    2021         [ #  # ]:          0 :     if( !mxPatternModel )
    2022         [ #  # ]:          0 :         mxPatternModel.reset( new PatternFillModel( mbDxf ) );
    2023                 :          0 :     mxPatternModel->maPatternColor.importColor( rStrm );
    2024                 :          0 :     mxPatternModel->mbPattColorUsed = true;
    2025                 :          0 : }
    2026                 :            : 
    2027                 :          0 : void Fill::importDxfBgColor( SequenceInputStream& rStrm )
    2028                 :            : {
    2029                 :            :     OSL_ENSURE( mbDxf, "Fill::importDxfBgColor - missing conditional formatting flag" );
    2030         [ #  # ]:          0 :     if( !mxPatternModel )
    2031         [ #  # ]:          0 :         mxPatternModel.reset( new PatternFillModel( mbDxf ) );
    2032                 :          0 :     mxPatternModel->maFillColor.importColor( rStrm );
    2033                 :          0 :     mxPatternModel->mbFillColorUsed = true;
    2034                 :          0 : }
    2035                 :            : 
    2036                 :          0 : void Fill::importDxfGradient( SequenceInputStream& rStrm )
    2037                 :            : {
    2038                 :            :     OSL_ENSURE( mbDxf, "Fill::importDxfGradient - missing conditional formatting flag" );
    2039         [ #  # ]:          0 :     if( !mxGradientModel )
    2040         [ #  # ]:          0 :         mxGradientModel.reset( new GradientFillModel );
    2041                 :          0 :     mxGradientModel->readGradient( rStrm );
    2042                 :          0 : }
    2043                 :            : 
    2044                 :          0 : void Fill::importDxfStop( SequenceInputStream& rStrm )
    2045                 :            : {
    2046                 :            :     OSL_ENSURE( mbDxf, "Fill::importDxfStop - missing conditional formatting flag" );
    2047         [ #  # ]:          0 :     if( !mxGradientModel )
    2048         [ #  # ]:          0 :         mxGradientModel.reset( new GradientFillModel );
    2049                 :          0 :     mxGradientModel->readGradientStop( rStrm, true );
    2050                 :          0 : }
    2051                 :            : 
    2052                 :         51 : void Fill::finalizeImport()
    2053                 :            : {
    2054                 :         51 :     const GraphicHelper& rGraphicHelper = getBaseFilter().getGraphicHelper();
    2055                 :            : 
    2056         [ +  - ]:         51 :     if( mxPatternModel.get() )
    2057                 :            :     {
    2058                 :            :         // finalize the OOXML data struct
    2059                 :         51 :         PatternFillModel& rModel = *mxPatternModel;
    2060         [ -  + ]:         51 :         if( mbDxf )
    2061                 :            :         {
    2062 [ #  # ][ #  # ]:          0 :             if( rModel.mbFillColorUsed && (!rModel.mbPatternUsed || (rModel.mnPattern == XML_solid)) )
                 [ #  # ]
    2063                 :            :             {
    2064                 :          0 :                 rModel.maPatternColor = rModel.maFillColor;
    2065                 :          0 :                 rModel.mnPattern = XML_solid;
    2066                 :          0 :                 rModel.mbPattColorUsed = rModel.mbPatternUsed = true;
    2067                 :            :             }
    2068 [ #  # ][ #  # ]:          0 :             else if( !rModel.mbFillColorUsed && rModel.mbPatternUsed && (rModel.mnPattern == XML_solid) )
                 [ #  # ]
    2069                 :            :             {
    2070                 :          0 :                 rModel.mbPatternUsed = false;
    2071                 :            :             }
    2072                 :            :         }
    2073                 :            : 
    2074                 :            :         // convert to API fill settings
    2075                 :         51 :         maApiData.mbUsed = rModel.mbPatternUsed;
    2076         [ +  + ]:         51 :         if( rModel.mnPattern == XML_none )
    2077                 :            :         {
    2078                 :         24 :             maApiData.mnColor = API_RGB_TRANSPARENT;
    2079                 :         24 :             maApiData.mbTransparent = true;
    2080                 :            :         }
    2081                 :            :         else
    2082                 :            :         {
    2083                 :         27 :             sal_Int32 nAlpha = 0x80;
    2084   [ -  -  -  -  :         27 :             switch( rModel.mnPattern )
          -  -  -  -  +  
          -  -  -  -  -  
             -  -  -  +  
                      - ]
    2085                 :            :             {
    2086                 :          0 :                 case XML_darkDown:          nAlpha = 0x40;  break;
    2087                 :          0 :                 case XML_darkGray:          nAlpha = 0x60;  break;
    2088                 :          0 :                 case XML_darkGrid:          nAlpha = 0x40;  break;
    2089                 :          0 :                 case XML_darkHorizontal:    nAlpha = 0x40;  break;
    2090                 :          0 :                 case XML_darkTrellis:       nAlpha = 0x60;  break;
    2091                 :          0 :                 case XML_darkUp:            nAlpha = 0x40;  break;
    2092                 :          0 :                 case XML_darkVertical:      nAlpha = 0x40;  break;
    2093                 :          0 :                 case XML_gray0625:          nAlpha = 0x08;  break;
    2094                 :         24 :                 case XML_gray125:           nAlpha = 0x10;  break;
    2095                 :          0 :                 case XML_lightDown:         nAlpha = 0x20;  break;
    2096                 :          0 :                 case XML_lightGray:         nAlpha = 0x20;  break;
    2097                 :          0 :                 case XML_lightGrid:         nAlpha = 0x38;  break;
    2098                 :          0 :                 case XML_lightHorizontal:   nAlpha = 0x20;  break;
    2099                 :          0 :                 case XML_lightTrellis:      nAlpha = 0x30;  break;
    2100                 :          0 :                 case XML_lightUp:           nAlpha = 0x20;  break;
    2101                 :          0 :                 case XML_lightVertical:     nAlpha = 0x20;  break;
    2102                 :          0 :                 case XML_mediumGray:        nAlpha = 0x40;  break;
    2103                 :          3 :                 case XML_solid:             nAlpha = 0x80;  break;
    2104                 :            :             }
    2105                 :            : 
    2106                 :         27 :             sal_Int32 nWinTextColor = rGraphicHelper.getSystemColor( XML_windowText );
    2107                 :         27 :             sal_Int32 nWinColor = rGraphicHelper.getSystemColor( XML_window );
    2108                 :            : 
    2109         [ -  + ]:         27 :             if( !rModel.mbPattColorUsed )
    2110                 :          0 :                 rModel.maPatternColor.setAuto();
    2111                 :         27 :             sal_Int32 nPattColor = rModel.maPatternColor.getColor( rGraphicHelper, nWinTextColor );
    2112                 :            : 
    2113         [ -  + ]:         27 :             if( !rModel.mbFillColorUsed )
    2114                 :          0 :                 rModel.maFillColor.setAuto();
    2115                 :         27 :             sal_Int32 nFillColor = rModel.maFillColor.getColor( rGraphicHelper, nWinColor );
    2116                 :            : 
    2117                 :         27 :             maApiData.mnColor = lclGetMixedColor( nPattColor, nFillColor, nAlpha );
    2118                 :         27 :             maApiData.mbTransparent = false;
    2119                 :            :         }
    2120                 :            :     }
    2121 [ #  # ][ #  # ]:          0 :     else if( mxGradientModel.get() && !mxGradientModel->maColors.empty() )
                 [ #  # ]
    2122                 :            :     {
    2123                 :          0 :         GradientFillModel& rModel = *mxGradientModel;
    2124                 :          0 :         maApiData.mbUsed = true;    // no support for differential attributes
    2125                 :          0 :         GradientFillModel::ColorMap::const_iterator aIt = rModel.maColors.begin();
    2126                 :            :         OSL_ENSURE( !aIt->second.isAuto(), "Fill::finalizeImport - automatic gradient color" );
    2127         [ #  # ]:          0 :         maApiData.mnColor = aIt->second.getColor( rGraphicHelper, API_RGB_WHITE );
    2128         [ #  # ]:          0 :         if( ++aIt != rModel.maColors.end() )
    2129                 :            :         {
    2130                 :            :             OSL_ENSURE( !aIt->second.isAuto(), "Fill::finalizeImport - automatic gradient color" );
    2131         [ #  # ]:          0 :             sal_Int32 nEndColor = aIt->second.getColor( rGraphicHelper, API_RGB_WHITE );
    2132                 :          0 :             maApiData.mnColor = lclGetMixedColor( maApiData.mnColor, nEndColor, 0x40 );
    2133                 :          0 :             maApiData.mbTransparent = false;
    2134                 :            :         }
    2135                 :            :     }
    2136                 :         51 : }
    2137                 :            : 
    2138                 :        381 : void Fill::fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
    2139                 :            : {
    2140         [ +  - ]:        381 :     if( maApiData.mbUsed )
    2141                 :            :     {
    2142         [ +  - ]:        381 :         SvxBrushItem aBrushItem( ATTR_BACKGROUND );
    2143         [ +  + ]:        381 :         if ( maApiData.mbTransparent )
    2144                 :            :         {
    2145                 :        378 :             aBrushItem.SetColor( ::Color( COL_TRANSPARENT ) );
    2146                 :            :         }
    2147                 :            :         else
    2148                 :            :         {
    2149                 :          3 :             aBrushItem.SetColor( maApiData.mnColor  );
    2150                 :            :         }
    2151 [ +  - ][ +  - ]:        381 :         ScfTools::PutItem( rItemSet, aBrushItem, bSkipPoolDefs );
    2152                 :            :     }
    2153                 :        381 : }
    2154                 :            : 
    2155                 :         24 : void Fill::writeToPropertyMap( PropertyMap& rPropMap ) const
    2156                 :            : {
    2157         [ +  - ]:         24 :     if( maApiData.mbUsed )
    2158                 :            :     {
    2159                 :         24 :         rPropMap[ PROP_CellBackColor ] <<= maApiData.mnColor;
    2160                 :         24 :         rPropMap[ PROP_IsCellBackgroundTransparent ] <<= maApiData.mbTransparent;
    2161                 :            :     }
    2162                 :         24 : }
    2163                 :            : 
    2164                 :            : // ============================================================================
    2165                 :            : 
    2166                 :        465 : XfModel::XfModel() :
    2167                 :            :     mnStyleXfId( -1 ),
    2168                 :            :     mnFontId( -1 ),
    2169                 :            :     mnNumFmtId( -1 ),
    2170                 :            :     mnBorderId( -1 ),
    2171                 :            :     mnFillId( -1 ),
    2172                 :            :     mbCellXf( true ),
    2173                 :            :     mbFontUsed( false ),
    2174                 :            :     mbNumFmtUsed( false ),
    2175                 :            :     mbAlignUsed( false ),
    2176                 :            :     mbProtUsed( false ),
    2177                 :            :     mbBorderUsed( false ),
    2178                 :        465 :     mbAreaUsed( false )
    2179                 :            : {
    2180                 :        465 : }
    2181                 :            : 
    2182                 :            : // ============================================================================
    2183                 :            : 
    2184                 :        465 : Xf::Xf( const WorkbookHelper& rHelper ) :
    2185                 :            :     WorkbookHelper( rHelper ),
    2186                 :            :     maAlignment( rHelper ),
    2187                 :            :     maProtection( rHelper ),
    2188                 :            :     meRotationRef( ::com::sun::star::table::CellVertJustify2::STANDARD ),
    2189 [ +  - ][ +  - ]:        465 :     mpStyleSheet( NULL )
    2190                 :            : {
    2191                 :        465 : }
    2192                 :            : 
    2193                 :        465 : void Xf::importXf( const AttributeList& rAttribs, bool bCellXf )
    2194                 :            : {
    2195                 :        465 :     maModel.mbCellXf = bCellXf;
    2196                 :        465 :     maModel.mnStyleXfId = rAttribs.getInteger( XML_xfId, -1 );
    2197                 :        465 :     maModel.mnFontId = rAttribs.getInteger( XML_fontId, -1 );
    2198                 :        465 :     maModel.mnNumFmtId = rAttribs.getInteger( XML_numFmtId, -1 );
    2199                 :        465 :     maModel.mnBorderId = rAttribs.getInteger( XML_borderId, -1 );
    2200                 :        465 :     maModel.mnFillId = rAttribs.getInteger( XML_fillId, -1 );
    2201                 :            : 
    2202                 :            :     /*  Default value of the apply*** attributes is dependent on context:
    2203                 :            :         true in cellStyleXfs element, false in cellXfs element... */
    2204                 :        465 :     maModel.mbAlignUsed  = rAttribs.getBool( XML_applyAlignment,    !maModel.mbCellXf );
    2205                 :        465 :     maModel.mbProtUsed   = rAttribs.getBool( XML_applyProtection,   !maModel.mbCellXf );
    2206                 :        465 :     maModel.mbFontUsed   = rAttribs.getBool( XML_applyFont,         !maModel.mbCellXf );
    2207                 :        465 :     maModel.mbNumFmtUsed = rAttribs.getBool( XML_applyNumberFormat, !maModel.mbCellXf );
    2208                 :        465 :     maModel.mbBorderUsed = rAttribs.getBool( XML_applyBorder,       !maModel.mbCellXf );
    2209                 :        465 :     maModel.mbAreaUsed   = rAttribs.getBool( XML_applyFill,         !maModel.mbCellXf );
    2210                 :        465 : }
    2211                 :            : 
    2212                 :         33 : void Xf::importAlignment( const AttributeList& rAttribs )
    2213                 :            : {
    2214                 :         33 :     maAlignment.importAlignment( rAttribs );
    2215                 :         33 : }
    2216                 :            : 
    2217                 :         18 : void Xf::importProtection( const AttributeList& rAttribs )
    2218                 :            : {
    2219                 :         18 :     maProtection.importProtection( rAttribs );
    2220                 :         18 : }
    2221                 :            : 
    2222                 :          0 : void Xf::importXf( SequenceInputStream& rStrm, bool bCellXf )
    2223                 :            : {
    2224                 :          0 :     maModel.mbCellXf = bCellXf;
    2225                 :          0 :     maModel.mnStyleXfId = rStrm.readuInt16();
    2226                 :          0 :     maModel.mnNumFmtId = rStrm.readuInt16();
    2227                 :          0 :     maModel.mnFontId = rStrm.readuInt16();
    2228                 :          0 :     maModel.mnFillId = rStrm.readuInt16();
    2229                 :          0 :     maModel.mnBorderId = rStrm.readuInt16();
    2230                 :          0 :     sal_uInt32 nFlags = rStrm.readuInt32();
    2231                 :          0 :     maAlignment.setBiff12Data( nFlags );
    2232                 :          0 :     maProtection.setBiff12Data( nFlags );
    2233                 :            :     // used flags, see comments in Xf::setBiffUsedFlags()
    2234                 :          0 :     sal_uInt16 nUsedFlags = rStrm.readuInt16();
    2235                 :          0 :     maModel.mbFontUsed   = maModel.mbCellXf == getFlag( nUsedFlags, BIFF12_XF_FONT_USED );
    2236                 :          0 :     maModel.mbNumFmtUsed = maModel.mbCellXf == getFlag( nUsedFlags, BIFF12_XF_NUMFMT_USED );
    2237                 :          0 :     maModel.mbAlignUsed  = maModel.mbCellXf == getFlag( nUsedFlags, BIFF12_XF_ALIGN_USED );
    2238                 :          0 :     maModel.mbProtUsed   = maModel.mbCellXf == getFlag( nUsedFlags, BIFF12_XF_PROT_USED );
    2239                 :          0 :     maModel.mbBorderUsed = maModel.mbCellXf == getFlag( nUsedFlags, BIFF12_XF_BORDER_USED );
    2240                 :          0 :     maModel.mbAreaUsed   = maModel.mbCellXf == getFlag( nUsedFlags, BIFF12_XF_AREA_USED );
    2241                 :          0 : }
    2242                 :            : 
    2243                 :        465 : void Xf::finalizeImport()
    2244                 :            : {
    2245                 :            :     // alignment and protection
    2246                 :        465 :     maAlignment.finalizeImport();
    2247                 :        465 :     maProtection.finalizeImport();
    2248                 :        465 :     createPattern();
    2249                 :        465 : }
    2250                 :            : 
    2251                 :        267 : FontRef Xf::getFont() const
    2252                 :            : {
    2253                 :        267 :     return getStyles().getFont( maModel.mnFontId );
    2254                 :            : }
    2255                 :            : 
    2256                 :         93 : void Xf::writeToMarkData( ::ScMarkData& rMarkData, sal_Int32 nNumFmtId  )
    2257                 :            : {
    2258                 :         93 :     createPattern();
    2259                 :         93 :     ScPatternAttr& rPat = *mpPattern;
    2260                 :         93 :     ScDocument& rDoc = getScDocument();
    2261         [ +  - ]:         93 :     if ( isCellXf() )
    2262                 :            :     {
    2263         [ -  + ]:         93 :         if ( mpStyleSheet )
    2264                 :            :         {
    2265                 :            :             // Apply style sheet.  Don't clear the direct formats.
    2266                 :          0 :             rPat.SetStyleSheet(mpStyleSheet, false);
    2267                 :            :         }
    2268                 :            :         else
    2269                 :            :         {
    2270                 :         93 :             ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
    2271         [ +  - ]:         93 :             if (pStylePool)
    2272                 :            :             {
    2273                 :            :                 ScStyleSheet* pStyleSheet = static_cast<ScStyleSheet*>(
    2274                 :            :                     pStylePool->Find(
    2275                 :         93 :                         ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA));
    2276                 :            : 
    2277         [ +  - ]:         93 :                 if (pStyleSheet)
    2278                 :         93 :                     rPat.SetStyleSheet(pStyleSheet, false);
    2279                 :            :             }
    2280                 :            :         }
    2281                 :            :     }
    2282         [ -  + ]:         93 :     if ( nNumFmtId >= 0 )
    2283                 :            :     {
    2284 [ #  # ][ #  # ]:          0 :         ScPatternAttr aNumPat(rDoc.GetPool());
    2285 [ #  # ][ #  # ]:          0 :         getStyles().writeNumFmtToItemSet( aNumPat.GetItemSet(), nNumFmtId );
    2286 [ #  # ][ #  # ]:          0 :         rPat.GetItemSet().Put(aNumPat.GetItemSet());
    2287                 :            :     }
    2288                 :         93 :     rDoc.ApplySelectionPattern( rPat, rMarkData );
    2289                 :         93 : }
    2290                 :            : 
    2291                 :         84 : void Xf::writeToPropertyMap( PropertyMap& rPropMap ) const
    2292                 :            : {
    2293         [ +  - ]:         84 :     StylesBuffer& rStyles = getStyles();
    2294                 :            : 
    2295                 :            :     // create and set cell style
    2296         [ +  + ]:         84 :     if( isCellXf() )
    2297 [ +  - ][ +  - ]:         60 :         rPropMap[ PROP_CellStyle ] <<= rStyles.createCellStyle( maModel.mnStyleXfId );
                 [ +  - ]
    2298                 :            : 
    2299         [ +  + ]:         84 :     if( maModel.mbFontUsed )
    2300         [ +  - ]:         24 :         rStyles.writeFontToPropertyMap( rPropMap, maModel.mnFontId );
    2301         [ +  + ]:         84 :     if( maModel.mbNumFmtUsed )
    2302         [ +  - ]:         24 :         rStyles.writeNumFmtToPropertyMap( rPropMap, maModel.mnNumFmtId );
    2303         [ +  + ]:         84 :     if( maModel.mbAlignUsed )
    2304         [ +  - ]:         24 :         maAlignment.writeToPropertyMap( rPropMap );
    2305         [ +  + ]:         84 :     if( maModel.mbProtUsed )
    2306         [ +  - ]:         24 :         maProtection.writeToPropertyMap( rPropMap );
    2307         [ +  + ]:         84 :     if( maModel.mbBorderUsed )
    2308         [ +  - ]:         24 :         rStyles.writeBorderToPropertyMap( rPropMap, maModel.mnBorderId );
    2309         [ +  + ]:         84 :     if( maModel.mbAreaUsed )
    2310         [ +  - ]:         24 :         rStyles.writeFillToPropertyMap( rPropMap, maModel.mnFillId );
    2311 [ +  + ][ -  + ]:         84 :     if( maModel.mbAlignUsed || maModel.mbBorderUsed )
    2312 [ +  - ][ +  - ]:         24 :         rPropMap[ PROP_RotateReference ] <<= meRotationRef;
    2313                 :            : 
    2314                 :         84 :     sal_Int32 eRotRef = ::com::sun::star::table::CellVertJustify2::STANDARD;
    2315 [ +  + ][ +  - ]:         84 :     if (maModel.mbBorderUsed && rStyles.hasBorder(maModel.mnBorderId) && maAlignment.getApiData().mnRotation)
         [ -  + ][ #  # ]
                 [ -  + ]
    2316                 :          0 :         eRotRef = ::com::sun::star::table::CellVertJustify2::BOTTOM;
    2317 [ +  - ][ +  - ]:         84 :     rPropMap[ PROP_RotateReference ] <<= eRotRef;
    2318                 :         84 : }
    2319                 :            : 
    2320                 :         84 : void Xf::writeToPropertySet( PropertySet& rPropSet ) const
    2321                 :            : {
    2322         [ +  - ]:         84 :     PropertyMap aPropMap;
    2323         [ +  - ]:         84 :     writeToPropertyMap( aPropMap );
    2324         [ +  - ]:         84 :     rPropSet.setProperties( aPropMap );
    2325                 :         84 : }
    2326                 :            : 
    2327                 :            : const ::ScPatternAttr&
    2328                 :        570 : Xf::createPattern( bool bSkipPoolDefs )
    2329                 :            : {
    2330         [ +  + ]:        570 :     if( mpPattern.get() )
    2331                 :        105 :         return *mpPattern;
    2332                 :            :     // create new pattern attribute set
    2333         [ +  - ]:        465 :     mpPattern.reset( new ::ScPatternAttr( getScDocument().GetPool() ) );
    2334                 :        465 :     SfxItemSet& rItemSet = mpPattern->GetItemSet();
    2335                 :            :     /*  Enables the used flags, if the formatting attributes differ from the
    2336                 :            :         style XF. In cell XFs Excel uses the cell attributes, if they differ
    2337                 :            :         from the parent style XF (even if the used flag is switched off).
    2338                 :            :         #109899# ...or if the respective flag is not set in parent style XF.
    2339                 :            :      */
    2340                 :        465 :     StylesBuffer& rStyles = getStyles();
    2341                 :            : 
    2342 [ +  - ][ +  + ]:        465 :     const Xf* pStyleXf = isCellXf() ? rStyles.getStyleXf( maModel.mnStyleXfId ).get() : 0;
         [ #  # ][ +  + ]
    2343         [ +  + ]:        465 :     if( pStyleXf )
    2344                 :            :     {
    2345                 :         87 :         const XfModel& rStyleData = pStyleXf->maModel;
    2346         [ +  + ]:         87 :         if( !maModel.mbFontUsed )
    2347 [ +  - ][ -  + ]:         48 :             maModel.mbFontUsed = !rStyleData.mbFontUsed || (maModel.mnFontId != rStyleData.mnFontId);
    2348         [ +  - ]:         87 :         if( !maModel.mbNumFmtUsed )
    2349 [ +  - ][ +  + ]:         87 :             maModel.mbNumFmtUsed = !rStyleData.mbNumFmtUsed || (maModel.mnNumFmtId != rStyleData.mnNumFmtId);
    2350         [ +  + ]:         87 :         if( !maModel.mbAlignUsed )
    2351 [ +  - ][ -  + ]:         78 :             maModel.mbAlignUsed = !rStyleData.mbAlignUsed || !(maAlignment.getApiData() == pStyleXf->maAlignment.getApiData());
    2352         [ +  - ]:         87 :         if( !maModel.mbProtUsed )
    2353 [ +  - ][ -  + ]:         87 :             maModel.mbProtUsed = !rStyleData.mbProtUsed || !(maProtection.getApiData() == pStyleXf->maProtection.getApiData());
    2354         [ +  - ]:         87 :         if( !maModel.mbBorderUsed )
    2355 [ +  - ][ -  + ]:         87 :             maModel.mbBorderUsed = !rStyleData.mbBorderUsed || !rStyles.equalBorders( maModel.mnBorderId, rStyleData.mnBorderId );
    2356         [ +  - ]:         87 :         if( !maModel.mbAreaUsed )
    2357 [ +  - ][ +  + ]:         87 :             maModel.mbAreaUsed = !rStyleData.mbAreaUsed || !rStyles.equalFills( maModel.mnFillId, rStyleData.mnFillId );
    2358                 :            :     }
    2359                 :            :     // cell protection
    2360         [ +  + ]:        465 :     if( maModel.mbProtUsed )
    2361                 :            :     {
    2362                 :         36 :         maProtection.fillToItemSet( rItemSet, bSkipPoolDefs );
    2363                 :            :     }
    2364                 :            : 
    2365                 :            :     // font
    2366         [ +  + ]:        465 :     if( maModel.mbFontUsed )
    2367                 :            :     {
    2368                 :        417 :         rStyles.writeFontToItemSet( rItemSet, maModel.mnFontId, bSkipPoolDefs );
    2369                 :            :     }
    2370                 :            : 
    2371                 :            :     // value format
    2372         [ +  + ]:        465 :     if( maModel.mbNumFmtUsed )
    2373                 :            :     {
    2374                 :        405 :         rStyles.writeNumFmtToItemSet( rItemSet, maModel.mnNumFmtId, bSkipPoolDefs );
    2375                 :            :     }
    2376                 :            :     // alignment
    2377         [ +  + ]:        465 :     if( maModel.mbAlignUsed )
    2378                 :            :     {
    2379                 :         45 :         maAlignment.fillToItemSet( rItemSet, bSkipPoolDefs );
    2380                 :            :     }
    2381                 :            : 
    2382                 :            :     // border
    2383         [ +  + ]:        465 :     if( maModel.mbBorderUsed )
    2384                 :            :     {
    2385                 :         36 :         rStyles.writeBorderToItemSet( rItemSet, maModel.mnBorderId, bSkipPoolDefs );
    2386                 :            :     }
    2387                 :            : 
    2388                 :            :     // area
    2389         [ +  + ]:        465 :     if( maModel.mbAreaUsed )
    2390                 :            :     {
    2391                 :        381 :         rStyles.writeFillToItemSet( rItemSet, maModel.mnFillId, bSkipPoolDefs );
    2392                 :            :     }
    2393                 :            : 
    2394                 :            :     /*  #i38709# Decide which rotation reference mode to use. If any outer
    2395                 :            :         border line of the cell is set (either explicitly or via cell style),
    2396                 :            :         and the cell contents are rotated, set rotation reference to bottom of
    2397                 :            :         cell. This causes the borders to be painted rotated with the text. */
    2398 [ +  + ][ +  + ]:        465 :     if( const Alignment* pAlignment = maModel.mbAlignUsed ? &maAlignment : (pStyleXf ? &pStyleXf->maAlignment : 0) )
                 [ +  + ]
    2399                 :            :     {
    2400                 :        123 :         SvxRotateMode eRotateMode = SVX_ROTATE_MODE_STANDARD;
    2401 [ +  + ][ +  - ]:        123 :         sal_Int32 nBorderId = maModel.mbBorderUsed ? maModel.mnBorderId : (pStyleXf ? pStyleXf->maModel.mnBorderId : -1);
    2402         [ +  - ]:        123 :         if( const Border* pBorder = rStyles.getBorder( nBorderId ).get() )
    2403                 :            :         {
    2404 [ +  + ][ -  + ]:        123 :             if( (pAlignment->getApiData().mnRotation != 0) && pBorder->getApiData().hasAnyOuterBorder() )
                 [ -  + ]
    2405                 :            :             {
    2406                 :          0 :                 meRotationRef = ::com::sun::star::table::CellVertJustify2::BOTTOM;
    2407                 :          0 :                 eRotateMode = SVX_ROTATE_MODE_BOTTOM;
    2408                 :            :             }
    2409                 :            :         }
    2410         [ +  - ]:        123 :         ScfTools::PutItem( rItemSet, SvxRotateModeItem( eRotateMode, ATTR_ROTATE_MODE ), bSkipPoolDefs );
    2411                 :            :     }
    2412                 :            : 
    2413                 :        570 :     return *mpPattern;
    2414                 :            : }
    2415                 :            : 
    2416                 :            : // ============================================================================
    2417                 :            : 
    2418                 :          0 : Dxf::Dxf( const WorkbookHelper& rHelper ) :
    2419 [ #  # ][ #  # ]:          0 :     WorkbookHelper( rHelper )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2420                 :            : {
    2421                 :          0 : }
    2422                 :            : 
    2423                 :          0 : FontRef Dxf::createFont( bool bAlwaysNew )
    2424                 :            : {
    2425 [ #  # ][ #  # ]:          0 :     if( bAlwaysNew || !mxFont )
                 [ #  # ]
    2426         [ #  # ]:          0 :         mxFont.reset( new Font( *this, true ) );
    2427                 :          0 :     return mxFont;
    2428                 :            : }
    2429                 :            : 
    2430                 :          0 : BorderRef Dxf::createBorder( bool bAlwaysNew )
    2431                 :            : {
    2432 [ #  # ][ #  # ]:          0 :     if( bAlwaysNew || !mxBorder )
                 [ #  # ]
    2433         [ #  # ]:          0 :         mxBorder.reset( new Border( *this, true ) );
    2434                 :          0 :     return mxBorder;
    2435                 :            : }
    2436                 :            : 
    2437                 :          0 : FillRef Dxf::createFill( bool bAlwaysNew )
    2438                 :            : {
    2439 [ #  # ][ #  # ]:          0 :     if( bAlwaysNew || !mxFill )
                 [ #  # ]
    2440         [ #  # ]:          0 :         mxFill.reset( new Fill( *this, true ) );
    2441                 :          0 :     return mxFill;
    2442                 :            : }
    2443                 :            : 
    2444                 :          0 : void Dxf::importNumFmt( const AttributeList& rAttribs )
    2445                 :            : {
    2446         [ #  # ]:          0 :     mxNumFmt = getStyles().importNumFmt( rAttribs );
    2447                 :          0 : }
    2448                 :            : 
    2449                 :          0 : void Dxf::importDxf( SequenceInputStream& rStrm )
    2450                 :            : {
    2451                 :          0 :     sal_Int32 nNumFmtId = -1;
    2452                 :          0 :     OUString aFmtCode;
    2453                 :            :     sal_uInt16 nRecCount;
    2454         [ #  # ]:          0 :     rStrm.skip( 4 );    // flags
    2455         [ #  # ]:          0 :     rStrm >> nRecCount;
    2456 [ #  # ][ #  # ]:          0 :     for( sal_uInt16 nRec = 0; !rStrm.isEof() && (nRec < nRecCount); ++nRec )
                 [ #  # ]
    2457                 :            :     {
    2458                 :            :         sal_uInt16 nSubRecId, nSubRecSize;
    2459         [ #  # ]:          0 :         sal_Int64 nRecEnd = rStrm.tell();
    2460 [ #  # ][ #  # ]:          0 :         rStrm >> nSubRecId >> nSubRecSize;
    2461                 :          0 :         nRecEnd += nSubRecSize;
    2462   [ #  #  #  #  :          0 :         switch( nSubRecId )
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
    2463                 :            :         {
    2464 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FILL_PATTERN:       createFill( false )->importDxfPattern( rStrm );                         break;
                 [ #  # ]
    2465 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FILL_FGCOLOR:       createFill( false )->importDxfFgColor( rStrm );                         break;
                 [ #  # ]
    2466 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FILL_BGCOLOR:       createFill( false )->importDxfBgColor( rStrm );                         break;
                 [ #  # ]
    2467 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FILL_GRADIENT:      createFill( false )->importDxfGradient( rStrm );                        break;
                 [ #  # ]
    2468 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FILL_STOP:          createFill( false )->importDxfStop( rStrm );                            break;
                 [ #  # ]
    2469 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FONT_COLOR:         createFont( false )->importDxfColor( rStrm );                           break;
                 [ #  # ]
    2470 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_BORDER_TOP:         createBorder( false )->importDxfBorder( XLS_TOKEN( top ), rStrm );      break;
                 [ #  # ]
    2471 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_BORDER_BOTTOM:      createBorder( false )->importDxfBorder( XLS_TOKEN( bottom ), rStrm );   break;
                 [ #  # ]
    2472 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_BORDER_LEFT:        createBorder( false )->importDxfBorder( XLS_TOKEN( left ), rStrm );     break;
                 [ #  # ]
    2473 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_BORDER_RIGHT:       createBorder( false )->importDxfBorder( XLS_TOKEN( right ), rStrm );    break;
                 [ #  # ]
    2474 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FONT_NAME:          createFont( false )->importDxfName( rStrm );                            break;
                 [ #  # ]
    2475 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FONT_WEIGHT:        createFont( false )->importDxfWeight( rStrm );                          break;
                 [ #  # ]
    2476 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FONT_UNDERLINE:     createFont( false )->importDxfUnderline( rStrm );                       break;
                 [ #  # ]
    2477 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FONT_ESCAPEMENT:    createFont( false )->importDxfEscapement( rStrm );                      break;
                 [ #  # ]
    2478 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FONT_ITALIC:        createFont( false )->importDxfFlag( XML_i, rStrm );                     break;
                 [ #  # ]
    2479 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FONT_STRIKE:        createFont( false )->importDxfFlag( XML_strike, rStrm );                break;
                 [ #  # ]
    2480 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FONT_OUTLINE:       createFont( false )->importDxfFlag( XML_outline, rStrm );               break;
                 [ #  # ]
    2481 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FONT_SHADOW:        createFont( false )->importDxfFlag( XML_shadow, rStrm );                break;
                 [ #  # ]
    2482 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FONT_HEIGHT:        createFont( false )->importDxfHeight( rStrm );                          break;
                 [ #  # ]
    2483 [ #  # ][ #  # ]:          0 :             case BIFF12_DXF_FONT_SCHEME:        createFont( false )->importDxfScheme( rStrm );                          break;
                 [ #  # ]
    2484         [ #  # ]:          0 :             case BIFF12_DXF_NUMFMT_CODE:        aFmtCode = BiffHelper::readString( rStrm, false );                      break;
    2485         [ #  # ]:          0 :             case BIFF12_DXF_NUMFMT_ID:          nNumFmtId = rStrm.readuInt16();                                         break;
    2486                 :            :         }
    2487         [ #  # ]:          0 :         rStrm.seek( nRecEnd );
    2488                 :            :     }
    2489                 :            :     OSL_ENSURE( !rStrm.isEof() && (rStrm.getRemaining() == 0), "Dxf::importDxf - unexpected remaining data" );
    2490 [ #  # ][ #  # ]:          0 :     mxNumFmt = getStyles().createNumFmt( nNumFmtId, aFmtCode );
         [ #  # ][ #  # ]
    2491                 :          0 : }
    2492                 :            : 
    2493                 :          0 : void Dxf::finalizeImport()
    2494                 :            : {
    2495         [ #  # ]:          0 :     if( mxFont.get() )
    2496                 :          0 :         mxFont->finalizeImport();
    2497                 :            :     // number format already finalized by the number formats buffer
    2498         [ #  # ]:          0 :     if( mxAlignment.get() )
    2499                 :          0 :         mxAlignment->finalizeImport();
    2500         [ #  # ]:          0 :     if( mxProtection.get() )
    2501                 :          0 :         mxProtection->finalizeImport();
    2502         [ #  # ]:          0 :     if( mxBorder.get() )
    2503                 :          0 :         mxBorder->finalizeImport();
    2504         [ #  # ]:          0 :     if( mxFill.get() )
    2505                 :          0 :         mxFill->finalizeImport();
    2506                 :          0 : }
    2507                 :            : 
    2508                 :          0 : void Dxf::writeToPropertyMap( PropertyMap& rPropMap ) const
    2509                 :            : {
    2510         [ #  # ]:          0 :     if( mxFont.get() )
    2511                 :          0 :         mxFont->writeToPropertyMap( rPropMap, FONT_PROPTYPE_CELL );
    2512         [ #  # ]:          0 :     if( mxNumFmt.get() )
    2513                 :          0 :         mxNumFmt->writeToPropertyMap( rPropMap );
    2514         [ #  # ]:          0 :     if( mxAlignment.get() )
    2515                 :          0 :         mxAlignment->writeToPropertyMap( rPropMap );
    2516         [ #  # ]:          0 :     if( mxProtection.get() )
    2517                 :          0 :         mxProtection->writeToPropertyMap( rPropMap );
    2518         [ #  # ]:          0 :     if( mxBorder.get() )
    2519                 :          0 :         mxBorder->writeToPropertyMap( rPropMap );
    2520         [ #  # ]:          0 :     if( mxFill.get() )
    2521                 :          0 :         mxFill->writeToPropertyMap( rPropMap );
    2522                 :          0 : }
    2523                 :            : 
    2524                 :          0 : void Dxf::writeToPropertySet( PropertySet& rPropSet ) const
    2525                 :            : {
    2526         [ #  # ]:          0 :     PropertyMap aPropMap;
    2527         [ #  # ]:          0 :     writeToPropertyMap( aPropMap );
    2528         [ #  # ]:          0 :     rPropSet.setProperties( aPropMap );
    2529                 :          0 : }
    2530                 :            : 
    2531                 :            : // ============================================================================
    2532                 :            : 
    2533                 :            : namespace {
    2534                 :            : 
    2535                 :            : const sal_Char* const spcLegacyStyleNamePrefix = "Excel_BuiltIn_";
    2536                 :            : const sal_Char* const sppcLegacyStyleNames[] =
    2537                 :            : {
    2538                 :            :     "Normal",
    2539                 :            :     "RowLevel_",            // outline level will be appended
    2540                 :            :     "ColumnLevel_",         // outline level will be appended
    2541                 :            :     "Comma",
    2542                 :            :     "Currency",
    2543                 :            :     "Percent",
    2544                 :            :     "Comma_0",              // new in BIFF4
    2545                 :            :     "Currency_0",
    2546                 :            :     "Hyperlink",            // new in BIFF8
    2547                 :            :     "Followed_Hyperlink"
    2548                 :            : };
    2549                 :            : const sal_Int32 snLegacyStyleNamesCount = static_cast< sal_Int32 >( STATIC_ARRAY_SIZE( sppcLegacyStyleNames ) );
    2550                 :            : 
    2551                 :            : const sal_Char* const spcStyleNamePrefix = "Excel Built-in ";
    2552                 :            : const sal_Char* const sppcStyleNames[] =
    2553                 :            : {
    2554                 :            :     "Normal",
    2555                 :            :     "RowLevel_",            // outline level will be appended
    2556                 :            :     "ColLevel_",            // outline level will be appended
    2557                 :            :     "Comma",
    2558                 :            :     "Currency",
    2559                 :            :     "Percent",
    2560                 :            :     "Comma [0]",            // new in BIFF4
    2561                 :            :     "Currency [0]",
    2562                 :            :     "Hyperlink",            // new in BIFF8
    2563                 :            :     "Followed Hyperlink",
    2564                 :            :     "Note",                 // new in OOX
    2565                 :            :     "Warning Text",
    2566                 :            :     "",
    2567                 :            :     "",
    2568                 :            :     "",
    2569                 :            :     "Title",
    2570                 :            :     "Heading 1",
    2571                 :            :     "Heading 2",
    2572                 :            :     "Heading 3",
    2573                 :            :     "Heading 4",
    2574                 :            :     "Input",
    2575                 :            :     "Output",
    2576                 :            :     "Calculation",
    2577                 :            :     "Check Cell",
    2578                 :            :     "Linked Cell",
    2579                 :            :     "Total",
    2580                 :            :     "Good",
    2581                 :            :     "Bad",
    2582                 :            :     "Neutral",
    2583                 :            :     "Accent1",
    2584                 :            :     "20% - Accent1",
    2585                 :            :     "40% - Accent1",
    2586                 :            :     "60% - Accent1",
    2587                 :            :     "Accent2",
    2588                 :            :     "20% - Accent2",
    2589                 :            :     "40% - Accent2",
    2590                 :            :     "60% - Accent2",
    2591                 :            :     "Accent3",
    2592                 :            :     "20% - Accent3",
    2593                 :            :     "40% - Accent3",
    2594                 :            :     "60% - Accent3",
    2595                 :            :     "Accent4",
    2596                 :            :     "20% - Accent4",
    2597                 :            :     "40% - Accent4",
    2598                 :            :     "60% - Accent4",
    2599                 :            :     "Accent5",
    2600                 :            :     "20% - Accent5",
    2601                 :            :     "40% - Accent5",
    2602                 :            :     "60% - Accent5",
    2603                 :            :     "Accent6",
    2604                 :            :     "20% - Accent6",
    2605                 :            :     "40% - Accent6",
    2606                 :            :     "60% - Accent6",
    2607                 :            :     "Explanatory Text"
    2608                 :            : };
    2609                 :            : const sal_Int32 snStyleNamesCount = static_cast< sal_Int32 >( STATIC_ARRAY_SIZE( sppcStyleNames ) );
    2610                 :            : 
    2611                 :        210 : OUString lclGetBuiltinStyleName( sal_Int32 nBuiltinId, const OUString& rName, sal_Int32 nLevel = 0 )
    2612                 :            : {
    2613                 :            :     OSL_ENSURE( (0 <= nBuiltinId) && (nBuiltinId < snStyleNamesCount), "lclGetBuiltinStyleName - unknown built-in style" );
    2614                 :        210 :     OUStringBuffer aStyleName;
    2615         [ +  - ]:        210 :     aStyleName.appendAscii( spcStyleNamePrefix );
    2616 [ +  - ][ +  - ]:        210 :     if( (0 <= nBuiltinId) && (nBuiltinId < snStyleNamesCount) && (sppcStyleNames[ nBuiltinId ][ 0 ] != 0) )
                 [ +  - ]
    2617         [ +  - ]:        210 :         aStyleName.appendAscii( sppcStyleNames[ nBuiltinId ] );
    2618         [ #  # ]:          0 :     else if( !rName.isEmpty() )
    2619         [ #  # ]:          0 :         aStyleName.append( rName );
    2620                 :            :     else
    2621         [ #  # ]:          0 :         aStyleName.append( nBuiltinId );
    2622 [ +  - ][ -  + ]:        210 :     if( (nBuiltinId == OOX_STYLE_ROWLEVEL) || (nBuiltinId == OOX_STYLE_COLLEVEL) )
    2623         [ #  # ]:          0 :         aStyleName.append( nLevel );
    2624         [ +  - ]:        210 :     return aStyleName.makeStringAndClear();
    2625                 :            : }
    2626                 :            : 
    2627                 :            : } // namespace
    2628                 :            : 
    2629                 :            : // ----------------------------------------------------------------------------
    2630                 :            : 
    2631                 :        126 : CellStyleModel::CellStyleModel() :
    2632                 :            :     mnXfId( -1 ),
    2633                 :            :     mnBuiltinId( -1 ),
    2634                 :            :     mnLevel( 0 ),
    2635                 :            :     mbBuiltin( false ),
    2636                 :            :     mbCustom( false ),
    2637                 :        126 :     mbHidden( false )
    2638                 :            : {
    2639                 :        126 : }
    2640                 :            : 
    2641                 :        228 : bool CellStyleModel::isBuiltin() const
    2642                 :            : {
    2643 [ +  + ][ +  - ]:        228 :     return mbBuiltin && (mnBuiltinId >= 0);
    2644                 :            : }
    2645                 :            : 
    2646                 :        252 : bool CellStyleModel::isDefaultStyle() const
    2647                 :            : {
    2648 [ +  + ][ +  + ]:        252 :     return mbBuiltin && (mnBuiltinId == OOX_STYLE_NORMAL);
    2649                 :            : }
    2650                 :            : 
    2651                 :            : // ============================================================================
    2652                 :            : 
    2653                 :        126 : CellStyle::CellStyle( const WorkbookHelper& rHelper ) :
    2654                 :            :     WorkbookHelper( rHelper ),
    2655                 :            :     mbCreated( false ),
    2656                 :        126 :     mpStyleSheet( NULL )
    2657                 :            : {
    2658                 :        126 : }
    2659                 :            : 
    2660                 :        126 : void CellStyle::importCellStyle( const AttributeList& rAttribs )
    2661                 :            : {
    2662         [ +  - ]:        126 :     maModel.maName      = rAttribs.getXString( XML_name, OUString() );
    2663                 :        126 :     maModel.mnXfId      = rAttribs.getInteger( XML_xfId, -1 );
    2664                 :        126 :     maModel.mnBuiltinId = rAttribs.getInteger( XML_builtinId, -1 );
    2665                 :        126 :     maModel.mnLevel     = rAttribs.getInteger( XML_iLevel, 0 );
    2666                 :        126 :     maModel.mbBuiltin   = rAttribs.hasAttribute( XML_builtinId );
    2667                 :        126 :     maModel.mbCustom    = rAttribs.getBool( XML_customBuiltin, false );
    2668                 :        126 :     maModel.mbHidden    = rAttribs.getBool( XML_hidden, false );
    2669                 :        126 : }
    2670                 :            : 
    2671                 :          0 : void CellStyle::importCellStyle( SequenceInputStream& rStrm )
    2672                 :            : {
    2673                 :            :     sal_uInt16 nFlags;
    2674 [ #  # ][ #  # ]:          0 :     rStrm >> maModel.mnXfId >> nFlags;
    2675         [ #  # ]:          0 :     maModel.mnBuiltinId = rStrm.readInt8();
    2676         [ #  # ]:          0 :     maModel.mnLevel = rStrm.readInt8();
    2677         [ #  # ]:          0 :     rStrm >> maModel.maName;
    2678                 :          0 :     maModel.mbBuiltin = getFlag( nFlags, BIFF12_CELLSTYLE_BUILTIN );
    2679                 :          0 :     maModel.mbCustom = getFlag( nFlags, BIFF12_CELLSTYLE_CUSTOM );
    2680                 :          0 :     maModel.mbHidden = getFlag( nFlags, BIFF12_CELLSTYLE_HIDDEN );
    2681                 :          0 : }
    2682                 :            : 
    2683                 :        132 : void CellStyle::createCellStyle()
    2684                 :            : {
    2685                 :            : 
    2686                 :            :     // #i1624# #i1768# ignore unnamed user styles
    2687         [ +  + ]:        132 :     if( !mbCreated )
    2688                 :         36 :         mbCreated = maFinalName.isEmpty();
    2689                 :            : 
    2690                 :        132 :     ::ScDocument& rDoc = getScDocument();
    2691 [ +  - ][ +  + ]:        132 :     if( !mbCreated && !mpStyleSheet )
    2692                 :            :     {
    2693                 :         12 :         bool bCreatePattern = false;
    2694                 :         12 :         Xf* pXF = getStyles().getStyleXf( maModel.mnXfId ).get();
    2695                 :            : 
    2696                 :         12 :         bool bDefStyle = maModel.isDefaultStyle();
    2697         [ -  + ]:         12 :         if( bDefStyle )
    2698                 :            :         {
    2699                 :            :             // use existing "Default" style sheet
    2700                 :          0 :             mpStyleSheet = static_cast< ScStyleSheet* >( static_cast< ScStyleSheetPool* >( rDoc.GetStyleSheetPool() )->Find(
    2701 [ #  # ][ #  # ]:          0 :                 getStyles().getDefaultStyleName(), SFX_STYLE_FAMILY_PARA ) );
                 [ #  # ]
    2702                 :            :             OSL_ENSURE( mpStyleSheet, "CellStyle::createStyle - Default style not found" );
    2703                 :          0 :             bCreatePattern = true;
    2704                 :            :         }
    2705                 :            :         else
    2706                 :            :         {
    2707         [ +  - ]:         12 :             mpStyleSheet = static_cast< ScStyleSheet* >( static_cast< ScStyleSheetPool* >( rDoc.GetStyleSheetPool() )->Find( maFinalName, SFX_STYLE_FAMILY_PARA ) );
    2708         [ +  - ]:         12 :             if( !mpStyleSheet )
    2709                 :            :             {
    2710         [ +  - ]:         12 :                 mpStyleSheet = &static_cast< ScStyleSheet& >( rDoc.GetStyleSheetPool()->Make( maFinalName, SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_USERDEF ) );
    2711                 :         12 :                 bCreatePattern = true;
    2712                 :            :             }
    2713                 :            :         }
    2714                 :            : 
    2715                 :            :         // bDefStyle==true omits default pool items in CreatePattern()
    2716 [ +  - ][ +  - ]:         12 :         if( bCreatePattern && mpStyleSheet && pXF )
                 [ +  - ]
    2717                 :         12 :             mpStyleSheet->GetItemSet().Put( pXF->createPattern( bDefStyle ).GetItemSet() );
    2718                 :            :     }
    2719                 :        132 : }
    2720                 :            : 
    2721                 :        102 : void CellStyle::finalizeImport( const OUString& rFinalName )
    2722                 :            : {
    2723                 :        102 :     maFinalName = rFinalName;
    2724 [ -  + ][ +  + ]:        102 :     if( !maModel.isBuiltin() || maModel.mbCustom )
                 [ +  + ]
    2725                 :         12 :         createCellStyle();
    2726                 :        102 : }
    2727                 :            : 
    2728                 :            : // ============================================================================
    2729                 :            : 
    2730                 :         24 : CellStyleBuffer::CellStyleBuffer( const WorkbookHelper& rHelper ) :
    2731 [ +  - ][ +  - ]:         24 :     WorkbookHelper( rHelper )
         [ +  - ][ +  - ]
    2732                 :            : {
    2733                 :         24 : }
    2734                 :            : 
    2735                 :        126 : CellStyleRef CellStyleBuffer::importCellStyle( const AttributeList& rAttribs )
    2736                 :            : {
    2737 [ +  - ][ +  - ]:        126 :     CellStyleRef xCellStyle( new CellStyle( *this ) );
    2738         [ +  - ]:        126 :     xCellStyle->importCellStyle( rAttribs );
    2739 [ +  - ][ +  - ]:        126 :     insertCellStyle( xCellStyle );
                 [ +  - ]
    2740                 :        126 :     return xCellStyle;
    2741                 :            : }
    2742                 :            : 
    2743                 :          0 : CellStyleRef CellStyleBuffer::importCellStyle( SequenceInputStream& rStrm )
    2744                 :            : {
    2745 [ #  # ][ #  # ]:          0 :     CellStyleRef xCellStyle( new CellStyle( *this ) );
    2746         [ #  # ]:          0 :     xCellStyle->importCellStyle( rStrm );
    2747 [ #  # ][ #  # ]:          0 :     insertCellStyle( xCellStyle );
                 [ #  # ]
    2748                 :          0 :     return xCellStyle;
    2749                 :            : }
    2750                 :            : 
    2751                 :         24 : void CellStyleBuffer::finalizeImport()
    2752                 :            : {
    2753                 :            :     // calculate final names of all styles
    2754                 :            :     typedef RefMap< OUString, CellStyle, IgnoreCaseCompare > CellStyleNameMap;
    2755         [ +  - ]:         24 :     CellStyleNameMap aCellStyles;
    2756         [ +  - ]:         24 :     CellStyleVector aConflictNameStyles;
    2757                 :            : 
    2758                 :            :     /*  First, reserve style names that are built-in in Calc. This causes that
    2759                 :            :         imported cell styles get different unused names and thus do not try to
    2760                 :            :         overwrite these built-in styles. For BIFF4 workbooks (which contain a
    2761                 :            :         separate list of cell styles per sheet), reserve all existing styles if
    2762                 :            :         current sheet is not the first sheet (this styles buffer will be
    2763                 :            :         constructed again for every new sheet). This will create unique names
    2764                 :            :         for styles in different sheets with the same name. Assuming that the
    2765                 :            :         BIFF4W import filter is never used to import from clipboard... */
    2766 [ +  - ][ -  + ]:         24 :     bool bReserveAll = (getFilterType() == FILTER_BIFF) && (getBiff() == BIFF4) && isWorkbookFile() && (getCurrentSheetIndex() > 0);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2767                 :            :     try
    2768                 :            :     {
    2769                 :            :         // unfortunately, com.sun.star.style.StyleFamily does not implement XEnumerationAccess...
    2770 [ +  - ][ +  - ]:         24 :         Reference< XIndexAccess > xStyleFamilyIA( getStyleFamily( false ), UNO_QUERY_THROW );
    2771 [ +  - ][ +  + ]:        144 :         for( sal_Int32 nIndex = 0, nCount = xStyleFamilyIA->getCount(); nIndex < nCount; ++nIndex )
                 [ +  - ]
    2772                 :            :         {
    2773 [ +  - ][ +  - ]:        120 :             Reference< XStyle > xStyle( xStyleFamilyIA->getByIndex( nIndex ), UNO_QUERY_THROW );
                 [ +  - ]
    2774 [ +  - ][ +  - ]:        120 :             if( bReserveAll || !xStyle->isUserDefined() )
         [ +  - ][ +  - ]
                 [ +  - ]
    2775                 :            :             {
    2776         [ +  - ]:        120 :                 Reference< XNamed > xStyleName( xStyle, UNO_QUERY_THROW );
    2777                 :            :                 // create an empty entry by using ::std::map<>::operator[]
    2778 [ +  - ][ +  - ]:        120 :                 aCellStyles[ xStyleName->getName() ];
                 [ +  - ]
    2779                 :            :             }
    2780         [ #  # ]:        144 :         }
    2781                 :            :     }
    2782         [ #  # ]:          0 :     catch( Exception& )
    2783                 :            :     {
    2784                 :            :     }
    2785                 :            : 
    2786                 :            :     /*  Calculate names of built-in styles. Store styles with reserved names
    2787                 :            :         in the aConflictNameStyles list. */
    2788 [ +  - ][ +  + ]:        138 :     for( CellStyleVector::iterator aIt = maBuiltinStyles.begin(), aEnd = maBuiltinStyles.end(); aIt != aEnd; ++aIt )
    2789                 :            :     {
    2790                 :        114 :         const CellStyleModel& rModel = (*aIt)->getModel();
    2791         [ +  + ]:        114 :         if (rModel.isDefaultStyle())
    2792                 :         24 :             continue;
    2793                 :            : 
    2794         [ +  - ]:         90 :         OUString aStyleName = lclGetBuiltinStyleName( rModel.mnBuiltinId, rModel.maName, rModel.mnLevel );
    2795                 :            :         OSL_ENSURE( bReserveAll || (aCellStyles.count( aStyleName ) == 0),
    2796                 :            :             "CellStyleBuffer::finalizeImport - multiple styles with equal built-in identifier" );
    2797 [ +  - ][ -  + ]:         90 :         if( aCellStyles.count( aStyleName ) > 0 )
    2798         [ #  # ]:          0 :             aConflictNameStyles.push_back( *aIt );
    2799                 :            :         else
    2800 [ +  - ][ +  - ]:         90 :             aCellStyles[ aStyleName ] = *aIt;
    2801                 :         90 :     }
    2802                 :            : 
    2803                 :            :     /*  Calculate names of user defined styles. Store styles with reserved
    2804                 :            :         names in the aConflictNameStyles list. */
    2805 [ +  - ][ +  + ]:         36 :     for( CellStyleVector::iterator aIt = maUserStyles.begin(), aEnd = maUserStyles.end(); aIt != aEnd; ++aIt )
    2806                 :            :     {
    2807                 :         12 :         const CellStyleModel& rModel = (*aIt)->getModel();
    2808                 :            :         // #i1624# #i1768# ignore unnamed user styles
    2809         [ +  - ]:         12 :         if( !rModel.maName.isEmpty() )
    2810                 :            :         {
    2811 [ +  - ][ +  - ]:         12 :             if( aCellStyles.count( rModel.maName ) > 0 )
    2812         [ +  - ]:         12 :                 aConflictNameStyles.push_back( *aIt );
    2813                 :            :             else
    2814 [ #  # ][ #  # ]:          0 :                 aCellStyles[ rModel.maName ] = *aIt;
    2815                 :            :         }
    2816                 :            :     }
    2817                 :            : 
    2818                 :            :     // find unused names for all styles with conflicting names
    2819 [ +  - ][ +  + ]:         36 :     for( CellStyleVector::iterator aIt = aConflictNameStyles.begin(), aEnd = aConflictNameStyles.end(); aIt != aEnd; ++aIt )
    2820                 :            :     {
    2821                 :         12 :         const CellStyleModel& rModel = (*aIt)->getModel();
    2822                 :         12 :         OUString aUnusedName;
    2823                 :         12 :         sal_Int32 nIndex = 0;
    2824         [ -  + ]:         12 :         do
    2825                 :            :         {
    2826 [ +  - ][ +  - ]:         12 :             aUnusedName = OUStringBuffer( rModel.maName ).append( sal_Unicode( ' ' ) ).append( ++nIndex ).makeStringAndClear();
         [ +  - ][ +  - ]
    2827                 :            :         }
    2828         [ +  - ]:         12 :         while( aCellStyles.count( aUnusedName ) > 0 );
    2829 [ +  - ][ +  - ]:         12 :         aCellStyles[ aUnusedName ] = *aIt;
    2830                 :         12 :     }
    2831                 :            : 
    2832                 :            :     // set final names and create user-defined and modified built-in cell styles
    2833         [ +  - ]:         24 :     aCellStyles.forEachMemWithKey( &CellStyle::finalizeImport );
    2834                 :            : 
    2835         [ +  - ]:         24 :     if (mxDefStyle)
    2836                 :            :     {
    2837 [ +  - ][ +  - ]:         24 :         Reference<XNameAccess> xNA(getStyleFamily(false), UNO_QUERY_THROW);
    2838 [ +  - ][ +  - ]:         24 :         if (xNA->hasByName(CREATE_OUSTRING("Default")))
         [ +  - ][ +  - ]
    2839                 :            :         {
    2840 [ +  - ][ +  - ]:         24 :             PropertySet aPropSet(xNA->getByName(CREATE_OUSTRING("Default")));
         [ +  - ][ +  - ]
    2841 [ +  - ][ +  - ]:         24 :             getStyles().writeStyleXfToPropertySet(aPropSet, mxDefStyle->getModel().mnXfId);
                 [ +  - ]
    2842                 :         24 :         }
    2843                 :         24 :     }
    2844                 :         24 : }
    2845                 :            : 
    2846                 :        126 : sal_Int32 CellStyleBuffer::getDefaultXfId() const
    2847                 :            : {
    2848         [ +  - ]:        126 :     return mxDefStyle.get() ? mxDefStyle->getModel().mnXfId : -1;
    2849                 :            : }
    2850                 :            : 
    2851                 :         60 : OUString CellStyleBuffer::getDefaultStyleName() const
    2852                 :            : {
    2853                 :         60 :     return createCellStyle( mxDefStyle );
    2854                 :            : }
    2855                 :            : 
    2856                 :         60 : OUString CellStyleBuffer::createCellStyle( sal_Int32 nXfId ) const
    2857                 :            : {
    2858         [ +  - ]:         60 :     return createCellStyle( maStylesByXf.get( nXfId ) );
    2859                 :            : }
    2860                 :            : 
    2861                 :            : // private --------------------------------------------------------------------
    2862                 :            : 
    2863                 :        126 : void CellStyleBuffer::insertCellStyle( CellStyleRef xCellStyle )
    2864                 :            : {
    2865                 :        126 :     const CellStyleModel& rModel = xCellStyle->getModel();
    2866         [ +  - ]:        126 :     if( rModel.mnXfId >= 0 )
    2867                 :            :     {
    2868                 :            :         // insert into the built-in map or user defined map
    2869         [ +  + ]:        126 :         (rModel.isBuiltin() ? maBuiltinStyles : maUserStyles).push_back( xCellStyle );
    2870                 :            : 
    2871                 :            :         // insert into the XF identifier map
    2872                 :            :         OSL_ENSURE( maStylesByXf.count( rModel.mnXfId ) == 0, "CellStyleBuffer::insertCellStyle - multiple styles with equal XF identifier" );
    2873                 :        126 :         maStylesByXf[ rModel.mnXfId ] = xCellStyle;
    2874                 :            : 
    2875                 :            :         // remember default cell style
    2876         [ +  + ]:        126 :         if( rModel.isDefaultStyle() )
    2877                 :         24 :             mxDefStyle = xCellStyle;
    2878                 :            :     }
    2879                 :        126 : }
    2880                 :            : 
    2881                 :        120 : OUString CellStyleBuffer::createCellStyle( const CellStyleRef& rxCellStyle ) const
    2882                 :            : {
    2883         [ +  - ]:        120 :     if( rxCellStyle.get() )
    2884                 :            :     {
    2885                 :        120 :         rxCellStyle->createCellStyle();
    2886                 :        120 :         const OUString& rStyleName = rxCellStyle->getFinalStyleName();
    2887         [ -  + ]:        120 :         if( !rStyleName.isEmpty() )
    2888                 :          0 :             return rStyleName;
    2889                 :            :     }
    2890                 :            :     // on error: fallback to default style
    2891         [ +  - ]:        120 :     return lclGetBuiltinStyleName( OOX_STYLE_NORMAL, OUString() );
    2892                 :            : }
    2893                 :            : 
    2894                 :            : // ============================================================================
    2895                 :            : 
    2896                 :          0 : AutoFormatModel::AutoFormatModel() :
    2897                 :            :     mnAutoFormatId( 0 ),
    2898                 :            :     mbApplyNumFmt( false ),
    2899                 :            :     mbApplyFont( false ),
    2900                 :            :     mbApplyAlignment( false ),
    2901                 :            :     mbApplyBorder( false ),
    2902                 :            :     mbApplyFill( false ),
    2903                 :          0 :     mbApplyProtection( false )
    2904                 :            : {
    2905                 :          0 : }
    2906                 :            : 
    2907                 :            : // ============================================================================
    2908                 :            : 
    2909                 :         24 : StylesBuffer::StylesBuffer( const WorkbookHelper& rHelper ) :
    2910                 :            :     WorkbookHelper( rHelper ),
    2911                 :            :     maPalette( rHelper ),
    2912                 :            :     maNumFmts( rHelper ),
    2913 [ +  - ][ +  - ]:         24 :     maCellStyles( rHelper )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2914                 :            : {
    2915                 :         24 : }
    2916                 :            : 
    2917                 :        108 : FontRef StylesBuffer::createFont( sal_Int32* opnFontId )
    2918                 :            : {
    2919         [ -  + ]:        108 :     if( opnFontId ) *opnFontId = static_cast< sal_Int32 >( maFonts.size() );
    2920 [ +  - ][ +  - ]:        108 :     FontRef xFont( new Font( *this, false ) );
    2921         [ +  - ]:        108 :     maFonts.push_back( xFont );
    2922                 :        108 :     return xFont;
    2923                 :            : }
    2924                 :            : 
    2925                 :          0 : NumberFormatRef StylesBuffer::createNumFmt( sal_Int32 nNumFmtId, const OUString& rFmtCode )
    2926                 :            : {
    2927                 :          0 :     return maNumFmts.createNumFmt( nNumFmtId, rFmtCode );
    2928                 :            : }
    2929                 :            : 
    2930                 :         24 : BorderRef StylesBuffer::createBorder( sal_Int32* opnBorderId )
    2931                 :            : {
    2932         [ -  + ]:         24 :     if( opnBorderId ) *opnBorderId = static_cast< sal_Int32 >( maBorders.size() );
    2933 [ +  - ][ +  - ]:         24 :     BorderRef xBorder( new Border( *this, false ) );
    2934         [ +  - ]:         24 :     maBorders.push_back( xBorder );
    2935                 :         24 :     return xBorder;
    2936                 :            : }
    2937                 :            : 
    2938                 :         51 : FillRef StylesBuffer::createFill( sal_Int32* opnFillId )
    2939                 :            : {
    2940         [ -  + ]:         51 :     if( opnFillId ) *opnFillId = static_cast< sal_Int32 >( maFills.size() );
    2941 [ +  - ][ +  - ]:         51 :     FillRef xFill( new Fill( *this, false ) );
    2942         [ +  - ]:         51 :     maFills.push_back( xFill );
    2943                 :         51 :     return xFill;
    2944                 :            : }
    2945                 :            : 
    2946                 :         87 : XfRef StylesBuffer::createCellXf( sal_Int32* opnXfId )
    2947                 :            : {
    2948         [ -  + ]:         87 :     if( opnXfId ) *opnXfId = static_cast< sal_Int32 >( maCellXfs.size() );
    2949 [ +  - ][ +  - ]:         87 :     XfRef xXf( new Xf( *this ) );
    2950         [ +  - ]:         87 :     maCellXfs.push_back( xXf );
    2951                 :         87 :     return xXf;
    2952                 :            : }
    2953                 :            : 
    2954                 :        378 : XfRef StylesBuffer::createStyleXf( sal_Int32* opnXfId )
    2955                 :            : {
    2956         [ -  + ]:        378 :     if( opnXfId ) *opnXfId = static_cast< sal_Int32 >( maStyleXfs.size() );
    2957 [ +  - ][ +  - ]:        378 :     XfRef xXf( new Xf( *this ) );
    2958         [ +  - ]:        378 :     maStyleXfs.push_back( xXf );
    2959                 :        378 :     return xXf;
    2960                 :            : }
    2961                 :            : 
    2962                 :          0 : DxfRef StylesBuffer::createDxf( sal_Int32* opnDxfId )
    2963                 :            : {
    2964         [ #  # ]:          0 :     if( opnDxfId ) *opnDxfId = static_cast< sal_Int32 >( maDxfs.size() );
    2965 [ #  # ][ #  # ]:          0 :     DxfRef xDxf( new Dxf( *this ) );
    2966         [ #  # ]:          0 :     maDxfs.push_back( xDxf );
    2967                 :          0 :     return xDxf;
    2968                 :            : }
    2969                 :            : 
    2970                 :          0 : void StylesBuffer::importPaletteColor( const AttributeList& rAttribs )
    2971                 :            : {
    2972                 :          0 :     maPalette.importPaletteColor( rAttribs );
    2973                 :          0 : }
    2974                 :            : 
    2975                 :         48 : NumberFormatRef StylesBuffer::importNumFmt( const AttributeList& rAttribs )
    2976                 :            : {
    2977                 :         48 :     return maNumFmts.importNumFmt( rAttribs );
    2978                 :            : }
    2979                 :            : 
    2980                 :        126 : CellStyleRef StylesBuffer::importCellStyle( const AttributeList& rAttribs )
    2981                 :            : {
    2982                 :        126 :     return maCellStyles.importCellStyle( rAttribs );
    2983                 :            : }
    2984                 :            : 
    2985                 :          0 : void StylesBuffer::importPaletteColor( SequenceInputStream& rStrm )
    2986                 :            : {
    2987                 :          0 :     maPalette.importPaletteColor( rStrm );
    2988                 :          0 : }
    2989                 :            : 
    2990                 :          0 : void StylesBuffer::importNumFmt( SequenceInputStream& rStrm )
    2991                 :            : {
    2992                 :          0 :     maNumFmts.importNumFmt( rStrm );
    2993                 :          0 : }
    2994                 :            : 
    2995                 :          0 : void StylesBuffer::importCellStyle( SequenceInputStream& rStrm )
    2996                 :            : {
    2997                 :          0 :     maCellStyles.importCellStyle( rStrm );
    2998                 :          0 : }
    2999                 :            : 
    3000                 :         24 : void StylesBuffer::finalizeImport()
    3001                 :            : {
    3002                 :            :     // fonts first, are needed to finalize unit converter and XFs below
    3003                 :         24 :     maFonts.forEachMem( &Font::finalizeImport );
    3004                 :            :     // finalize unit coefficients after default font is known
    3005                 :         24 :     getUnitConverter().finalizeImport();
    3006                 :            :     // number formats
    3007                 :         24 :     maNumFmts.finalizeImport();
    3008                 :            :     // borders and fills
    3009                 :         24 :     maBorders.forEachMem( &Border::finalizeImport );
    3010                 :         24 :     maFills.forEachMem( &Fill::finalizeImport );
    3011                 :            :     // style XFs and cell XFs
    3012                 :         24 :     maStyleXfs.forEachMem( &Xf::finalizeImport );
    3013                 :         24 :     maCellXfs.forEachMem( &Xf::finalizeImport );
    3014                 :            :     // built-in and user defined cell styles
    3015                 :         24 :     maCellStyles.finalizeImport();
    3016                 :            :     // differential formatting (for conditional formatting)
    3017                 :         24 :     maDxfs.forEachMem( &Dxf::finalizeImport );
    3018                 :         24 : }
    3019                 :            : 
    3020                 :        144 : sal_Int32 StylesBuffer::getPaletteColor( sal_Int32 nPaletteIdx ) const
    3021                 :            : {
    3022                 :        144 :     return maPalette.getColor( nPaletteIdx );
    3023                 :            : }
    3024                 :            : 
    3025                 :        267 : FontRef StylesBuffer::getFont( sal_Int32 nFontId ) const
    3026                 :            : {
    3027                 :        267 :     return maFonts.get( nFontId );
    3028                 :            : }
    3029                 :            : 
    3030                 :        123 : BorderRef StylesBuffer::getBorder( sal_Int32 nBorderId ) const
    3031                 :            : {
    3032                 :        123 :     return maBorders.get( nBorderId );
    3033                 :            : }
    3034                 :            : 
    3035                 :        963 : XfRef StylesBuffer::getCellXf( sal_Int32 nXfId ) const
    3036                 :            : {
    3037                 :        963 :     return maCellXfs.get( nXfId );
    3038                 :            : }
    3039                 :            : 
    3040                 :        225 : XfRef StylesBuffer::getStyleXf( sal_Int32 nXfId ) const
    3041                 :            : {
    3042                 :        225 :     return maStyleXfs.get( nXfId );
    3043                 :            : }
    3044                 :            : 
    3045                 :        147 : FontRef StylesBuffer::getFontFromCellXf( sal_Int32 nXfId ) const
    3046                 :            : {
    3047                 :        147 :     FontRef xFont;
    3048 [ +  - ][ +  + ]:        147 :     if( const Xf* pXf = getCellXf( nXfId ).get() )
                 [ +  - ]
    3049 [ +  - ][ +  - ]:        141 :         xFont = pXf->getFont();
                 [ +  - ]
    3050                 :        147 :     return xFont;
    3051                 :            : }
    3052                 :            : 
    3053                 :        126 : FontRef StylesBuffer::getDefaultFont() const
    3054                 :            : {
    3055                 :        126 :     FontRef xDefFont;
    3056 [ +  - ][ +  - ]:        126 :     if( const Xf* pXf = getStyleXf( maCellStyles.getDefaultXfId() ).get() )
         [ +  - ][ +  - ]
    3057 [ +  - ][ +  - ]:        126 :         xDefFont = pXf->getFont();
                 [ +  - ]
    3058                 :            :     // no font from styles - try first loaded font (e.g. BIFF2)
    3059         [ -  + ]:        126 :     if( !xDefFont )
    3060 [ #  # ][ #  # ]:          0 :         xDefFont = maFonts.get( 0 );
                 [ #  # ]
    3061                 :            :     OSL_ENSURE( xDefFont.get(), "StylesBuffer::getDefaultFont - no default font found" );
    3062                 :        126 :     return xDefFont;
    3063                 :            : }
    3064                 :            : 
    3065                 :        102 : const FontModel& StylesBuffer::getDefaultFontModel() const
    3066                 :            : {
    3067         [ +  - ]:        102 :     FontRef xDefFont = getDefaultFont();
    3068 [ +  - ][ #  # ]:        102 :     return xDefFont.get() ? xDefFont->getModel() : getTheme().getDefaultFontModel();
                 [ +  - ]
    3069                 :            : }
    3070                 :            : 
    3071                 :         87 : bool StylesBuffer::equalBorders( sal_Int32 nBorderId1, sal_Int32 nBorderId2 ) const
    3072                 :            : {
    3073         [ +  - ]:         87 :     if( nBorderId1 == nBorderId2 )
    3074                 :         87 :         return true;
    3075                 :            : 
    3076   [ #  #  #  # ]:          0 :     switch( getFilterType() )
    3077                 :            :     {
    3078                 :            :         case FILTER_OOXML:
    3079                 :            :             // in OOXML, borders are assumed to be unique
    3080                 :          0 :             return false;
    3081                 :            : 
    3082                 :            :         case FILTER_BIFF:
    3083                 :            :         {
    3084                 :            :             // in BIFF, a new border entry has been created for every XF
    3085                 :          0 :             const Border* pBorder1 = maBorders.get( nBorderId1 ).get();
    3086                 :          0 :             const Border* pBorder2 = maBorders.get( nBorderId2 ).get();
    3087 [ #  # ][ #  # ]:          0 :             return pBorder1 && pBorder2 && (pBorder1->getApiData() == pBorder2->getApiData());
                 [ #  # ]
    3088                 :            :         }
    3089                 :            : 
    3090                 :            :         case FILTER_UNKNOWN:
    3091                 :          0 :         break;
    3092                 :            :     }
    3093                 :         87 :     return false;
    3094                 :            : }
    3095                 :            : 
    3096                 :         87 : bool StylesBuffer::equalFills( sal_Int32 nFillId1, sal_Int32 nFillId2 ) const
    3097                 :            : {
    3098         [ +  + ]:         87 :     if( nFillId1 == nFillId2 )
    3099                 :         84 :         return true;
    3100                 :            : 
    3101   [ +  -  -  - ]:          3 :     switch( getFilterType() )
    3102                 :            :     {
    3103                 :            :         case FILTER_OOXML:
    3104                 :            :             // in OOXML, fills are assumed to be unique
    3105                 :          3 :             return false;
    3106                 :            : 
    3107                 :            :         case FILTER_BIFF:
    3108                 :            :         {
    3109                 :            :             // in BIFF, a new fill entry has been created for every XF
    3110                 :          0 :             const Fill* pFill1 = maFills.get( nFillId1 ).get();
    3111                 :          0 :             const Fill* pFill2 = maFills.get( nFillId2 ).get();
    3112 [ #  # ][ #  # ]:          0 :             return pFill1 && pFill2 && (pFill1->getApiData() == pFill2->getApiData());
                 [ #  # ]
    3113                 :            :         }
    3114                 :            : 
    3115                 :            :         case FILTER_UNKNOWN:
    3116                 :          0 :         break;
    3117                 :            :     }
    3118                 :         87 :     return false;
    3119                 :            : }
    3120                 :            : 
    3121                 :         60 : OUString StylesBuffer::getDefaultStyleName() const
    3122                 :            : {
    3123                 :         60 :     return maCellStyles.getDefaultStyleName();
    3124                 :            : }
    3125                 :            : 
    3126                 :         60 : OUString StylesBuffer::createCellStyle( sal_Int32 nXfId ) const
    3127                 :            : {
    3128                 :         60 :     return maCellStyles.createCellStyle( nXfId );
    3129                 :            : }
    3130                 :            : 
    3131                 :          0 : OUString StylesBuffer::createDxfStyle( sal_Int32 nDxfId ) const
    3132                 :            : {
    3133                 :          0 :     OUString& rStyleName = maDxfStyles[ nDxfId ];
    3134         [ #  # ]:          0 :     if( rStyleName.isEmpty() )
    3135                 :            :     {
    3136         [ #  # ]:          0 :         if( Dxf* pDxf = maDxfs.get( nDxfId ).get() )
    3137                 :            :         {
    3138 [ #  # ][ #  # ]:          0 :             rStyleName = OUStringBuffer( CREATE_OUSTRING( "ConditionalStyle_" ) ).append( nDxfId + 1 ).makeStringAndClear();
         [ #  # ][ #  # ]
    3139                 :            :             // create the style sheet (this may change rStyleName if such a style already exists)
    3140         [ #  # ]:          0 :             Reference< XStyle > xStyle = createStyleObject( rStyleName, false );
    3141                 :            :             // write style formatting properties
    3142         [ #  # ]:          0 :             PropertySet aPropSet( xStyle );
    3143 [ #  # ][ #  # ]:          0 :             pDxf->writeToPropertySet( aPropSet );
    3144                 :            :         }
    3145                 :            :         // on error: fallback to default style
    3146         [ #  # ]:          0 :         if( rStyleName.isEmpty() )
    3147                 :          0 :             rStyleName = maCellStyles.getDefaultStyleName();
    3148                 :            :     }
    3149                 :          0 :     return rStyleName;
    3150                 :            : }
    3151                 :            : 
    3152                 :        417 : void StylesBuffer::writeFontToItemSet( SfxItemSet& rItemSet, sal_Int32 nFontId, bool bSkipPoolDefs ) const
    3153                 :            : {
    3154         [ +  - ]:        417 :     if( Font* pFont = maFonts.get( nFontId ).get() )
    3155                 :        417 :         pFont->fillToItemSet( rItemSet, FONT_PROPTYPE_CELL, bSkipPoolDefs );
    3156                 :        417 : }
    3157                 :            : 
    3158                 :         24 : void StylesBuffer::writeFontToPropertyMap( PropertyMap& rPropMap, sal_Int32 nFontId ) const
    3159                 :            : {
    3160         [ +  - ]:         24 :     if( Font* pFont = maFonts.get( nFontId ).get() )
    3161                 :         24 :         pFont->writeToPropertyMap( rPropMap, FONT_PROPTYPE_CELL );
    3162                 :         24 : }
    3163                 :            : 
    3164                 :        405 : void StylesBuffer::writeNumFmtToItemSet( SfxItemSet& rItemSet, sal_Int32 nNumFmtId, bool bSkipPoolDefs ) const
    3165                 :            : {
    3166                 :        405 :     maNumFmts.fillToItemSet( rItemSet, nNumFmtId, bSkipPoolDefs );
    3167                 :        405 : }
    3168                 :            : 
    3169                 :         24 : void StylesBuffer::writeNumFmtToPropertyMap( PropertyMap& rPropMap, sal_Int32 nNumFmtId ) const
    3170                 :            : {
    3171                 :         24 :     maNumFmts.writeToPropertyMap( rPropMap, nNumFmtId );
    3172                 :         24 : }
    3173                 :            : 
    3174                 :         36 : void StylesBuffer::writeBorderToItemSet( SfxItemSet& rItemSet, sal_Int32 nBorderId, bool bSkipPoolDefs ) const
    3175                 :            : {
    3176         [ +  - ]:         36 :     if( Border* pBorder = maBorders.get( nBorderId ).get() )
    3177                 :         36 :         pBorder->fillToItemSet( rItemSet, bSkipPoolDefs );
    3178                 :         36 : }
    3179                 :            : 
    3180                 :         24 : void StylesBuffer::writeBorderToPropertyMap( PropertyMap& rPropMap, sal_Int32 nBorderId ) const
    3181                 :            : {
    3182         [ +  - ]:         24 :     if( Border* pBorder = maBorders.get( nBorderId ).get() )
    3183                 :         24 :         pBorder->writeToPropertyMap( rPropMap );
    3184                 :         24 : }
    3185                 :            : 
    3186                 :        381 : void StylesBuffer::writeFillToItemSet( SfxItemSet& rItemSet, sal_Int32 nFillId, bool bSkipPoolDefs ) const
    3187                 :            : {
    3188         [ +  - ]:        381 :     if( Fill* pFill = maFills.get( nFillId ).get() )
    3189                 :        381 :         pFill->fillToItemSet( rItemSet, bSkipPoolDefs );
    3190                 :        381 : }
    3191                 :            : 
    3192                 :         24 : void StylesBuffer::writeFillToPropertyMap( PropertyMap& rPropMap, sal_Int32 nFillId ) const
    3193                 :            : {
    3194         [ +  - ]:         24 :     if( Fill* pFill = maFills.get( nFillId ).get() )
    3195                 :         24 :         pFill->writeToPropertyMap( rPropMap );
    3196                 :         24 : }
    3197                 :            : 
    3198                 :        153 : void StylesBuffer::writeCellXfToMarkData( ScMarkData& rMark,  sal_Int32 nXfId, sal_Int32 nNumFmtId  )
    3199                 :            : {
    3200         [ +  + ]:        153 :     if( Xf* pXf = maCellXfs.get( nXfId ).get() )
    3201                 :         93 :         pXf->writeToMarkData( rMark, nNumFmtId );
    3202                 :        153 : }
    3203                 :            : 
    3204                 :        312 : bool operator==( const XfModel& rXfModel1,  const XfModel& rXfModel2 )
    3205                 :            : {
    3206                 :            :     return ( rXfModel1.mbCellXf == rXfModel2.mbCellXf &&
    3207                 :            :         rXfModel1.mnStyleXfId == rXfModel2.mnStyleXfId &&
    3208                 :            :         rXfModel1.mbFontUsed == rXfModel2.mbFontUsed &&
    3209                 :            :         rXfModel1.mnFontId == rXfModel2.mnFontId &&
    3210                 :            :         rXfModel1.mbNumFmtUsed == rXfModel2.mbNumFmtUsed &&
    3211                 :            :         rXfModel1.mnNumFmtId == rXfModel2.mnNumFmtId &&
    3212                 :            :         rXfModel1.mbAlignUsed == rXfModel2.mbAlignUsed &&
    3213                 :            :         rXfModel1.mbBorderUsed == rXfModel2.mbBorderUsed &&
    3214                 :            :         rXfModel1.mnBorderId == rXfModel2.mnBorderId &&
    3215                 :            :         rXfModel1.mbAreaUsed == rXfModel2.mbAreaUsed &&
    3216                 :            :         rXfModel1.mnFillId == rXfModel2.mnFillId &&
    3217 [ +  - ][ +  - ]:        312 :         rXfModel1.mbProtUsed == rXfModel2.mbProtUsed );
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    3218                 :            : }
    3219                 :            : 
    3220                 :        312 : bool operator==( const Xf& rXf1, const Xf& rXf2 )
    3221                 :            : {
    3222         [ +  + ]:        312 :     if ( rXf1.maModel == rXf2.maModel )
    3223                 :            :     {
    3224         [ +  - ]:          9 :         if ( rXf1.maModel.mbAlignUsed )
    3225                 :            :         {
    3226         [ +  - ]:          9 :             if ( !( rXf1.maAlignment.getApiData() == rXf2.maAlignment.getApiData() ) )
    3227                 :          9 :                 return false;
    3228                 :            :         }
    3229         [ #  # ]:          0 :         if ( rXf1.maModel.mbProtUsed )
    3230                 :            :         {
    3231         [ #  # ]:          0 :             if ( !( rXf1.maProtection.getApiData() == rXf2.maProtection.getApiData() ) )
    3232                 :          0 :                 return false;
    3233                 :            :         }
    3234                 :          0 :         return true;
    3235                 :            :     }
    3236                 :        312 :     return false;
    3237                 :            : }
    3238                 :            : 
    3239                 :         69 : void StylesBuffer::writeCellXfToPropertySet( PropertySet& rPropSet, sal_Int32 nXfId ) const
    3240                 :            : {
    3241         [ +  + ]:         69 :     if( Xf* pXf = maCellXfs.get( nXfId ).get() )
    3242                 :         60 :         pXf->writeToPropertySet( rPropSet );
    3243                 :         69 : }
    3244                 :            : 
    3245                 :         24 : bool StylesBuffer::hasBorder( sal_Int32 nBorderId ) const
    3246                 :            : {
    3247                 :         24 :     Border* pBorder = maBorders.get( nBorderId ).get();
    3248 [ -  + ][ +  - ]:         24 :     return pBorder && pBorder->hasBorder();
    3249                 :            : }
    3250                 :            : 
    3251                 :         24 : void StylesBuffer::writeStyleXfToPropertySet( PropertySet& rPropSet, sal_Int32 nXfId ) const
    3252                 :            : {
    3253         [ +  - ]:         24 :     if( Xf* pXf = maStyleXfs.get( nXfId ).get() )
    3254                 :         24 :         pXf->writeToPropertySet( rPropSet );
    3255                 :         24 : }
    3256                 :            : 
    3257                 :            : // ============================================================================
    3258                 :            : 
    3259                 :            : } // namespace xls
    3260 [ +  - ][ +  - ]:         24 : } // namespace oox
    3261                 :            : 
    3262                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10