tdf#168589 - sc fix xls import with subtotal function
Check if the trimmed data range of Subtotal double references
is valid otherwise do not trim.
regression after: b89047a0f0
(tdf#164843 - sc optimize "SubTotal" function's reference ranges)
Change-Id: I5f1fa4f67a685deb4a391e19e3acd9849b03c1b4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191691
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga@collabora.com>
This commit is contained in:
Binary file not shown.
@@ -276,6 +276,15 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest5, testTdf161948_NaturalSortSaveLoad)
|
||||
CPPUNIT_ASSERT(!aSortParam.bNaturalSort);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(ScFiltersTest5, testTdf168589)
|
||||
{
|
||||
// Open xls document with Subtotal function
|
||||
createScDoc("xls/tdf168589.xls");
|
||||
ScDocument* pDoc = getScDoc();
|
||||
CPPUNIT_ASSERT(pDoc);
|
||||
ASSERT_DOUBLES_EQUAL(6.0, pDoc->GetValue(4, 5, 0));
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -6879,17 +6879,21 @@ void ScCompiler::AnnotateTrimOnDoubleRefs()
|
||||
if (pTok->GetType() == svDoubleRef)
|
||||
{
|
||||
ScComplexRefData* pRefData = pTok->GetDoubleRef();
|
||||
// no need to set pRefData->SetTrimToData(true); because we already trim here
|
||||
// do no set pRefData->SetTrimToData(true); because we need to trim here if possible
|
||||
ScRange rRange = pRefData->toAbs(rDoc, aPos);
|
||||
SCCOL nTempStartCol = rRange.aStart.Col();
|
||||
SCROW nTempStartRow = rRange.aStart.Row();
|
||||
SCCOL nTempEndCol = rRange.aEnd.Col();
|
||||
SCROW nTempEndRow = rRange.aEnd.Row();
|
||||
rDoc.ShrinkToDataArea(rRange.aStart.Tab(), nTempStartCol, nTempStartRow, nTempEndCol, nTempEndRow);
|
||||
rRange.aStart.Set(nTempStartCol, nTempStartRow, rRange.aStart.Tab());
|
||||
rRange.aEnd.Set(nTempEndCol, nTempEndRow, rRange.aEnd.Tab());
|
||||
rRange.PutInOrder();
|
||||
pRefData->SetRange(rDoc.GetSheetLimits(), rRange, aPos);
|
||||
// check if range is still valid
|
||||
if (nTempStartRow <= nTempEndRow && nTempStartCol <= nTempEndCol)
|
||||
{
|
||||
rRange.aStart.Set(nTempStartCol, nTempStartRow, rRange.aStart.Tab());
|
||||
rRange.aEnd.Set(nTempEndCol, nTempEndRow, rRange.aEnd.Tab());
|
||||
if (rRange.IsValid())
|
||||
pRefData->SetRange(rDoc.GetSheetLimits(), rRange, aPos);
|
||||
}
|
||||
}
|
||||
--ppTok;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user