summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorGülşah Köse <gulsah.kose@collabora.com>2024-11-14 10:44:47 +0300
committerSzymon Kłos <szymon.klos@collabora.com>2024-11-14 17:35:15 +0100
commite43c2c640ec62864f79962cc345d206c2caafffb (patch)
treef7f868cf97a3447e168673c672a83b275dfb585f /sc
parent2870bf6cacc4cde2c69e51d429c2a1dc6de57543 (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>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/data/ods/autofilter-colbutton.odsbin0 -> 9626 bytes
-rw-r--r--sc/qa/unit/subsequent_export_test2.cxx13
-rw-r--r--sc/source/filter/excel/excrecds.cxx4
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
new file mode 100644
index 000000000000..87d49ef2a4ec
--- /dev/null
+++ b/sc/qa/unit/data/ods/autofilter-colbutton.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx
index c0b17e11aeb8..a423711d91fa 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -536,6 +536,19 @@ CPPUNIT_TEST_FIXTURE(ScExportTest2, testAutofilterTop10XLSX)
assertXPath(pDoc, "//x:autoFilter/x:filterColumn/x:top10"_ostr, "val"_ostr, "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"_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 f18e9f829bbe..2350e803a24d 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 )