LibreOffice Module sc (master)  1
lotus.cxx
Go to the documentation of this file.
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 ErrCode ScFormatFilterPluginImpl::ScImportLotus123( SfxMedium& rMedium, ScDocument* pDocument, rtl_TextEncoding eSrc )
32 {
33  SvStream* pStream = rMedium.GetInStream();
34  if (!pStream)
35  return SCERR_IMPORT_OPEN;
36 
37  pStream->Seek( 0 );
38 
39  pStream->SetBufferSize( 32768 );
40 
41  LotusContext aContext(pDocument, eSrc);
42 
43  ImportLotus aLotusImport(aContext, *pStream, pDocument, eSrc);
44 
45  ErrCode eRet;
46  if (ScFilterOptions().GetWK3Flag())
47  eRet = aLotusImport.Read();
48  else
49  eRet = ErrCode(0xFFFFFFFF); // force WK1 /WKS
50 
51  // WARNING: QUICK-HACK for WK1 / WKS <-> WK3 / WK4
52  if( eRet == ErrCode(0xFFFFFFFF) )
53  {
54  pStream->Seek( 0 );
55  pStream->SetBufferSize( 32768 );
56  eRet = ScImportLotus123old(aContext, *pStream, pDocument, eSrc);
57  pStream->SetBufferSize( 0 );
58  return eRet;
59  }
60 
61  if( eRet != ERRCODE_NONE )
62  return eRet;
63 
64  if (aContext.eFirstType == Lotus123Typ::WK3)
65  {
66  // try to load *.FM3 file
67  INetURLObject aURL( rMedium.GetURLObject() );
68  aURL.setExtension( "FM3" );
69  SfxMedium aMedium( aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::STD_READ );
70  pStream = aMedium.GetInStream();
71  if ( pStream )
72  {
73  if( aLotusImport.Read( *pStream ) != ERRCODE_NONE )
75  }
76  else
78  }
79 
80  return eRet;
81 }
82 
83 LotusContext::LotusContext(ScDocument* pDocP, rtl_TextEncoding eQ)
84  : eTyp(eWK_UNKNOWN)
85  , bEOF(false)
86  , eCharset(eQ)
87  , pDoc(pDocP)
88  , pAttrRight(nullptr)
89  , pAttrLeft(nullptr)
90  , pAttrCenter(nullptr)
91  , pAttrRepeat(nullptr)
92  , pAttrStandard(nullptr)
93  , pValueFormCache(nullptr)
94  , maRangeNames()
95  , eFirstType( Lotus123Typ::X)
96  , eActType( Lotus123Typ::X)
97  , pRngNmBffWK3( new RangeNameBufferWK3(pDocP) )
98  , maAttrTable( *this )
99 {
100 }
101 
102 
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
URL aURL
#define SCWARN_IMPORT_WRONG_FM3
Definition: scerrors.hxx:46
sal_uInt64 Seek(sal_uInt64 nPos)
#define SCWARN_IMPORT_OPEN_FM3
Definition: scerrors.hxx:45
#define X
ErrCode ScImportLotus123old(LotusContext &rContext, SvStream &aStream, ScDocument *pDocument, rtl_TextEncoding eSrc)
Definition: filter.cxx:185
virtual ErrCode ScImportLotus123(SfxMedium &, ScDocument *, rtl_TextEncoding eSrc) override
Definition: lotus.cxx:31
void SetBufferSize(sal_uInt16 m_nBufSize)
Lotus123Typ
Definition: flttypes.hxx:33
#define SCERR_IMPORT_OPEN
Definition: scerrors.hxx:27
SvStream * GetInStream()
void Read(ScAddress &)
Definition: lotimpop.hxx:84
#define ERRCODE_NONE
const INetURLObject & GetURLObject() const
Lotus123Typ eFirstType
Definition: lotfilter.hxx:53
LotusContext(ScDocument *pDocP, rtl_TextEncoding eQ)
Definition: lotus.cxx:83