Kaydet (Commit) 02ed81ef authored tarafından Armin Le Grand's avatar Armin Le Grand

filter review Lotus WK

Patch by: Eike Rathke
üst a6b0b8d0
...@@ -44,8 +44,6 @@ ...@@ -44,8 +44,6 @@
#include "patattr.hxx" #include "patattr.hxx"
#include "ftools.hxx" #include "ftools.hxx"
const sal_uInt16 LotusFontBuffer::nSize = 8;
void LotusFontBuffer::Fill( const sal_uInt8 nIndex, SfxItemSet& rItemSet ) void LotusFontBuffer::Fill( const sal_uInt8 nIndex, SfxItemSet& rItemSet )
{ {
sal_uInt8 nIntIndex = nIndex & 0x07; sal_uInt8 nIntIndex = nIndex & 0x07;
......
...@@ -92,14 +92,15 @@ private: ...@@ -92,14 +92,15 @@ private:
inline void Type( const sal_uInt16 nNew ) { nType = nNew; } inline void Type( const sal_uInt16 nNew ) { nType = nNew; }
}; };
ENTRY pData[ 8 ];
const static sal_uInt16 nSize;
void MakeFont( ENTRY* pEntry ); void MakeFont( ENTRY* pEntry );
public: public:
const static sal_uInt16 nSize = 8;
void Fill( const sal_uInt8 nIndex, SfxItemSet& rItemSet ); void Fill( const sal_uInt8 nIndex, SfxItemSet& rItemSet );
void SetName( const sal_uInt16 nIndex, const String& rName ); void SetName( const sal_uInt16 nIndex, const String& rName );
void SetHeight( const sal_uInt16 nIndex, const sal_uInt16 nHeight ); void SetHeight( const sal_uInt16 nIndex, const sal_uInt16 nHeight );
void SetType( const sal_uInt16 nIndex, const sal_uInt16 nType ); void SetType( const sal_uInt16 nIndex, const sal_uInt16 nType );
private:
ENTRY pData[ nSize ];
}; };
......
...@@ -41,7 +41,6 @@ class ImportLotus : public ImportTyp ...@@ -41,7 +41,6 @@ class ImportLotus : public ImportTyp
{ {
private: private:
SvStream* pIn; // benoetigt wegen multiplem Read()! SvStream* pIn; // benoetigt wegen multiplem Read()!
LotusFontBuffer* pFontBuff;
LotusToSc aConv; LotusToSc aConv;
sal_uInt16 nTab; // z.Zt. bearbeitete Tabelle sal_uInt16 nTab; // z.Zt. bearbeitete Tabelle
sal_Int32 nExtTab; sal_Int32 nExtTab;
......
...@@ -35,7 +35,6 @@ void OP_EOF( SvStream &aStream, sal_uInt16 nLaenge ); ...@@ -35,7 +35,6 @@ void OP_EOF( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Integer( SvStream &aStream, sal_uInt16 nLaenge ); void OP_Integer( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Number( SvStream &aStream, sal_uInt16 nLaenge ); void OP_Number( SvStream &aStream, sal_uInt16 nLaenge );
void OP_Label( SvStream &aStream, sal_uInt16 nLaenge ); void OP_Label( SvStream &aStream, sal_uInt16 nLaenge );
//UNUSED2009-05 void OP_Text( SvStream &aStream, sal_uInt16 nLaenge ); // WK3
void OP_Integer3( SvStream &aStream, sal_uInt16 nLaenge ); // WK3 void OP_Integer3( SvStream &aStream, sal_uInt16 nLaenge ); // WK3
void OP_Number3( 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_Formula( SvStream &aStream, sal_uInt16 nLaenge );
......
...@@ -105,6 +105,9 @@ struct LOTUS_ROOT ...@@ -105,6 +105,9 @@ struct LOTUS_ROOT
RangeNameBufferWK3* pRngNmBffWK3; RangeNameBufferWK3* pRngNmBffWK3;
LotusFontBuffer* pFontBuff; LotusFontBuffer* pFontBuff;
LotAttrTable* pAttrTable; LotAttrTable* pAttrTable;
LOTUS_ROOT( ScDocument* pDocP, CharSet eQ );
~LOTUS_ROOT();
}; };
extern LOTUS_ROOT* pLotusRoot; // -> Inkarn. in filter.cxx extern LOTUS_ROOT* pLotusRoot; // -> Inkarn. in filter.cxx
......
...@@ -170,17 +170,20 @@ class TokenPool ...@@ -170,17 +170,20 @@ class TokenPool
#endif #endif
ScTokenArray* pScToken; // Tokenbastler ScTokenArray* pScToken; // Tokenbastler
void GrowString( void ); bool GrowString( void );
void GrowDouble( void ); bool GrowDouble( void );
//UNUSED2009-05 void GrowError( void ); /* TODO: in case we had FormulaTokenArray::AddError() */
void GrowTripel( void ); #if 0
void GrowId( void ); bool GrowError( void );
void GrowElement( void ); #endif
void GrowExt( void ); bool GrowTripel( sal_uInt16 nByMin = 1 );
void GrowNlf( void ); bool GrowId( void );
void GrowMatrix( void ); bool GrowElement( void );
void GetElement( const sal_uInt16 nId ); bool GrowExt( void );
void GetElementRek( const sal_uInt16 nId ); bool GrowNlf( void );
bool GrowMatrix( void );
bool GetElement( const sal_uInt16 nId );
bool GetElementRek( const sal_uInt16 nId );
public: public:
TokenPool( void ); TokenPool( void );
~TokenPool(); ~TokenPool();
...@@ -214,7 +217,6 @@ class TokenPool ...@@ -214,7 +217,6 @@ class TokenPool
inline E_TYPE GetType( const TokenId& nId ) const; inline E_TYPE GetType( const TokenId& nId ) const;
sal_Bool IsSingleOp( const TokenId& nId, const DefTokenId eId ) const; sal_Bool IsSingleOp( const TokenId& nId, const DefTokenId eId ) const;
const String* GetExternal( const TokenId& nId ) const; const String* GetExternal( const TokenId& nId ) const;
//UNUSED2008-05 const String* GetString( const TokenId& nId ) const;
ScMatrix* GetMatrix( unsigned int n ) const; ScMatrix* GetMatrix( unsigned int n ) const;
}; };
...@@ -305,7 +307,8 @@ inline TokenPool& TokenPool::operator <<( const TokenId nId ) ...@@ -305,7 +307,8 @@ inline TokenPool& TokenPool::operator <<( const TokenId nId )
"-TokenPool::operator <<: TokenId im DefToken-Bereich!" ); "-TokenPool::operator <<: TokenId im DefToken-Bereich!" );
if( nP_IdAkt >= nP_Id ) if( nP_IdAkt >= nP_Id )
GrowId(); if (!GrowId())
return *this;
pP_Id[ nP_IdAkt ] = ( ( sal_uInt16 ) nId ) - 1; pP_Id[ nP_IdAkt ] = ( ( sal_uInt16 ) nId ) - 1;
nP_IdAkt++; nP_IdAkt++;
...@@ -320,7 +323,8 @@ inline TokenPool& TokenPool::operator <<( const DefTokenId eId ) ...@@ -320,7 +323,8 @@ inline TokenPool& TokenPool::operator <<( const DefTokenId eId )
"-TokenPool::operator<<: enmum zu gross!" ); "-TokenPool::operator<<: enmum zu gross!" );
if( nP_IdAkt >= nP_Id ) if( nP_IdAkt >= nP_Id )
GrowId(); if (!GrowId())
return *this;
pP_Id[ nP_IdAkt ] = ( ( sal_uInt16 ) eId ) + nScTokenOff; pP_Id[ nP_IdAkt ] = ( ( sal_uInt16 ) eId ) + nScTokenOff;
nP_IdAkt++; nP_IdAkt++;
...@@ -332,7 +336,8 @@ inline TokenPool& TokenPool::operator <<( const DefTokenId eId ) ...@@ -332,7 +336,8 @@ inline TokenPool& TokenPool::operator <<( const DefTokenId eId )
inline TokenPool& TokenPool::operator <<( TokenStack& rStack ) inline TokenPool& TokenPool::operator <<( TokenStack& rStack )
{ {
if( nP_IdAkt >= nP_Id ) if( nP_IdAkt >= nP_Id )
GrowId(); if (!GrowId())
return *this;
pP_Id[ nP_IdAkt ] = ( ( sal_uInt16 ) rStack.Get() ) - 1; pP_Id[ nP_IdAkt ] = ( ( sal_uInt16 ) rStack.Get() ) - 1;
nP_IdAkt++; nP_IdAkt++;
......
...@@ -60,9 +60,6 @@ WKTYP eTyp; ...@@ -60,9 +60,6 @@ WKTYP eTyp;
extern sal_Bool bEOF; // zeigt Ende der Datei extern sal_Bool bEOF; // zeigt Ende der Datei
sal_Bool bEOF; sal_Bool bEOF;
extern CharSet eCharNach; // Zeichenkonvertierung von->nach
CharSet eCharNach;
extern CharSet eCharVon; extern CharSet eCharVon;
CharSet eCharVon; CharSet eCharVon;
...@@ -70,16 +67,11 @@ extern ScDocument* pDoc; // Aufhaenger zum Dokumentzugriff ...@@ -70,16 +67,11 @@ extern ScDocument* pDoc; // Aufhaenger zum Dokumentzugriff
ScDocument* pDoc; ScDocument* pDoc;
extern sal_Char* pPuffer; // -> memory.cxx
extern sal_Char* pDummy1; // -> memory.cxx
extern OPCODE_FKT pOpFkt[ FKT_LIMIT ]; extern OPCODE_FKT pOpFkt[ FKT_LIMIT ];
// -> optab.cxx, Tabelle moeglicher Opcodes // -> optab.cxx, Tabelle moeglicher Opcodes
extern OPCODE_FKT pOpFkt123[ FKT_LIMIT123 ]; extern OPCODE_FKT pOpFkt123[ FKT_LIMIT123 ];
// -> optab.cxx, Table of possible Opcodes // -> optab.cxx, Table of possible Opcodes
extern long nDateiLaenge; // -> datei.cpp, ...der gerade offenen Datei
LOTUS_ROOT* pLotusRoot = NULL; LOTUS_ROOT* pLotusRoot = NULL;
...@@ -193,9 +185,10 @@ WKTYP ScanVersion( SvStream& aStream ) ...@@ -193,9 +185,10 @@ WKTYP ScanVersion( SvStream& aStream )
aStream >> nVersNr; aStream >> nVersNr;
if( aStream.IsEof() ) return eWK_Error; if( aStream.IsEof() ) return eWK_Error;
if( nVersNr == 0x0004 && nRecLen == 26 ) if( nVersNr == 0x0004 && nRecLen == 26 )
{ // 4 Bytes von 26 gelesen->22 ueberlesen { // 4 bytes of 26 read => skip 22 (read instead of seek to make IsEof() work just in case)
aStream.Read( pDummy1, 22 ); sal_Char aDummy[22];
return eWK3; aStream.Read( aDummy, 22 );
return aStream.IsEof() ? eWK_Error : eWK3;
} }
break; break;
case 0x1003: case 0x1003:
......
...@@ -68,7 +68,7 @@ void LotAttrCache::LotusToScBorderLine( sal_uInt8 nLine, SvxBorderLine& aBL ) ...@@ -68,7 +68,7 @@ void LotAttrCache::LotusToScBorderLine( sal_uInt8 nLine, SvxBorderLine& aBL )
const SvxColorItem& LotAttrCache::GetColorItem( const sal_uInt8 nLotIndex ) const const SvxColorItem& LotAttrCache::GetColorItem( const sal_uInt8 nLotIndex ) const
{ {
DBG_ASSERT( nLotIndex > 0 && nLotIndex < 7, DBG_ASSERT( nLotIndex > 0 && nLotIndex < 7,
"-LotAttrCache::GetColorItem(): so nicht!" ); "-LotAttrCache::GetColorItem(): caller hast to check index!" );
return *ppColorItems[ nLotIndex - 1 ]; return *ppColorItems[ nLotIndex - 1 ];
} }
...@@ -77,7 +77,7 @@ const SvxColorItem& LotAttrCache::GetColorItem( const sal_uInt8 nLotIndex ) cons ...@@ -77,7 +77,7 @@ const SvxColorItem& LotAttrCache::GetColorItem( const sal_uInt8 nLotIndex ) cons
const Color& LotAttrCache::GetColor( const sal_uInt8 nLotIndex ) const const Color& LotAttrCache::GetColor( const sal_uInt8 nLotIndex ) const
{ {
// Farbe <-> Index passt fuer Background, nicht aber fuer Fonts (0 <-> 7)! // Farbe <-> Index passt fuer Background, nicht aber fuer Fonts (0 <-> 7)!
DBG_ASSERT( nLotIndex < 8, "*LotAttrCache::GetColor(): Index > 7!" ); DBG_ASSERT( nLotIndex < 8, "*LotAttrCache::GetColor(): Index > 7, caller hast to check index!" );
return pColTab[ nLotIndex ]; return pColTab[ nLotIndex ];
} }
...@@ -208,6 +208,8 @@ LotAttrCol::~LotAttrCol() ...@@ -208,6 +208,8 @@ LotAttrCol::~LotAttrCol()
void LotAttrCol::SetAttr( const SCROW nRow, const ScPatternAttr& rAttr ) void LotAttrCol::SetAttr( const SCROW nRow, const ScPatternAttr& rAttr )
{ {
// Actually with the current implementation of MAXROWCOUNT>=64k and nRow
// being read as sal_uInt16 there's no chance that nRow would be invalid..
DBG_ASSERT( ValidRow(nRow), "*LotAttrCol::SetAttr(): ... und rums?!" ); DBG_ASSERT( ValidRow(nRow), "*LotAttrCol::SetAttr(): ... und rums?!" );
ENTRY* pAkt = ( ENTRY* ) List::Last(); ENTRY* pAkt = ( ENTRY* ) List::Last();
...@@ -275,6 +277,9 @@ LotAttrTable::~LotAttrTable() ...@@ -275,6 +277,9 @@ LotAttrTable::~LotAttrTable()
void LotAttrTable::SetAttr( const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, void LotAttrTable::SetAttr( const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow,
const LotAttrWK3& rAttr ) const LotAttrWK3& rAttr )
{ {
// With the current implementation of MAXCOLCOUNT>=1024 and nColFirst and
// nColLast being calculated as sal_uInt8+sal_uInt8 there's no chance that
// they would be invalid.
const ScPatternAttr& rPattAttr = aAttrCache.GetPattAttr( rAttr ); const ScPatternAttr& rPattAttr = aAttrCache.GetPattAttr( rAttr );
SCCOL nColCnt; SCCOL nColCnt;
......
...@@ -121,6 +121,7 @@ void LotusToSc::DoFunc( DefTokenId eOc, sal_uInt8 nAnz, const sal_Char* pExtStri ...@@ -121,6 +121,7 @@ void LotusToSc::DoFunc( DefTokenId eOc, sal_uInt8 nAnz, const sal_Char* pExtStri
break; break;
case ocChose: case ocChose:
{// 1. Parameter ++ {// 1. Parameter ++
if (nAnz >= 1)
IncToken( eParam[ nAnz - 1 ] ); IncToken( eParam[ nAnz - 1 ] );
} }
break; break;
...@@ -134,6 +135,7 @@ void LotusToSc::DoFunc( DefTokenId eOc, sal_uInt8 nAnz, const sal_Char* pExtStri ...@@ -134,6 +135,7 @@ void LotusToSc::DoFunc( DefTokenId eOc, sal_uInt8 nAnz, const sal_Char* pExtStri
case ocMid: case ocMid:
case ocReplace: case ocReplace:
{// 2. Parameter ++ {// 2. Parameter ++
if (nAnz >= 2)
IncToken( eParam[ nAnz - 2 ] ); IncToken( eParam[ nAnz - 2 ] );
} }
break; break;
...@@ -604,8 +606,9 @@ ConvErr LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest, ...@@ -604,8 +606,9 @@ ConvErr LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest,
if( nStrLen ) if( nStrLen )
{ {
// String t( ReadString( aIn, nStrLen, eSrcChar ) ); sal_Char* p = new (::std::nothrow) sal_Char[ nStrLen + 1 ];
sal_Char* p = new sal_Char[ nStrLen + 1 ]; if (p)
{
aIn.Read( p, nStrLen ); aIn.Read( p, nStrLen );
p[ nStrLen ] = 0x00; p[ nStrLen ] = 0x00;
...@@ -615,6 +618,9 @@ ConvErr LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest, ...@@ -615,6 +618,9 @@ ConvErr LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest,
} }
else else
DoFunc( ocNoName, nAnz, NULL ); DoFunc( ocNoName, nAnz, NULL );
}
else
DoFunc( ocNoName, nAnz, NULL );
} }
break; break;
case FT_Const10Float: case FT_Const10Float:
...@@ -1991,7 +1997,7 @@ const sal_Char* GetAddInName( const sal_uInt8 n ) ...@@ -1991,7 +1997,7 @@ const sal_Char* GetAddInName( const sal_uInt8 n )
} }
DefTokenId lcl_KnownAddIn( const ByteString& sTest ) static DefTokenId lcl_KnownAddIn( const ByteString& sTest )
{ {
DefTokenId eId = ocNoName; DefTokenId eId = ocNoName;
......
...@@ -46,6 +46,29 @@ ...@@ -46,6 +46,29 @@
static vos:: OMutex aLotImpSemaphore; static vos:: OMutex aLotImpSemaphore;
LOTUS_ROOT::LOTUS_ROOT( ScDocument* pDocP, CharSet eQ )
:
pDoc( pDocP),
pRangeNames( new LotusRangeList),
pScRangeName( pDocP->GetRangeName()),
eCharsetQ( eQ),
eFirstType( Lotus_X),
eActType( Lotus_X),
pRngNmBffWK3( new RangeNameBufferWK3),
pFontBuff( new LotusFontBuffer),
pAttrTable( new LotAttrTable)
{
}
LOTUS_ROOT::~LOTUS_ROOT()
{
delete pRangeNames;
delete pRngNmBffWK3;
delete pFontBuff;
delete pAttrTable;
}
ImportLotus::ImportLotus( SvStream& aStream, ScDocument* pDoc, CharSet eQ ) : ImportLotus::ImportLotus( SvStream& aStream, ScDocument* pDoc, CharSet eQ ) :
ImportTyp( pDoc, eQ ), ImportTyp( pDoc, eQ ),
...@@ -55,30 +78,14 @@ ImportLotus::ImportLotus( SvStream& aStream, ScDocument* pDoc, CharSet eQ ) : ...@@ -55,30 +78,14 @@ ImportLotus::ImportLotus( SvStream& aStream, ScDocument* pDoc, CharSet eQ ) :
// good point to start locking of import lotus // good point to start locking of import lotus
aLotImpSemaphore.acquire(); aLotImpSemaphore.acquire();
pLotusRoot = new LOTUS_ROOT; pLotusRoot = new LOTUS_ROOT( pDoc, eQ);
pLotusRoot->pDoc = pDoc;
pLotusRoot->pRangeNames = new LotusRangeList;
pLotusRoot->pScRangeName = pDoc->GetRangeName();
pLotusRoot->eCharsetQ = eQ;
pLotusRoot->eFirstType = Lotus_X;
pLotusRoot->eActType = Lotus_X;
pLotusRoot->pRngNmBffWK3 = new RangeNameBufferWK3;
pFontBuff = pLotusRoot->pFontBuff = new LotusFontBuffer;
pLotusRoot->pAttrTable = new LotAttrTable;
} }
ImportLotus::~ImportLotus() ImportLotus::~ImportLotus()
{ {
delete pLotusRoot->pRangeNames;
delete pLotusRoot->pRngNmBffWK3;
delete pFontBuff;
delete pLotusRoot->pAttrTable;
delete pLotusRoot; delete pLotusRoot;
#ifdef DBG_UTIL
pLotusRoot = NULL; pLotusRoot = NULL;
#endif
// no need 4 pLotusRoot anymore // no need 4 pLotusRoot anymore
aLotImpSemaphore.release(); aLotImpSemaphore.release();
...@@ -129,7 +136,7 @@ void ImportLotus::Columnwidth( sal_uInt16 nRecLen ) ...@@ -129,7 +136,7 @@ void ImportLotus::Columnwidth( sal_uInt16 nRecLen )
DBG_ASSERT( nRecLen >= 4, "*ImportLotus::Columnwidth(): Record zu kurz!" ); DBG_ASSERT( nRecLen >= 4, "*ImportLotus::Columnwidth(): Record zu kurz!" );
sal_uInt8 nLTab, nWindow2; sal_uInt8 nLTab, nWindow2;
sal_uInt16 nCnt = ( nRecLen - 4 ) / 2; sal_uInt16 nCnt = (nRecLen < 4) ? 0 : ( nRecLen - 4 ) / 2;
Read( nLTab ); Read( nLTab );
Read( nWindow2 ); Read( nWindow2 );
...@@ -161,7 +168,7 @@ void ImportLotus::Hiddencolumn( sal_uInt16 nRecLen ) ...@@ -161,7 +168,7 @@ void ImportLotus::Hiddencolumn( sal_uInt16 nRecLen )
DBG_ASSERT( nRecLen >= 4, "*ImportLotus::Hiddencolumn(): Record zu kurz!" ); DBG_ASSERT( nRecLen >= 4, "*ImportLotus::Hiddencolumn(): Record zu kurz!" );
sal_uInt8 nLTab, nWindow2; sal_uInt8 nLTab, nWindow2;
sal_uInt16 nCnt = ( nRecLen - 4 ) / 2; sal_uInt16 nCnt = (nRecLen < 4) ? 0 : ( nRecLen - 4 ) / 2;
Read( nLTab ); Read( nLTab );
Read( nWindow2 ); Read( nWindow2 );
...@@ -187,18 +194,17 @@ void ImportLotus::Userrange( void ) ...@@ -187,18 +194,17 @@ void ImportLotus::Userrange( void )
{ {
sal_uInt16 nRangeType; sal_uInt16 nRangeType;
ScRange aScRange; ScRange aScRange;
sal_Char* pBuffer = new sal_Char[ 32 ];
Read( nRangeType ); Read( nRangeType );
pIn->Read( pBuffer, 16 ); sal_Char aBuffer[ 17 ];
pBuffer[ 16 ] = ( sal_Char ) 0x00; // zur Sicherheit... pIn->Read( aBuffer, 16 );
String aName( pBuffer, eQuellChar ); aBuffer[ 16 ] = 0;
String aName( aBuffer, eQuellChar );
Read( aScRange ); Read( aScRange );
pLotusRoot->pRngNmBffWK3->Add( aName, aScRange ); pLotusRoot->pRngNmBffWK3->Add( aName, aScRange );
delete[] pBuffer;
} }
...@@ -239,7 +245,7 @@ void ImportLotus::Labelcell( void ) ...@@ -239,7 +245,7 @@ void ImportLotus::Labelcell( void )
void ImportLotus::Numbercell( void ) void ImportLotus::Numbercell( void )
{ {
ScAddress aAddr; ScAddress aAddr;
double fVal; double fVal;
...@@ -248,11 +254,11 @@ void ImportLotus::Numbercell( void ) ...@@ -248,11 +254,11 @@ void ImportLotus::Numbercell( void )
pD->PutCell( aAddr.Col(), aAddr.Row(), aAddr.Tab(), pD->PutCell( aAddr.Col(), aAddr.Row(), aAddr.Tab(),
new ScValueCell( fVal ), (sal_Bool)sal_True ); new ScValueCell( fVal ), (sal_Bool)sal_True );
} }
void ImportLotus::Smallnumcell( void ) void ImportLotus::Smallnumcell( void )
{ {
ScAddress aAddr; ScAddress aAddr;
sal_Int16 nVal; sal_Int16 nVal;
...@@ -261,11 +267,11 @@ void ImportLotus::Smallnumcell( void ) ...@@ -261,11 +267,11 @@ void ImportLotus::Smallnumcell( void )
pD->PutCell( aAddr.Col(), aAddr.Row(), aAddr.Tab(), pD->PutCell( aAddr.Col(), aAddr.Row(), aAddr.Tab(),
new ScValueCell( SnumToDouble( nVal ) ), ( sal_Bool ) sal_True ); new ScValueCell( SnumToDouble( nVal ) ), ( sal_Bool ) sal_True );
} }
ScFormulaCell *ImportLotus::Formulacell( sal_uInt16 n ) ScFormulaCell *ImportLotus::Formulacell( sal_uInt16 n )
{ {
DBG_ASSERT( pIn, "-ImportLotus::Formulacell(): Null-Stream -> Rums!" ); DBG_ASSERT( pIn, "-ImportLotus::Formulacell(): Null-Stream -> Rums!" );
ScAddress aAddr; ScAddress aAddr;
...@@ -273,7 +279,7 @@ ScFormulaCell *ImportLotus::Formulacell( sal_uInt16 n ) ...@@ -273,7 +279,7 @@ ScFormulaCell *ImportLotus::Formulacell( sal_uInt16 n )
Read( aAddr ); Read( aAddr );
Skip( 10 ); Skip( 10 );
n -= 14; n -= (n > 14) ? 14 : n;
const ScTokenArray* pErg; const ScTokenArray* pErg;
sal_Int32 nRest = n; sal_Int32 nRest = n;
...@@ -289,7 +295,7 @@ ScFormulaCell *ImportLotus::Formulacell( sal_uInt16 n ) ...@@ -289,7 +295,7 @@ ScFormulaCell *ImportLotus::Formulacell( sal_uInt16 n )
pD->PutCell( aAddr.Col(), aAddr.Row(), aAddr.Tab(), pZelle, (sal_Bool)sal_True ); pD->PutCell( aAddr.Col(), aAddr.Row(), aAddr.Tab(), pZelle, (sal_Bool)sal_True );
return NULL; return NULL;
} }
void ImportLotus::Read( String &r ) void ImportLotus::Read( String &r )
...@@ -304,7 +310,7 @@ void ImportLotus::RowPresentation( sal_uInt16 nRecLen ) ...@@ -304,7 +310,7 @@ void ImportLotus::RowPresentation( sal_uInt16 nRecLen )
sal_uInt8 nLTab, nFlags; sal_uInt8 nLTab, nFlags;
sal_uInt16 nRow, nHeight; sal_uInt16 nRow, nHeight;
sal_uInt16 nCnt = ( nRecLen - 4 ) / 8; sal_uInt16 nCnt = (nRecLen < 4) ? 0 : ( nRecLen - 4 ) / 8;
Read( nLTab ); Read( nLTab );
Skip( 1 ); Skip( 1 );
...@@ -355,52 +361,44 @@ void ImportLotus::Font_Face( void ) ...@@ -355,52 +361,44 @@ void ImportLotus::Font_Face( void )
Read( nNum ); Read( nNum );
// ACHTUNG: QUICK-HACK gegen unerklaerliche Loops if( nNum >= LotusFontBuffer::nSize )
if( nNum > 7 ) return; // nonsense
return;
// ACHTUNG
Read( aName ); Read( aName );
pFontBuff->SetName( nNum, aName ); pLotusRoot->pFontBuff->SetName( nNum, aName );
} }
void ImportLotus::Font_Type( void ) void ImportLotus::Font_Type( void )
{ {
static const sal_uInt16 nAnz = 8; for( sal_uInt16 nCnt = 0 ; nCnt < LotusFontBuffer::nSize ; nCnt++ )
sal_uInt16 nCnt;
sal_uInt16 nType;
for( nCnt = 0 ; nCnt < nAnz ; nCnt++ )
{ {
sal_uInt16 nType;
Read( nType ); Read( nType );
pFontBuff->SetType( nCnt, nType ); pLotusRoot->pFontBuff->SetType( nCnt, nType );
} }
} }
void ImportLotus::Font_Ysize( void ) void ImportLotus::Font_Ysize( void )
{ {
static const sal_uInt16 nAnz = 8; for( sal_uInt16 nCnt = 0 ; nCnt < LotusFontBuffer::nSize ; nCnt++ )
sal_uInt16 nCnt;
sal_uInt16 nSize;
for( nCnt = 0 ; nCnt < nAnz ; nCnt++ )
{ {
sal_uInt16 nSize;
Read( nSize ); Read( nSize );
pFontBuff->SetHeight( nCnt, nSize ); pLotusRoot->pFontBuff->SetHeight( nCnt, nSize );
} }
} }
void ImportLotus::_Row( const sal_uInt16 nRecLen ) void ImportLotus::_Row( const sal_uInt16 nRecLen )
{ {
DBG_ASSERT( nExtTab >= 0, "*ImportLotus::_Row(): Kann hier nicht sein!" ); DBG_ASSERT( nExtTab >= 0, "*ImportLotus::_Row(): Kann hier nicht sein!" );
sal_uInt16 nRow; sal_uInt16 nRow;
sal_uInt16 nHeight; sal_uInt16 nHeight;
sal_uInt16 nCntDwn = ( nRecLen - 4 ) / 5; sal_uInt16 nCntDwn = (nRecLen < 4) ? 0 : ( nRecLen - 4 ) / 5;
SCCOL nColCnt = 0; SCCOL nColCnt = 0;
sal_uInt8 nRepeats; sal_uInt8 nRepeats;
LotAttrWK3 aAttr; LotAttrWK3 aAttr;
...@@ -464,6 +462,4 @@ void ImportLotus::_Row( const sal_uInt16 nRecLen ) ...@@ -464,6 +462,4 @@ void ImportLotus::_Row( const sal_uInt16 nRecLen )
if( bCenter ) if( bCenter )
// evtl. alte Center bemachen // evtl. alte Center bemachen
pD->DoMerge( static_cast<SCTAB> (nExtTab), nCenterStart, static_cast<SCROW> (nRow), nCenterEnd, static_cast<SCROW> (nRow) ); pD->DoMerge( static_cast<SCTAB> (nExtTab), nCenterStart, static_cast<SCROW> (nRow), nCenterEnd, static_cast<SCROW> (nRow) );
} }
...@@ -73,7 +73,7 @@ FltError ImportLotus::Read() ...@@ -73,7 +73,7 @@ FltError ImportLotus::Read()
{ {
*pIn >> nOp >> nRecLen; *pIn >> nOp >> nRecLen;
if( pIn->IsEof() ) if( pIn->IsEof() || nNextRec > SAL_MAX_UINT32 - nRecLen - 4 )
eAkt = S_END; eAkt = S_END;
nNextRec += nRecLen + 4; nNextRec += nRecLen + 4;
...@@ -168,6 +168,8 @@ FltError ImportLotus::Read() ...@@ -168,6 +168,8 @@ FltError ImportLotus::Read()
break; break;
case 0x001b: // extended attributes case 0x001b: // extended attributes
if (nRecLen > 2)
{
Read( nSubType ); Read( nSubType );
nRecLen -= 2; nRecLen -= 2;
switch( nSubType ) switch( nSubType )
...@@ -181,6 +183,12 @@ FltError ImportLotus::Read() ...@@ -181,6 +183,12 @@ FltError ImportLotus::Read()
break; break;
} }
} }
else
{
eRet = eERR_FORMAT;
eAkt = S_END;
}
}
break; break;
// ----------------------------------------------------------- // -----------------------------------------------------------
...@@ -189,12 +197,6 @@ FltError ImportLotus::Read() ...@@ -189,12 +197,6 @@ FltError ImportLotus::Read()
// ----------------------------------------------------------- // -----------------------------------------------------------
case S_END: // S_END case S_END: // S_END
break; break;
// -----------------------------------------------------------
#ifdef DBG_UTIL
default:
DBG_ERROR( "*ImportLotus::Read(): State unbekannt!" );
eAkt = S_END;
#endif
} }
DBG_ASSERT( nNextRec >= pIn->Tell(), DBG_ASSERT( nNextRec >= pIn->Tell(),
...@@ -259,7 +261,7 @@ FltError ImportLotus::Read( SvStream& rIn ) ...@@ -259,7 +261,7 @@ FltError ImportLotus::Read( SvStream& rIn )
{ {
*pIn >> nOp >> nRecLen; *pIn >> nOp >> nRecLen;
if( pIn->IsEof() ) if( pIn->IsEof() || nNextRec > SAL_MAX_UINT32 - nRecLen - 4 )
bRead = sal_False; bRead = sal_False;
else else
{ {
......
...@@ -37,38 +37,10 @@ ...@@ -37,38 +37,10 @@
#include "decl.h" #include "decl.h"
#include "tool.h" #include "tool.h"
extern const long nStackSize;
extern const int nAnzNRange;
extern ScDocument* pDoc; extern ScDocument* pDoc;
const long nStackSize = 8L * 1024; // -> form_xxx.cpp
const int nAnzNRange = 2048; // -> tool_xxx.cpp, max. 2048 Named Ranges
sal_Char* pPuffer; // -> flt_xxx.cxx
sal_Char* pDummy1; // -> flt_xxx.cxx, ScanVersion()
sal_Char* pDummy2; // -> tool.cxx, CreateTable()
extern sal_uInt8* pFormelBuffer; // -> tool.cxx, fuer OP_Formula()
sal_uInt8* pFormelBuffer;
extern FormCache* pValueFormCache; // -> tool.cxx extern FormCache* pValueFormCache; // -> tool.cxx
sal_Char* pStack; // -> formel.cxx
sal_Char* pPuffer0; // -> formel.cxx
sal_Char* pPuffer1; // -> formel.cxx
extern const int nMaxPar;
const int nMaxPar = 128; // max. 128 Parameter werden unterstuetzt
sal_Char** pPar; // -> formel.cxx, Pn()
#ifndef _DOS // -> op.cxx
sal_Char* pAnsi;
#endif
sal_Char* pErgebnis; // -> op.cxx
extern sal_Bool bFormInit; // -> tool.cxx, fuer GetFormHandle()
sal_Bool bFormInit;
extern SvxHorJustifyItem *pAttrRight, *pAttrLeft, *pAttrCenter, extern SvxHorJustifyItem *pAttrRight, *pAttrLeft, *pAttrCenter,
*pAttrRepeat, *pAttrStandard; // -> tool.cxx, fuer GetFormAttr() *pAttrRepeat, *pAttrStandard; // -> tool.cxx, fuer GetFormAttr()
extern ScProtectionAttr* pAttrUnprot; // -> tool.cxx, fuer PutFormString() extern ScProtectionAttr* pAttrUnprot; // -> tool.cxx, fuer PutFormString()
...@@ -77,25 +49,6 @@ extern ScProtectionAttr* pAttrUnprot; // -> tool.cxx, fuer PutFormString() ...@@ -77,25 +49,6 @@ extern ScProtectionAttr* pAttrUnprot; // -> tool.cxx, fuer PutFormString()
sal_Bool MemNew( void ) sal_Bool MemNew( void )
{ {
pPuffer = new sal_Char [ 32L*1024L ];
pDummy1 = new sal_Char [ 32 ];
pDummy2 = new sal_Char [ 32 ];
pStack = new sal_Char [ nStackSize * 3 ]; // alle drei auf einmal
pPuffer0 = pStack + nStackSize;
pPuffer1 = pPuffer0 + nStackSize;
pAnsi = new sal_Char [ 2048 ];
pErgebnis = new sal_Char [ 32L*1024L ];
pPar = new sal_Char *[ nMaxPar ];
pFormelBuffer = new sal_uInt8[ 4096 ];
pValueFormCache = new FormCache( pDoc ); pValueFormCache = new FormCache( pDoc );
// fuer tool.cxx::PutFormString() // fuer tool.cxx::PutFormString()
...@@ -105,7 +58,6 @@ sal_Bool MemNew( void ) ...@@ -105,7 +58,6 @@ sal_Bool MemNew( void )
pAttrCenter = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY ); pAttrCenter = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY );
pAttrRepeat = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_REPEAT, ATTR_HOR_JUSTIFY ); pAttrRepeat = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_REPEAT, ATTR_HOR_JUSTIFY );
pAttrStandard = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY ); pAttrStandard = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY );
bFormInit = sal_True;
return sal_True; return sal_True;
} }
...@@ -113,15 +65,6 @@ sal_Bool MemNew( void ) ...@@ -113,15 +65,6 @@ sal_Bool MemNew( void )
void MemDelete( void ) void MemDelete( void )
{ {
delete[] pPuffer;
delete[] pDummy1;
delete[] pDummy2;
delete[] pStack;
delete[] pAnsi;
delete[] pErgebnis;
delete[] pPar;
delete[] pFormelBuffer;
delete pValueFormCache; delete pValueFormCache;
delete pAttrRight; delete pAttrRight;
delete pAttrLeft; delete pAttrLeft;
......
This diff is collapsed.
...@@ -52,11 +52,7 @@ ...@@ -52,11 +52,7 @@
//--------------------------------------------------------- EXTERNE VARIABLEN - //--------------------------------------------------------- EXTERNE VARIABLEN -
extern WKTYP eTyp; // -> filter.cxx, aktueller Dateityp extern WKTYP eTyp; // -> filter.cxx, aktueller Dateityp
extern sal_Char* pDummy2; // -> memory.cxx
extern ScDocument* pDoc; // -> filter.cxx, Aufhaenger zum Dokumentzugriff extern ScDocument* pDoc; // -> filter.cxx, Aufhaenger zum Dokumentzugriff
extern CharSet eCharNach; // -> filter.cxx, Zeichenkonvertierung von->nach
extern sal_Bool bFormInit; // -> memory.cxx, fuer GetFormHandle()
//--------------------------------------------------------- GLOBALE VARIABLEN - //--------------------------------------------------------- GLOBALE VARIABLEN -
sal_uInt8 nDefaultFormat; // -> op.cpp, Standard-Zellenformat sal_uInt8 nDefaultFormat; // -> op.cpp, Standard-Zellenformat
...@@ -82,6 +78,8 @@ void PutFormString( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Char* pString ) ...@@ -82,6 +78,8 @@ void PutFormString( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Char* pString )
{ {
// Label-Format-Auswertung // Label-Format-Auswertung
DBG_ASSERT( pString != NULL, "PutFormString(): pString == NULL" ); DBG_ASSERT( pString != NULL, "PutFormString(): pString == NULL" );
if (!pString)
return;
sal_Char cForm; sal_Char cForm;
SvxHorJustifyItem* pJustify = NULL; SvxHorJustifyItem* pJustify = NULL;
...@@ -113,12 +111,9 @@ void PutFormString( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Char* pString ) ...@@ -113,12 +111,9 @@ void PutFormString( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Char* pString )
pJustify = pAttrStandard; pJustify = pAttrStandard;
} }
if( pString )
{
pDoc->ApplyAttr( nCol, nRow, nTab, *pJustify ); pDoc->ApplyAttr( nCol, nRow, nTab, *pJustify );
ScStringCell* pZelle = new ScStringCell( String( pString, pLotusRoot->eCharsetQ ) ); ScStringCell* pZelle = new ScStringCell( String( pString, pLotusRoot->eCharsetQ ) );
pDoc->PutCell( nCol, nRow, nTab, pZelle, ( sal_Bool ) sal_True ); pDoc->PutCell( nCol, nRow, nTab, pZelle, ( sal_Bool ) sal_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