Bug 149531 - Excel Visual Basic compatibility issue in LibreOffice Calc: .Delete
Summary: Excel Visual Basic compatibility issue in LibreOffice Calc: .Delete
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.0.7.3 release
Hardware: All All
: medium normal
Assignee: Eike Rathke
URL:
Whiteboard: target:7.5.0 target:7.4.0.0.beta2 tar...
Keywords: bibisected, bisected, regression
Depends on:
Blocks: Macro-VBA
  Show dependency treegraph
 
Reported: 2022-06-12 10:24 UTC by Óvári
Modified: 2022-06-15 06:28 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
CellsDelete.xls which crashes (44.50 KB, application/vnd.ms-excel)
2022-06-12 11:12 UTC, Óvári
Details
CellsDelete2.xls does not crash as .Cells.Delete line commented out (44.50 KB, application/vnd.ms-excel)
2022-06-12 11:18 UTC, Óvári
Details
CellsDelete3.xls does not crash as .ColumnWidth lines are commented out (32.00 KB, application/vnd.ms-excel)
2022-06-12 11:19 UTC, Óvári
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Óvári 2022-06-12 10:24:39 UTC
Description:
VBA .ColumnWidth crashes LibreOffice Calc

Steps to Reproduce:
VBA code with ColumnWidth crashes LibreOffice Calc 7.4.3.2

Sheets(1).Columns(1).ColumnWidth = 13

Actual Results:
Crashes LibreOffice Calc

Expected Results:
Update the column width in a LibreOffice Calc spreadsheet without crashing.


Reproducible: Always


User Profile Reset: No



Additional Info:
Above code in steps to reproduce modified from Statement.xls attachment in bug 149325.

Thank you
Comment 1 Óvári 2022-06-12 10:45:55 UTC
Sorry, ColumnWidth does work. It was the previous lines' code that doesn't work, i.e.

.Cells.Delete

Closing this issue
Comment 2 Óvári 2022-06-12 11:12:07 UTC
Created attachment 180685 [details]
CellsDelete.xls which crashes

1. Open attachment in LibreOffice Calc.
2. Click on "ColumnWidth" button in Sheet1.
3. LibreOffice Calc show a MsgBox with the text:
Here I am! Next line crashes with LibreOffice Calc!
4. Click "OK"
5. Crash

There is no crash is the following line is removed:
.Cells.Delete

Likewise there is no crash if .Cells.Delete remains and the .ColumnWidth lines are removed

Are you able to reproduce this strange behavior?

Thank you
Comment 3 Óvári 2022-06-12 11:18:08 UTC
Created attachment 180686 [details]
CellsDelete2.xls does not crash as .Cells.Delete line commented out

Only change from CellsDelete.xls is an apostrophe (') to comment out:
.Cells.Delete

With this change LibreOffice Calc does not crash.

Thank you
Comment 4 Óvári 2022-06-12 11:19:41 UTC
Created attachment 180687 [details]
CellsDelete3.xls does not crash as .ColumnWidth lines are commented out

Only change from CellsDelete.xls are apostrophes (') to comment out lines with:
.ColumnWidth

With this change LibreOffice Calc does not crash.

Thank you
Comment 5 Óvári 2022-06-12 11:28:59 UTC
Workaround which seems to work:
Replace the line
.Cells.Delete
with
.Cells.Clear

Seems to delete the contents and also clears the formatting.
Comment 6 raal 2022-06-12 20:39:14 UTC
Confirm crash with Version: 7.4.0.0.alpha1+ / LibreOffice Community
Build ID: d4123356c61db269651e950a0a2cc93e6d801c90
CPU threads: 4; OS: Linux 5.13; UI render: default; VCL: x11
Locale: cs-CZ (cs_CZ.UTF-8); UI: en-US
Calc: threaded Jumbo

no crash in Version 4.1.0.0.alpha0+ (Build ID: efca6f15609322f62a35619619a6d5fe5c9bd5a)
Comment 7 raal 2022-06-12 21:02:54 UTC
This seems to have begun at the below commit.
Adding Cc: to Eike Rathke; Could you possibly take a look at this one?
Thanks
 8484b5fb178bca2a8e569694b9896665a6b27ede is the first bad commit
commit 8484b5fb178bca2a8e569694b9896665a6b27ede
Author: Jenkins Build User <tdf@pollux.tdf>
Date:   Tue Jun 27 17:11:16 2017 +0200

    source a962f1465a8db9b6c4dfdfd8fef9141f07d7fd06
https://git.libreoffice.org/core/+/a962f1465a8db9b6c4dfdfd8fef9141f07d7fd06
Comment 8 Eike Rathke 2022-06-13 10:14:03 UTC
Don't know why or how that ever worked..
sc/source/ui/vba/vbarange.cxx ScVbaRange::Columns() line 2425 attempts to unconditionally access aCellRanges.front() where in this case aCellRanges is empty.
Comment 9 Commit Notification 2022-06-13 17:25:26 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/3ad12672e924f7aef394119f9fe5f0b06a900b9e

Resolves: tdf#149531 Use initial sheet range for VBA Columns and Rows

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2022-06-13 23:20:16 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

https://git.libreoffice.org/core/commit/e6294617b93a8d763d9355c5ce517428dea38e09

Resolves: tdf#149531 Use initial sheet range for VBA Columns and Rows

It will be available in 7.4.0.0.beta2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Xisco Faulí 2022-06-14 09:20:37 UTC
Issue verified in

Version: 7.4.0.0.beta1+ / LibreOffice Community
Build ID: fe3be12afd810e17427601178b5d186364bef8de
CPU threads: 8; OS: Linux 5.10; UI render: default; VCL: x11
Locale: es-ES (es_ES.UTF-8); UI: en-US
Calc: threaded

@Eike, thanks for fixing this issue. Should it be closed as RESOLVED FIXED ?
Comment 12 Commit Notification 2022-06-14 09:22:00 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/e463c3d6e1e657a2a281f3cf0ae1dc01bdc25c5b

tdf#149531 tdf#149325 Eliminate unconditional ScRangeList::front() access

It will be available in 7.3.5.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 13 Óvári 2022-06-14 21:43:51 UTC
Thank you
Comment 14 Commit Notification 2022-06-15 06:28:56 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/4b97420c5bc72504cfbf793aaa7837ebe812399a

tdf#149325, tdf#149531: sc_macros_test: Add unittest

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.