Printing from CALC with macro causes oo to hang randomly

Discuss setup / installation issues - Add a spell checker, Language pack?
Post Reply
JulianR
Posts: 26
Joined: Mon Mar 12, 2018 9:41 am

Printing from CALC with macro causes oo to hang randomly

Post by JulianR »

Hello!

I have run into a very weird problem with printing from CALC with a macro. Usually CALC prints one sheet, then hangs, in Task Manager soffice.bin starts using entire CPU Core and I can see another sheet "buffering" in print queue.

Problem happens on different machines (all tested were running windows 7), different versions of AOO (4.1.5, 4.1.3) and LO (5.1.4, 5.4.4, 6.0.2), all macros were created with AOO API Guide.

On my machine AOO 4.1.3 prints fine, LO 6.0.2 hangs every time, also on my machine LO often hangs with manually invoked printing (Ctrl+P). On another machine AOO 4.1.5 hangs randomly while LO 5.4.4 prints fine, and on yet another machine LO 5.1.4 printed fine the other day, today it hung, and after restarting the machine it started printing fine again.

Printing is done with the following Basic code:

Code: Select all

oController.setActiveSheet(oSheet1)
ThisComponent.Print(Array())
Wait(500)

oController.setActiveSheet(oSheet2)
ThisComponent.Print(Array())
Wait(500)
ThisComponent.Print(Array())
Wait(500)

oController.setActiveSheet(oSheet3)
ThisComponent.Print(Array())
Wait(500)
Did anyone encounter similar problem? It has to be related to some software installed on all of those machines, but I have no idea which one.
Apache OpenOffice 4.1.1 / LibreOffice 5.3 / LibreOffice 6.0 / LibreOffice 6.2 on Windows 7
User avatar
RoryOF
Moderator
Posts: 34612
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Printing from CALC with macro causes oo to hang randomly

Post by RoryOF »

It might be a race condition, between the printing of the sheets and OO/LO's internal housekeeping. I suggest increasing the wait commands quite substantially (perhaps to 5000 initially, for faultfinding) to see if the problem vanishes, then reducing them until it reoccurs.It may then be possible to recommend a better monitoring method.

Depending on the complexity of the file, OO/LO can be doing much internal housekeeping behind the scenes.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
JulianR
Posts: 26
Joined: Mon Mar 12, 2018 9:41 am

Re: Printing from CALC with macro causes oo to hang randomly

Post by JulianR »

It does not seem to be it. At wait(5000) LO 6.0.2 hung after first printout, after that I tried it with wait(25000), and it managed to print three printouts, but then crashed instead of hanging. Second run with wait(25000) hanged itself with first printout.
After that I run AOO 4.1.3 and it first printed all printouts at wait(500)and completed the procedure.
Then I run LO 6.0.2 again with wait(500) and it hung at third printout.
Apache OpenOffice 4.1.1 / LibreOffice 5.3 / LibreOffice 6.0 / LibreOffice 6.2 on Windows 7
User avatar
RoryOF
Moderator
Posts: 34612
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Printing from CALC with macro causes oo to hang randomly

Post by RoryOF »

I suggest you start some type of memory and activity monitor and look at what is happening while you run your macro. My experience with OO (LO not tried) is that OO does some heavy background work even after the loaded file is editable. One can see this by the CPU % used, also by the increasing memory allocation. I suggest waiting until these parameters are stable at the time when you invoke macro and seeing if the macro runs correctly then.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply