Bug 114038 - Range operations setting the values of previously empty cells can not be undone
Summary: Range operations setting the values of previously empty cells can not be undone
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
3.5.0 release
Hardware: All All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: preBibisect, regression
: 116850 (view as bug list)
Depends on:
Blocks: Undo-Redo
  Show dependency treegraph
 
Reported: 2017-11-24 22:54 UTC by Mátyás Jani
Modified: 2023-10-13 11:41 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
small spreadsheet demonstrating the bug (10.55 KB, application/vnd.oasis.opendocument.spreadsheet)
2017-11-24 22:54 UTC, Mátyás Jani
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mátyás Jani 2017-11-24 22:54:54 UTC
Created attachment 137971 [details]
small spreadsheet demonstrating the bug

In LibreOffice Calc BASIC macros setting the values of empty cell ranges can not be undone. The new values will remain in the previously empty cells after pressing undo.

Tested functions, undo does not work after these:
targetRange.setDataArray(valueArray)
targetRange.DataArray = sourceRange.DataArray

Steps to reproduce:
1. create a macro that sets the values in a range of empty cells using the above functions
2. execute the macro
3. press undo

Expected behaviour: the cells content will be erased after undo, restoring their original state.
Actual behaviour: the cells content does not change, the values set by the macro remains there.

See the attached .ods file.

Tested on:
Version: 5.4.3.2
Build ID: 5.4.3-2
CPU threads: 6; OS: Linux 4.13; UI render: default; VCL: kde4; 
Locale: hu-HU (hu_HU.UTF-8); Calc: group
Comment 1 Mátyás Jani 2017-11-24 23:15:33 UTC
Workaround: set the target cells of the range to empty string before applying the range operation. Do it in an undo context, to have enough undo steps to undo the whole action in one.

Something like this:

	undo = ThisComponent.UndoManager
	undo.enterUndoContext("Copy range action")
	' clear target range, undo workaround
	for row = 4 to 8
		for col = 0 to 1
			sheet.getCellByPosition(col, row).string = ""
		next col
	next row
	copyRange = sheet.getCellRangeByName("A1:B4")
	pasteRange = sheet.getCellRangeByName("A5:B8")
	pasteRange.DataArray = copyRange.DataArray
	undo.leaveUndoContext

(Note, clearing the target range with range operation will not work.)
Comment 2 Buovjaga 2017-11-26 18:45:12 UTC
Regression from 3.3, but seen already in 3.5, so not bibisectable.

Severity minor per existing workaround.

Win 10
LibreOffice 3.5.0rc3 
Build ID: 7e68ba2-a744ebf-1f241b7-c506db1-7d53735

Arch Linux 64-bit
Version: 6.0.0.0.alpha1+
Build ID: 008673c23db0c812eb0b48a1c29ab88b48aaa867
CPU threads: 8; OS: Linux 4.13; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group threaded
Built on November 23rd 2017

Arch Linux 64-bit
LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4
Comment 3 QA Administrators 2018-11-27 03:43:21 UTC Comment hidden (obsolete)
Comment 4 QA Administrators 2020-11-27 04:41:00 UTC Comment hidden (obsolete)
Comment 5 Aron Budea 2021-02-14 10:21:17 UTC
Still in LO 7.2.0.0.alpha0+ (066799b4a162aa0a4bc6aa28339f1f943a13971e).
Comment 6 QA Administrators 2023-02-15 03:20:55 UTC Comment hidden (obsolete)
Comment 7 Mike Kaganski 2023-10-13 11:41:19 UTC
*** Bug 116850 has been marked as a duplicate of this bug. ***