Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "lotfilter.hxx"
21 : #include "lotimpop.hxx"
22 :
23 : #include <sfx2/docfile.hxx>
24 : #include <tools/urlobj.hxx>
25 :
26 : #include "scerrors.hxx"
27 : #include "root.hxx"
28 : #include "filtopt.hxx"
29 : #include "ftools.hxx"
30 :
31 4 : FltError ScFormatFilterPluginImpl::ScImportLotus123( SfxMedium& rMedium, ScDocument* pDocument, rtl_TextEncoding eSrc )
32 : {
33 4 : ScFilterOptions aFilterOpt;
34 4 : bool bWithWK3 = aFilterOpt.GetWK3Flag();
35 :
36 4 : SvStream* pStream = rMedium.GetInStream();
37 :
38 4 : if( !pStream )
39 0 : return eERR_OPEN;
40 :
41 : FltError eRet;
42 :
43 4 : pStream->Seek( 0UL );
44 :
45 4 : pStream->SetBufferSize( 32768 );
46 :
47 8 : LotusContext aContext;
48 :
49 8 : ImportLotus aLotusImport(aContext, *pStream, pDocument, eSrc);
50 :
51 4 : if( bWithWK3 )
52 0 : eRet = aLotusImport.Read();
53 : else
54 4 : eRet = 0xFFFFFFFF; // WK1 /WKS erzwingen
55 :
56 : // ACHTUNG: QUICK-HACK fuer WK1 / WKS <-> WK3 / WK4
57 4 : if( eRet == 0xFFFFFFFF )
58 : {
59 4 : pStream->Seek( 0UL );
60 :
61 4 : pStream->SetBufferSize( 32768 );
62 :
63 4 : eRet = ScImportLotus123old(aContext, *pStream, pDocument, eSrc);
64 :
65 4 : pStream->SetBufferSize( 0 );
66 :
67 4 : return eRet;
68 : }
69 :
70 0 : if( eRet != eERR_OK )
71 0 : return eRet;
72 :
73 0 : if (aContext.pLotusRoot->eFirstType == Lotus_WK3)
74 : {
75 : // versuchen *.FM3-File zu laden
76 0 : INetURLObject aURL( rMedium.GetURLObject() );
77 0 : aURL.setExtension( "FM3" );
78 0 : SfxMedium aMedium( aURL.GetMainURL(INetURLObject::NO_DECODE), STREAM_STD_READ );
79 0 : pStream = aMedium.GetInStream();
80 0 : if ( pStream )
81 : {
82 0 : if( aLotusImport.Read( *pStream ) != eERR_OK )
83 0 : eRet = SCWARN_IMPORT_WRONG_FM3;
84 : }
85 : else
86 0 : eRet = SCWARN_IMPORT_OPEN_FM3;
87 : }
88 :
89 4 : return eRet;
90 30 : }
91 :
92 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|