Description: The exemple file attached contains a macro that is executed when we press Ctrl+S (when we save the document). When executed what should happend: Sort by column 16 ASCENDING Than by column 17 DESCENDING Than by column 23 DESCENDING Than by column 20 ASCENDING Than by column 21 ASCENDING What is happend: Sort by column 16 ASCENDING Than by column 17 DESCENDING Than by column 23 DESCENDING Last 2 options are ignored. See the video, it's much easier to understand the bug. Steps to Reproduce: The exemple file attached contains a macro that is executed when we press Ctrl+S (when we save the document). When executed what should happend: Sort by column 16 ASCENDING Than by column 17 DESCENDING Than by column 23 DESCENDING Than by column 20 ASCENDING Than by column 21 ASCENDING What is happend: Sort by column 16 ASCENDING Than by column 17 DESCENDING Than by column 23 DESCENDING Last 2 options are ignored. Actual Results: The last 2 sorting criteria are ignored. Expected Results: The last 2 sorting criteria are executed. Reproducible: Always User Profile Reset: Yes Additional Info: Version: 6.4.5.2 Build ID: a726b36747cf2001e06b58ad5db1aa3a9a1872d6 CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3; Locale: ro-RO (ro_RO.UTF-8); UI-Language: en-US Calc: threaded
Created attachment 163706 [details] video showing the bug
Created attachment 163707 [details] the file with the problem described
Code in MACRO that is executed: REM ***** BASIC ***** Sub Main End Sub sub Macro1 rem ---------------------------------------------------------------------- rem define variables dim document as object dim dispatcher as object rem ---------------------------------------------------------------------- rem get access to the document document = ThisComponent.CurrentController.Frame dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") rem ---------------------------------------------------------------------- dim args1(0) as new com.sun.star.beans.PropertyValue args1(0).Name = "DbName" args1(0).Value = "bd" dispatcher.executeDispatch(document, ".uno:SelectDB", "", 0, args1()) rem ---------------------------------------------------------------------- dim args2(17) as new com.sun.star.beans.PropertyValue args2(0).Name = "ByRows" args2(0).Value = true args2(1).Name = "HasHeader" args2(1).Value = true args2(2).Name = "CaseSensitive" args2(2).Value = false args2(3).Name = "NaturalSort" args2(3).Value = false args2(4).Name = "IncludeAttribs" args2(4).Value = true args2(5).Name = "UserDefIndex" args2(5).Value = 0 args2(6).Name = "Col1" args2(6).Value = 16 args2(7).Name = "Ascending1" args2(7).Value = true args2(8).Name = "Col2" args2(8).Value = 17 args2(9).Name = "Ascending2" args2(9).Value = false args2(10).Name = "Col3" args2(10).Value = 23 args2(11).Name = "Ascending3" args2(11).Value = false args2(12).Name = "Col4" args2(12).Value = 20 args2(13).Name = "Ascending4" args2(13).Value = true args2(14).Name = "Col5" args2(14).Value = 21 args2(15).Name = "Ascending5" args2(15).Value = true args2(16).Name = "IncludeComments" args2(16).Value = false args2(17).Name = "IncludeImages" args2(17).Value = true dispatcher.executeDispatch(document, ".uno:DataSort", "", 0, args2()) end sub Sub Macro2 End Sub
Confirming using Version: 7.1.0.0.alpha0+ (x64) Build ID: b18c44e7e467ab872dc6283d558c57d91ead45cb CPU threads: 12; OS: Windows 10.0 Build 18363; UI render: Skia/Raster; VCL: win Locale: ru-RU (ru_RU); UI: en-US Calc: CL. Code pointer: ScCellShell::ExecuteDB (case SID_SORT) in sc/source/ui/view/cellsh2.cxx. The API case only considers three keys (aSortParam.maKeyState[0 to 2]).
If I go to sort, I can use 5 criteria for sorting. How can be MACRO forced to use 5 criteria like in manual sort?
See also SfxVoidItem DataSort SID_SORT in sc/sdi/scalc.sdi, where only 14 parameters are defined, with keys limited to Col1 - Col3.
Tested also in Version: 7.2.0.0.alpha0+ Build ID: 5adc93a9a9426ef79054751be2904896f787a8a2 CPU threads: 4; OS: Linux 5.8; UI render: default; VCL: gtk3 Locale: ro-RO (ro_RO.UTF-8); UI: en-US Calc: threaded Not working.
The fix of bug 90296 did not fix this bug.
The fix of bug 105301 did not fix this bug. Previously, I had the wrong bug number.
If you want to sort for more than 3 columns, you may use these approaches: https://ask.libreoffice.org/en/question/111683/macro-sort-only-allows-3-criteria/ or https://ask.libreoffice.org/en/question/111683/macro-sort-only-allows-3-criteria/. Is there a possibilty in SfxVoidItem DataSort SID_SORT in sc/sdi/scalc.sdi to change the api to a dynamic number of columns?
Retested. Also in Version: 24.2.0.3 (X86_64) / LibreOffice Community Build ID: da48488a73ddd66ea24cf16bbc4f7b9c08e9bea1 CPU threads: 4; OS: Linux 6.5; UI render: default; VCL: gtk3 Locale: ro-RO (ro_RO.UTF-8); UI: en-US Calc: threaded