Supress display during processing

(This was a question, but now includes the answer.)
The macro (Startup) in the attached database (Call to Startup with icon on the front screen) opens an internal form (FTest) and stores it as a file (TestOut.odt). Previously, during operation the form appeared on the screen, which was messy and confusing. In this edited version, sokol92’s proposal has been incorporated to open in hidden mode and dispose rather than close the form.

Ubunto 20.04 LO 7.2.1.
hide.odb (39.3 KB)

@Pansmanser German Forum Tread:
maybe a hint for optimizing your workflow??

@karolus I’m sorry neither my German nor my python is up to this.

ThisComponent.CurrentController.Frame.ComponentWindow.Visible = False

ThisComponent.CurrentController.Frame.ComponentWindow.Visible = True

Just re-tested Hidden & Visible. Visible works while Hidden errors on closing the form. My testing is erratic today.

Done for now - above code should work for you.

Thanks, @philippe.s.levi, that looks helpful, but when I run it I get an exception :-

type: com.sun.star.lang.DisposedException
Message: /nome/buildsafe/source/libo-core/sfx2/source/doc/-sfxbasemodel.css:2953

which is Greek to me.

Thank you, @Ratslinger. That has cracked it.

In my experiments, the Hidden : True option works without errors if I use

oForm.dispose 

@Pansmanser, this topic may be of interest to other users as well. Could you upload a test file(s)?

Yes, @sokol92 ‘hidden’ and ‘dipose’ works better. Thank you. If you post it as an answer, I’ll accept it.

@Pansmanser

To hide form is (using your code after call to OpenForm):

oForm.CurrentController.Frame.ContainerWindow.Visible = False
and
oForm.CurrentController.Frame.ContainerWindow.Visible = True

provided that the form you are opening is the one to be reduced. It is confusing as all is just bits and pieces.

Edit:

If it is not the form you are opening but the current form, then:

ThisComponent.CurrentController.Frame.ContainerWindow.Visible = False
and
ThisComponent.CurrentController.Frame.ContainerWindow.Visible = True

Thank you, this is not necessary! I think that attentive readers will study the topic to the end. :slightly_smiling_face:

to me too ! :frowning:

I found that … not very helpfull !

Description

This exception occurs if the object behind this interface has been disposed before and can’t uphold its method specification anymore.

The implementation normally should implement the XComponent interface to indicate this possibility.

Developers Guide

Thanks, @Ratslinger.

Your first suggestion certainly reduces the time my form is on screen to a mere flash, however the output file is empty. I guess that StarDesktop.CurrentComponent() is no longer the Form that I am trying to write to the file. Furthermore the wrong Frame is closed when attempting to close the form, even if I set Visible=True before closing the window.

The second version produces the same DisposedException as @philippe.s.levi’s method.

Is it not possible to use the Hidden property when opening?

Sorry, but you are likely changing focus as to which form is currently ThisComponent and without a complete working sample it will be difficult to test. Basically you need to independently save access to each form (ie the one loaded in OpenForm is ‘oForm’) and that is how you access and close the one you wish. Possibly save a reference to the ThisComponent form before opening the other.

Can you explain how you would do that, @sokol92 ? I don’t know how to set ‘hidden’ with a normal odt, never mind loading a form within base.

In the second macro snippet in your startup message, add before the last line:

oParams(2).name = "Hidden" : oParams(2).value = True

Accordingly, it is also necessary to change the upper bound in the oParams description (dim) from 1 to 2.
LO documents can be opened in hidden mode (I use this), forms - I don’t know. :confused:

@Ratslinger I’ve rewritten the original question including the complete macro. (Should I have been able to attach the database?)

Yes, @sokol92, thank you! That has achieved the hiding.
However, when saving the file, there is an IOException, presumably because there is nothing there.
And then it closes the wrong window!
(I’ve rewritten the original question.)

The proposal seems to be effectve if you has your form opened, then you have the reference and then you can hide It.
I think It is not really easy, and It needs to open the form in hidden way, then put your preferences and finally unhide It as the final result.
All with macros and I am not sure to be able to do that.
Probably somebody could find the path.
Bye!