[Solved] Open Doc invisible and make it visible if prepared

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Peter18
Posts: 102
Joined: Thu May 12, 2011 1:01 pm

[Solved] Open Doc invisible and make it visible if prepared

Post by Peter18 »

A friendly hallo to anybody,

I would like to open a Doc invisible. ( Par[0].Name := 'Hidden'; Par[0].Value := True;) Then I want to prepare it and make it visible. If possible I want to bring the Window on top of the others.

Greetins and have a nice day

Peter
Last edited by Peter18 on Thu Oct 13, 2011 10:57 am, edited 1 time in total.
OpenOffice 3.3; OpenOffice 4.1.1
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Open a Doc invisible and make it visible if prepared

Post by JohnSUN-Pensioner »

What do you want to do with hidden frame? Will be some operations with DispatchHelper? Forget! It's not working... I hope this is temporary.
About "set visible and bring to front" - see the Pitonyak's book chapters "5.41. Focus (bring to the front) a new document" and "5.45. Load hidden then setVisible"
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: Open a Doc invisible and make it visible if prepared

Post by Charlie Young »

The subject of running a macro in a hidden component has come up before, and it is possible. I think the basic idea was presented by hanya.

I still have some of that code, in Basic, which runs a macro in the document, waits 5 seconds, then makes the document visible and brings it to the front.

Code: Select all

Sub ManipulateHiddenDoc
	Dim oDoc
	Dim oVal(1) As New com.sun.star.beans.PropertyValue
	Dim oscriptProvider
	Dim oScript
		
	oVal(0).Name = "Hidden"
	oVal(0).Value = True
	oVal(1).Name = "MacroExecutionMode"
	oVal(1).Value = com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE_NO_WARN
	
	oDoc = StarDesktop.loadComponentFromURL("file:///c:/tmp/a.odt", " blank", 0, oVal())
	oscriptProvider = oDoc.getScriptProvider()
	oScript = oscriptProvider.getScript("vnd.sun.star.script:Standard.Module1.MyMacro?language=Basic&location=document")
	oScript.invoke(array(), array(), array())
	Wait 5000
	oDoc.CurrentController.Frame.ContainerWindow.Visible = True
	oDoc.CurrentController.Frame.ContainerWindow.toFront()
End Sub

Apache OpenOffice 4.1.1
Windows XP
Peter18
Posts: 102
Joined: Thu May 12, 2011 1:01 pm

Re: Open a Doc invisible and make it visible if prepared

Post by Peter18 »

Hello JohnSUN-Pensioner, hello Charlie Young,

thank you for your answers. It works :D . Why hidden frame? Well, my software is written with Delphi. So I like to prepare a doc, reading data from an other file and write it into the doc. If the doc is ready to work with, I make it visible. So you can't try to work with the doc while my prog is preparing it.

By the way, JohnSUN-Pensioner, are there more Documents with informations like this? An overview of the inteface components and its proertys and methods would be nice.

Greetings

Peter
OpenOffice 3.3; OpenOffice 4.1.1
User avatar
RoryOF
Moderator
Posts: 34612
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Solved]Open a Doc invisible and make it visible if prep

Post by RoryOF »

Start with Andrew Pitonyak's site and documents downloadable from there; follow the references from them when you need to know more.
http://www.pitonyak.org/oo.php
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply