Page 1 of 1

XSystemShellExecute default web browser parameter

Posted: Mon Oct 10, 2011 9:53 pm
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();
        }
    }

Re: XSystemShellExecute default web browser parameter

Posted: Fri Nov 04, 2011 6:44 pm
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.

Re: XSystemShellExecute default web browser parameter

Posted: Fri Nov 04, 2011 9:34 pm
by othmanelmoulat
yes that's the conclusion i came to after searching more on this issue.
thanks anyway for the reply.