LCOV - code coverage report
Current view: top level - sc/source/filter/lotus - filter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 79 2.5 %
Date: 2012-08-25 Functions: 2 5 40.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 113 1.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : //  Das geht:   Versionserkennung WKS, WK1 und WK3
      30                 :            : //              ...Rest steht in op.cpp
      31                 :            : 
      32                 :            : //------------------------------------------------------------------------
      33                 :            : 
      34                 :            : #include <tools/solar.h>
      35                 :            : #include <string.h>
      36                 :            : #include <map>
      37                 :            : 
      38                 :            : #include "filter.hxx"
      39                 :            : #include "document.hxx"
      40                 :            : #include "compiler.hxx"
      41                 :            : #include "scerrors.hxx"
      42                 :            : 
      43                 :            : #include "root.hxx"
      44                 :            : #include "lotrange.hxx"
      45                 :            : #include "optab.h"
      46                 :            : #include "scmem.h"
      47                 :            : #include "decl.h"
      48                 :            : #include "tool.h"
      49                 :            : 
      50                 :            : #include "fprogressbar.hxx"
      51                 :            : 
      52                 :            : #include "op.h"
      53                 :            : 
      54                 :            : // Konstanten ------------------------------------------------------------
      55                 :            : const sal_uInt16        nBOF = 0x0000;
      56                 :            : 
      57                 :            : 
      58                 :            : 
      59                 :            : // externe Variablen -----------------------------------------------------
      60                 :            : extern WKTYP        eTyp;   // Typ der gerade in bearbeitung befindlichen Datei
      61                 :            : WKTYP               eTyp;
      62                 :            : 
      63                 :            : extern sal_Bool         bEOF;           // zeigt Ende der Datei
      64                 :            : sal_Bool                bEOF;
      65                 :            : 
      66                 :            : extern CharSet      eCharVon;
      67                 :            : CharSet             eCharVon;
      68                 :            : 
      69                 :            : extern ScDocument*  pDoc;           // Aufhaenger zum Dokumentzugriff
      70                 :            : ScDocument*         pDoc;
      71                 :            : 
      72                 :            : 
      73                 :            : extern OPCODE_FKT   pOpFkt[ FKT_LIMIT ];
      74                 :            :                                     // -> optab.cxx, Tabelle moeglicher Opcodes
      75                 :            : extern OPCODE_FKT   pOpFkt123[ FKT_LIMIT123 ];
      76                 :            :                                     // -> optab.cxx, Table of possible Opcodes
      77                 :            : 
      78                 :            : LOTUS_ROOT*         pLotusRoot = NULL;
      79                 :            : 
      80                 :            : 
      81                 :          8 : std::map<sal_uInt16, ScPatternAttr> aLotusPatternPool;
      82                 :            : 
      83                 :            : static FltError
      84                 :          0 : generate_Opcodes( SvStream& aStream, ScDocument& rDoc,
      85                 :            :                   ScfStreamProgressBar& aPrgrsBar, WKTYP eType )
      86                 :            : {
      87                 :            :     OPCODE_FKT *pOps;
      88                 :            :     int         nOps;
      89                 :            : 
      90   [ #  #  #  #  :          0 :     switch(eType)
                      # ]
      91                 :            :     {
      92                 :            :         case eWK_1:
      93                 :            :         case eWK_2:
      94                 :          0 :         pOps = pOpFkt;
      95                 :          0 :         nOps = FKT_LIMIT;
      96                 :          0 :         break;
      97                 :            :         case eWK123:
      98                 :          0 :         pOps = pOpFkt123;
      99                 :          0 :         nOps = FKT_LIMIT123;
     100                 :          0 :         break;
     101                 :          0 :         case eWK3:      return eERR_NI;
     102                 :          0 :         case eWK_Error: return eERR_FORMAT;
     103                 :          0 :         default:        return eERR_UNKN_WK;
     104                 :            :      }
     105                 :            : 
     106                 :            :     // #i76299# seems that SvStream::IsEof() does not work correctly
     107                 :          0 :     aStream.Seek( STREAM_SEEK_TO_END );
     108                 :          0 :     sal_Size nStrmSize = aStream.Tell();
     109                 :          0 :     aStream.Seek( STREAM_SEEK_TO_BEGIN );
     110 [ #  # ][ #  # ]:          0 :     while( !bEOF && !aStream.IsEof() && (aStream.Tell() < nStrmSize) )
         [ #  # ][ #  # ]
     111                 :            :     {
     112                 :            :         sal_uInt16 nOpcode, nLength;
     113                 :            : 
     114 [ #  # ][ #  # ]:          0 :         aStream >> nOpcode >> nLength;
     115         [ #  # ]:          0 :         aPrgrsBar.Progress();
     116         [ #  # ]:          0 :         if( nOpcode == LOTUS_EOF )
     117                 :          0 :         bEOF = sal_True;
     118                 :            : 
     119         [ #  # ]:          0 :         else if( nOpcode == LOTUS_FILEPASSWD )
     120                 :          0 :         return eERR_FILEPASSWD;
     121                 :            : 
     122         [ #  # ]:          0 :         else if( nOpcode < nOps )
     123         [ #  # ]:          0 :         pOps[ nOpcode ] ( aStream, nLength );
     124                 :            : 
     125 [ #  # ][ #  # ]:          0 :         else if( eType == eWK123 &&
     126                 :            :              nOpcode == LOTUS_PATTERN )
     127                 :            :             {
     128                 :            :         // This is really ugly - needs re-factoring ...
     129         [ #  # ]:          0 :         aStream.SeekRel(nLength);
     130 [ #  # ][ #  # ]:          0 :         aStream >> nOpcode >> nLength;
     131         [ #  # ]:          0 :         if ( nOpcode == 0x29a)
     132                 :            :         {
     133         [ #  # ]:          0 :             aStream.SeekRel(nLength);
     134 [ #  # ][ #  # ]:          0 :             aStream >> nOpcode >> nLength;
     135         [ #  # ]:          0 :             if ( nOpcode == 0x804 )
     136                 :            :             {
     137         [ #  # ]:          0 :             aStream.SeekRel(nLength);
     138         [ #  # ]:          0 :             OP_ApplyPatternArea123(aStream);
     139                 :            :             }
     140                 :            :             else
     141         [ #  # ]:          0 :             aStream.SeekRel(nLength);
     142                 :            :         }
     143                 :            :         else
     144         [ #  # ]:          0 :             aStream.SeekRel(nLength);
     145                 :            :         }
     146                 :            :         else
     147         [ #  # ]:          0 :         aStream.SeekRel( nLength );
     148                 :            :     }
     149                 :            : 
     150                 :          0 :     MemDelete();
     151                 :            : 
     152                 :          0 :     rDoc.CalcAfterLoad();
     153                 :            : 
     154                 :          0 :     return eERR_OK;
     155                 :            : }
     156                 :            : 
     157                 :          0 : WKTYP ScanVersion( SvStream& aStream )
     158                 :            : {
     159                 :            :     // PREC:    pWKDatei:   Zeiger auf offene Datei
     160                 :            :     // POST:    return:     Typ der Datei
     161                 :            :     sal_uInt16          nOpcode, nVersNr, nRecLen;
     162                 :            : 
     163                 :            :     // erstes Byte muss wegen BOF zwingend 0 sein!
     164         [ #  # ]:          0 :     aStream >> nOpcode;
     165         [ #  # ]:          0 :     if( nOpcode != nBOF )
     166                 :          0 :         return eWK_UNKNOWN;
     167                 :            : 
     168 [ #  # ][ #  # ]:          0 :     aStream >> nRecLen >> nVersNr;
     169                 :            : 
     170         [ #  # ]:          0 :     if( aStream.IsEof() )
     171                 :          0 :         return eWK_Error;
     172                 :            : 
     173   [ #  #  #  #  :          0 :     switch( nVersNr )
                   #  # ]
     174                 :            :     {
     175                 :            :         case 0x0404:
     176         [ #  # ]:          0 :             if( nRecLen == 2 )
     177                 :          0 :                 return eWK_1;
     178                 :            :             else
     179                 :          0 :                 return eWK_UNKNOWN;
     180                 :            : 
     181                 :            :         case 0x0406:
     182         [ #  # ]:          0 :             if( nRecLen == 2 )
     183                 :          0 :                 return eWK_2;
     184                 :            :             else
     185                 :          0 :                 return eWK_UNKNOWN;
     186                 :            : 
     187                 :            :         case 0x1000:
     188         [ #  # ]:          0 :             aStream >> nVersNr;
     189         [ #  # ]:          0 :             if( aStream.IsEof() ) return eWK_Error;
     190 [ #  # ][ #  # ]:          0 :             if( nVersNr == 0x0004 && nRecLen == 26 )
     191                 :            :                         {       // 4 bytes of 26 read => skip 22 (read instead of seek to make IsEof() work just in case)
     192                 :            :                 sal_Char aDummy[22];
     193         [ #  # ]:          0 :                 aStream.Read( aDummy, 22 );
     194         [ #  # ]:          0 :                 return aStream.IsEof() ? eWK_Error : eWK3;
     195                 :            :             }
     196                 :          0 :             break;
     197                 :            :         case 0x1003:
     198         [ #  # ]:          0 :             if( nRecLen == 0x1a )
     199                 :          0 :                 return eWK123;
     200                 :            :             else
     201                 :          0 :                 return eWK_UNKNOWN;
     202                 :            :         case 0x1005:
     203         [ #  # ]:          0 :             if( nRecLen == 0x1a )
     204                 :          0 :                 return eWK123;
     205                 :            :             else
     206                 :          0 :                 return eWK_UNKNOWN;
     207                 :            :     }
     208                 :            : 
     209                 :          0 :     return eWK_UNKNOWN;
     210                 :            : }
     211                 :            : 
     212                 :          0 : FltError ScImportLotus123old( SvStream& aStream, ScDocument* pDocument, CharSet eSrc )
     213                 :            : {
     214         [ #  # ]:          0 :     aStream.Seek( 0UL );
     215                 :            : 
     216                 :            :     // Zeiger auf Dokument global machen
     217                 :          0 :     pDoc = pDocument;
     218                 :            : 
     219                 :          0 :     bEOF = false;
     220                 :            : 
     221                 :          0 :     eCharVon = eSrc;
     222                 :            : 
     223                 :            :     // Speicher besorgen
     224 [ #  # ][ #  # ]:          0 :     if( !MemNew() )
     225                 :          0 :         return eERR_NOMEM;
     226                 :            : 
     227         [ #  # ]:          0 :     InitPage(); // Seitenformat initialisieren (nur Tab 0!)
     228                 :            : 
     229                 :            :         // Progressbar starten
     230         [ #  # ]:          0 :     ScfStreamProgressBar aPrgrsBar( aStream, pDocument->GetDocumentShell() );
     231                 :            : 
     232                 :            :     // Datei-Typ ermitteln
     233         [ #  # ]:          0 :     eTyp = ScanVersion( aStream );
     234                 :            : 
     235                 :          0 :     aLotusPatternPool.clear();
     236                 :            : 
     237 [ #  # ][ #  # ]:          0 :     return generate_Opcodes( aStream, *pDoc, aPrgrsBar, eTyp );
     238 [ +  - ][ +  - ]:         24 : }
     239                 :            : 
     240                 :            : 
     241                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10