diff options
author | offtkp <parisoplop@gmail.com> | 2022-11-30 00:54:08 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-01-05 11:33:10 +0000 |
commit | 11e2dd533a6e6985ab1547630b62e772f6533946 (patch) | |
tree | 225726f31f0faa20638b04bcc9ff9137cd8ed414 /sc | |
parent | 519ead63478a66f907c477dd15dba214d2b59f90 (diff) |
xlsx: Don't add cell data to chart data sequence if in totalsRow
When importing data from a cell range to use in a chart, if a cell is in
the totalsRow it is now ignored if it's the last row in the range.
Change-Id: Ie8c79b995c4d46b361492e8f7687894e2640392f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143488
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
(cherry picked from commit ad085990b8073a122ac5222e5220f8f1d6826dcf)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144306
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/unoobj/chart2uno.cxx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 54a88b749a77..797eb39b3bf8 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2521,6 +2521,26 @@ void ScChart2DataSequence::BuildDataCache() m_pDocument->InitColumnBlockPosition( hint, nTab, nCol ); for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow) { + if (nRow == aRange.aEnd.Row()) + { + // Excel behavior: if the last row is the totals row, the data + // is not added to the chart. If it's not the last row, the data + // is added like normal. + const auto* rData = m_pDocument->GetDBAtCursor( + nCol, nRow, nTab, + ScDBDataPortion::AREA + ); + if (rData && rData->HasTotals()) + { + ScRange aTempRange; + rData->GetArea(aTempRange); + if (aTempRange.aEnd.Row() == nRow) + { + // Current row is totals row, skip + break; + } + } + } bool bColHidden = m_pDocument->ColHidden(nCol, nTab, nullptr, &nLastCol); bool bRowHidden = m_pDocument->RowHidden(nRow, nTab, nullptr, &nLastRow); |