LCOV - code coverage report
Current view: top level - sc/source/filter/lotus - lotread.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 126 0.0 %
Date: 2014-04-14 Functions: 0 4 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 "document.hxx"
      21             : 
      22             : #include "scerrors.hxx"
      23             : #include "root.hxx"
      24             : #include "lotimpop.hxx"
      25             : #include "lotattr.hxx"
      26             : #include "fprogressbar.hxx"
      27             : 
      28             : 
      29             : class ScFormulaCell;
      30             : 
      31             : 
      32           0 : FltError ImportLotus::Read()
      33             : {
      34             :     enum STATE
      35             :     {
      36             :         S_START,        // analyse first BOF
      37             :         S_WK1,          // in WK1-Stream
      38             :         S_WK3,          // in WK3-Section
      39             :         S_WK4,
      40             :         S_FM3,
      41             :         S_END           // Import finished
      42             :     };
      43             : 
      44             :     sal_uInt16          nOp;
      45             :     sal_uInt16          nSubType;
      46             :     sal_uInt16          nRecLen;
      47           0 :     sal_uInt32          nNextRec = 0UL;
      48           0 :     FltError        eRet = eERR_OK;
      49             : //  ScFormulaCell   *pLastFormCell;
      50             : 
      51           0 :     STATE           eAkt = S_START;
      52             : 
      53           0 :     nTab = 0;
      54           0 :     nExtTab = -2;
      55             : 
      56           0 :     pIn->Seek( nNextRec );
      57             : 
      58             :     // Progressbar starten
      59           0 :     ScfStreamProgressBar aPrgrsBar( *pIn, pD->GetDocumentShell() );
      60             : 
      61           0 :     while( eAkt != S_END )
      62             :     {
      63           0 :         pIn->ReadUInt16( nOp ).ReadUInt16( nRecLen );
      64             : 
      65           0 :                 if( pIn->IsEof() || nNextRec > SAL_MAX_UINT32 - nRecLen - 4 )
      66           0 :             eAkt = S_END;
      67             : 
      68           0 :         nNextRec += nRecLen + 4;
      69             : 
      70           0 :         switch( eAkt )
      71             :         {
      72             : 
      73             :             case S_START:                                           // S_START
      74           0 :             if( nOp )
      75             :             {
      76           0 :                 eRet = SCERR_IMPORT_UNKNOWN_WK;
      77           0 :                 eAkt = S_END;
      78             :             }
      79             :             else
      80             :             {
      81           0 :                 if( nRecLen > 2 )
      82             :                 {
      83           0 :                     Bof();
      84           0 :                     switch( pLotusRoot->eFirstType )
      85             :                     {
      86           0 :                         case Lotus_WK1: eAkt = S_WK1; break;
      87           0 :                         case Lotus_WK3: eAkt = S_WK3; break;
      88           0 :                         case Lotus_WK4: eAkt = S_WK4; break;
      89           0 :                         case Lotus_FM3: eAkt = S_FM3; break;
      90             :                         default:
      91           0 :                         eRet = SCERR_IMPORT_UNKNOWN_WK;
      92           0 :                         eAkt = S_END;
      93             :                     }
      94             :                 }
      95             :                 else
      96             :                 {
      97           0 :                     eAkt = S_END;   // hier kommt wat fuer <= WK1 hinne!
      98           0 :                     eRet = 0xFFFFFFFF;
      99             :                 }
     100             :             }
     101           0 :             break;
     102             : 
     103             :             case S_WK1:                                             // S_WK1
     104           0 :             break;
     105             : 
     106             :             case S_WK3:                                             // S_WK3
     107             :             case S_WK4:                                             // S_WK4
     108           0 :             switch( nOp )
     109             :             {
     110             :                 case 0x0001:                            // EOF
     111           0 :                 eAkt = S_FM3;
     112           0 :                 nTab++;
     113           0 :                 break;
     114             : 
     115             :                 case 0x0002:                            // PASSWORD
     116           0 :                 eRet = eERR_FILEPASSWD;
     117           0 :                 eAkt = S_END;
     118           0 :                 break;
     119             : 
     120             :                 case 0x0007:                            // COLUMNWIDTH
     121           0 :                 Columnwidth( nRecLen );
     122           0 :                 break;
     123             : 
     124             :                 case 0x0008:                            // HIDDENCOLUMN
     125           0 :                 Hiddencolumn( nRecLen );
     126           0 :                 break;
     127             : 
     128             :                 case 0x0009:                            // USERRANGE
     129           0 :                 Userrange();
     130           0 :                 break;
     131             : 
     132             :                 case 0x0013:                            // FORMAT
     133             : 
     134           0 :                 break;
     135             :                 case 0x0014:                            // ERRCELL
     136           0 :                 Errcell();
     137           0 :                 break;
     138             : 
     139             :                 case 0x0015:                            // NACELL
     140           0 :                 Nacell();
     141           0 :                 break;
     142             : 
     143             :                 case 0x0016:                            // LABELCELL
     144           0 :                 Labelcell();
     145           0 :                 break;
     146             : 
     147             :                 case 0x0017:                            // NUMBERCELL
     148           0 :                 Numbercell();
     149           0 :                 break;
     150             : 
     151             :                 case 0x0018:                            // SMALLNUMCELL
     152           0 :                 Smallnumcell();
     153           0 :                 break;
     154             : 
     155             :                 case 0x0019:                            // FORMULACELL
     156           0 :                 Formulacell( nRecLen );
     157           0 :                 break;
     158             : 
     159             :                 case 0x001b:                            // extended attributes
     160           0 :                 if (nRecLen > 2)
     161             :                 {
     162           0 :                     Read( nSubType );
     163           0 :                     nRecLen -= 2;
     164           0 :                     switch( nSubType )
     165             :                     {
     166             :                         case 2007:                      // ROW PRESENTATION
     167           0 :                             RowPresentation( nRecLen );
     168           0 :                             break;
     169             : 
     170             :                         case 14000:                     // NAMED SHEET
     171           0 :                             NamedSheet();
     172           0 :                             break;
     173             :                     }
     174             :                 }
     175             :                 else
     176             :                 {
     177           0 :                     eRet = eERR_FORMAT;
     178           0 :                     eAkt = S_END;
     179             :                 }
     180             :             }
     181             : 
     182           0 :             break;
     183             : 
     184             :             case S_FM3:                                             // S_FM3
     185           0 :             break;
     186             : 
     187             :             case S_END:                                             // S_END
     188           0 :             break;
     189             :         }
     190             : 
     191             :         OSL_ENSURE( nNextRec >= pIn->Tell(),
     192             :             "*ImportLotus::Read(): Etwas zu gierig..." );
     193             : 
     194           0 :         pIn->Seek( nNextRec );
     195           0 :         aPrgrsBar.Progress();
     196             :     }
     197             : 
     198             :     // duemmliche Namen eliminieren
     199           0 :     SCTAB       nTabs = pD->GetTableCount();
     200             :     SCTAB       nCnt;
     201           0 :     OUString aTabName;
     202           0 :     OUString aBaseName;
     203           0 :     OUString aRef( "temp" );
     204           0 :     if( nTabs != 0 )
     205             :     {
     206           0 :         if( nTabs > 1 )
     207             :         {
     208           0 :             pD->GetName( 0, aBaseName );
     209           0 :             aBaseName = aBaseName.copy(0, aBaseName.getLength()-1);
     210             :         }
     211           0 :         for( nCnt = 1 ; nCnt < nTabs ; nCnt++ )
     212             :         {
     213             :             OSL_ENSURE( pD->HasTable( nCnt ),
     214             :                 "-ImportLotus::Read(): Wo ist meine Tabelle?!" );
     215           0 :             pD->GetName( nCnt, aTabName );
     216           0 :             if( aTabName.equals(aRef) )
     217             :             {
     218           0 :                 aTabName = aBaseName;
     219           0 :                 pD->CreateValidTabName( aTabName );
     220           0 :                 pD->RenameTab( nCnt, aTabName );
     221             :             }
     222             :         }
     223             :     }
     224             : 
     225           0 :     pD->CalcAfterLoad();
     226             : 
     227           0 :     return eRet;
     228             : }
     229             : 
     230             : 
     231           0 : FltError ImportLotus::Read( SvStream& rIn )
     232             : {
     233           0 :     pIn = &rIn;
     234             : 
     235           0 :     sal_Bool            bRead = sal_True;
     236             :     sal_uInt16          nOp;
     237             :     sal_uInt16          nRecLen;
     238           0 :     sal_uInt32          nNextRec = 0UL;
     239           0 :     FltError        eRet = eERR_OK;
     240             : 
     241           0 :     nTab = 0;
     242           0 :     nExtTab = -1;
     243             : 
     244           0 :     pIn->Seek( nNextRec );
     245             : 
     246             :     // Progressbar starten
     247           0 :     ScfStreamProgressBar aPrgrsBar( *pIn, pD->GetDocumentShell() );
     248             : 
     249           0 :     while( bRead )
     250             :     {
     251           0 :         pIn->ReadUInt16( nOp ).ReadUInt16( nRecLen );
     252             : 
     253           0 :                 if( pIn->IsEof() || nNextRec > SAL_MAX_UINT32 - nRecLen - 4 )
     254           0 :             bRead = false;
     255             :         else
     256             :         {
     257           0 :             nNextRec += nRecLen + 4;
     258             : 
     259           0 :             switch( nOp )
     260             :             {
     261             :                 case 0x0000:                            // BOF
     262           0 :                 if( nRecLen != 26 || !BofFm3() )
     263             :                 {
     264           0 :                     bRead = false;
     265           0 :                     eRet = eERR_FORMAT;
     266             :                 }
     267           0 :                 break;
     268             : 
     269             :                 case 0x0001:                            // EOF
     270           0 :                     bRead = false;
     271             :                     OSL_ENSURE( nTab == 0,
     272             :                         "-ImportLotus::Read( SvStream& ): Zweimal EOF nicht erlaubt" );
     273           0 :                     nTab++;
     274           0 :                 break;
     275             : 
     276             :                 case 174:                               // FONT_FACE
     277           0 :                     Font_Face();
     278           0 :                 break;
     279             : 
     280             :                 case 176:                               // FONT_TYPE
     281           0 :                     Font_Type();
     282           0 :                 break;
     283             : 
     284             :                 case 177:                               // FONT_YSIZE
     285           0 :                     Font_Ysize();
     286           0 :                 break;
     287             : 
     288             :                 case 195:
     289           0 :                     if( nExtTab >= 0 )
     290           0 :                         pLotusRoot->pAttrTable->Apply( ( SCTAB ) nExtTab );
     291           0 :                     nExtTab++;
     292           0 :                     break;
     293             :                 case 197:
     294           0 :                     _Row( nRecLen );
     295           0 :                 break;
     296             :             }
     297             : 
     298             :             OSL_ENSURE( nNextRec >= pIn->Tell(),
     299             :                 "*ImportLotus::Read(): Etwas zu gierig..." );
     300           0 :             pIn->Seek( nNextRec );
     301           0 :             aPrgrsBar.Progress();
     302             :         }
     303             :     }
     304             : 
     305           0 :     pLotusRoot->pAttrTable->Apply( ( SCTAB ) nExtTab );
     306             : 
     307           0 :     return eRet;
     308           0 : }
     309             : 
     310             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10