XSystemShellExecute default web browser parameter

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
othmanelmoulat
Posts: 142
Joined: Sun Aug 03, 2008 4:39 am

XSystemShellExecute default web browser parameter

Post by othmanelmoulat »

Hi,
the below java code lauches a url in default browser. I wonder if there is a way to have more control on the browser opened window? i want to have the url opened in a new window with specific width and height. i tried doing this by Passing parameters argument but this has no effect.
is it possible to control the default web browser by asking for a new window with widthxheight?

thanks

Code: Select all

 try {
            // open the help web page
            final Object xObject = mxMCF.createInstanceWithContext("com.sun.star.system.SystemShellExecute", m_xContext);
            final XSystemShellExecute xSystemShellExecute = (XSystemShellExecute) UnoRuntime.queryInterface(XSystemShellExecute.class, xObject);
            StringBuffer Parameters=new StringBuffer();
            Parameters.append("new-window"+SPACE);
            Parameters.append("height 600 "+SPACE);
            Parameters.append("width 800");

            if (xSystemShellExecute != null) {
                xSystemShellExecute.execute(url, Parameters.toString(), SystemShellExecuteFlags.DEFAULTS);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
OOo 3.4 and LibreOffice 3.4 on openSuse 11.4 + windows 7
rudolfo
Volunteer
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: XSystemShellExecute default web browser parameter

Post by rudolfo »

The service is called com.sun.star.system.SystemShellExecute. Which means that most of the things are in control of the OS file manager. At least on Windows SystemShellExecute behaves much like the Startmenu Run entry. You can even pass document file names or image files and they will be opened with the associated application. The second parameters parameter of the UNO object method execute() can only contain what your executable (given in the first parameter) accepts as command line arguments. And that's different for different browsers, the only thing what the have in common is the url. You may try:

.execute( "/path/to/firefox", "-width 600 -new-tab " + url, 0);

Firefox supports -height and -width, but the hyphen at the beginning is important. For other parameters see http://kb.mozillazine.org/Command_line_arguments
In general using the system default browser and passing parameters doesn't make sense. You either let others (the OS) choose the browser, but then also the parameters or you choose the browser by yourself and if you are lucky and fin the right version of the browser you want to start you can also pass parameters.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
othmanelmoulat
Posts: 142
Joined: Sun Aug 03, 2008 4:39 am

Re: XSystemShellExecute default web browser parameter

Post by othmanelmoulat »

yes that's the conclusion i came to after searching more on this issue.
thanks anyway for the reply.
OOo 3.4 and LibreOffice 3.4 on openSuse 11.4 + windows 7
Post Reply