xref: /aoo42x/main/sc/source/filter/lotus/lotus.cxx (revision b77af630)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_scfilt.hxx"
26 #include "lotimpop.hxx"
27 
28 #include <sfx2/docfile.hxx>
29 #include <tools/urlobj.hxx>
30 
31 #include "scerrors.hxx"
32 #include "root.hxx"
33 #include "filtopt.hxx"
34 #include "ftools.hxx"
35 
36 //------------------------------------------------------------------------
37 
38 extern FltError ScImportLotus123old( SvStream&, ScDocument*, CharSet eSrc );
39 		// alter Krempel in filter.cxx!
40 
ScImportLotus123(SfxMedium & rMedium,ScDocument * pDocument,CharSet eSrc)41 FltError ScFormatFilterPluginImpl::ScImportLotus123( SfxMedium& rMedium, ScDocument* pDocument, CharSet eSrc )
42 {
43         ScFilterOptions aFilterOpt;
44 	sal_Bool bWithWK3 = aFilterOpt.GetWK3Flag();
45 
46 	SvStream*			pStream = rMedium.GetInStream();
47 
48 	if( !pStream )
49 		return eERR_OPEN;
50 
51 	FltError			eRet;
52 
53 	pStream->Seek( 0UL );
54 
55 	pStream->SetBufferSize( 32768 );
56 
57 	ImportLotus			aLotusImport( *pStream, pDocument, eSrc );
58 
59 	if( bWithWK3 )
60 		eRet = aLotusImport.Read();
61 	else
62 		eRet = 0xFFFFFFFF;	// WK1 /WKS erzwingen
63 
64 	// ACHTUNG: QUICK-HACK fuer WK1 / WKS  <->  WK3 / WK4
65 	if( eRet == 0xFFFFFFFF )
66 	{
67 		pStream->Seek( 0UL );
68 
69 		pStream->SetBufferSize( 32768 );
70 
71 		eRet = ScImportLotus123old( *pStream, pDocument, eSrc );
72 
73 		pStream->SetBufferSize( 0 );
74 
75 		return eRet;
76 	}
77 
78 	if( eRet != eERR_OK )
79 		return eRet;
80 
81 	if( pLotusRoot->eFirstType == Lotus_WK3 )
82 	{// versuchen *.FM3-File zu laden
83 		INetURLObject aURL( rMedium.GetURLObject() );
84         aURL.setExtension( CREATE_STRING( "FM3" ) );
85 		SfxMedium aMedium( aURL.GetMainURL(INetURLObject::NO_DECODE), STREAM_STD_READ, sal_True );
86         pStream = aMedium.GetInStream();
87 		if ( pStream )
88 		{
89 			if( aLotusImport.Read( *pStream ) != eERR_OK )
90 				eRet = SCWARN_IMPORT_WRONG_FM3;
91 		}
92 		else
93 			eRet = SCWARN_IMPORT_OPEN_FM3;
94 	}
95 
96 	return eRet;
97 }
98 
99