Page 1 of 1

[Solved] Open in Full Screen Mode

Posted: Mon May 20, 2013 6:58 pm
by aviator40
This code does not work although it throws no errors and opens a document - just not in Full Screen mode. It's a VBScript file. Can anyone help me understand why it doesn't work and tell me what I should write instead?

Code: Select all

Dim args(0)
Set oSM= CreateObject ("com.sun.star.ServiceManager")
Set oDp= oSM.createInstance("com.sun.star.frame.Desktop")

Set args(0) = oSM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")

args(0).Name = "FullScreen" 
args(0).Value = true

Set oDoc = oDp.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)

many thanks

Re: Open in Full Screen Mode

Posted: Mon May 20, 2013 9:18 pm
by RPG
Hello

Open first the new document. When the new document is open change it to fullscreen. loadComponentFromURL returns an object what is the same as thiscomponent for the new document.

http://www.oooforum.org/forum/viewtopic ... screen+sub
Maybe this link can help you.

Romke

Re: Open in Full Screen Mode

Posted: Wed May 22, 2013 11:38 pm
by aviator40
Thanks for you reply. How would I do that? I couldn't find a way from the code in the link. I have a suspicion that it is not the document itself which can have a FullScreen property but the containing Window, Frame or whatever it's called, and it's this structure you have to get hold of in order to activate FullScreen. Something like .GetContainerWindow.

Re: Open in Full Screen Mode

Posted: Thu May 23, 2013 1:06 am
by Charlie Young
The ContainerWindow is the obvious place to look, but the only way I know to do full screen is with the dispatcher. In VB you need, as you realize

Code: Select all

FullScreenArg(0).Name = "FullScreen"
FullScreenArg(0).Value = True
then

Code: Select all

oDispatch = oSM.createInstance("com.sun.star.frame.DispatchHelper")
oFrame = oDoc.CurrentController.Frame
oDispatch.executeDispatch(oFrame, ".uno:FullScreen", "", 0, FullScreenArg)
If you do that right after opening the document, you might notice a small delay before it goes into full screen mode.

Re: Open in Full Screen Mode

Posted: Thu May 23, 2013 7:19 am
by aviator40
Yah, many thanks . With one small adjustment - the oDispatch and oFrame objects have to be created first with the Set command - this works.

Code: Select all

Dim args(0),CW,oDispatch,oFrame
Set oSM= CreateObject ("com.sun.star.ServiceManager")
Set oDp= oSM.createInstance("com.sun.star.frame.Desktop")
Set args(0) = oSM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
Set oDispatch = oSM.createInstance("com.sun.star.frame.DispatchHelper")

args(0).Name = "FullScreen" 
args(0).Value = true

Set oDoc = oDp.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)
Set oFrame = oDoc.CurrentController.Frame
oDispatch.executeDispatch oFrame, ".uno:FullScreen", "", 0, args

Re: Open in Full Screen Mode

Posted: Thu May 23, 2013 9:04 am
by Charlie Young
aviator40 wrote:Yah, many thanks . With one small adjustment - the oDispatch and oFrame objects have to be created first with the Set command
I guess that depends on your version of VB. I was using VB 2010, where it isn't required. If, as you indicated, you were using VBScript, perhaps it is. I should propably have checked that. :(

Re: [Solved] Open in Full Screen Mode

Posted: Thu May 23, 2013 12:28 pm
by RPG
Hello

I have the idea you are mixing two different language, in this case VBscript and the uno interface. This is nearly the same as mixing star BASIC and SQL embedded in uno.

The best way to solve your problems is most of the time make clear you do have a good understanding of one part and test the code and when that is ready go to the next part. In your case make first ready the uno part and then the VBscript.

The reason to do it in that way is: it is more easy to find the errors in the code.

Romke

Re: [Solved] Open in Full Screen Mode

Posted: Thu May 23, 2013 9:05 pm
by aviator40
The best way to solve your problems is most of the time make clear you do have a good understanding of one part
This is just it, I don't have a good understanding of any part of it. My understanding so far is that the OpenOffice API is constructed to make its interfaces and services accessible to other languages, but that doesn't mean these languages automatically have direct access to any commands in OO basic or the UNO. Open Office has things called ServiceManager, frame, Desktop, beans, DispatchHelper, and goodness knows what more, and VBScript of course has no native knowledge of these things; it has to link up to them by creating the objects and composing commands with the syntax OO expects to receive them with. So I don't know if this Means technically that one is "mixing languages". I'd tend to call it translation since it's not like human language where if you don't know a Word in the language you're trying to communicate in you can sometimes botch something together borrowing from other languages. The translation has to be spot on every time or there'll be no communication whatever. I'm content for now because the problem is solved thanks to Charlie Young putting me on the right track, but I won't pretend I really know what I'm doing, so I'll be back seeking more help that's for sure! Anyway for now thanks to you all for your contributions.

Re: [Solved] Open in Full Screen Mode

Posted: Thu May 23, 2013 10:07 pm
by RPG
Hello

I did mean: I think it was better if you did wrote the code first only in star BASIC and when it was working create the objects in VBscript. In that way it is more easy to search for the errors. I have the idea you do get a better understanding where the code change from VBscript to uno. As far I knew star BASIC does also not understand uno but the objects are created more easy. This means there is not a big difference between VBscript and star BASIC, as far I understand.

Romke

Re: [Solved] Open in Full Screen Mode

Posted: Fri May 24, 2013 4:42 pm
by Charlie Young
For my own edification I tried the VBScript, which I had only ever tried previously to use SendKeys. It does indeed require Set.

I'll just post it to show that the brief pause before going into FullScreen mode may be suppressed by first opening the component hidden, then making it visible after the FullScreen is activated.

Code: Select all

<package>
    <job id="vbs">
        <script language="VBScript" >
            Dim args(0)
            Dim farg(0)
                                                    
            Set oSM = CreateObject("com.sun.star.ServiceManager")
            Set oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
            Set args(0) = oSM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
            Set farg(0) = oSM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
            args(0).Name = "Hidden"
            args(0).Value = true
            farg(0).Name = "FullScreen"
            farg(0).Value = true
            
            Set oDoc = oDesk.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)
            Set oDispatch = oSM.createInstance("com.sun.star.frame.DispatchHelper")
            Set oFrame = oDoc.CurrentController.Frame
            oDispatch.executeDispatch oFrame, ".uno:FullScreen", "", 0, fArg
            oDoc.CurrentController.Frame.ContainerWindow.Visible = true
       </script>
   </job>
</package>