https://bugs.documentfoundation.org/show_bug.cgi?id=174386

            Bug ID: 174386
           Summary: BASIC setArrayFormula() produces #NAME? after an
                    undo/redo cycle when formula contains LET
           Product: LibreOffice
           Version: 26.8.1.1 release
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: Calc
          Assignee: [email protected]
          Reporter: [email protected]

Description:
Using a script to enter an array formula that contains a LET produces a result
that can be undone, but cannot be redone afterward. Instead of reproducing the
expected result, it returns a #NAME? error.

The behaviour is not reproduced with a manual entry of the formula, nor with
other programmatically entered formulae that don't contain LET, but it
systematically fails with LET, even in very simple forms.

Steps to Reproduce:
1.Create a new workbook
2.Run the following BASIC script:

Sub LET_ArrayFormula_UndoRedo()
    Dim Doc As Object,oSheet As Object, Range As Object, Controller As Object

    Doc = ThisComponent
    Controller = Doc.getCurrentController()
    Sheet = Controller.getActiveSheet()
    Range = Sheet.getCellRangeByName("A1:A2")
    Controller.select(Range)

    ' Very simple LET array formula.
    Range.setArrayFormula("=LET(x;1;x)")
        ' Does not support a REDO after an UNDO
End Sub

3.Confirm that A1:A2 both contain the value 1
4.Undo: A1:A2 should return to their original blank state
5.Redo: A1:A2 now contain the same array formula that was programmatically
entered, but it returns #NAME? instead of 1.

Actual Results:
The array formula in A1:A2 is entered properly, but not recalculated as it
should.

Expected Results:
After a redo, A1:A2 should display 1 again.


Reproducible: Always


User Profile Reset: No

Additional Info:
1.If we manually enter the array formula "{=LET(x,1,x)}" in a couple of cells
(say B1:B2), commit it with Ctrl+Shift+Enter, then do a cycle of undo/redo, the
formula is properly reinstated, and B1:B2 values are equal to 1 again.
2.If we programmatically enter a more complex array formula involving HSTACK,
TRANSPOSE, ROW and COLUMN for instance, applying a cycle of undo/redo also
recalculates the values properly and doesn't result in an error. The following
BASIC script may be used to test this:

Sub Other_ArrayFormula_UndoRedo()
    Dim Doc As Object,oSheet As Object, Range As Object, Controller As Object

    Doc = ThisComponent
    Controller = Doc.getCurrentController()
    Sheet = Controller.getActiveSheet()
    Range = Sheet.getCellRangeByName("E1:F2")
    Controller.select(Range)

    ' More complex HSTACK TRANSPOSE ROW COLUMN array formula.
    Range.setArrayFormula("=HSTACK(ROW(A1:A2);TRANSPOSE(COLUMN(B4:C4)))")
    ' Supports a REDO after an UNDO
End Sub

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to