1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "document.hxx"
22 #include "scerrors.hxx"
24 #include "lotimpop.hxx"
25 #include "lotattr.hxx"
26 #include "fprogressbar.hxx"
32 FltError
ImportLotus::Read()
36 S_START
, // analyse first BOF
37 S_WK1
, // in WK1-Stream
38 S_WK3
, // in WK3-Section
41 S_END
// Import finished
47 sal_uInt32 nNextRec
= 0UL;
48 FltError eRet
= eERR_OK
;
49 // ScFormulaCell *pLastFormCell;
56 pIn
->Seek( nNextRec
);
58 // Progressbar starten
59 ScfStreamProgressBar
aPrgrsBar( *pIn
, pD
->GetDocumentShell() );
61 while( eAkt
!= S_END
)
63 pIn
->ReadUInt16( nOp
).ReadUInt16( nRecLen
);
65 if( pIn
->IsEof() || nNextRec
> SAL_MAX_UINT32
- nRecLen
- 4 )
68 nNextRec
+= nRecLen
+ 4;
73 case S_START
: // S_START
76 eRet
= SCERR_IMPORT_UNKNOWN_WK
;
84 switch( pLotusRoot
->eFirstType
)
86 case Lotus_WK1
: eAkt
= S_WK1
; break;
87 case Lotus_WK3
: eAkt
= S_WK3
; break;
88 case Lotus_WK4
: eAkt
= S_WK4
; break;
89 case Lotus_FM3
: eAkt
= S_FM3
; break;
91 eRet
= SCERR_IMPORT_UNKNOWN_WK
;
97 eAkt
= S_END
; // hier kommt wat fuer <= WK1 hinne!
115 case 0x0002: // PASSWORD
116 eRet
= eERR_FILEPASSWD
;
120 case 0x0007: // COLUMNWIDTH
121 Columnwidth( nRecLen
);
124 case 0x0008: // HIDDENCOLUMN
125 Hiddencolumn( nRecLen
);
128 case 0x0009: // USERRANGE
132 case 0x0013: // FORMAT
135 case 0x0014: // ERRCELL
139 case 0x0015: // NACELL
143 case 0x0016: // LABELCELL
147 case 0x0017: // NUMBERCELL
151 case 0x0018: // SMALLNUMCELL
155 case 0x0019: // FORMULACELL
156 Formulacell( nRecLen
);
159 case 0x001b: // extended attributes
166 case 2007: // ROW PRESENTATION
167 RowPresentation( nRecLen
);
170 case 14000: // NAMED SHEET
191 OSL_ENSURE( nNextRec
>= pIn
->Tell(),
192 "*ImportLotus::Read(): Etwas zu gierig..." );
194 pIn
->Seek( nNextRec
);
195 aPrgrsBar
.Progress();
198 // duemmliche Namen eliminieren
199 SCTAB nTabs
= pD
->GetTableCount();
203 OUString
aRef( "temp" );
208 pD
->GetName( 0, aBaseName
);
209 aBaseName
= aBaseName
.copy(0, aBaseName
.getLength()-1);
211 for( nCnt
= 1 ; nCnt
< nTabs
; nCnt
++ )
213 OSL_ENSURE( pD
->HasTable( nCnt
),
214 "-ImportLotus::Read(): Wo ist meine Tabelle?!" );
215 pD
->GetName( nCnt
, aTabName
);
216 if( aTabName
.equals(aRef
) )
218 aTabName
= aBaseName
;
219 pD
->CreateValidTabName( aTabName
);
220 pD
->RenameTab( nCnt
, aTabName
);
231 FltError
ImportLotus::Read( SvStream
& rIn
)
238 sal_uInt32 nNextRec
= 0UL;
239 FltError eRet
= eERR_OK
;
244 pIn
->Seek( nNextRec
);
246 // Progressbar starten
247 ScfStreamProgressBar
aPrgrsBar( *pIn
, pD
->GetDocumentShell() );
251 pIn
->ReadUInt16( nOp
).ReadUInt16( nRecLen
);
253 if( pIn
->IsEof() || nNextRec
> SAL_MAX_UINT32
- nRecLen
- 4 )
257 nNextRec
+= nRecLen
+ 4;
262 if( nRecLen
!= 26 || !BofFm3() )
271 OSL_ENSURE( nTab
== 0,
272 "-ImportLotus::Read( SvStream& ): Zweimal EOF nicht erlaubt" );
276 case 174: // FONT_FACE
280 case 176: // FONT_TYPE
284 case 177: // FONT_YSIZE
290 pLotusRoot
->pAttrTable
->Apply( ( SCTAB
) nExtTab
);
298 OSL_ENSURE( nNextRec
>= pIn
->Tell(),
299 "*ImportLotus::Read(): Etwas zu gierig..." );
300 pIn
->Seek( nNextRec
);
301 aPrgrsBar
.Progress();
305 pLotusRoot
->pAttrTable
->Apply( ( SCTAB
) nExtTab
);
310 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */