Bug 169610 - Data Provider Sort Columns Transformation not saved to file
Summary: Data Provider Sort Columns Transformation not saved to file
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
26.2.0.0 alpha0+ master
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on: 165619 169568 169570 169572 169596 169612 169615
Blocks: Data-Provider 169581 169608 169609
  Show dependency treegraph
 
Reported: 2025-11-22 10:00 UTC by Michael Otto
Modified: 2025-11-23 14:18 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Data Provider added Transformation Sort Columns (10.92 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-11-22 10:00 UTC, Michael Otto
Details
ordering Sort Columns + Delete Column screen shot (58.47 KB, image/png)
2025-11-23 11:12 UTC, Michael Otto
Details
ordering Sort Columns + Delete Column ods (11.27 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-11-23 11:12 UTC, Michael Otto
Details
ordering Delete Column + Sort Columns screen shot (58.47 KB, image/png)
2025-11-23 11:14 UTC, Michael Otto
Details
ordering Delete Column + Sort Columns ods (11.28 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-11-23 11:14 UTC, Michael Otto
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Otto 2025-11-22 10:00:57 UTC
Created attachment 204199 [details]
Data Provider added Transformation Sort Columns

+++ This bug was initially created as a clone of Bug #169596 +++

PRECONDITION:
new Calc spreadsheet
Data > Define Range 
= e.g. DataRangeForDataProvider.ods from #169514:
https://bugs.documentfoundation.org/attachment.cgi?id=204066

Data > Data Provider
select DBrange, CSV, URL 5x3numbersN.csv from #169570
https://bugs.documentfoundation.org/attachment.cgi?id=204142


PROBLEM DESCRIPTION:
Data Provider Transformations: Sort Columns [Add]
Parameters: Ascending Order, Column in... 9;10
save Calc file --> attached DataProvider-Transformation-SortColumns.ods

transformation is not saved in the file
this means that Data > Refresh Data Provider does not fill the expected data

no data-transformations in content.xml:
<calcext:data-mappings>
<calcext:data-mapping xlink:href="file:///home/micha/LibreOffice/bugreports/5x3numbersN.csv" calcext:provider="org.libreoffice.calc.csv" calcext:frequency="0" calcext:id="org.libreoffice.calc.csv" calcext:database-name="DBrange">
<calcext:data-transformations/>
</calcext:data-mapping>
</calcext:data-mappings>


EXPECTED BEHAVIOR:
transformation Sort Columns shall be saved to content.xml


Version: 26.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 480ef73deef62c458e5735cd496a1d74ef408ed8
CPU threads: 2; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: de-DE (de_DE.UTF-8); UI: en-US
Calc: threaded
Comment 1 Regina Henschel 2025-11-22 15:58:33 UTC
I confirm that it is not written to file. Tested with Version: 26.2.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: f8224b9625c26a7c92a289573765d4a201678d68
CPU threads: 32; OS: Windows 11 X86_64 (build 26100); UI render: Skia/Vulkan; VCL: win
Locale: en-US (de_DE); UI: en-US
Calc: threaded

I wonder what happens here, because ScXMLExport::WriteExternalDataTransformations has a case sc::TransformationType::SORT_TRANSFORMATION
Comment 2 Regina Henschel 2025-11-22 16:25:08 UTC
(In reply to Regina Henschel from comment #1)
> I wonder what happens here, because
> ScXMLExport::WriteExternalDataTransformations has a case
> sc::TransformationType::SORT_TRANSFORMATION

The implementation has
    const sc::DocumentLinkManager& rMgr = rDoc.GetDocLinkManager();
    const sc::DataStream* pStrm = rMgr.getDataStream();
    if (!pStrm)
        // No data stream.
        return;

pStrm is nullptr here.

This part is different from the other cases.
Comment 3 Michael Otto 2025-11-23 11:11:14 UTC
according to Regina's Comment
https://bugs.documentfoundation.org/show_bug.cgi?id=169596#c4
the implementation of the export to ODF is NOT missing for SORT_TRANSFORMATION

this case has a further impact:
all transformations behind the SORT_TRANSFORMATION are not saved as well
-->presumably the SORT_TRANSFORMATION aborts all further save processing


see below two combined tests: Sort Columns + Delete Column and vv.
same PRECONDITION as in bugreport Description

A)
ordering Sort Columns + Delete Column:
Data Provider Transformations: Sort Columns [Add]
Parameters: Ascending Order, Column in... 2;3
Data Provider Transformations: Delete Column [Add]
Parameters: Cols 7
save Calc file --> attached DataProvider-Transformation-‍‍Sort+DeleteCol.ods
content.xml:
<calcext:data-transformations/>

B)
reverse order: Delete Column + Sort Columns
Data Provider Transformations: Delete Column [Add]
Parameters: Cols 7
Data Provider Transformations: Sort Columns [Add]
Parameters: Ascending Order, Column in... 2;3
save Calc file --> attached DataProvider-Transformation-‍‍Delete+SortCol.ods
content.xml:
<calcext:data-transformations>
<calcext:column-remove-transformation>
<calcext:column calcext:column="6"/>
</calcext:column-remove-transformation>
</calcext:data-transformations>


checked as well with further otherwise saved transformations (Aggregate 
Functions, Numeric, Replace Null, Date and Time) after Sort Column: 
transformations after the Sort Column transformation are NOT saved.
Comment 4 Michael Otto 2025-11-23 11:12:21 UTC
Created attachment 204223 [details]
ordering Sort Columns + Delete Column screen shot
Comment 5 Michael Otto 2025-11-23 11:12:53 UTC
Created attachment 204224 [details]
ordering Sort Columns + Delete Column ods
Comment 6 Michael Otto 2025-11-23 11:14:24 UTC
Created attachment 204225 [details]
ordering Delete Column + Sort Columns screen shot
Comment 7 Michael Otto 2025-11-23 11:14:52 UTC
Created attachment 204226 [details]
ordering Delete Column + Sort Columns ods
Comment 8 Michael Otto 2025-11-23 12:34:20 UTC
one more hint:
the processing of save Sort Columns transformation does not inhibit saving 
of ALL transformations for this file but only the transformations BEHIND 
the Sort Columns. This can be seen in the example of #169596
Comment 9 Regina Henschel 2025-11-23 14:18:38 UTC
I can replace the not working part mentioned in comment 2 with a part that uses the range from aSortParam. That would be
    ScRange aRange(aSortParam.nCol1, aSortParam.nRow1, aSortParam.nSourceTab,
                   aSortParam.nCol2, aSortParam.nRow2, aSortParam.nSourceTab);
Then the transformation is written to file.

But that does not really help. The corresponding import is not implemented, see the commented-out part in  https://opengrok.libreoffice.org/xref/core/sc/source/filter/xml/xmltransformationi.hxx?r=24552a0b5be620b5e58b10842cba78e36fa26b04#73

The not available sort transformation export stops the further export of transformations because it uses "return" instead of "continue". I do not see this as an error, because the transformations are applied in the given order and if the sort transformation is missing, further transformations would work on a different basis than with sort transformation.

Perhaps we should hide the sort transformation in the drop-down list in the dialog until the problems with the sort transformation are solved?