Page 1 of 1

oRow.isVisible causes OpenOffice to Crash

Posted: Fri Jun 01, 2018 3:29 am
by Mi7ke
Using oRow.isVisible = any boolean value causes OpenOffice to crash. See code below:
Am I using the object properties correctly? Is there a library descibing all such properties?

NOTE: I used Variants in ShowRow() since using Integer and Booleans caused other issues? Could this be a related issue?

Code: Select all

function ShowRow(row as Variant, show as Variant) as Variant

Dim oSheet as Object, oRow as Object

oSheet = ThisComponent.currentController.activeSheet
oRow   = oSheet.getRows().getByIndex(row-1)

'Problem #1
'Why does the following line (if uncommented) cause OpenOffice Calc to crash?
'oRow.isVisible = show
ShowRow = show

end function
Background: This macro is used on a speadsheet meant to be a teaching aid on division for my son.
Use of this macro seems to work in another spread sheet, but not this one. See attached.

Here's my environment:
WIndows 7
OpenOffice Calc Apache 4.1.5
AOO415m1(Build:9789) - Rev. 1817496
2017-12-11 17:25

Re: oRow.isVisible causes OpenOffice to Crash

Posted: Fri Jun 01, 2018 4:50 am
by FJCC
I confirmed the crash but I don't think it is worth trying to figure out why it happens. Functions will not change the properties of cells other than the cell they are in. They usually just fail silently to perform the request, causing much confusion. In a backwards sort of way this crash saved you from that. You might be able to do what you want with a Listener on the appropriate cells that would then call a procedure. If you can explain what you want to achieve, someone might have a specific suggestion.

Re: oRow.isVisible causes OpenOffice to Crash

Posted: Fri Jun 01, 2018 7:32 pm
by Mi7ke
Thanks for your quick response. :)

The macro ShowRow() is meant to show or hide a row based on a logic calculation. In the spreadsheet that I included earlier, I am trying to hide rows in a division demonstration problem that do not provide any useful information to the reader or which might confuse the reader.

I based the ShowRow() macro on an earlier forum topic: viewtopic.php?f=20&t=79218 which was aimed at hiding columns instead of rows. But, the idea is the same.

I tried placing the ShowRow() macro in a cell on the row that would be shown or hidden by the macro, per your implied suggestion. There didn't seem to be any change in behavior.

I heard your suggestion regarding the Listener. I'll investigate that technique as well.

I am attaching another spreadsheet where this macro does work. (Be sure that AutoCalculate is off, before pressing <F9>. Otherwise OpenOfice Calc gets stuck in endless calculations, despite the apparent lack of circular references.) Note: There are two similar macros: ShowRow() and ShownRow(). ShownRow() merely goes around a problem that ShowRow() is experiencing. But, that's another issue.

This issue is: Why does isVisible crash on the earlier posted spreadsheet and not this one? If I am using the isVisible property incorrectly or applying it inappropriately then I would appreciate clarification on that point, particularly since it seems to work in this last spreadsheet.

I'm not sure I understand your statement, "Functions will not change the properties of cells other than the cell they are in." since rows have alterable properties including the isVisible property, which necessarily affects more than one cell. Are you suggesting that this should have been done by a Subroutine instead of a Function?

Re: oRow.isVisible causes OpenOffice to Crash

Posted: Fri Jun 01, 2018 7:50 pm
by RPG
I think the correct call is

Code: Select all

=SHOWROW(8;FALSE())
Romke