diff options
author | Gülşah Köse <gulsah.kose@collabora.com> | 2024-11-14 10:44:47 +0300 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2024-11-19 05:38:59 +0100 |
commit | b4b3949da1aad091b9f8d0f301f9f7031d6ce295 (patch) | |
tree | bd253ddfe0c8ff3831e511e2874ea0b63cc47cd4 | |
parent | 3e9658a201f60dee95bd1bd8421b18bf8905c308 (diff) |
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.kose@collabora.com>
Change-Id: I1f94058caa23686596d57dd6983ddf02cd8f5e71
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176564
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176717
Tested-by: Jenkins
-rw-r--r-- | sc/qa/unit/data/ods/autofilter-colbutton.ods | bin | 0 -> 9626 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export_test2.cxx | 13 | ||||
-rw-r--r-- | sc/source/filter/excel/excrecds.cxx | 4 |
3 files changed, 15 insertions, 2 deletions
diff --git a/sc/qa/unit/data/ods/autofilter-colbutton.ods b/sc/qa/unit/data/ods/autofilter-colbutton.ods Binary files differnew file mode 100644 index 000000000000..87d49ef2a4ec --- /dev/null +++ b/sc/qa/unit/data/ods/autofilter-colbutton.ods diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 91ef0a47a287..decbf2ad00b2 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -522,6 +522,19 @@ CPPUNIT_TEST_FIXTURE(ScExportTest2, testAutofilterTop10XLSX) assertXPath(pDoc, "//x:autoFilter/x:filterColumn/x:top10", "val", u"4"); } +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("Calc Office Open XML"); + xmlDocUniquePtr pDoc = parseExport("xl/worksheets/sheet1.xml"); + CPPUNIT_ASSERT(pDoc); + assertXPathNoAttribute(pDoc, "//x:autoFilter/x:filterColumn", "hiddenButton"); +} + 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 afd38447d865..f9e596142473 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -995,10 +995,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 ) |