2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 import com
.sun
.star
.awt
.XControl
;
21 import com
.sun
.star
.awt
.XControlModel
;
22 import com
.sun
.star
.awt
.XDevice
;
23 import com
.sun
.star
.awt
.XGraphics
;
24 import com
.sun
.star
.awt
.XToolkit
;
25 import com
.sun
.star
.awt
.XWindow
;
26 import com
.sun
.star
.awt
.XWindowPeer
;
27 import com
.sun
.star
.drawing
.XControlShape
;
28 import com
.sun
.star
.text
.XTextDocument
;
29 import com
.sun
.star
.uno
.UnoRuntime
;
30 import com
.sun
.star
.uno
.XInterface
;
31 import com
.sun
.star
.view
.XControlAccess
;
33 import java
.io
.PrintWriter
;
35 import lib
.StatusException
;
37 import lib
.TestEnvironment
;
38 import lib
.TestParameters
;
40 import util
.FormTools
;
41 import util
.WriterTools
;
45 public class UnoSpinButtonControl
extends TestCase
{
46 private static XTextDocument xTextDoc
;
49 protected void initialize(TestParameters Param
, PrintWriter log
) {
50 log
.println("creating a textdocument");
51 xTextDoc
= WriterTools
.createTextDoc(
56 protected void cleanup(TestParameters tParam
, PrintWriter log
) {
57 log
.println(" disposing xTextDoc ");
59 util
.DesktopTools
.closeDoc(xTextDoc
);
63 protected TestEnvironment
createTestEnvironment(TestParameters Param
,
65 XInterface oObj
= null;
66 XWindowPeer the_win
= null;
67 XToolkit the_kit
= null;
68 XDevice aDevice
= null;
69 XGraphics aGraphic
= null;
70 XControl aControl
= null;
72 //Insert a ControlShape and get the ControlModel
73 XControlShape aShape
= FormTools
.createUnoControlShape(xTextDoc
, 3000,
77 "UnoControlSpinButton");
79 WriterTools
.getDrawPage(xTextDoc
).add(aShape
);
81 XControlModel the_Model
= aShape
.getControl();
83 XControlShape aShape2
= FormTools
.createControlShape(xTextDoc
, 3000,
87 WriterTools
.getDrawPage(xTextDoc
).add(aShape2
);
89 XControlModel the_Model2
= aShape2
.getControl();
91 //Try to query XControlAccess
92 XControlAccess the_access
= UnoRuntime
.queryInterface(
94 xTextDoc
.getCurrentController());
96 //get the SpinButtonControl for the needed Object relations
98 oObj
= the_access
.getControl(the_Model
);
99 aControl
= the_access
.getControl(the_Model2
);
100 the_win
= the_access
.getControl(the_Model
).getPeer();
101 the_kit
= the_win
.getToolkit();
102 aDevice
= the_kit
.createScreenCompatibleDevice(200, 200);
103 aGraphic
= aDevice
.createGraphics();
104 } catch (Exception e
) {
105 log
.println("Couldn't get SpinButtonControl");
106 e
.printStackTrace(log
);
107 throw new StatusException("Couldn't get SpinButtonControl", e
);
111 "creating a new environment for UnoControlSpinButton object");
113 TestEnvironment tEnv
= new TestEnvironment(oObj
);
116 //adding Object-Relation for XScrollBar
117 tEnv
.addObjRelation("Document", xTextDoc
);
120 //Adding ObjRelation for XView
121 tEnv
.addObjRelation("GRAPHICS", aGraphic
);
124 //Adding ObjRelation for XControl
125 tEnv
.addObjRelation("CONTEXT", xTextDoc
);
126 tEnv
.addObjRelation("WINPEER", the_win
);
127 tEnv
.addObjRelation("TOOLKIT", the_kit
);
128 tEnv
.addObjRelation("MODEL", the_Model
);
130 XWindow forObjRel
= UnoRuntime
.queryInterface(XWindow
.class,
133 tEnv
.addObjRelation("XWindow.AnotherWindow", forObjRel
);
135 tEnv
.addObjRelation("Document", xTextDoc
);
137 System
.out
.println("ImplementationName: " + utils
.getImplName(oObj
));
140 } // finish method getTestEnvironment