LCOV - code coverage report
Current view: top level - libreoffice/sc/source/filter/excel - impop.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 328 625 52.5 %
Date: 2012-12-27 Functions: 42 69 60.9 %
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 "imp_op.hxx"
      21             : 
      22             : #include <filter/msfilter/countryid.hxx>
      23             : 
      24             : #include "scitems.hxx"
      25             : #include <editeng/eeitem.hxx>
      26             : 
      27             : #include <editeng/editdata.hxx>
      28             : #include <editeng/editeng.hxx>
      29             : #include <editeng/editobj.hxx>
      30             : #include <editeng/editstat.hxx>
      31             : #include <editeng/flditem.hxx>
      32             : #include <svx/pageitem.hxx>
      33             : #include <editeng/colritem.hxx>
      34             : #include <sfx2/printer.hxx>
      35             : #include <sfx2/docfile.hxx>
      36             : #include <svl/zforlist.hxx>
      37             : 
      38             : #include <sfx2/objsh.hxx>
      39             : #include "tools/urlobj.hxx"
      40             : #include "docuno.hxx"
      41             : 
      42             : #include "cell.hxx"
      43             : #include "document.hxx"
      44             : #include "rangenam.hxx"
      45             : #include "compiler.hxx"
      46             : #include "patattr.hxx"
      47             : #include "attrib.hxx"
      48             : #include "globstr.hrc"
      49             : #include "global.hxx"
      50             : #include "markdata.hxx"
      51             : #include "olinetab.hxx"
      52             : #include "stlsheet.hxx"
      53             : #include "stlpool.hxx"
      54             : #include "viewopti.hxx"
      55             : #include "docoptio.hxx"
      56             : #include "scextopt.hxx"
      57             : #include "editutil.hxx"
      58             : #include "filtopt.hxx"
      59             : #include "scerrors.hxx"
      60             : #include "unonames.hxx"
      61             : #include "paramisc.hxx"
      62             : #include "postit.hxx"
      63             : 
      64             : #include "fapihelper.hxx"
      65             : #include "xltools.hxx"
      66             : #include "xltable.hxx"
      67             : #include "xlview.hxx"
      68             : #include "xltracer.hxx"
      69             : #include "xihelper.hxx"
      70             : #include "xipage.hxx"
      71             : #include "xiview.hxx"
      72             : #include "xilink.hxx"
      73             : #include "xiescher.hxx"
      74             : #include "xicontent.hxx"
      75             : 
      76             : #include "excimp8.hxx"
      77             : #include "excform.hxx"
      78             : 
      79             : #if defined( WNT )
      80             : #include <math.h>
      81             : #else
      82             : #include <stdlib.h>
      83             : #endif
      84             : 
      85             : using namespace ::com::sun::star;
      86             : 
      87             : 
      88             : const double ImportExcel::fExcToTwips =
      89             :     ( double ) TWIPS_PER_CHAR / 256.0;
      90             : 
      91             : 
      92          21 : ImportTyp::ImportTyp( ScDocument* pDoc, CharSet eQ )
      93             : {
      94          21 :     eQuellChar = eQ;
      95          21 :     pD = pDoc;
      96          21 : }
      97             : 
      98             : 
      99          21 : ImportTyp::~ImportTyp()
     100             : {
     101          21 : }
     102             : 
     103             : 
     104           0 : FltError ImportTyp::Read()
     105             : {
     106           0 :     return eERR_INTERN;
     107             : }
     108             : 
     109             : 
     110          20 : ImportExcel::ImportExcel( XclImpRootData& rImpData, SvStream& rStrm ):
     111             :     ImportTyp( &rImpData.mrDoc, rImpData.meTextEnc ),
     112             :     XclImpRoot( rImpData ),
     113          20 :     maStrm( rStrm, GetRoot() ),
     114             :     aIn( maStrm ),
     115             :     maScOleSize( ScAddress::INITIALIZE_INVALID ),
     116             :     mnLastRefIdx( 0 ),
     117             :     mnIxfeIndex( 0 ),
     118             :     mbBiff2HasXfs( false ),
     119          40 :     mbBiff2HasXfsValid( false )
     120             : {
     121          20 :     nBdshtTab = 0;
     122             : 
     123             :     // Root-Daten fuellen - nach new's ohne Root als Parameter
     124          20 :     pExcRoot = &GetOldRoot();
     125          20 :     pExcRoot->pIR = this;   // ExcRoot -> XclImpRoot
     126          20 :     pExcRoot->eDateiTyp = BiffX;
     127          20 :     pExcRoot->pExtSheetBuff = new ExtSheetBuffer( pExcRoot );   //&aExtSheetBuff;
     128          20 :     pExcRoot->pShrfmlaBuff = new ShrfmlaBuffer( pExcRoot );     //&aShrfrmlaBuff;
     129          20 :     pExcRoot->pExtNameBuff = new ExtNameBuff ( *this );
     130             : 
     131          20 :     pExtNameBuff = new NameBuffer( pExcRoot );          //prevent empty rootdata
     132          20 :     pExtNameBuff->SetBase( 1 );
     133             : 
     134          20 :     pOutlineListBuffer = new XclImpOutlineListBuffer( );
     135             : 
     136             :     // ab Biff8
     137          20 :     pFormConv = pExcRoot->pFmlaConverter = new ExcelToSc( GetRoot() );
     138             : 
     139          20 :     bTabTruncated = false;
     140             : 
     141             :     // Excel-Dokument per Default auf 31.12.1899, entspricht Excel-Einstellungen mit 1.1.1900
     142          20 :     ScDocOptions aOpt = pD->GetDocOptions();
     143          20 :     aOpt.SetDate( 30, 12, 1899 );
     144          20 :     pD->SetDocOptions( aOpt );
     145          20 :     pD->GetFormatTable()->ChangeNullDate( 30, 12, 1899 );
     146             : 
     147          20 :     ScDocOptions aDocOpt( pD->GetDocOptions() );
     148          20 :     aDocOpt.SetIgnoreCase( sal_True );              // always in Excel
     149          20 :     aDocOpt.SetFormulaRegexEnabled( false );    // regular expressions? what's that?
     150          20 :     aDocOpt.SetLookUpColRowNames( false );      // default: no natural language refs
     151          20 :     pD->SetDocOptions( aDocOpt );
     152          20 : }
     153             : 
     154             : 
     155          40 : ImportExcel::~ImportExcel( void )
     156             : {
     157          20 :     GetDoc().SetSrcCharSet( GetTextEncoding() );
     158             : 
     159          20 :     delete pExtNameBuff;
     160             : 
     161          20 :     delete pOutlineListBuffer;
     162             : 
     163          20 :     delete pFormConv;
     164          20 : }
     165             : 
     166             : 
     167           0 : void ImportExcel::ReadFileSharing()
     168             : {
     169             :     sal_uInt16 nRecommendReadOnly, nPasswordHash;
     170           0 :     maStrm >> nRecommendReadOnly >> nPasswordHash;
     171             : 
     172           0 :     if( (nRecommendReadOnly != 0) || (nPasswordHash != 0) )
     173             :     {
     174           0 :         if( SfxItemSet* pItemSet = GetMedium().GetItemSet() )
     175           0 :             pItemSet->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
     176             : 
     177           0 :         if( SfxObjectShell* pShell = GetDocShell() )
     178             :         {
     179           0 :             if( nRecommendReadOnly != 0 )
     180           0 :                 pShell->SetLoadReadonly( sal_True );
     181           0 :             if( nPasswordHash != 0 )
     182           0 :                 pShell->SetModifyPasswordHash( nPasswordHash );
     183             :         }
     184             :     }
     185           0 : }
     186             : 
     187        4468 : sal_uInt16 ImportExcel::ReadXFIndex( const ScAddress& rScPos, bool bBiff2 )
     188             : {
     189        4468 :     sal_uInt16 nXFIdx = 0;
     190        4468 :     if( bBiff2 )
     191             :     {
     192             :         /*  #i71453# On first call, check if the file contains XF records (by
     193             :             trying to access the first XF with index 0). If there are no XFs,
     194             :             the explicit formatting information contained in each cell record
     195             :             will be used instead. */
     196           0 :         if( !mbBiff2HasXfsValid )
     197             :         {
     198           0 :             mbBiff2HasXfsValid = true;
     199           0 :             mbBiff2HasXfs = GetXFBuffer().GetXF( 0 ) != 0;
     200             :         }
     201             :         // read formatting information (includes the XF identifier)
     202             :         sal_uInt8 nFlags1, nFlags2, nFlags3;
     203           0 :         maStrm >> nFlags1 >> nFlags2 >> nFlags3;
     204             :         /*  If the file contains XFs, extract and set the XF identifier,
     205             :             otherwise get the explicit formatting. */
     206           0 :         if( mbBiff2HasXfs )
     207             :         {
     208           0 :             nXFIdx = ::extract_value< sal_uInt16 >( nFlags1, 0, 6 );
     209             :             /*  If the identifier is equal to 63, then the real identifier is
     210             :                 contained in the preceding IXFE record (stored in mnBiff2XfId). */
     211           0 :             if( nXFIdx == 63 )
     212           0 :                 nXFIdx = mnIxfeIndex;
     213             :         }
     214             :         else
     215             :         {
     216             :             /*  Let the XclImpXF class do the conversion of the imported
     217             :                 formatting. The XF buffer is empty, therefore will not do any
     218             :                 conversion based on the XF index later on. */
     219           0 :             XclImpXF::ApplyPatternForBiff2CellFormat( GetRoot(), rScPos, nFlags1, nFlags2, nFlags3 );
     220             :         }
     221             :     }
     222             :     else
     223        4468 :         aIn >> nXFIdx;
     224        4468 :     return nXFIdx;
     225             : }
     226             : 
     227          75 : void ImportExcel::ReadDimensions()
     228             : {
     229          75 :     XclRange aXclUsedArea( ScAddress::UNINITIALIZED );
     230          75 :     if( (maStrm.GetRecId() == EXC_ID2_DIMENSIONS) || (GetBiff() <= EXC_BIFF5) )
     231             :     {
     232           1 :         maStrm >> aXclUsedArea;
     233           1 :         if( (aXclUsedArea.GetColCount() > 1) && (aXclUsedArea.GetRowCount() > 1) )
     234             :         {
     235             :             // Excel stores first unused row/column index
     236           1 :             --aXclUsedArea.maLast.mnCol;
     237           1 :             --aXclUsedArea.maLast.mnRow;
     238             :             // create the Calc range
     239           1 :             SCTAB nScTab = GetCurrScTab();
     240           1 :             ScRange& rScUsedArea = GetExtDocOptions().GetOrCreateTabSettings( nScTab ).maUsedArea;
     241           1 :             GetAddressConverter().ConvertRange( rScUsedArea, aXclUsedArea, nScTab, nScTab, false );
     242             :             // if any error occurs in ConvertRange(), rScUsedArea keeps untouched
     243             :         }
     244             :     }
     245             :     else
     246             :     {
     247             :         sal_uInt32 nXclRow1, nXclRow2;
     248          74 :         maStrm >> nXclRow1 >> nXclRow2 >> aXclUsedArea.maFirst.mnCol >> aXclUsedArea.maLast.mnCol;
     249         137 :         if( (nXclRow1 < nXclRow2) && (aXclUsedArea.GetColCount() > 1) &&
     250          63 :             (nXclRow1 <= static_cast< sal_uInt32 >( GetScMaxPos().Row() )) )
     251             :         {
     252             :             // Excel stores first unused row/column index
     253          63 :             --nXclRow2;
     254          63 :             --aXclUsedArea.maLast.mnCol;
     255             :             // convert row indexes to 16-bit values
     256          63 :             aXclUsedArea.maFirst.mnRow = static_cast< sal_uInt16 >( nXclRow1 );
     257          63 :             aXclUsedArea.maLast.mnRow = limit_cast< sal_uInt16 >( nXclRow2, aXclUsedArea.maFirst.mnRow, SAL_MAX_UINT16 );
     258             :             // create the Calc range
     259          63 :             SCTAB nScTab = GetCurrScTab();
     260          63 :             ScRange& rScUsedArea = GetExtDocOptions().GetOrCreateTabSettings( nScTab ).maUsedArea;
     261          63 :             GetAddressConverter().ConvertRange( rScUsedArea, aXclUsedArea, nScTab, nScTab, false );
     262             :             // if any error occurs in ConvertRange(), rScUsedArea keeps untouched
     263             :         }
     264             :     }
     265          75 : }
     266             : 
     267         666 : void ImportExcel::ReadBlank()
     268             : {
     269         666 :     XclAddress aXclPos;
     270         666 :     aIn >> aXclPos;
     271             : 
     272         666 :     ScAddress aScPos( ScAddress::UNINITIALIZED );
     273         666 :     if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
     274             :     {
     275         666 :         sal_uInt16 nXFIdx = ReadXFIndex( aScPos, maStrm.GetRecId() == EXC_ID2_BLANK );
     276             : 
     277         666 :         GetXFRangeBuffer().SetBlankXF( aScPos, nXFIdx );
     278             :     }
     279         666 : }
     280             : 
     281           0 : void ImportExcel::ReadInteger()
     282             : {
     283           0 :     XclAddress aXclPos;
     284           0 :     maStrm >> aXclPos;
     285             : 
     286           0 :     ScAddress aScPos( ScAddress::UNINITIALIZED );
     287           0 :     if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
     288             :     {
     289           0 :         sal_uInt16 nXFIdx = ReadXFIndex( aScPos, true );
     290             :         sal_uInt16 nValue;
     291           0 :         maStrm >> nValue;
     292             : 
     293           0 :         GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
     294           0 :         GetDoc().PutCell( aScPos, new ScValueCell( nValue ) );
     295             :     }
     296           0 : }
     297             : 
     298        1852 : void ImportExcel::ReadNumber()
     299             : {
     300        1852 :     XclAddress aXclPos;
     301        1852 :     maStrm >> aXclPos;
     302             : 
     303        1852 :     ScAddress aScPos( ScAddress::UNINITIALIZED );
     304        1852 :     if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
     305             :     {
     306        1852 :         sal_uInt16 nXFIdx = ReadXFIndex( aScPos, maStrm.GetRecId() == EXC_ID2_NUMBER );
     307             :         double fValue;
     308        1852 :         maStrm >> fValue;
     309             : 
     310        1852 :         GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
     311        1852 :         GetDoc().PutCell( aScPos, new ScValueCell( fValue ) );
     312             :     }
     313        1852 : }
     314             : 
     315           0 : void ImportExcel::ReadLabel()
     316             : {
     317           0 :     XclAddress aXclPos;
     318           0 :     maStrm >> aXclPos;
     319             : 
     320           0 :     ScAddress aScPos( ScAddress::UNINITIALIZED );
     321           0 :     if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
     322             :     {
     323             :         /*  Record ID   BIFF    XF type     String type
     324             :             0x0004      2-7     3 byte      8-bit length, byte string
     325             :             0x0004      8       3 byte      16-bit length, unicode string
     326             :             0x0204      2-7     2 byte      16-bit length, byte string
     327             :             0x0204      8       2 byte      16-bit length, unicode string */
     328           0 :         bool bBiff2 = maStrm.GetRecId() == EXC_ID2_LABEL;
     329           0 :         sal_uInt16 nXFIdx = ReadXFIndex( aScPos, bBiff2 );
     330           0 :         XclStrFlags nFlags = (bBiff2 && (GetBiff() <= EXC_BIFF5)) ? EXC_STR_8BITLENGTH : EXC_STR_DEFAULT;
     331           0 :         XclImpString aString;
     332             : 
     333             :         // #i63105# use text encoding from FONT record
     334           0 :         rtl_TextEncoding eOldTextEnc = GetTextEncoding();
     335           0 :         if( const XclImpFont* pFont = GetXFBuffer().GetFont( nXFIdx ) )
     336           0 :             SetTextEncoding( pFont->GetFontEncoding() );
     337           0 :         aString.Read( maStrm, nFlags );
     338           0 :         SetTextEncoding( eOldTextEnc );
     339             : 
     340           0 :         GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
     341           0 :         if( ScBaseCell* pCell = XclImpStringHelper::CreateCell( GetRoot(), aString, nXFIdx ) )
     342           0 :             GetDoc().PutCell( aScPos, pCell );
     343             :     }
     344           0 : }
     345             : 
     346           0 : void ImportExcel::ReadBoolErr()
     347             : {
     348           0 :     XclAddress aXclPos;
     349           0 :     maStrm >> aXclPos;
     350             : 
     351           0 :     ScAddress aScPos( ScAddress::UNINITIALIZED );
     352           0 :     if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
     353             :     {
     354           0 :         sal_uInt16 nXFIdx = ReadXFIndex( aScPos, maStrm.GetRecId() == EXC_ID2_BOOLERR );
     355             :         sal_uInt8 nValue, nType;
     356           0 :         maStrm >> nValue >> nType;
     357             : 
     358           0 :         if( nType == EXC_BOOLERR_BOOL )
     359           0 :             GetXFRangeBuffer().SetBoolXF( aScPos, nXFIdx );
     360             :         else
     361           0 :             GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
     362             : 
     363             :         double fValue;
     364           0 :         const ScTokenArray* pScTokArr = ErrorToFormula( nType, nValue, fValue );
     365           0 :         ScFormulaCell* pCell = new ScFormulaCell( pD, aScPos, pScTokArr );
     366           0 :         pCell->SetHybridDouble( fValue );
     367           0 :         GetDoc().PutCell( aScPos, pCell );
     368             :     }
     369           0 : }
     370             : 
     371        1950 : void ImportExcel::ReadRk()
     372             : {
     373        1950 :     XclAddress aXclPos;
     374        1950 :     maStrm >> aXclPos;
     375             : 
     376        1950 :     ScAddress aScPos( ScAddress::UNINITIALIZED );
     377        1950 :     if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
     378             :     {
     379        1950 :         sal_uInt16 nXFIdx = ReadXFIndex( aScPos, false );
     380             :         sal_Int32 nRk;
     381        1950 :         maStrm >> nRk;
     382             : 
     383        1950 :         GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
     384        1950 :         GetDoc().PutCell( aScPos, new ScValueCell( XclTools::GetDoubleFromRK( nRk ) ) );
     385             :     }
     386        1950 : }
     387             : 
     388             : 
     389          18 : void ImportExcel::Window1()
     390             : {
     391          18 :     GetDocViewSettings().ReadWindow1( maStrm );
     392          18 : }
     393             : 
     394             : 
     395             : 
     396             : 
     397           0 : void ImportExcel::Row25( void )
     398             : {
     399             :     sal_uInt16  nRow, nRowHeight;
     400             : 
     401           0 :     aIn >> nRow;
     402           0 :     aIn.Ignore( 4 );   // Mic und Mac ueberspringen
     403             : 
     404           0 :     if( ValidRow( nRow ) )
     405             :     {
     406           0 :         aIn >> nRowHeight;  // direkt in Twips angegeben
     407           0 :         aIn.Ignore( 2 );
     408             : 
     409           0 :         if( GetBiff() == EXC_BIFF2 )
     410             :         {// -------------------- BIFF2
     411           0 :             pColRowBuff->SetHeight( nRow, nRowHeight );
     412             :         }
     413             :         else
     414             :         {// -------------------- BIFF5
     415             :             sal_uInt16  nGrbit;
     416             : 
     417           0 :             aIn.Ignore( 2 );   // reserved
     418           0 :             aIn >> nGrbit;
     419             : 
     420           0 :             sal_uInt8 nLevel = ::extract_value< sal_uInt8 >( nGrbit, 0, 3 );
     421           0 :             pRowOutlineBuff->SetLevel( nRow, nLevel, ::get_flag( nGrbit, EXC_ROW_COLLAPSED ) );
     422           0 :             pColRowBuff->SetRowSettings( nRow, nRowHeight, nGrbit );
     423             :         }
     424             :     }
     425           0 : }
     426             : 
     427             : 
     428           0 : void ImportExcel::Bof2( void )
     429             : {
     430             :     sal_uInt16 nSubType;
     431           0 :     maStrm.DisableDecryption();
     432           0 :     maStrm.Ignore( 2 );
     433           0 :     maStrm >> nSubType;
     434             : 
     435           0 :     if( nSubType == 0x0020 )        // Chart
     436           0 :         pExcRoot->eDateiTyp = Biff2C;
     437           0 :     else if( nSubType == 0x0040 )   // Macro
     438           0 :         pExcRoot->eDateiTyp = Biff2M;
     439             :     else                            // #i51490# Excel interprets invalid indexes as worksheet
     440           0 :         pExcRoot->eDateiTyp = Biff2;
     441           0 : }
     442             : 
     443             : 
     444          75 : void ImportExcel::Eof( void )
     445             : {
     446             :     //  POST: darf nur nach einer GUELTIGEN Tabelle gerufen werden!
     447          75 :     EndSheet();
     448          75 :     IncCurrScTab();
     449          75 : }
     450             : 
     451             : 
     452           1 : void ImportExcel::SheetPassword( void )
     453             : {
     454           1 :     if (GetRoot().GetBiff() != EXC_BIFF8)
     455           1 :         return;
     456             : 
     457           1 :     GetRoot().GetSheetProtectBuffer().ReadPasswordHash( aIn, GetCurrScTab() );
     458             : }
     459             : 
     460             : 
     461           0 : void ImportExcel::Externsheet( void )
     462             : {
     463           0 :     String aUrl, aTabName;
     464             :     bool bSameWorkBook;
     465           0 :     String aEncodedUrl( aIn.ReadByteString( false ) );
     466           0 :     XclImpUrlHelper::DecodeUrl( aUrl, aTabName, bSameWorkBook, *pExcRoot->pIR, aEncodedUrl );
     467           0 :     mnLastRefIdx = pExcRoot->pExtSheetBuff->Add( aUrl, aTabName, bSameWorkBook );
     468           0 : }
     469             : 
     470             : 
     471          11 : void ImportExcel:: WinProtection( void )
     472             : {
     473          11 :     if (GetRoot().GetBiff() != EXC_BIFF8)
     474          11 :         return;
     475             : 
     476          11 :     GetRoot().GetDocProtectBuffer().ReadWinProtect( aIn );
     477             : }
     478             : 
     479             : 
     480           0 : void ImportExcel::Columndefault( void )
     481             : {// Default Cell Attributes
     482             :     sal_uInt16  nColMic, nColMac;
     483             :     sal_uInt8   nOpt0;
     484             : 
     485           0 :     aIn >> nColMic >> nColMac;
     486             : 
     487             :     OSL_ENSURE( aIn.GetRecLeft() == (sal_Size)(nColMac - nColMic) * 3 + 2,
     488             :                 "ImportExcel::Columndefault - wrong record size" );
     489             : 
     490           0 :     nColMac--;
     491             : 
     492           0 :     if( nColMac > MAXCOL )
     493           0 :         nColMac = static_cast<sal_uInt16>(MAXCOL);
     494             : 
     495           0 :     for( sal_uInt16 nCol = nColMic ; nCol <= nColMac ; nCol++ )
     496             :     {
     497           0 :         aIn >> nOpt0;
     498           0 :         aIn.Ignore( 2 );   // nur 0. Attribut-Byte benutzt
     499             : 
     500           0 :         if( nOpt0 & 0x80 )  // Col hidden?
     501           0 :             pColRowBuff->HideCol( nCol );
     502             :     }
     503           0 : }
     504             : 
     505             : 
     506           0 : void ImportExcel::Array25( void )
     507             : {
     508             :     sal_uInt16      nFirstRow, nLastRow, nFormLen;
     509             :     sal_uInt8       nFirstCol, nLastCol;
     510             : 
     511           0 :     aIn >> nFirstRow >> nLastRow >> nFirstCol >> nLastCol;
     512             : 
     513           0 :     if( GetBiff() == EXC_BIFF2 )
     514             :     {//                     BIFF2
     515           0 :         aIn.Ignore( 1 );
     516           0 :         nFormLen = aIn.ReaduInt8();
     517             :     }
     518             :     else
     519             :     {//                     BIFF5
     520           0 :         aIn.Ignore( 6 );
     521           0 :         aIn >> nFormLen;
     522             :     }
     523             : 
     524           0 :     if( ValidColRow( nLastCol, nLastRow ) )
     525             :     {
     526             :         // jetzt steht Lesemarke auf Formel, Laenge in nFormLen
     527             :         const ScTokenArray* pErgebnis;
     528             : 
     529             :         pFormConv->Reset( ScAddress( static_cast<SCCOL>(nFirstCol),
     530           0 :                     static_cast<SCROW>(nFirstRow), GetCurrScTab() ) );
     531           0 :         pFormConv->Convert( pErgebnis, maStrm, nFormLen, true, FT_CellFormula);
     532             : 
     533             :         OSL_ENSURE( pErgebnis, "*ImportExcel::Array25(): ScTokenArray ist NULL!" );
     534             : 
     535           0 :         ScMarkData          aMarkData;
     536           0 :         aMarkData.SelectOneTable( GetCurrScTab() );
     537             :         pD->InsertMatrixFormula( static_cast<SCCOL>(nFirstCol),
     538             :                 static_cast<SCROW>(nFirstRow), static_cast<SCCOL>(nLastCol),
     539           0 :                 static_cast<SCROW>(nLastRow), aMarkData, EMPTY_STRING,
     540           0 :                 pErgebnis );
     541             :     }
     542           0 : }
     543             : 
     544             : 
     545          18 : void ImportExcel::Rec1904( void )
     546             : {
     547             :     sal_uInt16  n1904;
     548             : 
     549          18 :     aIn >> n1904;
     550             : 
     551          18 :     if( n1904 )
     552             :     {// 1904 date system
     553           0 :         ScDocOptions aOpt = pD->GetDocOptions();
     554           0 :         aOpt.SetDate( 1, 1, 1904 );
     555           0 :         pD->SetDocOptions( aOpt );
     556           0 :         pD->GetFormatTable()->ChangeNullDate( 1, 1, 1904 );
     557             :     }
     558          18 : }
     559             : 
     560             : 
     561           0 : void ImportExcel::Externname25( void )
     562             : {
     563             :     sal_uInt32      nRes;
     564             :     sal_uInt16      nOpt;
     565             : 
     566           0 :     aIn >> nOpt >> nRes;
     567             : 
     568           0 :     String aName( aIn.ReadByteString( false ) );
     569             : 
     570           0 :     if( ( nOpt & 0x0001 ) || ( ( nOpt & 0xFFFE ) == 0x0000 ) )
     571             :     {// external name
     572           0 :         ScfTools::ConvertToScDefinedName( aName );
     573           0 :         pExcRoot->pExtNameBuff->AddName( aName, mnLastRefIdx );
     574             :     }
     575           0 :     else if( nOpt & 0x0010 )
     576             :     {// ole link
     577           0 :         pExcRoot->pExtNameBuff->AddOLE( aName, mnLastRefIdx, nRes );        // nRes is storage ID
     578             :     }
     579             :     else
     580             :     {// dde link
     581           0 :         pExcRoot->pExtNameBuff->AddDDE( aName, mnLastRefIdx );
     582           0 :     }
     583           0 : }
     584             : 
     585             : 
     586           0 : void ImportExcel::Colwidth( void )
     587             : {// Column Width
     588             :     sal_uInt8   nColFirst, nColLast;
     589             :     sal_uInt16  nColWidth;
     590             : 
     591           0 :     aIn >> nColFirst >> nColLast >> nColWidth;
     592             : 
     593             : //! TODO: add a check for the unlikely case of changed MAXCOL (-> XclImpAddressConverter)
     594             : //   if( nColLast > MAXCOL )
     595             : //       nColLast = static_cast<sal_uInt16>(MAXCOL);
     596             : 
     597           0 :     sal_uInt16 nScWidth = XclTools::GetScColumnWidth( nColWidth, GetCharWidth() );
     598           0 :     pColRowBuff->SetWidthRange( nColFirst, nColLast, nScWidth );
     599           0 : }
     600             : 
     601             : 
     602           0 : void ImportExcel::Defrowheight2( void )
     603             : {
     604             :     sal_uInt16 nDefHeight;
     605           0 :     maStrm >> nDefHeight;
     606           0 :     nDefHeight &= 0x7FFF;
     607           0 :     pColRowBuff->SetDefHeight( nDefHeight, EXC_DEFROW_UNSYNCED );
     608           0 : }
     609             : 
     610             : 
     611          12 : void ImportExcel::SheetProtect( void )
     612             : {
     613          12 :     if (GetRoot().GetBiff() != EXC_BIFF8)
     614          12 :         return;
     615             : 
     616          12 :     GetRoot().GetSheetProtectBuffer().ReadProtect( aIn, GetCurrScTab() );
     617             : }
     618             : 
     619          11 : void ImportExcel::DocProtect( void )
     620             : {
     621          11 :     if (GetRoot().GetBiff() != EXC_BIFF8)
     622          11 :         return;
     623             : 
     624          11 :     GetRoot().GetDocProtectBuffer().ReadDocProtect( aIn );
     625             : }
     626             : 
     627          11 : void ImportExcel::DocPasssword( void )
     628             : {
     629          11 :     if (GetRoot().GetBiff() != EXC_BIFF8)
     630          11 :         return;
     631             : 
     632          11 :     GetRoot().GetDocProtectBuffer().ReadPasswordHash( aIn );
     633             : }
     634             : 
     635          18 : void ImportExcel::Codepage( void )
     636             : {
     637          18 :     SetCodePage( maStrm.ReaduInt16() );
     638          18 : }
     639             : 
     640             : 
     641           0 : void ImportExcel::Ixfe( void )
     642             : {
     643           0 :     maStrm >> mnIxfeIndex;
     644           0 : }
     645             : 
     646             : 
     647          73 : void ImportExcel::DefColWidth( void )
     648             : {
     649             :     // stored as entire characters -> convert to 1/256 of characters (as in COLINFO)
     650          73 :     double fDefWidth = 256.0 * maStrm.ReaduInt16();
     651             : 
     652             :     // #i3006# additional space for default width - Excel adds space depending on font size
     653          73 :     long nFontHt = GetFontBuffer().GetAppFontData().mnHeight;
     654          73 :     fDefWidth += XclTools::GetXclDefColWidthCorrection( nFontHt );
     655             : 
     656          73 :     sal_uInt16 nScWidth = XclTools::GetScColumnWidth( limit_cast< sal_uInt16 >( fDefWidth ), GetCharWidth() );
     657          73 :     pColRowBuff->SetDefWidth( nScWidth );
     658          73 : }
     659             : 
     660             : 
     661           0 : void ImportExcel::Builtinfmtcnt( void )
     662             : {
     663           0 : }
     664             : 
     665             : 
     666         278 : void ImportExcel::Colinfo( void )
     667             : {// Column Formatting Information
     668             :     sal_uInt16  nColFirst, nColLast, nColWidth, nXF;
     669             :     sal_uInt16  nOpt;
     670             : 
     671         278 :     aIn >> nColFirst >> nColLast >> nColWidth >> nXF >> nOpt;
     672             : 
     673         278 :     if( nColFirst > MAXCOL )
     674         278 :         return;
     675             : 
     676         278 :     if( nColLast > MAXCOL )
     677           0 :         nColLast = static_cast<sal_uInt16>(MAXCOL);
     678             : 
     679         278 :     bool bHidden = ::get_flag( nOpt, EXC_COLINFO_HIDDEN );
     680         278 :     bool bCollapsed = ::get_flag( nOpt, EXC_COLINFO_COLLAPSED );
     681         278 :     sal_uInt8 nLevel = ::extract_value< sal_uInt8 >( nOpt, 8, 3 );
     682         278 :     pColOutlineBuff->SetLevelRange( nColFirst, nColLast, nLevel, bCollapsed );
     683             : 
     684         278 :     if( bHidden )
     685           1 :         pColRowBuff->HideColRange( nColFirst, nColLast );
     686             : 
     687         278 :     sal_uInt16 nScWidth = XclTools::GetScColumnWidth( nColWidth, GetCharWidth() );
     688         278 :     pColRowBuff->SetWidthRange( nColFirst, nColLast, nScWidth );
     689         278 :     pColRowBuff->SetDefaultXF( nColFirst, nColLast, nXF );
     690             : }
     691             : 
     692             : 
     693          74 : void ImportExcel::Wsbool( void )
     694             : {
     695             :     sal_uInt16 nFlags;
     696          74 :     aIn >> nFlags;
     697             : 
     698          74 :     pRowOutlineBuff->SetButtonMode( ::get_flag( nFlags, EXC_WSBOOL_ROWBELOW ) );
     699          74 :     pColOutlineBuff->SetButtonMode( ::get_flag( nFlags, EXC_WSBOOL_COLBELOW ) );
     700             : 
     701          74 :     GetPageSettings().SetFitToPages( ::get_flag( nFlags, EXC_WSBOOL_FITTOPAGE ) );
     702          74 : }
     703             : 
     704             : 
     705           0 : void ImportExcel::Boundsheet( void )
     706             : {
     707           0 :     sal_uInt16 nGrbit = 0;
     708             : 
     709           0 :     if( GetBiff() == EXC_BIFF5 )
     710             :     {
     711           0 :         aIn.DisableDecryption();
     712           0 :         maSheetOffsets.push_back( aIn.ReaduInt32() );
     713           0 :         aIn.EnableDecryption();
     714           0 :         aIn >> nGrbit;
     715             :     }
     716             : 
     717           0 :     rtl::OUString aName( aIn.ReadByteString( false ) );
     718             : 
     719           0 :     SCTAB nScTab = static_cast< SCTAB >( nBdshtTab );
     720           0 :     if( nScTab > 0 )
     721             :     {
     722             :         OSL_ENSURE( !pD->HasTable( nScTab ), "ImportExcel::Boundsheet - sheet exists already" );
     723           0 :         pD->MakeTable( nScTab );
     724             :     }
     725             : 
     726           0 :     if( ( nGrbit & 0x0001 ) || ( nGrbit & 0x0002 ) )
     727           0 :         pD->SetVisible( nScTab, false );
     728             : 
     729           0 :     if( !pD->RenameTab( nScTab, aName ) )
     730             :     {
     731           0 :         pD->CreateValidTabName( aName );
     732           0 :         pD->RenameTab( nScTab, aName );
     733             :     }
     734             : 
     735           0 :     nBdshtTab++;
     736           0 : }
     737             : 
     738             : 
     739          17 : void ImportExcel::Country( void )
     740             : {
     741             :     sal_uInt16 nUICountry, nDocCountry;
     742          17 :     maStrm >> nUICountry >> nDocCountry;
     743             : 
     744             :     // Store system language in XclRoot
     745          17 :     LanguageType eLanguage = ::msfilter::ConvertCountryToLanguage( static_cast< ::msfilter::CountryId >( nDocCountry ) );
     746          17 :     if( eLanguage != LANGUAGE_DONTKNOW )
     747          17 :         SetDocLanguage( eLanguage );
     748             : 
     749             :     // Set Excel UI language in add-in name translator
     750          17 :     eLanguage = ::msfilter::ConvertCountryToLanguage( static_cast< ::msfilter::CountryId >( nUICountry ) );
     751          17 :     if( eLanguage != LANGUAGE_DONTKNOW )
     752          17 :         SetUILanguage( eLanguage );
     753          17 : }
     754             : 
     755             : 
     756          17 : void ImportExcel::ReadUsesElfs()
     757             : {
     758          17 :     if( maStrm.ReaduInt16() != 0 )
     759             :     {
     760           9 :         ScDocOptions aDocOpt = GetDoc().GetDocOptions();
     761           9 :         aDocOpt.SetLookUpColRowNames( sal_True );
     762           9 :         GetDoc().SetDocOptions( aDocOpt );
     763             :     }
     764          17 : }
     765             : 
     766             : 
     767          18 : void ImportExcel::Hideobj( void )
     768             : {
     769             :     sal_uInt16      nHide;
     770             :     ScVObjMode  eOle, eChart, eDraw;
     771             : 
     772          18 :     aIn >> nHide;
     773             : 
     774          18 :     ScViewOptions aOpts( pD->GetViewOptions() );
     775             : 
     776          18 :     switch( nHide )
     777             :     {
     778             :         case 1:                         // Placeholders
     779           0 :             eOle   = VOBJ_MODE_SHOW;    // in Excel 97 werden nur Charts als Platzhalter angezeigt
     780           0 :             eChart = VOBJ_MODE_SHOW;    //#i80528# VOBJ_MODE_DUMMY replaced by VOBJ_MODE_SHOW now
     781           0 :             eDraw  = VOBJ_MODE_SHOW;
     782           0 :             break;
     783             :         case 2:                         // Hide all
     784           0 :             eOle   = VOBJ_MODE_HIDE;
     785           0 :             eChart = VOBJ_MODE_HIDE;
     786           0 :             eDraw  = VOBJ_MODE_HIDE;
     787           0 :             break;
     788             :         default:                        // Show all
     789          18 :             eOle   = VOBJ_MODE_SHOW;
     790          18 :             eChart = VOBJ_MODE_SHOW;
     791          18 :             eDraw  = VOBJ_MODE_SHOW;
     792          18 :             break;
     793             :     }
     794             : 
     795          18 :     aOpts.SetObjMode( VOBJ_TYPE_OLE,   eOle );
     796          18 :     aOpts.SetObjMode( VOBJ_TYPE_CHART, eChart );
     797          18 :     aOpts.SetObjMode( VOBJ_TYPE_DRAW,  eDraw );
     798             : 
     799          18 :     pD->SetViewOptions( aOpts );
     800          18 : }
     801             : 
     802             : 
     803           0 : void ImportExcel::Bundleheader( void )
     804             : {
     805           0 : }
     806             : 
     807             : 
     808           1 : void ImportExcel::Standardwidth( void )
     809             : {
     810           1 :     sal_uInt16 nScWidth = XclTools::GetScColumnWidth( maStrm.ReaduInt16(), GetCharWidth() );
     811           1 :     pColRowBuff->SetDefWidth( nScWidth, sal_True );
     812           1 : }
     813             : 
     814             : 
     815          12 : void ImportExcel::Shrfmla( void )
     816             : {
     817             :     sal_uInt16              nFirstRow, nLastRow, nLenExpr;
     818             :     sal_uInt8               nFirstCol, nLastCol;
     819             : 
     820          12 :     aIn >> nFirstRow >> nLastRow >> nFirstCol >> nLastCol;
     821          12 :     aIn.Ignore( 2 );
     822          12 :     aIn >> nLenExpr;
     823             : 
     824             :     // jetzt steht Lesemarke an der Formel
     825             : 
     826             :     const ScTokenArray* pErgebnis;
     827             : 
     828          12 :     pFormConv->Reset();
     829          12 :     pFormConv->Convert( pErgebnis, maStrm, nLenExpr, true, FT_SharedFormula );
     830             : 
     831             : 
     832             :     OSL_ENSURE( pErgebnis, "+ImportExcel::Shrfmla(): ScTokenArray ist NULL!" );
     833             : 
     834             :     pExcRoot->pShrfmlaBuff->Store( ScRange( static_cast<SCCOL>(nFirstCol),
     835          12 :                 static_cast<SCROW>(nFirstRow), GetCurrScTab(),
     836             :                 static_cast<SCCOL>(nLastCol), static_cast<SCROW>(nLastRow),
     837          24 :                 GetCurrScTab()), *pErgebnis );
     838          12 : }
     839             : 
     840             : 
     841        2004 : void ImportExcel::Mulrk( void )
     842             : {
     843        2004 :     XclAddress aXclPos;
     844             :     sal_uInt16  nXF;
     845             :     sal_Int32   nRkNum;
     846             : 
     847        2004 :     aIn >> aXclPos;
     848             : 
     849       13145 :     for( XclAddress aCurrXclPos( aXclPos ); (aXclPos.mnCol <= aCurrXclPos.mnCol) && (aIn.GetRecLeft() > 2); ++aCurrXclPos.mnCol )
     850             :     {
     851       11141 :         aIn >> nXF >> nRkNum;
     852             : 
     853       11141 :         ScAddress aScPos( ScAddress::UNINITIALIZED );
     854       11141 :         if( GetAddressConverter().ConvertAddress( aScPos, aCurrXclPos, GetCurrScTab(), true ) )
     855             :         {
     856       11141 :             GetXFRangeBuffer().SetXF( aScPos, nXF );
     857       11141 :             GetDoc().PutCell( aScPos, new ScValueCell( XclTools::GetDoubleFromRK( nRkNum ) ) );
     858             :         }
     859             :     }
     860        2004 : }
     861             : 
     862             : 
     863        1791 : void ImportExcel::Mulblank( void )
     864             : {
     865        1791 :     XclAddress aXclPos;
     866             :     sal_uInt16  nXF;
     867             : 
     868        1791 :     aIn >> aXclPos;
     869             : 
     870       26081 :     for( XclAddress aCurrXclPos( aXclPos ); (aXclPos.mnCol <= aCurrXclPos.mnCol) && (aIn.GetRecLeft() > 2); ++aCurrXclPos.mnCol )
     871             :     {
     872       24290 :         aIn >> nXF;
     873             : 
     874       24290 :         ScAddress aScPos( ScAddress::UNINITIALIZED );
     875       24290 :         if( GetAddressConverter().ConvertAddress( aScPos, aCurrXclPos, GetCurrScTab(), true ) )
     876       18391 :             GetXFRangeBuffer().SetBlankXF( aScPos, nXF );
     877             :     }
     878        1791 : }
     879             : 
     880             : 
     881           0 : void ImportExcel::Rstring( void )
     882             : {
     883           0 :     XclAddress aXclPos;
     884             :     sal_uInt16 nXFIdx;
     885           0 :     aIn >> aXclPos >> nXFIdx;
     886             : 
     887           0 :     ScAddress aScPos( ScAddress::UNINITIALIZED );
     888           0 :     if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
     889             :     {
     890             :         // unformatted Unicode string with separate formatting information
     891           0 :         XclImpString aString;
     892             : 
     893             :         // #i63105# use text encoding from FONT record
     894           0 :         rtl_TextEncoding eOldTextEnc = GetTextEncoding();
     895           0 :         if( const XclImpFont* pFont = GetXFBuffer().GetFont( nXFIdx ) )
     896           0 :             SetTextEncoding( pFont->GetFontEncoding() );
     897           0 :         aString.Read( maStrm );
     898           0 :         SetTextEncoding( eOldTextEnc );
     899             : 
     900             :         // character formatting runs
     901           0 :         if( !aString.IsRich() )
     902           0 :             aString.ReadFormats( maStrm );
     903             : 
     904           0 :         GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
     905           0 :         if( ScBaseCell* pCell = XclImpStringHelper::CreateCell( *this, aString, nXFIdx ) )
     906           0 :             GetDoc().PutCell( aScPos, pCell );
     907             :     }
     908           0 : }
     909             : 
     910             : 
     911          30 : void ImportExcel::Cellmerging()
     912             : {
     913          30 :     XclImpAddressConverter& rAddrConv = GetAddressConverter();
     914          30 :     SCTAB nScTab = GetCurrScTab();
     915             : 
     916             :     sal_uInt16 nCount;
     917          30 :     maStrm >> nCount;
     918         459 :     for( sal_uInt16 nIdx = 0; (nIdx < nCount) && (maStrm.GetRecLeft() >= 8); ++nIdx )
     919             :     {
     920         429 :         XclRange aXclRange;
     921         429 :         maStrm >> aXclRange;    // 16-bit rows and columns
     922         429 :         ScRange aScRange( ScAddress::UNINITIALIZED );
     923         429 :         if( rAddrConv.ConvertRange( aScRange, aXclRange, nScTab, nScTab, true ) )
     924         429 :             GetXFRangeBuffer().SetMerge( aScRange.aStart.Col(), aScRange.aStart.Row(), aScRange.aEnd.Col(), aScRange.aEnd.Row() );
     925             :     }
     926          30 : }
     927             : 
     928             : 
     929           0 : void ImportExcel::Olesize( void )
     930             : {
     931           0 :     XclRange aXclOleSize( ScAddress::UNINITIALIZED );
     932           0 :     maStrm.Ignore( 2 );
     933           0 :     aXclOleSize.Read( maStrm, false );
     934             : 
     935           0 :     SCTAB nScTab = GetCurrScTab();
     936           0 :     GetAddressConverter().ConvertRange( maScOleSize, aXclOleSize, nScTab, nScTab, false );
     937           0 : }
     938             : 
     939             : 
     940        4596 : void ImportExcel::Row34( void )
     941             : {
     942             :     sal_uInt16  nRow, nRowHeight, nGrbit, nXF;
     943             : 
     944        4596 :     aIn >> nRow;
     945        4596 :     aIn.Ignore( 4 );   // Mic und Mac ueberspringen
     946             : 
     947        4596 :     SCROW nScRow = static_cast< SCROW >( nRow );
     948             : 
     949        4596 :     if( ValidRow( nScRow ) )
     950             :     {
     951        4596 :         aIn >> nRowHeight;  // direkt in Twips angegeben
     952        4596 :         aIn.Ignore( 4 );
     953             : 
     954        4596 :         nRowHeight = nRowHeight & 0x7FFF; // Bit 15: Row Height not changed manually
     955        4596 :         if( !nRowHeight )
     956           0 :             nRowHeight = (GetBiff() == EXC_BIFF2) ? 0x25 : 0x225;
     957             : 
     958        4596 :         aIn >> nGrbit >> nXF;
     959             : 
     960        4596 :         sal_uInt8 nLevel = ::extract_value< sal_uInt8 >( nGrbit, 0, 3 );
     961        4596 :         pRowOutlineBuff->SetLevel( nScRow, nLevel, ::get_flag( nGrbit, EXC_ROW_COLLAPSED ) );
     962        4596 :         pColRowBuff->SetRowSettings( nScRow, nRowHeight, nGrbit );
     963             : 
     964        4596 :         if( nGrbit & EXC_ROW_USEDEFXF )
     965         310 :             GetXFRangeBuffer().SetRowDefXF( nScRow, nXF & EXC_ROW_XFMASK );
     966             :     }
     967        4596 : }
     968             : 
     969             : 
     970           0 : void ImportExcel::Bof3( void )
     971             : {
     972             :     sal_uInt16 nSubType;
     973           0 :     maStrm.DisableDecryption();
     974           0 :     maStrm.Ignore( 2 );
     975           0 :     maStrm >> nSubType;
     976             : 
     977             :     OSL_ENSURE( nSubType != 0x0100, "*ImportExcel::Bof3(): Biff3 als Workbook?!" );
     978           0 :     if( nSubType == 0x0100 )        // Book
     979           0 :         pExcRoot->eDateiTyp = Biff3W;
     980           0 :     else if( nSubType == 0x0020 )   // Chart
     981           0 :         pExcRoot->eDateiTyp = Biff3C;
     982           0 :     else if( nSubType == 0x0040 )   // Macro
     983           0 :         pExcRoot->eDateiTyp = Biff3M;
     984             :     else                            // #i51490# Excel interprets invalid indexes as worksheet
     985           0 :         pExcRoot->eDateiTyp = Biff3;
     986           0 : }
     987             : 
     988             : 
     989           2 : void ImportExcel::Array34( void )
     990             : {
     991             :     sal_uInt16                  nFirstRow, nLastRow, nFormLen;
     992             :     sal_uInt8                   nFirstCol, nLastCol;
     993             : 
     994           2 :     aIn >> nFirstRow >> nLastRow >> nFirstCol >> nLastCol;
     995           2 :     aIn.Ignore( (GetBiff() >= EXC_BIFF5) ? 6 : 2 );
     996           2 :     aIn >> nFormLen;
     997             : 
     998           2 :     if( ValidColRow( nLastCol, nLastRow ) )
     999             :     {
    1000             :         // jetzt steht Lesemarke auf Formel, Laenge in nFormLen
    1001             :         const ScTokenArray* pErgebnis;
    1002             : 
    1003             :         pFormConv->Reset( ScAddress( static_cast<SCCOL>(nFirstCol),
    1004           2 :                     static_cast<SCROW>(nFirstRow), GetCurrScTab() ) );
    1005           2 :         pFormConv->Convert( pErgebnis, maStrm, nFormLen, true, FT_CellFormula);
    1006             : 
    1007             :         OSL_ENSURE( pErgebnis, "+ImportExcel::Array34(): ScTokenArray ist NULL!" );
    1008             : 
    1009           2 :         ScMarkData          aMarkData;
    1010           2 :         aMarkData.SelectOneTable( GetCurrScTab() );
    1011             :         pD->InsertMatrixFormula( static_cast<SCCOL>(nFirstCol),
    1012             :                 static_cast<SCROW>(nFirstRow), static_cast<SCCOL>(nLastCol),
    1013           2 :                 static_cast<SCROW>(nLastRow), aMarkData, EMPTY_STRING,
    1014           4 :                 pErgebnis);
    1015             :     }
    1016           2 : }
    1017             : 
    1018             : 
    1019           0 : void ImportExcel::Externname34( void )
    1020             : {
    1021           0 : }
    1022             : 
    1023             : 
    1024          74 : void ImportExcel::Defrowheight345( void )
    1025             : {
    1026             :     sal_uInt16 nFlags, nDefHeight;
    1027          74 :     maStrm >> nFlags >> nDefHeight;
    1028          74 :     pColRowBuff->SetDefHeight( nDefHeight, nFlags );
    1029          74 : }
    1030             : 
    1031             : 
    1032           0 : void ImportExcel::TableOp( void )
    1033             : {
    1034             :     sal_uInt16 nFirstRow, nLastRow;
    1035             :     sal_uInt8 nFirstCol, nLastCol;
    1036             :     sal_uInt16 nGrbit;
    1037             :     sal_uInt16 nInpRow, nInpCol, nInpRow2, nInpCol2;
    1038             : 
    1039           0 :     aIn >> nFirstRow >> nLastRow >> nFirstCol >> nLastCol >> nGrbit
    1040           0 :         >> nInpRow >> nInpCol >> nInpRow2 >> nInpCol2;
    1041             : 
    1042           0 :     if( ValidColRow( nLastCol, nLastRow ) )
    1043             :     {
    1044           0 :         if( nFirstCol && nFirstRow )
    1045             :         {
    1046           0 :             ScTabOpParam aTabOpParam;
    1047           0 :             aTabOpParam.nMode = (nGrbit & EXC_TABLEOP_BOTH) ? 2 : ((nGrbit & EXC_TABLEOP_ROW) ? 1 : 0 );
    1048           0 :             sal_uInt16 nCol = nFirstCol - 1;
    1049           0 :             sal_uInt16 nRow = nFirstRow - 1;
    1050           0 :             SCTAB nTab = GetCurrScTab();
    1051           0 :             switch( aTabOpParam.nMode )
    1052             :             {
    1053             :                 case 0:     // COL
    1054             :                     aTabOpParam.aRefFormulaCell.Set(
    1055             :                             static_cast<SCCOL>(nFirstCol),
    1056             :                             static_cast<SCROW>(nFirstRow - 1), nTab, false,
    1057           0 :                             false, false );
    1058             :                     aTabOpParam.aRefFormulaEnd.Set(
    1059             :                             static_cast<SCCOL>(nLastCol),
    1060             :                             static_cast<SCROW>(nFirstRow - 1), nTab, false,
    1061           0 :                             false, false );
    1062             :                     aTabOpParam.aRefColCell.Set( static_cast<SCCOL>(nInpCol),
    1063             :                             static_cast<SCROW>(nInpRow), nTab, false, false,
    1064           0 :                             false );
    1065           0 :                     nRow++;
    1066           0 :                 break;
    1067             :                 case 1:     // ROW
    1068             :                     aTabOpParam.aRefFormulaCell.Set(
    1069             :                             static_cast<SCCOL>(nFirstCol - 1),
    1070             :                             static_cast<SCROW>(nFirstRow), nTab, false, false,
    1071           0 :                             false );
    1072             :                     aTabOpParam.aRefFormulaEnd.Set(
    1073             :                             static_cast<SCCOL>(nFirstCol - 1),
    1074             :                             static_cast<SCROW>(nLastRow), nTab, false, false,
    1075           0 :                             false );
    1076             :                     aTabOpParam.aRefRowCell.Set( static_cast<SCCOL>(nInpCol),
    1077             :                             static_cast<SCROW>(nInpRow), nTab, false, false,
    1078           0 :                             false );
    1079           0 :                     nCol++;
    1080           0 :                 break;
    1081             :                 case 2:     // TWO-INPUT
    1082             :                     aTabOpParam.aRefFormulaCell.Set(
    1083             :                             static_cast<SCCOL>(nFirstCol - 1),
    1084             :                             static_cast<SCROW>(nFirstRow - 1), nTab, false,
    1085           0 :                             false, false );
    1086             :                     aTabOpParam.aRefRowCell.Set( static_cast<SCCOL>(nInpCol),
    1087             :                             static_cast<SCROW>(nInpRow), nTab, false, false,
    1088           0 :                             false );
    1089             :                     aTabOpParam.aRefColCell.Set( static_cast<SCCOL>(nInpCol2),
    1090             :                             static_cast<SCROW>(nInpRow2), nTab, false, false,
    1091           0 :                             false );
    1092           0 :                 break;
    1093             :             }
    1094             : 
    1095           0 :             ScMarkData aMarkData;
    1096           0 :             aMarkData.SelectOneTable( nTab );
    1097             :             pD->InsertTableOp( aTabOpParam, static_cast<SCCOL>(nCol),
    1098             :                     static_cast<SCROW>(nRow), static_cast<SCCOL>(nLastCol),
    1099           0 :                     static_cast<SCROW>(nLastRow), aMarkData );
    1100             :         }
    1101             :     }
    1102             :     else
    1103             :     {
    1104           0 :         bTabTruncated = sal_True;
    1105           0 :         GetTracer().TraceInvalidRow(nLastRow, MAXROW);
    1106             :     }
    1107           0 : }
    1108             : 
    1109             : 
    1110           0 : void ImportExcel::Bof4( void )
    1111             : {
    1112             :     sal_uInt16 nSubType;
    1113           0 :     maStrm.DisableDecryption();
    1114           0 :     maStrm.Ignore( 2 );
    1115           0 :     maStrm >> nSubType;
    1116             : 
    1117           0 :     if( nSubType == 0x0100 )        // Book
    1118           0 :         pExcRoot->eDateiTyp = Biff4W;
    1119           0 :     else if( nSubType == 0x0020 )   // Chart
    1120           0 :         pExcRoot->eDateiTyp = Biff4C;
    1121           0 :     else if( nSubType == 0x0040 )   // Macro
    1122           0 :         pExcRoot->eDateiTyp = Biff4M;
    1123             :     else                            // #i51490# Excel interprets invalid indexes as worksheet
    1124           0 :         pExcRoot->eDateiTyp = Biff4;
    1125           0 : }
    1126             : 
    1127             : 
    1128          95 : void ImportExcel::Bof5( void )
    1129             : {
    1130             :     //POST: eDateiTyp = Typ der zu lesenden Datei
    1131             :     sal_uInt16      nSubType, nVers;
    1132             :     BiffTyp     eDatei;
    1133             : 
    1134          95 :     maStrm.DisableDecryption();
    1135          95 :     maStrm >> nVers >> nSubType;
    1136             : 
    1137          95 :     switch( nSubType )
    1138             :     {
    1139          19 :         case 0x0005:    eDatei = Biff5W;    break;  // workbook globals
    1140           0 :         case 0x0006:    eDatei = Biff5V;    break;  // VB module
    1141          67 :         case 0x0010:    eDatei = Biff5;     break;  // worksheet
    1142           0 :         case 0x0020:    eDatei = Biff5C;    break;  // chart
    1143           8 :         case 0x0040:    eDatei = Biff5M4;   break;  // macro sheet
    1144             :         default:
    1145           1 :             pExcRoot->eDateiTyp = BiffX;
    1146          95 :             return;
    1147             :     }
    1148             : 
    1149          94 :     if( nVers == 0x0600 && (GetBiff() == EXC_BIFF8) )
    1150          94 :         eDatei = ( BiffTyp ) ( eDatei - Biff5 + Biff8 );
    1151             : 
    1152          94 :     pExcRoot->eDateiTyp = eDatei;
    1153             : }
    1154             : 
    1155          75 : void ImportExcel::EndSheet( void )
    1156             : {
    1157          75 :     pExcRoot->pExtSheetBuff->Reset();
    1158             : 
    1159          75 :     if( GetBiff() <= EXC_BIFF5 )
    1160             :     {
    1161           0 :         pExcRoot->pExtNameBuff->Reset();
    1162           0 :         mnLastRefIdx = 0;
    1163             :     }
    1164             : 
    1165          75 :     FinalizeTable();
    1166          75 : }
    1167             : 
    1168             : 
    1169          75 : void ImportExcel::NeueTabelle( void )
    1170             : {
    1171          75 :     SCTAB nTab = GetCurrScTab();
    1172          75 :     if( nTab > 0 && !pD->HasTable( nTab ) )
    1173           0 :         pD->MakeTable( nTab );
    1174             : 
    1175          75 :     if (nTab == 0 && GetBiff() == EXC_BIFF2)
    1176             :     {
    1177             :         // For Excel 2.1 Worksheet file, we need to set the file name as the
    1178             :         // sheet name.
    1179           0 :         INetURLObject aURL(GetDocUrl());
    1180           0 :         pD->RenameTab(0, aURL.getBase(), false);
    1181             :     }
    1182             : 
    1183          75 :     pExcRoot->pShrfmlaBuff->Clear();
    1184             : 
    1185          75 :     InitializeTable( nTab );
    1186             : 
    1187          75 :     XclImpOutlineDataBuffer* pNewItem = new XclImpOutlineDataBuffer( GetRoot(), nTab );
    1188          75 :     pOutlineListBuffer->push_back( pNewItem );
    1189          75 :     pExcRoot->pColRowBuff = pColRowBuff = pNewItem->GetColRowBuff();
    1190          75 :     pColOutlineBuff = pNewItem->GetColOutline();
    1191          75 :     pRowOutlineBuff = pNewItem->GetRowOutline();
    1192          75 : }
    1193             : 
    1194             : 
    1195           0 : const ScTokenArray* ImportExcel::ErrorToFormula( sal_uInt8 bErrOrVal, sal_uInt8 nError, double& rVal )
    1196             : {
    1197           0 :     return pFormConv->GetBoolErr( XclTools::ErrorToEnum( rVal, bErrOrVal, nError ) );
    1198             : }
    1199             : 
    1200             : 
    1201           0 : void ImportExcel::AdjustRowHeight()
    1202             : {
    1203             :     /*  Speed up chart import: import all sheets without charts, then
    1204             :         update row heights (here), last load all charts -> do not any longer
    1205             :         update inside of ScDocShell::ConvertFrom() (causes update of existing
    1206             :         charts during each and every change of row height). */
    1207           0 :     if( ScModelObj* pDocObj = GetDocModelObj() )
    1208           0 :         pDocObj->UpdateAllRowHeights();
    1209           0 : }
    1210             : 
    1211             : 
    1212          20 : void ImportExcel::PostDocLoad( void )
    1213             : {
    1214             :     /*  Set automatic page numbering in Default page style (default is "page number = 1").
    1215             :         Otherwise hidden tables (i.e. for scenarios) which have Default page style will
    1216             :         break automatic page numbering. */
    1217          20 :     if( SfxStyleSheetBase* pStyleSheet = GetStyleSheetPool().Find( ScGlobal::GetRscString( STR_STYLENAME_STANDARD ), SFX_STYLE_FAMILY_PAGE ) )
    1218          20 :         pStyleSheet->GetItemSet().Put( SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO, 0 ) );
    1219             : 
    1220             :     // outlines for all sheets, sets hidden rows and columns (#i11776# after filtered ranges)
    1221          95 :     for (XclImpOutlineListBuffer::iterator itBuffer = pOutlineListBuffer->begin(); itBuffer != pOutlineListBuffer->end(); ++itBuffer)
    1222          75 :         itBuffer->Convert();
    1223             : 
    1224             :     // document view settings (before visible OLE area)
    1225          20 :     GetDocViewSettings().Finalize();
    1226             : 
    1227             :     // process all drawing objects (including OLE, charts, controls; after hiding rows/columns; before visible OLE area)
    1228          20 :     GetObjectManager().ConvertObjects();
    1229             : 
    1230             :     // visible area (used if this document is an embedded OLE object)
    1231          20 :     if( SfxObjectShell* pDocShell = GetDocShell() )
    1232             :     {
    1233             :         // visible area if embedded
    1234          20 :         const ScExtDocSettings& rDocSett = GetExtDocOptions().GetDocSettings();
    1235          20 :         SCTAB nDisplScTab = rDocSett.mnDisplTab;
    1236             : 
    1237             :         /*  #i44077# If a new OLE object is inserted from file, there is no
    1238             :             OLESIZE record in the Excel file. Calculate used area from file
    1239             :             contents (used cells and drawing objects). */
    1240          20 :         if( !maScOleSize.IsValid() )
    1241             :         {
    1242             :             // used area of displayed sheet (cell contents)
    1243          20 :             if( const ScExtTabSettings* pTabSett = GetExtDocOptions().GetTabSettings( nDisplScTab ) )
    1244          18 :                 maScOleSize = pTabSett->maUsedArea;
    1245             :             // add all valid drawing objects
    1246          20 :             ScRange aScObjArea = GetObjectManager().GetUsedArea( nDisplScTab );
    1247          20 :             if( aScObjArea.IsValid() )
    1248           5 :                 maScOleSize.ExtendTo( aScObjArea );
    1249             :         }
    1250             : 
    1251             :         // valid size found - set it at the document
    1252          20 :         if( maScOleSize.IsValid() )
    1253             :         {
    1254          17 :             pDocShell->SetVisArea( GetDoc().GetMMRect(
    1255          17 :                 maScOleSize.aStart.Col(), maScOleSize.aStart.Row(),
    1256          51 :                 maScOleSize.aEnd.Col(), maScOleSize.aEnd.Row(), nDisplScTab ) );
    1257          17 :             GetDoc().SetVisibleTab( nDisplScTab );
    1258             :         }
    1259             :     }
    1260             : 
    1261             :     // open forms in alive mode (has no effect, if no controls in document)
    1262          20 :     if( ScModelObj* pDocObj = GetDocModelObj() )
    1263          20 :         pDocObj->setPropertyValue( SC_UNO_APPLYFMDES, uno::Any( false ) );
    1264             : 
    1265             :     // enables extended options to be set to the view after import
    1266          20 :     GetExtDocOptions().SetChanged( true );
    1267             : 
    1268             :     // root data owns the extended document options -> create a new object
    1269          20 :     GetDoc().SetExtDocOptions( new ScExtDocOptions( GetExtDocOptions() ) );
    1270             : 
    1271          20 :     const SCTAB     nLast = pD->GetTableCount();
    1272             :     const ScRange*      p;
    1273             : 
    1274          20 :     if( pExcRoot->pPrintRanges->HasRanges() )
    1275             :     {
    1276           0 :         for( SCTAB n = 0 ; n < nLast ; n++ )
    1277             :         {
    1278           0 :             p = pExcRoot->pPrintRanges->First(n);
    1279           0 :             if( p )
    1280             :             {
    1281           0 :                 pD->ClearPrintRanges( n );
    1282           0 :                 while( p )
    1283             :                 {
    1284           0 :                     pD->AddPrintRange( n, *p );
    1285           0 :                     p = pExcRoot->pPrintRanges->Next();
    1286             :                 }
    1287             :             }
    1288             :             else
    1289             :             {
    1290             :                 // #i4063# no print ranges -> print entire sheet
    1291           0 :                 pD->SetPrintEntireSheet( n );
    1292             :             }
    1293             :         }
    1294           0 :         GetTracer().TracePrintRange();
    1295             :     }
    1296             : 
    1297          20 :     if( pExcRoot->pPrintTitles->HasRanges() )
    1298             :     {
    1299           0 :         for( SCTAB n = 0 ; n < nLast ; n++ )
    1300             :         {
    1301           0 :             p = pExcRoot->pPrintTitles->First(n);
    1302           0 :             if( p )
    1303             :             {
    1304           0 :                 sal_Bool    bRowVirgin = sal_True;
    1305           0 :                 sal_Bool    bColVirgin = sal_True;
    1306             : 
    1307           0 :                 while( p )
    1308             :                 {
    1309           0 :                     if( p->aStart.Col() == 0 && p->aEnd.Col() == MAXCOL && bRowVirgin )
    1310             :                     {
    1311           0 :                         pD->SetRepeatRowRange( n, p );
    1312           0 :                         bRowVirgin = false;
    1313             :                     }
    1314             : 
    1315           0 :                     if( p->aStart.Row() == 0 && p->aEnd.Row() == MAXROW && bColVirgin )
    1316             :                     {
    1317           0 :                         pD->SetRepeatColRange( n, p );
    1318           0 :                         bColVirgin = false;
    1319             :                     }
    1320             : 
    1321           0 :                     p = pExcRoot->pPrintTitles->Next();
    1322             :                 }
    1323             :             }
    1324             :         }
    1325             :     }
    1326          20 : }
    1327             : 
    1328          75 : XclImpOutlineDataBuffer::XclImpOutlineDataBuffer( const XclImpRoot& rRoot, SCTAB nScTab ) :
    1329             :     XclImpRoot( rRoot ),
    1330         150 :     mxColOutlineBuff( new XclImpOutlineBuffer( rRoot.GetXclMaxPos().Col() + 1 ) ),
    1331         150 :     mxRowOutlineBuff( new XclImpOutlineBuffer( rRoot.GetXclMaxPos().Row() + 1 ) ),
    1332          75 :     mxColRowBuff( new XclImpColRowSettings( rRoot ) ),
    1333         450 :     mnScTab( nScTab )
    1334             : {
    1335          75 : }
    1336             : 
    1337         150 : XclImpOutlineDataBuffer::~XclImpOutlineDataBuffer()
    1338             : {
    1339         150 : }
    1340             : 
    1341          75 : void XclImpOutlineDataBuffer::Convert()
    1342             : {
    1343          75 :     mxColOutlineBuff->SetOutlineArray( GetDoc().GetOutlineTable( mnScTab, sal_True )->GetColArray() );
    1344          75 :     mxColOutlineBuff->MakeScOutline();
    1345             : 
    1346          75 :     mxRowOutlineBuff->SetOutlineArray( GetDoc().GetOutlineTable( mnScTab, sal_True )->GetRowArray() );
    1347          75 :     mxRowOutlineBuff->MakeScOutline();
    1348             : 
    1349          75 :     mxColRowBuff->ConvertHiddenFlags( mnScTab );
    1350          84 : }
    1351             : 
    1352             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10