1ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5ef39d40dSAndrew Rist * distributed with this work for additional information 6ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17ef39d40dSAndrew Rist * specific language governing permissions and limitations 18ef39d40dSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20ef39d40dSAndrew Rist *************************************************************/ 21ef39d40dSAndrew Rist 22ef39d40dSAndrew Rist 23cdf0e10cSrcweir package mod._dbaccess; 24cdf0e10cSrcweir 25cdf0e10cSrcweir import java.io.PrintWriter; 26cdf0e10cSrcweir import java.util.Comparator; 27cdf0e10cSrcweir 28cdf0e10cSrcweir import lib.StatusException; 29cdf0e10cSrcweir import lib.TestCase; 30cdf0e10cSrcweir import lib.TestEnvironment; 31cdf0e10cSrcweir import lib.TestParameters; 32cdf0e10cSrcweir import util.AccessibilityTools; 33cdf0e10cSrcweir import util.FormTools; 34cdf0e10cSrcweir import util.SOfficeFactory; 35cdf0e10cSrcweir import util.WriterTools; 36cdf0e10cSrcweir import util.utils; 37cdf0e10cSrcweir 38cdf0e10cSrcweir import com.sun.star.accessibility.AccessibleRole; 39cdf0e10cSrcweir import com.sun.star.accessibility.XAccessible; 40cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleAction; 41cdf0e10cSrcweir import com.sun.star.awt.Point; 42cdf0e10cSrcweir import com.sun.star.awt.Size; 43cdf0e10cSrcweir import com.sun.star.awt.XControlModel; 44cdf0e10cSrcweir import com.sun.star.awt.XDevice; 45cdf0e10cSrcweir import com.sun.star.awt.XExtendedToolkit; 46cdf0e10cSrcweir import com.sun.star.awt.XGraphics; 47cdf0e10cSrcweir import com.sun.star.awt.XToolkit; 48cdf0e10cSrcweir import com.sun.star.awt.XWindow; 49cdf0e10cSrcweir import com.sun.star.awt.XWindowPeer; 50cdf0e10cSrcweir import com.sun.star.beans.XPropertySet; 51cdf0e10cSrcweir import com.sun.star.container.XNameContainer; 52cdf0e10cSrcweir import com.sun.star.drawing.XControlShape; 53cdf0e10cSrcweir import com.sun.star.drawing.XShape; 54cdf0e10cSrcweir import com.sun.star.form.XBoundComponent; 55cdf0e10cSrcweir import com.sun.star.form.XGridColumnFactory; 56cdf0e10cSrcweir import com.sun.star.form.XLoadable; 57cdf0e10cSrcweir import com.sun.star.lang.XComponent; 58cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 59cdf0e10cSrcweir import com.sun.star.sdbc.XResultSetUpdate; 60cdf0e10cSrcweir import com.sun.star.text.XTextDocument; 61cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 62cdf0e10cSrcweir import com.sun.star.uno.XInterface; 63cdf0e10cSrcweir import com.sun.star.util.URL; 64cdf0e10cSrcweir import com.sun.star.util.XCloseable; 65cdf0e10cSrcweir import com.sun.star.view.XControlAccess; 66cdf0e10cSrcweir 67cdf0e10cSrcweir 68cdf0e10cSrcweir /** 69cdf0e10cSrcweir * Test for object which represents the control of the Grid model. <p> 70cdf0e10cSrcweir * Object implements the following interfaces : 71cdf0e10cSrcweir * <ul> 72cdf0e10cSrcweir * <li> <code>com::sun::star::util::XModifyBroadcaster</code></li> 73cdf0e10cSrcweir * <li> <code>com::sun::star::form::XGridFieldDataSupplier</code></li> 74cdf0e10cSrcweir * <li> <code>com::sun::star::view::XSelectionSupplier</code></li> 75cdf0e10cSrcweir * <li> <code>com::sun::star::form::XGrid</code></li> 76cdf0e10cSrcweir * <li> <code>com::sun::star::awt::XControl</code></li> 77cdf0e10cSrcweir * <li> <code>com::sun::star::util::XModeSelector</code></li> 78cdf0e10cSrcweir * <li> <code>com::sun::star::container::XElementAccess</code></li> 79cdf0e10cSrcweir * <li> <code>com::sun::star::awt::XWindow</code></li> 80cdf0e10cSrcweir * <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> 81cdf0e10cSrcweir * <li> <code>com::sun::star::frame::XDispatch</code></li> 82cdf0e10cSrcweir * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> 83cdf0e10cSrcweir * <li> <code>com::sun::star::form::XBoundComponent</code></li> 84cdf0e10cSrcweir * <li> <code>com::sun::star::frame::XDispatchProviderInterception</code></li> 85cdf0e10cSrcweir * <li> <code>com::sun::star::container::XIndexAccess</code></li> 86cdf0e10cSrcweir * <li> <code>com::sun::star::lang::XComponent</code></li> 87cdf0e10cSrcweir * <li> <code>com::sun::star::awt::XView</code></li> 88cdf0e10cSrcweir * <li> <code>com::sun::star::container::XContainer</code></li> 89cdf0e10cSrcweir * </ul> 90cdf0e10cSrcweir * This object test <b> is NOT </b> designed to be run in several 91cdf0e10cSrcweir * threads concurently. 92cdf0e10cSrcweir * @see com.sun.star.util.XModifyBroadcaster 93cdf0e10cSrcweir * @see com.sun.star.form.XGridFieldDataSupplier 94cdf0e10cSrcweir * @see com.sun.star.view.XSelectionSupplier 95cdf0e10cSrcweir * @see com.sun.star.form.XGrid 96cdf0e10cSrcweir * @see com.sun.star.awt.XControl 97cdf0e10cSrcweir * @see com.sun.star.util.XModeSelector 98cdf0e10cSrcweir * @see com.sun.star.container.XElementAccess 99cdf0e10cSrcweir * @see com.sun.star.awt.XWindow 100cdf0e10cSrcweir * @see com.sun.star.form.XUpdateBroadcaster 101cdf0e10cSrcweir * @see com.sun.star.frame.XDispatch 102cdf0e10cSrcweir * @see com.sun.star.container.XEnumerationAccess 103cdf0e10cSrcweir * @see com.sun.star.form.XBoundComponent 104cdf0e10cSrcweir * @see com.sun.star.frame.XDispatchProviderInterception 105cdf0e10cSrcweir * @see com.sun.star.container.XIndexAccess 106cdf0e10cSrcweir * @see com.sun.star.lang.XComponent 107cdf0e10cSrcweir * @see com.sun.star.awt.XView 108cdf0e10cSrcweir * @see com.sun.star.container.XContainer 109cdf0e10cSrcweir * @see ifc.util._XModifyBroadcaster 110cdf0e10cSrcweir * @see ifc.form._XGridFieldDataSupplier 111cdf0e10cSrcweir * @see ifc.view._XSelectionSupplier 112cdf0e10cSrcweir * @see ifc.form._XGrid 113cdf0e10cSrcweir * @see ifc.awt._XControl 114cdf0e10cSrcweir * @see ifc.util._XModeSelector 115cdf0e10cSrcweir * @see ifc.container._XElementAccess 116cdf0e10cSrcweir * @see ifc.awt._XWindow 117cdf0e10cSrcweir * @see ifc.form._XUpdateBroadcaster 118cdf0e10cSrcweir * @see ifc.frame._XDispatch 119cdf0e10cSrcweir * @see ifc.container._XEnumerationAccess 120cdf0e10cSrcweir * @see ifc.form._XBoundComponent 121cdf0e10cSrcweir * @see ifc.frame._XDispatchProviderInterception 122cdf0e10cSrcweir * @see ifc.container._XIndexAccess 123cdf0e10cSrcweir * @see ifc.lang._XComponent 124cdf0e10cSrcweir * @see ifc.awt._XView 125cdf0e10cSrcweir * @see ifc.container._XContainer 126cdf0e10cSrcweir */ 127cdf0e10cSrcweir public class SbaXGridControl extends TestCase { 128cdf0e10cSrcweir XTextDocument xTextDoc; 129cdf0e10cSrcweir 130cdf0e10cSrcweir /** 131cdf0e10cSrcweir * Creates Writer document. 132cdf0e10cSrcweir */ initialize(TestParameters Param, PrintWriter log)133cdf0e10cSrcweir protected void initialize(TestParameters Param, PrintWriter log) { 134cdf0e10cSrcweir SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory)Param.getMSF()); 135cdf0e10cSrcweir 136cdf0e10cSrcweir try { 137cdf0e10cSrcweir log.println("creating a textdocument"); 138cdf0e10cSrcweir xTextDoc = SOF.createTextDoc(null); 139cdf0e10cSrcweir } catch (com.sun.star.uno.Exception e) { 140cdf0e10cSrcweir // Some exception occures.FAILED 141cdf0e10cSrcweir e.printStackTrace(log); 142cdf0e10cSrcweir throw new StatusException("Couldn't create document", e); 143cdf0e10cSrcweir } 144cdf0e10cSrcweir } 145cdf0e10cSrcweir 146cdf0e10cSrcweir /** 147cdf0e10cSrcweir * Disposes Writer document. 148cdf0e10cSrcweir */ cleanup(TestParameters tParam, PrintWriter log)149cdf0e10cSrcweir protected void cleanup(TestParameters tParam, PrintWriter log) { 150cdf0e10cSrcweir //closing the appearing dialog before disposing the document 151cdf0e10cSrcweir XInterface toolkit = null; 152cdf0e10cSrcweir 153cdf0e10cSrcweir try { 154cdf0e10cSrcweir toolkit = (XInterface) ((XMultiServiceFactory)tParam.getMSF()) 155cdf0e10cSrcweir .createInstance("com.sun.star.awt.Toolkit"); 156cdf0e10cSrcweir } catch (com.sun.star.uno.Exception e) { 157cdf0e10cSrcweir log.println("Couldn't get toolkit"); 158cdf0e10cSrcweir e.printStackTrace(log); 159cdf0e10cSrcweir throw new StatusException("Couldn't get toolkit", e); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir 162cdf0e10cSrcweir XExtendedToolkit tk = (XExtendedToolkit) UnoRuntime.queryInterface( 163cdf0e10cSrcweir XExtendedToolkit.class, toolkit); 164cdf0e10cSrcweir 165cdf0e10cSrcweir Object atw = tk.getActiveTopWindow(); 166cdf0e10cSrcweir 167cdf0e10cSrcweir XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, 168cdf0e10cSrcweir atw); 169cdf0e10cSrcweir 170cdf0e10cSrcweir XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); 171cdf0e10cSrcweir 172cdf0e10cSrcweir XInterface button = AccessibilityTools.getAccessibleObjectForRole(xRoot, 173cdf0e10cSrcweir AccessibleRole.PUSH_BUTTON); 174cdf0e10cSrcweir 175cdf0e10cSrcweir XAccessibleAction action = (XAccessibleAction) UnoRuntime.queryInterface( 176cdf0e10cSrcweir XAccessibleAction.class, button); 177cdf0e10cSrcweir 178cdf0e10cSrcweir try { 179cdf0e10cSrcweir action.doAccessibleAction(0); 180cdf0e10cSrcweir } catch (com.sun.star.lang.IndexOutOfBoundsException iob) { 181cdf0e10cSrcweir log.println("couldn't close dialog"); 182cdf0e10cSrcweir } catch (com.sun.star.lang.DisposedException e) { 183cdf0e10cSrcweir log.println("couldn't close dialog"); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir 186cdf0e10cSrcweir log.println(" disposing xTextDoc "); 187cdf0e10cSrcweir 188cdf0e10cSrcweir try { 189cdf0e10cSrcweir XCloseable closer = (XCloseable) UnoRuntime.queryInterface( 190cdf0e10cSrcweir XCloseable.class, xTextDoc); 191cdf0e10cSrcweir closer.close(true); 192cdf0e10cSrcweir } catch (com.sun.star.util.CloseVetoException e) { 193cdf0e10cSrcweir log.println("couldn't close document"); 194cdf0e10cSrcweir } catch (com.sun.star.lang.DisposedException e) { 195cdf0e10cSrcweir log.println("couldn't close document"); 196cdf0e10cSrcweir } 197cdf0e10cSrcweir } 198cdf0e10cSrcweir 199cdf0e10cSrcweir /** 200cdf0e10cSrcweir * Creating a Testenvironment for the interfaces to be tested. 201cdf0e10cSrcweir * For object creation first a 202cdf0e10cSrcweir * <code>com.sun.star.form.component.GridControl<code> instance 203cdf0e10cSrcweir * is added to the <code>ControlShape</code>. Then this model's 204cdf0e10cSrcweir * control is retrieved. 205cdf0e10cSrcweir * 206cdf0e10cSrcweir * Object relations created : 207cdf0e10cSrcweir * <ul> 208cdf0e10cSrcweir * <li> <code>'GRAPHICS'</code> for 209*e6b649b5SPedro Giffuni * {@link ifc.awt._XView} test : <code>XGraphics</code> 210cdf0e10cSrcweir * object different that belong to the object tested.</li> 211cdf0e10cSrcweir * <li> <code>'CONTEXT'</code> for 212cdf0e10cSrcweir * {@link ifc.awt._XControl} </li> 213cdf0e10cSrcweir * <li> <code>'WINPEER'</code> for 214*e6b649b5SPedro Giffuni * {@link ifc.awt._XControl} </li> 215cdf0e10cSrcweir * <li> <code>'TOOLKIT'</code> for 216*e6b649b5SPedro Giffuni * {@link ifc.awt._XControl} </li> 217cdf0e10cSrcweir * <li> <code>'MODEL'</code> for 218*e6b649b5SPedro Giffuni * {@link ifc.awt._XControl} </li> 219cdf0e10cSrcweir * <li> <code>'XWindow.AnotherWindow'</code> for 220cdf0e10cSrcweir * {@link ifc.awt._XWindow} for switching focus.</li> 221cdf0e10cSrcweir * <li> <code>'XDispatch.URL'</code> for 222cdf0e10cSrcweir * {@link ifc.frame._XDispatch} the url which moves 223cdf0e10cSrcweir * DB cursor to the next row (".uno:FormSlots/moveToNext").</li> 224cdf0e10cSrcweir * <li> <code>'XContainer.Container'</code> for 225cdf0e10cSrcweir * {@link ifc.container._XContainer} as the component created 226cdf0e10cSrcweir * doesn't support <code>XContainer</code> itself, but 227cdf0e10cSrcweir * it is supported by its model. So this model is passed.</li> 228cdf0e10cSrcweir * <li> <code>'INSTANCE'</code> for 229cdf0e10cSrcweir * {@link ifc.container._XContainer} the instance to be 230cdf0e10cSrcweir * inserted into collection. Is a column instance.</li> 231cdf0e10cSrcweir * </ul> 232cdf0e10cSrcweir */ createTestEnvironment(TestParameters Param, PrintWriter log)233cdf0e10cSrcweir protected TestEnvironment createTestEnvironment(TestParameters Param, 234cdf0e10cSrcweir PrintWriter log) { 235cdf0e10cSrcweir XInterface oObj = null; 236cdf0e10cSrcweir XWindowPeer the_win = null; 237cdf0e10cSrcweir XToolkit the_kit = null; 238cdf0e10cSrcweir XDevice aDevice = null; 239cdf0e10cSrcweir XGraphics aGraphic = null; 240cdf0e10cSrcweir XPropertySet aControl = null; 241cdf0e10cSrcweir XPropertySet aControl2 = null; 242cdf0e10cSrcweir XPropertySet aControl3 = null; 243cdf0e10cSrcweir XPropertySet aControl4 = null; 244cdf0e10cSrcweir XGridColumnFactory columns = null; 245cdf0e10cSrcweir 246cdf0e10cSrcweir //Insert a ControlShape and get the ControlModel 247cdf0e10cSrcweir XControlShape aShape = createGrid(xTextDoc, 3000, 4500, 15000, 10000); 248cdf0e10cSrcweir 249cdf0e10cSrcweir XControlModel the_Model = aShape.getControl(); 250cdf0e10cSrcweir 251cdf0e10cSrcweir WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); 252cdf0e10cSrcweir 253cdf0e10cSrcweir XLoadable formLoader = FormTools.bindForm(xTextDoc); 254cdf0e10cSrcweir 255cdf0e10cSrcweir //Try to query XControlAccess 256cdf0e10cSrcweir XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( 257cdf0e10cSrcweir XControlAccess.class, 258cdf0e10cSrcweir xTextDoc.getCurrentController()); 259cdf0e10cSrcweir 260cdf0e10cSrcweir try { 261cdf0e10cSrcweir columns = (XGridColumnFactory) UnoRuntime.queryInterface( 262cdf0e10cSrcweir XGridColumnFactory.class, the_Model); 263cdf0e10cSrcweir aControl = columns.createColumn("TextField"); 264cdf0e10cSrcweir aControl.setPropertyValue("DataField", "Identifier"); 265cdf0e10cSrcweir aControl.setPropertyValue("Label", "Identifier"); 266cdf0e10cSrcweir aControl2 = columns.createColumn("TextField"); 267cdf0e10cSrcweir aControl2.setPropertyValue("DataField", "Publisher"); 268cdf0e10cSrcweir aControl2.setPropertyValue("Label", "Publisher"); 269cdf0e10cSrcweir aControl3 = columns.createColumn("TextField"); 270cdf0e10cSrcweir aControl3.setPropertyValue("DataField", "Author"); 271cdf0e10cSrcweir aControl3.setPropertyValue("Label", "Author"); 272cdf0e10cSrcweir aControl4 = columns.createColumn("TextField"); 273cdf0e10cSrcweir aControl4.setPropertyValue("DataField", "Title"); 274cdf0e10cSrcweir aControl4.setPropertyValue("Label", "Title"); 275cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 276cdf0e10cSrcweir // Some exception occures.FAILED 277cdf0e10cSrcweir log.println("!!! Couldn't create instance : " + e); 278cdf0e10cSrcweir throw new StatusException("Can't create column instances.", e); 279cdf0e10cSrcweir } catch (com.sun.star.lang.WrappedTargetException e) { 280cdf0e10cSrcweir // Some exception occures.FAILED 281cdf0e10cSrcweir log.println("!!! Couldn't create instance : " + e); 282cdf0e10cSrcweir throw new StatusException("Can't create column instances.", e); 283cdf0e10cSrcweir } catch (com.sun.star.beans.PropertyVetoException e) { 284cdf0e10cSrcweir // Some exception occures.FAILED 285cdf0e10cSrcweir log.println("!!! Couldn't create instance : " + e); 286cdf0e10cSrcweir throw new StatusException("Can't create column instances.", e); 287cdf0e10cSrcweir } catch (com.sun.star.beans.UnknownPropertyException e) { 288cdf0e10cSrcweir // Some exception occures.FAILED 289cdf0e10cSrcweir log.println("!!! Couldn't create instance : " + e); 290cdf0e10cSrcweir throw new StatusException("Can't create column instances.", e); 291cdf0e10cSrcweir } 292cdf0e10cSrcweir 293cdf0e10cSrcweir XNameContainer aContainer = (XNameContainer) UnoRuntime.queryInterface( 294cdf0e10cSrcweir XNameContainer.class, the_Model); 295cdf0e10cSrcweir 296cdf0e10cSrcweir try { 297cdf0e10cSrcweir aContainer.insertByName("First", aControl); 298cdf0e10cSrcweir aContainer.insertByName("Second", aControl2); 299cdf0e10cSrcweir } catch (com.sun.star.uno.Exception e) { 300cdf0e10cSrcweir log.println("!!! Could't insert column Instance"); 301cdf0e10cSrcweir e.printStackTrace(log); 302cdf0e10cSrcweir throw new StatusException("Can't insert columns", e); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir //now get the OGridControl 306cdf0e10cSrcweir try { 307cdf0e10cSrcweir oObj = the_access.getControl(the_Model); 308cdf0e10cSrcweir the_win = the_access.getControl(the_Model).getPeer(); 309cdf0e10cSrcweir the_kit = the_win.getToolkit(); 310cdf0e10cSrcweir aDevice = the_kit.createScreenCompatibleDevice(200, 200); 311cdf0e10cSrcweir aGraphic = aDevice.createGraphics(); 312cdf0e10cSrcweir } catch (com.sun.star.uno.Exception e) { 313cdf0e10cSrcweir log.println("Couldn't get GridControl"); 314cdf0e10cSrcweir e.printStackTrace(log); 315cdf0e10cSrcweir throw new StatusException("Couldn't get GridControl", e); 316cdf0e10cSrcweir } 317cdf0e10cSrcweir 318cdf0e10cSrcweir 319cdf0e10cSrcweir // creating another window 320cdf0e10cSrcweir aShape = FormTools.createControlShape(xTextDoc, 3000, 4500, 15000, 321cdf0e10cSrcweir 10000, "TextField"); 322cdf0e10cSrcweir 323cdf0e10cSrcweir WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); 324cdf0e10cSrcweir 325cdf0e10cSrcweir the_Model = aShape.getControl(); 326cdf0e10cSrcweir 327cdf0e10cSrcweir 328cdf0e10cSrcweir //Try to query XControlAccess 329cdf0e10cSrcweir the_access = (XControlAccess) UnoRuntime.queryInterface( 330cdf0e10cSrcweir XControlAccess.class, 331cdf0e10cSrcweir xTextDoc.getCurrentController()); 332cdf0e10cSrcweir 333cdf0e10cSrcweir //now get the TextControl 334cdf0e10cSrcweir XWindow win = null; 335cdf0e10cSrcweir Object cntrl = null; 336cdf0e10cSrcweir 337cdf0e10cSrcweir try { 338cdf0e10cSrcweir cntrl = the_access.getControl(the_Model); 339cdf0e10cSrcweir win = (XWindow) UnoRuntime.queryInterface(XWindow.class, cntrl); 340cdf0e10cSrcweir } catch (com.sun.star.uno.Exception e) { 341cdf0e10cSrcweir log.println("Couldn't get Control"); 342cdf0e10cSrcweir e.printStackTrace(log); 343cdf0e10cSrcweir throw new StatusException("Couldn't get Control", e); 344cdf0e10cSrcweir } 345cdf0e10cSrcweir 346cdf0e10cSrcweir log.println("creating a new environment for object"); 347cdf0e10cSrcweir 348cdf0e10cSrcweir TestEnvironment tEnv = new TestEnvironment(oObj); 349cdf0e10cSrcweir 350cdf0e10cSrcweir 351cdf0e10cSrcweir //Relations for XSelectionSupplier 352cdf0e10cSrcweir tEnv.addObjRelation("Selections", 353cdf0e10cSrcweir new Object[] { 354cdf0e10cSrcweir new Object[] { new Integer(0) }, new Object[] { new Integer(1) } 355cdf0e10cSrcweir }); 356cdf0e10cSrcweir tEnv.addObjRelation("Comparer", 357cdf0e10cSrcweir new Comparator() { 358cdf0e10cSrcweir public int compare(Object o1, Object o2) { 359cdf0e10cSrcweir return ((Integer) o1).compareTo((Integer)o2); 360cdf0e10cSrcweir } 361cdf0e10cSrcweir 362cdf0e10cSrcweir public boolean equals(Object obj) { 363cdf0e10cSrcweir return compare(this, obj) == 0; 364cdf0e10cSrcweir } 365cdf0e10cSrcweir }); 366cdf0e10cSrcweir 367cdf0e10cSrcweir 368cdf0e10cSrcweir //Realtion for XContainer 369cdf0e10cSrcweir tEnv.addObjRelation("XContainer.Container", aContainer); 370cdf0e10cSrcweir tEnv.addObjRelation("INSTANCE", aControl3); 371cdf0e10cSrcweir tEnv.addObjRelation("INSTANCE2", aControl4); 372cdf0e10cSrcweir 373cdf0e10cSrcweir 374cdf0e10cSrcweir //Adding ObjRelation for XView 375cdf0e10cSrcweir tEnv.addObjRelation("GRAPHICS", aGraphic); 376cdf0e10cSrcweir 377cdf0e10cSrcweir 378cdf0e10cSrcweir //Adding ObjRelation for XControl 379cdf0e10cSrcweir tEnv.addObjRelation("CONTEXT", xTextDoc); 380cdf0e10cSrcweir tEnv.addObjRelation("WINPEER", the_win); 381cdf0e10cSrcweir tEnv.addObjRelation("TOOLKIT", the_kit); 382cdf0e10cSrcweir tEnv.addObjRelation("MODEL", the_Model); 383cdf0e10cSrcweir 384cdf0e10cSrcweir 385cdf0e10cSrcweir // Adding relation for XWindow 386cdf0e10cSrcweir tEnv.addObjRelation("XWindow.AnotherWindow", win); 387cdf0e10cSrcweir 388cdf0e10cSrcweir // Adding relation for XDispatch 389cdf0e10cSrcweir URL url = new URL(); 390cdf0e10cSrcweir url.Complete = ".uno:FormSlots/moveToNext"; 391cdf0e10cSrcweir 392cdf0e10cSrcweir 393cdf0e10cSrcweir //url.Complete = ".uno:GridSlots/RowHeight"; 394cdf0e10cSrcweir //url.Complete = ".uno:GridSlots/RowHeight" ; 395cdf0e10cSrcweir tEnv.addObjRelation("XDispatch.URL", url); 396cdf0e10cSrcweir 397cdf0e10cSrcweir log.println("ImplName: " + utils.getImplName(oObj)); 398cdf0e10cSrcweir 399cdf0e10cSrcweir FormTools.switchDesignOf((XMultiServiceFactory)Param.getMSF(), xTextDoc); 400cdf0e10cSrcweir 401cdf0e10cSrcweir // adding relation for XUpdateBroadcaster 402cdf0e10cSrcweir final XInterface ctrl = oObj; 403cdf0e10cSrcweir final XLoadable formLoaderF = formLoader; 404cdf0e10cSrcweir final XPropertySet ps = (XPropertySet) UnoRuntime.queryInterface( 405cdf0e10cSrcweir XPropertySet.class, aControl2); 406cdf0e10cSrcweir tEnv.addObjRelation("XUpdateBroadcaster.Checker", 407cdf0e10cSrcweir new ifc.form._XUpdateBroadcaster.UpdateChecker() { 408cdf0e10cSrcweir private String lastText = ""; 409cdf0e10cSrcweir 410cdf0e10cSrcweir public void update() throws com.sun.star.uno.Exception { 411cdf0e10cSrcweir if (!formLoaderF.isLoaded()) { 412cdf0e10cSrcweir formLoaderF.load(); 413cdf0e10cSrcweir } 414cdf0e10cSrcweir 415cdf0e10cSrcweir lastText = "_" + ps.getPropertyValue("Text"); 416cdf0e10cSrcweir ps.setPropertyValue("Text", lastText); 417cdf0e10cSrcweir } 418cdf0e10cSrcweir 419cdf0e10cSrcweir public void commit() throws com.sun.star.sdbc.SQLException { 420cdf0e10cSrcweir XBoundComponent bound = (XBoundComponent) UnoRuntime.queryInterface( 421cdf0e10cSrcweir XBoundComponent.class, ctrl); 422cdf0e10cSrcweir XResultSetUpdate update = (XResultSetUpdate) UnoRuntime.queryInterface( 423cdf0e10cSrcweir XResultSetUpdate.class, 424cdf0e10cSrcweir formLoaderF); 425cdf0e10cSrcweir 426cdf0e10cSrcweir bound.commit(); 427cdf0e10cSrcweir update.updateRow(); 428cdf0e10cSrcweir } 429cdf0e10cSrcweir 430cdf0e10cSrcweir public boolean wasCommited() throws com.sun.star.uno.Exception { 431cdf0e10cSrcweir String getS = (String) ps.getPropertyValue("Text"); 432cdf0e10cSrcweir 433cdf0e10cSrcweir return lastText.equals(getS); 434cdf0e10cSrcweir } 435cdf0e10cSrcweir }); 436cdf0e10cSrcweir 437cdf0e10cSrcweir return tEnv; 438cdf0e10cSrcweir } // finish method getTestEnvironment 439cdf0e10cSrcweir createGrid(XComponent oDoc, int height, int width, int x, int y)440cdf0e10cSrcweir public static XControlShape createGrid(XComponent oDoc, int height, 441cdf0e10cSrcweir int width, int x, int y) { 442cdf0e10cSrcweir Size size = new Size(); 443cdf0e10cSrcweir Point position = new Point(); 444cdf0e10cSrcweir XControlShape oCShape = null; 445cdf0e10cSrcweir XControlModel aControl = null; 446cdf0e10cSrcweir 447cdf0e10cSrcweir //get MSF 448cdf0e10cSrcweir XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( 449cdf0e10cSrcweir XMultiServiceFactory.class, 450cdf0e10cSrcweir oDoc); 451cdf0e10cSrcweir 452cdf0e10cSrcweir try { 453cdf0e10cSrcweir Object oInt = oDocMSF.createInstance( 454cdf0e10cSrcweir "com.sun.star.drawing.ControlShape"); 455cdf0e10cSrcweir Object aCon = oDocMSF.createInstance( 456cdf0e10cSrcweir "com.sun.star.form.component.GridControl"); 457cdf0e10cSrcweir XPropertySet model_props = (XPropertySet) UnoRuntime.queryInterface( 458cdf0e10cSrcweir XPropertySet.class, aCon); 459cdf0e10cSrcweir model_props.setPropertyValue("DefaultControl", 460cdf0e10cSrcweir "com.sun.star.form.control.InteractionGridControl"); 461cdf0e10cSrcweir aControl = (XControlModel) UnoRuntime.queryInterface( 462cdf0e10cSrcweir XControlModel.class, aCon); 463cdf0e10cSrcweir oCShape = (XControlShape) UnoRuntime.queryInterface( 464cdf0e10cSrcweir XControlShape.class, oInt); 465cdf0e10cSrcweir size.Height = height; 466cdf0e10cSrcweir size.Width = width; 467cdf0e10cSrcweir position.X = x; 468cdf0e10cSrcweir position.Y = y; 469cdf0e10cSrcweir oCShape.setSize(size); 470cdf0e10cSrcweir oCShape.setPosition(position); 471cdf0e10cSrcweir } catch (com.sun.star.uno.Exception e) { 472cdf0e10cSrcweir // Some exception occures.FAILED 473cdf0e10cSrcweir System.out.println("Couldn't create Grid" + e); 474cdf0e10cSrcweir throw new StatusException("Couldn't create Grid", e); 475cdf0e10cSrcweir } 476cdf0e10cSrcweir 477cdf0e10cSrcweir oCShape.setControl(aControl); 478cdf0e10cSrcweir 479cdf0e10cSrcweir return oCShape; 480cdf0e10cSrcweir } // finish createGrid 481cdf0e10cSrcweir } 482