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 .
21 import com
.sun
.star
.container
.XChild
;
22 import com
.sun
.star
.container
.XNamed
;
23 import com
.sun
.star
.uno
.UnoRuntime
;
24 import share
.LogWriter
;
27 * Testing <code>com.sun.star.container.XChild</code>
30 * <li><code> getParent()</code></li>
31 * <li><code> setParent()</code></li>
33 * @see com.sun.star.container.XChild
35 public class _XChild
{
37 public XChild oObj
= null;
38 private Object gotten
= null;
39 private final LogWriter log
= null;
43 * Test calls the method and checks return value and that
44 * no exceptions were thrown. Parent returned is stored.<p>
45 * Has <b> OK </b> status if the method returns not null value
46 * and no exceptions were thrown. <p>
48 public boolean _getParent(boolean hasParent
) {
49 gotten
= oObj
.getParent();
51 return gotten
== null;
52 XNamed the_name
= UnoRuntime
.queryInterface(XNamed
.class,gotten
);
54 log
.println("Parent:"+the_name
.getName());
55 return gotten
!= null;
59 * Sets existing parent and checks that
60 * no exceptions were thrown. <p>
61 * Has <b> OK </b> status if no exceptions were thrown. <p>
62 * The following method tests are to be completed successfully before :
64 * <li> <code> getParent() </code> : to get the parent. </li>
67 public boolean _setParent(boolean supported
) {
68 String parentComment
= null;//String) tEnv.getObjRelation("cannotSwitchParent");
70 if (parentComment
!= null) {
71 log
.println(parentComment
);
76 oObj
.setParent(gotten
);
78 catch (com
.sun
.star
.lang
.NoSupportException ex
) {
79 log
.println("Exception occurred during setParent() - " + (supported?
"FAILED":"OK"));
81 ex
.printStackTrace((java
.io
.PrintWriter
)log
);
88 } // finish class _XChild