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
.text
.XTextDocument
;
27 import com
.sun
.star
.uno
.AnyConverter
;
28 import com
.sun
.star
.uno
.Type
;
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 TabController
extends TestCase
{
46 private static XTextDocument xTextDoc
= null;
49 protected void initialize(TestParameters param
, PrintWriter log
) {
51 log
.println("creating a textdocument");
52 xTextDoc
= WriterTools
.createTextDoc(
54 } catch (Exception e
) {
55 // Some exception occurs.FAILED
56 e
.printStackTrace(log
);
57 throw new StatusException("Couldn't create document", e
);
62 protected void cleanup(TestParameters param
, PrintWriter log
) {
63 log
.println("disposing xTextDoc");
64 util
.DesktopTools
.closeDoc(xTextDoc
);
68 public TestEnvironment
createTestEnvironment(TestParameters param
,
70 XInterface oObj
= null;
71 XControl xCtrl1
= null;
72 XTabControllerModel tabCtrlModel
= null;
73 XControlContainer aCtrlContainer
= null;
76 // create object relations
77 FormTools
.insertForm(xTextDoc
,
78 FormTools
.getForms(WriterTools
.getDrawPage(
79 xTextDoc
)), "MyForm");
81 XControlShape aShape
= FormTools
.createUnoControlShape(xTextDoc
, 3000,
86 WriterTools
.getDrawPage(xTextDoc
).add(aShape
);
88 XControlModel model
= aShape
.getControl();
89 XControlAccess access
= UnoRuntime
.queryInterface(
91 xTextDoc
.getCurrentController());
94 xCtrl1
= access
.getControl(model
);
95 } catch (Exception e
) {
101 form
= (XForm
) AnyConverter
.toObject(new Type(XForm
.class),
103 WriterTools
.getDrawPage(
105 .getByName("MyForm"));
106 } catch (Exception e
) {
107 log
.println("Couldn't get Form");
108 e
.printStackTrace(log
);
111 tabCtrlModel
= UnoRuntime
.queryInterface(
112 XTabControllerModel
.class, form
);
114 aCtrlContainer
= UnoRuntime
.queryInterface(
115 XControlContainer
.class, xCtrl1
.getContext());
119 oObj
= (XInterface
) param
.getMSF().createInstance(
120 "com.sun.star.awt.TabController");
121 } catch (Exception e
) {
124 TestEnvironment tEnv
= new TestEnvironment(oObj
);
126 String objName
= "TabController";
127 tEnv
.addObjRelation("OBJNAME", "toolkit." + objName
);
128 tEnv
.addObjRelation("MODEL", tabCtrlModel
);
129 tEnv
.addObjRelation("CONTAINER", aCtrlContainer
);
130 System
.out
.println("ImplementationName: " + utils
.getImplName(oObj
));