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