Kaydet (Commit) 96328945 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Ivan Timofeev

Convert tools/table.hxx to std::map in ScEEParser class in SC module

üst a13a9a04
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <tools/urlobj.hxx> #include <tools/urlobj.hxx>
#include <tools/tenccvt.hxx> #include <tools/tenccvt.hxx>
#include <tools/table.hxx>
#include "htmlpars.hxx" #include "htmlpars.hxx"
#include "global.hxx" #include "global.hxx"
...@@ -331,7 +332,7 @@ sal_uLong ScHTMLLayoutParser::Read( SvStream& rStream, const String& rBaseURL ) ...@@ -331,7 +332,7 @@ sal_uLong ScHTMLLayoutParser::Read( SvStream& rStream, const String& rBaseURL )
{ {
aSize.Width() = *pOff - nOff; aSize.Width() = *pOff - nOff;
aSize = pDefaultDev->PixelToLogic( aSize, MapMode( MAP_TWIP ) ); aSize = pDefaultDev->PixelToLogic( aSize, MapMode( MAP_TWIP ) );
pColWidths->Insert( j-1, (void*)aSize.Width() ); maColWidths[ j-1 ] = aSize.Width();
nOff = *pOff; nOff = *pOff;
} }
return nErr; return nErr;
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <tools/string.hxx> #include <tools/string.hxx>
#include <tools/gen.hxx> #include <tools/gen.hxx>
#include <vcl/graph.hxx> #include <vcl/graph.hxx>
#include <tools/table.hxx>
#include <svl/itemset.hxx> #include <svl/itemset.hxx>
#include <editeng/editdata.hxx> #include <editeng/editdata.hxx>
#include <address.hxx> #include <address.hxx>
...@@ -108,6 +107,8 @@ struct ScEEParseEntry ...@@ -108,6 +107,8 @@ struct ScEEParseEntry
class EditEngine; class EditEngine;
typedef std::map<SCCOL, sal_uInt16> ColWidthsMap;
class ScEEParser class ScEEParser
{ {
protected: protected:
...@@ -116,7 +117,7 @@ protected: ...@@ -116,7 +117,7 @@ protected:
SfxItemPool* pDocPool; SfxItemPool* pDocPool;
::std::vector< ScEEParseEntry* > maList; ::std::vector< ScEEParseEntry* > maList;
ScEEParseEntry* pActEntry; ScEEParseEntry* pActEntry;
Table* pColWidths; ColWidthsMap maColWidths;
int nLastToken; int nLastToken;
SCCOL nColCnt; SCCOL nColCnt;
SCROW nRowCnt; SCROW nRowCnt;
...@@ -131,7 +132,8 @@ public: ...@@ -131,7 +132,8 @@ public:
virtual sal_uLong Read( SvStream&, const String& rBaseURL ) = 0; virtual sal_uLong Read( SvStream&, const String& rBaseURL ) = 0;
Table* GetColWidths() const { return pColWidths; } const ColWidthsMap& GetColWidths() const { return maColWidths; }
ColWidthsMap& GetColWidths() { return maColWidths; }
void GetDimensions( SCCOL& nCols, SCROW& nRows ) const void GetDimensions( SCCOL& nCols, SCROW& nRows ) const
{ nCols = nColMax; nRows = nRowMax; } { nCols = nColMax; nRows = nRowMax; }
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include <unotools/syslocale.hxx> #include <unotools/syslocale.hxx>
#include <unotools/charclass.hxx> #include <unotools/charclass.hxx>
#include <comphelper/string.hxx> #include <comphelper/string.hxx>
#include <tools/table.hxx>
#include "eeimport.hxx" #include "eeimport.hxx"
#include "global.hxx" #include "global.hxx"
...@@ -431,14 +432,17 @@ void ScEEImport::WriteToDocument( sal_Bool bSizeColsRows, double nOutputFactor, ...@@ -431,14 +432,17 @@ void ScEEImport::WriteToDocument( sal_Bool bSizeColsRows, double nOutputFactor,
if ( bSizeColsRows ) if ( bSizeColsRows )
{ {
// Spaltenbreiten // Spaltenbreiten
Table* pColWidths = mpParser->GetColWidths(); ColWidthsMap& rColWidths = mpParser->GetColWidths();
if ( pColWidths->Count() ) if ( !rColWidths.empty() )
{ {
nProgress = 0; nProgress = 0;
pProgress->SetState( nProgress, nEndCol - nStartCol + 1 ); pProgress->SetState( nProgress, nEndCol - nStartCol + 1 );
for ( SCCOL nCol = nStartCol; nCol <= nEndCol; nCol++ ) for ( SCCOL nCol = nStartCol; nCol <= nEndCol; nCol++ )
{ {
sal_uInt16 nWidth = (sal_uInt16)(sal_uLong) pColWidths->Get( nCol ); sal_uInt16 nWidth = 0;
ColWidthsMap::const_iterator it = rColWidths.find( nCol );
if ( it != rColWidths.end() )
nWidth = it->second;
if ( nWidth ) if ( nWidth )
mpDoc->SetColWidth( nCol, nTab, nWidth ); mpDoc->SetColWidth( nCol, nTab, nWidth );
pProgress->SetState( ++nProgress ); pProgress->SetState( ++nProgress );
...@@ -513,20 +517,22 @@ sal_Bool ScEEImport::GraphicSize( SCCOL nCol, SCROW nRow, SCTAB /*nTab*/, ScEEPa ...@@ -513,20 +517,22 @@ sal_Bool ScEEImport::GraphicSize( SCCOL nCol, SCROW nRow, SCTAB /*nTab*/, ScEEPa
nDir = pI->nDir; nDir = pI->nDir;
} }
// Spaltenbreiten // Spaltenbreiten
Table* pColWidths = mpParser->GetColWidths(); ColWidthsMap& rColWidths = mpParser->GetColWidths();
long nThisWidth = (long) pColWidths->Get( nCol ); long nThisWidth = 0;
ColWidthsMap::const_iterator it = rColWidths.find( nCol );
if ( it != rColWidths.end() )
nThisWidth = it->second;
long nColWidths = nThisWidth; long nColWidths = nThisWidth;
SCCOL nColSpanCol = nCol + pE->nColOverlap; SCCOL nColSpanCol = nCol + pE->nColOverlap;
for ( SCCOL nC = nCol + 1; nC < nColSpanCol; nC++ ) for ( SCCOL nC = nCol + 1; nC < nColSpanCol; nC++ )
{ {
nColWidths += (long) pColWidths->Get( nC ); ColWidthsMap::const_iterator it2 = rColWidths.find( nC );
if ( it2 != rColWidths.end() )
nColWidths += it2->second;
} }
if ( nWidth > nColWidths ) if ( nWidth > nColWidths )
{ // Differenz nur in der ersten Spalte eintragen { // Differenz nur in der ersten Spalte eintragen
if ( nThisWidth ) rColWidths[ nCol ] = nWidth - nColWidths + nThisWidth;
pColWidths->Replace( nCol, (void*)(nWidth - nColWidths + nThisWidth) );
else
pColWidths->Insert( nCol, (void*)(nWidth - nColWidths) );
} }
// Zeilenhoehen, Differenz auf alle betroffenen Zeilen verteilen // Zeilenhoehen, Differenz auf alle betroffenen Zeilen verteilen
SCROW nRowSpan = pE->nRowOverlap; SCROW nRowSpan = pE->nRowOverlap;
...@@ -619,7 +625,6 @@ ScEEParser::ScEEParser( EditEngine* pEditP ) : ...@@ -619,7 +625,6 @@ ScEEParser::ScEEParser( EditEngine* pEditP ) :
pEdit( pEditP ), pEdit( pEditP ),
pPool( EditEngine::CreatePool() ), pPool( EditEngine::CreatePool() ),
pDocPool( new ScDocumentPool ), pDocPool( new ScDocumentPool ),
pColWidths( new Table ),
nLastToken(0), nLastToken(0),
nColCnt(0), nColCnt(0),
nRowCnt(0), nRowCnt(0),
...@@ -636,7 +641,6 @@ ScEEParser::ScEEParser( EditEngine* pEditP ) : ...@@ -636,7 +641,6 @@ ScEEParser::ScEEParser( EditEngine* pEditP ) :
ScEEParser::~ScEEParser() ScEEParser::~ScEEParser()
{ {
delete pActEntry; delete pActEntry;
delete pColWidths;
if ( !maList.empty() ) maList.clear(); if ( !maList.empty() ) maList.clear();
// Pool erst loeschen nachdem die Listen geloescht wurden // Pool erst loeschen nachdem die Listen geloescht wurden
......
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