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

Generated by: LCOV version 1.11