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 "lotfilter.hxx"
25 #include "lotimpop.hxx"
26 #include "lotattr.hxx"
27 #include "fprogressbar.hxx"
31 FltError
ImportLotus::Read()
35 S_START
, // analyse first BOF
36 S_WK1
, // in WK1-Stream
37 S_WK3
, // in WK3-Section
40 S_END
// Import finished
46 sal_uInt32 nNextRec
= 0UL;
47 FltError eRet
= eERR_OK
;
48 // ScFormulaCell *pLastFormCell;
55 pIn
->Seek( nNextRec
);
58 ScfStreamProgressBar
aPrgrsBar( *pIn
, pD
->GetDocumentShell() );
59 LotusContext
&rContext
= aConv
.getContext();
60 while( eAkt
!= S_END
)
62 pIn
->ReadUInt16( nOp
).ReadUInt16( nRecLen
);
64 if( pIn
->IsEof() || nNextRec
> SAL_MAX_UINT32
- nRecLen
- 4 )
67 nNextRec
+= nRecLen
+ 4;
72 case S_START
: // S_START
75 eRet
= SCERR_IMPORT_UNKNOWN_WK
;
83 switch (rContext
.pLotusRoot
->eFirstType
)
85 case Lotus_WK1
: eAkt
= S_WK1
; break;
86 case Lotus_WK3
: eAkt
= S_WK3
; break;
87 case Lotus_WK4
: eAkt
= S_WK4
; break;
88 case Lotus_FM3
: eAkt
= S_FM3
; break;
90 eRet
= SCERR_IMPORT_UNKNOWN_WK
;
96 eAkt
= S_END
; // TODO: add here something for <= WK1!
114 case 0x0002: // PASSWORD
115 eRet
= eERR_FILEPASSWD
;
119 case 0x0007: // COLUMNWIDTH
120 Columnwidth( nRecLen
);
123 case 0x0008: // HIDDENCOLUMN
124 Hiddencolumn( nRecLen
);
127 case 0x0009: // USERRANGE
131 case 0x0013: // FORMAT
134 case 0x0014: // ERRCELL
138 case 0x0015: // NACELL
142 case 0x0016: // LABELCELL
146 case 0x0017: // NUMBERCELL
150 case 0x0018: // SMALLNUMCELL
154 case 0x0019: // FORMULACELL
155 Formulacell( nRecLen
);
158 case 0x001b: // extended attributes
165 case 2007: // ROW PRESENTATION
166 RowPresentation( nRecLen
);
169 case 14000: // NAMED SHEET
190 OSL_ENSURE( nNextRec
>= pIn
->Tell(),
191 "*ImportLotus::Read(): Read too much..." );
193 pIn
->Seek( nNextRec
);
194 aPrgrsBar
.Progress();
197 // TODO: eliminate stupid names
198 SCTAB nTabs
= pD
->GetTableCount();
202 OUString
aRef( "temp" );
207 pD
->GetName( 0, aBaseName
);
208 aBaseName
= aBaseName
.copy(0, aBaseName
.getLength()-1);
210 for( nCnt
= 1 ; nCnt
< nTabs
; nCnt
++ )
212 OSL_ENSURE( pD
->HasTable( nCnt
),
213 "-ImportLotus::Read(): Where is my table?!" );
214 pD
->GetName( nCnt
, aTabName
);
215 if( aTabName
.equals(aRef
) )
217 aTabName
= aBaseName
;
218 pD
->CreateValidTabName( aTabName
);
219 pD
->RenameTab( nCnt
, aTabName
);
229 FltError
ImportLotus::Read(SvStream
& rIn
)
236 sal_uInt32 nNextRec
= 0UL;
237 FltError eRet
= eERR_OK
;
242 pIn
->Seek( nNextRec
);
245 ScfStreamProgressBar
aPrgrsBar( *pIn
, pD
->GetDocumentShell() );
246 LotusContext
&rContext
= aConv
.getContext();
249 pIn
->ReadUInt16( nOp
).ReadUInt16( nRecLen
);
251 if( pIn
->IsEof() || nNextRec
> SAL_MAX_UINT32
- nRecLen
- 4 )
255 nNextRec
+= nRecLen
+ 4;
260 if( nRecLen
!= 26 || !BofFm3() )
269 OSL_ENSURE( nTab
== 0,
270 "-ImportLotus::Read( SvStream& ): EOF twice!" );
274 case 174: // FONT_FACE
278 case 176: // FONT_TYPE
282 case 177: // FONT_YSIZE
288 rContext
.pLotusRoot
->pAttrTable
->Apply(rContext
.pLotusRoot
, (SCTAB
)nExtTab
);
296 OSL_ENSURE( nNextRec
>= pIn
->Tell(),
297 "*ImportLotus::Read(): Read too much..." );
298 pIn
->Seek( nNextRec
);
299 aPrgrsBar
.Progress();
303 rContext
.pLotusRoot
->pAttrTable
->Apply(rContext
.pLotusRoot
, (SCTAB
)nExtTab
);
308 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */