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
.XControlContainer
;
22 import com
.sun
.star
.awt
.XControlModel
;
23 import com
.sun
.star
.awt
.XTabControllerModel
;
24 import com
.sun
.star
.drawing
.XControlShape
;
25 import com
.sun
.star
.form
.XForm
;
26 import com
.sun
.star
.lang
.XMultiServiceFactory
;
27 import com
.sun
.star
.text
.XTextDocument
;
28 import com
.sun
.star
.uno
.AnyConverter
;
29 import com
.sun
.star
.uno
.Type
;
30 import com
.sun
.star
.uno
.UnoRuntime
;
31 import com
.sun
.star
.uno
.XInterface
;
32 import com
.sun
.star
.view
.XControlAccess
;
34 import java
.io
.PrintWriter
;
36 import lib
.StatusException
;
38 import lib
.TestEnvironment
;
39 import lib
.TestParameters
;
41 import util
.FormTools
;
42 import util
.WriterTools
;
46 public class TabController
extends TestCase
{
47 private static XTextDocument xTextDoc
= null;
49 protected void initialize(TestParameters param
, PrintWriter log
) {
51 log
.println("creating a textdocument");
52 xTextDoc
= WriterTools
.createTextDoc(
53 (XMultiServiceFactory
) param
.getMSF());
54 } catch (Exception e
) {
55 // Some exception occurs.FAILED
56 e
.printStackTrace(log
);
57 throw new StatusException("Couldn't create document", e
);
61 protected void cleanup(TestParameters param
, PrintWriter log
) {
62 log
.println("disposing xTextDoc");
63 util
.DesktopTools
.closeDoc(xTextDoc
);
66 public TestEnvironment
createTestEnvironment(TestParameters param
,
68 XInterface oObj
= null;
69 XControl xCtrl1
= null;
70 XTabControllerModel tabCtrlModel
= null;
71 XControlContainer aCtrlContainer
= null;
74 // create object relations
75 FormTools
.insertForm(xTextDoc
,
76 FormTools
.getForms(WriterTools
.getDrawPage(
77 xTextDoc
)), "MyForm");
79 XControlShape aShape
= FormTools
.createUnoControlShape(xTextDoc
, 3000,
84 WriterTools
.getDrawPage(xTextDoc
).add(aShape
);
86 XControlModel model
= aShape
.getControl();
87 XControlAccess access
= UnoRuntime
.queryInterface(
89 xTextDoc
.getCurrentController());
92 xCtrl1
= access
.getControl(model
);
93 } catch (Exception e
) {
99 form
= (XForm
) AnyConverter
.toObject(new Type(XForm
.class),
101 WriterTools
.getDrawPage(
103 .getByName("MyForm"));
104 } catch (Exception e
) {
105 log
.println("Couldn't get Form");
106 e
.printStackTrace(log
);
109 tabCtrlModel
= UnoRuntime
.queryInterface(
110 XTabControllerModel
.class, form
);
112 aCtrlContainer
= UnoRuntime
.queryInterface(
113 XControlContainer
.class, xCtrl1
.getContext());
117 oObj
= (XInterface
) ((XMultiServiceFactory
) param
.getMSF()).createInstance(
118 "com.sun.star.awt.TabController");
119 } catch (Exception e
) {
122 TestEnvironment tEnv
= new TestEnvironment(oObj
);
124 String objName
= "TabController";
125 tEnv
.addObjRelation("OBJNAME", "toolkit." + objName
);
126 tEnv
.addObjRelation("MODEL", tabCtrlModel
);
127 tEnv
.addObjRelation("CONTAINER", aCtrlContainer
);
128 System
.out
.println("ImplementationName: " + utils
.getImplName(oObj
));