sc/qa/unit/data/xlsx/sortconditionref2.xlsx |binary sc/qa/unit/subsequent_export_test2.cxx | 13 +++++++++++++ sc/source/filter/oox/autofilterbuffer.cxx | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-)
New commits: commit 0212a994fc6674ba314aa57ce367fd1109c497c8 Author: Gülşah Köse <[email protected]> AuthorDate: Fri Feb 7 16:05:16 2025 +0300 Commit: Gülşah Köse <[email protected]> CommitDate: Wed Feb 12 10:46:37 2025 +0100 Fix wrong detection of sortCondition reference Signed-off-by: Gülşah Köse <[email protected]> Change-Id: I877ede71f9487ba35efd7da6aeeee954560272cc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181248 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181475 diff --git a/sc/qa/unit/data/xlsx/sortconditionref2.xlsx b/sc/qa/unit/data/xlsx/sortconditionref2.xlsx new file mode 100644 index 000000000000..748e894ac0a7 Binary files /dev/null and b/sc/qa/unit/data/xlsx/sortconditionref2.xlsx differ diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 4f705abe5a7e..1396cef69fa5 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -432,6 +432,19 @@ CPPUNIT_TEST_FIXTURE(ScExportTest2, testSortConditionRef) assertXPath(pDoc, "//x:worksheet/x:autoFilter/x:sortState/x:sortCondition", "ref", u"B3:B2"); } +CPPUNIT_TEST_FIXTURE(ScExportTest2, testSortConditionRef2) +{ + // Ascending sortCondition reference detected wrong without fix. + //- Expected: A11:A300 + //- Actual : J11:J300 + //- In <>, attribute 'ref' of '//x:worksheet/x:autoFilter/x:sortState/x:sortCondition' incorrect value. + createScDoc("xlsx/sortconditionref2.xlsx"); + save(u"Calc Office Open XML"_ustr); + xmlDocUniquePtr pDoc = parseExport(u"xl/worksheets/sheet1.xml"_ustr); + + assertXPath(pDoc, "//x:worksheet/x:autoFilter/x:sortState/x:sortCondition", "ref", u"A11:A300"); +} + CPPUNIT_TEST_FIXTURE(ScExportTest2, testDateAutofilterXLSX) { // XLSX Roundtripping autofilter with date list diff --git a/sc/source/filter/oox/autofilterbuffer.cxx b/sc/source/filter/oox/autofilterbuffer.cxx index 1d7b7ffb0d70..dcf8da5fdc9d 100644 --- a/sc/source/filter/oox/autofilterbuffer.cxx +++ b/sc/source/filter/oox/autofilterbuffer.cxx @@ -846,7 +846,7 @@ void AutoFilter::finalizeImport( const Reference< XDatabaseRange >& rxDatabaseRa if (!aParam.bUserDef) return; - SCCOLROW nStartPos = aParam.bByRow ? maRange.aStart.Col() : maRange.aStart.Row(); + SCCOLROW nStartPos = aParam.bByRow ? maRange.aStart.Row() : maRange.aStart.Col(); // descending sort - need to enable 1st SortParam slot if (rSorConditionLoaded.mbDescending) assert(aParam.GetSortKeyCount() == DEFSORT);
