summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-09-10 11:09:30 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-09-10 12:46:49 +0100
commit206b32c231ea9f1fc7dbb60af307e30d03398095 (patch)
tree1982ecf3830b13353ada4bb4c309168e36440d4f /sc
parentabbeed756019e099d16acb4155c7c459fef2d1b4 (diff)
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
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/filter.hxx4
-rw-r--r--sc/source/filter/inc/lotattr.hxx4
-rw-r--r--sc/source/filter/inc/lotform.hxx9
-rw-r--r--sc/source/filter/inc/lotimpop.hxx3
-rw-r--r--sc/source/filter/inc/lotrange.hxx7
-rw-r--r--sc/source/filter/inc/namebuff.hxx7
-rw-r--r--sc/source/filter/inc/op.h63
-rw-r--r--sc/source/filter/inc/optab.h4
-rw-r--r--sc/source/filter/inc/root.hxx2
-rw-r--r--sc/source/filter/inc/scmem.h7
-rw-r--r--sc/source/filter/inc/tool.h6
-rw-r--r--sc/source/filter/lotus/filter.cxx108
-rw-r--r--sc/source/filter/lotus/lotattr.cxx10
-rw-r--r--sc/source/filter/lotus/lotfilter.hxx77
-rw-r--r--sc/source/filter/lotus/lotform.cxx17
-rw-r--r--sc/source/filter/lotus/lotimpop.cxx42
-rw-r--r--sc/source/filter/lotus/lotread.cxx15
-rw-r--r--sc/source/filter/lotus/lotus.cxx14
-rw-r--r--sc/source/filter/lotus/memory.cxx43
-rw-r--r--sc/source/filter/lotus/op.cxx207
-rw-r--r--sc/source/filter/lotus/optab.cxx5
-rw-r--r--sc/source/filter/lotus/tool.cxx65
22 files changed, 379 insertions, 340 deletions
diff --git a/sc/inc/filter.hxx b/sc/inc/filter.hxx
index 53062c343e8d..6d3df3dedec3 100644
--- a/sc/inc/filter.hxx
+++ b/sc/inc/filter.hxx
@@ -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
diff --git a/sc/source/filter/inc/lotattr.hxx b/sc/source/filter/inc/lotattr.hxx
index 2e0829ac5030..fe5df58a6507 100644
--- a/sc/source/filter/inc/lotattr.hxx
+++ b/sc/source/filter/inc/lotattr.hxx
@@ -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:
diff --git a/sc/source/filter/inc/lotform.hxx b/sc/source/filter/inc/lotform.hxx
index c356fcda32c0..4c3165d8adbe 100644
--- a/sc/source/filter/inc/lotform.hxx
+++ b/sc/source/filter/inc/lotform.hxx
@@ -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;
diff --git a/sc/source/filter/inc/lotimpop.hxx b/sc/source/filter/inc/lotimpop.hxx
index ab1aa6e2b287..f177eeb5b75d 100644
--- a/sc/source/filter/inc/lotimpop.hxx
+++ b/sc/source/filter/inc/lotimpop.hxx
@@ -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();
diff --git a/sc/source/filter/inc/lotrange.hxx b/sc/source/filter/inc/lotrange.hxx
index 59d1012b11dd..2950e50638a6 100644
--- a/sc/source/filter/inc/lotrange.hxx
+++ b/sc/source/filter/inc/lotrange.hxx
@@ -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& );
diff --git a/sc/source/filter/inc/namebuff.hxx b/sc/source/filter/inc/namebuff.hxx
index 908e2703496c..cf3bc9050347 100644
--- a/sc/source/filter/inc/namebuff.hxx
+++ b/sc/source/filter/inc/namebuff.hxx
@@ -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 );
diff --git a/sc/source/filter/inc/op.h b/sc/source/filter/inc/op.h
index d6204ff17c3c..4e70bcbb6f97 100644
--- a/sc/source/filter/inc/op.h
+++ b/sc/source/filter/inc/op.h
@@ -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
diff --git a/sc/source/filter/inc/optab.h b/sc/source/filter/inc/optab.h
index 9fb0031b15da..7d4ad1d49aec 100644
--- a/sc/source/filter/inc/optab.h
+++ b/sc/source/filter/inc/optab.h
@@ -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
diff --git a/sc/source/filter/inc/root.hxx b/sc/source/filter/inc/root.hxx
index e250b2c81b08..0dd0e57e0c77 100644
--- a/sc/source/filter/inc/root.hxx
+++ b/sc/source/filter/inc/root.hxx
@@ -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: */
diff --git a/sc/source/filter/inc/scmem.h b/sc/source/filter/inc/scmem.h
index c46645fc0402..2c105ca127f0 100644
--- a/sc/source/filter/inc/scmem.h
+++ b/sc/source/filter/inc/scmem.h
@@ -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
diff --git a/sc/source/filter/inc/tool.h b/sc/source/filter/inc/tool.h
index cadf3f5af87d..5515834ccc4c 100644
--- a/sc/source/filter/inc/tool.h
+++ b/sc/source/filter/inc/tool.h
@@ -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 );
diff --git a/sc/source/filter/lotus/filter.cxx b/sc/source/filter/lotus/filter.cxx
index 2fdb9e11353b..b4e3cb919eab 100644
--- a/sc/source/filter/lotus/filter.cxx
+++ b/sc/source/filter/lotus/filter.cxx
@@ -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: */
diff --git a/sc/source/filter/lotus/lotattr.cxx b/sc/source/filter/lotus/lotattr.cxx
index b309f6a3a50e..725414480d0c 100644
--- a/sc/source/filter/lotus/lotattr.cxx
+++ b/sc/source/filter/lotus/lotattr.cxx
@@ -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: */
diff --git a/sc/source/filter/lotus/lotfilter.hxx b/sc/source/filter/lotus/lotfilter.hxx
new file mode 100644
index 000000000000..047391ad6e33
--- /dev/null
+++ b/sc/source/filter/lotus/lotfilter.hxx
@@ -0,0 +1,77 @@
+/* -*- 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: */
diff --git a/sc/source/filter/lotus/lotform.cxx b/sc/source/filter/lotus/lotform.cxx
index 59d8750d41f0..31e844aa235a 100644
--- a/sc/source/filter/lotus/lotform.cxx
+++ b/sc/source/filter/lotus/lotform.cxx
@@ -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;
diff --git a/sc/source/filter/lotus/lotimpop.cxx b/sc/source/filter/lotus/lotimpop.cxx
index 60fa5a4880b0..b13ed65d37e8 100644
--- a/sc/source/filter/lotus/lotimpop.cxx
+++ b/sc/source/filter/lotus/lotimpop.cxx
@@ -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
diff --git a/sc/source/filter/lotus/lotread.cxx b/sc/source/filter/lotus/lotread.cxx
index c690eb57df26..c739ab2129b5 100644
--- a/sc/source/filter/lotus/lotread.cxx
+++ b/sc/source/filter/lotus/lotread.cxx
@@ -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;
}
diff --git a/sc/source/filter/lotus/lotus.cxx b/sc/source/filter/lotus/lotus.cxx
index cc0af0924f5d..321d4bd4543b 100644
--- a/sc/source/filter/lotus/lotus.cxx
+++ b/sc/source/filter/lotus/lotus.cxx
@@ -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 );
diff --git a/sc/source/filter/lotus/memory.cxx b/sc/source/filter/lotus/memory.cxx
index 28630b7419d2..5e348ea1016c 100644
--- a/sc/source/filter/lotus/memory.cxx
+++ b/sc/source/filter/lotus/memory.cxx
@@ -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: */
diff --git a/sc/source/filter/lotus/op.cxx b/sc/source/filter/lotus/op.cxx
index fbbda654017c..c1eb9703ddbc 100644
--- a/sc/source/filter/lotus/op.cxx
+++ b/sc/source/filter/lotus/op.cxx
@@ -43,85 +43,76 @@
#include "optab.h"
#include "tool.h"
#include "decl.h"
+#include "lotfilter.hxx"
#include "lotform.hxx"
#include "lotrange.hxx"
-
#include "root.hxx"
-
#include "ftools.hxx"
#include <vector>
#include <map>
#include <boost/scoped_array.hpp>
-extern WKTYP eTyp; // -> filter.cxx, aktueller Dateityp
-extern bool bEOF; // -> filter.cxx, zeigt Dateiende an
-extern sal_uInt8 nDefaultFormat; // -> tool.cxx, Default-Zellenformat
-extern ScDocument* pDoc; // -> filter.cxx, Aufhaenger zum Dokumentzugriff
-extern rtl_TextEncoding eCharVon; // -> filter.cxx, character set specified
-
static sal_uInt16 nDefWidth = ( sal_uInt16 ) ( TWIPS_PER_CHAR * 10 );
-extern std::map<sal_uInt16, ScPatternAttr> aLotusPatternPool;
-
-void NI( SvStream& r, sal_uInt16 n )
+void NI(LotusContext& /*rContext*/, SvStream& r, sal_uInt16 n)
{
r.SeekRel( n );
}
-void OP_BOF( SvStream& r, sal_uInt16 /*n*/ )
+void OP_BOF(LotusContext& /*rContext*/, SvStream& r, sal_uInt16 /*n*/)
{
r.SeekRel( 2 ); // Versionsnummer ueberlesen
}
-void OP_EOF( SvStream& /*r*/, sal_uInt16 /*n*/ )
+void OP_EOF(LotusContext& rContext, SvStream& /*r*/, sal_uInt16 /*n*/)
{
- bEOF = true;
+ rContext.bEOF = true;
}
-void OP_Integer( SvStream& r, sal_uInt16 /*n*/ )
+void OP_Integer(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/)
{
- sal_uInt8 nFormat;
- sal_uInt16 nCol, nRow;
- SCTAB nTab = 0;
- sal_Int16 nValue;
+ sal_uInt8 nFormat(0);
+ sal_uInt16 nCol(0), nRow(0);
+ SCTAB nTab(0);
+ sal_Int16 nValue(0);
r.ReadUChar( nFormat ).ReadUInt16( nCol ).ReadUInt16( nRow ).ReadInt16( nValue );
if (ValidColRow( static_cast<SCCOL>(nCol), nRow))
{
- pDoc->EnsureTable(nTab);
- pDoc->SetValue(ScAddress(nCol,nRow,nTab), static_cast<double>(nValue));
+ rContext.pDoc->EnsureTable(nTab);
+ rContext.pDoc->SetValue(ScAddress(nCol,nRow,nTab), static_cast<double>(nValue));
// 0 Stellen nach'm Komma!
- SetFormat( static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab, nFormat, 0 );
+ SetFormat(rContext, static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab, nFormat, 0);
}
}
-void OP_Number( SvStream& r, sal_uInt16 /*n*/ )
+void OP_Number(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/)
{
- sal_uInt8 nFormat;
- sal_uInt16 nCol, nRow;
- SCTAB nTab = 0;
- double fValue;
+ sal_uInt8 nFormat(0);
+ sal_uInt16 nCol(0), nRow(0);
+ SCTAB nTab(0);
+ double fValue(0.0);
r.ReadUChar( nFormat ).ReadUInt16( nCol ).ReadUInt16( nRow ).ReadDouble( fValue );
if (ValidColRow( static_cast<SCCOL>(nCol), nRow))
{
fValue = ::rtl::math::round( fValue, 15 );
- pDoc->EnsureTable(nTab);
- pDoc->SetValue(ScAddress(nCol,nRow,nTab), fValue);
+ rContext.pDoc->EnsureTable(nTab);
+ rContext.pDoc->SetValue(ScAddress(nCol,nRow,nTab), fValue);
- SetFormat( static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab, nFormat, nDezFloat );
+ SetFormat(rContext, static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab, nFormat, nDezFloat);
}
}
-void OP_Label( SvStream& r, sal_uInt16 n )
+void OP_Label(LotusContext& rContext, SvStream& r, sal_uInt16 n)
{
- sal_uInt8 nFormat;
- sal_uInt16 nCol, nRow;
- SCTAB nTab = 0;
+ sal_uInt8 nFormat(0);
+ sal_uInt16 nCol(0), nRow(0);
+ SCTAB nTab(0);
r.ReadUChar( nFormat ).ReadUInt16( nCol ).ReadUInt16( nRow );
@@ -136,13 +127,13 @@ void OP_Label( SvStream& r, sal_uInt16 n )
nFormat &= 0x80; // Bit 7 belassen
nFormat |= 0x75; // protected egal, special-text gesetzt
- PutFormString( static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab, pText.get() );
+ PutFormString(rContext, static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab, pText.get());
- SetFormat( static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab, nFormat, nDezStd );
+ SetFormat(rContext, static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab, nFormat, nDezStd);
}
}
-void OP_Formula( SvStream& r, sal_uInt16 /*n*/ )
+void OP_Formula(LotusContext &rContext, SvStream& r, sal_uInt16 /*n*/)
{
sal_uInt8 nFormat;
sal_uInt16 nCol, nRow, nFormulaSize;
@@ -156,24 +147,24 @@ void OP_Formula( SvStream& r, sal_uInt16 /*n*/ )
sal_Int32 nBytesLeft = nFormulaSize;
ScAddress aAddress( static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab );
- svl::SharedStringPool& rSPool = pLotusRoot->pDoc->GetSharedStringPool();
- LotusToSc aConv(r, rSPool, pLotusRoot->eCharsetQ, false);
+ svl::SharedStringPool& rSPool = rContext.pLotusRoot->pDoc->GetSharedStringPool();
+ LotusToSc aConv(rContext, r, rSPool, rContext.pLotusRoot->eCharsetQ, false);
aConv.Reset( aAddress );
aConv.Convert( pErg, nBytesLeft );
if (ValidColRow( static_cast<SCCOL>(nCol), nRow))
{
- ScFormulaCell* pCell = new ScFormulaCell(pLotusRoot->pDoc, aAddress, *pErg);
+ ScFormulaCell* pCell = new ScFormulaCell(rContext.pLotusRoot->pDoc, aAddress, *pErg);
pCell->AddRecalcMode( RECALCMODE_ONLOAD_ONCE );
- pDoc->EnsureTable(nTab);
- pDoc->SetFormulaCell(ScAddress(nCol,nRow,nTab), pCell);
+ rContext.pDoc->EnsureTable(nTab);
+ rContext.pDoc->SetFormulaCell(ScAddress(nCol,nRow,nTab), pCell);
// nFormat = Standard -> Nachkommastellen wie Float
- SetFormat( static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab, nFormat, nDezFloat );
+ SetFormat(rContext, static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab, nFormat, nDezFloat);
}
}
-void OP_ColumnWidth( SvStream& r, sal_uInt16 /*n*/ )
+void OP_ColumnWidth(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/)
{
sal_uInt16 nCol, nBreite;
sal_uInt8 nWidthSpaces;
@@ -188,16 +179,16 @@ void OP_ColumnWidth( SvStream& r, sal_uInt16 /*n*/ )
nBreite = ( sal_uInt16 ) ( TWIPS_PER_CHAR * nWidthSpaces );
else
{
- pDoc->SetColHidden(static_cast<SCCOL>(nCol), static_cast<SCCOL>(nCol), 0, true);
+ rContext.pDoc->SetColHidden(static_cast<SCCOL>(nCol), static_cast<SCCOL>(nCol), 0, true);
nBreite = nDefWidth;
}
- pDoc->SetColWidth( static_cast<SCCOL> (nCol), nTab, nBreite );
+ rContext.pDoc->SetColWidth( static_cast<SCCOL> (nCol), nTab, nBreite );
}
}
-void OP_NamedRange( SvStream& r, sal_uInt16 /*n*/ )
- {
+void OP_NamedRange(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/)
+{
// POST: waren Koordinaten ungueltig, wird nicht gespeichert
sal_uInt16 nColSt, nRowSt, nColEnd, nRowEnd;
@@ -226,15 +217,15 @@ void OP_NamedRange( SvStream& r, sal_uInt16 /*n*/ )
else
strcpy( cBuf, cPuffer ); // #100211# - checked
- OUString aTmp( cBuf, strlen(cBuf), pLotusRoot->eCharsetQ );
+ OUString aTmp( cBuf, strlen(cBuf), rContext.pLotusRoot->eCharsetQ );
aTmp = ScfTools::ConvertToScDefinedName( aTmp );
- pLotusRoot->pRangeNames->Append( pRange, aTmp );
+ rContext.pLotusRoot->pRangeNames->Append( pRange, aTmp );
}
}
-void OP_SymphNamedRange( SvStream& r, sal_uInt16 /*n*/ )
+void OP_SymphNamedRange(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/)
{
// POST: waren Koordinaten ungueltig, wird nicht gespeichert
sal_uInt16 nColSt, nRowSt, nColEnd, nRowEnd;
@@ -265,29 +256,29 @@ void OP_SymphNamedRange( SvStream& r, sal_uInt16 /*n*/ )
else
strcpy( cBuf, cPuffer ); // #100211# - checked
- OUString aTmp( cBuf, strlen(cBuf), pLotusRoot->eCharsetQ );
+ OUString aTmp( cBuf, strlen(cBuf), rContext.pLotusRoot->eCharsetQ );
aTmp = ScfTools::ConvertToScDefinedName( aTmp );
- pLotusRoot->pRangeNames->Append( pRange, aTmp );
+ rContext.pLotusRoot->pRangeNames->Append( pRange, aTmp );
}
}
-void OP_Footer( SvStream& r, sal_uInt16 n )
+void OP_Footer(LotusContext& /*rContext*/, SvStream& r, sal_uInt16 n)
{
r.SeekRel( n );
}
-void OP_Header( SvStream& r, sal_uInt16 n )
+void OP_Header(LotusContext& /*rContext*/, SvStream& r, sal_uInt16 n)
{
r.SeekRel( n );
}
-void OP_Margins( SvStream& r, sal_uInt16 n )
+void OP_Margins(LotusContext& /*rContext*/, SvStream& r, sal_uInt16 n)
{
r.SeekRel( n );
}
-void OP_HiddenCols( SvStream& r, sal_uInt16 /*n*/ )
+void OP_HiddenCols(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/)
{
sal_uInt16 nByte, nBit;
SCCOL nCount;
@@ -300,8 +291,10 @@ void OP_HiddenCols( SvStream& r, sal_uInt16 /*n*/ )
for( nBit = 0 ; nBit < 8 ; nBit++ ) // ...jeweils 8 Bits = 256 Bits
{
if( nAkt & 0x01 ) // unterstes Bit gesetzt?
+ {
// -> Hidden Col
- pDoc->SetColHidden(nCount, nCount, 0, true);
+ rContext.pDoc->SetColHidden(nCount, nCount, 0, true);
+ }
nCount++;
nAkt = nAkt / 2; // der Naechste bitte...
@@ -309,11 +302,11 @@ void OP_HiddenCols( SvStream& r, sal_uInt16 /*n*/ )
}
}
-void OP_Window1( SvStream& r, sal_uInt16 n )
+void OP_Window1(LotusContext& rContext, SvStream& r, sal_uInt16 n)
{
r.SeekRel( 4 ); // Cursor Pos ueberspringen
- r.ReadUChar( nDefaultFormat );
+ r.ReadUChar(rContext.nDefaultFormat);
r.SeekRel( 1 ); // 'unused' ueberspringen
@@ -325,29 +318,29 @@ void OP_Window1( SvStream& r, sal_uInt16 n )
// statt Defaulteinstellung in SC alle Cols zu Fuss setzen
for( SCCOL nCol = 0 ; nCol <= MAXCOL ; nCol++ )
- pDoc->SetColWidth( nCol, 0, nDefWidth );
+ rContext.pDoc->SetColWidth( nCol, 0, nDefWidth );
}
-void OP_Blank( SvStream& r, sal_uInt16 /*n*/ )
+void OP_Blank(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/)
{
sal_uInt16 nCol, nRow;
sal_uInt8 nFormat;
r.ReadUChar( nFormat ).ReadUInt16( nCol ).ReadUInt16( nRow );
- SetFormat( static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), 0, nFormat, nDezFloat );
+ SetFormat(rContext, static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), 0, nFormat, nDezFloat);
}
-void OP_BOF123( SvStream& r, sal_uInt16 /*n*/ )
+void OP_BOF123(LotusContext& /*rContext*/, SvStream& r, sal_uInt16 /*n*/)
{
r.SeekRel( 26 );
}
-void OP_EOF123( SvStream& /*r*/, sal_uInt16 /*n*/ )
+void OP_EOF123(LotusContext& rContext, SvStream& /*r*/, sal_uInt16 /*n*/)
{
- bEOF = true;
+ rContext.bEOF = true;
}
-void OP_Label123( SvStream& r, sal_uInt16 n )
+void OP_Label123(LotusContext& rContext, SvStream& r, sal_uInt16 n)
{
sal_uInt8 nTab, nCol;
sal_uInt16 nRow;
@@ -358,29 +351,29 @@ void OP_Label123( SvStream& r, sal_uInt16 n )
r.Read( pText.get(), n );
pText[ n ] = 0;
- PutFormString( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), static_cast<SCTAB>(nTab), pText.get() );
+ PutFormString(rContext, static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), static_cast<SCTAB>(nTab), pText.get());
}
-void OP_Number123( SvStream& r, sal_uInt16 /*n*/ )
+void OP_Number123(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/)
{
- sal_uInt8 nCol,nTab;
- sal_uInt16 nRow;
- sal_uInt32 nValue;
+ sal_uInt8 nCol(0), nTab(0);
+ sal_uInt16 nRow(0);
+ sal_uInt32 nValue(0);
r.ReadUInt16( nRow ).ReadUChar( nTab ).ReadUChar( nCol ).ReadUInt32( nValue );
- if (ValidColRow( static_cast<SCCOL>(nCol), nRow) && nTab <= pDoc->GetMaxTableNumber())
+ if (ValidColRow( static_cast<SCCOL>(nCol), nRow) && nTab <= rContext.pDoc->GetMaxTableNumber())
{
double fValue = Snum32ToDouble( nValue );
- pDoc->EnsureTable(nTab);
- pDoc->SetValue(ScAddress(nCol,nRow,nTab), fValue);
+ rContext.pDoc->EnsureTable(nTab);
+ rContext.pDoc->SetValue(ScAddress(nCol,nRow,nTab), fValue);
}
}
-void OP_Formula123( SvStream& r, sal_uInt16 n )
+void OP_Formula123(LotusContext& rContext, SvStream& r, sal_uInt16 n)
{
- sal_uInt8 nCol,nTab;
- sal_uInt16 nRow;
+ sal_uInt8 nCol(0), nTab(0);
+ sal_uInt16 nRow(0);
r.ReadUInt16( nRow ).ReadUChar( nTab ).ReadUChar( nCol );
r.SeekRel( 8 ); // Result- jump over
@@ -389,21 +382,21 @@ void OP_Formula123( SvStream& r, sal_uInt16 n )
sal_Int32 nBytesLeft = (n > 12) ? n - 12 : 0;
ScAddress aAddress( nCol, nRow, nTab );
- svl::SharedStringPool& rSPool = pLotusRoot->pDoc->GetSharedStringPool();
- LotusToSc aConv(r, rSPool, pLotusRoot->eCharsetQ, true);
+ svl::SharedStringPool& rSPool = rContext.pLotusRoot->pDoc->GetSharedStringPool();
+ LotusToSc aConv(rContext, r, rSPool, rContext.pLotusRoot->eCharsetQ, true);
aConv.Reset( aAddress );
aConv.Convert( pErg, nBytesLeft );
- if (ValidColRow( static_cast<SCCOL>(nCol), nRow) && nTab <= pDoc->GetMaxTableNumber())
+ if (ValidColRow( static_cast<SCCOL>(nCol), nRow) && nTab <= rContext.pDoc->GetMaxTableNumber())
{
- ScFormulaCell* pCell = new ScFormulaCell(pLotusRoot->pDoc, aAddress, *pErg);
+ ScFormulaCell* pCell = new ScFormulaCell(rContext.pLotusRoot->pDoc, aAddress, *pErg);
pCell->AddRecalcMode( RECALCMODE_ONLOAD_ONCE );
- pDoc->EnsureTable(nTab);
- pDoc->SetFormulaCell(ScAddress(nCol,nRow,nTab), pCell);
+ rContext.pDoc->EnsureTable(nTab);
+ rContext.pDoc->SetFormulaCell(ScAddress(nCol,nRow,nTab), pCell);
}
}
-void OP_IEEENumber123( SvStream& r, sal_uInt16 /*n*/ )
+void OP_IEEENumber123(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/)
{
sal_uInt8 nCol,nTab;
sal_uInt16 nRow;
@@ -411,14 +404,14 @@ void OP_IEEENumber123( SvStream& r, sal_uInt16 /*n*/ )
r.ReadUInt16( nRow ).ReadUChar( nTab ).ReadUChar( nCol ).ReadDouble( dValue );
- if (ValidColRow( static_cast<SCCOL>(nCol), nRow) && nTab <= pDoc->GetMaxTableNumber())
+ if (ValidColRow( static_cast<SCCOL>(nCol), nRow) && nTab <= rContext.pDoc->GetMaxTableNumber())
{
- pDoc->EnsureTable(nTab);
- pDoc->SetValue(ScAddress(nCol,nRow,nTab), dValue);
+ rContext.pDoc->EnsureTable(nTab);
+ rContext.pDoc->SetValue(ScAddress(nCol,nRow,nTab), dValue);
}
}
-void OP_Note123( SvStream& r, sal_uInt16 n)
+void OP_Note123(LotusContext& rContext, SvStream& r, sal_uInt16 n)
{
sal_uInt8 nTab, nCol;
sal_uInt16 nRow;
@@ -429,14 +422,14 @@ void OP_Note123( SvStream& r, sal_uInt16 n)
r.Read( pText.get(), n );
pText[ n ] = 0;
- OUString aNoteText(pText.get(), strlen(pText.get()), pLotusRoot->eCharsetQ);
+ OUString aNoteText(pText.get(), strlen(pText.get()), rContext.pLotusRoot->eCharsetQ);
pText.reset();
ScAddress aPos( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), static_cast<SCTAB>(nTab) );
- ScNoteUtil::CreateNoteFromString( *pDoc, aPos, aNoteText, false, false );
+ ScNoteUtil::CreateNoteFromString( *rContext.pDoc, aPos, aNoteText, false, false );
}
-void OP_HorAlign123( sal_uInt8 nAlignPattern, SfxItemSet& rPatternItemSet )
+void OP_HorAlign123(LotusContext& /*rContext*/, sal_uInt8 nAlignPattern, SfxItemSet& rPatternItemSet)
{
// pre: Pattern is stored in the last 3 bites of the 21st byte
// post: Appropriate Horizontal Alignement is set in rPattern according to the bit pattern.
@@ -469,7 +462,7 @@ void OP_HorAlign123( sal_uInt8 nAlignPattern, SfxItemSet& rPatternItemSet )
}
}
-void OP_VerAlign123( sal_uInt8 nAlignPattern,SfxItemSet& rPatternItemSet )
+void OP_VerAlign123(LotusContext& /*rContext*/, sal_uInt8 nAlignPattern, SfxItemSet& rPatternItemSet)
{
// pre: Pattern is stored in the last 3 bites of the 22nd byte
// post: Appropriate Verticle Alignement is set in rPattern according to the bit pattern.
@@ -498,11 +491,11 @@ void OP_VerAlign123( sal_uInt8 nAlignPattern,SfxItemSet& rPatternItemSet )
}
}
-void OP_CreatePattern123( SvStream& r, sal_uInt16 n)
+void OP_CreatePattern123(LotusContext& rContext, SvStream& r, sal_uInt16 n)
{
sal_uInt16 nCode,nPatternId;
- ScPatternAttr aPattern(pDoc->GetPool());
+ ScPatternAttr aPattern(rContext.pDoc->GetPool());
SfxItemSet& rItemSet = aPattern.GetItemSet();
r.ReadUInt16( nCode );
@@ -535,18 +528,18 @@ void OP_CreatePattern123( SvStream& r, sal_uInt16 n)
// Read 21st Byte
r.ReadUChar( Hor_Align );
- OP_HorAlign123( Hor_Align, rItemSet );
+ OP_HorAlign123(rContext, Hor_Align, rItemSet );
r.ReadUChar( Ver_Align );
- OP_VerAlign123( Ver_Align, rItemSet );
+ OP_VerAlign123(rContext, Ver_Align, rItemSet );
- aLotusPatternPool.insert( std::map<sal_uInt16, ScPatternAttr>::value_type( nPatternId, aPattern ) );
+ rContext.aLotusPatternPool.insert( std::map<sal_uInt16, ScPatternAttr>::value_type( nPatternId, aPattern ) );
n -= (n > 20) ? 20 : n;
}
r.SeekRel(n);
}
-void OP_SheetName123( SvStream& rStream, sal_uInt16 nLength )
+void OP_SheetName123(LotusContext& rContext, SvStream& rStream, sal_uInt16 nLength)
{
if (nLength <= 4)
{
@@ -560,7 +553,7 @@ void OP_SheetName123( SvStream& rStream, sal_uInt16 nLength )
rStream.ReadUInt16( nDummy ); // ignore the first 2 bytes (B0 36).
rStream.ReadUInt16( nDummy );
SCTAB nSheetNum = static_cast<SCTAB>(nDummy);
- pDoc->MakeTable(nSheetNum);
+ rContext.pDoc->MakeTable(nSheetNum);
::std::vector<sal_Char> sSheetName;
sSheetName.reserve(nLength-4);
@@ -573,12 +566,12 @@ void OP_SheetName123( SvStream& rStream, sal_uInt16 nLength )
if (!sSheetName.empty())
{
- OUString aName(&sSheetName[0], strlen(&sSheetName[0]), eCharVon);
- pDoc->RenameTab(nSheetNum, aName);
+ OUString aName(&sSheetName[0], strlen(&sSheetName[0]), rContext.eCharVon);
+ rContext.pDoc->RenameTab(nSheetNum, aName);
}
}
-void OP_ApplyPatternArea123( SvStream& rStream )
+void OP_ApplyPatternArea123(LotusContext& rContext, SvStream& rStream)
{
sal_uInt16 nOpcode, nLength;
sal_uInt16 nCol = 0, nColCount = 0, nRow = 0, nRowCount = 0, nTab = 0, nData, nTabCount = 0, nLevel = 0;
@@ -630,12 +623,12 @@ void OP_ApplyPatternArea123( SvStream& rStream )
{
rStream.ReadUInt16( nData );
rStream.SeekRel( nLength - 2 );
- std::map<sal_uInt16, ScPatternAttr>::iterator loc = aLotusPatternPool.find( nData );
+ std::map<sal_uInt16, ScPatternAttr>::iterator loc = rContext.aLotusPatternPool.find( nData );
// #126338# apparently, files with invalid index occur in the wild -> don't crash then
- if ( loc != aLotusPatternPool.end() )
+ if ( loc != rContext.aLotusPatternPool.end() )
for( int i = 0; i < nTabCount; i++)
{
- pDoc->ApplyPatternAreaTab( nCol, nRow, nCol + nColCount - 1, nRow + nRowCount - 1, static_cast< SCTAB >( nTab + i ), loc->second );
+ rContext.pDoc->ApplyPatternAreaTab( nCol, nRow, nCol + nColCount - 1, nRow + nRowCount - 1, static_cast< SCTAB >( nTab + i ), loc->second );
}
}
else
@@ -648,7 +641,7 @@ void OP_ApplyPatternArea123( SvStream& rStream )
}
while( nLevel && !rStream.IsEof() );
- aLotusPatternPool.clear();
+ rContext.aLotusPatternPool.clear();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/lotus/optab.cxx b/sc/source/filter/lotus/optab.cxx
index b5525d80799e..9c6230761fc8 100644
--- a/sc/source/filter/lotus/optab.cxx
+++ b/sc/source/filter/lotus/optab.cxx
@@ -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
diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx
index 288522ad931e..273ae789caf2 100644
--- a/sc/source/filter/lotus/tool.cxx
+++ b/sc/source/filter/lotus/tool.cxx
@@ -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;