summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-03-16 14:56:53 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2012-03-22 06:56:27 +0100
commitdb3786ee3aa0d8911042c9bbcea02cf36d96dfa1 (patch)
tree8cdd3e6f52fc5a61a6b953dbe37b537c2e33a15e /sc/source
parent6af00cf90f4314be11ac7d8f186bb9da4f228cf1 (diff)
Convert tools/table.hxx to std::map in Chart2PositionMap class
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/ui/unoobj/chart2uno.cxx88
1 files changed, 46 insertions, 42 deletions
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 0c86655c9fe0..469eb1d8bade 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -47,7 +47,6 @@
#include "formula/opcode.hxx"
#include <sfx2/objsh.hxx>
-#include <tools/table.hxx>
#include <vcl/svapp.hxx>
#include <com/sun/star/beans/UnknownPropertyException.hpp>
@@ -249,12 +248,14 @@ vector<ScTokenRef>* TokenTable::getAllRanges() const
}
// ============================================================================
+typedef std::map<int, ScToken*> ScTokenPtrMap;
+typedef std::map<int, ScTokenPtrMap*> ChartTokenMap;
class Chart2PositionMap
{
public:
Chart2PositionMap(SCCOL nColCount, SCROW nRowCount,
- bool bFillRowHeader, bool bFillColumnHeader, Table& rCols,
+ bool bFillRowHeader, bool bFillColumnHeader, ChartTokenMap& rCols,
ScDocument* pDoc );
~Chart2PositionMap();
@@ -282,7 +283,7 @@ private:
};
Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
- bool bFillRowHeader, bool bFillColumnHeader, Table& rCols, ScDocument* pDoc)
+ bool bFillRowHeader, bool bFillColumnHeader, ChartTokenMap& rCols, ScDocument* pDoc)
{
// if bFillRowHeader is true, at least the first column serves as a row header.
// If more than one column is pure text all the first pure text columns are used as header.
@@ -299,16 +300,18 @@ Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
SCROW nSmallestValueRowIndex = nAllRowCount;
bool bFoundValues = false;
bool bFoundAnything = false;
- Table* pCol = static_cast<Table*>(rCols.First());
+ ChartTokenMap::iterator aColIter = rCols.begin();
for (SCCOL nCol = 0; !bFoundValues && nCol < nAllColCount; ++nCol)
{
- if (pCol && nCol>=nHeaderColCount)
+ if (aColIter != rCols.end() && nCol>=nHeaderColCount)
{
- ScToken* pToken = static_cast<ScToken*>(pCol->First());
+ ScTokenPtrMap* pCol = aColIter->second;
+ ScTokenPtrMap::iterator tokenIter = pCol->begin();
for (SCROW nRow = 0; !bFoundValues && nRow < nSmallestValueRowIndex; ++nRow)
{
- if (pToken && nRow>=nHeaderRowCount)
+ if (tokenIter != pCol->end() && nRow>=nHeaderRowCount)
{
+ ScToken* pToken = tokenIter->second;
ScRange aRange;
bool bExternal = false;
StackVar eType = pToken->GetType();
@@ -331,12 +334,14 @@ Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
bFoundAnything = true;
}
}
- pToken = static_cast<ScToken*>(pCol->Next());
+ if (tokenIter != pCol->end() )
+ ++tokenIter;
}
if(!bFoundValues && nHeaderColCount>0)
nHeaderColCount++;
}
- pCol = static_cast<Table*>(rCols.Next());
+ if (aColIter != rCols.end())
+ ++aColIter;
}
if( bFoundAnything )
{
@@ -360,15 +365,16 @@ Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
maRowHeaders.init(nHeaderColCount,mnDataRowCount);
maData.init(mnDataColCount,mnDataRowCount);
- Table* pCol = static_cast<Table*>(rCols.First());
- FormulaToken* pToken = NULL;
+ ChartTokenMap::iterator aColIter = rCols.begin();
for (SCCOL nCol = 0; nCol < nAllColCount; ++nCol)
{
- if (pCol)
+ if (aColIter != rCols.end())
{
- pToken = static_cast<FormulaToken*>(pCol->First());
+ ScTokenPtrMap* pCol = aColIter->second;
+ ScTokenPtrMap::iterator tokenIter = pCol->begin();
for (SCROW nRow = 0; nRow < nAllRowCount; ++nRow)
{
+ FormulaToken* pToken = static_cast<FormulaToken*>(tokenIter->second);
if( nCol < nHeaderColCount )
{
if( nRow < nHeaderRowCount )
@@ -380,11 +386,10 @@ Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
maColHeaders.push_back(pToken);
else
maData.push_back(pToken);
-
- pToken = static_cast<FormulaToken*>(pCol->Next());
+ ++tokenIter;
}
+ ++aColIter;
}
- pCol = static_cast<Table*>(rCols.Next());
}
}
@@ -715,10 +720,7 @@ void Chart2Positioner::createPositionMap()
glueState();
bool bNoGlue = (meGlue == GLUETYPE_NONE);
- SAL_WNODEPRECATED_DECLARATIONS_PUSH
- auto_ptr<Table> pCols(new Table);
- SAL_WNODEPRECATED_DECLARATIONS_POP
- Table* pCol = NULL;
+ auto_ptr<ChartTokenMap> pCols(new ChartTokenMap);
SCROW nNoGlueRow = 0;
for (vector<ScTokenRef>::const_iterator itr = mrRefTokens.begin(), itrEnd = mrRefTokens.end();
itr != itrEnd; ++itr)
@@ -748,12 +750,15 @@ void Chart2Positioner::createPositionMap()
for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol, ++nInsCol)
{
- pCol = static_cast<Table*>(pCols->Get(nInsCol));
- if (!pCol)
+ ScTokenPtrMap* pCol = NULL;
+ ChartTokenMap::iterator it = pCols->find( nInsCol );
+ if ( it == pCols->end() )
{
- pCol = new Table;
- pCols->Insert(nInsCol, pCol);
+ pCol = new ScTokenPtrMap;
+ (*pCols)[nInsCol] = pCol;
}
+ else
+ pCol = it->second;
sal_uInt32 nInsRow = static_cast<sal_uInt32>(bNoGlue ? nNoGlueRow : nRow1);
for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow, ++nInsRow)
@@ -768,12 +773,12 @@ void Chart2Positioner::createPositionMap()
aCellData.nRow = nRow;
aCellData.nTab = nTab;
- if (pCol->Get(nInsRow) == NULL)
+ if ( pCol->find(nInsRow) == pCol->end() )
{
if (bExternal)
- pCol->Insert(nInsRow, new ScExternalSingleRefToken(nFileId, aTabName, aCellData));
+ (*pCol)[nInsRow] = new ScExternalSingleRefToken(nFileId, aTabName, aCellData);
else
- pCol->Insert(nInsRow, new ScSingleRefToken(aCellData));
+ (*pCol)[nInsRow] = new ScSingleRefToken(aCellData);
}
}
}
@@ -784,29 +789,28 @@ void Chart2Positioner::createPositionMap()
bool bFillRowHeader = mbRowHeaders;
bool bFillColumnHeader = mbColHeaders;
- SCSIZE nAllColCount = static_cast<SCSIZE>(pCols->Count());
+ SCSIZE nAllColCount = static_cast<SCSIZE>(pCols->size());
SCSIZE nAllRowCount = 0;
- pCol = static_cast<Table*>(pCols->First());
- if (pCol)
+ if ( !pCols->empty() )
{
+ nAllRowCount = static_cast<SCSIZE>(pCols->begin()->second->size());
if (mbDummyUpperLeft)
- pCol->Insert(0, NULL); // Dummy fuer Beschriftung
- nAllRowCount = static_cast<SCSIZE>(pCol->Count());
+ (*pCols)[ 0 ] = NULL; // Dummy fuer Beschriftung
}
if( nAllColCount!=0 && nAllRowCount!=0 )
{
if (bNoGlue)
{
- Table* pFirstCol = static_cast<Table*>(pCols->First());
- sal_uInt32 nCount = pFirstCol->Count();
- pFirstCol->First();
- for (sal_uInt32 n = 0; n < nCount; ++n, pFirstCol->Next())
+ ScTokenPtrMap* pFirstCol = pCols->begin()->second;
+ for ( ScTokenPtrMap::const_iterator it1 = pFirstCol->begin(); it1 != pFirstCol->end(); ++it1 )
{
- sal_uInt32 nKey = pFirstCol->GetCurKey();
- pCols->First();
- for (pCol = static_cast<Table*>(pCols->Next()); pCol; pCol = static_cast<Table*>(pCols->Next()))
- pCol->Insert(nKey, NULL);
+ sal_uInt32 nKey = it1->first;
+ for ( ChartTokenMap::const_iterator it2 = pCols->begin(); it2 != pCols->end(); ++it2 )
+ {
+ ScTokenPtrMap* pCol = it2->second;
+ (*pCol)[nKey] = NULL;
+ }
}
}
}
@@ -816,8 +820,8 @@ void Chart2Positioner::createPositionMap()
bFillRowHeader, bFillColumnHeader, *pCols, mpDoc));
// Destroy all column instances.
- for (pCol = static_cast<Table*>(pCols->First()); pCol; pCol = static_cast<Table*>(pCols->Next()))
- delete pCol;
+ for (ChartTokenMap::const_iterator it = pCols->begin(); it != pCols->end(); ++it)
+ delete it->second;
}
// ============================================================================