sc/qa/unit/data/ods/autofilter-colbutton.ods |binary sc/qa/unit/subsequent_export_test2.cxx | 13 +++++++++++++ sc/source/filter/excel/excrecds.cxx | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-)
New commits: commit af59826d64a2e2552d4d8c41e5a319da359badac Author: Gülşah Köse <gulsah.k...@collabora.com> AuthorDate: Thu Nov 14 10:44:47 2024 +0300 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Nov 19 11:55:02 2024 +0100 tdf#162992: Fix the wrong detection of hidden autofilter button Regression caused by 2942fdc8dbda375622d0add8c36df2d6679e321a OOXML <filterColumn colId="0"> Autofilter range colID is not absolute id. It starts always with 0 even if the autofiltered range doesn't start with col 0 in the document. So we are checking the flag from document (rDoc), not from the autofiltered range. So we should use absolute column id to get right flag. Signed-off-by: Gülşah Köse <gulsah.k...@collabora.com> Change-Id: I1f94058caa23686596d57dd6983ddf02cd8f5e71 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176564 Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176717 Tested-by: Jenkins (cherry picked from commit b4b3949da1aad091b9f8d0f301f9f7031d6ce295) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176754 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/unit/data/ods/autofilter-colbutton.ods b/sc/qa/unit/data/ods/autofilter-colbutton.ods new file mode 100644 index 000000000000..87d49ef2a4ec Binary files /dev/null and b/sc/qa/unit/data/ods/autofilter-colbutton.ods differ diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 81ad2857269c..f7a8e35c0907 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -543,6 +543,19 @@ CPPUNIT_TEST_FIXTURE(ScExportTest2, testAutofilterTop10XLSX) assertXPath(pDoc, "//x:autoFilter/x:filterColumn/x:top10"_ostr, "val"_ostr, u"4"_ustr); } +CPPUNIT_TEST_FIXTURE(ScExportTest2, testAutofilterColButton) +{ + // Without fix it will fail + // - Expression: !xmlGetProp(pXmlNode, BAD_CAST(rAttribute.getStr())) + // - In <>, XPath '//x:autoFilter/x:filterColumn' unexpected 'hiddenButton' attribute + createScDoc("ods/autofilter-colbutton.ods"); + + save(u"Calc Office Open XML"_ustr); + xmlDocUniquePtr pDoc = parseExport(u"xl/worksheets/sheet1.xml"_ustr); + CPPUNIT_ASSERT(pDoc); + assertXPathNoAttribute(pDoc, "//x:autoFilter/x:filterColumn"_ostr, "hiddenButton"_ostr); +} + CPPUNIT_TEST_FIXTURE(ScExportTest2, testTdf88657ODS) { createScDoc("ods/tdf88657.ods"); diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index 381836c10c12..4e7301e3dece 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -993,10 +993,10 @@ ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const bContLoop = rEntry.bDoQuery; if( bContLoop ) { - SCCOL nCol = static_cast<SCCOL>( rEntry.nField ) - aRange.aStart.Col(); + SCCOL nCol = static_cast<SCCOL>(rEntry.nField); + XclExpAutofilter* pFilter = GetByCol( nCol - aRange.aStart.Col() ); auto nFlag = rDoc.GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG )->GetValue(); bool bIsButtonHidden = !( nFlag & ScMF::Auto ); - XclExpAutofilter* pFilter = GetByCol( nCol ); pFilter->SetButtonHidden( bIsButtonHidden ); if( nEntry > 0 )