LCOV - code coverage report
Current view: top level - sc/source/filter/lotus - lotread.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 126 0.8 %
Date: 2012-08-25 Functions: 2 4 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 160 1.2 %

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

Generated by: LCOV version 1.10