[Libreoffice-commits] .: 5 commits - sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Sat Mar 24 19:42:45 PDT 2012
sc/source/ui/unoobj/chart2uno.cxx | 111 +++++++++++++++++++++-----------------
1 file changed, 62 insertions(+), 49 deletions(-)
New commits:
commit 8269e88b9b9ba508f53489269031e5d41074fc60
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Mar 25 04:38:20 2012 +0200
Revert "simplify code - remove unnecessary and complicated allocation"
This reverts commit 3ffdb45ae047f12480e73fdd4b28fe35f1e8d48c.
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 1c637fb..5ff808b 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -717,6 +717,7 @@ void Chart2Positioner::createPositionMap()
bool bNoGlue = (meGlue == GLUETYPE_NONE);
SAL_WNODEPRECATED_DECLARATIONS_PUSH
auto_ptr<Table> pCols(new Table);
+ auto_ptr<FormulaToken> pNewAddress;
auto_ptr<Table> pNewRowTable(new Table);
SAL_WNODEPRECATED_DECLARATIONS_POP
Table* pCol = NULL;
@@ -783,18 +784,19 @@ void Chart2Positioner::createPositionMap()
aCellData.nRow = nRow;
aCellData.nTab = nTab;
- if (pCol->Get(nInsRow) == NULL)
- {
- if (bExternal)
- pCol->Insert(nInsRow, new ScExternalSingleRefToken(nFileId, aTabName, aCellData));
- else
- pCol->Insert(nInsRow, new ScSingleRefToken(aCellData));
- }
+ if (bExternal)
+ pNewAddress.reset(new ScExternalSingleRefToken(nFileId, aTabName, aCellData));
+ else
+ pNewAddress.reset(new ScSingleRefToken(aCellData));
+
+ if (pCol->Insert(nInsRow, pNewAddress.get()))
+ pNewAddress.release(); // To prevent the instance from being destroyed.
}
}
}
nNoGlueRow += nRow2 - nRow1 + 1;
}
+ pNewAddress.reset(NULL);
pNewRowTable.reset(NULL);
bool bFillRowHeader = mbRowHeaders;
commit 3079cebfe62a482cb82a67a77e436b85f6249b9c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Mar 25 04:38:02 2012 +0200
Revert "restructure insert code as a precursor to further simplification"
This reverts commit 4aa72e0dee42c80667083c0b86a3d0ec5381c1ae.
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index e2f7059..1c637fb 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -761,13 +761,13 @@ void Chart2Positioner::createPositionMap()
}
else
{
- pCol = static_cast<Table*>(pCols->Get(nInsCol));
- if (!pCol)
+ if (pCols->Insert(nInsCol, pNewRowTable.get()))
{
- pCol = pNewRowTable.get();
- pCols->Insert(nInsCol, pNewRowTable.release());
+ pCol = pNewRowTable.release();
pNewRowTable.reset(new Table);
}
+ else
+ pCol = static_cast<Table*>(pCols->Get(nInsCol));
}
sal_uInt32 nInsRow = static_cast<sal_uInt32>(bNoGlue ? nNoGlueRow : nRow1);
@@ -786,7 +786,7 @@ void Chart2Positioner::createPositionMap()
if (pCol->Get(nInsRow) == NULL)
{
if (bExternal)
- pCol->Insert(nInsRow, new ScExternalSingleRefToken(nFileId, aTabName, aCellData))
+ pCol->Insert(nInsRow, new ScExternalSingleRefToken(nFileId, aTabName, aCellData));
else
pCol->Insert(nInsRow, new ScSingleRefToken(aCellData));
}
commit d1fcea677a0d814ca92a00717a4ff7090291f6cd
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Mar 25 04:37:41 2012 +0200
Revert "if/else branches contain same code"
This reverts commit 13bf19769e6e0522d920594225b9baa2c1b7dd63.
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 1a04ce4..e2f7059 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -749,12 +749,25 @@ void Chart2Positioner::createPositionMap()
for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol, ++nInsCol)
{
- pCol = static_cast<Table*>(pCols->Get(nInsCol));
- if (!pCol)
+ if (bNoGlue || meGlue == GLUETYPE_ROWS)
{
- pCol = pNewRowTable.get();
- pCols->Insert(nInsCol, pNewRowTable.release());
- pNewRowTable.reset(new Table);
+ pCol = static_cast<Table*>(pCols->Get(nInsCol));
+ if (!pCol)
+ {
+ pCol = pNewRowTable.get();
+ pCols->Insert(nInsCol, pNewRowTable.release());
+ pNewRowTable.reset(new Table);
+ }
+ }
+ else
+ {
+ pCol = static_cast<Table*>(pCols->Get(nInsCol));
+ if (!pCol)
+ {
+ pCol = pNewRowTable.get();
+ pCols->Insert(nInsCol, pNewRowTable.release());
+ pNewRowTable.reset(new Table);
+ }
}
sal_uInt32 nInsRow = static_cast<sal_uInt32>(bNoGlue ? nNoGlueRow : nRow1);
commit 300365c29b1fb3ff47d9b24cacd990f9df1c9555
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Mar 25 04:37:24 2012 +0200
Revert "remove unnecessary use of local variable and auto_ptr"
This reverts commit 6af00cf90f4314be11ac7d8f186bb9da4f228cf1.
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 0c86655..1a04ce4 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -717,6 +717,7 @@ void Chart2Positioner::createPositionMap()
bool bNoGlue = (meGlue == GLUETYPE_NONE);
SAL_WNODEPRECATED_DECLARATIONS_PUSH
auto_ptr<Table> pCols(new Table);
+ auto_ptr<Table> pNewRowTable(new Table);
SAL_WNODEPRECATED_DECLARATIONS_POP
Table* pCol = NULL;
SCROW nNoGlueRow = 0;
@@ -751,8 +752,9 @@ void Chart2Positioner::createPositionMap()
pCol = static_cast<Table*>(pCols->Get(nInsCol));
if (!pCol)
{
- pCol = new Table;
- pCols->Insert(nInsCol, pCol);
+ pCol = pNewRowTable.get();
+ pCols->Insert(nInsCol, pNewRowTable.release());
+ pNewRowTable.reset(new Table);
}
sal_uInt32 nInsRow = static_cast<sal_uInt32>(bNoGlue ? nNoGlueRow : nRow1);
@@ -771,7 +773,7 @@ void Chart2Positioner::createPositionMap()
if (pCol->Get(nInsRow) == NULL)
{
if (bExternal)
- pCol->Insert(nInsRow, new ScExternalSingleRefToken(nFileId, aTabName, aCellData));
+ pCol->Insert(nInsRow, new ScExternalSingleRefToken(nFileId, aTabName, aCellData))
else
pCol->Insert(nInsRow, new ScSingleRefToken(aCellData));
}
@@ -780,6 +782,7 @@ void Chart2Positioner::createPositionMap()
}
nNoGlueRow += nRow2 - nRow1 + 1;
}
+ pNewRowTable.reset(NULL);
bool bFillRowHeader = mbRowHeaders;
bool bFillColumnHeader = mbColHeaders;
commit 473a182824c2e3413dd5b36f193bb9a586b4a0ce
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Mar 25 04:37:06 2012 +0200
Revert "Convert tools/table.hxx to std::map in Chart2PositionMap class"
This reverts commit db3786ee3aa0d8911042c9bbcea02cf36d96dfa1.
Conflicts:
sc/source/ui/unoobj/chart2uno.cxx
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 9f5e3cd..0c86655 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -47,6 +47,7 @@
#include "formula/opcode.hxx"
#include <sfx2/objsh.hxx>
+#include <tools/table.hxx>
#include <vcl/svapp.hxx>
#include <com/sun/star/beans/UnknownPropertyException.hpp>
@@ -248,14 +249,12 @@ 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, ChartTokenMap& rCols,
+ bool bFillRowHeader, bool bFillColumnHeader, Table& rCols,
ScDocument* pDoc );
~Chart2PositionMap();
@@ -283,7 +282,7 @@ private:
};
Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
- bool bFillRowHeader, bool bFillColumnHeader, ChartTokenMap& rCols, ScDocument* pDoc)
+ bool bFillRowHeader, bool bFillColumnHeader, Table& 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.
@@ -300,17 +299,14 @@ Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
SCROW nSmallestValueRowIndex = nAllRowCount;
bool bFoundValues = false;
bool bFoundAnything = false;
- ChartTokenMap::iterator aColIter = rCols.begin();
+ Table* pCol = static_cast<Table*>(rCols.First());
for (SCCOL nCol = 0; !bFoundValues && nCol < nAllColCount; ++nCol)
{
- if (aColIter != rCols.end() && nCol>=nHeaderColCount)
+ if (pCol && nCol>=nHeaderColCount)
{
- ScTokenPtrMap* pCol = aColIter->second;
- ScTokenPtrMap::iterator tokenIter = pCol->begin();
+ ScToken* pToken = static_cast<ScToken*>(pCol->First());
for (SCROW nRow = 0; !bFoundValues && nRow < nSmallestValueRowIndex; ++nRow)
{
- ScToken* pToken =
- tokenIter == pCol->end() ? 0 : tokenIter->second;
if (pToken && nRow>=nHeaderRowCount)
{
ScRange aRange;
@@ -335,14 +331,12 @@ Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
bFoundAnything = true;
}
}
- if (tokenIter != pCol->end() )
- ++tokenIter;
+ pToken = static_cast<ScToken*>(pCol->Next());
}
if(!bFoundValues && nHeaderColCount>0)
nHeaderColCount++;
}
- if (aColIter != rCols.end())
- ++aColIter;
+ pCol = static_cast<Table*>(rCols.Next());
}
if( bFoundAnything )
{
@@ -366,16 +360,15 @@ Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
maRowHeaders.init(nHeaderColCount,mnDataRowCount);
maData.init(mnDataColCount,mnDataRowCount);
- ChartTokenMap::iterator aColIter = rCols.begin();
+ Table* pCol = static_cast<Table*>(rCols.First());
+ FormulaToken* pToken = NULL;
for (SCCOL nCol = 0; nCol < nAllColCount; ++nCol)
{
- if (aColIter != rCols.end())
+ if (pCol)
{
- ScTokenPtrMap* pCol = aColIter->second;
- ScTokenPtrMap::iterator tokenIter = pCol->begin();
+ pToken = static_cast<FormulaToken*>(pCol->First());
for (SCROW nRow = 0; nRow < nAllRowCount; ++nRow)
{
- FormulaToken* pToken = static_cast<FormulaToken*>(tokenIter->second);
if( nCol < nHeaderColCount )
{
if( nRow < nHeaderRowCount )
@@ -387,10 +380,11 @@ Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
maColHeaders.push_back(pToken);
else
maData.push_back(pToken);
- ++tokenIter;
+
+ pToken = static_cast<FormulaToken*>(pCol->Next());
}
- ++aColIter;
}
+ pCol = static_cast<Table*>(rCols.Next());
}
}
@@ -721,7 +715,10 @@ void Chart2Positioner::createPositionMap()
glueState();
bool bNoGlue = (meGlue == GLUETYPE_NONE);
- auto_ptr<ChartTokenMap> pCols(new ChartTokenMap);
+ SAL_WNODEPRECATED_DECLARATIONS_PUSH
+ auto_ptr<Table> pCols(new Table);
+ SAL_WNODEPRECATED_DECLARATIONS_POP
+ Table* pCol = NULL;
SCROW nNoGlueRow = 0;
for (vector<ScTokenRef>::const_iterator itr = mrRefTokens.begin(), itrEnd = mrRefTokens.end();
itr != itrEnd; ++itr)
@@ -751,15 +748,12 @@ void Chart2Positioner::createPositionMap()
for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol, ++nInsCol)
{
- ScTokenPtrMap* pCol = NULL;
- ChartTokenMap::iterator it = pCols->find( nInsCol );
- if ( it == pCols->end() )
+ pCol = static_cast<Table*>(pCols->Get(nInsCol));
+ if (!pCol)
{
- pCol = new ScTokenPtrMap;
- (*pCols)[nInsCol] = pCol;
+ pCol = new Table;
+ pCols->Insert(nInsCol, pCol);
}
- else
- pCol = it->second;
sal_uInt32 nInsRow = static_cast<sal_uInt32>(bNoGlue ? nNoGlueRow : nRow1);
for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow, ++nInsRow)
@@ -774,12 +768,12 @@ void Chart2Positioner::createPositionMap()
aCellData.nRow = nRow;
aCellData.nTab = nTab;
- if ( pCol->find(nInsRow) == pCol->end() )
+ if (pCol->Get(nInsRow) == NULL)
{
if (bExternal)
- (*pCol)[nInsRow] = new ScExternalSingleRefToken(nFileId, aTabName, aCellData);
+ pCol->Insert(nInsRow, new ScExternalSingleRefToken(nFileId, aTabName, aCellData));
else
- (*pCol)[nInsRow] = new ScSingleRefToken(aCellData);
+ pCol->Insert(nInsRow, new ScSingleRefToken(aCellData));
}
}
}
@@ -790,28 +784,29 @@ void Chart2Positioner::createPositionMap()
bool bFillRowHeader = mbRowHeaders;
bool bFillColumnHeader = mbColHeaders;
- SCSIZE nAllColCount = static_cast<SCSIZE>(pCols->size());
+ SCSIZE nAllColCount = static_cast<SCSIZE>(pCols->Count());
SCSIZE nAllRowCount = 0;
- if ( !pCols->empty() )
+ pCol = static_cast<Table*>(pCols->First());
+ if (pCol)
{
- nAllRowCount = static_cast<SCSIZE>(pCols->begin()->second->size());
if (mbDummyUpperLeft)
- (*pCols)[ 0 ] = NULL; // Dummy fuer Beschriftung
+ pCol->Insert(0, NULL); // Dummy fuer Beschriftung
+ nAllRowCount = static_cast<SCSIZE>(pCol->Count());
}
if( nAllColCount!=0 && nAllRowCount!=0 )
{
if (bNoGlue)
{
- ScTokenPtrMap* pFirstCol = pCols->begin()->second;
- for ( ScTokenPtrMap::const_iterator it1 = pFirstCol->begin(); it1 != pFirstCol->end(); ++it1 )
+ Table* pFirstCol = static_cast<Table*>(pCols->First());
+ sal_uInt32 nCount = pFirstCol->Count();
+ pFirstCol->First();
+ for (sal_uInt32 n = 0; n < nCount; ++n, pFirstCol->Next())
{
- sal_uInt32 nKey = it1->first;
- for ( ChartTokenMap::const_iterator it2 = pCols->begin(); it2 != pCols->end(); ++it2 )
- {
- ScTokenPtrMap* pCol = it2->second;
- (*pCol)[nKey] = NULL;
- }
+ 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);
}
}
}
@@ -821,8 +816,8 @@ void Chart2Positioner::createPositionMap()
bFillRowHeader, bFillColumnHeader, *pCols, mpDoc));
// Destroy all column instances.
- for (ChartTokenMap::const_iterator it = pCols->begin(); it != pCols->end(); ++it)
- delete it->second;
+ for (pCol = static_cast<Table*>(pCols->First()); pCol; pCol = static_cast<Table*>(pCols->Next()))
+ delete pCol;
}
// ============================================================================
More information about the Libreoffice-commits
mailing list