summaryrefslogtreecommitdiffstats
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-05 01:23:40 +0200
commit3a51b402f243eb32b544c16813f682617d88c0b9 (patch)
treef298deb010c82490db9db27db1a0debcf3ea832d
parentproblem pasting to calc an image copied from firefox (windows) (diff)
downloadcore-3a51b402f243eb32b544c16813f682617d88c0b9.tar.gz
core-3a51b402f243eb32b544c16813f682617d88c0b9.zip
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>
-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 9a5c5124cb08..99a8492ce87d 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -43,6 +43,7 @@
#include <scitems.hxx>
#include <stringutil.hxx>
#include <tokenarray.hxx>
+#include <o3tl/safeint.hxx>
#include <orcus/csv_parser.hpp>
@@ -527,6 +528,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 bf2109b300a3..b8565852d511 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);