summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-04-04 20:37:04 +0200
committerMichael Stahl <mstahl@redhat.com>2012-04-04 20:41:08 +0200
commit61af0e1c3c1c9003c741d64840f9b6f39ea87ead (patch)
tree8f7eb01e1d90d8cc9bb49c951770c4e7630b2a6d /sc
parenta64475a0ac7f9be2e599e0b2bbc643fcb55a4c1f (diff)
ScDBDocFunc::Sort: work around STL assertion in sc_unoapi
from dbdocfun.cxx:588: error: attempt to subscript container with out-of-bounds index 0, but container only holds 0 elements. The code in sortparam.cxx still looks quite wrong, and in table3.cxx there are various arrays hard-coded to size 3... (regression from a02b445c39d969fedc554fc2c500b88a27a13906)
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/sortparam.cxx40
-rw-r--r--sc/source/ui/docshell/dbdocfun.cxx5
2 files changed, 18 insertions, 27 deletions
diff --git a/sc/source/core/data/sortparam.cxx b/sc/source/core/data/sortparam.cxx
index 069e410ac219..21bf327bfaf8 100644
--- a/sc/source/core/data/sortparam.cxx
+++ b/sc/source/core/data/sortparam.cxx
@@ -175,8 +175,6 @@ ScSortParam::ScSortParam( const ScSubTotalParam& rSub, const ScSortParam& rOld )
aCollatorLocale( rOld.aCollatorLocale ), aCollatorAlgorithm( rOld.aCollatorAlgorithm ),
nCompatHeader( rOld.nCompatHeader )
{
- sal_uInt16 nNewCount = 0;
- sal_uInt16 nSortSize = GetSortKeyCount();
sal_uInt16 i;
// zuerst die Gruppen aus den Teilergebnissen
@@ -184,42 +182,34 @@ ScSortParam::ScSortParam( const ScSubTotalParam& rSub, const ScSortParam& rOld )
for (i=0; i<MAXSUBTOTAL; i++)
if (rSub.bGroupActive[i])
{
- if (nNewCount < nSortSize)
- {
- maKeyState[nNewCount].bDoSort = true;
- maKeyState[nNewCount].nField = rSub.nField[i];
- maKeyState[nNewCount].bAscending = rSub.bAscending;
- ++nNewCount;
- }
+#if 0
+// FIXME this crashes in sc_unoapi currently; table3.cxx has nMaxSorts = 3...
+ ScSortKeyState key;
+ key.bDoSort = true;
+ key.nField = rSub.nField[i];
+ key.bAscending = rSub.bAscending;
+ maKeyState.push_back(key);
+#endif
}
// dann dahinter die alten Einstellungen
- for (i=0; i<nSortSize; i++)
+ for (i=0; i < rOld.GetSortKeyCount(); i++)
if (rOld.maKeyState[i].bDoSort)
{
SCCOLROW nThisField = rOld.maKeyState[i].nField;
bool bDouble = false;
- for (sal_uInt16 j=0; j<nNewCount; j++)
+ for (sal_uInt16 j = 0; j < GetSortKeyCount(); j++)
if ( maKeyState[j].nField == nThisField )
bDouble = true;
if (!bDouble) // ein Feld nicht zweimal eintragen
{
- if (nNewCount < nSortSize)
- {
- maKeyState[nNewCount].bDoSort = true;
- maKeyState[nNewCount].nField = nThisField;
- maKeyState[nNewCount].bAscending = rOld.maKeyState[i].bAscending;
- ++nNewCount;
- }
+ ScSortKeyState key;
+ key.bDoSort = true;
+ key.nField = nThisField;
+ key.bAscending = rOld.maKeyState[i].bAscending;
+ maKeyState.push_back(key);
}
}
-
- for (i=nNewCount; i<nSortSize; i++) // Rest loeschen
- {
- maKeyState[nNewCount].bDoSort = false;
- maKeyState[nNewCount].nField = 0;
- maKeyState[nNewCount].bAscending = true;
- }
}
//------------------------------------------------------------------------
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index a54f906c1829..c315147419da 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -585,7 +585,7 @@ sal_Bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
}
// don't call ScDocument::Sort with an empty SortParam (may be empty here if bCopy is set)
- if ( aLocalParam.maKeyState[0].bDoSort )
+ if (aLocalParam.GetSortKeyCount() && aLocalParam.maKeyState[0].bDoSort)
pDoc->Sort( nTab, aLocalParam, bRepeatQuery );
sal_Bool bSave = sal_True;
@@ -593,7 +593,8 @@ sal_Bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
{
ScSortParam aOldSortParam;
pDBData->GetSortParam( aOldSortParam );
- if ( aOldSortParam.maKeyState[0].bDoSort && aOldSortParam.bInplace ) // Inplace-Sortierung gemerkt?
+ if (aOldSortParam.GetSortKeyCount() &&
+ aOldSortParam.maKeyState[0].bDoSort && aOldSortParam.bInplace)
{
bSave = false;
aOldSortParam.nDestCol = rSortParam.nDestCol;