oRow.isVisible causes OpenOffice to Crash

Keyboard macros or custom scripts

oRow.isVisible causes OpenOffice to Crash

Postby Mi7ke » Fri Jun 01, 2018 3:29 am

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   Expand viewCollapse view
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 42 times
Open Office Apache 4.15
Windows 7
Mi7ke
 
Posts: 2
Joined: Fri May 18, 2018 7:50 pm

Re: oRow.isVisible causes OpenOffice to Crash

Postby FJCC » Fri Jun 01, 2018 4:50 am

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.
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 6761
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: oRow.isVisible causes OpenOffice to Crash

Postby Mi7ke » Fri Jun 01, 2018 7:32 pm

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: https://forum.openoffice.org/en/forum/v ... 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 34 times
Open Office Apache 4.15
Windows 7
Mi7ke
 
Posts: 2
Joined: Fri May 18, 2018 7:50 pm

Re: oRow.isVisible causes OpenOffice to Crash

Postby RPG » Fri Jun 01, 2018 7:50 pm

I think the correct call is
Code: Select all   Expand viewCollapse view
=SHOWROW(8;FALSE())


Romke
LibreOffice 6.1.3.1 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2141
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 5 guests