xref: /AOO41X/main/odk/examples/DevelopersGuide/GUI/UnoDialogSample.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  *  The Contents of this file are made available subject to the terms of
4*cdf0e10cSrcweir  *  the BSD license.
5*cdf0e10cSrcweir  *
6*cdf0e10cSrcweir  *  Copyright 2000, 2010 Oracle and/or its affiliates.
7*cdf0e10cSrcweir  *  All rights reserved.
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  *  Redistribution and use in source and binary forms, with or without
10*cdf0e10cSrcweir  *  modification, are permitted provided that the following conditions
11*cdf0e10cSrcweir  *  are met:
12*cdf0e10cSrcweir  *  1. Redistributions of source code must retain the above copyright
13*cdf0e10cSrcweir  *     notice, this list of conditions and the following disclaimer.
14*cdf0e10cSrcweir  *  2. Redistributions in binary form must reproduce the above copyright
15*cdf0e10cSrcweir  *     notice, this list of conditions and the following disclaimer in the
16*cdf0e10cSrcweir  *     documentation and/or other materials provided with the distribution.
17*cdf0e10cSrcweir  *  3. Neither the name of Sun Microsystems, Inc. nor the names of its
18*cdf0e10cSrcweir  *     contributors may be used to endorse or promote products derived
19*cdf0e10cSrcweir  *     from this software without specific prior written permission.
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22*cdf0e10cSrcweir  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23*cdf0e10cSrcweir  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24*cdf0e10cSrcweir  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25*cdf0e10cSrcweir  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26*cdf0e10cSrcweir  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27*cdf0e10cSrcweir  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28*cdf0e10cSrcweir  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29*cdf0e10cSrcweir  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30*cdf0e10cSrcweir  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31*cdf0e10cSrcweir  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*cdf0e10cSrcweir  *
33*cdf0e10cSrcweir  *************************************************************************/
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir import com.sun.star.awt.ActionEvent;
36*cdf0e10cSrcweir import com.sun.star.awt.AdjustmentEvent;
37*cdf0e10cSrcweir import com.sun.star.awt.AdjustmentType;
38*cdf0e10cSrcweir import com.sun.star.awt.FocusChangeReason;
39*cdf0e10cSrcweir import com.sun.star.awt.FocusEvent;
40*cdf0e10cSrcweir import com.sun.star.awt.ItemEvent;
41*cdf0e10cSrcweir import com.sun.star.awt.KeyEvent;
42*cdf0e10cSrcweir import com.sun.star.awt.MouseEvent;
43*cdf0e10cSrcweir import com.sun.star.awt.PosSize;
44*cdf0e10cSrcweir import com.sun.star.awt.PushButtonType;
45*cdf0e10cSrcweir import com.sun.star.awt.Rectangle;
46*cdf0e10cSrcweir import com.sun.star.awt.SpinEvent;
47*cdf0e10cSrcweir import com.sun.star.awt.TextEvent;
48*cdf0e10cSrcweir import com.sun.star.awt.XActionListener;
49*cdf0e10cSrcweir import com.sun.star.awt.XAdjustmentListener;
50*cdf0e10cSrcweir import com.sun.star.awt.XButton;
51*cdf0e10cSrcweir import com.sun.star.awt.XCheckBox;
52*cdf0e10cSrcweir import com.sun.star.awt.XComboBox;
53*cdf0e10cSrcweir import com.sun.star.awt.XControl;
54*cdf0e10cSrcweir import com.sun.star.awt.XControlContainer;
55*cdf0e10cSrcweir import com.sun.star.awt.XControlModel;
56*cdf0e10cSrcweir import com.sun.star.awt.XDialog;
57*cdf0e10cSrcweir import com.sun.star.awt.XFixedText;
58*cdf0e10cSrcweir import com.sun.star.awt.XFocusListener;
59*cdf0e10cSrcweir import com.sun.star.awt.XItemEventBroadcaster;
60*cdf0e10cSrcweir import com.sun.star.awt.XItemListener;
61*cdf0e10cSrcweir import com.sun.star.awt.XKeyListener;
62*cdf0e10cSrcweir import com.sun.star.awt.XListBox;
63*cdf0e10cSrcweir //import com.sun.star.awt.XMessageBoxFactory;
64*cdf0e10cSrcweir import com.sun.star.awt.XMouseListener;
65*cdf0e10cSrcweir import com.sun.star.awt.XPointer;
66*cdf0e10cSrcweir import com.sun.star.awt.XReschedule;
67*cdf0e10cSrcweir import com.sun.star.awt.XScrollBar;
68*cdf0e10cSrcweir import com.sun.star.awt.XSpinField;
69*cdf0e10cSrcweir import com.sun.star.awt.XSpinListener;
70*cdf0e10cSrcweir import com.sun.star.awt.XTextComponent;
71*cdf0e10cSrcweir import com.sun.star.awt.XTextListener;
72*cdf0e10cSrcweir import com.sun.star.awt.XToolkit;
73*cdf0e10cSrcweir import com.sun.star.awt.XTopWindow;
74*cdf0e10cSrcweir import com.sun.star.awt.XWindow;
75*cdf0e10cSrcweir import com.sun.star.awt.XWindowPeer;
76*cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
77*cdf0e10cSrcweir import com.sun.star.beans.XMultiPropertySet;
78*cdf0e10cSrcweir import com.sun.star.beans.XPropertySet;
79*cdf0e10cSrcweir import com.sun.star.container.XIndexContainer;
80*cdf0e10cSrcweir import com.sun.star.container.XNameAccess;
81*cdf0e10cSrcweir import com.sun.star.container.XNameContainer;
82*cdf0e10cSrcweir import com.sun.star.frame.XDesktop;
83*cdf0e10cSrcweir import com.sun.star.frame.XFrame;
84*cdf0e10cSrcweir import com.sun.star.frame.XModel;
85*cdf0e10cSrcweir import com.sun.star.lang.EventObject;
86*cdf0e10cSrcweir import com.sun.star.lang.XComponent;
87*cdf0e10cSrcweir import com.sun.star.lang.XMultiComponentFactory;
88*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
89*cdf0e10cSrcweir import com.sun.star.lang.XSingleServiceFactory;
90*cdf0e10cSrcweir import com.sun.star.text.XTextDocument;
91*cdf0e10cSrcweir import com.sun.star.ucb.XFileIdentifierConverter;
92*cdf0e10cSrcweir import com.sun.star.uno.AnyConverter;
93*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
94*cdf0e10cSrcweir import com.sun.star.uno.XComponentContext;
95*cdf0e10cSrcweir import com.sun.star.util.XMacroExpander;
96*cdf0e10cSrcweir import com.sun.star.util.XNumberFormats;
97*cdf0e10cSrcweir import com.sun.star.util.XNumberFormatsSupplier;
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir // Anregung von DV:
101*cdf0e10cSrcweir // Position und Weite als Parameter uebergeben
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir public class UnoDialogSample implements XTextListener, XSpinListener, XActionListener, XFocusListener, XMouseListener, XItemListener, XAdjustmentListener, XKeyListener {
104*cdf0e10cSrcweir     protected XComponentContext m_xContext = null;
105*cdf0e10cSrcweir     protected com.sun.star.lang.XMultiComponentFactory m_xMCF;
106*cdf0e10cSrcweir     protected XMultiServiceFactory m_xMSFDialogModel;
107*cdf0e10cSrcweir     protected XModel m_xModel;
108*cdf0e10cSrcweir     protected XNameContainer m_xDlgModelNameContainer;
109*cdf0e10cSrcweir     protected XControlContainer m_xDlgContainer;
110*cdf0e10cSrcweir //    protected XNameAccess m_xDlgModelNameAccess;
111*cdf0e10cSrcweir     protected XControl m_xDialogControl;
112*cdf0e10cSrcweir     protected XDialog xDialog;
113*cdf0e10cSrcweir     protected XReschedule mxReschedule;
114*cdf0e10cSrcweir     protected XWindowPeer m_xWindowPeer = null;
115*cdf0e10cSrcweir     protected XTopWindow m_xTopWindow = null;
116*cdf0e10cSrcweir     protected XFrame m_xFrame = null;
117*cdf0e10cSrcweir     protected XComponent m_xComponent = null;
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     /**
121*cdf0e10cSrcweir      * Creates a new instance of UnoDialogSample
122*cdf0e10cSrcweir      */
123*cdf0e10cSrcweir     public UnoDialogSample(XComponentContext _xContext, XMultiComponentFactory _xMCF) {
124*cdf0e10cSrcweir         m_xContext = _xContext;
125*cdf0e10cSrcweir         m_xMCF = _xMCF;
126*cdf0e10cSrcweir         createDialog(m_xMCF);
127*cdf0e10cSrcweir     }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir     public static void main(String args[]) {
131*cdf0e10cSrcweir         UnoDialogSample oUnoDialogSample = null;
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir         try {
134*cdf0e10cSrcweir             XComponentContext xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
135*cdf0e10cSrcweir             if(xContext != null )
136*cdf0e10cSrcweir                 System.out.println("Connected to a running office ...");
137*cdf0e10cSrcweir             XMultiComponentFactory xMCF = xContext.getServiceManager();
138*cdf0e10cSrcweir             oUnoDialogSample = new UnoDialogSample(xContext, xMCF);
139*cdf0e10cSrcweir             oUnoDialogSample.initialize( new String[] {"Height", "Moveable", "Name","PositionX","PositionY", "Step", "TabIndex","Title","Width"},
140*cdf0e10cSrcweir                     new Object[] { new Integer(380), Boolean.TRUE, "MyTestDialog", new Integer(102),new Integer(41), new Integer(0), new Short((short) 0), "OpenOffice", new Integer(380)});
141*cdf0e10cSrcweir             Object oFTHeaderModel = oUnoDialogSample.m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel");
142*cdf0e10cSrcweir             XMultiPropertySet xFTHeaderModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel);
143*cdf0e10cSrcweir             xFTHeaderModelMPSet.setPropertyValues(
144*cdf0e10cSrcweir                     new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Width"},
145*cdf0e10cSrcweir                     new Object[] { new Integer(8), "This code-sample demonstrates how to create various controls in a dialog", "HeaderLabel", new Integer(106), new Integer(6), new Integer(300)});
146*cdf0e10cSrcweir             // add the model to the NameContainer of the dialog model
147*cdf0e10cSrcweir             oUnoDialogSample.m_xDlgModelNameContainer.insertByName("Headerlabel", oFTHeaderModel);
148*cdf0e10cSrcweir             oUnoDialogSample.insertFixedText(oUnoDialogSample, 106, 18, 100, 0, "My ~Label");
149*cdf0e10cSrcweir             oUnoDialogSample.insertCurrencyField(oUnoDialogSample, 106, 30, 60);
150*cdf0e10cSrcweir             oUnoDialogSample.insertProgressBar(106, 44, 100, 100);
151*cdf0e10cSrcweir             oUnoDialogSample.insertHorizontalFixedLine(106, 58, 100, "My FixedLine");
152*cdf0e10cSrcweir             oUnoDialogSample.insertEditField(oUnoDialogSample, oUnoDialogSample, 106, 72, 60);
153*cdf0e10cSrcweir             oUnoDialogSample.insertTimeField(106, 96, 50, 0, 170000, 1000);
154*cdf0e10cSrcweir             oUnoDialogSample.insertDateField(oUnoDialogSample, 166, 96, 50);
155*cdf0e10cSrcweir             oUnoDialogSample.insertGroupBox(102, 124, 70, 100);
156*cdf0e10cSrcweir             oUnoDialogSample.insertPatternField(106, 136, 50);
157*cdf0e10cSrcweir             oUnoDialogSample.insertNumericField(106, 152, 50, 0.0, 1000.0, 500.0, 100.0, (short) 1);
158*cdf0e10cSrcweir             oUnoDialogSample.insertCheckBox(oUnoDialogSample, 106, 168, 150);
159*cdf0e10cSrcweir             oUnoDialogSample.insertRadioButtonGroup((short) 50, 130, 200, 150);
160*cdf0e10cSrcweir             oUnoDialogSample.insertListBox(106, 230, 50, 0, new String[]{"First Item", "Second Item"});
161*cdf0e10cSrcweir             oUnoDialogSample.insertComboBox(106, 250, 50);
162*cdf0e10cSrcweir             oUnoDialogSample.insertFormattedField(oUnoDialogSample, 106, 270, 100);
163*cdf0e10cSrcweir             oUnoDialogSample.insertVerticalScrollBar(oUnoDialogSample, 230, 230, 52);
164*cdf0e10cSrcweir             oUnoDialogSample.insertFileControl(oUnoDialogSample, 106, 290, 200 );
165*cdf0e10cSrcweir             oUnoDialogSample.insertButton(oUnoDialogSample, 106, 320, 50, "~Close dialog", (short) PushButtonType.OK_value);
166*cdf0e10cSrcweir             oUnoDialogSample.createWindowPeer();
167*cdf0e10cSrcweir             oUnoDialogSample.addRoadmap(oUnoDialogSample.getRoadmapItemStateChangeListener());
168*cdf0e10cSrcweir             oUnoDialogSample.insertRoadmapItem(0, true, "Introduction", 1);
169*cdf0e10cSrcweir             oUnoDialogSample.insertRoadmapItem(1, true, "Documents", 2);
170*cdf0e10cSrcweir             oUnoDialogSample.xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, oUnoDialogSample.m_xDialogControl);
171*cdf0e10cSrcweir             oUnoDialogSample.executeDialog();
172*cdf0e10cSrcweir         }catch( Exception e ) {
173*cdf0e10cSrcweir             System.err.println( e + e.getMessage());
174*cdf0e10cSrcweir             e.printStackTrace();
175*cdf0e10cSrcweir         } finally{
176*cdf0e10cSrcweir             //make sure always to dispose the component and free the memory!
177*cdf0e10cSrcweir             if (oUnoDialogSample != null){
178*cdf0e10cSrcweir                 if (oUnoDialogSample.m_xComponent != null){
179*cdf0e10cSrcweir                     oUnoDialogSample.m_xComponent.dispose();
180*cdf0e10cSrcweir                 }
181*cdf0e10cSrcweir             }
182*cdf0e10cSrcweir         }
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir         System.exit( 0 );
185*cdf0e10cSrcweir     }
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir     /**
189*cdf0e10cSrcweir      * @param _sKeyName
190*cdf0e10cSrcweir      * @return
191*cdf0e10cSrcweir      */
192*cdf0e10cSrcweir     public XNameAccess getRegistryKeyContent(String _sKeyName){
193*cdf0e10cSrcweir         try {
194*cdf0e10cSrcweir             Object oConfigProvider;
195*cdf0e10cSrcweir             PropertyValue[] aNodePath = new PropertyValue[1];
196*cdf0e10cSrcweir             oConfigProvider = m_xMCF.createInstanceWithContext("com.sun.star.configuration.ConfigurationProvider", this.m_xContext);
197*cdf0e10cSrcweir             aNodePath[0] = new PropertyValue();
198*cdf0e10cSrcweir             aNodePath[0].Name = "nodepath";
199*cdf0e10cSrcweir             aNodePath[0].Value = _sKeyName;
200*cdf0e10cSrcweir             XMultiServiceFactory xMSFConfig = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oConfigProvider);
201*cdf0e10cSrcweir             Object oNode = xMSFConfig.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", aNodePath);
202*cdf0e10cSrcweir             XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oNode);
203*cdf0e10cSrcweir             return xNameAccess;
204*cdf0e10cSrcweir         } catch (Exception exception) {
205*cdf0e10cSrcweir             exception.printStackTrace(System.out);
206*cdf0e10cSrcweir             return null;
207*cdf0e10cSrcweir         }
208*cdf0e10cSrcweir     }
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir     /**
212*cdf0e10cSrcweir      * @param _sRegistryPath the path a registryNode
213*cdf0e10cSrcweir      * @param _sImageName the name of the image
214*cdf0e10cSrcweir      */
215*cdf0e10cSrcweir     public String getImageUrl(String _sRegistryPath, String _sImageName) {
216*cdf0e10cSrcweir         String sImageUrl = "";
217*cdf0e10cSrcweir         try {
218*cdf0e10cSrcweir             // retrive the configuration node of the extension
219*cdf0e10cSrcweir             XNameAccess xNameAccess = getRegistryKeyContent(_sRegistryPath);
220*cdf0e10cSrcweir             if (xNameAccess != null){
221*cdf0e10cSrcweir                 if (xNameAccess.hasByName(_sImageName)){
222*cdf0e10cSrcweir                     // get the Image Url and process the Url by the macroexpander...
223*cdf0e10cSrcweir                     sImageUrl = (String) xNameAccess.getByName(_sImageName);
224*cdf0e10cSrcweir                     Object oMacroExpander = this.m_xContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander");
225*cdf0e10cSrcweir                     XMacroExpander xMacroExpander = (XMacroExpander) UnoRuntime.queryInterface(XMacroExpander.class, oMacroExpander);
226*cdf0e10cSrcweir                     sImageUrl = xMacroExpander.expandMacros(sImageUrl);
227*cdf0e10cSrcweir                     sImageUrl = sImageUrl.substring(new String("vnd.sun.star.expand:").length(), sImageUrl.length());
228*cdf0e10cSrcweir                     sImageUrl = sImageUrl.trim();
229*cdf0e10cSrcweir                     sImageUrl += "/" + _sImageName;
230*cdf0e10cSrcweir                 }
231*cdf0e10cSrcweir             }
232*cdf0e10cSrcweir         } catch (Exception ex) {
233*cdf0e10cSrcweir         /* perform individual exception handling here.
234*cdf0e10cSrcweir          * Possible exception types are:
235*cdf0e10cSrcweir          * com.sun.star.lang.IllegalArgumentException,
236*cdf0e10cSrcweir          * com.sun.star.lang.WrappedTargetException,
237*cdf0e10cSrcweir          */
238*cdf0e10cSrcweir             ex.printStackTrace(System.out);
239*cdf0e10cSrcweir         }
240*cdf0e10cSrcweir         return sImageUrl;
241*cdf0e10cSrcweir     }
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir     protected void createDialog(XMultiComponentFactory _xMCF) {
244*cdf0e10cSrcweir         try {
245*cdf0e10cSrcweir             Object oDialogModel =  _xMCF.createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", m_xContext);
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir             // The XMultiServiceFactory of the dialogmodel is needed to instantiate the controls...
248*cdf0e10cSrcweir             m_xMSFDialogModel = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDialogModel);
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir             // The named container is used to insert the created controls into...
251*cdf0e10cSrcweir             m_xDlgModelNameContainer = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, oDialogModel);
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir             // create the dialog...
254*cdf0e10cSrcweir             Object oUnoDialog = _xMCF.createInstanceWithContext("com.sun.star.awt.UnoControlDialog", m_xContext);
255*cdf0e10cSrcweir             m_xDialogControl = (XControl) UnoRuntime.queryInterface(XControl.class, oUnoDialog);
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir             // The scope of the control container is public...
258*cdf0e10cSrcweir             m_xDlgContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class, oUnoDialog);
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir             m_xTopWindow = (XTopWindow) UnoRuntime.queryInterface(XTopWindow.class, m_xDlgContainer);
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir             // link the dialog and its model...
263*cdf0e10cSrcweir             XControlModel xControlModel = (XControlModel) UnoRuntime.queryInterface(XControlModel.class, oDialogModel);
264*cdf0e10cSrcweir             m_xDialogControl.setModel(xControlModel);
265*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception exception) {
266*cdf0e10cSrcweir             exception.printStackTrace(System.out);
267*cdf0e10cSrcweir         }
268*cdf0e10cSrcweir     }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir     public short executeDialogWithembeddedExampleSnippets() throws com.sun.star.script.BasicErrorException {
273*cdf0e10cSrcweir         if (m_xWindowPeer == null){
274*cdf0e10cSrcweir             createWindowPeer();
275*cdf0e10cSrcweir         }
276*cdf0e10cSrcweir         addRoadmap(getRoadmapItemStateChangeListener());
277*cdf0e10cSrcweir         insertRoadmapItem(0, true, "Introduction", 1);
278*cdf0e10cSrcweir         insertRoadmapItem(1, true, "Documents", 2);
279*cdf0e10cSrcweir         xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, m_xDialogControl);
280*cdf0e10cSrcweir         return xDialog.execute();
281*cdf0e10cSrcweir     }
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     public short executeDialog() throws com.sun.star.script.BasicErrorException {
285*cdf0e10cSrcweir         if (m_xWindowPeer == null) {
286*cdf0e10cSrcweir             createWindowPeer();
287*cdf0e10cSrcweir         }
288*cdf0e10cSrcweir         xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, m_xDialogControl);
289*cdf0e10cSrcweir         m_xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, m_xDialogControl);
290*cdf0e10cSrcweir         return xDialog.execute();
291*cdf0e10cSrcweir     }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir     public XItemListener getRoadmapItemStateChangeListener(){
297*cdf0e10cSrcweir         return new RoadmapItemStateChangeListener(m_xMSFDialogModel);
298*cdf0e10cSrcweir     }
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir     public void initialize(String[] PropertyNames, Object[] PropertyValues) throws com.sun.star.script.BasicErrorException{
302*cdf0e10cSrcweir         try{
303*cdf0e10cSrcweir             XMultiPropertySet xMultiPropertySet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, m_xDlgModelNameContainer);
304*cdf0e10cSrcweir             xMultiPropertySet.setPropertyValues(PropertyNames, PropertyValues);
305*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
306*cdf0e10cSrcweir             ex.printStackTrace(System.out);
307*cdf0e10cSrcweir         }}
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir     /**
312*cdf0e10cSrcweir      * create a peer for this
313*cdf0e10cSrcweir      * dialog, using the given
314*cdf0e10cSrcweir      * peer as a parent.
315*cdf0e10cSrcweir      * @param parentPeer
316*cdf0e10cSrcweir      * @return
317*cdf0e10cSrcweir      * @throws java.lang.Exception
318*cdf0e10cSrcweir      */
319*cdf0e10cSrcweir     public XWindowPeer createWindowPeer(XWindowPeer _xWindowParentPeer) throws com.sun.star.script.BasicErrorException{
320*cdf0e10cSrcweir         try{
321*cdf0e10cSrcweir             if (_xWindowParentPeer == null){
322*cdf0e10cSrcweir                 XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, m_xDlgContainer);
323*cdf0e10cSrcweir                 xWindow.setVisible(false);
324*cdf0e10cSrcweir                 Object tk = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext);
325*cdf0e10cSrcweir                 XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, tk);
326*cdf0e10cSrcweir                 mxReschedule = (XReschedule) UnoRuntime.queryInterface(XReschedule.class, xToolkit);
327*cdf0e10cSrcweir                 m_xDialogControl.createPeer(xToolkit, _xWindowParentPeer);
328*cdf0e10cSrcweir                 m_xWindowPeer = m_xDialogControl.getPeer();
329*cdf0e10cSrcweir                 return m_xWindowPeer;
330*cdf0e10cSrcweir             }
331*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception exception) {
332*cdf0e10cSrcweir             exception.printStackTrace(System.out);
333*cdf0e10cSrcweir         }
334*cdf0e10cSrcweir         return null;
335*cdf0e10cSrcweir     }
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir     public void calculateDialogPosition(XWindow _xWindow) {
339*cdf0e10cSrcweir         Rectangle aFramePosSize = m_xModel.getCurrentController().getFrame().getComponentWindow().getPosSize();
340*cdf0e10cSrcweir         Rectangle CurPosSize = _xWindow.getPosSize();
341*cdf0e10cSrcweir         int WindowHeight = aFramePosSize.Height;
342*cdf0e10cSrcweir         int WindowWidth = aFramePosSize.Width;
343*cdf0e10cSrcweir         int DialogWidth = CurPosSize.Width;
344*cdf0e10cSrcweir         int DialogHeight = CurPosSize.Height;
345*cdf0e10cSrcweir         int iXPos = ((WindowWidth / 2) - (DialogWidth / 2));
346*cdf0e10cSrcweir         int iYPos = ((WindowHeight / 2) - (DialogHeight / 2));
347*cdf0e10cSrcweir         _xWindow.setPosSize(iXPos, iYPos, DialogWidth, DialogHeight, PosSize.POS);
348*cdf0e10cSrcweir     }
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir     /**
353*cdf0e10cSrcweir      * Creates a peer for this
354*cdf0e10cSrcweir      * dialog, using the active OO frame
355*cdf0e10cSrcweir      * as the parent window.
356*cdf0e10cSrcweir      * @return
357*cdf0e10cSrcweir      * @throws java.lang.Exception
358*cdf0e10cSrcweir      */
359*cdf0e10cSrcweir     public XWindowPeer createWindowPeer() throws com.sun.star.script.BasicErrorException{
360*cdf0e10cSrcweir         return createWindowPeer(null);
361*cdf0e10cSrcweir     }
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir     public void endExecute() {
364*cdf0e10cSrcweir         xDialog.endExecute();
365*cdf0e10cSrcweir     }
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir     public Object insertControlModel(String ServiceName, String sName, String[] sProperties, Object[] sValues) throws com.sun.star.script.BasicErrorException{
369*cdf0e10cSrcweir         try {
370*cdf0e10cSrcweir             Object oControlModel = m_xMSFDialogModel.createInstance(ServiceName);
371*cdf0e10cSrcweir             XMultiPropertySet xControlMultiPropertySet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oControlModel);
372*cdf0e10cSrcweir             xControlMultiPropertySet.setPropertyValues(sProperties, sValues);
373*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oControlModel);
374*cdf0e10cSrcweir             return oControlModel;
375*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception exception) {
376*cdf0e10cSrcweir             exception.printStackTrace(System.out);
377*cdf0e10cSrcweir             return null;
378*cdf0e10cSrcweir         }
379*cdf0e10cSrcweir     }
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir     public XFixedText insertFixedText(XMouseListener _xMouseListener, int _nPosX, int _nPosY, int _nWidth, int _nStep, String _sLabel){
383*cdf0e10cSrcweir         XFixedText xFixedText = null;
384*cdf0e10cSrcweir         try{
385*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
386*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "Label");
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
389*cdf0e10cSrcweir             Object oFTModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel");
390*cdf0e10cSrcweir             XMultiPropertySet xFTModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFTModel);
391*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir             xFTModelMPSet.setPropertyValues(
394*cdf0e10cSrcweir                     new String[] {"Height", "Name", "PositionX", "PositionY", "Step", "Width"},
395*cdf0e10cSrcweir                     new Object[] { new Integer(8), sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nStep), new Integer(_nWidth)});
396*cdf0e10cSrcweir             // add the model to the NameContainer of the dialog model
397*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oFTModel);
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir             // The following property may also be set with XMultiPropertySet but we
400*cdf0e10cSrcweir             // use the XPropertySet interface merely for reasons of demonstration
401*cdf0e10cSrcweir             XPropertySet xFTPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oFTModel);
402*cdf0e10cSrcweir             xFTPSet.setPropertyValue("Label", _sLabel);
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir             // reference the control by the Name
405*cdf0e10cSrcweir             XControl xFTControl = m_xDlgContainer.getControl(sName);
406*cdf0e10cSrcweir             xFixedText = (XFixedText) UnoRuntime.queryInterface(XFixedText.class, xFTControl);
407*cdf0e10cSrcweir             XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xFTControl);
408*cdf0e10cSrcweir             xWindow.addMouseListener(_xMouseListener);
409*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
410*cdf0e10cSrcweir             /* perform individual exception handling here.
411*cdf0e10cSrcweir              * Possible exception types are:
412*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
413*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
414*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
415*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
416*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
417*cdf0e10cSrcweir              * com.sun.star.uno.Exception
418*cdf0e10cSrcweir              */
419*cdf0e10cSrcweir             ex.printStackTrace(System.out);
420*cdf0e10cSrcweir         }
421*cdf0e10cSrcweir         return xFixedText;
422*cdf0e10cSrcweir     }
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir     public XTextComponent insertCurrencyField(XTextListener _xTextListener, int _nPositionX, int _nPositionY, int _nWidth){
426*cdf0e10cSrcweir         XTextComponent xTextComponent = null;
427*cdf0e10cSrcweir         try{
428*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
429*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "CurrencyField");
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
432*cdf0e10cSrcweir             Object oCFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlCurrencyFieldModel");
433*cdf0e10cSrcweir             XMultiPropertySet xCFModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oCFModel);
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
436*cdf0e10cSrcweir             xCFModelMPSet.setPropertyValues(
437*cdf0e10cSrcweir                     new String[] {"Height", "Name", "PositionX", "PositionY", "Width"},
438*cdf0e10cSrcweir                     new Object[] { new Integer(12), sName, new Integer(_nPositionX), new Integer(_nPositionY), new Integer(_nWidth)});
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir             // The controlmodel is not really available until inserted to the Dialog container
441*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oCFModel);
442*cdf0e10cSrcweir             XPropertySet xCFModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oCFModel);
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir             // The following properties may also be set with XMultiPropertySet but we
445*cdf0e10cSrcweir             // use the XPropertySet interface merely for reasons of demonstration
446*cdf0e10cSrcweir             xCFModelPSet.setPropertyValue("PrependCurrencySymbol", Boolean.TRUE);
447*cdf0e10cSrcweir             xCFModelPSet.setPropertyValue("CurrencySymbol", "$");
448*cdf0e10cSrcweir             xCFModelPSet.setPropertyValue("Value", new Double(2.93));
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir             // add a textlistener that is notified on each change of the controlvalue...
451*cdf0e10cSrcweir             Object oCFControl = m_xDlgContainer.getControl(sName);
452*cdf0e10cSrcweir             xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, oCFControl);
453*cdf0e10cSrcweir             xTextComponent.addTextListener(_xTextListener);
454*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
455*cdf0e10cSrcweir             /* perform individual exception handling here.
456*cdf0e10cSrcweir              * Possible exception types are:
457*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
458*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
459*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
460*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
461*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
462*cdf0e10cSrcweir              * com.sun.star.uno.Exception
463*cdf0e10cSrcweir              */
464*cdf0e10cSrcweir             ex.printStackTrace(System.out);
465*cdf0e10cSrcweir         }
466*cdf0e10cSrcweir         return xTextComponent;
467*cdf0e10cSrcweir     }
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir     public XPropertySet insertProgressBar(int _nPosX, int _nPosY, int _nWidth, int _nProgressMax){
472*cdf0e10cSrcweir         XPropertySet xPBModelPSet = null;
473*cdf0e10cSrcweir         try{
474*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
475*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "ProgressBar");
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
478*cdf0e10cSrcweir             Object oPBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlProgressBarModel");
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir             XMultiPropertySet xPBModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oPBModel);
481*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
482*cdf0e10cSrcweir             xPBModelMPSet.setPropertyValues(
483*cdf0e10cSrcweir                     new String[] {"Height", "Name", "PositionX", "PositionY", "Width"},
484*cdf0e10cSrcweir                     new Object[] { new Integer(8), sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nWidth)});
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir             // The controlmodel is not really available until inserted to the Dialog container
487*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oPBModel);
488*cdf0e10cSrcweir             xPBModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oPBModel);
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir             // The following properties may also be set with XMultiPropertySet but we
491*cdf0e10cSrcweir             // use the XPropertySet interface merely for reasons of demonstration
492*cdf0e10cSrcweir             xPBModelPSet.setPropertyValue("ProgressValueMin", new Integer(0));
493*cdf0e10cSrcweir             xPBModelPSet.setPropertyValue("ProgressValueMax", new Integer(_nProgressMax));
494*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
495*cdf0e10cSrcweir             /* perform individual exception handling here.
496*cdf0e10cSrcweir              * Possible exception types are:
497*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
498*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
499*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
500*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
501*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
502*cdf0e10cSrcweir              * com.sun.star.uno.Exception
503*cdf0e10cSrcweir              */
504*cdf0e10cSrcweir             ex.printStackTrace(System.out);
505*cdf0e10cSrcweir         }
506*cdf0e10cSrcweir         return xPBModelPSet;
507*cdf0e10cSrcweir     }
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir     public void insertHorizontalFixedLine(int _nPosX, int _nPosY, int _nWidth, String _sLabel){
512*cdf0e10cSrcweir         try{
513*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
514*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "FixedLine");
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
517*cdf0e10cSrcweir             Object oFLModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedLineModel");
518*cdf0e10cSrcweir             XMultiPropertySet xFLModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFLModel);
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
521*cdf0e10cSrcweir             xFLModelMPSet.setPropertyValues(
522*cdf0e10cSrcweir                     new String[] {"Height", "Name", "Orientation", "PositionX", "PositionY", "Width"},
523*cdf0e10cSrcweir                     new Object[] { new Integer(8), sName, new Integer(0), new Integer(_nPosX), new Integer(_nPosY), new Integer(_nWidth)});
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir             // The controlmodel is not really available until inserted to the Dialog container
526*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oFLModel);
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir             // The following property may also be set with XMultiPropertySet but we
529*cdf0e10cSrcweir             // use the XPropertySet interface merely for reasons of demonstration
530*cdf0e10cSrcweir             XPropertySet xFLPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oFLModel);
531*cdf0e10cSrcweir             xFLPSet.setPropertyValue("Label", _sLabel);
532*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
533*cdf0e10cSrcweir             /* perform individual exception handling here.
534*cdf0e10cSrcweir              * Possible exception types are:
535*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
536*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
537*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
538*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
539*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
540*cdf0e10cSrcweir              * com.sun.star.uno.Exception
541*cdf0e10cSrcweir              */
542*cdf0e10cSrcweir             ex.printStackTrace(System.out);
543*cdf0e10cSrcweir         }
544*cdf0e10cSrcweir     }
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir     public void insertGroupBox(int _nPosX, int _nPosY, int _nHeight, int _nWidth){
549*cdf0e10cSrcweir         try{
550*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
551*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "FrameControl");
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
554*cdf0e10cSrcweir             Object oGBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlGroupBoxModel");
555*cdf0e10cSrcweir             XMultiPropertySet xGBModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oGBModel);
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
558*cdf0e10cSrcweir             xGBModelMPSet.setPropertyValues(
559*cdf0e10cSrcweir                     new String[] {"Height", "Name", "PositionX", "PositionY", "Width"},
560*cdf0e10cSrcweir                     new Object[] { new Integer(_nHeight), sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nWidth)});
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir             // The controlmodel is not really available until inserted to the Dialog container
563*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oGBModel);
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir             // The following property may also be set with XMultiPropertySet but we
566*cdf0e10cSrcweir             // use the XPropertySet interface merely for reasons of demonstration
567*cdf0e10cSrcweir             XPropertySet xGBPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oGBModel);
568*cdf0e10cSrcweir             xGBPSet.setPropertyValue("Label", "~My GroupBox");
569*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
570*cdf0e10cSrcweir             /* perform individual exception handling here.
571*cdf0e10cSrcweir              * Possible exception types are:
572*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
573*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
574*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
575*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
576*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
577*cdf0e10cSrcweir              * com.sun.star.uno.Exception
578*cdf0e10cSrcweir              */
579*cdf0e10cSrcweir             ex.printStackTrace(System.out);
580*cdf0e10cSrcweir         }
581*cdf0e10cSrcweir     }
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir     public XTextComponent insertEditField(XTextListener _xTextListener, XFocusListener _xFocusListener, int _nPosX, int _nPosY, int _nWidth){
586*cdf0e10cSrcweir         XTextComponent xTextComponent = null;
587*cdf0e10cSrcweir         try{
588*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
589*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "TextField");
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
592*cdf0e10cSrcweir             Object oTFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlEditModel");
593*cdf0e10cSrcweir             XMultiPropertySet xTFModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oTFModel);
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
596*cdf0e10cSrcweir             xTFModelMPSet.setPropertyValues(
597*cdf0e10cSrcweir                     new String[] {"Height", "Name", "PositionX", "PositionY", "Text", "Width"},
598*cdf0e10cSrcweir                     new Object[] { new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), "MyText", new Integer(_nWidth)});
599*cdf0e10cSrcweir 
600*cdf0e10cSrcweir             // The controlmodel is not really available until inserted to the Dialog container
601*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oTFModel);
602*cdf0e10cSrcweir             XPropertySet xTFModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oTFModel);
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir             // The following property may also be set with XMultiPropertySet but we
605*cdf0e10cSrcweir             // use the XPropertySet interface merely for reasons of demonstration
606*cdf0e10cSrcweir             xTFModelPSet.setPropertyValue("EchoChar", new Short((short) '*'));
607*cdf0e10cSrcweir             XControl xTFControl = m_xDlgContainer.getControl(sName);
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir             // add a textlistener that is notified on each change of the controlvalue...
610*cdf0e10cSrcweir             xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, xTFControl);
611*cdf0e10cSrcweir             XWindow xTFWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xTFControl);
612*cdf0e10cSrcweir             xTFWindow.addFocusListener(_xFocusListener);
613*cdf0e10cSrcweir             xTextComponent.addTextListener(_xTextListener);
614*cdf0e10cSrcweir             xTFWindow.addKeyListener(this);
615*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
616*cdf0e10cSrcweir             /* perform individual exception handling here.
617*cdf0e10cSrcweir              * Possible exception types are:
618*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
619*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
620*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
621*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
622*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
623*cdf0e10cSrcweir              * com.sun.star.uno.Exception
624*cdf0e10cSrcweir              */
625*cdf0e10cSrcweir             ex.printStackTrace(System.out);
626*cdf0e10cSrcweir         }
627*cdf0e10cSrcweir         return xTextComponent;
628*cdf0e10cSrcweir     }
629*cdf0e10cSrcweir 
630*cdf0e10cSrcweir     public XPropertySet insertTimeField(int _nPosX, int _nPosY, int _nWidth, int _nTime, int _nTimeMin, int _nTimeMax){
631*cdf0e10cSrcweir         XPropertySet xTFModelPSet = null;
632*cdf0e10cSrcweir         try{
633*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
634*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "TimeField");
635*cdf0e10cSrcweir 
636*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
637*cdf0e10cSrcweir             Object oTFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlTimeFieldModel");
638*cdf0e10cSrcweir             XMultiPropertySet xTFModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oTFModel);
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
641*cdf0e10cSrcweir             xTFModelMPSet.setPropertyValues(
642*cdf0e10cSrcweir                     new String[] {"Height", "Name", "PositionX", "PositionY", "Spin", "Width"},
643*cdf0e10cSrcweir                     new Object[] { new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), Boolean.TRUE, new Integer(_nWidth)});
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir             // The controlmodel is not really available until inserted to the Dialog container
646*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oTFModel);
647*cdf0e10cSrcweir             xTFModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oTFModel);
648*cdf0e10cSrcweir 
649*cdf0e10cSrcweir             // The following properties may also be set with XMultiPropertySet but we
650*cdf0e10cSrcweir             // use the XPropertySet interface merely for reasons of demonstration
651*cdf0e10cSrcweir             xTFModelPSet.setPropertyValue("TimeFormat", new Short((short) 5));
652*cdf0e10cSrcweir             xTFModelPSet.setPropertyValue("TimeMin", new Integer(_nTimeMin));
653*cdf0e10cSrcweir             xTFModelPSet.setPropertyValue("TimeMax", new Integer(_nTimeMax));
654*cdf0e10cSrcweir             xTFModelPSet.setPropertyValue("Time", new Integer(_nTime));
655*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
656*cdf0e10cSrcweir             /* perform individual exception handling here.
657*cdf0e10cSrcweir              * Possible exception types are:
658*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
659*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
660*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
661*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
662*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
663*cdf0e10cSrcweir              * com.sun.star.uno.Exception
664*cdf0e10cSrcweir              */
665*cdf0e10cSrcweir             ex.printStackTrace(System.out);
666*cdf0e10cSrcweir         }
667*cdf0e10cSrcweir         return xTFModelPSet;
668*cdf0e10cSrcweir     }
669*cdf0e10cSrcweir 
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir     public XPropertySet insertDateField(XSpinListener _xSpinListener, int _nPosX, int _nPosY, int _nWidth){
673*cdf0e10cSrcweir         XPropertySet xDFModelPSet = null;
674*cdf0e10cSrcweir         try{
675*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
676*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "DateField");
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
679*cdf0e10cSrcweir             Object oDFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlDateFieldModel");
680*cdf0e10cSrcweir             XMultiPropertySet xDFModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oDFModel);
681*cdf0e10cSrcweir 
682*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
683*cdf0e10cSrcweir             xDFModelMPSet.setPropertyValues(
684*cdf0e10cSrcweir                     new String[] {"Dropdown", "Height", "Name", "PositionX", "PositionY", "Width"},
685*cdf0e10cSrcweir                     new Object[] {Boolean.TRUE, new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nWidth)});
686*cdf0e10cSrcweir 
687*cdf0e10cSrcweir             // The controlmodel is not really available until inserted to the Dialog container
688*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oDFModel);
689*cdf0e10cSrcweir             xDFModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oDFModel);
690*cdf0e10cSrcweir 
691*cdf0e10cSrcweir             // The following properties may also be set with XMultiPropertySet but we
692*cdf0e10cSrcweir             // use the XPropertySet interface merely for reasons of demonstration
693*cdf0e10cSrcweir             xDFModelPSet.setPropertyValue("DateFormat", new Short((short) 7));
694*cdf0e10cSrcweir             xDFModelPSet.setPropertyValue("DateMin", new Integer(20070401));
695*cdf0e10cSrcweir             xDFModelPSet.setPropertyValue("DateMax", new Integer(20070501));
696*cdf0e10cSrcweir             xDFModelPSet.setPropertyValue("Date", new Integer(20000415));
697*cdf0e10cSrcweir             Object oDFControl = m_xDlgContainer.getControl(sName);
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir             // add a SpinListener that is notified on each change of the controlvalue...
700*cdf0e10cSrcweir             XSpinField xSpinField = (XSpinField) UnoRuntime.queryInterface(XSpinField.class, oDFControl);
701*cdf0e10cSrcweir             xSpinField.addSpinListener(_xSpinListener);
702*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
703*cdf0e10cSrcweir             /* perform individual exception handling here.
704*cdf0e10cSrcweir              * Possible exception types are:
705*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
706*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
707*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
708*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
709*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
710*cdf0e10cSrcweir              * com.sun.star.uno.Exception
711*cdf0e10cSrcweir              */
712*cdf0e10cSrcweir             ex.printStackTrace(System.out);
713*cdf0e10cSrcweir         }
714*cdf0e10cSrcweir         return xDFModelPSet;
715*cdf0e10cSrcweir     }
716*cdf0e10cSrcweir 
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir     public XPropertySet insertPatternField(int _nPosX, int _nPosY, int _nWidth){
719*cdf0e10cSrcweir         XPropertySet xPFModelPSet = null;
720*cdf0e10cSrcweir         try{
721*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
722*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "PatternField");
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
725*cdf0e10cSrcweir             Object oPFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlPatternFieldModel");
726*cdf0e10cSrcweir             XMultiPropertySet xPFModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oPFModel);
727*cdf0e10cSrcweir 
728*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
729*cdf0e10cSrcweir             xPFModelMPSet.setPropertyValues(
730*cdf0e10cSrcweir                     new String[] {"Height", "Name", "PositionX", "PositionY", "Width"},
731*cdf0e10cSrcweir                     new Object[] { new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nWidth)});
732*cdf0e10cSrcweir 
733*cdf0e10cSrcweir             // The controlmodel is not really available until inserted to the Dialog container
734*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oPFModel);
735*cdf0e10cSrcweir             xPFModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oPFModel);
736*cdf0e10cSrcweir 
737*cdf0e10cSrcweir             // The following properties may also be set with XMultiPropertySet but we
738*cdf0e10cSrcweir             // use the XPropertySet interface merely for reasons of demonstration
739*cdf0e10cSrcweir             xPFModelPSet.setPropertyValue("LiteralMask", "__.05.2007");
740*cdf0e10cSrcweir             // Allow only numbers for the first two digits...
741*cdf0e10cSrcweir             xPFModelPSet.setPropertyValue("EditMask", "NNLLLLLLLL");
742*cdf0e10cSrcweir             // verify the user input immediately...
743*cdf0e10cSrcweir             xPFModelPSet.setPropertyValue("StrictFormat", Boolean.TRUE);
744*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
745*cdf0e10cSrcweir             /* perform individual exception handling here.
746*cdf0e10cSrcweir              * Possible exception types are:
747*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
748*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
749*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
750*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
751*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
752*cdf0e10cSrcweir              * com.sun.star.uno.Exception
753*cdf0e10cSrcweir              */
754*cdf0e10cSrcweir             ex.printStackTrace(System.out);
755*cdf0e10cSrcweir         }
756*cdf0e10cSrcweir         return xPFModelPSet;
757*cdf0e10cSrcweir     }
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir 
760*cdf0e10cSrcweir     public XPropertySet insertNumericField( int _nPosX, int _nPosY, int _nWidth,
761*cdf0e10cSrcweir             double _fValueMin, double _fValueMax, double _fValue,
762*cdf0e10cSrcweir             double _fValueStep, short _nDecimalAccuracy){
763*cdf0e10cSrcweir         XPropertySet xNFModelPSet = null;
764*cdf0e10cSrcweir         try{
765*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
766*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "NumericField");
767*cdf0e10cSrcweir 
768*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
769*cdf0e10cSrcweir             Object oNFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlNumericFieldModel");
770*cdf0e10cSrcweir             XMultiPropertySet xNFModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oNFModel);
771*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
772*cdf0e10cSrcweir             xNFModelMPSet.setPropertyValues(
773*cdf0e10cSrcweir                     new String[] {"Height", "Name", "PositionX", "PositionY", "Spin", "StrictFormat", "Width"},
774*cdf0e10cSrcweir                     new Object[] { new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), Boolean.TRUE, Boolean.TRUE, new Integer(_nWidth)});
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir             // The controlmodel is not really available until inserted to the Dialog container
777*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oNFModel);
778*cdf0e10cSrcweir             xNFModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oNFModel);
779*cdf0e10cSrcweir             // The following properties may also be set with XMultiPropertySet but we
780*cdf0e10cSrcweir             // use the XPropertySet interface merely for reasons of demonstration
781*cdf0e10cSrcweir             xNFModelPSet.setPropertyValue("ValueMin", new Double(_fValueMin));
782*cdf0e10cSrcweir             xNFModelPSet.setPropertyValue("ValueMax", new Double(_fValueMax));
783*cdf0e10cSrcweir             xNFModelPSet.setPropertyValue("Value", new Double(_fValue));
784*cdf0e10cSrcweir             xNFModelPSet.setPropertyValue("ValueStep", new Double(_fValueStep));
785*cdf0e10cSrcweir             xNFModelPSet.setPropertyValue("ShowThousandsSeparator", Boolean.TRUE);
786*cdf0e10cSrcweir             xNFModelPSet.setPropertyValue("DecimalAccuracy", new Short(_nDecimalAccuracy));
787*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
788*cdf0e10cSrcweir             /* perform individual exception handling here.
789*cdf0e10cSrcweir              * Possible exception types are:
790*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
791*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
792*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
793*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
794*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
795*cdf0e10cSrcweir              * com.sun.star.uno.Exception
796*cdf0e10cSrcweir              */
797*cdf0e10cSrcweir             ex.printStackTrace(System.out);
798*cdf0e10cSrcweir         }
799*cdf0e10cSrcweir         return xNFModelPSet;
800*cdf0e10cSrcweir     }
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir 
804*cdf0e10cSrcweir     public XPropertySet insertVerticalScrollBar(XAdjustmentListener _xAdjustmentListener, int _nPosX, int _nPosY, int _nHeight){
805*cdf0e10cSrcweir         XPropertySet xSBModelPSet = null;
806*cdf0e10cSrcweir         try{
807*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
808*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "ScrollBar");
809*cdf0e10cSrcweir 
810*cdf0e10cSrcweir             Integer NOrientation = new Integer(com.sun.star.awt.ScrollBarOrientation.VERTICAL);
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
813*cdf0e10cSrcweir             Object oSBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlScrollBarModel");
814*cdf0e10cSrcweir             XMultiPropertySet xSBModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oSBModel);
815*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
816*cdf0e10cSrcweir             xSBModelMPSet.setPropertyValues(
817*cdf0e10cSrcweir                     new String[] {"Height", "Name", "Orientation", "PositionX", "PositionY", "Width"},
818*cdf0e10cSrcweir                     new Object[] { new Integer(_nHeight), sName, NOrientation, new Integer(_nPosX), new Integer(_nPosY), new Integer(8)});
819*cdf0e10cSrcweir 
820*cdf0e10cSrcweir             // The controlmodel is not really available until inserted to the Dialog container
821*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oSBModel);
822*cdf0e10cSrcweir 
823*cdf0e10cSrcweir             xSBModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oSBModel);
824*cdf0e10cSrcweir             // The following properties may also be set with XMultiPropertySet but we
825*cdf0e10cSrcweir             // use the XPropertySet interface merely for reasons of demonstration
826*cdf0e10cSrcweir             xSBModelPSet.setPropertyValue("ScrollValueMin", new Integer(0));
827*cdf0e10cSrcweir             xSBModelPSet.setPropertyValue("ScrollValueMax", new Integer(100));
828*cdf0e10cSrcweir             xSBModelPSet.setPropertyValue("ScrollValue", new Integer(5));
829*cdf0e10cSrcweir             xSBModelPSet.setPropertyValue("LineIncrement", new Integer(2));
830*cdf0e10cSrcweir             xSBModelPSet.setPropertyValue("BlockIncrement", new Integer(10));
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir             // Add an Adjustment that will listen to changes of the scrollbar...
833*cdf0e10cSrcweir             XControl xSBControl = m_xDlgContainer.getControl(sName);
834*cdf0e10cSrcweir             XScrollBar xScrollBar = (XScrollBar) UnoRuntime.queryInterface(XScrollBar.class, xSBControl);
835*cdf0e10cSrcweir             xScrollBar.addAdjustmentListener(_xAdjustmentListener);
836*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
837*cdf0e10cSrcweir             /* perform individual exception handling here.
838*cdf0e10cSrcweir              * Possible exception types are:
839*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
840*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
841*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
842*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
843*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
844*cdf0e10cSrcweir              * com.sun.star.uno.Exception
845*cdf0e10cSrcweir              */
846*cdf0e10cSrcweir             ex.printStackTrace(System.out);
847*cdf0e10cSrcweir         }
848*cdf0e10cSrcweir         return xSBModelPSet;
849*cdf0e10cSrcweir     }
850*cdf0e10cSrcweir 
851*cdf0e10cSrcweir 
852*cdf0e10cSrcweir     /** makes a String unique by appending a numerical suffix
853*cdf0e10cSrcweir      * @param _xElementContainer the com.sun.star.container.XNameAccess container
854*cdf0e10cSrcweir      * that the new Element is going to be inserted to
855*cdf0e10cSrcweir      * @param _sElementName the StemName of the Element
856*cdf0e10cSrcweir      */
857*cdf0e10cSrcweir     public static String createUniqueName(XNameAccess _xElementContainer, String _sElementName) {
858*cdf0e10cSrcweir         boolean bElementexists = true;
859*cdf0e10cSrcweir         int i = 1;
860*cdf0e10cSrcweir         String sIncSuffix = "";
861*cdf0e10cSrcweir         String BaseName = _sElementName;
862*cdf0e10cSrcweir         while (bElementexists) {
863*cdf0e10cSrcweir             bElementexists = _xElementContainer.hasByName(_sElementName);
864*cdf0e10cSrcweir             if (bElementexists) {
865*cdf0e10cSrcweir                 i += 1;
866*cdf0e10cSrcweir                 _sElementName = BaseName + Integer.toString(i);
867*cdf0e10cSrcweir             }
868*cdf0e10cSrcweir         }
869*cdf0e10cSrcweir         return _sElementName;
870*cdf0e10cSrcweir     }
871*cdf0e10cSrcweir 
872*cdf0e10cSrcweir 
873*cdf0e10cSrcweir     public XCheckBox insertCheckBox(XItemListener _xItemListener, int _nPosX, int _nPosY, int _nWidth){
874*cdf0e10cSrcweir         XCheckBox xCheckBox = null;
875*cdf0e10cSrcweir         try{
876*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
877*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "CheckBox");
878*cdf0e10cSrcweir 
879*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
880*cdf0e10cSrcweir             Object oCBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlCheckBoxModel");
881*cdf0e10cSrcweir 
882*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
883*cdf0e10cSrcweir             XMultiPropertySet xCBMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oCBModel);
884*cdf0e10cSrcweir             xCBMPSet.setPropertyValues(
885*cdf0e10cSrcweir                     new String[]  {"Height", "Label", "Name", "PositionX", "PositionY", "Width" } ,
886*cdf0e10cSrcweir                     new Object[] {new Integer(8), "~Include page number", sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nWidth)});
887*cdf0e10cSrcweir 
888*cdf0e10cSrcweir             // The following property may also be set with XMultiPropertySet but we
889*cdf0e10cSrcweir             // use the XPropertySet interface merely for reasons of demonstration
890*cdf0e10cSrcweir             XPropertySet xCBModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xCBMPSet);
891*cdf0e10cSrcweir             xCBModelPSet.setPropertyValue("TriState", Boolean.TRUE);
892*cdf0e10cSrcweir             xCBModelPSet.setPropertyValue("State", new Short((short) 1));
893*cdf0e10cSrcweir 
894*cdf0e10cSrcweir             // add the model to the NameContainer of the dialog model
895*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oCBModel);
896*cdf0e10cSrcweir             XControl xCBControl = m_xDlgContainer.getControl(sName);
897*cdf0e10cSrcweir             xCheckBox = (XCheckBox) UnoRuntime.queryInterface(XCheckBox.class, xCBControl);
898*cdf0e10cSrcweir             // An ActionListener will be notified on the activation of the button...
899*cdf0e10cSrcweir             xCheckBox.addItemListener(_xItemListener);
900*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
901*cdf0e10cSrcweir             /* perform individual exception handling here.
902*cdf0e10cSrcweir              * Possible exception types are:
903*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
904*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
905*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
906*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
907*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
908*cdf0e10cSrcweir              * com.sun.star.uno.Exception
909*cdf0e10cSrcweir              */
910*cdf0e10cSrcweir             ex.printStackTrace(System.out);
911*cdf0e10cSrcweir         }
912*cdf0e10cSrcweir         return xCheckBox;
913*cdf0e10cSrcweir     }
914*cdf0e10cSrcweir 
915*cdf0e10cSrcweir 
916*cdf0e10cSrcweir 
917*cdf0e10cSrcweir 
918*cdf0e10cSrcweir     public void insertRadioButtonGroup(short _nTabIndex, int _nPosX, int _nPosY, int _nWidth){
919*cdf0e10cSrcweir         try{
920*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
921*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "OptionButton");
922*cdf0e10cSrcweir 
923*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
924*cdf0e10cSrcweir             Object oRBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlRadioButtonModel");
925*cdf0e10cSrcweir             XMultiPropertySet xRBMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oRBModel);
926*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
927*cdf0e10cSrcweir             xRBMPSet.setPropertyValues(
928*cdf0e10cSrcweir                     new String[]  {"Height", "Label", "Name", "PositionX", "PositionY", "State", "TabIndex", "Width" } ,
929*cdf0e10cSrcweir                     new Object[] {new Integer(8), "~First Option", sName, new Integer(_nPosX), new Integer(_nPosY), new Short((short) 1), new Short(_nTabIndex++),new Integer(_nWidth)});
930*cdf0e10cSrcweir             // add the model to the NameContainer of the dialog model
931*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oRBModel);
932*cdf0e10cSrcweir 
933*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
934*cdf0e10cSrcweir             sName = createUniqueName(m_xDlgModelNameContainer, "OptionButton");
935*cdf0e10cSrcweir 
936*cdf0e10cSrcweir             oRBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlRadioButtonModel");
937*cdf0e10cSrcweir             xRBMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oRBModel);
938*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
939*cdf0e10cSrcweir             xRBMPSet.setPropertyValues(
940*cdf0e10cSrcweir                     new String[]  {"Height", "Label", "Name", "PositionX", "PositionY", "TabIndex", "Width" } ,
941*cdf0e10cSrcweir                     new Object[] {new Integer(8), "~Second Option", sName, new Integer(130), new Integer(214), new Short(_nTabIndex), new Integer(150)});
942*cdf0e10cSrcweir             // add the model to the NameContainer of the dialog model
943*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oRBModel);
944*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
945*cdf0e10cSrcweir             /* perform individual exception handling here.
946*cdf0e10cSrcweir              * Possible exception types are:
947*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
948*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
949*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
950*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
951*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
952*cdf0e10cSrcweir              * com.sun.star.uno.Exception
953*cdf0e10cSrcweir              */
954*cdf0e10cSrcweir             ex.printStackTrace(System.out);
955*cdf0e10cSrcweir         }
956*cdf0e10cSrcweir     }
957*cdf0e10cSrcweir 
958*cdf0e10cSrcweir 
959*cdf0e10cSrcweir     public XListBox insertListBox(int _nPosX, int _nPosY, int _nWidth, int _nStep, String[] _sStringItemList){
960*cdf0e10cSrcweir         XListBox xListBox = null;
961*cdf0e10cSrcweir         try{
962*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
963*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "ListBox");
964*cdf0e10cSrcweir 
965*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
966*cdf0e10cSrcweir             Object oListBoxModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlListBoxModel");
967*cdf0e10cSrcweir             XMultiPropertySet xLBModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oListBoxModel);
968*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
969*cdf0e10cSrcweir             xLBModelMPSet.setPropertyValues(
970*cdf0e10cSrcweir                     new String[]  {"Dropdown", "Height", "Name", "PositionX", "PositionY", "Step", "StringItemList", "Width" } ,
971*cdf0e10cSrcweir                     new Object[] {Boolean.TRUE, new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nStep), _sStringItemList, new Integer(_nWidth)});
972*cdf0e10cSrcweir             // The following property may also be set with XMultiPropertySet but we
973*cdf0e10cSrcweir             // use the XPropertySet interface merely for reasons of demonstration
974*cdf0e10cSrcweir             XPropertySet xLBModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xLBModelMPSet);
975*cdf0e10cSrcweir             xLBModelPSet.setPropertyValue("MultiSelection", Boolean.TRUE);
976*cdf0e10cSrcweir             short[] nSelItems = new short[] {(short) 1, (short) 3};
977*cdf0e10cSrcweir             xLBModelPSet.setPropertyValue("SelectedItems", nSelItems);
978*cdf0e10cSrcweir             // add the model to the NameContainer of the dialog model
979*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, xLBModelMPSet);
980*cdf0e10cSrcweir             XControl xControl = m_xDlgContainer.getControl(sName);
981*cdf0e10cSrcweir             // retrieve a ListBox that is more convenient to work with than the Model of the ListBox...
982*cdf0e10cSrcweir             xListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, xControl);
983*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
984*cdf0e10cSrcweir             /* perform individual exception handling here.
985*cdf0e10cSrcweir              * Possible exception types are:
986*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
987*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
988*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
989*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
990*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
991*cdf0e10cSrcweir              * com.sun.star.uno.Exception
992*cdf0e10cSrcweir              */
993*cdf0e10cSrcweir             ex.printStackTrace(System.out);
994*cdf0e10cSrcweir         }
995*cdf0e10cSrcweir         return xListBox;
996*cdf0e10cSrcweir     }
997*cdf0e10cSrcweir 
998*cdf0e10cSrcweir 
999*cdf0e10cSrcweir     public XComboBox insertComboBox(int _nPosX, int _nPosY, int _nWidth){
1000*cdf0e10cSrcweir         XComboBox xComboBox = null;
1001*cdf0e10cSrcweir         try{
1002*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
1003*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "ComboBox");
1004*cdf0e10cSrcweir 
1005*cdf0e10cSrcweir             String[] sStringItemList = new String[]{"First Entry", "Second Entry", "Third Entry", "Fourth Entry"};
1006*cdf0e10cSrcweir 
1007*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
1008*cdf0e10cSrcweir             Object oComboBoxModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlComboBoxModel");
1009*cdf0e10cSrcweir             XMultiPropertySet xCbBModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oComboBoxModel);
1010*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
1011*cdf0e10cSrcweir             xCbBModelMPSet.setPropertyValues(
1012*cdf0e10cSrcweir                     new String[]  {"Dropdown", "Height", "Name", "PositionX", "PositionY", "StringItemList", "Width" } ,
1013*cdf0e10cSrcweir                     new Object[] {Boolean.TRUE, new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), sStringItemList, new Integer(_nWidth)});
1014*cdf0e10cSrcweir 
1015*cdf0e10cSrcweir             // The following property may also be set with XMultiPropertySet but we
1016*cdf0e10cSrcweir             // use the XPropertySet interface merely for reasons of demonstration
1017*cdf0e10cSrcweir             XPropertySet xCbBModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xCbBModelMPSet);
1018*cdf0e10cSrcweir             xCbBModelPSet.setPropertyValue("MaxTextLen", new Short((short) 10));
1019*cdf0e10cSrcweir             xCbBModelPSet.setPropertyValue("ReadOnly", Boolean.FALSE);
1020*cdf0e10cSrcweir 
1021*cdf0e10cSrcweir             // add the model to the NameContainer of the dialog model
1022*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, xCbBModelMPSet);
1023*cdf0e10cSrcweir             XControl xControl = m_xDlgContainer.getControl(sName);
1024*cdf0e10cSrcweir 
1025*cdf0e10cSrcweir             // retrieve a ListBox that is more convenient to work with than the Model of the ListBox...
1026*cdf0e10cSrcweir             xComboBox = (XComboBox) UnoRuntime.queryInterface(XComboBox.class, xControl);
1027*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
1028*cdf0e10cSrcweir             /* perform individual exception handling here.
1029*cdf0e10cSrcweir              * Possible exception types are:
1030*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
1031*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
1032*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
1033*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
1034*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
1035*cdf0e10cSrcweir              * com.sun.star.uno.Exception
1036*cdf0e10cSrcweir              */
1037*cdf0e10cSrcweir             ex.printStackTrace(System.out);
1038*cdf0e10cSrcweir         }
1039*cdf0e10cSrcweir         return xComboBox;
1040*cdf0e10cSrcweir     }
1041*cdf0e10cSrcweir 
1042*cdf0e10cSrcweir 
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir     public XPropertySet insertFormattedField(XSpinListener _xSpinListener, int _nPosX, int _nPosY, int _nWidth){
1045*cdf0e10cSrcweir         XPropertySet xFFModelPSet = null;
1046*cdf0e10cSrcweir         try{
1047*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
1048*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "FormattedField");
1049*cdf0e10cSrcweir 
1050*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
1051*cdf0e10cSrcweir             Object oFFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFormattedFieldModel");
1052*cdf0e10cSrcweir             XMultiPropertySet xFFModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFFModel);
1053*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
1054*cdf0e10cSrcweir             xFFModelMPSet.setPropertyValues(
1055*cdf0e10cSrcweir                     new String[] {"EffectiveValue", "Height",  "Name", "PositionX", "PositionY", "StrictFormat", "Spin", "Width"},
1056*cdf0e10cSrcweir                     new Object[] { new Double(12348), new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), Boolean.TRUE, Boolean.TRUE, new Integer(_nWidth)});
1057*cdf0e10cSrcweir 
1058*cdf0e10cSrcweir             xFFModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oFFModel);
1059*cdf0e10cSrcweir             // to define a numberformat you always need a locale...
1060*cdf0e10cSrcweir             com.sun.star.lang.Locale aLocale = new com.sun.star.lang.Locale();
1061*cdf0e10cSrcweir             aLocale.Country = "US";
1062*cdf0e10cSrcweir             aLocale.Language = "en";
1063*cdf0e10cSrcweir             // this Format is only compliant to the english locale!
1064*cdf0e10cSrcweir             String sFormatString = "NNNNMMMM DD, YYYY";
1065*cdf0e10cSrcweir 
1066*cdf0e10cSrcweir             // a NumberFormatsSupplier has to be created first "in the open countryside"...
1067*cdf0e10cSrcweir             Object oNumberFormatsSupplier = m_xMCF.createInstanceWithContext("com.sun.star.util.NumberFormatsSupplier", m_xContext);
1068*cdf0e10cSrcweir             XNumberFormatsSupplier xNumberFormatsSupplier = (XNumberFormatsSupplier) UnoRuntime.queryInterface(XNumberFormatsSupplier.class, oNumberFormatsSupplier);
1069*cdf0e10cSrcweir             XNumberFormats xNumberFormats = xNumberFormatsSupplier.getNumberFormats();
1070*cdf0e10cSrcweir             // is the numberformat already defined?
1071*cdf0e10cSrcweir             int nFormatKey = xNumberFormats.queryKey(sFormatString, aLocale, true);
1072*cdf0e10cSrcweir             if (nFormatKey == -1){
1073*cdf0e10cSrcweir                 // if not then add it to the NumberFormatsSupplier
1074*cdf0e10cSrcweir                 nFormatKey = xNumberFormats.addNew(sFormatString, aLocale);
1075*cdf0e10cSrcweir             }
1076*cdf0e10cSrcweir 
1077*cdf0e10cSrcweir             // The following property may also be set with XMultiPropertySet but we
1078*cdf0e10cSrcweir             // use the XPropertySet interface merely for reasons of demonstration
1079*cdf0e10cSrcweir             xFFModelPSet.setPropertyValue("FormatsSupplier", xNumberFormatsSupplier);
1080*cdf0e10cSrcweir             xFFModelPSet.setPropertyValue("FormatKey", new Integer(nFormatKey));
1081*cdf0e10cSrcweir 
1082*cdf0e10cSrcweir             // The controlmodel is not really available until inserted to the Dialog container
1083*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oFFModel);
1084*cdf0e10cSrcweir 
1085*cdf0e10cSrcweir             // finally we add a Spin-Listener to the control
1086*cdf0e10cSrcweir             XControl xFFControl = m_xDlgContainer.getControl(sName);
1087*cdf0e10cSrcweir             // add a SpinListener that is notified on each change of the controlvalue...
1088*cdf0e10cSrcweir             XSpinField xSpinField = (XSpinField) UnoRuntime.queryInterface(XSpinField.class, xFFControl);
1089*cdf0e10cSrcweir             xSpinField.addSpinListener(_xSpinListener);
1090*cdf0e10cSrcweir 
1091*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
1092*cdf0e10cSrcweir             /* perform individual exception handling here.
1093*cdf0e10cSrcweir              * Possible exception types are:
1094*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
1095*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
1096*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
1097*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
1098*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
1099*cdf0e10cSrcweir              * com.sun.star.uno.Exception
1100*cdf0e10cSrcweir              */
1101*cdf0e10cSrcweir             ex.printStackTrace(System.out);
1102*cdf0e10cSrcweir         }
1103*cdf0e10cSrcweir         return xFFModelPSet;
1104*cdf0e10cSrcweir     }
1105*cdf0e10cSrcweir 
1106*cdf0e10cSrcweir     public void convertUnits(){
1107*cdf0e10cSrcweir     //    iXPixelFactor = (int) (100000/xDevice.getInfo().PixelPerMeterX);
1108*cdf0e10cSrcweir     }
1109*cdf0e10cSrcweir 
1110*cdf0e10cSrcweir 
1111*cdf0e10cSrcweir     public XTextComponent insertFileControl(XTextListener _xTextListener, int _nPosX, int _nPosY, int _nWidth){
1112*cdf0e10cSrcweir         XTextComponent xTextComponent = null;
1113*cdf0e10cSrcweir         try{
1114*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
1115*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "FileControl");
1116*cdf0e10cSrcweir 
1117*cdf0e10cSrcweir             // retrieve the configured Work path...
1118*cdf0e10cSrcweir             Object oPathSettings = m_xMCF.createInstanceWithContext("com.sun.star.util.PathSettings",m_xContext);
1119*cdf0e10cSrcweir             XPropertySet xPropertySet = (XPropertySet) com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, oPathSettings);
1120*cdf0e10cSrcweir             String sWorkUrl = (String) xPropertySet.getPropertyValue("Work");
1121*cdf0e10cSrcweir 
1122*cdf0e10cSrcweir             // convert the Url to a system path that is "human readable"...
1123*cdf0e10cSrcweir             Object oFCProvider = m_xMCF.createInstanceWithContext("com.sun.star.ucb.FileContentProvider", m_xContext);
1124*cdf0e10cSrcweir             XFileIdentifierConverter xFileIdentifierConverter = (XFileIdentifierConverter) UnoRuntime.queryInterface(XFileIdentifierConverter.class, oFCProvider);
1125*cdf0e10cSrcweir             String sSystemWorkPath = xFileIdentifierConverter.getSystemPathFromFileURL(sWorkUrl);
1126*cdf0e10cSrcweir 
1127*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
1128*cdf0e10cSrcweir             Object oFCModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFileControlModel");
1129*cdf0e10cSrcweir 
1130*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
1131*cdf0e10cSrcweir             XMultiPropertySet xFCModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFCModel);
1132*cdf0e10cSrcweir             xFCModelMPSet.setPropertyValues(
1133*cdf0e10cSrcweir                     new String[] {"Height", "Name", "PositionX", "PositionY", "Text", "Width"},
1134*cdf0e10cSrcweir                     new Object[] { new Integer(14), sName, new Integer(_nPosX), new Integer(_nPosY), sSystemWorkPath, new Integer(_nWidth)});
1135*cdf0e10cSrcweir 
1136*cdf0e10cSrcweir             // The controlmodel is not really available until inserted to the Dialog container
1137*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oFCModel);
1138*cdf0e10cSrcweir             XPropertySet xFCModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oFCModel);
1139*cdf0e10cSrcweir 
1140*cdf0e10cSrcweir             // add a textlistener that is notified on each change of the controlvalue...
1141*cdf0e10cSrcweir             XControl xFCControl = m_xDlgContainer.getControl(sName);
1142*cdf0e10cSrcweir             xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, xFCControl);
1143*cdf0e10cSrcweir             XWindow xFCWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xFCControl);
1144*cdf0e10cSrcweir             xTextComponent.addTextListener(_xTextListener);
1145*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
1146*cdf0e10cSrcweir             /* perform individual exception handling here.
1147*cdf0e10cSrcweir              * Possible exception types are:
1148*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
1149*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
1150*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
1151*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
1152*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
1153*cdf0e10cSrcweir              * com.sun.star.uno.Exception
1154*cdf0e10cSrcweir              */
1155*cdf0e10cSrcweir             ex.printStackTrace(System.out);
1156*cdf0e10cSrcweir         }
1157*cdf0e10cSrcweir         return xTextComponent;
1158*cdf0e10cSrcweir     }
1159*cdf0e10cSrcweir 
1160*cdf0e10cSrcweir 
1161*cdf0e10cSrcweir     public XButton insertButton(XActionListener _xActionListener, int _nPosX, int _nPosY, int _nWidth, String _sLabel, short _nPushButtonType){
1162*cdf0e10cSrcweir         XButton xButton = null;
1163*cdf0e10cSrcweir         try{
1164*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
1165*cdf0e10cSrcweir             String sName = createUniqueName(m_xDlgModelNameContainer, "CommandButton");
1166*cdf0e10cSrcweir 
1167*cdf0e10cSrcweir             // create a controlmodel at the multiservicefactory of the dialog model...
1168*cdf0e10cSrcweir             Object oButtonModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlButtonModel");
1169*cdf0e10cSrcweir             XMultiPropertySet xButtonMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oButtonModel);
1170*cdf0e10cSrcweir             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
1171*cdf0e10cSrcweir             xButtonMPSet.setPropertyValues(
1172*cdf0e10cSrcweir                     new String[]  {"Height", "Label", "Name", "PositionX", "PositionY", "PushButtonType", "Width" } ,
1173*cdf0e10cSrcweir                     new Object[] {new Integer(14), _sLabel, sName, new Integer(_nPosX), new Integer(_nPosY), new Short(_nPushButtonType), new Integer(_nWidth)});
1174*cdf0e10cSrcweir 
1175*cdf0e10cSrcweir             // add the model to the NameContainer of the dialog model
1176*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sName, oButtonModel);
1177*cdf0e10cSrcweir             XControl xButtonControl = m_xDlgContainer.getControl(sName);
1178*cdf0e10cSrcweir             xButton = (XButton) UnoRuntime.queryInterface(XButton.class, xButtonControl);
1179*cdf0e10cSrcweir             // An ActionListener will be notified on the activation of the button...
1180*cdf0e10cSrcweir             xButton.addActionListener(_xActionListener);
1181*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
1182*cdf0e10cSrcweir             /* perform individual exception handling here.
1183*cdf0e10cSrcweir              * Possible exception types are:
1184*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException,
1185*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
1186*cdf0e10cSrcweir              * com.sun.star.container.ElementExistException,
1187*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException,
1188*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
1189*cdf0e10cSrcweir              * com.sun.star.uno.Exception
1190*cdf0e10cSrcweir              */
1191*cdf0e10cSrcweir             ex.printStackTrace(System.out);
1192*cdf0e10cSrcweir         }
1193*cdf0e10cSrcweir         return xButton;
1194*cdf0e10cSrcweir     }
1195*cdf0e10cSrcweir 
1196*cdf0e10cSrcweir     /** gets the WindowPeer of a frame
1197*cdf0e10cSrcweir      *  @param _XTextDocument the instance of a textdocument
1198*cdf0e10cSrcweir      *  @return the windowpeer of the frame
1199*cdf0e10cSrcweir      */
1200*cdf0e10cSrcweir     public XWindowPeer getWindowPeer(XTextDocument _xTextDocument){
1201*cdf0e10cSrcweir         XModel xModel =  (XModel) UnoRuntime.queryInterface(XModel.class, _xTextDocument);
1202*cdf0e10cSrcweir         XFrame xFrame = xModel.getCurrentController().getFrame();
1203*cdf0e10cSrcweir         XWindow xWindow = xFrame.getContainerWindow();
1204*cdf0e10cSrcweir         XWindowPeer xWindowPeer =  (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xWindow);
1205*cdf0e10cSrcweir         return xWindowPeer;
1206*cdf0e10cSrcweir     }
1207*cdf0e10cSrcweir 
1208*cdf0e10cSrcweir     public XFrame getCurrentFrame(){
1209*cdf0e10cSrcweir         XFrame xRetFrame = null;
1210*cdf0e10cSrcweir         try {
1211*cdf0e10cSrcweir             Object oDesktop = m_xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext);
1212*cdf0e10cSrcweir             XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, oDesktop);
1213*cdf0e10cSrcweir             xRetFrame = xDesktop.getCurrentFrame();
1214*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
1215*cdf0e10cSrcweir             ex.printStackTrace();
1216*cdf0e10cSrcweir         }
1217*cdf0e10cSrcweir         return xRetFrame;
1218*cdf0e10cSrcweir     }
1219*cdf0e10cSrcweir 
1220*cdf0e10cSrcweir 
1221*cdf0e10cSrcweir     public void textChanged(TextEvent textEvent) {
1222*cdf0e10cSrcweir         try {
1223*cdf0e10cSrcweir             // get the control that has fired the event,
1224*cdf0e10cSrcweir             XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, textEvent.Source);
1225*cdf0e10cSrcweir             XControlModel xControlModel = xControl.getModel();
1226*cdf0e10cSrcweir             XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControlModel);
1227*cdf0e10cSrcweir             String sName = (String) xPSet.getPropertyValue("Name");
1228*cdf0e10cSrcweir             // just in case the listener has been added to several controls,
1229*cdf0e10cSrcweir             // we make sure we refer to the right one
1230*cdf0e10cSrcweir             if (sName.equals("TextField1")){
1231*cdf0e10cSrcweir                 String sText = (String) xPSet.getPropertyValue("Text");
1232*cdf0e10cSrcweir                 System.out.println(sText);
1233*cdf0e10cSrcweir                 // insert your code here to validate the text of the control...
1234*cdf0e10cSrcweir             }
1235*cdf0e10cSrcweir         }catch (com.sun.star.uno.Exception ex){
1236*cdf0e10cSrcweir             /* perform individual exception handling here.
1237*cdf0e10cSrcweir              * Possible exception types are:
1238*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
1239*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
1240*cdf0e10cSrcweir              * com.sun.star.uno.Exception
1241*cdf0e10cSrcweir              */
1242*cdf0e10cSrcweir             ex.printStackTrace(System.out);
1243*cdf0e10cSrcweir         }
1244*cdf0e10cSrcweir     }
1245*cdf0e10cSrcweir 
1246*cdf0e10cSrcweir 
1247*cdf0e10cSrcweir 
1248*cdf0e10cSrcweir     public void up(SpinEvent spinEvent) {
1249*cdf0e10cSrcweir         try {
1250*cdf0e10cSrcweir             // get the control that has fired the event,
1251*cdf0e10cSrcweir             XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, spinEvent.Source);
1252*cdf0e10cSrcweir             XControlModel xControlModel = xControl.getModel();
1253*cdf0e10cSrcweir             XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControlModel);
1254*cdf0e10cSrcweir             String sName = (String) xPSet.getPropertyValue("Name");
1255*cdf0e10cSrcweir             // just in case the listener has been added to several controls,
1256*cdf0e10cSrcweir             // we make sure we refer to the right one
1257*cdf0e10cSrcweir             if (sName.equals("FormattedField1")){
1258*cdf0e10cSrcweir                 double fvalue = AnyConverter.toDouble(xPSet.getPropertyValue("EffectiveValue"));
1259*cdf0e10cSrcweir                 System.out.println("Controlvalue:  " + fvalue);
1260*cdf0e10cSrcweir                 // insert your code here to validate the value of the control...
1261*cdf0e10cSrcweir             }
1262*cdf0e10cSrcweir         }catch (com.sun.star.uno.Exception ex){
1263*cdf0e10cSrcweir             /* perform individual exception handling here.
1264*cdf0e10cSrcweir              * Possible exception types are:
1265*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
1266*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
1267*cdf0e10cSrcweir              * com.sun.star.uno.Exception
1268*cdf0e10cSrcweir              */
1269*cdf0e10cSrcweir             ex.printStackTrace(System.out);
1270*cdf0e10cSrcweir         }
1271*cdf0e10cSrcweir     }
1272*cdf0e10cSrcweir 
1273*cdf0e10cSrcweir 
1274*cdf0e10cSrcweir     public void down(SpinEvent spinEvent) {
1275*cdf0e10cSrcweir     }
1276*cdf0e10cSrcweir 
1277*cdf0e10cSrcweir     public void last(SpinEvent spinEvent) {
1278*cdf0e10cSrcweir     }
1279*cdf0e10cSrcweir 
1280*cdf0e10cSrcweir     public void first(SpinEvent spinEvent) {
1281*cdf0e10cSrcweir     }
1282*cdf0e10cSrcweir 
1283*cdf0e10cSrcweir     public void disposing(EventObject rEventObject) {
1284*cdf0e10cSrcweir     }
1285*cdf0e10cSrcweir 
1286*cdf0e10cSrcweir 
1287*cdf0e10cSrcweir     public void actionPerformed(ActionEvent rEvent) {
1288*cdf0e10cSrcweir         try{
1289*cdf0e10cSrcweir             // get the control that has fired the event,
1290*cdf0e10cSrcweir             XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, rEvent.Source);
1291*cdf0e10cSrcweir             XControlModel xControlModel = xControl.getModel();
1292*cdf0e10cSrcweir             XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControlModel);
1293*cdf0e10cSrcweir             String sName = (String) xPSet.getPropertyValue("Name");
1294*cdf0e10cSrcweir             // just in case the listener has been added to several controls,
1295*cdf0e10cSrcweir             // we make sure we refer to the right one
1296*cdf0e10cSrcweir             if (sName.equals("CommandButton1")) {
1297*cdf0e10cSrcweir                 //...
1298*cdf0e10cSrcweir             }
1299*cdf0e10cSrcweir         }catch (com.sun.star.uno.Exception ex){
1300*cdf0e10cSrcweir             /* perform individual exception handling here.
1301*cdf0e10cSrcweir              * Possible exception types are:
1302*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
1303*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
1304*cdf0e10cSrcweir              * com.sun.star.uno.Exception
1305*cdf0e10cSrcweir              */
1306*cdf0e10cSrcweir             ex.printStackTrace(System.out);
1307*cdf0e10cSrcweir         }
1308*cdf0e10cSrcweir     }
1309*cdf0e10cSrcweir 
1310*cdf0e10cSrcweir 
1311*cdf0e10cSrcweir     public void focusLost(FocusEvent _focusEvent) {
1312*cdf0e10cSrcweir         short nFocusFlags = _focusEvent.FocusFlags;
1313*cdf0e10cSrcweir         int nFocusChangeReason = nFocusFlags & FocusChangeReason.TAB;
1314*cdf0e10cSrcweir         if (nFocusChangeReason == FocusChangeReason.TAB) {
1315*cdf0e10cSrcweir             // get the window of the Window that has gained the Focus...
1316*cdf0e10cSrcweir             // Note that the xWindow is just a representation of the controlwindow
1317*cdf0e10cSrcweir             // but not of the control itself
1318*cdf0e10cSrcweir             XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, _focusEvent.NextFocus);
1319*cdf0e10cSrcweir         }
1320*cdf0e10cSrcweir     }
1321*cdf0e10cSrcweir 
1322*cdf0e10cSrcweir 
1323*cdf0e10cSrcweir     public void focusGained(FocusEvent focusEvent) {
1324*cdf0e10cSrcweir     }
1325*cdf0e10cSrcweir 
1326*cdf0e10cSrcweir     public void mouseReleased(MouseEvent mouseEvent) {
1327*cdf0e10cSrcweir     }
1328*cdf0e10cSrcweir 
1329*cdf0e10cSrcweir     public void mousePressed(MouseEvent mouseEvent) {
1330*cdf0e10cSrcweir     }
1331*cdf0e10cSrcweir 
1332*cdf0e10cSrcweir     public void mouseExited(MouseEvent mouseEvent) {
1333*cdf0e10cSrcweir     }
1334*cdf0e10cSrcweir 
1335*cdf0e10cSrcweir     public void mouseEntered(MouseEvent _mouseEvent) {
1336*cdf0e10cSrcweir         try {
1337*cdf0e10cSrcweir             // retrieve the control that the event has been invoked at...
1338*cdf0e10cSrcweir             XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, _mouseEvent.Source);
1339*cdf0e10cSrcweir             Object tk = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext);
1340*cdf0e10cSrcweir             XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, tk);
1341*cdf0e10cSrcweir             // create the peer of the control by passing the windowpeer of the parent
1342*cdf0e10cSrcweir             // in this case the windowpeer of the control
1343*cdf0e10cSrcweir             xControl.createPeer(xToolkit, m_xWindowPeer);
1344*cdf0e10cSrcweir             // create a pointer object "in the open countryside" and set the type accordingly...
1345*cdf0e10cSrcweir             Object oPointer = this.m_xMCF.createInstanceWithContext("com.sun.star.awt.Pointer", this.m_xContext);
1346*cdf0e10cSrcweir             XPointer xPointer = (XPointer) UnoRuntime.queryInterface(XPointer.class, oPointer);
1347*cdf0e10cSrcweir             xPointer.setType(com.sun.star.awt.SystemPointer.REFHAND);
1348*cdf0e10cSrcweir             // finally set the created pointer at the windowpeer of the control
1349*cdf0e10cSrcweir             xControl.getPeer().setPointer(xPointer);
1350*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception ex) {
1351*cdf0e10cSrcweir             throw new java.lang.RuntimeException("cannot happen...");
1352*cdf0e10cSrcweir         }
1353*cdf0e10cSrcweir     }
1354*cdf0e10cSrcweir 
1355*cdf0e10cSrcweir 
1356*cdf0e10cSrcweir 
1357*cdf0e10cSrcweir     public void itemStateChanged(ItemEvent itemEvent) {
1358*cdf0e10cSrcweir         try{
1359*cdf0e10cSrcweir             // retrieve the control that the event has been invoked at...
1360*cdf0e10cSrcweir             XCheckBox xCheckBox = (XCheckBox) UnoRuntime.queryInterface(XCheckBox.class, itemEvent.Source);
1361*cdf0e10cSrcweir             // retrieve the control that we want to disable or enable
1362*cdf0e10cSrcweir             XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, m_xDlgContainer.getControl("CommandButton1"));
1363*cdf0e10cSrcweir             XPropertySet xModelPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel());
1364*cdf0e10cSrcweir             short nState = xCheckBox.getState();
1365*cdf0e10cSrcweir             boolean bdoEnable = true;
1366*cdf0e10cSrcweir             switch (nState){
1367*cdf0e10cSrcweir                 case 1:     // checked
1368*cdf0e10cSrcweir                     bdoEnable = true;
1369*cdf0e10cSrcweir                     break;
1370*cdf0e10cSrcweir                 case 0:     // not checked
1371*cdf0e10cSrcweir                 case 2:     // don't know
1372*cdf0e10cSrcweir                     bdoEnable = false;
1373*cdf0e10cSrcweir                     break;
1374*cdf0e10cSrcweir             }
1375*cdf0e10cSrcweir             // Alternatively we could have done it also this way:
1376*cdf0e10cSrcweir             // bdoEnable = (nState == 1);
1377*cdf0e10cSrcweir             xModelPropertySet.setPropertyValue("Enabled", new Boolean(bdoEnable));
1378*cdf0e10cSrcweir         }catch (com.sun.star.uno.Exception ex){
1379*cdf0e10cSrcweir             /* perform individual exception handling here.
1380*cdf0e10cSrcweir              * Possible exception types are:
1381*cdf0e10cSrcweir              * com.sun.star.lang.IllegalArgumentException
1382*cdf0e10cSrcweir              * com.sun.star.lang.WrappedTargetException,
1383*cdf0e10cSrcweir              * com.sun.star.beans.UnknownPropertyException,
1384*cdf0e10cSrcweir              * com.sun.star.beans.PropertyVetoException
1385*cdf0e10cSrcweir              * com.sun.star.uno.Exception
1386*cdf0e10cSrcweir              */
1387*cdf0e10cSrcweir             ex.printStackTrace(System.out);
1388*cdf0e10cSrcweir         }
1389*cdf0e10cSrcweir     }
1390*cdf0e10cSrcweir 
1391*cdf0e10cSrcweir 
1392*cdf0e10cSrcweir     public void adjustmentValueChanged(AdjustmentEvent _adjustmentEvent) {
1393*cdf0e10cSrcweir         switch (_adjustmentEvent.Type.getValue()){
1394*cdf0e10cSrcweir             case AdjustmentType.ADJUST_ABS_value:
1395*cdf0e10cSrcweir                 System.out.println( "The event has been triggered by dragging the thumb..." );
1396*cdf0e10cSrcweir                 break;
1397*cdf0e10cSrcweir             case AdjustmentType.ADJUST_LINE_value:
1398*cdf0e10cSrcweir                 System.out.println( "The event has been triggered by a single line move.." );
1399*cdf0e10cSrcweir                 break;
1400*cdf0e10cSrcweir             case AdjustmentType.ADJUST_PAGE_value:
1401*cdf0e10cSrcweir                 System.out.println( "The event has been triggered by a block move..." );
1402*cdf0e10cSrcweir                 break;
1403*cdf0e10cSrcweir         }
1404*cdf0e10cSrcweir         System.out.println( "The value of the scrollbar is: " + _adjustmentEvent.Value);
1405*cdf0e10cSrcweir     }
1406*cdf0e10cSrcweir 
1407*cdf0e10cSrcweir 
1408*cdf0e10cSrcweir 
1409*cdf0e10cSrcweir // Globally available object variables of the roadmapmodel
1410*cdf0e10cSrcweir     XPropertySet m_xRMPSet;
1411*cdf0e10cSrcweir     XSingleServiceFactory m_xSSFRoadmap;
1412*cdf0e10cSrcweir     XIndexContainer m_xRMIndexCont;
1413*cdf0e10cSrcweir 
1414*cdf0e10cSrcweir     public void addRoadmap(XItemListener _xItemListener) {
1415*cdf0e10cSrcweir         XPropertySet xDialogModelPropertySet = null;
1416*cdf0e10cSrcweir         try {
1417*cdf0e10cSrcweir             // create a unique name by means of an own implementation...
1418*cdf0e10cSrcweir             String sRoadmapName = createUniqueName(m_xDlgModelNameContainer, "Roadmap");
1419*cdf0e10cSrcweir 
1420*cdf0e10cSrcweir             xDialogModelPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, m_xMSFDialogModel);
1421*cdf0e10cSrcweir             // Similar to the office assistants the roadmap is adjusted to the height of the dialog
1422*cdf0e10cSrcweir             // where a certain space is left at the bottom for the buttons...
1423*cdf0e10cSrcweir             int nDialogHeight = ((Integer) xDialogModelPropertySet.getPropertyValue("Height")).intValue();
1424*cdf0e10cSrcweir 
1425*cdf0e10cSrcweir             // instantiate the roadmapmodel...
1426*cdf0e10cSrcweir             Object oRoadmapModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlRoadmapModel");
1427*cdf0e10cSrcweir 
1428*cdf0e10cSrcweir             // define the properties of the roadmapmodel
1429*cdf0e10cSrcweir             XMultiPropertySet xRMMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oRoadmapModel);
1430*cdf0e10cSrcweir             xRMMPSet.setPropertyValues( new String[] {"Complete", "Height", "Name", "PositionX", "PositionY", "Text", "Width" },
1431*cdf0e10cSrcweir                     new Object[] {Boolean.FALSE, new Integer(nDialogHeight - 26), sRoadmapName, new Integer(0), new Integer(0), "Steps", new Integer(85)});
1432*cdf0e10cSrcweir             m_xRMPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oRoadmapModel);
1433*cdf0e10cSrcweir 
1434*cdf0e10cSrcweir             // add the roadmapmodel to the dialog container..
1435*cdf0e10cSrcweir             m_xDlgModelNameContainer.insertByName(sRoadmapName, oRoadmapModel);
1436*cdf0e10cSrcweir 
1437*cdf0e10cSrcweir             // the roadmapmodel is a SingleServiceFactory to instantiate the roadmapitems...
1438*cdf0e10cSrcweir             m_xSSFRoadmap = (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, oRoadmapModel);
1439*cdf0e10cSrcweir             m_xRMIndexCont = (XIndexContainer) UnoRuntime.queryInterface(XIndexContainer.class, oRoadmapModel);
1440*cdf0e10cSrcweir 
1441*cdf0e10cSrcweir             // add the itemlistener to the control...
1442*cdf0e10cSrcweir             XControl xRMControl = this.m_xDlgContainer.getControl(sRoadmapName);
1443*cdf0e10cSrcweir             XItemEventBroadcaster xRMBroadcaster = (XItemEventBroadcaster) UnoRuntime.queryInterface(XItemEventBroadcaster.class, xRMControl);
1444*cdf0e10cSrcweir             xRMBroadcaster.addItemListener( getRoadmapItemStateChangeListener() );
1445*cdf0e10cSrcweir         } catch (java.lang.Exception jexception) {
1446*cdf0e10cSrcweir             jexception.printStackTrace(System.out);
1447*cdf0e10cSrcweir         }
1448*cdf0e10cSrcweir     }
1449*cdf0e10cSrcweir 
1450*cdf0e10cSrcweir     /**
1451*cdf0e10cSrcweir      *To fully understand the example one has to be aware that the passed ???Index??? parameter
1452*cdf0e10cSrcweir      * refers to the position of the roadmap item in the roadmapmodel container
1453*cdf0e10cSrcweir      * whereas the variable ???_ID??? directyl references to a certain step of dialog.
1454*cdf0e10cSrcweir      */
1455*cdf0e10cSrcweir     public void insertRoadmapItem(int Index, boolean _bEnabled, String _sLabel, int _ID) {
1456*cdf0e10cSrcweir         try {
1457*cdf0e10cSrcweir             // a roadmap is a SingleServiceFactory that can only create roadmapitems that are the only possible
1458*cdf0e10cSrcweir             // element types of the container
1459*cdf0e10cSrcweir             Object oRoadmapItem = m_xSSFRoadmap.createInstance();
1460*cdf0e10cSrcweir             XPropertySet xRMItemPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oRoadmapItem);
1461*cdf0e10cSrcweir             xRMItemPSet.setPropertyValue("Label", _sLabel);
1462*cdf0e10cSrcweir             // sometimes steps are supposed to be set disabled depending on the program logic...
1463*cdf0e10cSrcweir             xRMItemPSet.setPropertyValue("Enabled", new Boolean(_bEnabled));
1464*cdf0e10cSrcweir             // in this context the "ID" is meant to refer to a step of the dialog
1465*cdf0e10cSrcweir             xRMItemPSet.setPropertyValue("ID", new Integer(_ID));
1466*cdf0e10cSrcweir             m_xRMIndexCont.insertByIndex(Index, oRoadmapItem);
1467*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception exception) {
1468*cdf0e10cSrcweir             exception.printStackTrace(System.out);
1469*cdf0e10cSrcweir         }
1470*cdf0e10cSrcweir     }
1471*cdf0e10cSrcweir 
1472*cdf0e10cSrcweir 
1473*cdf0e10cSrcweir     public void keyReleased(KeyEvent keyEvent) {
1474*cdf0e10cSrcweir         int i = keyEvent.KeyChar;
1475*cdf0e10cSrcweir         int n = keyEvent.KeyCode;
1476*cdf0e10cSrcweir         int m = keyEvent.KeyFunc;
1477*cdf0e10cSrcweir     }
1478*cdf0e10cSrcweir 
1479*cdf0e10cSrcweir     public void keyPressed(KeyEvent keyEvent) {
1480*cdf0e10cSrcweir     }
1481*cdf0e10cSrcweir 
1482*cdf0e10cSrcweir }
1483