Kaydet (Commit) 5d88cb48 authored tarafından Winfried Donkers's avatar Winfried Donkers Kaydeden (comit) Eike Rathke

unify code duplication in ScInterpreter::ScSum and IterateParameters

The code in ScSum is mostly identical with that in IterateParameters.
Worse, functions like SUBTOTAL and AGGREGATE use IterateParameters for
the SUM function.
Now we have one set of code for all SUM-functions and averted the danger of
diverting pieces of code which are supposed to do the same thing.

Removed old-style bNull-method too.

Change-Id: Ia4f22c21c4b3c3a244ea1cd10c30d8cfcaa8ef6c
Reviewed-on: https://gerrit.libreoffice.org/15362Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: 's avatarEike Rathke <erack@redhat.com>
üst dacdb66f
...@@ -84,6 +84,7 @@ public: ...@@ -84,6 +84,7 @@ public:
virtual ~ColumnAction() = 0; virtual ~ColumnAction() = 0;
virtual void startColumn(ScColumn* pCol) = 0; virtual void startColumn(ScColumn* pCol) = 0;
virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal) = 0; virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal) = 0;
virtual void executeSum(SCROW, SCROW, bool, double& ) { return; } ;
}; };
ColumnSpanSet(bool bInit); ColumnSpanSet(bool bInit);
...@@ -103,6 +104,7 @@ public: ...@@ -103,6 +104,7 @@ public:
void executeAction(Action& ac) const; void executeAction(Action& ac) const;
void executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const; void executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const;
void executeColumnAction(ScDocument& rDoc, ColumnAction& ac, double& fMem) const;
void swap( ColumnSpanSet& r ); void swap( ColumnSpanSet& r );
}; };
......
...@@ -227,6 +227,49 @@ void ColumnSpanSet::executeColumnAction(ScDocument& rDoc, ColumnAction& ac) cons ...@@ -227,6 +227,49 @@ void ColumnSpanSet::executeColumnAction(ScDocument& rDoc, ColumnAction& ac) cons
} }
} }
void ColumnSpanSet::executeColumnAction(ScDocument& rDoc, ColumnAction& ac, double& fMem) const
{
for (size_t nTab = 0; nTab < maDoc.size(); ++nTab)
{
if (!maDoc[nTab])
continue;
const TableType& rTab = *maDoc[nTab];
for (size_t nCol = 0; nCol < rTab.size(); ++nCol)
{
if (!rTab[nCol])
continue;
ScTable* pTab = rDoc.FetchTable(nTab);
if (!pTab)
continue;
if (!ValidCol(nCol))
{
// End the loop.
nCol = rTab.size();
continue;
}
ScColumn& rColumn = pTab->aCol[nCol];
ac.startColumn(&rColumn);
ColumnType& rCol = *rTab[nCol];
ColumnSpansType::const_iterator it = rCol.maSpans.begin(), itEnd = rCol.maSpans.end();
SCROW nRow1, nRow2;
nRow1 = it->first;
bool bVal = it->second;
for (++it; it != itEnd; ++it)
{
nRow2 = it->first-1;
ac.executeSum( nRow1, nRow2, bVal, fMem );
nRow1 = nRow2+1; // for the next iteration.
bVal = it->second;
}
}
}
}
void ColumnSpanSet::swap( ColumnSpanSet& r ) void ColumnSpanSet::swap( ColumnSpanSet& r )
{ {
maDoc.swap(r.maDoc); maDoc.swap(r.maDoc);
......
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