basic/qa/basic_coverage/test_With.bas | 15 +++++++++++++++ basic/source/comp/loops.cxx | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-)
New commits: commit 47a348bb0fd6dfdd93c1975d216daadc4f6b9b6f Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Fri Sep 13 03:50:24 2024 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Fri Sep 13 01:55:07 2024 +0200 tdf#162935: use PUTC for WITH variable assignment: it doesn't copy value SbiRuntime::StepPUT, SbiRuntime::StepSET, SbiRuntime::StepVBASET call checkUnoStructCopy eventually, which copies the UNO struct by value. This is not what we need. On the other hand, SbiRuntime::StepPUTC only makes the by-ref assignment, and makes the reference const; but Basic code never assigns anything to the internal variable itself, only to its members. I hope that this time, I get it right. Change-Id: I2b4a51a2dca9e7106e14e03360ef0d5a50b60079 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173305 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/basic/qa/basic_coverage/test_With.bas b/basic/qa/basic_coverage/test_With.bas index b7bf439a01a4..39d480e96618 100644 --- a/basic/qa/basic_coverage/test_With.bas +++ b/basic/qa/basic_coverage/test_With.bas @@ -54,6 +54,21 @@ Sub test_with fields = "n = " & foo_var.n & " s = " & foo_var.s TestUtil.AssertEqual(fields, "n = 6 s = baz", "Field values of foo_var") + ' tdf#162935: Test an UNO struct - it used to copy into the With variable, not used by ref + Dim uno_struct As New com.sun.star.table.CellRangeAddress + With uno_struct + .Sheet = 1 + .StartColumn = 2 + .StartRow = 3 + .EndColumn = 4 + .EndRow = 5 + End With + TestUtil.AssertEqual(uno_struct.Sheet, 1, "uno_struct.Sheet") + TestUtil.AssertEqual(uno_struct.StartColumn, 2, "uno_struct.StartColumn") + TestUtil.AssertEqual(uno_struct.StartRow, 3, "uno_struct.StartRow") + TestUtil.AssertEqual(uno_struct.EndColumn, 4, "uno_struct.EndColumn") + TestUtil.AssertEqual(uno_struct.EndRow, 5, "uno_struct.EndRow") + Exit Sub errorHandler: TestUtil.ReportErrorHandler("test_with", Err, Error$, Erl) diff --git a/basic/source/comp/loops.cxx b/basic/source/comp/loops.cxx index bab033c49608..8fafec7310d7 100644 --- a/basic/source/comp/loops.cxx +++ b/basic/source/comp/loops.cxx @@ -321,7 +321,7 @@ void SbiParser::With() SbiExpression aWithParent(this, *pWithParentDef); aWithParent.Gen(); aVar.Gen(); - aGen.Gen(SbiOpcode::SET_); + aGen.Gen(SbiOpcode::PUTC_); OpenBlock(NIL, aWithParent.GetExprNode()); StmntBlock( ENDWITH ); @@ -340,7 +340,7 @@ void SbiParser::With() } aWithParent.Gen(); SbiExpression(this, *pNothingDef).Gen(); - aGen.Gen(SbiOpcode::SET_); + aGen.Gen(SbiOpcode::PUTC_); } // LOOP/NEXT/WEND without construct