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
.XControlModel
;
21 import com
.sun
.star
.awt
.XWindow
;
22 import com
.sun
.star
.awt
.XWindowPeer
;
23 import com
.sun
.star
.drawing
.XControlShape
;
24 import com
.sun
.star
.frame
.XController
;
25 import com
.sun
.star
.frame
.XModel
;
26 import com
.sun
.star
.text
.XTextDocument
;
27 import com
.sun
.star
.uno
.UnoRuntime
;
28 import com
.sun
.star
.uno
.XInterface
;
29 import com
.sun
.star
.view
.XControlAccess
;
31 import java
.io
.PrintWriter
;
34 import lib
.TestEnvironment
;
35 import lib
.TestParameters
;
37 import util
.FormTools
;
38 import util
.SOfficeFactory
;
39 import util
.WriterTools
;
44 * Test for <code>com.sun.star.awt.Toolkit</code> service.
46 public class Toolkit
extends TestCase
{
47 private static XTextDocument xTextDoc
;
50 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
51 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
54 log
.println("creating a textdocument");
55 xTextDoc
= SOF
.createTextDoc(null);
59 protected void cleanup(TestParameters tParam
, PrintWriter log
) {
60 log
.println(" disposing xTextDoc ");
61 util
.DesktopTools
.closeDoc(xTextDoc
);
65 * Creating a TestEnvironment for the interfaces to be tested.
66 * Creates <code>com.sun.star.awt.Toolkit</code> service.
69 public TestEnvironment
createTestEnvironment(TestParameters Param
,
72 XInterface oObj
= null;
73 XWindowPeer the_win
= null;
76 //Insert a ControlShape and get the ControlModel
77 XControlShape aShape
= FormTools
.createControlShape(xTextDoc
, 3000,
81 WriterTools
.getDrawPage(xTextDoc
).add(aShape
);
83 XControlModel the_Model
= aShape
.getControl();
85 //Try to query XControlAccess
86 XControlAccess the_access
= UnoRuntime
.queryInterface(
88 xTextDoc
.getCurrentController());
89 XController cntrlr
= UnoRuntime
.queryInterface(
91 xTextDoc
.getCurrentController());
94 win
= cntrlr
.getFrame().getContainerWindow();
96 the_win
= the_access
.getControl(the_Model
).getPeer();
97 oObj
= (XInterface
) Param
.getMSF().createInstance(
98 "com.sun.star.awt.Toolkit");
100 XModel xModel
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
102 log
.println(" creating a new environment for toolkit object");
104 TestEnvironment tEnv
= new TestEnvironment(oObj
);
106 log
.println("Implementation Name: " + utils
.getImplName(oObj
));
108 tEnv
.addObjRelation("WINPEER", the_win
);
110 tEnv
.addObjRelation("XModel", xModel
);
113 // adding relation for XDataTransferProviderAccess
114 tEnv
.addObjRelation("XDataTransferProviderAccess.XWindow", win
);
117 } // finish method getTestEnvironment
118 } // finish class Toolkit