1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package ifc.drawing;
25 
26 import lib.MultiMethodTest;
27 
28 import com.sun.star.drawing.XShapeDescriptor;
29 import com.sun.star.lang.XServiceInfo;
30 import com.sun.star.uno.UnoRuntime;
31 
32 /**
33 * Testing <code>com.sun.star.drawing.XShapeDescriptor</code>
34 * interface methods :
35 * <ul>
36 *  <li><code> getShapeType()</code></li>
37 * </ul> <p>
38 * Test is <b> NOT </b> multithread compilant. <p>
39 * @see com.sun.star.drawing.XShapeDescriptor
40 */
41 public class _XShapeDescriptor extends MultiMethodTest {
42 
43     public XShapeDescriptor    oObj = null;
44     boolean result = true;
45 
46     /**
47     * Gets the type of shape. This type must be a service name which
48     * is supported by object (except of ChartObject and Frame shapes).
49     * The object is queried for <code>XServiceInfo</code> and
50     * the type is checked to be among supported service names.<p>
51     *
52     * Has <b> OK </b> status if the type is found among supported
53     * services. Or if the object represents a text frame.<p>
54     */
_getShapeType()55     public void _getShapeType() {
56         result = false;
57 
58         String stype = oObj.getShapeType();
59         log.println("Current Shape Type is " + stype);
60 
61         XServiceInfo SI = (XServiceInfo)
62                         UnoRuntime.queryInterface(XServiceInfo.class, oObj);
63 
64         String[] serviceNames = SI.getSupportedServiceNames();
65 
66         log.println("Supported services :");
67         for (int i = 0; i < serviceNames.length; i++) {
68             log.println("  " + serviceNames[i]);
69             if (serviceNames[i].equals(stype))
70                 result = true;
71         }
72 
73         //remark: we should provide the expected name as ObjRelation
74 
75         //Chart has its own behaviour it always return 'ChartObject'
76         if (stype.equals("com.sun.star.chart.ChartObject")) result=true;
77         if (stype.equals("com.sun.star.drawing.ControlShape")) result=true;
78         if (stype.equals("com.sun.star.drawing.ClosedBezierShape")) result=true;
79         if (stype.equals("com.sun.star.drawing.CaptionShape")) result=true;
80 
81         //Writer has its own behaviour it returns a 'FrameShape'
82         if (stype.equals("FrameShape")) result=true;
83 
84         if (!result) {
85             log.println("Service " + stype + " not supported in the object.");
86         }
87 
88         tRes.tested("getShapeType()", result);
89     }
90 
91 }
92 
93 
94