LCOV - code coverage report
Current view: top level - sc/source/filter/excel - xistyle.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1077 0.0 %
Date: 2014-04-14 Functions: 0 124 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "xistyle.hxx"
      21             : #include <sfx2/printer.hxx>
      22             : #include <sfx2/objsh.hxx>
      23             : #include <svtools/ctrltool.hxx>
      24             : #include <editeng/editobj.hxx>
      25             : #include "scitems.hxx"
      26             : #include <editeng/fontitem.hxx>
      27             : #include <editeng/fhgtitem.hxx>
      28             : #include <editeng/wghtitem.hxx>
      29             : #include <editeng/udlnitem.hxx>
      30             : #include <editeng/postitem.hxx>
      31             : #include <editeng/crossedoutitem.hxx>
      32             : #include <editeng/contouritem.hxx>
      33             : #include <editeng/shdditem.hxx>
      34             : #include <editeng/escapementitem.hxx>
      35             : #include <svx/algitem.hxx>
      36             : #include <editeng/boxitem.hxx>
      37             : #include <editeng/lineitem.hxx>
      38             : #include <svx/rotmodit.hxx>
      39             : #include <editeng/colritem.hxx>
      40             : #include <editeng/brushitem.hxx>
      41             : #include <editeng/frmdiritem.hxx>
      42             : #include <editeng/eeitem.hxx>
      43             : #include <editeng/flstitem.hxx>
      44             : #include <editeng/justifyitem.hxx>
      45             : #include <sal/macros.h>
      46             : #include "document.hxx"
      47             : #include "docpool.hxx"
      48             : #include "attrib.hxx"
      49             : #include "stlpool.hxx"
      50             : #include "stlsheet.hxx"
      51             : #include "formulacell.hxx"
      52             : #include "globstr.hrc"
      53             : #include "attarray.hxx"
      54             : #include "xltracer.hxx"
      55             : #include "xistream.hxx"
      56             : #include "xicontent.hxx"
      57             : 
      58             : #include "root.hxx"
      59             : #include "colrowst.hxx"
      60             : #include "svl/poolcach.hxx"
      61             : 
      62             : #include <list>
      63             : 
      64             : using ::std::list;
      65             : 
      66             : #include <cppuhelper/implbase1.hxx>
      67             : #include <com/sun/star/container/XIndexAccess.hpp>
      68             : #include <com/sun/star/beans/XPropertySet.hpp>
      69             : using namespace ::com::sun::star;
      70             : 
      71             : typedef ::cppu::WeakImplHelper1< container::XIndexAccess > XIndexAccess_BASE;
      72             : typedef ::std::vector< ColorData > ColorDataVec;
      73             : 
      74           0 : class PaletteIndex : public XIndexAccess_BASE
      75             : {
      76             : public:
      77           0 :     PaletteIndex( const ColorDataVec& rColorDataTable ) : maColorData( rColorDataTable ) {}
      78             : 
      79             :     // Methods XIndexAccess
      80           0 :     virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      81             :     {
      82           0 :          return  maColorData.size();
      83             :     }
      84             : 
      85           0 :     virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
      86             :     {
      87             :         //--Index;  // apparently the palette is already 1 based
      88           0 :         return uno::makeAny( sal_Int32( maColorData[ Index ] ) );
      89             :     }
      90             : 
      91             :     // Methods XElementAcess
      92           0 :     virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      93             :     {
      94           0 :         return ::getCppuType( (sal_Int32*)0 );
      95             :     }
      96           0 :     virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      97             :     {
      98           0 :         return (maColorData.size() > 0);
      99             :     }
     100             : 
     101             : private:
     102             :     ColorDataVec        maColorData;
     103             : };
     104             : 
     105             : void
     106           0 : XclImpPalette::ExportPalette()
     107             : {
     108           0 :     if( SfxObjectShell* pDocShell = mrRoot.GetDocShell() )
     109             :     {
     110             :         // copy values in color palette
     111           0 :         sal_Int16 nColors =  maColorTable.size();
     112           0 :         ColorDataVec aColors;
     113           0 :         aColors.resize( nColors );
     114           0 :         for( sal_uInt16 nIndex = 0; nIndex < nColors; ++nIndex )
     115           0 :             aColors[ nIndex ] = GetColorData( nIndex );
     116             : 
     117           0 :         uno::Reference< beans::XPropertySet > xProps( pDocShell->GetModel(), uno::UNO_QUERY );
     118           0 :         if ( xProps.is() )
     119             :         {
     120           0 :             uno::Reference< container::XIndexAccess > xIndex( new PaletteIndex( aColors ) );
     121           0 :             xProps->setPropertyValue( "ColorPalette", uno::makeAny( xIndex ) );
     122           0 :         }
     123             :     }
     124             : 
     125           0 : }
     126             : // PALETTE record - color information =========================================
     127             : 
     128           0 : XclImpPalette::XclImpPalette( const XclImpRoot& rRoot ) :
     129           0 :     XclDefaultPalette( rRoot ), mrRoot( rRoot )
     130             : {
     131           0 : }
     132             : 
     133           0 : void XclImpPalette::Initialize()
     134             : {
     135           0 :     maColorTable.clear();
     136           0 : }
     137             : 
     138           0 : ColorData XclImpPalette::GetColorData( sal_uInt16 nXclIndex ) const
     139             : {
     140           0 :     if( nXclIndex >= EXC_COLOR_USEROFFSET )
     141             :     {
     142           0 :         sal_uInt32 nIx = nXclIndex - EXC_COLOR_USEROFFSET;
     143           0 :         if( nIx < maColorTable.size() )
     144           0 :             return maColorTable[ nIx ];
     145             :     }
     146           0 :     return GetDefColorData( nXclIndex );
     147             : }
     148             : 
     149           0 : void XclImpPalette::ReadPalette( XclImpStream& rStrm )
     150             : {
     151             :     sal_uInt16 nCount;
     152           0 :     rStrm >> nCount;
     153             :     OSL_ENSURE( rStrm.GetRecLeft() == static_cast< sal_Size >( 4 * nCount ),
     154             :         "XclImpPalette::ReadPalette - size mismatch" );
     155             : 
     156           0 :     maColorTable.resize( nCount );
     157           0 :     Color aColor;
     158           0 :     for( sal_uInt16 nIndex = 0; nIndex < nCount; ++nIndex )
     159             :     {
     160           0 :         rStrm >> aColor;
     161           0 :         maColorTable[ nIndex ] = aColor.GetColor();
     162             :     }
     163           0 :     ExportPalette();
     164           0 : }
     165             : 
     166             : // FONT record - font information =============================================
     167             : 
     168           0 : XclImpFont::XclImpFont( const XclImpRoot& rRoot ) :
     169             :     XclImpRoot( rRoot ),
     170             :     mbHasCharSet( false ),
     171             :     mbHasWstrn( true ),
     172             :     mbHasAsian( false ),
     173           0 :     mbHasCmplx( false )
     174             : {
     175           0 :     SetAllUsedFlags( false );
     176           0 : }
     177             : 
     178           0 : XclImpFont::XclImpFont( const XclImpRoot& rRoot, const XclFontData& rFontData ) :
     179           0 :     XclImpRoot( rRoot )
     180             : {
     181           0 :     SetFontData( rFontData, false );
     182           0 : }
     183             : 
     184           0 : void XclImpFont::SetAllUsedFlags( bool bUsed )
     185             : {
     186             :     mbFontNameUsed = mbHeightUsed = mbColorUsed = mbWeightUsed = mbEscapemUsed =
     187           0 :         mbUnderlUsed = mbItalicUsed = mbStrikeUsed = mbOutlineUsed = mbShadowUsed = bUsed;
     188           0 : }
     189             : 
     190           0 : void XclImpFont::SetFontData( const XclFontData& rFontData, bool bHasCharSet )
     191             : {
     192           0 :     maData = rFontData;
     193           0 :     mbHasCharSet = bHasCharSet;
     194           0 :     if( !maData.maStyle.isEmpty() )
     195             :     {
     196           0 :         if( SfxObjectShell* pDocShell = GetDocShell() )
     197             :         {
     198           0 :             if( const SvxFontListItem* pInfoItem = static_cast< const SvxFontListItem* >(
     199           0 :                 pDocShell->GetItem( SID_ATTR_CHAR_FONTLIST ) ) )
     200             :             {
     201           0 :                 if( const FontList* pFontList = pInfoItem->GetFontList() )
     202             :                 {
     203           0 :                     FontInfo aFontInfo( pFontList->Get( maData.maName, maData.maStyle ) );
     204           0 :                     maData.SetScWeight( aFontInfo.GetWeight() );
     205           0 :                     maData.SetScPosture( aFontInfo.GetItalic() );
     206             :                 }
     207             :             }
     208             :         }
     209           0 :         maData.maStyle = "";
     210             :     }
     211           0 :     GuessScriptType();
     212           0 :     SetAllUsedFlags( true );
     213           0 : }
     214             : 
     215           0 : rtl_TextEncoding XclImpFont::GetFontEncoding() const
     216             : {
     217             :     // #i63105# use text encoding from FONT record
     218             :     // #i67768# BIFF2-BIFF4 FONT records do not contain character set
     219           0 :     rtl_TextEncoding eFontEnc = mbHasCharSet ? maData.GetFontEncoding() : GetTextEncoding();
     220           0 :     return (eFontEnc == RTL_TEXTENCODING_DONTKNOW) ? GetTextEncoding() : eFontEnc;
     221             : }
     222             : 
     223           0 : void XclImpFont::ReadFont( XclImpStream& rStrm )
     224             : {
     225           0 :     switch( GetBiff() )
     226             :     {
     227             :         case EXC_BIFF2:
     228           0 :             ReadFontData2( rStrm );
     229           0 :             ReadFontName2( rStrm );
     230           0 :         break;
     231             :         case EXC_BIFF3:
     232             :         case EXC_BIFF4:
     233           0 :             ReadFontData2( rStrm );
     234           0 :             ReadFontColor( rStrm );
     235           0 :             ReadFontName2( rStrm );
     236           0 :         break;
     237             :         case EXC_BIFF5:
     238           0 :             ReadFontData5( rStrm );
     239           0 :             ReadFontName2( rStrm );
     240           0 :         break;
     241             :         case EXC_BIFF8:
     242           0 :             ReadFontData5( rStrm );
     243           0 :             ReadFontName8( rStrm );
     244           0 :         break;
     245             :         default:
     246             :             DBG_ERROR_BIFF();
     247           0 :             return;
     248             :     }
     249           0 :     GuessScriptType();
     250           0 :     SetAllUsedFlags( true );
     251             : }
     252             : 
     253           0 : void XclImpFont::ReadEfont( XclImpStream& rStrm )
     254             : {
     255           0 :     ReadFontColor( rStrm );
     256           0 : }
     257             : 
     258           0 : void XclImpFont::ReadCFFontBlock( XclImpStream& rStrm )
     259             : {
     260             :     OSL_ENSURE_BIFF( GetBiff() == EXC_BIFF8 );
     261           0 :     if( GetBiff() != EXC_BIFF8 )
     262           0 :         return;
     263             : 
     264             :     sal_uInt32 nHeight, nStyle, nColor, nFontFlags1, nFontFlags2, nFontFlags3;
     265             :     sal_uInt16 nWeight, nEscapem;
     266             :     sal_uInt8 nUnderl;
     267             : 
     268           0 :     rStrm.Ignore( 64 );
     269           0 :     rStrm >> nHeight >> nStyle >> nWeight >> nEscapem >> nUnderl;
     270           0 :     rStrm.Ignore( 3 );
     271           0 :     rStrm >> nColor;
     272           0 :     rStrm.Ignore( 4 );
     273           0 :     rStrm >> nFontFlags1 >> nFontFlags2 >> nFontFlags3;
     274           0 :     rStrm.Ignore( 18 );
     275             : 
     276           0 :     if( (mbHeightUsed = (nHeight <= 0x7FFF)) == true )
     277           0 :         maData.mnHeight = static_cast< sal_uInt16 >( nHeight );
     278           0 :     if( (mbWeightUsed = !::get_flag( nFontFlags1, EXC_CF_FONT_STYLE ) && (nWeight < 0x7FFF)) == true )
     279           0 :         maData.mnWeight = static_cast< sal_uInt16 >( nWeight );
     280           0 :     if( (mbItalicUsed = !::get_flag( nFontFlags1, EXC_CF_FONT_STYLE )) == true )
     281           0 :         maData.mbItalic = ::get_flag( nStyle, EXC_CF_FONT_STYLE );
     282           0 :     if( (mbUnderlUsed = !::get_flag( nFontFlags3, EXC_CF_FONT_UNDERL ) && (nUnderl <= 0x7F)) == true )
     283           0 :         maData.mnUnderline = nUnderl;
     284           0 :     if( (mbColorUsed = (nColor <= 0x7FFF)) == true )
     285           0 :         maData.maColor = GetPalette().GetColor( static_cast< sal_uInt16 >( nColor ) );
     286           0 :     if( (mbStrikeUsed = !::get_flag( nFontFlags1, EXC_CF_FONT_STRIKEOUT )) == true )
     287           0 :         maData.mbStrikeout = ::get_flag( nStyle, EXC_CF_FONT_STRIKEOUT );
     288             : }
     289             : 
     290           0 : void XclImpFont::FillToItemSet( SfxItemSet& rItemSet, XclFontItemType eType, bool bSkipPoolDefs ) const
     291             : {
     292             :     // true = edit engine Which-IDs (EE_CHAR_*); false = Calc Which-IDs (ATTR_*)
     293           0 :     bool bEE = eType != EXC_FONTITEM_CELL;
     294             : 
     295             : // item = the item to put into the item set
     296             : // sc_which = the Calc Which-ID of the item
     297             : // ee_which = the edit engine Which-ID of the item
     298             : #define PUTITEM( item, sc_which, ee_which ) \
     299             :     ScfTools::PutItem( rItemSet, item, (bEE ? (ee_which) : (sc_which)), bSkipPoolDefs )
     300             : 
     301             : // Font item
     302             :     // #i36997# do not set default Tahoma font from notes
     303           0 :     bool bDefNoteFont = (eType == EXC_FONTITEM_NOTE) && (maData.maName.equalsIgnoreAsciiCase( "Tahoma" ));
     304           0 :     if( mbFontNameUsed && !bDefNoteFont )
     305             :     {
     306           0 :         rtl_TextEncoding eFontEnc = maData.GetFontEncoding();
     307           0 :         rtl_TextEncoding eTempTextEnc = (bEE && (eFontEnc == GetTextEncoding())) ?
     308           0 :             ScfTools::GetSystemTextEncoding() : eFontEnc;
     309             : 
     310             :         //add corresponding pitch for FontFamily
     311           0 :         FontPitch ePitch = PITCH_DONTKNOW;
     312           0 :         FontFamily eFtFamily = maData.GetScFamily( GetTextEncoding() );
     313           0 :         switch( eFtFamily ) //refer http://msdn.microsoft.com/en-us/library/aa246306(v=VS.60).aspx
     314             :         {
     315           0 :             case FAMILY_ROMAN:              ePitch = PITCH_VARIABLE;        break;
     316           0 :             case FAMILY_SWISS:              ePitch = PITCH_VARIABLE;        break;
     317           0 :             case FAMILY_MODERN:             ePitch = PITCH_FIXED;           break;
     318           0 :             default:                        break;
     319             :          }
     320           0 :         SvxFontItem aFontItem( eFtFamily , maData.maName, EMPTY_OUSTRING, ePitch, eTempTextEnc, ATTR_FONT );
     321             : 
     322             :         // set only for valid script types
     323           0 :         if( mbHasWstrn )
     324           0 :             PUTITEM( aFontItem, ATTR_FONT,      EE_CHAR_FONTINFO );
     325           0 :         if( mbHasAsian )
     326           0 :             PUTITEM( aFontItem, ATTR_CJK_FONT,  EE_CHAR_FONTINFO_CJK );
     327           0 :         if( mbHasCmplx )
     328           0 :             PUTITEM( aFontItem, ATTR_CTL_FONT,  EE_CHAR_FONTINFO_CTL );
     329             :     }
     330             : 
     331             : // Font height (for all script types)
     332           0 :     if( mbHeightUsed )
     333             :     {
     334           0 :         sal_Int32 nHeight = maData.mnHeight;
     335           0 :         if( bEE && (eType != EXC_FONTITEM_HF) )     // do not convert header/footer height
     336           0 :             nHeight = (nHeight * 127 + 36) / EXC_POINTS_PER_INCH;   // 1 in == 72 pt
     337             : 
     338           0 :         SvxFontHeightItem aHeightItem( nHeight, 100, ATTR_FONT_HEIGHT );
     339           0 :         PUTITEM( aHeightItem,   ATTR_FONT_HEIGHT,       EE_CHAR_FONTHEIGHT );
     340           0 :         PUTITEM( aHeightItem,   ATTR_CJK_FONT_HEIGHT,   EE_CHAR_FONTHEIGHT_CJK );
     341           0 :         PUTITEM( aHeightItem,   ATTR_CTL_FONT_HEIGHT,   EE_CHAR_FONTHEIGHT_CTL );
     342             :     }
     343             : 
     344             : // Font color - pass AUTO_COL to item
     345           0 :     if( mbColorUsed )
     346           0 :         PUTITEM( SvxColorItem( maData.maColor, ATTR_FONT_COLOR  ), ATTR_FONT_COLOR, EE_CHAR_COLOR );
     347             : 
     348             : // Font weight (for all script types)
     349           0 :     if( mbWeightUsed )
     350             :     {
     351           0 :         SvxWeightItem aWeightItem( maData.GetScWeight(), ATTR_FONT_WEIGHT );
     352           0 :         PUTITEM( aWeightItem,   ATTR_FONT_WEIGHT,       EE_CHAR_WEIGHT );
     353           0 :         PUTITEM( aWeightItem,   ATTR_CJK_FONT_WEIGHT,   EE_CHAR_WEIGHT_CJK );
     354           0 :         PUTITEM( aWeightItem,   ATTR_CTL_FONT_WEIGHT,   EE_CHAR_WEIGHT_CTL );
     355             :     }
     356             : 
     357             : // Font underline
     358           0 :     if( mbUnderlUsed )
     359             :     {
     360           0 :         SvxUnderlineItem aUnderlItem( maData.GetScUnderline(), ATTR_FONT_UNDERLINE );
     361           0 :         PUTITEM( aUnderlItem,   ATTR_FONT_UNDERLINE,    EE_CHAR_UNDERLINE );
     362             :     }
     363             : 
     364             : // Font posture (for all script types)
     365           0 :     if( mbItalicUsed )
     366             :     {
     367           0 :         SvxPostureItem aPostItem( maData.GetScPosture(), ATTR_FONT_POSTURE );
     368           0 :         PUTITEM( aPostItem, ATTR_FONT_POSTURE,      EE_CHAR_ITALIC );
     369           0 :         PUTITEM( aPostItem, ATTR_CJK_FONT_POSTURE,  EE_CHAR_ITALIC_CJK );
     370           0 :         PUTITEM( aPostItem, ATTR_CTL_FONT_POSTURE,  EE_CHAR_ITALIC_CTL );
     371             :     }
     372             : 
     373             : // Boolean attributes crossed out, contoured, shadowed
     374           0 :     if( mbStrikeUsed )
     375           0 :         PUTITEM( SvxCrossedOutItem( maData.GetScStrikeout(), ATTR_FONT_CROSSEDOUT ), ATTR_FONT_CROSSEDOUT, EE_CHAR_STRIKEOUT );
     376           0 :     if( mbOutlineUsed )
     377           0 :         PUTITEM( SvxContourItem( maData.mbOutline, ATTR_FONT_CONTOUR ), ATTR_FONT_CONTOUR, EE_CHAR_OUTLINE );
     378           0 :     if( mbShadowUsed )
     379           0 :         PUTITEM( SvxShadowedItem( maData.mbShadow, ATTR_FONT_SHADOWED ), ATTR_FONT_SHADOWED, EE_CHAR_SHADOW );
     380             : 
     381             : // Super-/subscript: only on edit engine objects
     382           0 :     if( mbEscapemUsed && bEE )
     383           0 :         rItemSet.Put( SvxEscapementItem( maData.GetScEscapement(), EE_CHAR_ESCAPEMENT ) );
     384             : 
     385             : #undef PUTITEM
     386           0 : }
     387             : 
     388           0 : void XclImpFont::WriteFontProperties( ScfPropertySet& rPropSet,
     389             :         XclFontPropSetType eType, const Color* pFontColor ) const
     390             : {
     391           0 :     GetFontPropSetHelper().WriteFontProperties(
     392           0 :         rPropSet, eType, maData, mbHasWstrn, mbHasAsian, mbHasCmplx, pFontColor );
     393           0 : }
     394             : 
     395           0 : void XclImpFont::ReadFontData2( XclImpStream& rStrm )
     396             : {
     397             :     sal_uInt16 nFlags;
     398           0 :     rStrm >> maData.mnHeight >> nFlags;
     399             : 
     400           0 :     maData.mnWeight     = ::get_flagvalue( nFlags, EXC_FONTATTR_BOLD, EXC_FONTWGHT_BOLD, EXC_FONTWGHT_NORMAL );
     401           0 :     maData.mnUnderline  = ::get_flagvalue( nFlags, EXC_FONTATTR_UNDERLINE, EXC_FONTUNDERL_SINGLE, EXC_FONTUNDERL_NONE );
     402           0 :     maData.mbItalic     = ::get_flag( nFlags, EXC_FONTATTR_ITALIC );
     403           0 :     maData.mbStrikeout  = ::get_flag( nFlags, EXC_FONTATTR_STRIKEOUT );
     404           0 :     maData.mbOutline    = ::get_flag( nFlags, EXC_FONTATTR_OUTLINE );
     405           0 :     maData.mbShadow     = ::get_flag( nFlags, EXC_FONTATTR_SHADOW );
     406           0 :     mbHasCharSet = false;
     407           0 : }
     408             : 
     409           0 : void XclImpFont::ReadFontData5( XclImpStream& rStrm )
     410             : {
     411             :     sal_uInt16 nFlags;
     412             : 
     413           0 :     rStrm >> maData.mnHeight >> nFlags;
     414           0 :     ReadFontColor( rStrm );
     415           0 :     rStrm >> maData.mnWeight >> maData.mnEscapem >> maData.mnUnderline >> maData.mnFamily >> maData.mnCharSet;
     416           0 :     rStrm.Ignore( 1 );
     417             : 
     418           0 :     maData.mbItalic     = ::get_flag( nFlags, EXC_FONTATTR_ITALIC );
     419           0 :     maData.mbStrikeout  = ::get_flag( nFlags, EXC_FONTATTR_STRIKEOUT );
     420           0 :     maData.mbOutline    = ::get_flag( nFlags, EXC_FONTATTR_OUTLINE );
     421           0 :     maData.mbShadow     = ::get_flag( nFlags, EXC_FONTATTR_SHADOW );
     422           0 :     mbHasCharSet = true;
     423           0 : }
     424             : 
     425           0 : void XclImpFont::ReadFontColor( XclImpStream& rStrm )
     426             : {
     427           0 :     maData.maColor = GetPalette().GetColor( rStrm.ReaduInt16() );
     428           0 : }
     429             : 
     430           0 : void XclImpFont::ReadFontName2( XclImpStream& rStrm )
     431             : {
     432           0 :     maData.maName = rStrm.ReadByteString( false );
     433           0 : }
     434             : 
     435           0 : void XclImpFont::ReadFontName8( XclImpStream& rStrm )
     436             : {
     437           0 :     maData.maName = rStrm.ReadUniString( rStrm.ReaduInt8() );
     438           0 : }
     439             : 
     440           0 : void XclImpFont::GuessScriptType()
     441             : {
     442           0 :     mbHasWstrn = true;
     443           0 :     mbHasAsian = mbHasCmplx = false;
     444             : 
     445             :     // find the script types for which the font contains characters
     446           0 :     if( OutputDevice* pPrinter = GetPrinter() )
     447             :     {
     448           0 :         Font aFont( maData.maName, Size( 0, 10 ) );
     449           0 :         FontCharMap aCharMap;
     450             : 
     451           0 :         pPrinter->SetFont( aFont );
     452           0 :         if( pPrinter->GetFontCharMap( aCharMap ) )
     453             :         {
     454             :             // CJK fonts
     455             :             mbHasAsian =
     456           0 :                 aCharMap.HasChar( 0x3041 ) ||   // 3040-309F: Hiragana
     457           0 :                 aCharMap.HasChar( 0x30A1 ) ||   // 30A0-30FF: Katakana
     458           0 :                 aCharMap.HasChar( 0x3111 ) ||   // 3100-312F: Bopomofo
     459           0 :                 aCharMap.HasChar( 0x3131 ) ||   // 3130-318F: Hangul Compatibility Jamo
     460           0 :                 aCharMap.HasChar( 0x3301 ) ||   // 3300-33FF: CJK Compatibility
     461           0 :                 aCharMap.HasChar( 0x3401 ) ||   // 3400-4DBF: CJK Unified Ideographs Extension A
     462           0 :                 aCharMap.HasChar( 0x4E01 ) ||   // 4E00-9FAF: CJK Unified Ideographs
     463           0 :                 aCharMap.HasChar( 0x7E01 ) ||   // 4E00-9FAF: CJK unified ideographs
     464           0 :                 aCharMap.HasChar( 0xA001 ) ||   // A001-A48F: Yi Syllables
     465           0 :                 aCharMap.HasChar( 0xAC01 ) ||   // AC00-D7AF: Hangul Syllables
     466           0 :                 aCharMap.HasChar( 0xCC01 ) ||   // AC00-D7AF: Hangul Syllables
     467           0 :                 aCharMap.HasChar( 0xF901 ) ||   // F900-FAFF: CJK Compatibility Ideographs
     468           0 :                 aCharMap.HasChar( 0xFF71 );     // FF00-FFEF: Halfwidth/Fullwidth Forms
     469             :             // CTL fonts
     470             :             mbHasCmplx =
     471           0 :                 aCharMap.HasChar( 0x05D1 ) ||   // 0590-05FF: Hebrew
     472           0 :                 aCharMap.HasChar( 0x0631 ) ||   // 0600-06FF: Arabic
     473           0 :                 aCharMap.HasChar( 0x0721 ) ||   // 0700-074F: Syriac
     474           0 :                 aCharMap.HasChar( 0x0911 ) ||   // 0900-0DFF: Indic scripts
     475           0 :                 aCharMap.HasChar( 0x0E01 ) ||   // 0E00-0E7F: Thai
     476           0 :                 aCharMap.HasChar( 0xFB21 ) ||   // FB1D-FB4F: Hebrew Presentation Forms
     477           0 :                 aCharMap.HasChar( 0xFB51 ) ||   // FB50-FDFF: Arabic Presentation Forms-A
     478           0 :                 aCharMap.HasChar( 0xFE71 );     // FE70-FEFF: Arabic Presentation Forms-B
     479             :             // Western fonts
     480           0 :             mbHasWstrn = (!mbHasAsian && !mbHasCmplx) || aCharMap.HasChar( 'A' );
     481           0 :         }
     482             :     }
     483           0 : }
     484             : 
     485           0 : XclImpFontBuffer::XclImpFontBuffer( const XclImpRoot& rRoot ) :
     486             :     XclImpRoot( rRoot ),
     487             :     maFont4( rRoot ),
     488           0 :     maCtrlFont( rRoot )
     489             : {
     490           0 :     Initialize();
     491             : 
     492             :     // default font for form controls without own font information
     493           0 :     XclFontData aCtrlFontData;
     494           0 :     switch( GetBiff() )
     495             :     {
     496             :         case EXC_BIFF2:
     497             :         case EXC_BIFF3:
     498             :         case EXC_BIFF4:
     499             :         case EXC_BIFF5:
     500           0 :             aCtrlFontData.maName = "Helv";
     501           0 :             aCtrlFontData.mnHeight = 160;
     502           0 :             aCtrlFontData.mnWeight = EXC_FONTWGHT_BOLD;
     503           0 :         break;
     504             :         case EXC_BIFF8:
     505           0 :             aCtrlFontData.maName = "Tahoma";
     506           0 :             aCtrlFontData.mnHeight = 160;
     507           0 :             aCtrlFontData.mnWeight = EXC_FONTWGHT_NORMAL;
     508           0 :         break;
     509             :         default:
     510             :             DBG_ERROR_BIFF();
     511             :     }
     512           0 :     maCtrlFont.SetFontData( aCtrlFontData, false );
     513           0 : }
     514             : 
     515           0 : void XclImpFontBuffer::Initialize()
     516             : {
     517           0 :     maFontList.clear();
     518             : 
     519             :     // application font for column width calculation, later filled with first font from font list
     520           0 :     XclFontData aAppFontData;
     521           0 :     aAppFontData.maName = "Arial";
     522           0 :     aAppFontData.mnHeight = 200;
     523           0 :     aAppFontData.mnWeight = EXC_FONTWGHT_NORMAL;
     524           0 :     UpdateAppFont( aAppFontData, false );
     525           0 : }
     526             : 
     527           0 : const XclImpFont* XclImpFontBuffer::GetFont( sal_uInt16 nFontIndex ) const
     528             : {
     529             :     /*  Font with index 4 is not stored in an Excel file, but used e.g. by
     530             :         BIFF5 form pushbutton objects. It is the bold default font.
     531             :         This also means that entries above 4 are out by one in the list. */
     532             : 
     533           0 :     if (nFontIndex == 4)
     534           0 :         return &maFont4;
     535             : 
     536           0 :     if (nFontIndex < 4)
     537             :     {
     538             :         // Font ID is zero-based when it's less than 4.
     539           0 :         return nFontIndex >= maFontList.size() ? NULL : &maFontList[nFontIndex];
     540             :     }
     541             : 
     542             :     // Font ID is greater than 4.  It is now 1-based.
     543           0 :     return nFontIndex > maFontList.size() ? NULL : &maFontList[nFontIndex-1];
     544             : }
     545             : 
     546           0 : void XclImpFontBuffer::ReadFont( XclImpStream& rStrm )
     547             : {
     548           0 :     XclImpFont* pFont = new XclImpFont( GetRoot() );
     549           0 :     pFont->ReadFont( rStrm );
     550           0 :     maFontList.push_back( pFont );
     551             : 
     552           0 :     if( maFontList.size() == 1 )
     553             :     {
     554           0 :         UpdateAppFont( pFont->GetFontData(), pFont->HasCharSet() );
     555             :         // #i71033# set text encoding from application font, if CODEPAGE is missing
     556           0 :         SetAppFontEncoding( pFont->GetFontEncoding() );
     557             :     }
     558           0 : }
     559             : 
     560           0 : void XclImpFontBuffer::ReadEfont( XclImpStream& rStrm )
     561             : {
     562           0 :     if( !maFontList.empty() )
     563           0 :         maFontList.back().ReadEfont( rStrm );
     564           0 : }
     565             : 
     566           0 : void XclImpFontBuffer::FillToItemSet(
     567             :         SfxItemSet& rItemSet, XclFontItemType eType,
     568             :         sal_uInt16 nFontIdx, bool bSkipPoolDefs ) const
     569             : {
     570           0 :     if( const XclImpFont* pFont = GetFont( nFontIdx ) )
     571           0 :         pFont->FillToItemSet( rItemSet, eType, bSkipPoolDefs );
     572           0 : }
     573             : 
     574           0 : void XclImpFontBuffer::WriteFontProperties( ScfPropertySet& rPropSet,
     575             :         XclFontPropSetType eType, sal_uInt16 nFontIdx, const Color* pFontColor ) const
     576             : {
     577           0 :     if( const XclImpFont* pFont = GetFont( nFontIdx ) )
     578           0 :         pFont->WriteFontProperties( rPropSet, eType, pFontColor );
     579           0 : }
     580             : 
     581           0 : void XclImpFontBuffer::WriteDefaultCtrlFontProperties( ScfPropertySet& rPropSet ) const
     582             : {
     583           0 :     maCtrlFont.WriteFontProperties( rPropSet, EXC_FONTPROPSET_CONTROL );
     584           0 : }
     585             : 
     586           0 : void XclImpFontBuffer::UpdateAppFont( const XclFontData& rFontData, bool bHasCharSet )
     587             : {
     588           0 :     maAppFont = rFontData;
     589             :     // #i3006# Calculate the width of '0' from first font and current printer.
     590           0 :     SetCharWidth( maAppFont );
     591             : 
     592             :     // font 4 is bold font 0
     593           0 :     XclFontData aFont4Data( maAppFont );
     594           0 :     aFont4Data.mnWeight = EXC_FONTWGHT_BOLD;
     595           0 :     maFont4.SetFontData( aFont4Data, bHasCharSet );
     596           0 : }
     597             : 
     598             : // FORMAT record - number formats =============================================
     599             : 
     600           0 : XclImpNumFmtBuffer::XclImpNumFmtBuffer( const XclImpRoot& rRoot ) :
     601             :     XclNumFmtBuffer( rRoot ),
     602             :     XclImpRoot( rRoot ),
     603           0 :     mnNextXclIdx( 0 )
     604             : {
     605           0 : }
     606             : 
     607           0 : void XclImpNumFmtBuffer::Initialize()
     608             : {
     609           0 :     maIndexMap.clear();
     610           0 :     mnNextXclIdx = 0;
     611           0 :     InitializeImport();     // base class
     612           0 : }
     613             : 
     614           0 : void XclImpNumFmtBuffer::ReadFormat( XclImpStream& rStrm )
     615             : {
     616           0 :     OUString aFormat;
     617           0 :     switch( GetBiff() )
     618             :     {
     619             :         case EXC_BIFF2:
     620             :         case EXC_BIFF3:
     621           0 :             aFormat = rStrm.ReadByteString( false );
     622           0 :         break;
     623             : 
     624             :         case EXC_BIFF4:
     625           0 :             rStrm.Ignore( 2 );  // in BIFF4 the index field exists, but is undefined
     626           0 :             aFormat = rStrm.ReadByteString( false );
     627           0 :         break;
     628             : 
     629             :         case EXC_BIFF5:
     630           0 :             rStrm >> mnNextXclIdx;
     631           0 :             aFormat = rStrm.ReadByteString( false );
     632           0 :         break;
     633             : 
     634             :         case EXC_BIFF8:
     635           0 :             rStrm >> mnNextXclIdx;
     636           0 :             aFormat = rStrm.ReadUniString();
     637           0 :         break;
     638             : 
     639             :         default:
     640             :             DBG_ERROR_BIFF();
     641           0 :             return;
     642             :     }
     643             : 
     644           0 :     if( mnNextXclIdx < 0xFFFF )
     645             :     {
     646           0 :         InsertFormat( mnNextXclIdx, aFormat );
     647           0 :         ++mnNextXclIdx;
     648           0 :     }
     649             : }
     650             : 
     651           0 : sal_uInt16 XclImpNumFmtBuffer::ReadCFFormat( XclImpStream& rStrm, bool bIFmt )
     652             : {
     653             :     // internal number format ?
     654           0 :     if(bIFmt)
     655             :     {
     656           0 :         rStrm.Ignore(1);
     657             :         sal_uInt8 nIndex;
     658           0 :         rStrm >> nIndex;
     659           0 :         return nIndex;
     660             :     }
     661             :     else
     662             :     {
     663           0 :         OUString aFormat = rStrm.ReadUniString();
     664           0 :         InsertFormat( mnNextXclIdx, aFormat );
     665           0 :         ++mnNextXclIdx;
     666           0 :         return mnNextXclIdx - 1;
     667             :     }
     668             : }
     669             : 
     670           0 : void XclImpNumFmtBuffer::CreateScFormats()
     671             : {
     672             :     OSL_ENSURE( maIndexMap.empty(), "XclImpNumFmtBuffer::CreateScFormats - already created" );
     673             : 
     674           0 :     SvNumberFormatter& rFormatter = GetFormatter();
     675           0 :     for( XclNumFmtMap::const_iterator aIt = GetFormatMap().begin(), aEnd = GetFormatMap().end(); aIt != aEnd; ++aIt )
     676             :     {
     677           0 :         const XclNumFmt& rNumFmt = aIt->second;
     678             : 
     679             :         // insert/convert the Excel number format
     680             :         sal_Int32 nCheckPos;
     681           0 :         short nType = NUMBERFORMAT_DEFINED;
     682             :         sal_uInt32 nKey;
     683           0 :         if( !rNumFmt.maFormat.isEmpty() )
     684             :         {
     685           0 :             OUString aFormat( rNumFmt.maFormat );
     686             :             rFormatter.PutandConvertEntry( aFormat, nCheckPos,
     687           0 :                                            nType, nKey, LANGUAGE_ENGLISH_US, rNumFmt.meLanguage );
     688             :         }
     689             :         else
     690           0 :             nKey = rFormatter.GetFormatIndex( rNumFmt.meOffset, rNumFmt.meLanguage );
     691             : 
     692             :         // insert the resulting format key into the Excel->Calc index map
     693           0 :         maIndexMap[ aIt->first ] = nKey;
     694             :     }
     695           0 : }
     696             : 
     697           0 : sal_uLong XclImpNumFmtBuffer::GetScFormat( sal_uInt16 nXclNumFmt ) const
     698             : {
     699           0 :     XclImpIndexMap::const_iterator aIt = maIndexMap.find( nXclNumFmt );
     700           0 :     return (aIt != maIndexMap.end()) ? aIt->second : NUMBERFORMAT_ENTRY_NOT_FOUND;
     701             : }
     702             : 
     703           0 : void XclImpNumFmtBuffer::FillToItemSet( SfxItemSet& rItemSet, sal_uInt16 nXclNumFmt, bool bSkipPoolDefs ) const
     704             : {
     705           0 :     sal_uLong nScNumFmt = GetScFormat( nXclNumFmt );
     706           0 :     if( nScNumFmt == NUMBERFORMAT_ENTRY_NOT_FOUND )
     707           0 :         nScNumFmt = GetStdScNumFmt();
     708           0 :     FillScFmtToItemSet( rItemSet, nScNumFmt, bSkipPoolDefs );
     709           0 : }
     710             : 
     711           0 : void XclImpNumFmtBuffer::FillScFmtToItemSet( SfxItemSet& rItemSet, sal_uLong nScNumFmt, bool bSkipPoolDefs ) const
     712             : {
     713             :     OSL_ENSURE( nScNumFmt != NUMBERFORMAT_ENTRY_NOT_FOUND, "XclImpNumFmtBuffer::FillScFmtToItemSet - invalid number format" );
     714           0 :     ScfTools::PutItem( rItemSet, SfxUInt32Item( ATTR_VALUE_FORMAT, nScNumFmt ), bSkipPoolDefs );
     715           0 :     if( rItemSet.GetItemState( ATTR_VALUE_FORMAT, false ) == SFX_ITEM_SET )
     716           0 :         ScGlobal::AddLanguage( rItemSet, GetFormatter() );
     717           0 : }
     718             : 
     719             : // XF, STYLE record - Cell formatting =========================================
     720             : 
     721           0 : void XclImpCellProt::FillFromXF2( sal_uInt8 nNumFmt )
     722             : {
     723           0 :     mbLocked = ::get_flag( nNumFmt, EXC_XF2_LOCKED );
     724           0 :     mbHidden = ::get_flag( nNumFmt, EXC_XF2_HIDDEN );
     725           0 : }
     726             : 
     727           0 : void XclImpCellProt::FillFromXF3( sal_uInt16 nProt )
     728             : {
     729           0 :     mbLocked = ::get_flag( nProt, EXC_XF_LOCKED );
     730           0 :     mbHidden = ::get_flag( nProt, EXC_XF_HIDDEN );
     731           0 : }
     732             : 
     733           0 : void XclImpCellProt::FillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
     734             : {
     735           0 :     ScfTools::PutItem( rItemSet, ScProtectionAttr( mbLocked, mbHidden ), bSkipPoolDefs );
     736           0 : }
     737             : 
     738             : 
     739           0 : void XclImpCellAlign::FillFromXF2( sal_uInt8 nFlags )
     740             : {
     741           0 :     mnHorAlign = ::extract_value< sal_uInt8 >( nFlags, 0, 3 );
     742           0 : }
     743             : 
     744           0 : void XclImpCellAlign::FillFromXF3( sal_uInt16 nAlign )
     745             : {
     746           0 :     mnHorAlign = ::extract_value< sal_uInt8 >( nAlign, 0, 3 );
     747           0 :     mbLineBreak = ::get_flag( nAlign, EXC_XF_LINEBREAK );   // new in BIFF3
     748           0 : }
     749             : 
     750           0 : void XclImpCellAlign::FillFromXF4( sal_uInt16 nAlign )
     751             : {
     752           0 :     FillFromXF3( nAlign );
     753           0 :     mnVerAlign = ::extract_value< sal_uInt8 >( nAlign, 4, 2 );  // new in BIFF4
     754           0 :     mnOrient = ::extract_value< sal_uInt8 >( nAlign, 6, 2 );    // new in BIFF4
     755           0 : }
     756             : 
     757           0 : void XclImpCellAlign::FillFromXF5( sal_uInt16 nAlign )
     758             : {
     759           0 :     mnHorAlign = ::extract_value< sal_uInt8 >( nAlign, 0, 3 );
     760           0 :     mnVerAlign = ::extract_value< sal_uInt8 >( nAlign, 4, 3 );
     761           0 :     mbLineBreak = ::get_flag( nAlign, EXC_XF_LINEBREAK );
     762           0 :     mnOrient = ::extract_value< sal_uInt8 >( nAlign, 8, 2 );
     763           0 : }
     764             : 
     765           0 : void XclImpCellAlign::FillFromXF8( sal_uInt16 nAlign, sal_uInt16 nMiscAttrib )
     766             : {
     767           0 :     mnHorAlign = ::extract_value< sal_uInt8 >( nAlign, 0, 3 );
     768           0 :     mnVerAlign = ::extract_value< sal_uInt8 >( nAlign, 4, 3 );
     769           0 :     mbLineBreak = ::get_flag( nAlign, EXC_XF_LINEBREAK );
     770           0 :     mnRotation = ::extract_value< sal_uInt8 >( nAlign, 8, 8 );      // new in BIFF8
     771           0 :     mnIndent = ::extract_value< sal_uInt8 >( nMiscAttrib, 0, 4 );   // new in BIFF8
     772           0 :     mbShrink = ::get_flag( nMiscAttrib, EXC_XF8_SHRINK );           // new in BIFF8
     773           0 :     mnTextDir = ::extract_value< sal_uInt8 >( nMiscAttrib, 6, 2 );  // new in BIFF8
     774           0 : }
     775             : 
     776           0 : void XclImpCellAlign::FillFromCF( sal_uInt16 nAlign, sal_uInt16 nMiscAttrib )
     777             : {
     778           0 :     mnHorAlign = extract_value< sal_uInt8 >( nAlign, 0, 3 );
     779           0 :     mbLineBreak = get_flag< sal_uInt8 >( nAlign, EXC_XF_LINEBREAK );
     780           0 :     mnVerAlign = ::extract_value< sal_uInt8 >( nAlign, 4, 3 );
     781           0 :     mnRotation = ::extract_value< sal_uInt8 >( nAlign, 8, 8 );
     782           0 :     mnIndent = ::extract_value< sal_uInt8 >( nMiscAttrib, 0, 4 );
     783           0 :     mbShrink = ::get_flag( nMiscAttrib, EXC_XF8_SHRINK );
     784           0 :     mnTextDir = ::extract_value< sal_uInt8 >( nMiscAttrib, 6, 2 );
     785           0 : }
     786             : 
     787           0 : void XclImpCellAlign::FillToItemSet( SfxItemSet& rItemSet, const XclImpFont* pFont, bool bSkipPoolDefs ) const
     788             : {
     789             :     // horizontal alignment
     790           0 :     ScfTools::PutItem( rItemSet, SvxHorJustifyItem( GetScHorAlign(), ATTR_HOR_JUSTIFY ), bSkipPoolDefs );
     791           0 :     ScfTools::PutItem( rItemSet, SvxJustifyMethodItem( GetScHorJustifyMethod(), ATTR_HOR_JUSTIFY_METHOD ), bSkipPoolDefs );
     792             : 
     793             :     // text wrap (#i74508# always if vertical alignment is justified or distributed)
     794           0 :     bool bLineBreak = mbLineBreak || (mnVerAlign == EXC_XF_VER_JUSTIFY) || (mnVerAlign == EXC_XF_VER_DISTRIB);
     795           0 :     ScfTools::PutItem( rItemSet, SfxBoolItem( ATTR_LINEBREAK, bLineBreak ), bSkipPoolDefs );
     796             : 
     797             :     // vertical alignment
     798           0 :     ScfTools::PutItem( rItemSet, SvxVerJustifyItem( GetScVerAlign(), ATTR_VER_JUSTIFY ), bSkipPoolDefs );
     799           0 :     ScfTools::PutItem( rItemSet, SvxJustifyMethodItem( GetScVerJustifyMethod(), ATTR_VER_JUSTIFY_METHOD ), bSkipPoolDefs );
     800             : 
     801             :     // indent
     802           0 :     sal_uInt16 nScIndent = mnIndent * 200; // 1 Excel unit == 10 pt == 200 twips
     803           0 :     ScfTools::PutItem( rItemSet, SfxUInt16Item( ATTR_INDENT, nScIndent ), bSkipPoolDefs );
     804             : 
     805             :     // shrink to fit
     806           0 :     ScfTools::PutItem( rItemSet, SfxBoolItem( ATTR_SHRINKTOFIT, mbShrink ), bSkipPoolDefs );
     807             : 
     808             :     // text orientation/rotation (BIFF2-BIFF7 sets mnOrient)
     809           0 :     sal_uInt8 nXclRot = (mnOrient == EXC_ORIENT_NONE) ? mnRotation : XclTools::GetXclRotFromOrient( mnOrient );
     810           0 :     bool bStacked = (nXclRot == EXC_ROT_STACKED);
     811           0 :     ScfTools::PutItem( rItemSet, SfxBoolItem( ATTR_STACKED, bStacked ), bSkipPoolDefs );
     812             :     // set an angle in the range from -90 to 90 degrees
     813           0 :     sal_Int32 nAngle = XclTools::GetScRotation( nXclRot, 0 );
     814           0 :     ScfTools::PutItem( rItemSet, SfxInt32Item( ATTR_ROTATE_VALUE, nAngle ), bSkipPoolDefs );
     815             :     // set "Use asian vertical layout", if cell is stacked and font contains CKJ characters
     816           0 :     bool bAsianVert = bStacked && pFont && pFont->HasAsianChars();
     817           0 :     ScfTools::PutItem( rItemSet, SfxBoolItem( ATTR_VERTICAL_ASIAN, bAsianVert ), bSkipPoolDefs );
     818             : 
     819             :     // CTL text direction
     820           0 :     ScfTools::PutItem( rItemSet, SvxFrameDirectionItem( GetScFrameDir(), ATTR_WRITINGDIR ), bSkipPoolDefs );
     821           0 : }
     822             : 
     823           0 : XclImpCellBorder::XclImpCellBorder()
     824             : {
     825           0 :     SetUsedFlags( false, false );
     826           0 : }
     827             : 
     828           0 : void XclImpCellBorder::SetUsedFlags( bool bOuterUsed, bool bDiagUsed )
     829             : {
     830           0 :     mbLeftUsed = mbRightUsed = mbTopUsed = mbBottomUsed = bOuterUsed;
     831           0 :     mbDiagUsed = bDiagUsed;
     832           0 : }
     833             : 
     834           0 : void XclImpCellBorder::FillFromXF2( sal_uInt8 nFlags )
     835             : {
     836           0 :     mnLeftLine   = ::get_flagvalue( nFlags, EXC_XF2_LEFTLINE,   EXC_LINE_THIN, EXC_LINE_NONE );
     837           0 :     mnRightLine  = ::get_flagvalue( nFlags, EXC_XF2_RIGHTLINE,  EXC_LINE_THIN, EXC_LINE_NONE );
     838           0 :     mnTopLine    = ::get_flagvalue( nFlags, EXC_XF2_TOPLINE,    EXC_LINE_THIN, EXC_LINE_NONE );
     839           0 :     mnBottomLine = ::get_flagvalue( nFlags, EXC_XF2_BOTTOMLINE, EXC_LINE_THIN, EXC_LINE_NONE );
     840           0 :     mnLeftColor = mnRightColor = mnTopColor = mnBottomColor = EXC_COLOR_BIFF2_BLACK;
     841           0 :     SetUsedFlags( true, false );
     842           0 : }
     843             : 
     844           0 : void XclImpCellBorder::FillFromXF3( sal_uInt32 nBorder )
     845             : {
     846           0 :     mnTopLine     = ::extract_value< sal_uInt8  >( nBorder,  0, 3 );
     847           0 :     mnLeftLine    = ::extract_value< sal_uInt8  >( nBorder,  8, 3 );
     848           0 :     mnBottomLine  = ::extract_value< sal_uInt8  >( nBorder, 16, 3 );
     849           0 :     mnRightLine   = ::extract_value< sal_uInt8  >( nBorder, 24, 3 );
     850           0 :     mnTopColor    = ::extract_value< sal_uInt16 >( nBorder,  3, 5 );
     851           0 :     mnLeftColor   = ::extract_value< sal_uInt16 >( nBorder, 11, 5 );
     852           0 :     mnBottomColor = ::extract_value< sal_uInt16 >( nBorder, 19, 5 );
     853           0 :     mnRightColor  = ::extract_value< sal_uInt16 >( nBorder, 27, 5 );
     854           0 :     SetUsedFlags( true, false );
     855           0 : }
     856             : 
     857           0 : void XclImpCellBorder::FillFromXF5( sal_uInt32 nBorder, sal_uInt32 nArea )
     858             : {
     859           0 :     mnTopLine     = ::extract_value< sal_uInt8  >( nBorder,  0, 3 );
     860           0 :     mnLeftLine    = ::extract_value< sal_uInt8  >( nBorder,  3, 3 );
     861           0 :     mnBottomLine  = ::extract_value< sal_uInt8  >( nArea,   22, 3 );
     862           0 :     mnRightLine   = ::extract_value< sal_uInt8  >( nBorder,  6, 3 );
     863           0 :     mnTopColor    = ::extract_value< sal_uInt16 >( nBorder,  9, 7 );
     864           0 :     mnLeftColor   = ::extract_value< sal_uInt16 >( nBorder, 16, 7 );
     865           0 :     mnBottomColor = ::extract_value< sal_uInt16 >( nArea,   25, 7 );
     866           0 :     mnRightColor  = ::extract_value< sal_uInt16 >( nBorder, 23, 7 );
     867           0 :     SetUsedFlags( true, false );
     868           0 : }
     869             : 
     870           0 : void XclImpCellBorder::FillFromXF8( sal_uInt32 nBorder1, sal_uInt32 nBorder2 )
     871             : {
     872           0 :     mnLeftLine    = ::extract_value< sal_uInt8  >( nBorder1,  0, 4 );
     873           0 :     mnRightLine   = ::extract_value< sal_uInt8  >( nBorder1,  4, 4 );
     874           0 :     mnTopLine     = ::extract_value< sal_uInt8  >( nBorder1,  8, 4 );
     875           0 :     mnBottomLine  = ::extract_value< sal_uInt8  >( nBorder1, 12, 4 );
     876           0 :     mnLeftColor   = ::extract_value< sal_uInt16 >( nBorder1, 16, 7 );
     877           0 :     mnRightColor  = ::extract_value< sal_uInt16 >( nBorder1, 23, 7 );
     878           0 :     mnTopColor    = ::extract_value< sal_uInt16 >( nBorder2,  0, 7 );
     879           0 :     mnBottomColor = ::extract_value< sal_uInt16 >( nBorder2,  7, 7 );
     880           0 :     mbDiagTLtoBR  = ::get_flag( nBorder1, EXC_XF_DIAGONAL_TL_TO_BR );
     881           0 :     mbDiagBLtoTR  = ::get_flag( nBorder1, EXC_XF_DIAGONAL_BL_TO_TR );
     882           0 :     if( mbDiagTLtoBR || mbDiagBLtoTR )
     883             :     {
     884           0 :         mnDiagLine  = ::extract_value< sal_uInt8 >( nBorder2, 21, 4 );
     885           0 :         mnDiagColor = ::extract_value< sal_uInt16 >( nBorder2, 14, 7 );
     886             :     }
     887           0 :     SetUsedFlags( true, true );
     888           0 : }
     889             : 
     890           0 : void XclImpCellBorder::FillFromCF8( sal_uInt16 nLineStyle, sal_uInt32 nLineColor, sal_uInt32 nFlags )
     891             : {
     892           0 :     mnLeftLine    = ::extract_value< sal_uInt8  >( nLineStyle,  0, 4 );
     893           0 :     mnRightLine   = ::extract_value< sal_uInt8  >( nLineStyle,  4, 4 );
     894           0 :     mnTopLine     = ::extract_value< sal_uInt8  >( nLineStyle,  8, 4 );
     895           0 :     mnBottomLine  = ::extract_value< sal_uInt8  >( nLineStyle, 12, 4 );
     896           0 :     mnLeftColor   = ::extract_value< sal_uInt16 >( nLineColor,  0, 7 );
     897           0 :     mnRightColor  = ::extract_value< sal_uInt16 >( nLineColor,  7, 7 );
     898           0 :     mnTopColor    = ::extract_value< sal_uInt16 >( nLineColor, 16, 7 );
     899           0 :     mnBottomColor = ::extract_value< sal_uInt16 >( nLineColor, 23, 7 );
     900           0 :     mbLeftUsed    = !::get_flag( nFlags, EXC_CF_BORDER_LEFT );
     901           0 :     mbRightUsed   = !::get_flag( nFlags, EXC_CF_BORDER_RIGHT );
     902           0 :     mbTopUsed     = !::get_flag( nFlags, EXC_CF_BORDER_TOP );
     903           0 :     mbBottomUsed  = !::get_flag( nFlags, EXC_CF_BORDER_BOTTOM );
     904           0 :     mbDiagUsed    = false;
     905           0 : }
     906             : 
     907           0 : bool XclImpCellBorder::HasAnyOuterBorder() const
     908             : {
     909             :     return
     910           0 :         (mbLeftUsed   && (mnLeftLine != EXC_LINE_NONE)) ||
     911           0 :         (mbRightUsed  && (mnRightLine != EXC_LINE_NONE)) ||
     912           0 :         (mbTopUsed    && (mnTopLine != EXC_LINE_NONE)) ||
     913           0 :         (mbBottomUsed && (mnBottomLine != EXC_LINE_NONE));
     914             : }
     915             : 
     916             : namespace {
     917             : 
     918             : /** Converts the passed line style to a ::editeng::SvxBorderLine, or returns false, if style is "no line". */
     919           0 : bool lclConvertBorderLine( ::editeng::SvxBorderLine& rLine, const XclImpPalette& rPalette, sal_uInt8 nXclLine, sal_uInt16 nXclColor )
     920             : {
     921             :     static const sal_uInt16 ppnLineParam[][ 4 ] =
     922             :     {
     923             :         //  outer width,        type
     924             :         {   0,                  table::BorderLineStyle::SOLID        }, // 0 = none
     925             :         {   EXC_BORDER_THIN,    table::BorderLineStyle::SOLID        }, // 1 = thin
     926             :         {   EXC_BORDER_MEDIUM,  table::BorderLineStyle::SOLID        }, // 2 = medium
     927             :         {   EXC_BORDER_THIN,    table::BorderLineStyle::FINE_DASHED  }, // 3 = dashed
     928             :         {   EXC_BORDER_THIN,    table::BorderLineStyle::DOTTED       }, // 4 = dotted
     929             :         {   EXC_BORDER_THICK,   table::BorderLineStyle::SOLID        }, // 5 = thick
     930             :         {   EXC_BORDER_THICK,   table::BorderLineStyle::DOUBLE_THIN  }, // 6 = double
     931             :         {   EXC_BORDER_HAIR,    table::BorderLineStyle::SOLID        }, // 7 = hair
     932             :         {   EXC_BORDER_MEDIUM,  table::BorderLineStyle::DASHED       }, // 8 = med dash
     933             :         {   EXC_BORDER_THIN,    table::BorderLineStyle::DASH_DOT     }, // 9 = thin dashdot
     934             :         {   EXC_BORDER_MEDIUM,  table::BorderLineStyle::DASH_DOT     }, // A = med dashdot
     935             :         {   EXC_BORDER_THIN,    table::BorderLineStyle::DASH_DOT_DOT }, // B = thin dashdotdot
     936             :         {   EXC_BORDER_MEDIUM,  table::BorderLineStyle::DASH_DOT_DOT }, // C = med dashdotdot
     937             :         {   EXC_BORDER_MEDIUM,  table::BorderLineStyle::DASH_DOT     }  // D = med slant dashdot
     938             :     };
     939             : 
     940           0 :     if( nXclLine == EXC_LINE_NONE )
     941           0 :         return false;
     942           0 :     if( nXclLine >= SAL_N_ELEMENTS( ppnLineParam ) )
     943           0 :         nXclLine = EXC_LINE_THIN;
     944             : 
     945           0 :     rLine.SetColor( rPalette.GetColor( nXclColor ) );
     946           0 :     rLine.SetWidth( ppnLineParam[ nXclLine ][ 0 ] );
     947             :     rLine.SetBorderLineStyle( static_cast< ::editeng::SvxBorderStyle>(
     948           0 :                 ppnLineParam[ nXclLine ][ 1 ]) );
     949           0 :     return true;
     950             : }
     951             : 
     952             : } // namespace
     953             : 
     954           0 : void XclImpCellBorder::FillToItemSet( SfxItemSet& rItemSet, const XclImpPalette& rPalette, bool bSkipPoolDefs ) const
     955             : {
     956           0 :     if( mbLeftUsed || mbRightUsed || mbTopUsed || mbBottomUsed )
     957             :     {
     958           0 :         SvxBoxItem aBoxItem( ATTR_BORDER );
     959           0 :         ::editeng::SvxBorderLine aLine;
     960           0 :         if( mbLeftUsed && lclConvertBorderLine( aLine, rPalette, mnLeftLine, mnLeftColor ) )
     961           0 :             aBoxItem.SetLine( &aLine, BOX_LINE_LEFT );
     962           0 :         if( mbRightUsed && lclConvertBorderLine( aLine, rPalette, mnRightLine, mnRightColor ) )
     963           0 :             aBoxItem.SetLine( &aLine, BOX_LINE_RIGHT );
     964           0 :         if( mbTopUsed && lclConvertBorderLine( aLine, rPalette, mnTopLine, mnTopColor ) )
     965           0 :             aBoxItem.SetLine( &aLine, BOX_LINE_TOP );
     966           0 :         if( mbBottomUsed && lclConvertBorderLine( aLine, rPalette, mnBottomLine, mnBottomColor ) )
     967           0 :             aBoxItem.SetLine( &aLine, BOX_LINE_BOTTOM );
     968           0 :         ScfTools::PutItem( rItemSet, aBoxItem, bSkipPoolDefs );
     969             :     }
     970           0 :     if( mbDiagUsed )
     971             :     {
     972           0 :         SvxLineItem aTLBRItem( ATTR_BORDER_TLBR );
     973           0 :         SvxLineItem aBLTRItem( ATTR_BORDER_BLTR );
     974           0 :         ::editeng::SvxBorderLine aLine;
     975           0 :         if( lclConvertBorderLine( aLine, rPalette, mnDiagLine, mnDiagColor ) )
     976             :         {
     977           0 :             if( mbDiagTLtoBR )
     978           0 :                 aTLBRItem.SetLine( &aLine );
     979           0 :             if( mbDiagBLtoTR )
     980           0 :                 aBLTRItem.SetLine( &aLine );
     981             :         }
     982           0 :         ScfTools::PutItem( rItemSet, aTLBRItem, bSkipPoolDefs );
     983           0 :         ScfTools::PutItem( rItemSet, aBLTRItem, bSkipPoolDefs );
     984             :     }
     985           0 : }
     986             : 
     987           0 : XclImpCellArea::XclImpCellArea()
     988             : {
     989           0 :     SetUsedFlags( false );
     990           0 : }
     991             : 
     992           0 : void XclImpCellArea::SetUsedFlags( bool bUsed )
     993             : {
     994           0 :     mbForeUsed = mbBackUsed = mbPattUsed = bUsed;
     995           0 : }
     996             : 
     997           0 : void XclImpCellArea::FillFromXF2( sal_uInt8 nFlags )
     998             : {
     999           0 :     mnPattern = ::get_flagvalue( nFlags, EXC_XF2_BACKGROUND, EXC_PATT_12_5_PERC, EXC_PATT_NONE );
    1000           0 :     mnForeColor = EXC_COLOR_BIFF2_BLACK;
    1001           0 :     mnBackColor = EXC_COLOR_BIFF2_WHITE;
    1002           0 :     SetUsedFlags( true );
    1003           0 : }
    1004             : 
    1005           0 : void XclImpCellArea::FillFromXF3( sal_uInt16 nArea )
    1006             : {
    1007           0 :     mnPattern   = ::extract_value< sal_uInt8  >( nArea,  0, 6 );
    1008           0 :     mnForeColor = ::extract_value< sal_uInt16 >( nArea,  6, 5 );
    1009           0 :     mnBackColor = ::extract_value< sal_uInt16 >( nArea, 11, 5 );
    1010           0 :     SetUsedFlags( true );
    1011           0 : }
    1012             : 
    1013           0 : void XclImpCellArea::FillFromXF5( sal_uInt32 nArea )
    1014             : {
    1015           0 :     mnPattern   = ::extract_value< sal_uInt8  >( nArea, 16, 6 );
    1016           0 :     mnForeColor = ::extract_value< sal_uInt16 >( nArea,  0, 7 );
    1017           0 :     mnBackColor = ::extract_value< sal_uInt16 >( nArea,  7, 7 );
    1018           0 :     SetUsedFlags( true );
    1019           0 : }
    1020             : 
    1021           0 : void XclImpCellArea::FillFromXF8( sal_uInt32 nBorder2, sal_uInt16 nArea )
    1022             : {
    1023           0 :     mnPattern   = ::extract_value< sal_uInt8  >( nBorder2, 26, 6 );
    1024           0 :     mnForeColor = ::extract_value< sal_uInt16 >( nArea,     0, 7 );
    1025           0 :     mnBackColor = ::extract_value< sal_uInt16 >( nArea,     7, 7 );
    1026           0 :     SetUsedFlags( true );
    1027           0 : }
    1028             : 
    1029           0 : void XclImpCellArea::FillFromCF8( sal_uInt16 nPattern, sal_uInt16 nColor, sal_uInt32 nFlags )
    1030             : {
    1031           0 :     mnForeColor = ::extract_value< sal_uInt16 >( nColor,    0, 7 );
    1032           0 :     mnBackColor = ::extract_value< sal_uInt16 >( nColor,    7, 7 );
    1033           0 :     mnPattern   = ::extract_value< sal_uInt8  >( nPattern, 10, 6 );
    1034           0 :     mbForeUsed  = !::get_flag( nFlags, EXC_CF_AREA_FGCOLOR );
    1035           0 :     mbBackUsed  = !::get_flag( nFlags, EXC_CF_AREA_BGCOLOR );
    1036           0 :     mbPattUsed  = !::get_flag( nFlags, EXC_CF_AREA_PATTERN );
    1037             : 
    1038           0 :     if( mbBackUsed && (!mbPattUsed || (mnPattern == EXC_PATT_SOLID)) )
    1039             :     {
    1040           0 :         mnForeColor = mnBackColor;
    1041           0 :         mnPattern = EXC_PATT_SOLID;
    1042           0 :         mbForeUsed = mbPattUsed = true;
    1043             :     }
    1044           0 :     else if( !mbBackUsed && mbPattUsed && (mnPattern == EXC_PATT_SOLID) )
    1045             :     {
    1046           0 :         mbPattUsed = false;
    1047             :     }
    1048           0 : }
    1049             : 
    1050           0 : void XclImpCellArea::FillToItemSet( SfxItemSet& rItemSet, const XclImpPalette& rPalette, bool bSkipPoolDefs ) const
    1051             : {
    1052           0 :     if( mbPattUsed )    // colors may be both unused in cond. formats
    1053             :     {
    1054           0 :         SvxBrushItem aBrushItem( ATTR_BACKGROUND );
    1055             : 
    1056             :         // do not use IsTransparent() - old Calc filter writes tranparency with different color indexes
    1057           0 :         if( mnPattern == EXC_PATT_NONE )
    1058             :         {
    1059           0 :             aBrushItem.SetColor( Color( COL_TRANSPARENT ) );
    1060             :         }
    1061             :         else
    1062             :         {
    1063           0 :             Color aFore( rPalette.GetColor( mbForeUsed ? mnForeColor : EXC_COLOR_WINDOWTEXT ) );
    1064           0 :             Color aBack( rPalette.GetColor( mbBackUsed ? mnBackColor : EXC_COLOR_WINDOWBACK ) );
    1065           0 :             aBrushItem.SetColor( XclTools::GetPatternColor( aFore, aBack, mnPattern ) );
    1066             :         }
    1067             : 
    1068           0 :         ScfTools::PutItem( rItemSet, aBrushItem, bSkipPoolDefs );
    1069             :     }
    1070           0 : }
    1071             : 
    1072             : 
    1073           0 : XclImpXF::XclImpXF( const XclImpRoot& rRoot ) :
    1074             :     XclXFBase( true ),      // default is cell XF
    1075             :     XclImpRoot( rRoot ),
    1076             :     mpStyleSheet( 0 ),
    1077             :     mnXclNumFmt( 0 ),
    1078           0 :     mnXclFont( 0 )
    1079             : {
    1080           0 : }
    1081             : 
    1082           0 : XclImpXF::~XclImpXF()
    1083             : {
    1084           0 : }
    1085             : 
    1086           0 : void XclImpXF::ReadXF2( XclImpStream& rStrm )
    1087             : {
    1088             :     sal_uInt8 nReadFont, nReadNumFmt, nFlags;
    1089           0 :     rStrm >> nReadFont;
    1090           0 :     rStrm.Ignore( 1 );
    1091           0 :     rStrm >> nReadNumFmt >> nFlags;
    1092             : 
    1093             :     // XF type always cell, no parent, used flags always true
    1094           0 :     SetAllUsedFlags( true );
    1095             : 
    1096             :     // attributes
    1097           0 :     maProtection.FillFromXF2( nReadNumFmt );
    1098           0 :     mnXclFont = nReadFont;
    1099           0 :     mnXclNumFmt = nReadNumFmt & EXC_XF2_VALFMT_MASK;
    1100           0 :     maAlignment.FillFromXF2( nFlags );
    1101           0 :     maBorder.FillFromXF2( nFlags );
    1102           0 :     maArea.FillFromXF2( nFlags );
    1103           0 : }
    1104             : 
    1105           0 : void XclImpXF::ReadXF3( XclImpStream& rStrm )
    1106             : {
    1107             :     sal_uInt32 nBorder;
    1108             :     sal_uInt16 nTypeProt, nAlign, nArea;
    1109             :     sal_uInt8 nReadFont, nReadNumFmt;
    1110           0 :     rStrm >> nReadFont >> nReadNumFmt >> nTypeProt >> nAlign >> nArea >> nBorder;
    1111             : 
    1112             :     // XF type/parent, attribute used flags
    1113           0 :     mbCellXF = !::get_flag( nTypeProt, EXC_XF_STYLE );          // new in BIFF3
    1114           0 :     mnParent = ::extract_value< sal_uInt16 >( nAlign, 4, 12 );  // new in BIFF3
    1115           0 :     SetUsedFlags( ::extract_value< sal_uInt8 >( nTypeProt, 10, 6 ) );
    1116             : 
    1117             :     // attributes
    1118           0 :     maProtection.FillFromXF3( nTypeProt );
    1119           0 :     mnXclFont = nReadFont;
    1120           0 :     mnXclNumFmt = nReadNumFmt;
    1121           0 :     maAlignment.FillFromXF3( nAlign );
    1122           0 :     maBorder.FillFromXF3( nBorder );
    1123           0 :     maArea.FillFromXF3( nArea );                        // new in BIFF3
    1124           0 : }
    1125             : 
    1126           0 : void XclImpXF::ReadXF4( XclImpStream& rStrm )
    1127             : {
    1128             :     sal_uInt32 nBorder;
    1129             :     sal_uInt16 nTypeProt, nAlign, nArea;
    1130             :     sal_uInt8 nReadFont, nReadNumFmt;
    1131           0 :     rStrm >> nReadFont >> nReadNumFmt >> nTypeProt >> nAlign >> nArea >> nBorder;
    1132             : 
    1133             :     // XF type/parent, attribute used flags
    1134           0 :     mbCellXF = !::get_flag( nTypeProt, EXC_XF_STYLE );
    1135           0 :     mnParent = ::extract_value< sal_uInt16 >( nTypeProt, 4, 12 );
    1136           0 :     SetUsedFlags( ::extract_value< sal_uInt8 >( nAlign, 10, 6 ) );
    1137             : 
    1138             :     // attributes
    1139           0 :     maProtection.FillFromXF3( nTypeProt );
    1140           0 :     mnXclFont = nReadFont;
    1141           0 :     mnXclNumFmt = nReadNumFmt;
    1142           0 :     maAlignment.FillFromXF4( nAlign );
    1143           0 :     maBorder.FillFromXF3( nBorder );
    1144           0 :     maArea.FillFromXF3( nArea );
    1145           0 : }
    1146             : 
    1147           0 : void XclImpXF::ReadXF5( XclImpStream& rStrm )
    1148             : {
    1149             :     sal_uInt32 nArea, nBorder;
    1150             :     sal_uInt16 nTypeProt, nAlign;
    1151           0 :     rStrm >> mnXclFont >> mnXclNumFmt >> nTypeProt >> nAlign >> nArea >> nBorder;
    1152             : 
    1153             :     // XF type/parent, attribute used flags
    1154           0 :     mbCellXF = !::get_flag( nTypeProt, EXC_XF_STYLE );
    1155           0 :     mnParent = ::extract_value< sal_uInt16 >( nTypeProt, 4, 12 );
    1156           0 :     SetUsedFlags( ::extract_value< sal_uInt8 >( nAlign, 10, 6 ) );
    1157             : 
    1158             :     // attributes
    1159           0 :     maProtection.FillFromXF3( nTypeProt );
    1160           0 :     maAlignment.FillFromXF5( nAlign );
    1161           0 :     maBorder.FillFromXF5( nBorder, nArea );
    1162           0 :     maArea.FillFromXF5( nArea );
    1163           0 : }
    1164             : 
    1165           0 : void XclImpXF::ReadXF8( XclImpStream& rStrm )
    1166             : {
    1167             :     sal_uInt32 nBorder1, nBorder2;
    1168             :     sal_uInt16 nTypeProt, nAlign, nMiscAttrib, nArea;
    1169           0 :     rStrm >> mnXclFont >> mnXclNumFmt >> nTypeProt >> nAlign >> nMiscAttrib >> nBorder1 >> nBorder2 >> nArea;
    1170             : 
    1171             :     // XF type/parent, attribute used flags
    1172           0 :     mbCellXF = !::get_flag( nTypeProt, EXC_XF_STYLE );
    1173           0 :     mnParent = ::extract_value< sal_uInt16 >( nTypeProt, 4, 12 );
    1174           0 :     SetUsedFlags( ::extract_value< sal_uInt8 >( nMiscAttrib, 10, 6 ) );
    1175             : 
    1176             :     // attributes
    1177           0 :     maProtection.FillFromXF3( nTypeProt );
    1178           0 :     maAlignment.FillFromXF8( nAlign, nMiscAttrib );
    1179           0 :     maBorder.FillFromXF8( nBorder1, nBorder2 );
    1180           0 :     maArea.FillFromXF8( nBorder2, nArea );
    1181           0 : }
    1182             : 
    1183           0 : void XclImpXF::ReadXF( XclImpStream& rStrm )
    1184             : {
    1185           0 :     switch( GetBiff() )
    1186             :     {
    1187           0 :         case EXC_BIFF2: ReadXF2( rStrm );   break;
    1188           0 :         case EXC_BIFF3: ReadXF3( rStrm );   break;
    1189           0 :         case EXC_BIFF4: ReadXF4( rStrm );   break;
    1190           0 :         case EXC_BIFF5: ReadXF5( rStrm );   break;
    1191           0 :         case EXC_BIFF8: ReadXF8( rStrm );   break;
    1192             :         default:        DBG_ERROR_BIFF();
    1193             :     }
    1194           0 : }
    1195             : 
    1196           0 : const ScPatternAttr& XclImpXF::CreatePattern( bool bSkipPoolDefs )
    1197             : {
    1198           0 :     if( mpPattern.get() )
    1199           0 :         return *mpPattern;
    1200             : 
    1201             :     // create new pattern attribute set
    1202           0 :     mpPattern.reset( new ScPatternAttr( GetDoc().GetPool() ) );
    1203           0 :     SfxItemSet& rItemSet = mpPattern->GetItemSet();
    1204           0 :     XclImpXF* pParentXF = IsCellXF() ? GetXFBuffer().GetXF( mnParent ) : 0;
    1205             : 
    1206             :     // parent cell style
    1207           0 :     if( IsCellXF() && !mpStyleSheet )
    1208             :     {
    1209           0 :         mpStyleSheet = GetXFBuffer().CreateStyleSheet( mnParent );
    1210             : 
    1211             :         /*  Enables mb***Used flags, if the formatting attributes differ from
    1212             :             the passed XF record. In cell XFs Excel uses the cell attributes,
    1213             :             if they differ from the parent style XF.
    1214             :             ...or if the respective flag is not set in parent style XF. */
    1215           0 :         if( pParentXF )
    1216             :         {
    1217           0 :             if( !mbProtUsed )
    1218           0 :                 mbProtUsed = !pParentXF->mbProtUsed || !(maProtection == pParentXF->maProtection);
    1219           0 :             if( !mbFontUsed )
    1220           0 :                 mbFontUsed = !pParentXF->mbFontUsed || (mnXclFont != pParentXF->mnXclFont);
    1221           0 :             if( !mbFmtUsed )
    1222           0 :                 mbFmtUsed = !pParentXF->mbFmtUsed || (mnXclNumFmt != pParentXF->mnXclNumFmt);
    1223           0 :             if( !mbAlignUsed )
    1224           0 :                 mbAlignUsed = !pParentXF->mbAlignUsed || !(maAlignment == pParentXF->maAlignment);
    1225           0 :             if( !mbBorderUsed )
    1226           0 :                 mbBorderUsed = !pParentXF->mbBorderUsed || !(maBorder == pParentXF->maBorder);
    1227           0 :             if( !mbAreaUsed )
    1228           0 :                 mbAreaUsed = !pParentXF->mbAreaUsed || !(maArea == pParentXF->maArea);
    1229             :         }
    1230             :     }
    1231             : 
    1232             :     // cell protection
    1233           0 :     if( mbProtUsed )
    1234           0 :         maProtection.FillToItemSet( rItemSet, bSkipPoolDefs );
    1235             : 
    1236             :     // font
    1237           0 :     if( mbFontUsed )
    1238           0 :         GetFontBuffer().FillToItemSet( rItemSet, EXC_FONTITEM_CELL, mnXclFont, bSkipPoolDefs );
    1239             : 
    1240             :     // value format
    1241           0 :     if( mbFmtUsed )
    1242             :     {
    1243           0 :         GetNumFmtBuffer().FillToItemSet( rItemSet, mnXclNumFmt, bSkipPoolDefs );
    1244             :         // Trace occurrences of Windows date formats
    1245           0 :         GetTracer().TraceDates( mnXclNumFmt );
    1246             :     }
    1247             : 
    1248             :     // alignment
    1249           0 :     if( mbAlignUsed )
    1250           0 :         maAlignment.FillToItemSet( rItemSet, GetFontBuffer().GetFont( mnXclFont ), bSkipPoolDefs );
    1251             : 
    1252             :     // border
    1253           0 :     if( mbBorderUsed )
    1254             :     {
    1255           0 :         maBorder.FillToItemSet( rItemSet, GetPalette(), bSkipPoolDefs );
    1256           0 :         GetTracer().TraceBorderLineStyle(maBorder.mnLeftLine > EXC_LINE_HAIR ||
    1257           0 :             maBorder.mnRightLine > EXC_LINE_HAIR || maBorder.mnTopLine > EXC_LINE_HAIR ||
    1258           0 :             maBorder.mnBottomLine > EXC_LINE_HAIR );
    1259             :     }
    1260             : 
    1261             :     // area
    1262           0 :     if( mbAreaUsed )
    1263             :     {
    1264           0 :         maArea.FillToItemSet( rItemSet, GetPalette(), bSkipPoolDefs );
    1265           0 :         GetTracer().TraceFillPattern(maArea.mnPattern != EXC_PATT_NONE &&
    1266           0 :             maArea.mnPattern != EXC_PATT_SOLID);
    1267             :     }
    1268             : 
    1269             :     /*  #i38709# Decide which rotation reference mode to use. If any outer
    1270             :         border line of the cell is set (either explicitly or via cell style),
    1271             :         and the cell contents are rotated, set rotation reference to bottom of
    1272             :         cell. This causes the borders to be painted rotated with the text. */
    1273           0 :     if( mbAlignUsed || mbBorderUsed )
    1274             :     {
    1275           0 :         SvxRotateMode eRotateMode = SVX_ROTATE_MODE_STANDARD;
    1276           0 :         const XclImpCellAlign* pAlign = mbAlignUsed ? &maAlignment : (pParentXF ? &pParentXF->maAlignment : 0);
    1277           0 :         const XclImpCellBorder* pBorder = mbBorderUsed ? &maBorder : (pParentXF ? &pParentXF->maBorder : 0);
    1278           0 :         if( pAlign && pBorder && (0 < pAlign->mnRotation) && (pAlign->mnRotation <= 180) && pBorder->HasAnyOuterBorder() )
    1279           0 :             eRotateMode = SVX_ROTATE_MODE_BOTTOM;
    1280           0 :         ScfTools::PutItem( rItemSet, SvxRotateModeItem( eRotateMode, ATTR_ROTATE_MODE ), bSkipPoolDefs );
    1281             :     }
    1282             : 
    1283             :     // Excel's cell margins are different from Calc's default margins.
    1284           0 :     SvxMarginItem aItem(40, 40, 40, 40, ATTR_MARGIN);
    1285           0 :     ScfTools::PutItem(rItemSet, aItem, bSkipPoolDefs);
    1286             : 
    1287           0 :     return *mpPattern;
    1288             : }
    1289             : 
    1290           0 : void XclImpXF::ApplyPatternToAttrList(
    1291             :     list<ScAttrEntry>& rAttrs, SCROW nRow1, SCROW nRow2, sal_uInt32 nForceScNumFmt)
    1292             : {
    1293             :     // force creation of cell style and hard formatting, do it here to have mpStyleSheet
    1294           0 :     CreatePattern();
    1295           0 :     ScPatternAttr& rPat = *mpPattern;
    1296             : 
    1297             :     // insert into document
    1298           0 :     ScDocument& rDoc = GetDoc();
    1299             : 
    1300           0 :     if (IsCellXF())
    1301             :     {
    1302           0 :         if (mpStyleSheet)
    1303             :         {
    1304             :             // Apply style sheet.  Don't clear the direct formats.
    1305           0 :             rPat.SetStyleSheet(mpStyleSheet, false);
    1306             :         }
    1307             :         else
    1308             :         {
    1309             :             // When the cell format is not associated with any style, use the
    1310             :             // 'Default' style.  Some buggy XLS docs generated by apps other
    1311             :             // than Excel (such as 1C) may not have any built-in styles at
    1312             :             // all.
    1313           0 :             ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
    1314           0 :             if (pStylePool)
    1315             :             {
    1316             :                 ScStyleSheet* pStyleSheet = static_cast<ScStyleSheet*>(
    1317             :                     pStylePool->Find(
    1318           0 :                         ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA));
    1319             : 
    1320           0 :                 if (pStyleSheet)
    1321           0 :                     rPat.SetStyleSheet(pStyleSheet, false);
    1322             :             }
    1323             : 
    1324             :         }
    1325             :     }
    1326             : 
    1327           0 :     if (nForceScNumFmt != NUMBERFORMAT_ENTRY_NOT_FOUND)
    1328             :     {
    1329           0 :         ScPatternAttr aNumPat(rDoc.GetPool());
    1330           0 :         GetNumFmtBuffer().FillScFmtToItemSet(aNumPat.GetItemSet(), nForceScNumFmt);
    1331           0 :         rPat.GetItemSet().Put(aNumPat.GetItemSet());
    1332             :     }
    1333             : 
    1334             :     // Make sure we skip unnamed styles.
    1335           0 :     if (rPat.GetStyleName())
    1336             :     {
    1337             :         // Check for a gap between the last entry and this one.
    1338           0 :         bool bHasGap = false;
    1339           0 :         if (rAttrs.empty() && nRow1 > 0)
    1340             :             // First attribute range doesn't start at row 0.
    1341           0 :             bHasGap = true;
    1342             : 
    1343           0 :         if (!rAttrs.empty() && rAttrs.back().nRow + 1 < nRow1)
    1344           0 :             bHasGap = true;
    1345             : 
    1346           0 :         if (bHasGap)
    1347             :         {
    1348             :             // Fill this gap with the default pattern.
    1349             :             ScAttrEntry aEntry;
    1350           0 :             aEntry.nRow = nRow1 - 1;
    1351           0 :             aEntry.pPattern = rDoc.GetDefPattern();
    1352           0 :             rAttrs.push_back(aEntry);
    1353             :         }
    1354             : 
    1355             :         ScAttrEntry aEntry;
    1356           0 :         aEntry.nRow = nRow2;
    1357           0 :         aEntry.pPattern = static_cast<const ScPatternAttr*>(&rDoc.GetPool()->Put(rPat));
    1358           0 :         rAttrs.push_back(aEntry);
    1359             :     }
    1360           0 : }
    1361             : 
    1362           0 : void XclImpXF::ApplyPattern(
    1363             :         SCCOL nScCol1, SCROW nScRow1, SCCOL nScCol2, SCROW nScRow2,
    1364             :         SCTAB nScTab, sal_uLong nForceScNumFmt )
    1365             : {
    1366             :     // force creation of cell style and hard formatting, do it here to have mpStyleSheet
    1367           0 :     const ScPatternAttr& rPattern = CreatePattern();
    1368             : 
    1369             :     // insert into document
    1370           0 :     ScDocument& rDoc = GetDoc();
    1371           0 :     if( IsCellXF() && mpStyleSheet )
    1372           0 :         rDoc.ApplyStyleAreaTab( nScCol1, nScRow1, nScCol2, nScRow2, nScTab, *mpStyleSheet );
    1373           0 :     if( HasUsedFlags() )
    1374           0 :         rDoc.ApplyPatternAreaTab( nScCol1, nScRow1, nScCol2, nScRow2, nScTab, rPattern );
    1375             : 
    1376             :     // #108770# apply special number format
    1377           0 :     if( nForceScNumFmt != NUMBERFORMAT_ENTRY_NOT_FOUND )
    1378             :     {
    1379           0 :         ScPatternAttr aPattern( GetDoc().GetPool() );
    1380           0 :         GetNumFmtBuffer().FillScFmtToItemSet( aPattern.GetItemSet(), nForceScNumFmt );
    1381           0 :         rDoc.ApplyPatternAreaTab( nScCol1, nScRow1, nScCol2, nScRow2, nScTab, aPattern );
    1382             :     }
    1383           0 : }
    1384             : 
    1385           0 : /*static*/ void XclImpXF::ApplyPatternForBiff2CellFormat( const XclImpRoot& rRoot,
    1386             :         const ScAddress& rScPos, sal_uInt8 nFlags1, sal_uInt8 nFlags2, sal_uInt8 nFlags3 )
    1387             : {
    1388             :     /*  Create an XF object and let it do the work. We will have access to its
    1389             :         private members here. */
    1390           0 :     XclImpXF aXF( rRoot );
    1391             : 
    1392             :     // no used flags available in BIFF2 (always true)
    1393           0 :     aXF.SetAllUsedFlags( true );
    1394             : 
    1395             :     // set the attributes
    1396           0 :     aXF.maProtection.FillFromXF2( nFlags1 );
    1397           0 :     aXF.maAlignment.FillFromXF2( nFlags3 );
    1398           0 :     aXF.maBorder.FillFromXF2( nFlags3 );
    1399           0 :     aXF.maArea.FillFromXF2( nFlags3 );
    1400           0 :     aXF.mnXclNumFmt = ::extract_value< sal_uInt16 >( nFlags2, 0, 6 );
    1401           0 :     aXF.mnXclFont = ::extract_value< sal_uInt16 >( nFlags2, 6, 2 );
    1402             : 
    1403             :     // write the attributes to the cell
    1404           0 :     aXF.ApplyPattern( rScPos.Col(), rScPos.Row(), rScPos.Col(), rScPos.Row(), rScPos.Tab() );
    1405           0 : }
    1406             : 
    1407           0 : void XclImpXF::SetUsedFlags( sal_uInt8 nUsedFlags )
    1408             : {
    1409             :     /*  Notes about finding the mb***Used flags:
    1410             :         - In cell XFs a *set* bit means a used attribute.
    1411             :         - In style XFs a *cleared* bit means a used attribute.
    1412             :         The mb***Used members always store true, if the attribute is used.
    1413             :         The "mbCellXF == ::get_flag(...)" construct evaluates to true in
    1414             :         both mentioned cases: cell XF and set bit; or style XF and cleared bit.
    1415             :      */
    1416           0 :     mbProtUsed   = (mbCellXF == ::get_flag( nUsedFlags, EXC_XF_DIFF_PROT ));
    1417           0 :     mbFontUsed   = (mbCellXF == ::get_flag( nUsedFlags, EXC_XF_DIFF_FONT ));
    1418           0 :     mbFmtUsed    = (mbCellXF == ::get_flag( nUsedFlags, EXC_XF_DIFF_VALFMT ));
    1419           0 :     mbAlignUsed  = (mbCellXF == ::get_flag( nUsedFlags, EXC_XF_DIFF_ALIGN ));
    1420           0 :     mbBorderUsed = (mbCellXF == ::get_flag( nUsedFlags, EXC_XF_DIFF_BORDER ));
    1421           0 :     mbAreaUsed   = (mbCellXF == ::get_flag( nUsedFlags, EXC_XF_DIFF_AREA ));
    1422           0 : }
    1423             : 
    1424           0 : XclImpStyle::XclImpStyle( const XclImpRoot& rRoot ) :
    1425             :     XclImpRoot( rRoot ),
    1426             :     mnXfId( EXC_XF_NOTFOUND ),
    1427             :     mnBuiltinId( EXC_STYLE_USERDEF ),
    1428             :     mnLevel( EXC_STYLE_NOLEVEL ),
    1429             :     mbBuiltin( false ),
    1430             :     mbCustom( false ),
    1431             :     mbHidden( false ),
    1432           0 :     mpStyleSheet( 0 )
    1433             : {
    1434           0 : }
    1435             : 
    1436           0 : void XclImpStyle::ReadStyle( XclImpStream& rStrm )
    1437             : {
    1438             :     OSL_ENSURE_BIFF( GetBiff() >= EXC_BIFF3 );
    1439             : 
    1440             :     sal_uInt16 nXFIndex;
    1441           0 :     rStrm >> nXFIndex;
    1442           0 :     mnXfId = nXFIndex & EXC_STYLE_XFMASK;
    1443           0 :     mbBuiltin = ::get_flag( nXFIndex, EXC_STYLE_BUILTIN );
    1444             : 
    1445           0 :     if( mbBuiltin )
    1446             :     {
    1447           0 :         rStrm >> mnBuiltinId >> mnLevel;
    1448             :     }
    1449             :     else
    1450             :     {
    1451           0 :         maName = (GetBiff() <= EXC_BIFF5) ? rStrm.ReadByteString( false ) : rStrm.ReadUniString();
    1452             :         // #i103281# check if this is a new built-in style introduced in XL2007
    1453           0 :         if( (GetBiff() == EXC_BIFF8) && (rStrm.GetNextRecId() == EXC_ID_STYLEEXT) && rStrm.StartNextRecord() )
    1454             :         {
    1455             :             sal_uInt8 nExtFlags;
    1456           0 :             rStrm.Ignore( 12 );
    1457           0 :             rStrm >> nExtFlags;
    1458           0 :             mbBuiltin = ::get_flag( nExtFlags, EXC_STYLEEXT_BUILTIN );
    1459           0 :             mbCustom = ::get_flag( nExtFlags, EXC_STYLEEXT_CUSTOM );
    1460           0 :             mbHidden = ::get_flag( nExtFlags, EXC_STYLEEXT_HIDDEN );
    1461           0 :             if( mbBuiltin )
    1462             :             {
    1463           0 :                 rStrm.Ignore( 1 );  // category
    1464           0 :                 rStrm >> mnBuiltinId >> mnLevel;
    1465             :             }
    1466             :         }
    1467             :     }
    1468           0 : }
    1469             : 
    1470           0 : ScStyleSheet* XclImpStyle::CreateStyleSheet()
    1471             : {
    1472             :     // #i1624# #i1768# ignore unnamed user styles
    1473           0 :     if( !mpStyleSheet && (!maFinalName.isEmpty()) )
    1474             :     {
    1475           0 :         bool bCreatePattern = false;
    1476           0 :         XclImpXF* pXF = GetXFBuffer().GetXF( mnXfId );
    1477             : 
    1478           0 :         bool bDefStyle = mbBuiltin && (mnBuiltinId == EXC_STYLE_NORMAL);
    1479           0 :         if( bDefStyle )
    1480             :         {
    1481             :             // set all flags to true to get all items in XclImpXF::CreatePattern()
    1482           0 :             if( pXF ) pXF->SetAllUsedFlags( true );
    1483             :             // use existing "Default" style sheet
    1484           0 :             mpStyleSheet = static_cast< ScStyleSheet* >( GetStyleSheetPool().Find(
    1485           0 :                 ScGlobal::GetRscString( STR_STYLENAME_STANDARD ), SFX_STYLE_FAMILY_PARA ) );
    1486             :             OSL_ENSURE( mpStyleSheet, "XclImpStyle::CreateStyleSheet - Default style not found" );
    1487           0 :             bCreatePattern = true;
    1488             :         }
    1489             :         else
    1490             :         {
    1491             :             /*  #i103281# do not create another style sheet of the same name,
    1492             :                 if it exists already. This is needed to prevent that styles
    1493             :                 pasted from clipboard get duplicated over and over. */
    1494           0 :             mpStyleSheet = static_cast< ScStyleSheet* >( GetStyleSheetPool().Find( maFinalName, SFX_STYLE_FAMILY_PARA ) );
    1495           0 :             if( !mpStyleSheet )
    1496             :             {
    1497           0 :                 mpStyleSheet = &static_cast< ScStyleSheet& >( GetStyleSheetPool().Make( maFinalName, SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_USERDEF ) );
    1498           0 :                 bCreatePattern = true;
    1499             :             }
    1500             :         }
    1501             : 
    1502             :         // bDefStyle==true omits default pool items in CreatePattern()
    1503           0 :         if( bCreatePattern && mpStyleSheet && pXF )
    1504           0 :             mpStyleSheet->GetItemSet().Put( pXF->CreatePattern( bDefStyle ).GetItemSet() );
    1505             :     }
    1506           0 :     return mpStyleSheet;
    1507             : }
    1508             : 
    1509           0 : void XclImpStyle::CreateUserStyle( const OUString& rFinalName )
    1510             : {
    1511           0 :     maFinalName = rFinalName;
    1512           0 :     if( !IsBuiltin() || mbCustom )
    1513           0 :         CreateStyleSheet();
    1514           0 : }
    1515             : 
    1516           0 : XclImpXFBuffer::XclImpXFBuffer( const XclImpRoot& rRoot ) :
    1517           0 :     XclImpRoot( rRoot )
    1518             : {
    1519           0 : }
    1520             : 
    1521           0 : void XclImpXFBuffer::Initialize()
    1522             : {
    1523           0 :     maXFList.clear();
    1524           0 :     maBuiltinStyles.clear();
    1525           0 :     maUserStyles.clear();
    1526           0 :     maStylesByXf.clear();
    1527           0 : }
    1528             : 
    1529           0 : void XclImpXFBuffer::ReadXF( XclImpStream& rStrm )
    1530             : {
    1531           0 :     XclImpXF* pXF = new XclImpXF( GetRoot() );
    1532           0 :     pXF->ReadXF( rStrm );
    1533           0 :     maXFList.push_back( pXF );
    1534           0 : }
    1535             : 
    1536           0 : void XclImpXFBuffer::ReadStyle( XclImpStream& rStrm )
    1537             : {
    1538           0 :     XclImpStyle* pStyle = new XclImpStyle( GetRoot() );
    1539           0 :     pStyle->ReadStyle( rStrm );
    1540           0 :     (pStyle->IsBuiltin() ? maBuiltinStyles : maUserStyles).push_back( pStyle );
    1541             :     OSL_ENSURE( maStylesByXf.count( pStyle->GetXfId() ) == 0, "XclImpXFBuffer::ReadStyle - multiple styles with equal XF identifier" );
    1542           0 :     maStylesByXf[ pStyle->GetXfId() ] = pStyle;
    1543           0 : }
    1544             : 
    1545           0 : sal_uInt16 XclImpXFBuffer::GetFontIndex( sal_uInt16 nXFIndex ) const
    1546             : {
    1547           0 :     const XclImpXF* pXF = GetXF( nXFIndex );
    1548           0 :     return pXF ? pXF->GetFontIndex() : EXC_FONT_NOTFOUND;
    1549             : }
    1550             : 
    1551           0 : const XclImpFont* XclImpXFBuffer::GetFont( sal_uInt16 nXFIndex ) const
    1552             : {
    1553           0 :     return GetFontBuffer().GetFont( GetFontIndex( nXFIndex ) );
    1554             : }
    1555             : 
    1556             : namespace {
    1557             : 
    1558             : /** Functor for case-insensitive string comparison, usable in maps etc. */
    1559             : struct IgnoreCaseCompare
    1560             : {
    1561           0 :     inline bool operator()( const OUString& rName1, const OUString& rName2 ) const
    1562           0 :         { return rName1.compareToIgnoreAsciiCase( rName2 ) < 0; }
    1563             : };
    1564             : 
    1565             : } // namespace
    1566             : 
    1567           0 : void XclImpXFBuffer::CreateUserStyles()
    1568             : {
    1569             :     // calculate final names of all styles
    1570             :     typedef ::std::map< OUString, XclImpStyle*, IgnoreCaseCompare > CellStyleNameMap;
    1571             :     typedef ::std::vector< XclImpStyle* > XclImpStyleVector;
    1572             : 
    1573           0 :     CellStyleNameMap aCellStyles;
    1574           0 :     XclImpStyleVector aConflictNameStyles;
    1575             : 
    1576             :     /*  First, reserve style names that are built-in in Calc. This causes that
    1577             :         imported cell styles get different unused names and thus do not try to
    1578             :         overwrite these built-in styles. For BIFF4 workbooks (which contain a
    1579             :         separate list of cell styles per sheet), reserve all existing styles if
    1580             :         current sheet is not the first sheet (this styles buffer will be
    1581             :         initialized again for every new sheet). This will create unique names
    1582             :         for styles in different sheets with the same name. Assuming that the
    1583             :         BIFF4W import filter is never used to import from clipboard... */
    1584           0 :     bool bReserveAll = (GetBiff() == EXC_BIFF4) && (GetCurrScTab() > 0);
    1585           0 :     SfxStyleSheetIterator aStyleIter( GetDoc().GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
    1586           0 :     OUString aStandardName = ScGlobal::GetRscString( STR_STYLENAME_STANDARD );
    1587           0 :     for( SfxStyleSheetBase* pStyleSheet = aStyleIter.First(); pStyleSheet; pStyleSheet = aStyleIter.Next() )
    1588           0 :         if( (pStyleSheet->GetName() != aStandardName) && (bReserveAll || !pStyleSheet->IsUserDefined()) )
    1589           0 :             if( aCellStyles.count( pStyleSheet->GetName() ) == 0 )
    1590           0 :                 aCellStyles[ pStyleSheet->GetName() ] = 0;
    1591             : 
    1592             :     /*  Calculate names of built-in styles. Store styles with reserved names
    1593             :         in the aConflictNameStyles list. */
    1594           0 :     for( XclImpStyleList::iterator itStyle = maBuiltinStyles.begin(); itStyle != maBuiltinStyles.end(); ++itStyle )
    1595             :     {
    1596           0 :         OUString aStyleName = XclTools::GetBuiltInStyleName( itStyle->GetBuiltinId(), itStyle->GetName(), itStyle->GetLevel() );
    1597             :         OSL_ENSURE( bReserveAll || (aCellStyles.count( aStyleName ) == 0),
    1598             :             "XclImpXFBuffer::CreateUserStyles - multiple styles with equal built-in identifier" );
    1599           0 :         if( aCellStyles.count( aStyleName ) > 0 )
    1600           0 :             aConflictNameStyles.push_back( &(*itStyle) );
    1601             :         else
    1602           0 :             aCellStyles[ aStyleName ] = &(*itStyle);
    1603           0 :     }
    1604             : 
    1605             :     /*  Calculate names of user defined styles. Store styles with reserved
    1606             :         names in the aConflictNameStyles list. */
    1607           0 :     for( XclImpStyleList::iterator itStyle = maUserStyles.begin(); itStyle != maUserStyles.end(); ++itStyle )
    1608             :     {
    1609             :         // #i1624# #i1768# ignore unnamed user styles
    1610           0 :         if( !itStyle->GetName().isEmpty() )
    1611             :         {
    1612           0 :             if( aCellStyles.count( itStyle->GetName() ) > 0 )
    1613           0 :                 aConflictNameStyles.push_back( &(*itStyle) );
    1614             :             else
    1615           0 :                 aCellStyles[ itStyle->GetName() ] = &(*itStyle);
    1616             :         }
    1617             :     }
    1618             : 
    1619             :     // find unused names for all styles with conflicting names
    1620           0 :     for( XclImpStyleVector::iterator aIt = aConflictNameStyles.begin(), aEnd = aConflictNameStyles.end(); aIt != aEnd; ++aIt )
    1621             :     {
    1622           0 :         XclImpStyle* pStyle = *aIt;
    1623           0 :         OUString aUnusedName;
    1624           0 :         sal_Int32 nIndex = 0;
    1625           0 :         do
    1626             :         {
    1627           0 :             aUnusedName = pStyle->GetName() + " " + OUString::number( ++nIndex );
    1628             :         }
    1629           0 :         while( aCellStyles.count( aUnusedName ) > 0 );
    1630           0 :         aCellStyles[ aUnusedName ] = pStyle;
    1631           0 :     }
    1632             : 
    1633             :     // set final names and create user-defined and modified built-in cell styles
    1634           0 :     for( CellStyleNameMap::iterator aIt = aCellStyles.begin(), aEnd = aCellStyles.end(); aIt != aEnd; ++aIt )
    1635           0 :         if( aIt->second )
    1636           0 :             aIt->second->CreateUserStyle( aIt->first );
    1637           0 : }
    1638             : 
    1639           0 : ScStyleSheet* XclImpXFBuffer::CreateStyleSheet( sal_uInt16 nXFIndex )
    1640             : {
    1641           0 :     XclImpStyleMap::iterator aIt = maStylesByXf.find( nXFIndex );
    1642           0 :     return (aIt == maStylesByXf.end()) ? 0 : aIt->second->CreateStyleSheet();
    1643             : }
    1644             : 
    1645             : // Buffer for XF indexes in cells =============================================
    1646             : 
    1647           0 : IMPL_FIXEDMEMPOOL_NEWDEL( XclImpXFRange )
    1648             : 
    1649           0 : bool XclImpXFRange::Expand( SCROW nScRow, const XclImpXFIndex& rXFIndex )
    1650             : {
    1651           0 :     if( maXFIndex != rXFIndex )
    1652           0 :         return false;
    1653             : 
    1654           0 :     if( mnScRow2 + 1 == nScRow )
    1655             :     {
    1656           0 :         ++mnScRow2;
    1657           0 :         return true;
    1658             :     }
    1659           0 :     if( mnScRow1 > 0 && (mnScRow1 - 1 == nScRow) )
    1660             :     {
    1661           0 :         --mnScRow1;
    1662           0 :         return true;
    1663             :     }
    1664             : 
    1665           0 :     return false;
    1666             : }
    1667             : 
    1668           0 : bool XclImpXFRange::Expand( const XclImpXFRange& rNextRange )
    1669             : {
    1670             :     OSL_ENSURE( mnScRow2 < rNextRange.mnScRow1, "XclImpXFRange::Expand - rows out of order" );
    1671           0 :     if( (maXFIndex == rNextRange.maXFIndex) && (mnScRow2 + 1 == rNextRange.mnScRow1) )
    1672             :     {
    1673           0 :         mnScRow2 = rNextRange.mnScRow2;
    1674           0 :         return true;
    1675             :     }
    1676           0 :     return false;
    1677             : }
    1678             : 
    1679           0 : void XclImpXFRangeColumn::SetDefaultXF( const XclImpXFIndex& rXFIndex )
    1680             : {
    1681             :     // List should be empty when inserting the default column format.
    1682             :     // Later explicit SetXF() calls will break up this range.
    1683             :     OSL_ENSURE( maIndexList.empty(), "XclImpXFRangeColumn::SetDefaultXF - Setting Default Column XF is not empty" );
    1684             : 
    1685             :     // insert a complete row range with one insert.
    1686           0 :     maIndexList.push_back( new XclImpXFRange( 0, MAXROW, rXFIndex ) );
    1687           0 : }
    1688             : 
    1689           0 : void XclImpXFRangeColumn::SetXF( SCROW nScRow, const XclImpXFIndex& rXFIndex )
    1690             : {
    1691             :     XclImpXFRange* pPrevRange;
    1692             :     XclImpXFRange* pNextRange;
    1693             :     sal_uLong nNextIndex;
    1694             : 
    1695           0 :     Find( pPrevRange, pNextRange, nNextIndex, nScRow );
    1696             : 
    1697             :     // previous range:
    1698             :     // try to overwrite XF (if row is contained in) or try to expand range
    1699           0 :     if( pPrevRange )
    1700             :     {
    1701           0 :         if( pPrevRange->Contains( nScRow ) )        // overwrite old XF
    1702             :         {
    1703           0 :             if( rXFIndex == pPrevRange->maXFIndex )
    1704           0 :                 return;
    1705             : 
    1706           0 :             SCROW nFirstScRow = pPrevRange->mnScRow1;
    1707           0 :             SCROW nLastScRow = pPrevRange->mnScRow2;
    1708           0 :             sal_uLong nIndex = nNextIndex - 1;
    1709           0 :             XclImpXFRange* pThisRange = pPrevRange;
    1710           0 :             pPrevRange = (nIndex > 0 && nIndex <= maIndexList.size()) ? &(maIndexList[ nIndex - 1 ]) : 0;
    1711             : 
    1712           0 :             if( nFirstScRow == nLastScRow )         // replace solely XF
    1713             :             {
    1714           0 :                 pThisRange->maXFIndex = rXFIndex;
    1715           0 :                 TryConcatPrev( nNextIndex );        // try to concat. next with this
    1716           0 :                 TryConcatPrev( nIndex );            // try to concat. this with previous
    1717             :             }
    1718           0 :             else if( nFirstScRow == nScRow )        // replace first XF
    1719             :             {
    1720           0 :                 ++(pThisRange->mnScRow1);
    1721             :                 // try to concatenate with previous of this
    1722           0 :                 if( !pPrevRange || !pPrevRange->Expand( nScRow, rXFIndex ) )
    1723           0 :                     Insert( new XclImpXFRange( nScRow, rXFIndex ), nIndex );
    1724             :             }
    1725           0 :             else if( nLastScRow == nScRow )         // replace last XF
    1726             :             {
    1727           0 :                 --(pThisRange->mnScRow2);
    1728           0 :                 if( !pNextRange || !pNextRange->Expand( nScRow, rXFIndex ) )
    1729           0 :                     Insert( new XclImpXFRange( nScRow, rXFIndex ), nNextIndex );
    1730             :             }
    1731             :             else                                    // insert in the middle of the range
    1732             :             {
    1733           0 :                 pThisRange->mnScRow1 = nScRow + 1;
    1734             :                 // List::Insert() moves entries towards end of list, so insert twice at nIndex
    1735           0 :                 Insert( new XclImpXFRange( nScRow, rXFIndex ), nIndex );
    1736           0 :                 Insert( new XclImpXFRange( nFirstScRow, nScRow - 1, pThisRange->maXFIndex ), nIndex );
    1737             :             }
    1738           0 :             return;
    1739             :         }
    1740           0 :         else if( pPrevRange->Expand( nScRow, rXFIndex ) )    // try to expand
    1741             :         {
    1742           0 :             TryConcatPrev( nNextIndex );    // try to concatenate next with expanded
    1743           0 :             return;
    1744             :         }
    1745             :     }
    1746             : 
    1747             :     // try to expand next range
    1748           0 :     if( pNextRange && pNextRange->Expand( nScRow, rXFIndex ) )
    1749           0 :         return;
    1750             : 
    1751             :     // create new range
    1752           0 :     Insert( new XclImpXFRange( nScRow, rXFIndex ), nNextIndex );
    1753             : }
    1754             : 
    1755           0 : void XclImpXFRangeColumn::Insert(XclImpXFRange* pXFRange, sal_uLong nIndex)
    1756             : {
    1757           0 :     maIndexList.insert( maIndexList.begin() + nIndex, pXFRange );
    1758           0 : }
    1759             : 
    1760           0 : void XclImpXFRangeColumn::Find(
    1761             :         XclImpXFRange*& rpPrevRange, XclImpXFRange*& rpNextRange,
    1762             :         sal_uLong& rnNextIndex, SCROW nScRow )
    1763             : {
    1764             : 
    1765             :     // test whether list is empty
    1766           0 :     if( maIndexList.empty() )
    1767             :     {
    1768           0 :         rpPrevRange = rpNextRange = 0;
    1769           0 :         rnNextIndex = 0;
    1770           0 :         return;
    1771             :     }
    1772             : 
    1773           0 :     rpPrevRange = &maIndexList.front();
    1774           0 :     rpNextRange = &maIndexList.back();
    1775             : 
    1776             :     // test whether row is at end of list (contained in or behind last range)
    1777             :     // rpPrevRange will contain a possible existing row
    1778           0 :     if( rpNextRange->mnScRow1 <= nScRow )
    1779             :     {
    1780           0 :         rpPrevRange = rpNextRange;
    1781           0 :         rpNextRange = 0;
    1782           0 :         rnNextIndex = maIndexList.size();
    1783           0 :         return;
    1784             :     }
    1785             : 
    1786             :     // test whether row is at beginning of list (really before first range)
    1787           0 :     if( nScRow < rpPrevRange->mnScRow1 )
    1788             :     {
    1789           0 :         rpNextRange = rpPrevRange;
    1790           0 :         rpPrevRange = 0;
    1791           0 :         rnNextIndex = 0;
    1792           0 :         return;
    1793             :     }
    1794             : 
    1795             :     // loop: find range entries before and after new row
    1796             :     // break the loop if there is no more range between first and last -or-
    1797             :     // if rpPrevRange contains nScRow (rpNextRange will never contain nScRow)
    1798           0 :     sal_uLong nPrevIndex = 0;
    1799             :     sal_uLong nMidIndex;
    1800           0 :     rnNextIndex = maIndexList.size() - 1;
    1801             :     XclImpXFRange* pMidRange;
    1802           0 :     while( ((rnNextIndex - nPrevIndex) > 1) && (rpPrevRange->mnScRow2 < nScRow) )
    1803             :     {
    1804           0 :         nMidIndex = (nPrevIndex + rnNextIndex) / 2;
    1805           0 :         pMidRange = &maIndexList[nMidIndex];
    1806             :         OSL_ENSURE( pMidRange, "XclImpXFRangeColumn::Find - missing XF index range" );
    1807           0 :         if( nScRow < pMidRange->mnScRow1 )      // row is really before pMidRange
    1808             :         {
    1809           0 :             rpNextRange = pMidRange;
    1810           0 :             rnNextIndex = nMidIndex;
    1811             :         }
    1812             :         else                                    // row is in or after pMidRange
    1813             :         {
    1814           0 :             rpPrevRange = pMidRange;
    1815           0 :             nPrevIndex = nMidIndex;
    1816             :         }
    1817             :     }
    1818             : 
    1819             :     // find next rpNextRange if rpPrevRange contains nScRow
    1820           0 :     if( nScRow <= rpPrevRange->mnScRow2 )
    1821             :     {
    1822           0 :         rnNextIndex = nPrevIndex + 1;
    1823           0 :         rpNextRange = &maIndexList[rnNextIndex];
    1824             :     }
    1825             : }
    1826             : 
    1827           0 : void XclImpXFRangeColumn::TryConcatPrev( sal_uLong nIndex )
    1828             : {
    1829           0 :     if( !nIndex || nIndex >= maIndexList.size() )
    1830           0 :         return;
    1831             : 
    1832           0 :     XclImpXFRange& prevRange = maIndexList[ nIndex - 1 ];
    1833           0 :     XclImpXFRange& nextRange = maIndexList[ nIndex ];
    1834             : 
    1835           0 :     if( prevRange.Expand( nextRange ) )
    1836           0 :         maIndexList.erase( maIndexList.begin() + nIndex );
    1837             : }
    1838             : 
    1839           0 : XclImpXFRangeBuffer::XclImpXFRangeBuffer( const XclImpRoot& rRoot ) :
    1840           0 :     XclImpRoot( rRoot )
    1841             : {
    1842           0 : }
    1843             : 
    1844           0 : XclImpXFRangeBuffer::~XclImpXFRangeBuffer()
    1845             : {
    1846           0 : }
    1847             : 
    1848           0 : void XclImpXFRangeBuffer::Initialize()
    1849             : {
    1850           0 :     maColumns.clear();
    1851           0 :     maHyperlinks.clear();
    1852           0 :     maMergeList.RemoveAll();
    1853           0 : }
    1854             : 
    1855           0 : void XclImpXFRangeBuffer::SetXF( const ScAddress& rScPos, sal_uInt16 nXFIndex, XclImpXFInsertMode eMode )
    1856             : {
    1857           0 :     SCCOL nScCol = rScPos.Col();
    1858           0 :     SCROW nScRow = rScPos.Row();
    1859             : 
    1860             :     // set cell XF's
    1861           0 :     size_t nIndex = static_cast< size_t >( nScCol );
    1862           0 :     if( maColumns.size() <= nIndex )
    1863           0 :         maColumns.resize( nIndex + 1 );
    1864           0 :     if( !maColumns[ nIndex ] )
    1865           0 :         maColumns[ nIndex ].reset( new XclImpXFRangeColumn );
    1866             :     // remember all Boolean cells, they will get 'Standard' number format
    1867           0 :     maColumns[ nIndex ]->SetXF( nScRow, XclImpXFIndex( nXFIndex, eMode == xlXFModeBoolCell ) );
    1868             : 
    1869             :     // set "center across selection" and "fill" attribute for all following empty cells
    1870             :     // ignore it on row default XFs
    1871           0 :     if( eMode != xlXFModeRow )
    1872             :     {
    1873           0 :         const XclImpXF* pXF = GetXFBuffer().GetXF( nXFIndex );
    1874           0 :         if( pXF && ((pXF->GetHorAlign() == EXC_XF_HOR_CENTER_AS) || (pXF->GetHorAlign() == EXC_XF_HOR_FILL)) )
    1875             :         {
    1876             :             // expand last merged range if this attribute is set repeatedly
    1877           0 :             ScRange* pRange = maMergeList.empty() ? NULL : maMergeList.back();
    1878           0 :             if (pRange && (pRange->aEnd.Row() == nScRow) && (pRange->aEnd.Col() + 1 == nScCol) && (eMode == xlXFModeBlank))
    1879           0 :                 pRange->aEnd.IncCol();
    1880           0 :             else if( eMode != xlXFModeBlank )   // do not merge empty cells
    1881           0 :                 SetMerge( nScCol, nScRow );
    1882             :         }
    1883             :     }
    1884           0 : }
    1885             : 
    1886           0 : void XclImpXFRangeBuffer::SetXF( const ScAddress& rScPos, sal_uInt16 nXFIndex )
    1887             : {
    1888           0 :     SetXF( rScPos, nXFIndex, xlXFModeCell );
    1889           0 : }
    1890             : 
    1891           0 : void XclImpXFRangeBuffer::SetBlankXF( const ScAddress& rScPos, sal_uInt16 nXFIndex )
    1892             : {
    1893           0 :     SetXF( rScPos, nXFIndex, xlXFModeBlank );
    1894           0 : }
    1895             : 
    1896           0 : void XclImpXFRangeBuffer::SetBoolXF( const ScAddress& rScPos, sal_uInt16 nXFIndex )
    1897             : {
    1898           0 :     SetXF( rScPos, nXFIndex, xlXFModeBoolCell );
    1899           0 : }
    1900             : 
    1901           0 : void XclImpXFRangeBuffer::SetRowDefXF( SCROW nScRow, sal_uInt16 nXFIndex )
    1902             : {
    1903           0 :     for( SCCOL nScCol = 0; nScCol <= MAXCOL; ++nScCol )
    1904           0 :         SetXF( ScAddress( nScCol, nScRow, 0 ), nXFIndex, xlXFModeRow );
    1905           0 : }
    1906             : 
    1907           0 : void XclImpXFRangeBuffer::SetColumnDefXF( SCCOL nScCol, sal_uInt16 nXFIndex )
    1908             : {
    1909             :     // our array should not have values when creating the default column format.
    1910           0 :     size_t nIndex = static_cast< size_t >( nScCol );
    1911           0 :     if( maColumns.size() <= nIndex )
    1912           0 :         maColumns.resize( nIndex + 1 );
    1913             :     OSL_ENSURE( !maColumns[ nIndex ], "XclImpXFRangeBuffer::SetColumnDefXF - default column of XFs already has values" );
    1914           0 :     maColumns[ nIndex ].reset( new XclImpXFRangeColumn );
    1915           0 :     maColumns[ nIndex ]->SetDefaultXF( XclImpXFIndex( nXFIndex ) );
    1916           0 : }
    1917             : 
    1918           0 : void XclImpXFRangeBuffer::SetBorderLine( const ScRange& rRange, SCTAB nScTab, sal_uInt16 nLine )
    1919             : {
    1920           0 :     SCCOL nFromScCol = (nLine == BOX_LINE_RIGHT) ? rRange.aEnd.Col() : rRange.aStart.Col();
    1921           0 :     SCROW nFromScRow = (nLine == BOX_LINE_BOTTOM) ? rRange.aEnd.Row() : rRange.aStart.Row();
    1922           0 :     ScDocument& rDoc = GetDoc();
    1923             : 
    1924             :     const SvxBoxItem* pFromItem = static_cast< const SvxBoxItem* >(
    1925           0 :         rDoc.GetAttr( nFromScCol, nFromScRow, nScTab, ATTR_BORDER ) );
    1926             :     const SvxBoxItem* pToItem = static_cast< const SvxBoxItem* >(
    1927           0 :         rDoc.GetAttr( rRange.aStart.Col(), rRange.aStart.Row(), nScTab, ATTR_BORDER ) );
    1928             : 
    1929           0 :     SvxBoxItem aNewItem( *pToItem );
    1930           0 :     aNewItem.SetLine( pFromItem->GetLine( nLine ), nLine );
    1931           0 :     rDoc.ApplyAttr( rRange.aStart.Col(), rRange.aStart.Row(), nScTab, aNewItem );
    1932           0 : }
    1933             : 
    1934           0 : void XclImpXFRangeBuffer::SetHyperlink( const XclRange& rXclRange, const OUString& rUrl )
    1935             : {
    1936           0 :     maHyperlinks.push_back( XclImpHyperlinkRange( rXclRange, rUrl ) );
    1937           0 : }
    1938             : 
    1939           0 : void XclImpXFRangeBuffer::SetMerge( SCCOL nScCol, SCROW nScRow )
    1940             : {
    1941           0 :     maMergeList.Append( ScRange( nScCol, nScRow, 0 ) );
    1942           0 : }
    1943             : 
    1944           0 : void XclImpXFRangeBuffer::SetMerge( SCCOL nScCol1, SCROW nScRow1, SCCOL nScCol2, SCROW nScRow2 )
    1945             : {
    1946           0 :     if( (nScCol1 < nScCol2) || (nScRow1 < nScRow2) )
    1947           0 :         maMergeList.Append( ScRange( nScCol1, nScRow1, 0, nScCol2, nScRow2, 0 ) );
    1948           0 : }
    1949             : 
    1950           0 : void XclImpXFRangeBuffer::Finalize()
    1951             : {
    1952           0 :     ScDocument& rDoc = GetDoc();
    1953           0 :     SCTAB nScTab = GetCurrScTab();
    1954             : 
    1955             :     // apply patterns
    1956           0 :     XclImpXFBuffer& rXFBuffer = GetXFBuffer();
    1957           0 :     for( XclImpXFRangeColumnVec::const_iterator aVBeg = maColumns.begin(), aVEnd = maColumns.end(), aVIt = aVBeg; aVIt != aVEnd; ++aVIt )
    1958             :     {
    1959             :         // apply all cell styles of an existing column
    1960           0 :         if( aVIt->get() )
    1961             :         {
    1962           0 :             XclImpXFRangeColumn& rColumn = **aVIt;
    1963           0 :             SCCOL nScCol = static_cast< SCCOL >( aVIt - aVBeg );
    1964           0 :             list<ScAttrEntry> aAttrs;
    1965             : 
    1966           0 :             for (XclImpXFRangeColumn::IndexList::iterator itr = rColumn.begin(), itrEnd = rColumn.end();
    1967             :                  itr != itrEnd; ++itr)
    1968             :             {
    1969           0 :                 XclImpXFRange& rStyle = *itr;
    1970           0 :                 const XclImpXFIndex& rXFIndex = rStyle.maXFIndex;
    1971           0 :                 XclImpXF* pXF = rXFBuffer.GetXF( rXFIndex.GetXFIndex() );
    1972           0 :                 if (!pXF)
    1973           0 :                     continue;
    1974             : 
    1975           0 :                 sal_uInt32 nForceScNumFmt = rXFIndex.IsBoolCell() ?
    1976           0 :                     GetNumFmtBuffer().GetStdScNumFmt() : NUMBERFORMAT_ENTRY_NOT_FOUND;
    1977             : 
    1978           0 :                 pXF->ApplyPatternToAttrList(aAttrs, rStyle.mnScRow1, rStyle.mnScRow2, nForceScNumFmt);
    1979             :             }
    1980             : 
    1981           0 :             if (aAttrs.empty() || aAttrs.back().nRow != MAXROW)
    1982             :             {
    1983             :                 ScAttrEntry aEntry;
    1984           0 :                 aEntry.nRow = MAXROW;
    1985           0 :                 aEntry.pPattern = rDoc.GetDefPattern();
    1986           0 :                 aAttrs.push_back(aEntry);
    1987             :             }
    1988             : 
    1989           0 :             size_t nAttrSize = aAttrs.size();
    1990             :             assert(nAttrSize > 0);
    1991           0 :             ScAttrEntry* pData = new ScAttrEntry[nAttrSize];
    1992           0 :             list<ScAttrEntry>::const_iterator itr = aAttrs.begin(), itrEnd = aAttrs.end();
    1993           0 :             for (size_t i = 0; itr != itrEnd; ++itr, ++i)
    1994           0 :                 pData[i] = *itr;
    1995             : 
    1996           0 :             rDoc.SetAttrEntries(nScCol, nScTab, pData, static_cast<SCSIZE>(nAttrSize));
    1997             :         }
    1998             :     }
    1999             : 
    2000             :     // insert hyperlink cells
    2001           0 :     for( XclImpHyperlinkList::const_iterator aLIt = maHyperlinks.begin(), aLEnd = maHyperlinks.end(); aLIt != aLEnd; ++aLIt )
    2002           0 :         XclImpHyperlink::InsertUrl( GetRoot(), aLIt->first, aLIt->second );
    2003             : 
    2004             :     // apply cell merging
    2005           0 :     for ( size_t i = 0, nRange = maMergeList.size(); i < nRange; ++i )
    2006             :     {
    2007           0 :         const ScRange* pRange = maMergeList[ i ];
    2008           0 :         const ScAddress& rStart = pRange->aStart;
    2009           0 :         const ScAddress& rEnd = pRange->aEnd;
    2010           0 :         bool bMultiCol = rStart.Col() != rEnd.Col();
    2011           0 :         bool bMultiRow = rStart.Row() != rEnd.Row();
    2012             :         // set correct right border
    2013           0 :         if( bMultiCol )
    2014           0 :             SetBorderLine( *pRange, nScTab, BOX_LINE_RIGHT );
    2015             :         // set correct lower border
    2016           0 :         if( bMultiRow )
    2017           0 :             SetBorderLine( *pRange, nScTab, BOX_LINE_BOTTOM );
    2018             :         // do merge
    2019           0 :         if( bMultiCol || bMultiRow )
    2020           0 :             rDoc.DoMerge( nScTab, rStart.Col(), rStart.Row(), rEnd.Col(), rEnd.Row() );
    2021             :         // #i93609# merged range in a single row: test if manual row height is needed
    2022           0 :         if( !bMultiRow )
    2023             :         {
    2024           0 :             bool bTextWrap = static_cast< const SfxBoolItem* >( rDoc.GetAttr( rStart.Col(), rStart.Row(), rStart.Tab(), ATTR_LINEBREAK ) )->GetValue();
    2025           0 :             if( !bTextWrap && (rDoc.GetCellType( rStart ) == CELLTYPE_EDIT) )
    2026           0 :                 if (const EditTextObject* pEditObj = rDoc.GetEditText(rStart))
    2027           0 :                     bTextWrap = pEditObj->GetParagraphCount() > 1;
    2028           0 :             if( bTextWrap )
    2029           0 :                 GetOldRoot().pColRowBuff->SetManualRowHeight( rStart.Row() );
    2030             :         }
    2031             :     }
    2032           0 : }
    2033             : 
    2034             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10