oRow.isVisible causes OpenOffice to Crash

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Mi7ke
Posts: 2
Joined: Fri May 18, 2018 7:50 pm

oRow.isVisible causes OpenOffice to Crash

Post 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
Attachments
Math - 053118.ods
Spread Sheet to Demonstrate Division
(18.91 KiB) Downloaded 209 times
Open Office Apache 4.15
Windows 7
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: oRow.isVisible causes OpenOffice to Crash

Post 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.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Mi7ke
Posts: 2
Joined: Fri May 18, 2018 7:50 pm

Re: oRow.isVisible causes OpenOffice to Crash

Post 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?
Attachments
ShowRow.ods
(21.34 KiB) Downloaded 228 times
Open Office Apache 4.15
Windows 7
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: oRow.isVisible causes OpenOffice to Crash

Post by RPG »

I think the correct call is

Code: Select all

=SHOWROW(8;FALSE())
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Post Reply