merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / drawing / _ShapeDescriptor.java
blob6bbcdad152c0bed9893b62f49fc65c048dc14f5f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _ShapeDescriptor.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.drawing;
33 import lib.MultiMethodTest;
34 import util.ValueChanger;
36 import com.sun.star.beans.XPropertySet;
37 import com.sun.star.style.XStyle;
38 import com.sun.star.uno.UnoRuntime;
41 public class _ShapeDescriptor extends MultiMethodTest {
43 public XPropertySet oObj = null; // oObj filled by MultiMethodTest
44 public boolean ro = false;
46 public void _LayerID() {
47 com.sun.star.lang.XServiceInfo xInfo = (com.sun.star.lang.XServiceInfo)
48 UnoRuntime.queryInterface
49 (com.sun.star.lang.XServiceInfo.class, oObj);
50 if ( ! xInfo.supportsService("com.sun.star.drawing.ShapeDescriptor")) {
51 log.println("Service not available !!!!!!!!!!!!!");
52 tRes.tested("Supported", false);
54 ro = true;
55 changeProp("LayerID");
56 ro = false;
58 public void _LayerName() {
59 ro = true;
60 changeProp("LayerName");
61 ro = false;
63 public void _MoveProtect() {
64 changeProp("MoveProtect");
66 public void _Name() {
67 changeProp("Name");
69 public void _Printable() {
70 changeProp("Printable");
72 public void _SizeProtect() {
73 changeProp("SizeProtect");
75 public void _Style() {
76 changeProp("Style");
79 public void _Transformation() {
80 changeProp("Transformation");
83 public void changeProp(String name) {
85 Object gValue = null;
86 Object sValue = null;
87 Object ValueToSet = null;
90 try {
91 //waitForAllThreads();
92 gValue = oObj.getPropertyValue(name);
93 //waitForAllThreads();
94 if (!ro) {
95 ValueToSet = ValueChanger.changePValue(gValue);
96 if ( name.equals("Style") ) {
97 ValueToSet = newStyle(gValue);
99 //waitForAllThreads();
100 oObj.setPropertyValue(name,ValueToSet);
101 sValue = oObj.getPropertyValue(name);
104 //check get-set methods
105 if (gValue.equals(sValue)) {
106 log.println("Value for '"+name+"' hasn't changed");
107 tRes.tested(name, false);
108 } else {
109 log.println("Property '"+name+"' OK");
110 tRes.tested(name, true);
112 } catch (com.sun.star.beans.UnknownPropertyException ex) {
113 if (isOptional(name)) {
114 log.println("Property '"+name+
115 "' is optional and not supported");
116 tRes.tested(name,true);
117 } else {
118 log.println("Exception occured while testing property '" +
119 name + "'");
120 ex.printStackTrace(log);
121 tRes.tested(name, false);
124 catch (Exception e) {
125 log.println("Exception occured while testing property '" +
126 name + "'");
127 e.printStackTrace(log);
128 tRes.tested(name, false);
132 }// end of changeProp
134 public XStyle newStyle(Object oldStyle) {
135 XStyle Style1 = (XStyle) tEnv.getObjRelation("Style1");
136 XStyle Style2 = (XStyle) tEnv.getObjRelation("Style2");
137 XStyle back = null;
138 if ( (Style1!=null) && (Style2!=null) ) {
139 if ( ((XStyle) oldStyle).equals(Style1) ) {
140 back = Style2;
141 } else {
142 back = Style1;
145 return back;