summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluigiiucci <luigi.iucci@collabora.com>2023-05-17 11:02:37 +0200
committerAron Budea <aron.budea@collabora.com>2023-07-06 23:26:52 +0200
commit689a2e36ebcb7f2184210dcd0abee10cd9fac7d3 (patch)
tree87486111574d2228cee286ac0f558a6f3515a033
parentc7c41372a5fe0743042a3664ec52fe2d41c39244 (diff)
Header columns can disappear with filtered data in pivot tables
When we set on a pivot table a filter that filters all the rows, the pivot table showed only the first header columns and computed column, but all the columns headers should still be shown so we can adjust the filter for the column. This fixes this issue. Also add more debug output and prevent a crash when running pivot table tests. Change-Id: I30b4ee72cf8436c4522ab4ba0781462b214816dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151871 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 3551d18404cb19cdaa8edb170a549f5c5405d0cb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153686 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> (cherry picked from commit 3a51b402f243eb32b544c16813f682617d88c0b9)
-rw-r--r--sc/qa/unit/helper/qahelper.cxx38
-rw-r--r--sc/source/core/data/dpoutput.cxx6
2 files changed, 43 insertions, 1 deletions
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index c1d42a2a1a6a..b5785b4fa510 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -42,6 +42,7 @@
#include <scitems.hxx>
#include <stringutil.hxx>
#include <tokenarray.hxx>
+#include <o3tl/safeint.hxx>
#include <orcus/csv_parser.hpp>
@@ -523,6 +524,43 @@ bool checkOutput(
svl::GridPrinter printer(e.Row() - s.Row() + 1, e.Col() - s.Col() + 1, CALC_DEBUG_OUTPUT != 0);
SCROW nOutRowSize = e.Row() - s.Row() + 1;
SCCOL nOutColSize = e.Col() - s.Col() + 1;
+
+ // Check if expected size iz smaller than actual size (and prevent a crash)
+ if (aCheck.size() < o3tl::make_unsigned(nOutRowSize) || aCheck[0].size() < o3tl::make_unsigned(nOutColSize))
+ {
+ // Dump the arrays to console, so we can compare
+ std::cout << "Expected data:" << std::endl;
+ for (size_t nRow = 0; nRow < aCheck.size(); ++nRow)
+ {
+ for (size_t nCol = 0; nCol < aCheck[nRow].size(); ++nCol)
+ {
+ const char* p = aCheck[nRow][nCol];
+ if (p)
+ {
+ OUString aCheckVal = OUString::createFromAscii(p);
+ std::cout << "'" << aCheckVal << "', ";
+ }
+ else
+ std::cout << "null, ";
+ }
+ std::cout << std::endl;
+ }
+
+ std::cout << "Actual data:" << std::endl;
+ for (SCROW nRow = 0; nRow < nOutRowSize; ++nRow)
+ {
+ for (SCCOL nCol = 0; nCol < nOutColSize; ++nCol)
+ {
+ OUString aVal = pDoc->GetString(nCol + s.Col(), nRow + s.Row(), s.Tab());
+ std::cout << "'" << aVal << "', ";
+ }
+ std::cout << std::endl;
+ }
+ std::cout << std::endl;
+
+ return false;
+ }
+
for (SCROW nRow = 0; nRow < nOutRowSize; ++nRow)
{
for (SCCOL nCol = 0; nCol < nOutColSize; ++nCol)
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index aedbea61a044..11a69b427146 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -600,7 +600,11 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
case sheet::DataPilotFieldOrientation_ROW:
{
uno::Sequence<sheet::MemberResult> aResult = xLevRes->getResults();
- if (!lcl_MemberEmpty(aResult))
+ // We want only to remove the DATA column if it is empty
+ // and not any other empty columns (to still show the
+ // header columns)
+ bool bSkip = lcl_MemberEmpty(aResult) && bIsDataLayout;
+ if (!bSkip)
{
ScDPOutLevelData tmp(nDim, nHierarchy, nLev, nDimPos, nNumFmt, aResult, aName,
aCaption, bHasHiddenMember, bIsDataLayout, false);