1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
30 import lib
.MultiMethodTest
;
32 import com
.sun
.star
.drawing
.XShapeDescriptor
;
33 import com
.sun
.star
.lang
.XServiceInfo
;
34 import com
.sun
.star
.uno
.UnoRuntime
;
37 * Testing <code>com.sun.star.drawing.XShapeDescriptor</code>
40 * <li><code> getShapeType()</code></li>
42 * Test is <b> NOT </b> multithread compilant. <p>
43 * @see com.sun.star.drawing.XShapeDescriptor
45 public class _XShapeDescriptor
extends MultiMethodTest
{
47 public XShapeDescriptor oObj
= null;
48 boolean result
= true;
51 * Gets the type of shape. This type must be a service name which
52 * is supported by object (except of ChartObject and Frame shapes).
53 * The object is queried for <code>XServiceInfo</code> and
54 * the type is checked to be among supported service names.<p>
56 * Has <b> OK </b> status if the type is found among supported
57 * services. Or if the object represents a text frame.<p>
59 public void _getShapeType() {
62 String stype
= oObj
.getShapeType();
63 log
.println("Current Shape Type is " + stype
);
65 XServiceInfo SI
= (XServiceInfo
)
66 UnoRuntime
.queryInterface(XServiceInfo
.class, oObj
);
68 String
[] serviceNames
= SI
.getSupportedServiceNames();
70 log
.println("Supported services :");
71 for (int i
= 0; i
< serviceNames
.length
; i
++) {
72 log
.println(" " + serviceNames
[i
]);
73 if (serviceNames
[i
].equals(stype
))
77 //remark: we should provide the expected name as ObjRelation
79 //Chart has its own behaviour it always return 'ChartObject'
80 if (stype
.equals("com.sun.star.chart.ChartObject")) result
=true;
81 if (stype
.equals("com.sun.star.drawing.ControlShape")) result
=true;
82 if (stype
.equals("com.sun.star.drawing.ClosedBezierShape")) result
=true;
83 if (stype
.equals("com.sun.star.drawing.CaptionShape")) result
=true;
85 //Writer has its own behaviour it returns a 'FrameShape'
86 if (stype
.equals("FrameShape")) result
=true;
89 log
.println("Service " + stype
+ " not supported in the object.");
92 tRes
.tested("getShapeType()", result
);