From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../java/mod/_toolkit/UnoSpinButtonControl.java | 133 +++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 qadevOOo/tests/java/mod/_toolkit/UnoSpinButtonControl.java (limited to 'qadevOOo/tests/java/mod/_toolkit/UnoSpinButtonControl.java') diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoSpinButtonControl.java b/qadevOOo/tests/java/mod/_toolkit/UnoSpinButtonControl.java new file mode 100644 index 000000000..df8506f9e --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoSpinButtonControl.java @@ -0,0 +1,133 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.WriterTools; +import util.utils; + + +public class UnoSpinButtonControl extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + Param.getMSF()); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "SpinButton", + "UnoControlSpinButton"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the SpinButtonControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println( + "creating a new environment for UnoControlSpinButton object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //adding Object-Relation for XScrollBar + tEnv.addObjRelation("Document", xTextDoc); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + + tEnv.addObjRelation("Document", xTextDoc); + + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} -- cgit v1.2.3