1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 // Das geht: Versionserkennung WKS, WK1 und WK3
31 // ...Rest steht in op.cpp
33 //------------------------------------------------------------------------
35 #include <tools/solar.h>
40 #include "document.hxx"
41 #include "compiler.hxx"
42 #include "scerrors.hxx"
45 #include "lotrange.hxx"
51 #include "fprogressbar.hxx"
55 // Konstanten ------------------------------------------------------------
56 const UINT16 nBOF
= 0x0000;
60 // externe Variablen -----------------------------------------------------
61 extern WKTYP eTyp
; // Typ der gerade in bearbeitung befindlichen Datei
64 extern BOOL bEOF
; // zeigt Ende der Datei
67 extern CharSet eCharNach
; // Zeichenkonvertierung von->nach
70 extern CharSet eCharVon
;
73 extern ScDocument
* pDoc
; // Aufhaenger zum Dokumentzugriff
77 extern sal_Char
* pPuffer
; // -> memory.cxx
78 extern sal_Char
* pDummy1
; // -> memory.cxx
80 extern OPCODE_FKT pOpFkt
[ FKT_LIMIT
];
81 // -> optab.cxx, Tabelle moeglicher Opcodes
82 extern OPCODE_FKT pOpFkt123
[ FKT_LIMIT123
];
83 // -> optab.cxx, Table of possible Opcodes
85 extern long nDateiLaenge
; // -> datei.cpp, ...der gerade offenen Datei
87 LOTUS_ROOT
* pLotusRoot
= NULL
;
90 std::map
<UINT16
, ScPatternAttr
> aLotusPatternPool
;
93 generate_Opcodes( SvStream
& aStream
, ScDocument
& rDoc
,
94 ScfStreamProgressBar
& aPrgrsBar
, WKTYP eType
)
110 case eWK3
: return eERR_NI
;
111 case eWK_Error
: return eERR_FORMAT
;
112 default: return eERR_UNKN_WK
;
115 // #i76299# seems that SvStream::IsEof() does not work correctly
116 aStream
.Seek( STREAM_SEEK_TO_END
);
117 sal_Size nStrmSize
= aStream
.Tell();
118 aStream
.Seek( STREAM_SEEK_TO_BEGIN
);
119 while( !bEOF
&& !aStream
.IsEof() && (aStream
.Tell() < nStrmSize
) )
121 UINT16 nOpcode
, nLength
;
123 aStream
>> nOpcode
>> nLength
;
124 aPrgrsBar
.Progress();
125 if( nOpcode
== LOTUS_EOF
)
128 else if( nOpcode
== LOTUS_FILEPASSWD
)
129 return eERR_FILEPASSWD
;
131 else if( nOpcode
< nOps
)
132 pOps
[ nOpcode
] ( aStream
, nLength
);
134 else if( eType
== eWK123
&&
135 nOpcode
== LOTUS_PATTERN
)
137 // This is really ugly - needs re-factoring ...
138 aStream
.SeekRel(nLength
);
139 aStream
>> nOpcode
>> nLength
;
140 if ( nOpcode
== 0x29a)
142 aStream
.SeekRel(nLength
);
143 aStream
>> nOpcode
>> nLength
;
144 if ( nOpcode
== 0x804 )
146 aStream
.SeekRel(nLength
);
147 OP_ApplyPatternArea123(aStream
);
150 aStream
.SeekRel(nLength
);
153 aStream
.SeekRel(nLength
);
156 aStream
.SeekRel( nLength
);
161 rDoc
.CalcAfterLoad();
166 WKTYP
ScanVersion( SvStream
& aStream
)
168 // PREC: pWKDatei: Zeiger auf offene Datei
169 // POST: return: Typ der Datei
170 UINT16 nOpcode
, nVersNr
, nRecLen
;
172 // erstes Byte muss wegen BOF zwingend 0 sein!
174 if( nOpcode
!= nBOF
)
177 aStream
>> nRecLen
>> nVersNr
;
179 if( aStream
.IsEof() )
198 if( aStream
.IsEof() ) return eWK_Error
;
199 if( nVersNr
== 0x0004 && nRecLen
== 26 )
200 { // 4 Bytes von 26 gelesen->22 ueberlesen
201 aStream
.Read( pDummy1
, 22 );
206 if( nRecLen
== 0x1a )
211 if( nRecLen
== 0x1a )
220 FltError
ScImportLotus123old( SvStream
& aStream
, ScDocument
* pDocument
, CharSet eSrc
)
224 // Zeiger auf Dokument global machen
235 InitPage(); // Seitenformat initialisieren (nur Tab 0!)
237 // Progressbar starten
238 ScfStreamProgressBar
aPrgrsBar( aStream
, pDocument
->GetDocumentShell() );
240 // Datei-Typ ermitteln
241 eTyp
= ScanVersion( aStream
);
243 aLotusPatternPool
.clear();
245 return generate_Opcodes( aStream
, *pDoc
, aPrgrsBar
, eTyp
);