LCOV - code coverage report
Current view: top level - sc/source/core/tool - autoform.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 444 617 72.0 %
Date: 2012-08-25 Functions: 34 44 77.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 607 1292 47.0 %

           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 "autoform.hxx"
      30                 :            : 
      31                 :            : #include <sfx2/app.hxx>
      32                 :            : #include <sfx2/docfile.hxx>
      33                 :            : #include <unotools/pathoptions.hxx>
      34                 :            : #include <svl/itemset.hxx>
      35                 :            : #include <tools/shl.hxx>
      36                 :            : #include <vcl/svapp.hxx>
      37                 :            : #include <vcl/outdev.hxx>
      38                 :            : #include <svx/dialmgr.hxx>
      39                 :            : #include <svx/dialogs.hrc>
      40                 :            : #include <editeng/langitem.hxx>
      41                 :            : #include <tools/urlobj.hxx>
      42                 :            : #include <unotools/transliterationwrapper.hxx>
      43                 :            : #include <tools/tenccvt.hxx>
      44                 :            : 
      45                 :            : #include "globstr.hrc"
      46                 :            : #include "document.hxx"
      47                 :            : 
      48                 :            : //------------------------------------------------------------------------
      49                 :            : 
      50                 :            : const sal_Char *linker_dummy = "";
      51                 :            : 
      52                 :            : static const sal_Char sAutoTblFmtName[] = "autotbl.fmt";
      53                 :            : 
      54                 :            : // bis SO5PF
      55                 :            : const sal_uInt16 AUTOFORMAT_ID_X        = 9501;
      56                 :            : const sal_uInt16 AUTOFORMAT_ID_358      = 9601;
      57                 :            : const sal_uInt16 AUTOFORMAT_DATA_ID_X   = 9502;
      58                 :            : 
      59                 :            : // ab SO5
      60                 :            : //! in nachfolgenden Versionen muss der Betrag dieser IDs groesser sein
      61                 :            : const sal_uInt16 AUTOFORMAT_ID_504      = 9801;
      62                 :            : const sal_uInt16 AUTOFORMAT_DATA_ID_504 = 9802;
      63                 :            : 
      64                 :            : const sal_uInt16 AUTOFORMAT_ID_552      = 9901;
      65                 :            : const sal_uInt16 AUTOFORMAT_DATA_ID_552 = 9902;
      66                 :            : 
      67                 :            : // --- from 641 on: CJK and CTL font settings
      68                 :            : const sal_uInt16 AUTOFORMAT_ID_641      = 10001;
      69                 :            : const sal_uInt16 AUTOFORMAT_DATA_ID_641 = 10002;
      70                 :            : 
      71                 :            : // --- from 680/dr14 on: diagonal frame lines
      72                 :            : const sal_uInt16 AUTOFORMAT_ID_680DR14      = 10011;
      73                 :            : const sal_uInt16 AUTOFORMAT_DATA_ID_680DR14 = 10012;
      74                 :            : 
      75                 :            : // --- from 680/dr25 on: store strings as UTF-8
      76                 :            : const sal_uInt16 AUTOFORMAT_ID_680DR25      = 10021;
      77                 :            : const sal_uInt16 AUTOFORMAT_DATA_ID_680DR25 = 10022;
      78                 :            : 
      79                 :            : // --- from DEV300/overline2 on: overline support
      80                 :            : const sal_uInt16 AUTOFORMAT_ID_300OVRLN      = 10031;
      81                 :            : const sal_uInt16 AUTOFORMAT_DATA_ID_300OVRLN = 10032;
      82                 :            : 
      83                 :            : // --- Bug fix to fdo#31005: Table Autoformats does not save/apply all properties (Writer and Calc)
      84                 :            : const sal_uInt16 AUTOFORMAT_ID_31005      = 10041;
      85                 :            : const sal_uInt16 AUTOFORMAT_DATA_ID_31005 = 10042;
      86                 :            : 
      87                 :            : // current version
      88                 :            : const sal_uInt16 AUTOFORMAT_ID          = AUTOFORMAT_ID_31005;
      89                 :            : const sal_uInt16 AUTOFORMAT_DATA_ID     = AUTOFORMAT_DATA_ID_31005;
      90                 :            : 
      91                 :            : 
      92                 :            : namespace
      93                 :            : {
      94                 :            :     /// Read an AutoFormatSwBlob from stream.
      95                 :          0 :     SvStream& operator>>(SvStream &stream, AutoFormatSwBlob &blob)
      96                 :            :     {
      97                 :          0 :         blob.Reset();
      98                 :            : 
      99                 :          0 :         sal_uInt64 endOfBlob = 0;
     100         [ #  # ]:          0 :         stream >> endOfBlob;
     101                 :            : 
     102                 :          0 :         const sal_uInt64 currentPosition = stream.Tell();
     103                 :          0 :         const sal_uInt64 blobSize = endOfBlob - currentPosition;
     104                 :            :         // A zero-size indicates an empty blob. This happens when Calc creates a new autoformat,
     105                 :            :         // since it (naturally) doesn't have any writer-specific data to write.
     106         [ #  # ]:          0 :         if (blobSize)
     107                 :            :         {
     108         [ #  # ]:          0 :             blob.pData = new sal_uInt8[blobSize];
     109                 :          0 :             blob.size = static_cast<sal_Size>(blobSize);
     110         [ #  # ]:          0 :             stream.Read(blob.pData, blob.size);
     111                 :            :         }
     112                 :            : 
     113                 :          0 :         return stream;
     114                 :            :     }
     115                 :            : 
     116                 :            :     /// Write an AutoFormatSwBlob to stream.
     117                 :        563 :     SvStream& operator<<(SvStream &stream, AutoFormatSwBlob &blob)
     118                 :            :     {
     119                 :        563 :         const sal_uInt64 endOfBlob = stream.Tell() + sizeof(sal_uInt64) + blob.size;
     120                 :        563 :         stream << endOfBlob;
     121         [ -  + ]:        563 :         if (blob.size)
     122                 :          0 :             stream.Write(blob.pData, blob.size);
     123                 :            : 
     124                 :        563 :         return stream;
     125                 :            :     }
     126                 :            : }
     127                 :            : 
     128                 :          1 : ScAfVersions::ScAfVersions() :
     129                 :            :     nFontVersion(0),
     130                 :            :     nFontHeightVersion(0),
     131                 :            :     nWeightVersion(0),
     132                 :            :     nPostureVersion(0),
     133                 :            :     nUnderlineVersion(0),
     134                 :            :     nOverlineVersion(0),
     135                 :            :     nCrossedOutVersion(0),
     136                 :            :     nContourVersion(0),
     137                 :            :     nShadowedVersion(0),
     138                 :            :     nColorVersion(0),
     139                 :            :     nBoxVersion(0),
     140                 :            :     nLineVersion(0),
     141                 :            :     nBrushVersion(0),
     142                 :            :     nAdjustVersion(0),
     143                 :            :     nHorJustifyVersion(0),
     144                 :            :     nVerJustifyVersion(0),
     145                 :            :     nOrientationVersion(0),
     146                 :            :     nMarginVersion(0),
     147                 :            :     nBoolVersion(0),
     148                 :            :     nInt32Version(0),
     149                 :            :     nRotateModeVersion(0),
     150                 :          1 :     nNumFmtVersion(0)
     151                 :            : {
     152                 :          1 : }
     153                 :            : 
     154                 :          1 : void ScAfVersions::Load( SvStream& rStream, sal_uInt16 nVer )
     155                 :            : {
     156                 :          1 :     rStream >> nFontVersion;
     157                 :          1 :     rStream >> nFontHeightVersion;
     158                 :          1 :     rStream >> nWeightVersion;
     159                 :          1 :     rStream >> nPostureVersion;
     160                 :          1 :     rStream >> nUnderlineVersion;
     161         [ -  + ]:          1 :     if ( nVer >= AUTOFORMAT_ID_300OVRLN )
     162                 :          0 :         rStream >> nOverlineVersion;
     163                 :          1 :     rStream >> nCrossedOutVersion;
     164                 :          1 :     rStream >> nContourVersion;
     165                 :          1 :     rStream >> nShadowedVersion;
     166                 :          1 :     rStream >> nColorVersion;
     167                 :          1 :     rStream >> nBoxVersion;
     168         [ +  - ]:          1 :     if ( nVer >= AUTOFORMAT_ID_680DR14 )
     169                 :          1 :         rStream >> nLineVersion;
     170                 :          1 :     rStream >> nBrushVersion;
     171                 :          1 :     rStream >> nAdjustVersion;
     172         [ -  + ]:          1 :     if (nVer >= AUTOFORMAT_ID_31005)
     173                 :          0 :         rStream >> swVersions;
     174                 :          1 :     rStream >> nHorJustifyVersion;
     175                 :          1 :     rStream >> nVerJustifyVersion;
     176                 :          1 :     rStream >> nOrientationVersion;
     177                 :          1 :     rStream >> nMarginVersion;
     178                 :          1 :     rStream >> nBoolVersion;
     179         [ +  - ]:          1 :     if ( nVer >= AUTOFORMAT_ID_504 )
     180                 :            :     {
     181                 :          1 :         rStream >> nInt32Version;
     182                 :          1 :         rStream >> nRotateModeVersion;
     183                 :            :     }
     184                 :          1 :     rStream >> nNumFmtVersion;
     185                 :          1 : }
     186                 :            : 
     187                 :          2 : void ScAfVersions::Write(SvStream& rStream, sal_uInt16 fileVersion)
     188                 :            : {
     189 [ +  - ][ +  - ]:          2 :     rStream << SvxFontItem(ATTR_FONT).GetVersion(fileVersion);
     190 [ +  - ][ +  - ]:          2 :     rStream << SvxFontHeightItem(240, 100, ATTR_FONT_HEIGHT).GetVersion(fileVersion);
     191 [ +  - ][ +  - ]:          2 :     rStream << SvxWeightItem(WEIGHT_NORMAL, ATTR_FONT_WEIGHT).GetVersion(fileVersion);
     192 [ +  - ][ +  - ]:          2 :     rStream << SvxPostureItem(ITALIC_NONE, ATTR_FONT_POSTURE).GetVersion(fileVersion);
     193 [ +  - ][ +  - ]:          2 :     rStream << SvxUnderlineItem(UNDERLINE_NONE, ATTR_FONT_UNDERLINE).GetVersion(fileVersion);
     194 [ +  - ][ +  - ]:          2 :     rStream << SvxOverlineItem(UNDERLINE_NONE, ATTR_FONT_OVERLINE).GetVersion(fileVersion);
     195 [ +  - ][ +  - ]:          2 :     rStream << SvxCrossedOutItem(STRIKEOUT_NONE, ATTR_FONT_CROSSEDOUT).GetVersion(fileVersion);
     196 [ +  - ][ +  - ]:          2 :     rStream << SvxContourItem(false, ATTR_FONT_CONTOUR).GetVersion(fileVersion);
     197 [ +  - ][ +  - ]:          2 :     rStream << SvxShadowedItem(false, ATTR_FONT_SHADOWED).GetVersion(fileVersion);
     198 [ +  - ][ +  - ]:          2 :     rStream << SvxColorItem(ATTR_FONT_COLOR).GetVersion(fileVersion);
     199 [ +  - ][ +  - ]:          2 :     rStream << SvxBoxItem(ATTR_BORDER).GetVersion(fileVersion);
     200 [ +  - ][ +  - ]:          2 :     rStream << SvxLineItem(SID_FRAME_LINESTYLE).GetVersion(fileVersion);
     201 [ +  - ][ +  - ]:          2 :     rStream << SvxBrushItem(ATTR_BACKGROUND).GetVersion(fileVersion);
     202                 :            : 
     203 [ +  - ][ +  - ]:          2 :     rStream << SvxAdjustItem(SVX_ADJUST_LEFT, 0).GetVersion(fileVersion);
     204         [ +  - ]:          2 :     if (fileVersion >= SOFFICE_FILEFORMAT_50)
     205                 :          2 :         rStream << swVersions;
     206                 :            : 
     207 [ +  - ][ +  - ]:          2 :     rStream << SvxHorJustifyItem(SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY).GetVersion(fileVersion);
     208 [ +  - ][ +  - ]:          2 :     rStream << SvxVerJustifyItem(SVX_VER_JUSTIFY_STANDARD, ATTR_VER_JUSTIFY).GetVersion(fileVersion);
     209 [ +  - ][ +  - ]:          2 :     rStream << SvxOrientationItem(SVX_ORIENTATION_STANDARD, 0).GetVersion(fileVersion);
     210 [ +  - ][ +  - ]:          2 :     rStream << SvxMarginItem(ATTR_MARGIN).GetVersion(fileVersion);
     211 [ +  - ][ +  - ]:          2 :     rStream << SfxBoolItem(ATTR_LINEBREAK).GetVersion(fileVersion);
     212 [ +  - ][ +  - ]:          2 :     rStream << SfxInt32Item(ATTR_ROTATE_VALUE).GetVersion(fileVersion);
     213 [ +  - ][ +  - ]:          2 :     rStream << SvxRotateModeItem(SVX_ROTATE_MODE_STANDARD,0).GetVersion(fileVersion);
     214                 :            : 
     215                 :          2 :     rStream << (sal_uInt16)0;       // Num-Format
     216                 :          2 : }
     217                 :            : 
     218                 :            : //  ---------------------------------------------------------------------------
     219                 :            : 
     220                 :        288 : ScAutoFormatDataField::ScAutoFormatDataField() :
     221                 :            :     aFont( ATTR_FONT ),
     222                 :            :     aHeight( 240, 100, ATTR_FONT_HEIGHT ),
     223                 :            :     aWeight( WEIGHT_NORMAL, ATTR_FONT_WEIGHT ),
     224                 :            :     aPosture( ITALIC_NONE, ATTR_FONT_POSTURE ),
     225                 :            : 
     226                 :            :     aCJKFont( ATTR_CJK_FONT ),
     227                 :            :     aCJKHeight( 240, 100, ATTR_CJK_FONT_HEIGHT ),
     228                 :            :     aCJKWeight( WEIGHT_NORMAL, ATTR_CJK_FONT_WEIGHT ),
     229                 :            :     aCJKPosture( ITALIC_NONE, ATTR_CJK_FONT_POSTURE ),
     230                 :            : 
     231                 :            :     aCTLFont( ATTR_CTL_FONT ),
     232                 :            :     aCTLHeight( 240, 100, ATTR_CTL_FONT_HEIGHT ),
     233                 :            :     aCTLWeight( WEIGHT_NORMAL, ATTR_CTL_FONT_WEIGHT ),
     234                 :            :     aCTLPosture( ITALIC_NONE, ATTR_CTL_FONT_POSTURE ),
     235                 :            : 
     236                 :            :     aUnderline( UNDERLINE_NONE,ATTR_FONT_UNDERLINE ),
     237                 :            :     aOverline( UNDERLINE_NONE,ATTR_FONT_OVERLINE ),
     238                 :            :     aCrossedOut( STRIKEOUT_NONE, ATTR_FONT_CROSSEDOUT ),
     239                 :            :     aContour( false, ATTR_FONT_CONTOUR ),
     240                 :            :     aShadowed( false, ATTR_FONT_SHADOWED ),
     241                 :            :     aColor( ATTR_FONT_COLOR ),
     242                 :            :     aBox( ATTR_BORDER ),
     243                 :            :     aTLBR( ATTR_BORDER_TLBR ),
     244                 :            :     aBLTR( ATTR_BORDER_BLTR ),
     245                 :            :     aBackground( ATTR_BACKGROUND ),
     246                 :            :     aAdjust( SVX_ADJUST_LEFT, 0 ),
     247                 :            :     aHorJustify( SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY ),
     248                 :            :     aVerJustify( SVX_VER_JUSTIFY_STANDARD, ATTR_VER_JUSTIFY ),
     249                 :            :     aMargin( ATTR_MARGIN ),
     250                 :            :     aLinebreak( ATTR_LINEBREAK ),
     251                 :            :     aRotateAngle( ATTR_ROTATE_VALUE ),
     252 [ +  - ][ +  - ]:        288 :     aRotateMode( SVX_ROTATE_MODE_STANDARD, ATTR_ROTATE_MODE )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     253                 :            : {
     254                 :        288 : }
     255                 :            : 
     256                 :         32 : ScAutoFormatDataField::ScAutoFormatDataField( const ScAutoFormatDataField& rCopy ) :
     257                 :            :     aFont( rCopy.aFont ),
     258                 :            :     aHeight( rCopy.aHeight ),
     259                 :            :     aWeight( rCopy.aWeight ),
     260                 :            :     aPosture( rCopy.aPosture ),
     261                 :            :     aCJKFont( rCopy.aCJKFont ),
     262                 :            :     aCJKHeight( rCopy.aCJKHeight ),
     263                 :            :     aCJKWeight( rCopy.aCJKWeight ),
     264                 :            :     aCJKPosture( rCopy.aCJKPosture ),
     265                 :            :     aCTLFont( rCopy.aCTLFont ),
     266                 :            :     aCTLHeight( rCopy.aCTLHeight ),
     267                 :            :     aCTLWeight( rCopy.aCTLWeight ),
     268                 :            :     aCTLPosture( rCopy.aCTLPosture ),
     269                 :            :     aUnderline( rCopy.aUnderline ),
     270                 :            :     aOverline( rCopy.aOverline ),
     271                 :            :     aCrossedOut( rCopy.aCrossedOut ),
     272                 :            :     aContour( rCopy.aContour ),
     273                 :            :     aShadowed( rCopy.aShadowed ),
     274                 :            :     aColor( rCopy.aColor ),
     275                 :            :     aBox( rCopy.aBox ),
     276                 :            :     aTLBR( rCopy.aTLBR ),
     277                 :            :     aBLTR( rCopy.aBLTR ),
     278                 :            :     aBackground( rCopy.aBackground ),
     279                 :            :     aAdjust( rCopy.aAdjust ),
     280                 :            :     aHorJustify( rCopy.aHorJustify ),
     281                 :            :     aVerJustify( rCopy.aVerJustify ),
     282                 :            :     aStacked( rCopy.aStacked ),
     283                 :            :     aMargin( rCopy.aMargin ),
     284                 :            :     aLinebreak( rCopy.aLinebreak ),
     285                 :            :     aRotateAngle( rCopy.aRotateAngle ),
     286                 :            :     aRotateMode( rCopy.aRotateMode ),
     287 [ +  - ][ +  - ]:         32 :     aNumFormat( rCopy.aNumFormat )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     288                 :            : {
     289                 :         32 : }
     290                 :            : 
     291 [ +  - ][ +  - ]:        320 : ScAutoFormatDataField::~ScAutoFormatDataField()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     292                 :            : {
     293                 :        320 : }
     294                 :            : 
     295                 :        256 : void ScAutoFormatDataField::SetAdjust( const SvxAdjustItem& rAdjust )
     296                 :            : {
     297                 :        256 :     aAdjust.SetAdjust( rAdjust.GetAdjust() );
     298                 :        256 :     aAdjust.SetOneWord( rAdjust.GetOneWord() );
     299                 :        256 :     aAdjust.SetLastBlock( rAdjust.GetLastBlock() );
     300                 :        256 : }
     301                 :            : 
     302                 :            : #define READ( aItem, ItemType, nVers )      \
     303                 :            :     pNew = aItem.Create( rStream, nVers );  \
     304                 :            :     aItem = *(ItemType*)pNew;               \
     305                 :            :     delete pNew;
     306                 :            : 
     307                 :        256 : sal_Bool ScAutoFormatDataField::Load( SvStream& rStream, const ScAfVersions& rVersions, sal_uInt16 nVer )
     308                 :            : {
     309                 :            :     SfxPoolItem* pNew;
     310         [ +  - ]:        256 :     SvxOrientationItem aOrientation( SVX_ORIENTATION_STANDARD, 0 );
     311                 :            : 
     312 [ +  - ][ +  - ]:        256 :     READ( aFont,        SvxFontItem,        rVersions.nFontVersion)
         [ +  - ][ +  - ]
     313 [ +  - ][ +  - ]:        256 :     READ( aHeight,      SvxFontHeightItem,  rVersions.nFontHeightVersion)
         [ +  - ][ +  - ]
     314 [ +  - ][ +  - ]:        256 :     READ( aWeight,      SvxWeightItem,      rVersions.nWeightVersion)
                 [ +  - ]
     315 [ +  - ][ +  - ]:        256 :     READ( aPosture,     SvxPostureItem,     rVersions.nPostureVersion)
                 [ +  - ]
     316                 :            :     // --- from 641 on: CJK and CTL font settings
     317         [ +  - ]:        256 :     if( AUTOFORMAT_DATA_ID_641 <= nVer )
     318                 :            :     {
     319 [ +  - ][ +  - ]:        256 :         READ( aCJKFont,     SvxFontItem,        rVersions.nFontVersion)
         [ +  - ][ +  - ]
     320 [ +  - ][ +  - ]:        256 :         READ( aCJKHeight,   SvxFontHeightItem,  rVersions.nFontHeightVersion)
         [ +  - ][ +  - ]
     321 [ +  - ][ +  - ]:        256 :         READ( aCJKWeight,   SvxWeightItem,      rVersions.nWeightVersion)
                 [ +  - ]
     322 [ +  - ][ +  - ]:        256 :         READ( aCJKPosture,  SvxPostureItem,     rVersions.nPostureVersion)
                 [ +  - ]
     323 [ +  - ][ +  - ]:        256 :         READ( aCTLFont,     SvxFontItem,        rVersions.nFontVersion)
         [ +  - ][ +  - ]
     324 [ +  - ][ +  - ]:        256 :         READ( aCTLHeight,   SvxFontHeightItem,  rVersions.nFontHeightVersion)
         [ +  - ][ +  - ]
     325 [ +  - ][ +  - ]:        256 :         READ( aCTLWeight,   SvxWeightItem,      rVersions.nWeightVersion)
                 [ +  - ]
     326 [ +  - ][ +  - ]:        256 :         READ( aCTLPosture,  SvxPostureItem,     rVersions.nPostureVersion)
                 [ +  - ]
     327                 :            :     }
     328 [ +  - ][ +  - ]:        256 :     READ( aUnderline,   SvxUnderlineItem,   rVersions.nUnderlineVersion)
         [ +  - ][ +  - ]
     329         [ -  + ]:        256 :     if ( nVer >= AUTOFORMAT_DATA_ID_300OVRLN )
     330                 :            :     {
     331 [ #  # ][ #  # ]:          0 :         READ( aOverline,    SvxOverlineItem,    rVersions.nOverlineVersion)
         [ #  # ][ #  # ]
     332                 :            :     }
     333 [ +  - ][ +  - ]:        256 :     READ( aCrossedOut,  SvxCrossedOutItem,  rVersions.nCrossedOutVersion)
                 [ +  - ]
     334 [ +  - ][ +  - ]:        256 :     READ( aContour,     SvxContourItem,     rVersions.nContourVersion)
                 [ +  - ]
     335 [ +  - ][ +  - ]:        256 :     READ( aShadowed,    SvxShadowedItem,    rVersions.nShadowedVersion)
                 [ +  - ]
     336 [ +  - ][ +  - ]:        256 :     READ( aColor,       SvxColorItem,       rVersions.nColorVersion)
         [ +  - ][ +  - ]
     337 [ +  - ][ +  - ]:        256 :     READ( aBox,         SvxBoxItem,         rVersions.nBoxVersion)
         [ +  - ][ +  - ]
     338                 :            : 
     339                 :            :     // --- from 680/dr14 on: diagonal frame lines
     340         [ +  - ]:        256 :     if( AUTOFORMAT_DATA_ID_680DR14 <= nVer )
     341                 :            :     {
     342 [ +  - ][ +  - ]:        256 :         READ( aTLBR, SvxLineItem, rVersions.nLineVersion)
         [ +  - ][ +  - ]
     343 [ +  - ][ +  - ]:        256 :         READ( aBLTR, SvxLineItem, rVersions.nLineVersion)
         [ +  - ][ +  - ]
     344                 :            :     }
     345                 :            : 
     346 [ +  - ][ +  - ]:        256 :     READ( aBackground,  SvxBrushItem,       rVersions.nBrushVersion)
         [ +  - ][ +  - ]
     347                 :            : 
     348         [ +  - ]:        256 :     pNew = aAdjust.Create( rStream, rVersions.nAdjustVersion );
     349                 :        256 :     SetAdjust( *(SvxAdjustItem*)pNew );
     350 [ +  - ][ +  - ]:        256 :     delete pNew;
     351                 :            : 
     352         [ -  + ]:        256 :     if (nVer >= AUTOFORMAT_DATA_ID_31005)
     353         [ #  # ]:          0 :         rStream >> m_swFields;
     354                 :            : 
     355 [ +  - ][ +  - ]:        256 :     READ( aHorJustify,   SvxHorJustifyItem,  rVersions.nHorJustifyVersion)
                 [ +  - ]
     356 [ +  - ][ +  - ]:        256 :     READ( aVerJustify,   SvxVerJustifyItem,  rVersions.nVerJustifyVersion)
                 [ +  - ]
     357 [ +  - ][ +  - ]:        256 :     READ( aOrientation,  SvxOrientationItem, rVersions.nOrientationVersion)
                 [ +  - ]
     358 [ +  - ][ +  - ]:        256 :     READ( aMargin,       SvxMarginItem,      rVersions.nMarginVersion)
                 [ +  - ]
     359                 :            : 
     360         [ +  - ]:        256 :     pNew = aLinebreak.Create( rStream, rVersions.nBoolVersion );
     361                 :        256 :     SetLinebreak( *(SfxBoolItem*)pNew );
     362 [ +  - ][ +  - ]:        256 :     delete pNew;
     363                 :            : 
     364         [ +  - ]:        256 :     if ( nVer >= AUTOFORMAT_DATA_ID_504 )
     365                 :            :     {
     366         [ +  - ]:        256 :         pNew = aRotateAngle.Create( rStream, rVersions.nInt32Version );
     367                 :        256 :         SetRotateAngle( *(SfxInt32Item*)pNew );
     368 [ +  - ][ +  - ]:        256 :         delete pNew;
     369         [ +  - ]:        256 :         pNew = aRotateMode.Create( rStream, rVersions.nRotateModeVersion );
     370                 :        256 :         SetRotateMode( *(SvxRotateModeItem*)pNew );
     371 [ +  - ][ +  - ]:        256 :         delete pNew;
     372                 :            :     }
     373                 :            : 
     374         [ +  - ]:        256 :     if( 0 == rVersions.nNumFmtVersion )
     375                 :            :     {
     376                 :            :         // --- from 680/dr25 on: store strings as UTF-8
     377         [ -  + ]:        256 :         CharSet eCharSet = (nVer >= AUTOFORMAT_ID_680DR25) ? RTL_TEXTENCODING_UTF8 : rStream.GetStreamCharSet();
     378         [ +  - ]:        256 :         aNumFormat.Load( rStream, eCharSet );
     379                 :            :     }
     380                 :            : 
     381                 :            :     //  adjust charset in font
     382         [ +  - ]:        256 :     CharSet eSysSet = osl_getThreadTextEncoding();
     383                 :        256 :     CharSet eSrcSet = rStream.GetStreamCharSet();
     384 [ +  - ][ +  - ]:        256 :     if( eSrcSet != eSysSet && aFont.GetCharSet() == eSrcSet )
                 [ +  - ]
     385                 :        256 :         aFont.SetCharSet(eSysSet);
     386                 :            : 
     387         [ +  - ]:        256 :     aStacked.SetValue( aOrientation.IsStacked() );
     388         [ +  - ]:        256 :     aRotateAngle.SetValue( aOrientation.GetRotation( aRotateAngle.GetValue() ) );
     389                 :            : 
     390         [ +  - ]:        256 :     return (rStream.GetError() == 0);
     391                 :            : }
     392                 :            : 
     393                 :        528 : sal_Bool ScAutoFormatDataField::Save( SvStream& rStream, sal_uInt16 fileVersion )
     394                 :            : {
     395         [ +  - ]:        528 :     SvxOrientationItem aOrientation( aRotateAngle.GetValue(), aStacked.GetValue(), 0 );
     396                 :            : 
     397 [ +  - ][ +  - ]:        528 :     aFont.Store         ( rStream, aFont.GetVersion( fileVersion ) );
     398 [ +  - ][ +  - ]:        528 :     aHeight.Store       ( rStream, aHeight.GetVersion( fileVersion ) );
     399 [ +  - ][ +  - ]:        528 :     aWeight.Store       ( rStream, aWeight.GetVersion( fileVersion ) );
     400 [ +  - ][ +  - ]:        528 :     aPosture.Store      ( rStream, aPosture.GetVersion( fileVersion ) );
     401                 :            :     // --- from 641 on: CJK and CTL font settings
     402 [ +  - ][ +  - ]:        528 :     aCJKFont.Store      ( rStream, aCJKFont.GetVersion( fileVersion ) );
     403 [ +  - ][ +  - ]:        528 :     aCJKHeight.Store    ( rStream, aCJKHeight.GetVersion( fileVersion ) );
     404 [ +  - ][ +  - ]:        528 :     aCJKWeight.Store    ( rStream, aCJKWeight.GetVersion( fileVersion ) );
     405 [ +  - ][ +  - ]:        528 :     aCJKPosture.Store   ( rStream, aCJKPosture.GetVersion( fileVersion ) );
     406 [ +  - ][ +  - ]:        528 :     aCTLFont.Store      ( rStream, aCTLFont.GetVersion( fileVersion ) );
     407 [ +  - ][ +  - ]:        528 :     aCTLHeight.Store    ( rStream, aCTLHeight.GetVersion( fileVersion ) );
     408 [ +  - ][ +  - ]:        528 :     aCTLWeight.Store    ( rStream, aCTLWeight.GetVersion( fileVersion ) );
     409 [ +  - ][ +  - ]:        528 :     aCTLPosture.Store   ( rStream, aCTLPosture.GetVersion( fileVersion ) );
     410                 :            : 
     411 [ +  - ][ +  - ]:        528 :     aUnderline.Store    ( rStream, aUnderline.GetVersion( fileVersion ) );
     412                 :            :     // --- from DEV300/overline2 on: overline support
     413 [ +  - ][ +  - ]:        528 :     aOverline.Store     ( rStream, aOverline.GetVersion( fileVersion ) );
     414 [ +  - ][ +  - ]:        528 :     aCrossedOut.Store   ( rStream, aCrossedOut.GetVersion( fileVersion ) );
     415 [ +  - ][ +  - ]:        528 :     aContour.Store      ( rStream, aContour.GetVersion( fileVersion ) );
     416 [ +  - ][ +  - ]:        528 :     aShadowed.Store     ( rStream, aShadowed.GetVersion( fileVersion ) );
     417 [ +  - ][ +  - ]:        528 :     aColor.Store        ( rStream, aColor.GetVersion( fileVersion ) );
     418 [ +  - ][ +  - ]:        528 :     aBox.Store          ( rStream, aBox.GetVersion( fileVersion ) );
     419                 :            : 
     420                 :            :     // --- from 680/dr14 on: diagonal frame lines
     421 [ +  - ][ +  - ]:        528 :     aTLBR.Store         ( rStream, aTLBR.GetVersion( fileVersion ) );
     422 [ +  - ][ +  - ]:        528 :     aBLTR.Store         ( rStream, aBLTR.GetVersion( fileVersion ) );
     423                 :            : 
     424 [ +  - ][ +  - ]:        528 :     aBackground.Store   ( rStream, aBackground.GetVersion( fileVersion ) );
     425                 :            : 
     426 [ +  - ][ +  - ]:        528 :     aAdjust.Store       ( rStream, aAdjust.GetVersion( fileVersion ) );
     427         [ +  - ]:        528 :     if (fileVersion >= SOFFICE_FILEFORMAT_50)
     428         [ +  - ]:        528 :         rStream << m_swFields;
     429                 :            : 
     430 [ +  - ][ +  - ]:        528 :     aHorJustify.Store   ( rStream, aHorJustify.GetVersion( fileVersion ) );
     431 [ +  - ][ +  - ]:        528 :     aVerJustify.Store   ( rStream, aVerJustify.GetVersion( fileVersion ) );
     432 [ +  - ][ +  - ]:        528 :     aOrientation.Store  ( rStream, aOrientation.GetVersion( fileVersion ) );
     433 [ +  - ][ +  - ]:        528 :     aMargin.Store       ( rStream, aMargin.GetVersion( fileVersion ) );
     434 [ +  - ][ +  - ]:        528 :     aLinebreak.Store    ( rStream, aLinebreak.GetVersion( fileVersion ) );
     435                 :            :     // Rotation ab SO5
     436 [ +  - ][ +  - ]:        528 :     aRotateAngle.Store  ( rStream, aRotateAngle.GetVersion( fileVersion ) );
     437 [ +  - ][ +  - ]:        528 :     aRotateMode.Store   ( rStream, aRotateMode.GetVersion( fileVersion ) );
     438                 :            : 
     439                 :            :     // --- from 680/dr25 on: store strings as UTF-8
     440         [ +  - ]:        528 :     aNumFormat.Save( rStream, RTL_TEXTENCODING_UTF8 );
     441                 :            : 
     442         [ +  - ]:        528 :     return (rStream.GetError() == 0);
     443                 :            : }
     444                 :            : 
     445                 :            : 
     446                 :            : //  ---------------------------------------------------------------------------
     447                 :            : 
     448                 :         18 : ScAutoFormatData::ScAutoFormatData()
     449                 :            : {
     450                 :         18 :     nStrResId = USHRT_MAX;
     451                 :            : 
     452                 :            :     bIncludeValueFormat =
     453                 :            :     bIncludeFont =
     454                 :            :     bIncludeJustify =
     455                 :            :     bIncludeFrame =
     456                 :            :     bIncludeBackground =
     457                 :         18 :     bIncludeWidthHeight = true;
     458                 :            : 
     459         [ +  - ]:         18 :     ppDataField = new ScAutoFormatDataField*[ 16 ];
     460         [ +  + ]:        306 :     for( sal_uInt16 nIndex = 0; nIndex < 16; ++nIndex )
     461 [ +  - ][ +  - ]:        288 :         ppDataField[ nIndex ] = new ScAutoFormatDataField;
     462                 :         18 : }
     463                 :            : 
     464                 :          2 : ScAutoFormatData::ScAutoFormatData( const ScAutoFormatData& rData ) :
     465                 :            :         aName( rData.aName ),
     466                 :            :         nStrResId( rData.nStrResId ),
     467                 :            :         bIncludeFont( rData.bIncludeFont ),
     468                 :            :         bIncludeJustify( rData.bIncludeJustify ),
     469                 :            :         bIncludeFrame( rData.bIncludeFrame ),
     470                 :            :         bIncludeBackground( rData.bIncludeBackground ),
     471                 :            :         bIncludeValueFormat( rData.bIncludeValueFormat ),
     472                 :          2 :         bIncludeWidthHeight( rData.bIncludeWidthHeight )
     473                 :            : {
     474         [ +  - ]:          2 :     ppDataField = new ScAutoFormatDataField*[ 16 ];
     475         [ +  + ]:         34 :     for( sal_uInt16 nIndex = 0; nIndex < 16; ++nIndex )
     476 [ +  - ][ +  - ]:         32 :         ppDataField[ nIndex ] = new ScAutoFormatDataField( rData.GetField( nIndex ) );
     477                 :          2 : }
     478                 :            : 
     479         [ +  - ]:         20 : ScAutoFormatData::~ScAutoFormatData()
     480                 :            : {
     481         [ +  + ]:        340 :     for( sal_uInt16 nIndex = 0; nIndex < 16; ++nIndex )
     482 [ +  - ][ +  - ]:        320 :         delete ppDataField[ nIndex ];
     483         [ +  - ]:         20 :     delete[] ppDataField;
     484                 :         20 : }
     485                 :            : 
     486                 :       1016 : ScAutoFormatDataField& ScAutoFormatData::GetField( sal_uInt16 nIndex )
     487                 :            : {
     488                 :            :     OSL_ENSURE( nIndex < 16, "ScAutoFormatData::GetField - illegal index" );
     489                 :            :     OSL_ENSURE( ppDataField && ppDataField[ nIndex ], "ScAutoFormatData::GetField - no data" );
     490                 :       1016 :     return *ppDataField[ nIndex ];
     491                 :            : }
     492                 :            : 
     493                 :        338 : const ScAutoFormatDataField& ScAutoFormatData::GetField( sal_uInt16 nIndex ) const
     494                 :            : {
     495                 :            :     OSL_ENSURE( nIndex < 16, "ScAutoFormatData::GetField - illegal index" );
     496                 :            :     OSL_ENSURE( ppDataField && ppDataField[ nIndex ], "ScAutoFormatData::GetField - no data" );
     497                 :        338 :     return *ppDataField[ nIndex ];
     498                 :            : }
     499                 :            : 
     500                 :        306 : const SfxPoolItem* ScAutoFormatData::GetItem( sal_uInt16 nIndex, sal_uInt16 nWhich ) const
     501                 :            : {
     502                 :        306 :     const ScAutoFormatDataField& rField = GetField( nIndex );
     503   [ +  +  +  +  :        306 :     switch( nWhich )
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          -  -  +  +  +  
          +  +  +  +  +  
                      + ]
     504                 :            :     {
     505                 :         42 :         case ATTR_FONT:             return &rField.GetFont();
     506                 :          7 :         case ATTR_FONT_HEIGHT:      return &rField.GetHeight();
     507                 :          7 :         case ATTR_FONT_WEIGHT:      return &rField.GetWeight();
     508                 :          7 :         case ATTR_FONT_POSTURE:     return &rField.GetPosture();
     509                 :         35 :         case ATTR_CJK_FONT:         return &rField.GetCJKFont();
     510                 :          7 :         case ATTR_CJK_FONT_HEIGHT:  return &rField.GetCJKHeight();
     511                 :          7 :         case ATTR_CJK_FONT_WEIGHT:  return &rField.GetCJKWeight();
     512                 :          7 :         case ATTR_CJK_FONT_POSTURE: return &rField.GetCJKPosture();
     513                 :         35 :         case ATTR_CTL_FONT:         return &rField.GetCTLFont();
     514                 :          7 :         case ATTR_CTL_FONT_HEIGHT:  return &rField.GetCTLHeight();
     515                 :          7 :         case ATTR_CTL_FONT_WEIGHT:  return &rField.GetCTLWeight();
     516                 :          7 :         case ATTR_CTL_FONT_POSTURE: return &rField.GetCTLPosture();
     517                 :          7 :         case ATTR_FONT_UNDERLINE:   return &rField.GetUnderline();
     518                 :          7 :         case ATTR_FONT_OVERLINE:    return &rField.GetOverline();
     519                 :          7 :         case ATTR_FONT_CROSSEDOUT:  return &rField.GetCrossedOut();
     520                 :          7 :         case ATTR_FONT_CONTOUR:     return &rField.GetContour();
     521                 :          7 :         case ATTR_FONT_SHADOWED:    return &rField.GetShadowed();
     522                 :          7 :         case ATTR_FONT_COLOR:       return &rField.GetColor();
     523                 :          6 :         case ATTR_BORDER:           return &rField.GetBox();
     524                 :          0 :         case ATTR_BORDER_TLBR:      return &rField.GetTLBR();
     525                 :          0 :         case ATTR_BORDER_BLTR:      return &rField.GetBLTR();
     526                 :         14 :         case ATTR_BACKGROUND:       return &rField.GetBackground();
     527                 :          7 :         case ATTR_HOR_JUSTIFY:      return &rField.GetHorJustify();
     528                 :          3 :         case ATTR_VER_JUSTIFY:      return &rField.GetVerJustify();
     529                 :          7 :         case ATTR_STACKED:          return &rField.GetStacked();
     530                 :         28 :         case ATTR_MARGIN:           return &rField.GetMargin();
     531                 :          7 :         case ATTR_LINEBREAK:        return &rField.GetLinebreak();
     532                 :         12 :         case ATTR_ROTATE_VALUE:     return &rField.GetRotateAngle();
     533                 :          3 :         case ATTR_ROTATE_MODE:      return &rField.GetRotateMode();
     534                 :            :     }
     535                 :        306 :     return NULL;
     536                 :            : }
     537                 :            : 
     538                 :        232 : void ScAutoFormatData::PutItem( sal_uInt16 nIndex, const SfxPoolItem& rItem )
     539                 :            : {
     540                 :        232 :     ScAutoFormatDataField& rField = GetField( nIndex );
     541   [ +  +  +  +  :        232 :     switch( rItem.Which() )
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          -  -  +  +  +  
          +  +  +  +  +  
                      - ]
     542                 :            :     {
     543                 :         28 :         case ATTR_FONT:             rField.SetFont( (const SvxFontItem&)rItem );              break;
     544                 :         18 :         case ATTR_FONT_HEIGHT:      rField.SetHeight( (const SvxFontHeightItem&)rItem );      break;
     545                 :          2 :         case ATTR_FONT_WEIGHT:      rField.SetWeight( (const SvxWeightItem&)rItem );          break;
     546                 :          2 :         case ATTR_FONT_POSTURE:     rField.SetPosture( (const SvxPostureItem&)rItem );        break;
     547                 :         26 :         case ATTR_CJK_FONT:         rField.SetCJKFont( (const SvxFontItem&)rItem );           break;
     548                 :         18 :         case ATTR_CJK_FONT_HEIGHT:  rField.SetCJKHeight( (const SvxFontHeightItem&)rItem );   break;
     549                 :          2 :         case ATTR_CJK_FONT_WEIGHT:  rField.SetCJKWeight( (const SvxWeightItem&)rItem );       break;
     550                 :          2 :         case ATTR_CJK_FONT_POSTURE: rField.SetCJKPosture( (const SvxPostureItem&)rItem );     break;
     551                 :         26 :         case ATTR_CTL_FONT:         rField.SetCTLFont( (const SvxFontItem&)rItem );           break;
     552                 :         18 :         case ATTR_CTL_FONT_HEIGHT:  rField.SetCTLHeight( (const SvxFontHeightItem&)rItem );   break;
     553                 :          2 :         case ATTR_CTL_FONT_WEIGHT:  rField.SetCTLWeight( (const SvxWeightItem&)rItem );       break;
     554                 :          2 :         case ATTR_CTL_FONT_POSTURE: rField.SetCTLPosture( (const SvxPostureItem&)rItem );     break;
     555                 :          2 :         case ATTR_FONT_UNDERLINE:   rField.SetUnderline( (const SvxUnderlineItem&)rItem );    break;
     556                 :          2 :         case ATTR_FONT_OVERLINE:    rField.SetOverline( (const SvxOverlineItem&)rItem );      break;
     557                 :          2 :         case ATTR_FONT_CROSSEDOUT:  rField.SetCrossedOut( (const SvxCrossedOutItem&)rItem );  break;
     558                 :          2 :         case ATTR_FONT_CONTOUR:     rField.SetContour( (const SvxContourItem&)rItem );        break;
     559                 :          2 :         case ATTR_FONT_SHADOWED:    rField.SetShadowed( (const SvxShadowedItem&)rItem );      break;
     560                 :         18 :         case ATTR_FONT_COLOR:       rField.SetColor( (const SvxColorItem&)rItem );            break;
     561                 :         18 :         case ATTR_BORDER:           rField.SetBox( (const SvxBoxItem&)rItem );                break;
     562                 :          0 :         case ATTR_BORDER_TLBR:      rField.SetTLBR( (const SvxLineItem&)rItem );              break;
     563                 :          0 :         case ATTR_BORDER_BLTR:      rField.SetBLTR( (const SvxLineItem&)rItem );              break;
     564                 :         20 :         case ATTR_BACKGROUND:       rField.SetBackground( (const SvxBrushItem&)rItem );       break;
     565                 :          2 :         case ATTR_HOR_JUSTIFY:      rField.SetHorJustify( (const SvxHorJustifyItem&)rItem );  break;
     566                 :          1 :         case ATTR_VER_JUSTIFY:      rField.SetVerJustify( (const SvxVerJustifyItem&)rItem );  break;
     567                 :          2 :         case ATTR_STACKED:          rField.SetStacked( (const SfxBoolItem&)rItem );           break;
     568                 :          8 :         case ATTR_MARGIN:           rField.SetMargin( (const SvxMarginItem&)rItem );          break;
     569                 :          2 :         case ATTR_LINEBREAK:        rField.SetLinebreak( (const SfxBoolItem&)rItem );         break;
     570                 :          4 :         case ATTR_ROTATE_VALUE:     rField.SetRotateAngle( (const SfxInt32Item&)rItem );      break;
     571                 :          1 :         case ATTR_ROTATE_MODE:      rField.SetRotateMode( (const SvxRotateModeItem&)rItem );  break;
     572                 :            :     }
     573                 :        232 : }
     574                 :            : 
     575                 :          0 : void ScAutoFormatData::CopyItem( sal_uInt16 nToIndex, sal_uInt16 nFromIndex, sal_uInt16 nWhich )
     576                 :            : {
     577                 :          0 :     const SfxPoolItem* pItem = GetItem( nFromIndex, nWhich );
     578         [ #  # ]:          0 :     if( pItem )
     579                 :          0 :         PutItem( nToIndex, *pItem );
     580                 :          0 : }
     581                 :            : 
     582                 :          0 : const ScNumFormatAbbrev& ScAutoFormatData::GetNumFormat( sal_uInt16 nIndex ) const
     583                 :            : {
     584                 :          0 :     return GetField( nIndex ).GetNumFormat();
     585                 :            : }
     586                 :            : 
     587                 :          0 : bool ScAutoFormatData::IsEqualData( sal_uInt16 nIndex1, sal_uInt16 nIndex2 ) const
     588                 :            : {
     589                 :          0 :     bool bEqual = true;
     590                 :          0 :     const ScAutoFormatDataField& rField1 = GetField( nIndex1 );
     591                 :          0 :     const ScAutoFormatDataField& rField2 = GetField( nIndex2 );
     592                 :            : 
     593         [ #  # ]:          0 :     if( bIncludeValueFormat )
     594                 :            :     {
     595                 :            :         bEqual = bEqual
     596 [ #  # ][ #  # ]:          0 :             && (rField1.GetNumFormat()      == rField2.GetNumFormat());
     597                 :            :     }
     598         [ #  # ]:          0 :     if( bIncludeFont )
     599                 :            :     {
     600                 :            :         bEqual = bEqual
     601                 :          0 :             && (rField1.GetFont()           == rField2.GetFont())
     602                 :          0 :             && (rField1.GetHeight()         == rField2.GetHeight())
     603                 :          0 :             && (rField1.GetWeight()         == rField2.GetWeight())
     604                 :          0 :             && (rField1.GetPosture()        == rField2.GetPosture())
     605                 :          0 :             && (rField1.GetCJKFont()        == rField2.GetCJKFont())
     606                 :          0 :             && (rField1.GetCJKHeight()      == rField2.GetCJKHeight())
     607                 :          0 :             && (rField1.GetCJKWeight()      == rField2.GetCJKWeight())
     608                 :          0 :             && (rField1.GetCJKPosture()     == rField2.GetCJKPosture())
     609                 :          0 :             && (rField1.GetCTLFont()        == rField2.GetCTLFont())
     610                 :          0 :             && (rField1.GetCTLHeight()      == rField2.GetCTLHeight())
     611                 :          0 :             && (rField1.GetCTLWeight()      == rField2.GetCTLWeight())
     612                 :          0 :             && (rField1.GetCTLPosture()     == rField2.GetCTLPosture())
     613                 :          0 :             && (rField1.GetUnderline()      == rField2.GetUnderline())
     614                 :          0 :             && (rField1.GetOverline()       == rField2.GetOverline())
     615                 :          0 :             && (rField1.GetCrossedOut()     == rField2.GetCrossedOut())
     616                 :          0 :             && (rField1.GetContour()        == rField2.GetContour())
     617                 :          0 :             && (rField1.GetShadowed()       == rField2.GetShadowed())
     618   [ #  #  #  #  :          0 :             && (rField1.GetColor()          == rField2.GetColor());
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
           #  # ][ #  # ]
     619                 :            :     }
     620         [ #  # ]:          0 :     if( bIncludeJustify )
     621                 :            :     {
     622                 :            :         bEqual = bEqual
     623                 :          0 :             && (rField1.GetHorJustify()     == rField2.GetHorJustify())
     624                 :          0 :             && (rField1.GetVerJustify()     == rField2.GetVerJustify())
     625                 :          0 :             && (rField1.GetStacked()        == rField2.GetStacked())
     626                 :          0 :             && (rField1.GetLinebreak()      == rField2.GetLinebreak())
     627                 :          0 :             && (rField1.GetMargin()         == rField2.GetMargin())
     628                 :          0 :             && (rField1.GetRotateAngle()    == rField2.GetRotateAngle())
     629   [ #  #  #  #  :          0 :             && (rField1.GetRotateMode()     == rField2.GetRotateMode());
          #  #  #  #  #  
             #  #  #  #  
              # ][ #  # ]
     630                 :            :     }
     631         [ #  # ]:          0 :     if( bIncludeFrame )
     632                 :            :     {
     633                 :            :         bEqual = bEqual
     634                 :          0 :             && (rField1.GetBox()            == rField2.GetBox())
     635                 :          0 :             && (rField1.GetTLBR()           == rField2.GetTLBR())
     636   [ #  #  #  #  :          0 :             && (rField1.GetBLTR()           == rField2.GetBLTR());
           #  # ][ #  # ]
     637                 :            :     }
     638         [ #  # ]:          0 :     if( bIncludeBackground )
     639                 :            :     {
     640                 :            :         bEqual = bEqual
     641 [ #  # ][ #  # ]:          0 :             && (rField1.GetBackground()     == rField2.GetBackground());
     642                 :            :     }
     643                 :          0 :     return bEqual;
     644                 :            : }
     645                 :            : 
     646                 :          0 : void ScAutoFormatData::FillToItemSet( sal_uInt16 nIndex, SfxItemSet& rItemSet, ScDocument& rDoc ) const
     647                 :            : {
     648                 :          0 :     const ScAutoFormatDataField& rField = GetField( nIndex );
     649                 :            : 
     650         [ #  # ]:          0 :     if( bIncludeValueFormat )
     651                 :            :     {
     652                 :          0 :         ScNumFormatAbbrev& rNumFormat = (ScNumFormatAbbrev&)rField.GetNumFormat();
     653         [ #  # ]:          0 :         SfxUInt32Item aValueFormat( ATTR_VALUE_FORMAT, 0 );
     654 [ #  # ][ #  # ]:          0 :         aValueFormat.SetValue( rNumFormat.GetFormatIndex( *rDoc.GetFormatTable() ) );
     655         [ #  # ]:          0 :         rItemSet.Put( aValueFormat );
     656 [ #  # ][ #  # ]:          0 :         rItemSet.Put( SvxLanguageItem( rNumFormat.GetLanguage(), ATTR_LANGUAGE_FORMAT ) );
         [ #  # ][ #  # ]
     657                 :            :     }
     658         [ #  # ]:          0 :     if( bIncludeFont )
     659                 :            :     {
     660                 :          0 :         rItemSet.Put( rField.GetFont() );
     661                 :          0 :         rItemSet.Put( rField.GetHeight() );
     662                 :          0 :         rItemSet.Put( rField.GetWeight() );
     663                 :          0 :         rItemSet.Put( rField.GetPosture() );
     664                 :            :         // do not insert empty CJK font
     665                 :          0 :         const SvxFontItem& rCJKFont = rField.GetCJKFont();
     666         [ #  # ]:          0 :         if( rCJKFont.GetStyleName().Len() )
     667                 :            :         {
     668                 :          0 :             rItemSet.Put( rCJKFont );
     669                 :          0 :             rItemSet.Put( rField.GetCJKHeight() );
     670                 :          0 :             rItemSet.Put( rField.GetCJKWeight() );
     671                 :          0 :             rItemSet.Put( rField.GetCJKPosture() );
     672                 :            :         }
     673                 :            :         else
     674                 :            :         {
     675                 :          0 :             rItemSet.Put( rField.GetHeight(), ATTR_CJK_FONT_HEIGHT );
     676                 :          0 :             rItemSet.Put( rField.GetWeight(), ATTR_CJK_FONT_WEIGHT );
     677                 :          0 :             rItemSet.Put( rField.GetPosture(), ATTR_CJK_FONT_POSTURE );
     678                 :            :         }
     679                 :            :         // do not insert empty CTL font
     680                 :          0 :         const SvxFontItem& rCTLFont = rField.GetCTLFont();
     681         [ #  # ]:          0 :         if( rCTLFont.GetStyleName().Len() )
     682                 :            :         {
     683                 :          0 :             rItemSet.Put( rCTLFont );
     684                 :          0 :             rItemSet.Put( rField.GetCTLHeight() );
     685                 :          0 :             rItemSet.Put( rField.GetCTLWeight() );
     686                 :          0 :             rItemSet.Put( rField.GetCTLPosture() );
     687                 :            :         }
     688                 :            :         else
     689                 :            :         {
     690                 :          0 :             rItemSet.Put( rField.GetHeight(), ATTR_CTL_FONT_HEIGHT );
     691                 :          0 :             rItemSet.Put( rField.GetWeight(), ATTR_CTL_FONT_WEIGHT );
     692                 :          0 :             rItemSet.Put( rField.GetPosture(), ATTR_CTL_FONT_POSTURE );
     693                 :            :         }
     694                 :          0 :         rItemSet.Put( rField.GetUnderline() );
     695                 :          0 :         rItemSet.Put( rField.GetOverline() );
     696                 :          0 :         rItemSet.Put( rField.GetCrossedOut() );
     697                 :          0 :         rItemSet.Put( rField.GetContour() );
     698                 :          0 :         rItemSet.Put( rField.GetShadowed() );
     699                 :          0 :         rItemSet.Put( rField.GetColor() );
     700                 :            :     }
     701         [ #  # ]:          0 :     if( bIncludeJustify )
     702                 :            :     {
     703                 :          0 :         rItemSet.Put( rField.GetHorJustify() );
     704                 :          0 :         rItemSet.Put( rField.GetVerJustify() );
     705                 :          0 :         rItemSet.Put( rField.GetStacked() );
     706                 :          0 :         rItemSet.Put( rField.GetLinebreak() );
     707                 :          0 :         rItemSet.Put( rField.GetMargin() );
     708                 :          0 :         rItemSet.Put( rField.GetRotateAngle() );
     709                 :          0 :         rItemSet.Put( rField.GetRotateMode() );
     710                 :            :     }
     711         [ #  # ]:          0 :     if( bIncludeFrame )
     712                 :            :     {
     713                 :          0 :         rItemSet.Put( rField.GetBox() );
     714                 :          0 :         rItemSet.Put( rField.GetTLBR() );
     715                 :          0 :         rItemSet.Put( rField.GetBLTR() );
     716                 :            :     }
     717         [ #  # ]:          0 :     if( bIncludeBackground )
     718                 :          0 :         rItemSet.Put( rField.GetBackground() );
     719                 :          0 : }
     720                 :            : 
     721                 :          0 : void ScAutoFormatData::GetFromItemSet( sal_uInt16 nIndex, const SfxItemSet& rItemSet, const ScNumFormatAbbrev& rNumFormat )
     722                 :            : {
     723                 :          0 :     ScAutoFormatDataField& rField = GetField( nIndex );
     724                 :            : 
     725                 :          0 :     rField.SetNumFormat     ( rNumFormat);
     726                 :          0 :     rField.SetFont          ( (const SvxFontItem&)          rItemSet.Get( ATTR_FONT ) );
     727                 :          0 :     rField.SetHeight        ( (const SvxFontHeightItem&)    rItemSet.Get( ATTR_FONT_HEIGHT ) );
     728                 :          0 :     rField.SetWeight        ( (const SvxWeightItem&)        rItemSet.Get( ATTR_FONT_WEIGHT ) );
     729                 :          0 :     rField.SetPosture       ( (const SvxPostureItem&)       rItemSet.Get( ATTR_FONT_POSTURE ) );
     730                 :          0 :     rField.SetCJKFont       ( (const SvxFontItem&)          rItemSet.Get( ATTR_CJK_FONT ) );
     731                 :          0 :     rField.SetCJKHeight     ( (const SvxFontHeightItem&)    rItemSet.Get( ATTR_CJK_FONT_HEIGHT ) );
     732                 :          0 :     rField.SetCJKWeight     ( (const SvxWeightItem&)        rItemSet.Get( ATTR_CJK_FONT_WEIGHT ) );
     733                 :          0 :     rField.SetCJKPosture    ( (const SvxPostureItem&)       rItemSet.Get( ATTR_CJK_FONT_POSTURE ) );
     734                 :          0 :     rField.SetCTLFont       ( (const SvxFontItem&)          rItemSet.Get( ATTR_CTL_FONT ) );
     735                 :          0 :     rField.SetCTLHeight     ( (const SvxFontHeightItem&)    rItemSet.Get( ATTR_CTL_FONT_HEIGHT ) );
     736                 :          0 :     rField.SetCTLWeight     ( (const SvxWeightItem&)        rItemSet.Get( ATTR_CTL_FONT_WEIGHT ) );
     737                 :          0 :     rField.SetCTLPosture    ( (const SvxPostureItem&)       rItemSet.Get( ATTR_CTL_FONT_POSTURE ) );
     738                 :          0 :     rField.SetUnderline     ( (const SvxUnderlineItem&)     rItemSet.Get( ATTR_FONT_UNDERLINE ) );
     739                 :          0 :     rField.SetOverline      ( (const SvxOverlineItem&)      rItemSet.Get( ATTR_FONT_OVERLINE ) );
     740                 :          0 :     rField.SetCrossedOut    ( (const SvxCrossedOutItem&)    rItemSet.Get( ATTR_FONT_CROSSEDOUT ) );
     741                 :          0 :     rField.SetContour       ( (const SvxContourItem&)       rItemSet.Get( ATTR_FONT_CONTOUR ) );
     742                 :          0 :     rField.SetShadowed      ( (const SvxShadowedItem&)      rItemSet.Get( ATTR_FONT_SHADOWED ) );
     743                 :          0 :     rField.SetColor         ( (const SvxColorItem&)         rItemSet.Get( ATTR_FONT_COLOR ) );
     744                 :          0 :     rField.SetTLBR          ( (const SvxLineItem&)          rItemSet.Get( ATTR_BORDER_TLBR ) );
     745                 :          0 :     rField.SetBLTR          ( (const SvxLineItem&)          rItemSet.Get( ATTR_BORDER_BLTR ) );
     746                 :          0 :     rField.SetHorJustify    ( (const SvxHorJustifyItem&)    rItemSet.Get( ATTR_HOR_JUSTIFY ) );
     747                 :          0 :     rField.SetVerJustify    ( (const SvxVerJustifyItem&)    rItemSet.Get( ATTR_VER_JUSTIFY ) );
     748                 :          0 :     rField.SetStacked       ( (const SfxBoolItem&)          rItemSet.Get( ATTR_STACKED ) );
     749                 :          0 :     rField.SetLinebreak     ( (const SfxBoolItem&)          rItemSet.Get( ATTR_LINEBREAK ) );
     750                 :          0 :     rField.SetMargin        ( (const SvxMarginItem&)        rItemSet.Get( ATTR_MARGIN ) );
     751                 :          0 :     rField.SetBackground    ( (const SvxBrushItem&)         rItemSet.Get( ATTR_BACKGROUND ) );
     752                 :          0 :     rField.SetRotateAngle   ( (const SfxInt32Item&)         rItemSet.Get( ATTR_ROTATE_VALUE ) );
     753                 :          0 :     rField.SetRotateMode    ( (const SvxRotateModeItem&)    rItemSet.Get( ATTR_ROTATE_MODE ) );
     754                 :          0 : }
     755                 :            : 
     756                 :         16 : bool ScAutoFormatData::Load( SvStream& rStream, const ScAfVersions& rVersions )
     757                 :            : {
     758                 :         16 :     sal_Bool    bRet = true;
     759                 :         16 :     sal_uInt16  nVer = 0;
     760         [ +  - ]:         16 :     rStream >> nVer;
     761                 :         16 :     bRet = 0 == rStream.GetError();
     762 [ +  - ][ +  - ]:         16 :     if( bRet && (nVer == AUTOFORMAT_DATA_ID_X ||
         [ +  - ][ +  - ]
     763                 :            :             (AUTOFORMAT_DATA_ID_504 <= nVer && nVer <= AUTOFORMAT_DATA_ID)) )
     764                 :            :     {
     765                 :            :         // --- from 680/dr25 on: store strings as UTF-8
     766         [ +  - ]:         16 :         if (nVer >= AUTOFORMAT_ID_680DR25)
     767                 :            :         {
     768                 :            :             aName = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rStream,
     769         [ +  - ]:         16 :                 RTL_TEXTENCODING_UTF8);
     770                 :            :         }
     771                 :            :         else
     772         [ #  # ]:          0 :             aName = rStream.ReadUniOrByteString( rStream.GetStreamCharSet() );
     773                 :            : 
     774         [ +  - ]:         16 :         if( AUTOFORMAT_DATA_ID_552 <= nVer )
     775                 :            :         {
     776         [ +  - ]:         16 :             rStream >> nStrResId;
     777                 :         16 :             sal_uInt16 nId = RID_SVXSTR_TBLAFMT_BEGIN + nStrResId;
     778 [ +  - ][ +  - ]:         16 :             if( RID_SVXSTR_TBLAFMT_BEGIN <= nId &&
     779                 :            :                 nId < RID_SVXSTR_TBLAFMT_END )
     780                 :            :             {
     781 [ +  - ][ +  - ]:         16 :                 aName = SVX_RESSTR( nId );
     782                 :            :             }
     783                 :            :             else
     784                 :         16 :                 nStrResId = USHRT_MAX;
     785                 :            :         }
     786                 :            : 
     787                 :            :         sal_Bool b;
     788         [ +  - ]:         16 :         rStream >> b; bIncludeFont = b;
     789         [ +  - ]:         16 :         rStream >> b; bIncludeJustify = b;
     790         [ +  - ]:         16 :         rStream >> b; bIncludeFrame = b;
     791         [ +  - ]:         16 :         rStream >> b; bIncludeBackground = b;
     792         [ +  - ]:         16 :         rStream >> b; bIncludeValueFormat = b;
     793         [ +  - ]:         16 :         rStream >> b; bIncludeWidthHeight = b;
     794                 :            : 
     795         [ -  + ]:         16 :         if (nVer >= AUTOFORMAT_DATA_ID_31005)
     796         [ #  # ]:          0 :             rStream >> m_swFields;
     797                 :            : 
     798                 :         16 :         bRet = 0 == rStream.GetError();
     799 [ +  - ][ +  + ]:        272 :         for( sal_uInt16 i = 0; bRet && i < 16; ++i )
                 [ +  + ]
     800         [ +  - ]:        272 :             bRet = GetField( i ).Load( rStream, rVersions, nVer );
     801                 :            :     }
     802                 :            :     else
     803                 :          0 :         bRet = false;
     804                 :         16 :     return bRet;
     805                 :            : }
     806                 :            : 
     807                 :         33 : bool ScAutoFormatData::Save(SvStream& rStream, sal_uInt16 fileVersion)
     808                 :            : {
     809                 :         33 :     sal_uInt16 nVal = AUTOFORMAT_DATA_ID;
     810                 :            :     sal_Bool b;
     811                 :         33 :     rStream << nVal;
     812                 :            :     // --- from 680/dr25 on: store strings as UTF-8
     813                 :         33 :     write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rStream, aName, RTL_TEXTENCODING_UTF8);
     814                 :            : 
     815                 :         33 :     rStream << nStrResId;
     816                 :         33 :     rStream << ( b = bIncludeFont );
     817                 :         33 :     rStream << ( b = bIncludeJustify );
     818                 :         33 :     rStream << ( b = bIncludeFrame );
     819                 :         33 :     rStream << ( b = bIncludeBackground );
     820                 :         33 :     rStream << ( b = bIncludeValueFormat );
     821                 :         33 :     rStream << ( b = bIncludeWidthHeight );
     822                 :            : 
     823         [ +  - ]:         33 :     if (fileVersion >= SOFFICE_FILEFORMAT_50)
     824                 :         33 :         rStream << m_swFields;
     825                 :            : 
     826                 :         33 :     sal_Bool bRet = 0 == rStream.GetError();
     827 [ +  - ][ +  + ]:        561 :     for (sal_uInt16 i = 0; bRet && (i < 16); i++)
                 [ +  + ]
     828                 :        528 :         bRet = GetField( i ).Save( rStream, fileVersion );
     829                 :            : 
     830                 :         33 :     return bRet;
     831                 :            : }
     832                 :            : 
     833                 :            : //---------------------------------------------------------------------------------------
     834                 :            : //---------------------------------------------------------------------------------------
     835                 :            : 
     836                 :          1 : ScAutoFormat::ScAutoFormat() :
     837         [ +  - ]:          1 :     mbSaveLater(false)
     838                 :            : {
     839                 :            :     //  create default autoformat
     840 [ +  - ][ +  - ]:          1 :     ScAutoFormatData* pData = new ScAutoFormatData;
     841 [ +  - ][ +  - ]:          1 :     String aName(ScGlobal::GetRscString(STR_STYLENAME_STANDARD));
     842         [ +  - ]:          1 :     pData->SetName(aName);
     843                 :            : 
     844                 :            :     //  default font, default height
     845                 :            :     Font aStdFont = OutputDevice::GetDefaultFont(
     846         [ +  - ]:          1 :         DEFAULTFONT_LATIN_SPREADSHEET, LANGUAGE_ENGLISH_US, DEFAULTFONT_FLAGS_ONLYONE );
     847                 :            :     SvxFontItem aFontItem(
     848 [ +  - ][ +  - ]:          1 :         aStdFont.GetFamily(), aStdFont.GetName(), aStdFont.GetStyleName(),
     849 [ +  - ][ +  - ]:          2 :         aStdFont.GetPitch(), aStdFont.GetCharSet(), ATTR_FONT );
         [ +  - ][ +  - ]
     850                 :            : 
     851                 :            :     aStdFont = OutputDevice::GetDefaultFont(
     852 [ +  - ][ +  - ]:          1 :         DEFAULTFONT_CJK_SPREADSHEET, LANGUAGE_ENGLISH_US, DEFAULTFONT_FLAGS_ONLYONE );
                 [ +  - ]
     853                 :            :     SvxFontItem aCJKFontItem(
     854 [ +  - ][ +  - ]:          1 :         aStdFont.GetFamily(), aStdFont.GetName(), aStdFont.GetStyleName(),
     855 [ +  - ][ +  - ]:          2 :         aStdFont.GetPitch(), aStdFont.GetCharSet(), ATTR_CJK_FONT );
         [ +  - ][ +  - ]
     856                 :            : 
     857                 :            :     aStdFont = OutputDevice::GetDefaultFont(
     858 [ +  - ][ +  - ]:          1 :         DEFAULTFONT_CTL_SPREADSHEET, LANGUAGE_ENGLISH_US, DEFAULTFONT_FLAGS_ONLYONE );
                 [ +  - ]
     859                 :            :     SvxFontItem aCTLFontItem(
     860 [ +  - ][ +  - ]:          1 :         aStdFont.GetFamily(), aStdFont.GetName(), aStdFont.GetStyleName(),
     861 [ +  - ][ +  - ]:          2 :         aStdFont.GetPitch(), aStdFont.GetCharSet(), ATTR_CTL_FONT );
         [ +  - ][ +  - ]
     862                 :            : 
     863         [ +  - ]:          1 :     SvxFontHeightItem aHeight( 200, 100, ATTR_FONT_HEIGHT );      // 10 pt;
     864                 :            : 
     865                 :            :     //  black thin border
     866                 :          1 :     Color aBlack( COL_BLACK );
     867         [ +  - ]:          1 :     ::editeng::SvxBorderLine aLine( &aBlack, DEF_LINE_WIDTH_0 );
     868         [ +  - ]:          1 :     SvxBoxItem aBox( ATTR_BORDER );
     869         [ +  - ]:          1 :     aBox.SetLine(&aLine, BOX_LINE_LEFT);
     870         [ +  - ]:          1 :     aBox.SetLine(&aLine, BOX_LINE_TOP);
     871         [ +  - ]:          1 :     aBox.SetLine(&aLine, BOX_LINE_RIGHT);
     872         [ +  - ]:          1 :     aBox.SetLine(&aLine, BOX_LINE_BOTTOM);
     873                 :            : 
     874                 :          1 :     Color aWhite(COL_WHITE);
     875                 :          1 :     Color aBlue(COL_BLUE);
     876         [ +  - ]:          1 :     SvxColorItem aWhiteText( aWhite, ATTR_FONT_COLOR );
     877         [ +  - ]:          1 :     SvxColorItem aBlackText( aBlack, ATTR_FONT_COLOR );
     878         [ +  - ]:          1 :     SvxBrushItem aBlueBack( aBlue, ATTR_BACKGROUND );
     879         [ +  - ]:          1 :     SvxBrushItem aWhiteBack( aWhite, ATTR_BACKGROUND );
     880         [ +  - ]:          1 :     SvxBrushItem aGray70Back( Color(0x4d, 0x4d, 0x4d), ATTR_BACKGROUND );
     881         [ +  - ]:          1 :     SvxBrushItem aGray20Back( Color(0xcc, 0xcc, 0xcc), ATTR_BACKGROUND );
     882                 :            : 
     883         [ +  + ]:         17 :     for (sal_uInt16 i=0; i<16; i++)
     884                 :            :     {
     885         [ +  - ]:         16 :         pData->PutItem( i, aBox );
     886         [ +  - ]:         16 :         pData->PutItem( i, aFontItem );
     887         [ +  - ]:         16 :         pData->PutItem( i, aCJKFontItem );
     888         [ +  - ]:         16 :         pData->PutItem( i, aCTLFontItem );
     889                 :         16 :         aHeight.SetWhich( ATTR_FONT_HEIGHT );
     890         [ +  - ]:         16 :         pData->PutItem( i, aHeight );
     891                 :         16 :         aHeight.SetWhich( ATTR_CJK_FONT_HEIGHT );
     892         [ +  - ]:         16 :         pData->PutItem( i, aHeight );
     893                 :         16 :         aHeight.SetWhich( ATTR_CTL_FONT_HEIGHT );
     894         [ +  - ]:         16 :         pData->PutItem( i, aHeight );
     895         [ +  + ]:         16 :         if (i<4)                                    // top: white on blue
     896                 :            :         {
     897         [ +  - ]:          4 :             pData->PutItem( i, aWhiteText );
     898         [ +  - ]:          4 :             pData->PutItem( i, aBlueBack );
     899                 :            :         }
     900         [ +  + ]:         12 :         else if ( i%4 == 0 )                        // left: white on gray70
     901                 :            :         {
     902         [ +  - ]:          3 :             pData->PutItem( i, aWhiteText );
     903         [ +  - ]:          3 :             pData->PutItem( i, aGray70Back );
     904                 :            :         }
     905 [ +  + ][ +  + ]:          9 :         else if ( i%4 == 3 || i >= 12 )             // right and bottom: black on gray20
     906                 :            :         {
     907         [ +  - ]:          5 :             pData->PutItem( i, aBlackText );
     908         [ +  - ]:          5 :             pData->PutItem( i, aGray20Back );
     909                 :            :         }
     910                 :            :         else                                        // center: black on white
     911                 :            :         {
     912         [ +  - ]:          4 :             pData->PutItem( i, aBlackText );
     913         [ +  - ]:          4 :             pData->PutItem( i, aWhiteBack );
     914                 :            :         }
     915                 :            :     }
     916                 :            : 
     917 [ +  - ][ +  - ]:          1 :     insert(pData);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     918                 :          1 : }
     919                 :            : 
     920                 :          0 : ScAutoFormat::ScAutoFormat(const ScAutoFormat& r) :
     921                 :            :     maData(r.maData),
     922         [ #  # ]:          0 :     mbSaveLater(false) {}
     923                 :            : 
     924         [ +  - ]:          1 : ScAutoFormat::~ScAutoFormat()
     925                 :            : {
     926                 :            :     //  Bei Aenderungen per StarOne wird nicht sofort gespeichert, sondern zuerst nur
     927                 :            :     //  das SaveLater Flag gesetzt. Wenn das Flag noch gesetzt ist, jetzt speichern.
     928                 :            : 
     929         [ -  + ]:          1 :     if (mbSaveLater)
     930         [ #  # ]:          0 :         Save();
     931                 :          1 : }
     932                 :            : 
     933                 :        106 : void ScAutoFormat::SetSaveLater( bool bSet )
     934                 :            : {
     935                 :        106 :     mbSaveLater = bSet;
     936                 :        106 : }
     937                 :            : 
     938                 :          0 : const ScAutoFormatData* ScAutoFormat::findByIndex(size_t nIndex) const
     939                 :            : {
     940         [ #  # ]:          0 :     if (nIndex >= maData.size())
     941                 :          0 :         return NULL;
     942                 :            : 
     943         [ #  # ]:          0 :     MapType::const_iterator it = maData.begin();
     944         [ #  # ]:          0 :     std::advance(it, nIndex);
     945         [ #  # ]:          0 :     return it->second;
     946                 :            : }
     947                 :            : 
     948                 :        368 : ScAutoFormatData* ScAutoFormat::findByIndex(size_t nIndex)
     949                 :            : {
     950         [ -  + ]:        368 :     if (nIndex >= maData.size())
     951                 :          0 :         return NULL;
     952                 :            : 
     953         [ +  - ]:        368 :     MapType::iterator it = maData.begin();
     954         [ +  - ]:        368 :     std::advance(it, nIndex);
     955         [ +  - ]:        368 :     return it->second;
     956                 :            : }
     957                 :            : 
     958                 :          0 : ScAutoFormat::const_iterator ScAutoFormat::find(const ScAutoFormatData* pData) const
     959                 :            : {
     960 [ #  # ][ #  # ]:          0 :     MapType::const_iterator it = maData.begin(), itEnd = maData.end();
     961 [ #  # ][ #  # ]:          0 :     for (; it != itEnd; ++it)
                 [ #  # ]
     962                 :            :     {
     963 [ #  # ][ #  # ]:          0 :         if (it->second == pData)
     964                 :          0 :             return it;
     965                 :            :     }
     966                 :          0 :     return itEnd;
     967                 :            : }
     968                 :            : 
     969                 :          2 : ScAutoFormat::iterator ScAutoFormat::find(const ScAutoFormatData* pData)
     970                 :            : {
     971 [ +  - ][ +  - ]:          2 :     MapType::iterator it = maData.begin(), itEnd = maData.end();
     972 [ +  - ][ +  - ]:         34 :     for (; it != itEnd; ++it)
                 [ +  - ]
     973                 :            :     {
     974 [ +  - ][ +  + ]:         34 :         if (it->second == pData)
     975                 :          2 :             return it;
     976                 :            :     }
     977                 :          2 :     return itEnd;
     978                 :            : }
     979                 :            : 
     980                 :          0 : ScAutoFormat::const_iterator ScAutoFormat::find(const rtl::OUString& rName) const
     981                 :            : {
     982                 :          0 :     return maData.find(rName);
     983                 :            : }
     984                 :            : 
     985                 :          2 : ScAutoFormat::iterator ScAutoFormat::find(const rtl::OUString& rName)
     986                 :            : {
     987                 :          2 :     return maData.find(rName);
     988                 :            : }
     989                 :            : 
     990                 :         20 : bool ScAutoFormat::insert(ScAutoFormatData* pNew)
     991                 :            : {
     992                 :         20 :     rtl::OUString aName = pNew->GetName();
     993         [ +  - ]:         20 :     return maData.insert(aName, pNew).second;
     994                 :            : }
     995                 :            : 
     996                 :          3 : void ScAutoFormat::erase(const iterator& it)
     997                 :            : {
     998                 :          3 :     maData.erase(it);
     999                 :          3 : }
    1000                 :            : 
    1001                 :        422 : size_t ScAutoFormat::size() const
    1002                 :            : {
    1003                 :        422 :     return maData.size();
    1004                 :            : }
    1005                 :            : 
    1006                 :         11 : ScAutoFormat::const_iterator ScAutoFormat::begin() const
    1007                 :            : {
    1008                 :         11 :     return maData.begin();
    1009                 :            : }
    1010                 :            : 
    1011                 :         11 : ScAutoFormat::const_iterator ScAutoFormat::end() const
    1012                 :            : {
    1013                 :         11 :     return maData.end();
    1014                 :            : }
    1015                 :            : 
    1016                 :          8 : ScAutoFormat::iterator ScAutoFormat::begin()
    1017                 :            : {
    1018                 :          8 :     return maData.begin();
    1019                 :            : }
    1020                 :            : 
    1021                 :          6 : ScAutoFormat::iterator ScAutoFormat::end()
    1022                 :            : {
    1023                 :          6 :     return maData.end();
    1024                 :            : }
    1025                 :            : 
    1026                 :          1 : bool ScAutoFormat::Load()
    1027                 :            : {
    1028                 :          1 :     bool bRet = true;
    1029                 :            : 
    1030         [ +  - ]:          1 :     INetURLObject aURL;
    1031         [ +  - ]:          1 :     SvtPathOptions aPathOpt;
    1032 [ +  - ][ +  - ]:          1 :     aURL.SetSmartURL( aPathOpt.GetUserConfigPath() );
                 [ +  - ]
    1033         [ +  - ]:          1 :     aURL.setFinalSlash();
    1034 [ +  - ][ +  - ]:          1 :     aURL.Append( String( RTL_CONSTASCII_USTRINGPARAM( sAutoTblFmtName ) ) );
         [ +  - ][ +  - ]
    1035                 :            : 
    1036 [ +  - ][ +  - ]:          1 :     SfxMedium aMedium( aURL.GetMainURL(INetURLObject::NO_DECODE), STREAM_READ );
         [ +  - ][ +  - ]
    1037         [ +  - ]:          1 :     SvStream* pStream = aMedium.GetInStream();
    1038 [ +  - ][ +  - ]:          1 :     bRet = (pStream && pStream->GetError() == 0);
    1039         [ +  - ]:          1 :     if (bRet)
    1040                 :            :     {
    1041                 :          1 :         SvStream& rStream = *pStream;
    1042                 :            :         // Achtung hier muss ein allgemeiner Header gelesen werden
    1043                 :          1 :         sal_uInt16 nVal = 0;
    1044         [ +  - ]:          1 :         rStream >> nVal;
    1045                 :          1 :         bRet = 0 == rStream.GetError();
    1046                 :            : 
    1047         [ +  - ]:          1 :         if (bRet)
    1048                 :            :         {
    1049 [ +  - ][ +  - ]:          1 :             if( nVal == AUTOFORMAT_ID_358 ||
                 [ +  - ]
    1050                 :            :                     (AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
    1051                 :            :             {
    1052                 :          1 :                 sal_uInt16 nFileVers = SOFFICE_FILEFORMAT_40;
    1053                 :            :                 sal_uInt8 nChrSet, nCnt;
    1054                 :          1 :                 long nPos = rStream.Tell();
    1055 [ +  - ][ +  - ]:          1 :                 rStream >> nCnt >> nChrSet;
    1056         [ -  + ]:          1 :                 if( rStream.Tell() != sal_uLong(nPos + nCnt) )
    1057                 :            :                 {
    1058                 :            :                     OSL_FAIL( "Der Header enthaelt mehr/neuere Daten" );
    1059         [ #  # ]:          0 :                     rStream.Seek( nPos + nCnt );
    1060                 :            :                 }
    1061         [ +  - ]:          1 :                 rStream.SetStreamCharSet( GetSOLoadTextEncoding( nChrSet ) );
    1062                 :          1 :                 rStream.SetVersion( nFileVers );
    1063                 :            :             }
    1064                 :            : 
    1065 [ +  - ][ +  - ]:          1 :             if( nVal == AUTOFORMAT_ID_358 || nVal == AUTOFORMAT_ID_X ||
         [ +  - ][ +  - ]
    1066                 :            :                     (AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
    1067                 :            :             {
    1068         [ +  - ]:          1 :                 m_aVersions.Load( rStream, nVal );        // Item-Versionen
    1069                 :            : 
    1070                 :            :                 ScAutoFormatData* pData;
    1071                 :          1 :                 sal_uInt16 nAnz = 0;
    1072         [ +  - ]:          1 :                 rStream >> nAnz;
    1073                 :          1 :                 bRet = (rStream.GetError() == 0);
    1074 [ +  - ][ +  + ]:         17 :                 for (sal_uInt16 i=0; bRet && (i < nAnz); i++)
                 [ +  + ]
    1075                 :            :                 {
    1076 [ +  - ][ +  - ]:         16 :                     pData = new ScAutoFormatData();
    1077         [ +  - ]:         16 :                     bRet = pData->Load(rStream, m_aVersions);
    1078         [ +  - ]:         16 :                     insert(pData);
    1079                 :          1 :                 }
    1080                 :            :             }
    1081                 :            :             else
    1082                 :          1 :                 bRet = false;
    1083                 :            :         }
    1084                 :            :     }
    1085                 :          1 :     mbSaveLater = false;
    1086 [ +  - ][ +  - ]:          1 :     return bRet;
                 [ +  - ]
    1087                 :            : }
    1088                 :            : 
    1089                 :          2 : bool ScAutoFormat::Save()
    1090                 :            : {
    1091                 :          2 :     bool bRet = true;
    1092                 :            : 
    1093         [ +  - ]:          2 :     INetURLObject aURL;
    1094         [ +  - ]:          2 :     SvtPathOptions aPathOpt;
    1095 [ +  - ][ +  - ]:          2 :     aURL.SetSmartURL( aPathOpt.GetUserConfigPath() );
                 [ +  - ]
    1096         [ +  - ]:          2 :     aURL.setFinalSlash();
    1097 [ +  - ][ +  - ]:          2 :     aURL.Append( String( RTL_CONSTASCII_USTRINGPARAM( sAutoTblFmtName ) ) );
         [ +  - ][ +  - ]
    1098                 :            : 
    1099 [ +  - ][ +  - ]:          2 :     SfxMedium aMedium( aURL.GetMainURL(INetURLObject::NO_DECODE), STREAM_WRITE );
         [ +  - ][ +  - ]
    1100         [ +  - ]:          2 :     SvStream* pStream = aMedium.GetOutStream();
    1101 [ +  - ][ +  - ]:          2 :     bRet = (pStream && pStream->GetError() == 0);
    1102         [ +  - ]:          2 :     if (bRet)
    1103                 :            :     {
    1104                 :          2 :         const sal_uInt16 fileVersion = SOFFICE_FILEFORMAT_50;
    1105                 :          2 :         SvStream& rStream = *pStream;
    1106                 :          2 :         rStream.SetVersion( fileVersion );
    1107                 :            : 
    1108                 :            :         // Achtung hier muss ein allgemeiner Header gespeichert werden
    1109                 :          2 :         sal_uInt16 nVal = AUTOFORMAT_ID;
    1110         [ +  - ]:          2 :         rStream << nVal
    1111         [ +  - ]:          2 :                 << (sal_uInt8)2         // Anzahl von Zeichen des Headers incl. diesem
    1112                 :            :                 << (sal_uInt8)::GetSOStoreTextEncoding(
    1113 [ +  - ][ +  - ]:          4 :                     osl_getThreadTextEncoding() );
                 [ +  - ]
    1114         [ +  - ]:          2 :         m_aVersions.Write(rStream, fileVersion);
    1115                 :            : 
    1116                 :          2 :         bRet = (rStream.GetError() == 0);
    1117                 :            :         //-----------------------------------------------------------
    1118         [ +  - ]:          2 :         rStream << (sal_uInt16)(maData.size() - 1);
    1119                 :          2 :         bRet = (rStream.GetError() == 0);
    1120 [ +  - ][ +  - ]:          2 :         MapType::iterator it = maData.begin(), itEnd = maData.end();
    1121 [ +  - ][ +  - ]:         35 :         for (++it; bRet && it != itEnd; ++it) // Skip the first item.
         [ +  - ][ +  - ]
         [ +  + ][ +  + ]
    1122 [ +  - ][ +  - ]:         33 :             bRet = it->second->Save(rStream, fileVersion);
    1123                 :            : 
    1124         [ +  - ]:          2 :         rStream.Flush();
    1125                 :            : 
    1126         [ +  - ]:          2 :         aMedium.Commit();
    1127                 :            :     }
    1128                 :          2 :     mbSaveLater = false;
    1129 [ +  - ][ +  - ]:          2 :     return bRet;
                 [ +  - ]
    1130                 :            : }
    1131                 :            : 
    1132                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10