Kaydet (Commit) 206b32c2 authored tarafından Caolán McNamara's avatar Caolán McNamara

refactor lotus wks importer to remove globals

so that the global aLotusPatternPool map gets destroyed at a sane point in time
where calling delete on its patterns is a legal operation and not at some
random location in the dtor chain

Change-Id: I6f202c5345c6a227b5a680d70150bf32fb9450c7
üst abbeed75
......@@ -129,7 +129,9 @@ class ScFormatFilter {
SC_DLLPUBLIC static ScFormatFilterPlugin &Get();
};
FltError ScImportLotus123old( SvStream&, ScDocument*, rtl_TextEncoding eSrc );
struct LotusContext;
FltError ScImportLotus123old(LotusContext& rContext, SvStream&, ScDocument*, rtl_TextEncoding eSrc);
#endif
......
......@@ -110,7 +110,7 @@ class LotAttrCol
public:
void SetAttr (const SCROW nRow, const ScPatternAttr&);
void Apply (const SCCOL nCol, const SCTAB nTab );
void Apply(LOTUS_ROOT* pLotRoot, const SCCOL nCol, const SCTAB nTab);
private:
struct ENTRY
......@@ -130,7 +130,7 @@ public:
void SetAttr( const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, const LotAttrWK3& );
void Apply( const SCTAB nTabNum );
void Apply(LOTUS_ROOT* pLotRoot, const SCTAB nTabNum);
private:
......
......@@ -56,9 +56,12 @@ enum FUNC_TYPE
// fuer 'Problemfaelle' beim Import
};
struct LotusContext;
class LotusToSc : public LotusConverterBase
{
private:
LotusContext& m_rContext;
rtl_TextEncoding eSrcChar;
TokenId nAddToken; // ')+1.0'
TokenId nSubToken; // ~
......@@ -69,8 +72,7 @@ private:
static FUNC_TYPE IndexToTypeWK123( sal_uInt8 );
static DefTokenId IndexToTokenWK123( sal_uInt8 );
void DoFunc( DefTokenId eOc, sal_uInt8 nAnz, const sal_Char* pExtName );
void LotusRelToScRel( sal_uInt16 nCol, sal_uInt16 nRow,
ScSingleRefData& rSRD );
void LotusRelToScRel(sal_uInt16 nCol, sal_uInt16 nRow, ScSingleRefData& rSRD);
bool bWK3; // alternative Codeumsetzung statt fuer < WK1
bool bWK123; // alternative for 123
......@@ -85,13 +87,14 @@ private:
void NegToken( TokenId& rParam );
// ACHTUNG: wie ~, nur wird '-(<rParam>)' gebildet
public:
LotusToSc( SvStream& aStr, svl::SharedStringPool& rSPool, rtl_TextEncoding eSrc, bool b );
LotusToSc(LotusContext &rContext, SvStream& aStr, svl::SharedStringPool& rSPool, rtl_TextEncoding eSrc, bool b);
virtual ConvErr Convert( const ScTokenArray*& rpErg, sal_Int32& nRest,
const FORMULA_TYPE eFT = FT_CellFormula ) SAL_OVERRIDE;
void Reset( const ScAddress& rEingPos );
inline void SetWK3( void );
LotusContext& getContext() { return m_rContext; }
private:
using LotusConverterBase::Reset;
......
......@@ -30,6 +30,7 @@
class ScFormulaCell;
class LotusFontBuffer;
struct LotusContext;
class ImportLotus : public ImportTyp
{
......@@ -76,7 +77,7 @@ private:
inline void Skip( const sal_uInt16 nNumBytes );
public:
ImportLotus( SvStream&, ScDocument*, rtl_TextEncoding eSrc );
ImportLotus(LotusContext& rContext, SvStream&, ScDocument*, rtl_TextEncoding eSrc);
virtual ~ImportLotus();
......
......@@ -94,15 +94,16 @@ inline bool LotusRange::IsSingle( void ) const
class LotusRangeList
{
private:
LOTUS_ROOT* m_pLotRoot;
LR_ID nIdCnt;
ScComplexRefData aComplRef;
ScComplexRefData aComplRef;
static SCCOL nEingCol;
static SCROW nEingRow;
std::vector<LotusRange*> maRanges;
public:
LotusRangeList( void );
~LotusRangeList( void );
LotusRangeList(LOTUS_ROOT* pLotRoot);
~LotusRangeList( void );
inline sal_uInt16 GetIndex( SCCOL nCol, SCROW nRow );
inline sal_uInt16 GetIndex( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE );
sal_uInt16 GetIndex( const LotusRange& );
......
......@@ -172,12 +172,13 @@ private:
}
};
ScTokenArray* pScTokenArray;
sal_uInt16 nIntCount;
LOTUS_ROOT* m_pLotRoot;
ScTokenArray* pScTokenArray;
sal_uInt16 nIntCount;
std::vector<Entry> maEntries;
public:
RangeNameBufferWK3( void );
RangeNameBufferWK3(LOTUS_ROOT* pLotRoot);
virtual ~RangeNameBufferWK3();
void Add( const OUString& rName, const ScComplexRefData& rCRD );
inline void Add( const OUString& rName, const ScRange& aScRange );
......
......@@ -24,38 +24,39 @@
// OP-Code-Funktionen
class SvStream;
void NI( SvStream &aStream, sal_uInt16 nLaenge );
void OP_BOF( SvStream &aStream, sal_uInt16 nLaenge );
void OP_EOF( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Integer( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Number( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Label( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Integer3( SvStream &aStream, sal_uInt16 nLaenge ); // WK3
void OP_Number3( SvStream &aStream, sal_uInt16 nLaenge ); // WK3
void OP_Formula( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Formula3( SvStream &aStream, sal_uInt16 nLaenge ); // WK3
void OP_ColumnWidth( SvStream &aStream, sal_uInt16 nLaenge );
void OP_NamedRange( SvStream &aStream, sal_uInt16 nLaenge );
void OP_SymphNamedRange( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Footer( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Header( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Margins( SvStream &aStream, sal_uInt16 nLaenge );
void OP_HiddenCols( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Window1( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Blank( SvStream &aStream, sal_uInt16 nLaenge );
struct LotusContext;
void NI(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_BOF(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_EOF(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_Integer(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_Number(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_Label(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_Integer3(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge ); // WK3
void OP_Number3(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge ); // WK3
void OP_Formula(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_Formula3(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge ); // WK3
void OP_ColumnWidth(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_NamedRange(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_SymphNamedRange(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_Footer(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_Header(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_Margins(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_HiddenCols(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_Window1(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_Blank(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
// Lotus 123 bits.
void OP_BOF123( SvStream &aStream, sal_uInt16 nLaenge );
void OP_EOF123( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Number123( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Label123( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Formula123( SvStream &aStream, sal_uInt16 nLaenge );
void OP_IEEENumber123(SvStream& r, sal_uInt16 n);
void OP_Note123(SvStream &aStream, sal_uInt16 nLaenge);
void OP_CreatePattern123(SvStream &aStream, sal_uInt16 nLaenge);
void OP_SheetName123( SvStream &rStream, sal_uInt16 nLength );
void OP_HorAlign123(sal_uInt8 nAlignPattern, SfxItemSet& rPattern /* const ScPatternAttr& rPattern*/ );
void OP_VerAlign123(sal_uInt8 nAlignPattern, SfxItemSet& rPattern /* const ScPatternAttr& rPattern*/ );
void OP_ApplyPatternArea123(SvStream& r);
void OP_BOF123(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_EOF123(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_Number123(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_Label123(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_Formula123(LotusContext &rContext, SvStream &aStream, sal_uInt16 nLaenge );
void OP_IEEENumber123(LotusContext &rContext,SvStream& r, sal_uInt16 n);
void OP_Note123(LotusContext &rContext,SvStream &aStream, sal_uInt16 nLaenge);
void OP_CreatePattern123(LotusContext &rContext,SvStream &aStream, sal_uInt16 nLaenge);
void OP_SheetName123(LotusContext &rContext, SvStream &rStream, sal_uInt16 nLength );
void OP_HorAlign123(LotusContext &rContext,sal_uInt8 nAlignPattern, SfxItemSet& rPattern /* const ScPatternAttr& rPattern*/ );
void OP_VerAlign123(LotusContext &rContext,sal_uInt8 nAlignPattern, SfxItemSet& rPattern /* const ScPatternAttr& rPattern*/ );
void OP_ApplyPatternArea123(LotusContext &rContext,SvStream& r);
#endif
......
......@@ -20,7 +20,9 @@
#ifndef INCLUDED_SC_SOURCE_FILTER_INC_OPTAB_H
#define INCLUDED_SC_SOURCE_FILTER_INC_OPTAB_H
typedef void ( *OPCODE_FKT )( SvStream &aStream, sal_uInt16 nLaenge );
struct LotusContext;
typedef void ( *OPCODE_FKT )(LotusContext &rContext, SvStream &rStream, sal_uInt16 nLaenge);
#define FKT_LIMIT 101
......
......@@ -102,8 +102,6 @@ struct LOTUS_ROOT
~LOTUS_ROOT();
};
extern LOTUS_ROOT* pLotusRoot; // -> Inkarn. in filter.cxx
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -21,11 +21,12 @@
#define INCLUDED_SC_SOURCE_FILTER_INC_SCMEM_H
#include <sal/config.h>
#include <sal/types.h>
bool MemNew( void );
void MemDelete( void );
struct LotusContext;
bool MemNew(LotusContext& rContext);
void MemDelete(LotusContext& rContext);
#endif
......
......@@ -27,9 +27,11 @@
const sal_uInt8 nDezStd = 0; // Dezimalstellen fuer Standard-Zellen
const sal_uInt8 nDezFloat = 2; // " " Float-Zellen
void PutFormString( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Char *pString );
struct LotusContext;
void SetFormat( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt8 nFormat, sal_uInt8 nSt );
void PutFormString(LotusContext& rContext, SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Char *pString);
void SetFormat(LotusContext& rContext, SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt8 nFormat, sal_uInt8 nSt);
void InitPage( void );
......
......@@ -34,52 +34,25 @@
#include "scmem.h"
#include "decl.h"
#include "tool.h"
#include "fprogressbar.hxx"
#include "op.h"
// Konstanten
const sal_uInt16 nBOF = 0x0000;
// externe Variablen
extern WKTYP eTyp; // Typ der gerade in bearbeitung befindlichen Datei
WKTYP eTyp;
extern bool bEOF; // zeigt Ende der Datei
bool bEOF;
extern rtl_TextEncoding eCharVon;
rtl_TextEncoding eCharVon;
extern ScDocument* pDoc; // Aufhaenger zum Dokumentzugriff
ScDocument* pDoc;
extern OPCODE_FKT pOpFkt[ FKT_LIMIT ];
// -> optab.cxx, Tabelle moeglicher Opcodes
extern OPCODE_FKT pOpFkt123[ FKT_LIMIT123 ];
// -> optab.cxx, Table of possible Opcodes
LOTUS_ROOT* pLotusRoot = NULL;
std::map<sal_uInt16, ScPatternAttr> aLotusPatternPool;
#include "lotfilter.hxx"
static FltError
generate_Opcodes( SvStream& aStream, ScDocument& rDoc,
ScfStreamProgressBar& aPrgrsBar, WKTYP eType )
generate_Opcodes(LotusContext &rContext, SvStream& aStream,
ScfStreamProgressBar& aPrgrsBar)
{
OPCODE_FKT *pOps;
int nOps;
switch(eType)
switch (rContext.eTyp)
{
case eWK_1:
case eWK_2:
pOps = pOpFkt;
pOps = rContext.pOpFkt;
nOps = FKT_LIMIT;
break;
case eWK123:
pOps = pOpFkt123;
pOps = rContext.pOpFkt123;
nOps = FKT_LIMIT123;
break;
case eWK3: return eERR_NI;
......@@ -91,62 +64,58 @@ generate_Opcodes( SvStream& aStream, ScDocument& rDoc,
aStream.Seek( STREAM_SEEK_TO_END );
sal_Size nStrmSize = aStream.Tell();
aStream.Seek( STREAM_SEEK_TO_BEGIN );
while( !bEOF && !aStream.IsEof() && (aStream.Tell() < nStrmSize) )
while( !rContext.bEOF && !aStream.IsEof() && (aStream.Tell() < nStrmSize) )
{
sal_uInt16 nOpcode, nLength;
aStream.ReadUInt16( nOpcode ).ReadUInt16( nLength );
aPrgrsBar.Progress();
if( nOpcode == LOTUS_EOF )
bEOF = true;
rContext.bEOF = true;
else if( nOpcode == LOTUS_FILEPASSWD )
return eERR_FILEPASSWD;
return eERR_FILEPASSWD;
else if( nOpcode < nOps )
pOps[ nOpcode ] ( aStream, nLength );
else if( eType == eWK123 &&
nOpcode == LOTUS_PATTERN )
{
// This is really ugly - needs re-factoring ...
aStream.SeekRel(nLength);
aStream.ReadUInt16( nOpcode ).ReadUInt16( nLength );
if ( nOpcode == 0x29a)
pOps[ nOpcode ] (rContext, aStream, nLength);
else if (rContext.eTyp == eWK123 && nOpcode == LOTUS_PATTERN)
{
// This is really ugly - needs re-factoring ...
aStream.SeekRel(nLength);
aStream.ReadUInt16( nOpcode ).ReadUInt16( nLength );
if ( nOpcode == 0x804 )
if ( nOpcode == 0x29a)
{
aStream.SeekRel(nLength);
OP_ApplyPatternArea123(aStream);
aStream.SeekRel(nLength);
aStream.ReadUInt16( nOpcode ).ReadUInt16( nLength );
if ( nOpcode == 0x804 )
{
aStream.SeekRel(nLength);
OP_ApplyPatternArea123(rContext, aStream);
}
else
aStream.SeekRel(nLength);
}
else
aStream.SeekRel(nLength);
aStream.SeekRel(nLength);
}
else
aStream.SeekRel(nLength);
}
else
aStream.SeekRel( nLength );
aStream.SeekRel( nLength );
}
MemDelete();
MemDelete(rContext);
rDoc.CalcAfterLoad();
rContext.pDoc->CalcAfterLoad();
return eERR_OK;
}
WKTYP ScanVersion( SvStream& aStream )
WKTYP ScanVersion(LotusContext &rContext, SvStream& aStream)
{
// PREC: pWKDatei: Zeiger auf offene Datei
// POST: return: Typ der Datei
sal_uInt16 nOpcode, nVersNr, nRecLen;
sal_uInt16 nOpcode(0), nVersNr(0), nRecLen(0);
// erstes Byte muss wegen BOF zwingend 0 sein!
aStream.ReadUInt16( nOpcode );
if( nOpcode != nBOF )
if (nOpcode != rContext.nBOF)
return eWK_UNKNOWN;
aStream.ReadUInt16( nRecLen ).ReadUInt16( nVersNr );
......@@ -193,19 +162,17 @@ WKTYP ScanVersion( SvStream& aStream )
return eWK_UNKNOWN;
}
FltError ScImportLotus123old( SvStream& aStream, ScDocument* pDocument, rtl_TextEncoding eSrc )
FltError ScImportLotus123old(LotusContext& rContext, SvStream& aStream, ScDocument* pDocument, rtl_TextEncoding eSrc )
{
aStream.Seek( 0UL );
// Zeiger auf Dokument global machen
pDoc = pDocument;
bEOF = false;
eCharVon = eSrc;
rContext.pDoc = pDocument;
rContext.bEOF = false;
rContext.eCharVon = eSrc;
// Speicher besorgen
if( !MemNew() )
if( !MemNew(rContext) )
return eERR_NOMEM;
InitPage(); // Seitenformat initialisieren (nur Tab 0!)
......@@ -214,11 +181,10 @@ FltError ScImportLotus123old( SvStream& aStream, ScDocument* pDocument, rtl_Text
ScfStreamProgressBar aPrgrsBar( aStream, pDocument->GetDocumentShell() );
// Datei-Typ ermitteln
eTyp = ScanVersion( aStream );
aLotusPatternPool.clear();
rContext.eTyp = ScanVersion(rContext, aStream);
rContext.aLotusPatternPool.clear();
return generate_Opcodes( aStream, *pDoc, aPrgrsBar, eTyp );
return generate_Opcodes(rContext, aStream, aPrgrsBar);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -47,8 +47,8 @@ LotAttrCache::ENTRY::~ENTRY ()
delete pPattAttr;
}
LotAttrCache::LotAttrCache (LOTUS_ROOT* pLotRoot):
mpLotusRoot(pLotRoot)
LotAttrCache::LotAttrCache (LOTUS_ROOT* pLotRoot)
: mpLotusRoot(pLotRoot)
{
pDocPool = mpLotusRoot->pDoc->GetPool();
......@@ -218,7 +218,7 @@ void LotAttrCol::SetAttr( const SCROW nRow, const ScPatternAttr& rAttr )
}
}
void LotAttrCol::Apply( const SCCOL nColNum, const SCTAB nTabNum )
void LotAttrCol::Apply(LOTUS_ROOT* pLotusRoot, const SCCOL nColNum, const SCTAB nTabNum)
{
ScDocument* pDoc = pLotusRoot->pDoc;
......@@ -248,11 +248,11 @@ void LotAttrTable::SetAttr( const SCCOL nColFirst, const SCCOL nColLast, const S
pCols[ nColCnt ].SetAttr( nRow, rPattAttr );
}
void LotAttrTable::Apply( const SCTAB nTabNum )
void LotAttrTable::Apply(LOTUS_ROOT* pLotusRoot, const SCTAB nTabNum)
{
SCCOL nColCnt;
for( nColCnt = 0 ; nColCnt <= MAXCOL ; nColCnt++ )
pCols[ nColCnt ].Apply( nColCnt, nTabNum ); // macht auch gleich ein Clear() am Ende
pCols[ nColCnt ].Apply(pLotusRoot, nColCnt, nTabNum); // macht auch gleich ein Clear() am Ende
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_SC_SOURCE_FILTER_LOTUS_FILTER_HXX
#define INCLUDED_SC_SOURCE_FILTER_LOTUS_FILTER_HXX
#include <map>
#include "decl.h"
#include "op.h"
#include "optab.h"
#include "root.hxx"
class SvxHorJustifyItem;
class ScProtectionAttr;
class SfxUInt32Item;
class FormCache;
struct LotusContext
{
const sal_uInt16 nBOF;
WKTYP eTyp; // Typ der gerade in bearbeitung befindlichen Datei
bool bEOF; // zeigt Ende der Datei
rtl_TextEncoding eCharVon;
ScDocument* pDoc; // Aufhaenger zum Dokumentzugriff
static OPCODE_FKT pOpFkt[ FKT_LIMIT ];
static OPCODE_FKT pOpFkt123[ FKT_LIMIT123 ]; // -> optab.cxx, Table of possible Opcodes
LOTUS_ROOT* pLotusRoot;
std::map<sal_uInt16, ScPatternAttr> aLotusPatternPool;
sal_uInt8 nDefaultFormat; // -> op.cpp, Standard-Zellenformat
SvxHorJustifyItem *pAttrRight, *pAttrLeft, *pAttrCenter, *pAttrRepeat, *pAttrStandard;
ScProtectionAttr* pAttrUnprot;
SfxUInt32Item** pAttrValForms;
FormCache* pValueFormCache; // -> in memory.cxx initialisiert
LotusContext()
: nBOF(0x0000)
, eTyp(eWK_UNKNOWN)
, bEOF(false)
, eCharVon(RTL_TEXTENCODING_DONTKNOW)
, pDoc(0)
, pLotusRoot(NULL)
, nDefaultFormat(0)
, pAttrRight(NULL)
, pAttrLeft(NULL)
, pAttrCenter(NULL)
, pAttrRepeat(NULL)
, pAttrStandard(NULL)
, pAttrUnprot(NULL)
, pAttrValForms(NULL)
, pValueFormCache(NULL)
{
}
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -20,6 +20,7 @@
#include "decl.h"
#include "lotform.hxx"
#include "compiler.hxx"
#include "lotfilter.hxx"
#include "lotrange.hxx"
#include "namebuff.hxx"
#include "root.hxx"
......@@ -30,8 +31,6 @@
#include <comphelper/string.hxx>
#include <boost/scoped_array.hpp>
extern WKTYP eTyp;
static const sal_Char* GetAddInName( const sal_uInt8 nIndex );
static DefTokenId lcl_KnownAddIn(const OString& rTest);
......@@ -217,7 +216,7 @@ void LotusToSc::LotusRelToScRel( sal_uInt16 nCol, sal_uInt16 nRow, ScSingleRefDa
{
rSRD.SetRowRel(true);
// vorzeichenrichtige Erweiterung
switch( eTyp )
switch (m_rContext.eTyp)
{
// 5432 1098 7654 3210
// 8421 8421 8421 8421
......@@ -243,7 +242,7 @@ void LotusToSc::LotusRelToScRel( sal_uInt16 nCol, sal_uInt16 nRow, ScSingleRefDa
else
{
rSRD.SetRowRel(false);
switch( eTyp )
switch (m_rContext.eTyp)
{
// 5432 1098 7654 3210
// 8421 8421 8421 8421
......@@ -320,8 +319,10 @@ void LotusToSc::Reset( const ScAddress& rEingPos )
n0Token = aPool.Store( 0.0 );
}
LotusToSc::LotusToSc( SvStream &rStream, svl::SharedStringPool& rSPool, rtl_TextEncoding e, bool b ) :
LotusConverterBase(rStream, rSPool, 128)
LotusToSc::LotusToSc(LotusContext &rContext, SvStream &rStream, svl::SharedStringPool& rSPool,
rtl_TextEncoding e, bool b)
: LotusConverterBase(rStream, rSPool, 128)
, m_rContext(rContext)
{
eSrcChar = e;
bWK3 = false;
......@@ -343,7 +344,7 @@ ConvErr LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest,
TokenId nMerk0;
DefTokenId eOc;
const sal_Char* pExtName = 0;
RangeNameBufferWK3& rRangeNameBufferWK3 = *pLotusRoot->pRngNmBffWK3;
RangeNameBufferWK3& rRangeNameBufferWK3 = *m_rContext.pLotusRoot->pRngNmBffWK3;
ScComplexRefData aCRD;
aCRD.InitFlags();
......@@ -352,7 +353,7 @@ ConvErr LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest,
LR_ID nId;
TokenId nNewId;
LotusRangeList& rRangeList = *pLotusRoot->pRangeNames;
LotusRangeList& rRangeList = *m_rContext.pLotusRoot->pRangeNames;
FuncType1* pIndexToType;
FuncType2* pIndexToToken;
......
......@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "lotfilter.hxx"
#include "lotimpop.hxx"
#include <osl/mutex.hxx>
......@@ -41,12 +42,12 @@
LOTUS_ROOT::LOTUS_ROOT( ScDocument* pDocP, rtl_TextEncoding eQ )
:
pDoc( pDocP),
pRangeNames( new LotusRangeList),
pRangeNames( new LotusRangeList(this)),
pScRangeName( pDocP->GetRangeName()),
eCharsetQ( eQ),
eFirstType( Lotus_X),
eActType( Lotus_X),
pRngNmBffWK3( new RangeNameBufferWK3),
pRngNmBffWK3( new RangeNameBufferWK3(this)),
pFontBuff( new LotusFontBuffer),
pAttrTable( new LotAttrTable(this))
{
......@@ -62,23 +63,24 @@ LOTUS_ROOT::~LOTUS_ROOT()
static osl::Mutex aLotImpSemaphore;
ImportLotus::ImportLotus( SvStream& aStream, ScDocument* pDoc, rtl_TextEncoding eQ )
ImportLotus::ImportLotus(LotusContext &rContext, SvStream& aStream, ScDocument* pDoc, rtl_TextEncoding eQ)
: ImportTyp(pDoc, eQ)
, pIn(&aStream)
, aConv(*pIn, pDoc->GetSharedStringPool(), eQ, false)
, aConv(rContext, *pIn, pDoc->GetSharedStringPool(), eQ, false)
, nTab(0)
, nExtTab(0)
{
// good point to start locking of import lotus
aLotImpSemaphore.acquire();
pLotusRoot = new LOTUS_ROOT(pDoc, eQ);
rContext.pLotusRoot = new LOTUS_ROOT(pDoc, eQ);
}
ImportLotus::~ImportLotus()
{
delete pLotusRoot;
pLotusRoot = NULL;
LotusContext &rContext = aConv.getContext();
delete rContext.pLotusRoot;
rContext.pLotusRoot = NULL;
// no need 4 pLotusRoot anymore
aLotImpSemaphore.release();
......@@ -91,7 +93,8 @@ void ImportLotus::Bof( void )
Read( nFileCode );
Read( nFileSub );
Read( pLotusRoot->aActRange );
LotusContext &rContext = aConv.getContext();
Read( rContext.pLotusRoot->aActRange );
Read( nSaveCnt );
Read( nMajorId );
Read( nMinorId );
......@@ -102,11 +105,11 @@ void ImportLotus::Bof( void )
{
if( nFileCode == 0x1000 )
{// <= WK3
pLotusRoot->eFirstType = pLotusRoot->eActType = Lotus_WK3;
rContext.pLotusRoot->eFirstType = rContext.pLotusRoot->eActType = Lotus_WK3;
}
else if( nFileCode == 0x1002 )
{// WK4
pLotusRoot->eFirstType = pLotusRoot->eActType = Lotus_WK4;
rContext.pLotusRoot->eFirstType = rContext.pLotusRoot->eActType = Lotus_WK4;
}
}
}
......@@ -192,7 +195,8 @@ void ImportLotus::Userrange( void )
Read( aScRange );
pLotusRoot->pRngNmBffWK3->Add( aName, aScRange );
LotusContext &rContext = aConv.getContext();
rContext.pLotusRoot->pRngNmBffWK3->Add( aName, aScRange );
}
void ImportLotus::Errcell( void )
......@@ -350,26 +354,29 @@ void ImportLotus::Font_Face( void )
Read( aName );
pLotusRoot->pFontBuff->SetName( nNum, aName );
LotusContext &rContext = aConv.getContext();
rContext.pLotusRoot->pFontBuff->SetName( nNum, aName );
}
void ImportLotus::Font_Type( void )
{
LotusContext &rContext = aConv.getContext();
for( sal_uInt16 nCnt = 0 ; nCnt < LotusFontBuffer::nSize ; nCnt++ )
{
sal_uInt16 nType;
Read( nType );
pLotusRoot->pFontBuff->SetType( nCnt, nType );
rContext.pLotusRoot->pFontBuff->SetType( nCnt, nType );
}
}
void ImportLotus::Font_Ysize( void )
{
LotusContext &rContext = aConv.getContext();
for( sal_uInt16 nCnt = 0 ; nCnt < LotusFontBuffer::nSize ; nCnt++ )
{
sal_uInt16 nSize;
Read( nSize );
pLotusRoot->pFontBuff->SetHeight( nCnt, nSize );
rContext.pLotusRoot->pFontBuff->SetHeight( nCnt, nSize );
}
}
......@@ -396,13 +403,14 @@ void ImportLotus::_Row( const sal_uInt16 nRecLen )
if( nHeight )
pD->SetRowHeight( static_cast<SCROW> (nRow), static_cast<SCTAB> (nExtTab), nHeight );
LotusContext &rContext = aConv.getContext();
while( nCntDwn )
{
{
Read( aAttr );
Read( nRepeats );
if( aAttr.HasStyles() )
pLotusRoot->pAttrTable->SetAttr(
rContext.pLotusRoot->pAttrTable->SetAttr(
nColCnt, static_cast<SCCOL> ( nColCnt + nRepeats ), static_cast<SCROW> (nRow), aAttr );
// hier und NICHT in class LotAttrTable, weil nur Attributiert wird,
......@@ -438,7 +446,7 @@ void ImportLotus::_Row( const sal_uInt16 nRecLen )
nColCnt++;
nCntDwn--;
}
}
if( bCenter )
// evtl. alte Center bemachen
......
......@@ -21,6 +21,7 @@
#include "scerrors.hxx"
#include "root.hxx"
#include "lotfilter.hxx"
#include "lotimpop.hxx"
#include "lotattr.hxx"
#include "fprogressbar.hxx"
......@@ -55,12 +56,12 @@ FltError ImportLotus::Read()
// Progressbar starten
ScfStreamProgressBar aPrgrsBar( *pIn, pD->GetDocumentShell() );
LotusContext &rContext = aConv.getContext();
while( eAkt != S_END )
{
pIn->ReadUInt16( nOp ).ReadUInt16( nRecLen );
if( pIn->IsEof() || nNextRec > SAL_MAX_UINT32 - nRecLen - 4 )
if( pIn->IsEof() || nNextRec > SAL_MAX_UINT32 - nRecLen - 4 )
eAkt = S_END;
nNextRec += nRecLen + 4;
......@@ -79,7 +80,7 @@ FltError ImportLotus::Read()
if( nRecLen > 2 )
{
Bof();
switch( pLotusRoot->eFirstType )
switch (rContext.pLotusRoot->eFirstType)
{
case Lotus_WK1: eAkt = S_WK1; break;
case Lotus_WK3: eAkt = S_WK3; break;
......@@ -225,7 +226,7 @@ FltError ImportLotus::Read()
return eRet;
}
FltError ImportLotus::Read( SvStream& rIn )
FltError ImportLotus::Read(SvStream& rIn)
{
pIn = &rIn;
......@@ -242,7 +243,7 @@ FltError ImportLotus::Read( SvStream& rIn )
// Progressbar starten
ScfStreamProgressBar aPrgrsBar( *pIn, pD->GetDocumentShell() );
LotusContext &rContext = aConv.getContext();
while( bRead )
{
pIn->ReadUInt16( nOp ).ReadUInt16( nRecLen );
......@@ -284,7 +285,7 @@ FltError ImportLotus::Read( SvStream& rIn )
case 195:
if( nExtTab >= 0 )
pLotusRoot->pAttrTable->Apply( ( SCTAB ) nExtTab );
rContext.pLotusRoot->pAttrTable->Apply(rContext.pLotusRoot, (SCTAB)nExtTab);
nExtTab++;
break;
case 197:
......@@ -299,7 +300,7 @@ FltError ImportLotus::Read( SvStream& rIn )
}
}
pLotusRoot->pAttrTable->Apply( ( SCTAB ) nExtTab );
rContext.pLotusRoot->pAttrTable->Apply(rContext.pLotusRoot, (SCTAB)nExtTab);
return eRet;
}
......
......@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "lotfilter.hxx"
#include "lotimpop.hxx"
#include <sfx2/docfile.hxx>
......@@ -29,7 +30,7 @@
FltError ScFormatFilterPluginImpl::ScImportLotus123( SfxMedium& rMedium, ScDocument* pDocument, rtl_TextEncoding eSrc )
{
ScFilterOptions aFilterOpt;
ScFilterOptions aFilterOpt;
bool bWithWK3 = aFilterOpt.GetWK3Flag();
SvStream* pStream = rMedium.GetInStream();
......@@ -43,7 +44,9 @@ FltError ScFormatFilterPluginImpl::ScImportLotus123( SfxMedium& rMedium, ScDocum
pStream->SetBufferSize( 32768 );
ImportLotus aLotusImport( *pStream, pDocument, eSrc );
LotusContext aContext;
ImportLotus aLotusImport(aContext, *pStream, pDocument, eSrc);
if( bWithWK3 )
eRet = aLotusImport.Read();
......@@ -57,7 +60,7 @@ FltError ScFormatFilterPluginImpl::ScImportLotus123( SfxMedium& rMedium, ScDocum
pStream->SetBufferSize( 32768 );
eRet = ScImportLotus123old( *pStream, pDocument, eSrc );
eRet = ScImportLotus123old(aContext, *pStream, pDocument, eSrc);
pStream->SetBufferSize( 0 );
......@@ -67,8 +70,9 @@ FltError ScFormatFilterPluginImpl::ScImportLotus123( SfxMedium& rMedium, ScDocum
if( eRet != eERR_OK )
return eRet;
if( pLotusRoot->eFirstType == Lotus_WK3 )
{// versuchen *.FM3-File zu laden
if (aContext.pLotusRoot->eFirstType == Lotus_WK3)
{
// versuchen *.FM3-File zu laden
INetURLObject aURL( rMedium.GetURLObject() );
aURL.setExtension( "FM3" );
SfxMedium aMedium( aURL.GetMainURL(INetURLObject::NO_DECODE), STREAM_STD_READ );
......
......@@ -24,43 +24,34 @@
#include "scmem.h"
#include <svx/algitem.hxx>
#include <editeng/justifyitem.hxx>
#include "attrib.hxx"
#include "lotfilter.hxx"
#include "tool.h"
extern ScDocument* pDoc;
extern FormCache* pValueFormCache; // -> tool.cxx
extern SvxHorJustifyItem *pAttrRight, *pAttrLeft, *pAttrCenter,
*pAttrRepeat, *pAttrStandard; // -> tool.cxx, fuer GetFormAttr()
extern ScProtectionAttr* pAttrUnprot; // -> tool.cxx, fuer PutFormString()
bool MemNew( void )
bool MemNew(LotusContext &rContext)
{
pValueFormCache = new FormCache( pDoc );
rContext.pValueFormCache = new FormCache(rContext.pDoc);
// fuer tool.cxx::PutFormString()
pAttrUnprot = new ScProtectionAttr( true );
pAttrRight = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_RIGHT, ATTR_HOR_JUSTIFY );
pAttrLeft = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_LEFT, ATTR_HOR_JUSTIFY );
pAttrCenter = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY );
pAttrRepeat = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_REPEAT, ATTR_HOR_JUSTIFY );
pAttrStandard = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY );
rContext.pAttrUnprot = new ScProtectionAttr( true );
rContext.pAttrRight = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_RIGHT, ATTR_HOR_JUSTIFY );
rContext.pAttrLeft = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_LEFT, ATTR_HOR_JUSTIFY );
rContext.pAttrCenter = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY );
rContext.pAttrRepeat = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_REPEAT, ATTR_HOR_JUSTIFY );
rContext.pAttrStandard = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY );
return true;
}
void MemDelete( void )
void MemDelete(LotusContext &rContext)
{
delete pValueFormCache;
delete pAttrRight;
delete pAttrLeft;
delete pAttrCenter;
delete pAttrRepeat;
delete pAttrStandard;
delete pAttrUnprot;
delete rContext.pValueFormCache;
delete rContext.pAttrRight;
delete rContext.pAttrLeft;
delete rContext.pAttrCenter;
delete rContext.pAttrRepeat;
delete rContext.pAttrStandard;
delete rContext.pAttrUnprot;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
......@@ -19,9 +19,10 @@
#include "op.h"
#include "optab.h"
#include "lotfilter.hxx"
// Bearbeitungsfunktion sal_Char *X( sal_Char * )
OPCODE_FKT pOpFkt[ FKT_LIMIT ] =
OPCODE_FKT LotusContext::pOpFkt[ FKT_LIMIT ] =
{ // Code
OP_BOF, // 0
OP_EOF, // 1
......@@ -126,7 +127,7 @@ OPCODE_FKT pOpFkt[ FKT_LIMIT ] =
OP_HiddenCols, // 100
};
OPCODE_FKT pOpFkt123[ FKT_LIMIT123 ] =
OPCODE_FKT LotusContext::pOpFkt123[ FKT_LIMIT123 ] =
{ // Code
OP_BOF123, // 0
OP_EOF123, // 1
......
......@@ -33,31 +33,11 @@
#include "ftools.hxx"
#include "stringutil.hxx"
#include "tokenarray.hxx"
#include "lotfilter.hxx"
#include <math.h>
// External variable
extern WKTYP eTyp; // -> filter.cxx, aktueller Dateityp
extern ScDocument* pDoc; // -> filter.cxx, Aufhaenger zum Dokumentzugriff
// Global variable
sal_uInt8 nDefaultFormat; // -> op.cpp, Standard-Zellenformat
extern SvxHorJustifyItem *pAttrRight, *pAttrLeft, *pAttrCenter, *pAttrRepeat, *pAttrStandard;
extern ScProtectionAttr* pAttrUnprot;
extern SfxUInt32Item** pAttrValForms;
SvxHorJustifyItem *pAttrRight, *pAttrLeft, *pAttrCenter, *pAttrRepeat, *pAttrStandard;
// -> in memory.cxx initialisiert
ScProtectionAttr* pAttrUnprot; // -> " memory.cxx "
extern FormCache* pValueFormCache; // -> in memory.cxx initialisiert
FormCache* pValueFormCache;
SCCOL LotusRangeList::nEingCol;
SCROW LotusRangeList::nEingRow;
void PutFormString( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Char* pString )
void PutFormString(LotusContext& rContext, SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Char* pString)
{
// Label-Format-Auswertung
OSL_ENSURE( pString != NULL, "PutFormString(): pString == NULL" );
......@@ -72,47 +52,47 @@ void PutFormString( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Char* pString )
switch( cForm )
{
case '"': // rechtsbuendig
pJustify = pAttrRight;
pJustify = rContext.pAttrRight;
pString++;
break;
case '\'': // linksbuendig
pJustify = pAttrLeft;
pJustify = rContext.pAttrLeft;
pString++;
break;
case '^': // zentriert
pJustify = pAttrCenter;
pJustify = rContext.pAttrCenter;
pString++;
break;
case '|': // printer command
pString = NULL;
break;
case '\\': // Wiederholung
pJustify = pAttrRepeat;
pJustify = rContext.pAttrRepeat;
pString++;
break;
default: // kenn' ich nicht!
pJustify = pAttrStandard;
pJustify = rContext.pAttrStandard;
}
if (!pString)
return;
pDoc->ApplyAttr( nCol, nRow, nTab, *pJustify );
rContext.pDoc->ApplyAttr( nCol, nRow, nTab, *pJustify );
ScSetStringParam aParam;
aParam.setTextInput();
pDoc->SetString(ScAddress(nCol,nRow,nTab), OUString(pString, strlen(pString), pLotusRoot->eCharsetQ), &aParam);
rContext.pDoc->SetString(ScAddress(nCol,nRow,nTab), OUString(pString, strlen(pString), rContext.pLotusRoot->eCharsetQ), &aParam);
}
void SetFormat( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt8 nFormat, sal_uInt8 nSt )
void SetFormat(LotusContext& rContext, SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt8 nFormat, sal_uInt8 nSt)
{
// PREC: nSt = Standard-Dezimalstellenanzahl
pDoc->ApplyAttr( nCol, nRow, nTab, *( pValueFormCache->GetAttr( nFormat, nSt ) ) );
rContext.pDoc->ApplyAttr(nCol, nRow, nTab, *(rContext.pValueFormCache->GetAttr(nFormat, nSt)));
ScProtectionAttr aAttr;
aAttr.SetProtection( nFormat & 0x80 );
pDoc->ApplyAttr( nCol, nRow, nTab, aAttr );
rContext.pDoc->ApplyAttr( nCol, nRow, nTab, aAttr );
}
void InitPage( void )
......@@ -391,7 +371,8 @@ LotusRange::LotusRange( const LotusRange& rCpy )
Copy( rCpy );
}
LotusRangeList::LotusRangeList( void )
LotusRangeList::LotusRangeList(LOTUS_ROOT* pLotRoot)
: m_pLotRoot(pLotRoot)
{
aComplRef.InitFlags();
......@@ -411,6 +392,9 @@ LotusRangeList::LotusRangeList( void )
pSingRef->SetFlag3D( false );
}
SCCOL LotusRangeList::nEingCol;
SCROW LotusRangeList::nEingRow;
LotusRangeList::~LotusRangeList ()
{
std::vector<LotusRange*>::iterator pIter;
......@@ -453,16 +437,17 @@ void LotusRangeList::Append( LotusRange* pLR, const OUString& rName )
}
ScRangeData* pData = new ScRangeData(
pLotusRoot->pDoc, rName, aTokArray );
m_pLotRoot->pDoc, rName, aTokArray );
pLotusRoot->pScRangeName->insert( pData );
m_pLotRoot->pScRangeName->insert( pData );
pLR->SetId( nIdCnt );
nIdCnt++;
}
RangeNameBufferWK3::RangeNameBufferWK3( void )
RangeNameBufferWK3::RangeNameBufferWK3(LOTUS_ROOT* pLotRoot)
: m_pLotRoot(pLotRoot)
{
pScTokenArray = new ScTokenArray;
nIntCount = 1;
......@@ -496,14 +481,14 @@ void RangeNameBufferWK3::Add( const OUString& rOrgName, const ScComplexRefData&
aInsert.bSingleRef = false;
}
ScRangeData* pData = new ScRangeData( pLotusRoot->pDoc, aScName, *pScTokenArray );
ScRangeData* pData = new ScRangeData( m_pLotRoot->pDoc, aScName, *pScTokenArray );
aInsert.nRelInd = nIntCount;
pData->SetIndex( nIntCount );
nIntCount++;
maEntries.push_back( aInsert );
pLotusRoot->pScRangeName->insert( pData );
m_pLotRoot->pScRangeName->insert( pData );
}
bool RangeNameBufferWK3::FindRel( const OUString& rRef, sal_uInt16& rIndex )
......@@ -557,13 +542,13 @@ bool RangeNameBufferWK3::FindAbs( const OUString& rRef, sal_uInt16& rIndex )
pScTokenArray->AddDoubleReference( itr->aScComplexRefDataRel );
}
ScRangeData* pData = new ScRangeData( pLotusRoot->pDoc, itr->aScAbsName, *pScTokenArray );
ScRangeData* pData = new ScRangeData( m_pLotRoot->pDoc, itr->aScAbsName, *pScTokenArray );
rIndex = itr->nAbsInd = nIntCount;
pData->SetIndex( rIndex );
nIntCount++;
pLotusRoot->pScRangeName->insert( pData );
m_pLotRoot->pScRangeName->insert( pData );
}
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment