xref: /AOO41X/main/qadevOOo/runner/util/FormTools.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir package util;
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir // access the implementations via names
31*cdf0e10cSrcweir import com.sun.star.uno.XInterface;
32*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
33*cdf0e10cSrcweir import com.sun.star.lang.XComponent;
34*cdf0e10cSrcweir import com.sun.star.drawing.XControlShape;
35*cdf0e10cSrcweir import com.sun.star.drawing.XDrawPage;
36*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
37*cdf0e10cSrcweir import com.sun.star.awt.Size;
38*cdf0e10cSrcweir import com.sun.star.awt.Point;
39*cdf0e10cSrcweir import com.sun.star.awt.XControlModel;
40*cdf0e10cSrcweir import com.sun.star.container.XNameContainer;
41*cdf0e10cSrcweir import com.sun.star.container.XIndexContainer;
42*cdf0e10cSrcweir import com.sun.star.form.XFormsSupplier;
43*cdf0e10cSrcweir import com.sun.star.form.XForm;
44*cdf0e10cSrcweir import com.sun.star.form.XLoadable;
45*cdf0e10cSrcweir import com.sun.star.text.XTextDocument;
46*cdf0e10cSrcweir import com.sun.star.beans.XPropertySet;
47*cdf0e10cSrcweir import com.sun.star.uno.AnyConverter;
48*cdf0e10cSrcweir import com.sun.star.uno.Type;
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir /**
51*cdf0e10cSrcweir  * contains helper methods forms
52*cdf0e10cSrcweir  */
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir public class FormTools {
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir     /**
58*cdf0e10cSrcweir      * creates a XControlShape
59*cdf0e10cSrcweir      *
60*cdf0e10cSrcweir      * @param oDoc the document
61*cdf0e10cSrcweir      * @param height the height of the shape
62*cdf0e10cSrcweir      * @param width the width of the shape
63*cdf0e10cSrcweir      * @param x the x-position of the shape
64*cdf0e10cSrcweir      * @param y the y-position of the shape
65*cdf0e10cSrcweir      * @param kind the kind of the shape
66*cdf0e10cSrcweir      * @return the created XControlShape
67*cdf0e10cSrcweir     */
68*cdf0e10cSrcweir     public static XControlShape createControlShape( XComponent oDoc, int height,
69*cdf0e10cSrcweir                                         int width, int x, int y, String kind ) {
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir      	Size size = new Size();
72*cdf0e10cSrcweir         Point position = new Point();
73*cdf0e10cSrcweir         XControlShape oCShape = null;
74*cdf0e10cSrcweir         XControlModel aControl = null;
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir         //get MSF
77*cdf0e10cSrcweir         XMultiServiceFactory oDocMSF = (XMultiServiceFactory)
78*cdf0e10cSrcweir                 UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir         try{
81*cdf0e10cSrcweir             Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape");
82*cdf0e10cSrcweir             Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind);
83*cdf0e10cSrcweir             XPropertySet model_props = (XPropertySet)
84*cdf0e10cSrcweir                     UnoRuntime.queryInterface(XPropertySet.class,aCon);
85*cdf0e10cSrcweir             model_props.setPropertyValue("DefaultControl","com.sun.star.form.control."+kind);
86*cdf0e10cSrcweir             aControl = (XControlModel) UnoRuntime.queryInterface( XControlModel.class, aCon );
87*cdf0e10cSrcweir             oCShape = (XControlShape) UnoRuntime.queryInterface( XControlShape.class, oInt );
88*cdf0e10cSrcweir             size.Height = height;
89*cdf0e10cSrcweir             size.Width = width;
90*cdf0e10cSrcweir             position.X = x;
91*cdf0e10cSrcweir             position.Y = y;
92*cdf0e10cSrcweir             oCShape.setSize(size);
93*cdf0e10cSrcweir             oCShape.setPosition(position);
94*cdf0e10cSrcweir         } catch ( com.sun.star.uno.Exception e ) {
95*cdf0e10cSrcweir             // Some exception occures.FAILED
96*cdf0e10cSrcweir             System.out.println( "Couldn't create instance "+ e );
97*cdf0e10cSrcweir         }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir         oCShape.setControl(aControl);
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir         return oCShape;
102*cdf0e10cSrcweir     } // finish createControlShape
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 	public static XControlShape createUnoControlShape( XComponent oDoc, int height,
105*cdf0e10cSrcweir                                         int width, int x, int y, String kind, String defControl ) {
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir      	Size size = new Size();
108*cdf0e10cSrcweir         Point position = new Point();
109*cdf0e10cSrcweir         XControlShape oCShape = null;
110*cdf0e10cSrcweir         XControlModel aControl = null;
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir         //get MSF
113*cdf0e10cSrcweir    		XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir    		try{
116*cdf0e10cSrcweir          Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape");
117*cdf0e10cSrcweir          Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind);
118*cdf0e10cSrcweir          XPropertySet model_props = (XPropertySet)
119*cdf0e10cSrcweir                         UnoRuntime.queryInterface(XPropertySet.class,aCon);
120*cdf0e10cSrcweir          model_props.setPropertyValue("DefaultControl","com.sun.star.awt."+defControl);
121*cdf0e10cSrcweir          aControl = (XControlModel) UnoRuntime.queryInterface( XControlModel.class, aCon );
122*cdf0e10cSrcweir          oCShape = (XControlShape) UnoRuntime.queryInterface( XControlShape.class, oInt );
123*cdf0e10cSrcweir          size.Height = height;
124*cdf0e10cSrcweir 		 size.Width = width;
125*cdf0e10cSrcweir 		 position.X = x;
126*cdf0e10cSrcweir 		 position.Y = y;
127*cdf0e10cSrcweir 		 oCShape.setSize(size);
128*cdf0e10cSrcweir 		 oCShape.setPosition(position);
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir    		} catch ( com.sun.star.uno.Exception e ) {
132*cdf0e10cSrcweir 			// Some exception occures.FAILED
133*cdf0e10cSrcweir 			System.out.println( "Couldn't create instance "+ e );
134*cdf0e10cSrcweir 		}
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir         oCShape.setControl(aControl);
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir         return oCShape;
139*cdf0e10cSrcweir     } // finish createControlShape
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 	public static XControlShape createControlShapeWithDefaultControl( XComponent oDoc, int height,
142*cdf0e10cSrcweir                                         int width, int x, int y, String kind ) {
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir      	Size size = new Size();
145*cdf0e10cSrcweir         Point position = new Point();
146*cdf0e10cSrcweir         XControlShape oCShape = null;
147*cdf0e10cSrcweir         XControlModel aControl = null;
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir         //get MSF
150*cdf0e10cSrcweir    		XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir    		try{
153*cdf0e10cSrcweir          Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape");
154*cdf0e10cSrcweir          Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind);
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir          aControl = (XControlModel) UnoRuntime.queryInterface( XControlModel.class, aCon );
157*cdf0e10cSrcweir          oCShape = (XControlShape) UnoRuntime.queryInterface( XControlShape.class, oInt );
158*cdf0e10cSrcweir          size.Height = height;
159*cdf0e10cSrcweir 		 size.Width = width;
160*cdf0e10cSrcweir 		 position.X = x;
161*cdf0e10cSrcweir 		 position.Y = y;
162*cdf0e10cSrcweir 		 oCShape.setSize(size);
163*cdf0e10cSrcweir 		 oCShape.setPosition(position);
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir    		} catch ( com.sun.star.uno.Exception e ) {
167*cdf0e10cSrcweir 			// Some exception occures.FAILED
168*cdf0e10cSrcweir 			System.out.println( "Couldn't create instance "+ e );
169*cdf0e10cSrcweir 		}
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir         oCShape.setControl(aControl);
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir         return oCShape;
174*cdf0e10cSrcweir     } // finish createControlShape
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 	public static XInterface createControl( XComponent oDoc, String kind ) {
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir         XInterface oControl = null;
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir    		XMultiServiceFactory oDocMSF = (XMultiServiceFactory)
181*cdf0e10cSrcweir                 UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir    		try{
184*cdf0e10cSrcweir 	        oControl = (XInterface) oDocMSF.createInstance(
185*cdf0e10cSrcweir                                         "com.sun.star.form.component."+kind);
186*cdf0e10cSrcweir    		} catch ( Exception e ) {
187*cdf0e10cSrcweir 			// Some exception occures.FAILED
188*cdf0e10cSrcweir 			System.out.println( "Couldn't create instance "+ kind + ": "+ e );
189*cdf0e10cSrcweir 		}
190*cdf0e10cSrcweir         return oControl;
191*cdf0e10cSrcweir     } // finish createControl
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir     public static XNameContainer getForms ( XDrawPage oDP )
194*cdf0e10cSrcweir     {
195*cdf0e10cSrcweir 		XFormsSupplier oFS = (XFormsSupplier) UnoRuntime.queryInterface(
196*cdf0e10cSrcweir                                                     XFormsSupplier.class,oDP);
197*cdf0e10cSrcweir 		return oFS.getForms();
198*cdf0e10cSrcweir     } //finish getForms
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir     public static XIndexContainer getIndexedForms ( XDrawPage oDP )
201*cdf0e10cSrcweir     {
202*cdf0e10cSrcweir 		XFormsSupplier oFS = (XFormsSupplier) UnoRuntime.queryInterface(
203*cdf0e10cSrcweir                                                     XFormsSupplier.class,oDP);
204*cdf0e10cSrcweir 		return (XIndexContainer)UnoRuntime.queryInterface( XIndexContainer.class,
205*cdf0e10cSrcweir             oFS.getForms() );
206*cdf0e10cSrcweir     } //finish getIndexedForms
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir     public static void insertForm ( XComponent aDoc, XNameContainer Forms,
209*cdf0e10cSrcweir                                                                 String aName ) {
210*cdf0e10cSrcweir         try {
211*cdf0e10cSrcweir 		    XInterface oControl = createControl(aDoc, "Form");
212*cdf0e10cSrcweir 		    XForm oForm = (XForm) UnoRuntime.queryInterface(XForm.class, oControl);
213*cdf0e10cSrcweir             Forms.insertByName(aName,oForm);
214*cdf0e10cSrcweir 		} catch ( Exception e ) {
215*cdf0e10cSrcweir 			throw new IllegalArgumentException( "Couldn't insert Form" );
216*cdf0e10cSrcweir 		}
217*cdf0e10cSrcweir     }
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 	public static XControlShape insertControlShape( XComponent oDoc, int height,
220*cdf0e10cSrcweir                                         int width, int x, int y, String kind ) {
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir         XControlShape aShape = createControlShape(oDoc,height,width,x,y,kind);
223*cdf0e10cSrcweir         XDrawPage oDP = DrawTools.getDrawPage(oDoc,0);
224*cdf0e10cSrcweir         DrawTools.getShapes(oDP).add(aShape);
225*cdf0e10cSrcweir         return aShape;
226*cdf0e10cSrcweir     }
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir     public static XLoadable bindForm( XTextDocument aDoc ) {
229*cdf0e10cSrcweir         XLoadable formLoader = null;
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir         try {
232*cdf0e10cSrcweir             Object aForm = FormTools.getIndexedForms(WriterTools.getDrawPage(aDoc)).getByIndex(0);
233*cdf0e10cSrcweir             XForm the_form = null;
234*cdf0e10cSrcweir             try {
235*cdf0e10cSrcweir                 the_form = (XForm) AnyConverter.toObject(new Type(XForm.class), aForm);
236*cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException iae) {
237*cdf0e10cSrcweir                 System.out.println("### Couldn't convert Any");
238*cdf0e10cSrcweir             }
239*cdf0e10cSrcweir             XPropertySet formProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, the_form);
240*cdf0e10cSrcweir             formProps.setPropertyValue("DataSourceName","Bibliography");
241*cdf0e10cSrcweir             formProps.setPropertyValue("Command","biblio");
242*cdf0e10cSrcweir             formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE));
243*cdf0e10cSrcweir             formLoader = (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form);
244*cdf0e10cSrcweir         }
245*cdf0e10cSrcweir         catch (Exception ex) {
246*cdf0e10cSrcweir             System.out.println("Exception: "+ex);
247*cdf0e10cSrcweir             ex.printStackTrace(System.out);
248*cdf0e10cSrcweir         }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir         return formLoader;
251*cdf0e10cSrcweir     }
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir 	/**
254*cdf0e10cSrcweir 	* Binds <code>'Standard'</code> form of <code>aDoc</code> Writer document
255*cdf0e10cSrcweir 	* to the <code>tableName</code> table of <code>sourceName</code>
256*cdf0e10cSrcweir 	* Data Source.
257*cdf0e10cSrcweir 	* @param aDoc Writer document where DB controls are added.
258*cdf0e10cSrcweir 	* @param sourceName The name of DataSource in the <code>DatabaseContext</code>.
259*cdf0e10cSrcweir 	* @param tableName The name of the table to which controls are bound.
260*cdf0e10cSrcweir 	* @return <code>com.sun.star.form.component.DatabaseForm</code> service
261*cdf0e10cSrcweir 	* implementation which is the bound form inside the document.
262*cdf0e10cSrcweir 	*/
263*cdf0e10cSrcweir     public static XLoadable bindForm( XTextDocument aDoc, String sourceName, String tableName )
264*cdf0e10cSrcweir     	throws com.sun.star.uno.Exception {
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir         XForm the_form = (XForm) AnyConverter.toObject(new Type(XForm.class),
267*cdf0e10cSrcweir             FormTools.getIndexedForms(WriterTools.getDrawPage(aDoc)).getByIndex(0));
268*cdf0e10cSrcweir         XPropertySet formProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, the_form);
269*cdf0e10cSrcweir         formProps.setPropertyValue("DataSourceName",sourceName);
270*cdf0e10cSrcweir         formProps.setPropertyValue("Command",tableName);
271*cdf0e10cSrcweir         formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE));
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir         return (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form);
274*cdf0e10cSrcweir     }
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir     public static XLoadable bindForm( XTextDocument aDoc, String formName ) {
277*cdf0e10cSrcweir         XLoadable formLoader = null;
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir         try {
280*cdf0e10cSrcweir             XForm the_form = (XForm) FormTools.getForms(WriterTools.getDrawPage(aDoc)).getByName(formName);
281*cdf0e10cSrcweir             XPropertySet formProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, the_form);
282*cdf0e10cSrcweir             formProps.setPropertyValue("DataSourceName","Bibliography");
283*cdf0e10cSrcweir             formProps.setPropertyValue("Command","biblio");
284*cdf0e10cSrcweir             formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE));
285*cdf0e10cSrcweir             formLoader = (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form);
286*cdf0e10cSrcweir         }
287*cdf0e10cSrcweir         catch (Exception ex) {
288*cdf0e10cSrcweir             System.out.println("Exception: "+ex);
289*cdf0e10cSrcweir             ex.printStackTrace(System.out);
290*cdf0e10cSrcweir         }
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir         return formLoader;
293*cdf0e10cSrcweir     }
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir 	/**
296*cdf0e10cSrcweir 	* Binds the form with the name specified of <code>aDoc</code> Writer document
297*cdf0e10cSrcweir 	* to the <code>tableName</code> table of <code>sourceName</code>
298*cdf0e10cSrcweir 	* Data Source.
299*cdf0e10cSrcweir 	* @param aDoc Writer document where DB controls are added.
300*cdf0e10cSrcweir 	* @param formName The name of the form to be bound.
301*cdf0e10cSrcweir 	* @param sourceName The name of DataSource in the <code>DatabaseContext</code>.
302*cdf0e10cSrcweir 	* @param tableName The name of the table to which controls are bound.
303*cdf0e10cSrcweir 	* @return <code>com.sun.star.form.component.DatabaseForm</code> service
304*cdf0e10cSrcweir 	* implementation which is the bound form inside the document.
305*cdf0e10cSrcweir 	*/
306*cdf0e10cSrcweir     public static XLoadable bindForm( XTextDocument aDoc, String formName, String sourceName,
307*cdf0e10cSrcweir     	String tableName) throws com.sun.star.uno.Exception {
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir         XForm the_form = (XForm) AnyConverter.toObject(new Type(XForm.class),
310*cdf0e10cSrcweir             FormTools.getForms(WriterTools.getDrawPage(aDoc)).getByName(formName));
311*cdf0e10cSrcweir         XPropertySet formProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, the_form);
312*cdf0e10cSrcweir         formProps.setPropertyValue("DataSourceName",sourceName);
313*cdf0e10cSrcweir         formProps.setPropertyValue("Command",tableName);
314*cdf0e10cSrcweir         formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE));
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir         return (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form);
317*cdf0e10cSrcweir     }
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir     public static void switchDesignOf(XMultiServiceFactory xMSF, XTextDocument aDoc) {
320*cdf0e10cSrcweir     try {
321*cdf0e10cSrcweir         com.sun.star.frame.XController aController = aDoc.getCurrentController();
322*cdf0e10cSrcweir         com.sun.star.frame.XFrame aFrame = aController.getFrame();
323*cdf0e10cSrcweir         com.sun.star.frame.XDispatchProvider aDispProv = (com.sun.star.frame.XDispatchProvider)
324*cdf0e10cSrcweir                 UnoRuntime.queryInterface(com.sun.star.frame.XDispatchProvider.class,aFrame);
325*cdf0e10cSrcweir         com.sun.star.util.URL aURL = new com.sun.star.util.URL();
326*cdf0e10cSrcweir         aURL.Complete = ".uno:SwitchControlDesignMode";
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir         Object instance = xMSF.createInstance("com.sun.star.util.URLTransformer");
329*cdf0e10cSrcweir         com.sun.star.util.XURLTransformer atrans =
330*cdf0e10cSrcweir                 (com.sun.star.util.XURLTransformer)UnoRuntime.queryInterface(
331*cdf0e10cSrcweir                                     com.sun.star.util.XURLTransformer.class,instance);
332*cdf0e10cSrcweir         com.sun.star.util.URL[] aURLA = new com.sun.star.util.URL[1];
333*cdf0e10cSrcweir         aURLA[0] = aURL;
334*cdf0e10cSrcweir         atrans.parseStrict(aURLA);
335*cdf0e10cSrcweir         aURL = aURLA[0];
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir         com.sun.star.frame.XDispatch aDisp = (com.sun.star.frame.XDispatch)aDispProv.queryDispatch(aURL, "",
338*cdf0e10cSrcweir         	                    com.sun.star.frame.FrameSearchFlag.SELF |
339*cdf0e10cSrcweir                                     com.sun.star.frame.FrameSearchFlag.CHILDREN);
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir         com.sun.star.beans.PropertyValue[] noArgs = new com.sun.star.beans.PropertyValue[0];
342*cdf0e10cSrcweir         aDisp.dispatch(aURL, noArgs);
343*cdf0e10cSrcweir         } catch (Exception e) {
344*cdf0e10cSrcweir             System.out.println("******* Mist");
345*cdf0e10cSrcweir             e.printStackTrace();
346*cdf0e10cSrcweir             }
347*cdf0e10cSrcweir     }
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir }
350