1*ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ef39d40dSAndrew Rist  * distributed with this work for additional information
6*ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9*ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ef39d40dSAndrew Rist  *
11*ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ef39d40dSAndrew Rist  *
13*ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15*ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18*ef39d40dSAndrew Rist  * under the License.
19*ef39d40dSAndrew Rist  *
20*ef39d40dSAndrew Rist  *************************************************************/
21*ef39d40dSAndrew Rist 
22*ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.drawing;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import lib.MultiMethodTest;
27cdf0e10cSrcweir import util.ValueChanger;
28cdf0e10cSrcweir 
29cdf0e10cSrcweir import com.sun.star.awt.Point;
30cdf0e10cSrcweir import com.sun.star.beans.XPropertySet;
31cdf0e10cSrcweir import com.sun.star.lang.XServiceInfo;
32cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 
35cdf0e10cSrcweir public class _LineShapeDescriptor extends MultiMethodTest {
36cdf0e10cSrcweir 
37cdf0e10cSrcweir     public XPropertySet oObj = null;        // oObj filled by MultiMethodTest
38cdf0e10cSrcweir 
39cdf0e10cSrcweir 
_LineColor()40cdf0e10cSrcweir     public void _LineColor() {
41cdf0e10cSrcweir         XServiceInfo xInfo = (XServiceInfo)
42cdf0e10cSrcweir             UnoRuntime.queryInterface(XServiceInfo.class, oObj);
43cdf0e10cSrcweir         if ( ! xInfo.supportsService
44cdf0e10cSrcweir                 ("com.sun.star.drawing.LineShapeDescriptor")) {
45cdf0e10cSrcweir             log.println("Service not available !!!!!!!!!!!!!");
46cdf0e10cSrcweir             tRes.tested("Supported", false);
47cdf0e10cSrcweir         }
48cdf0e10cSrcweir         changeProp("LineColor");
49cdf0e10cSrcweir     }
50cdf0e10cSrcweir 
_LineDash()51cdf0e10cSrcweir     public void _LineDash() {
52cdf0e10cSrcweir         changeProp("LineDash");
53cdf0e10cSrcweir     }
_LineEnd()54cdf0e10cSrcweir     public void _LineEnd() {
55cdf0e10cSrcweir         changeProp("LineEnd");
56cdf0e10cSrcweir     }
_LineEndCenter()57cdf0e10cSrcweir     public void _LineEndCenter() {
58cdf0e10cSrcweir         changeProp("LineEndCenter");
59cdf0e10cSrcweir     }
_LineEndWidth()60cdf0e10cSrcweir     public void _LineEndWidth() {
61cdf0e10cSrcweir         changeProp("LineEndWidth");
62cdf0e10cSrcweir     }
_LineJoint()63cdf0e10cSrcweir     public void _LineJoint() {
64cdf0e10cSrcweir         changeProp("LineJoint");
65cdf0e10cSrcweir     }
_LineStart()66cdf0e10cSrcweir     public void _LineStart() {
67cdf0e10cSrcweir         changeProp("LineStart");
68cdf0e10cSrcweir     }
_LineStartCenter()69cdf0e10cSrcweir     public void _LineStartCenter() {
70cdf0e10cSrcweir         changeProp("LineStartCenter");
71cdf0e10cSrcweir     }
_LineStartWidth()72cdf0e10cSrcweir     public void _LineStartWidth() {
73cdf0e10cSrcweir         changeProp("LineStartWidth");
74cdf0e10cSrcweir     }
_LineStyle()75cdf0e10cSrcweir     public void _LineStyle() {
76cdf0e10cSrcweir         changeProp("LineStyle");
77cdf0e10cSrcweir     }
_LineTransparence()78cdf0e10cSrcweir     public void _LineTransparence() {
79cdf0e10cSrcweir         changeProp("LineTransparence");
80cdf0e10cSrcweir     }
_LineWidth()81cdf0e10cSrcweir     public void _LineWidth() {
82cdf0e10cSrcweir         changeProp("LineWidth");
83cdf0e10cSrcweir     }
84cdf0e10cSrcweir 
changeProp(String name)85cdf0e10cSrcweir     public void changeProp(String name) {
86cdf0e10cSrcweir 
87cdf0e10cSrcweir         Object gValue = null;
88cdf0e10cSrcweir         Object sValue = null;
89cdf0e10cSrcweir         Object ValueToSet = null;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir         try {
92cdf0e10cSrcweir             //waitForAllThreads();
93cdf0e10cSrcweir             gValue = oObj.getPropertyValue(name);
94cdf0e10cSrcweir             //waitForAllThreads();
95cdf0e10cSrcweir             if ( (name.equals("LineEnd")) || (name.equals("LineStart")) ) {
96cdf0e10cSrcweir                 if (gValue == null) gValue = newPoints(null);
97cdf0e10cSrcweir                 ValueToSet = newPoints( (Point[]) gValue);
98cdf0e10cSrcweir             }
99cdf0e10cSrcweir             else {
100cdf0e10cSrcweir                 ValueToSet = ValueChanger.changePValue(gValue);
101cdf0e10cSrcweir             }
102cdf0e10cSrcweir             //waitForAllThreads();
103cdf0e10cSrcweir             oObj.setPropertyValue(name,ValueToSet);
104cdf0e10cSrcweir             sValue = oObj.getPropertyValue(name);
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 
107cdf0e10cSrcweir          //check get-set methods
108cdf0e10cSrcweir          if (gValue.equals(sValue)) {
109cdf0e10cSrcweir             log.println("Value for '"+name+"' hasn't changed");
110cdf0e10cSrcweir             tRes.tested(name, false);
111cdf0e10cSrcweir         }
112cdf0e10cSrcweir         else {
113cdf0e10cSrcweir             log.println("Property '"+name+"' OK");
114cdf0e10cSrcweir             tRes.tested(name, true);
115cdf0e10cSrcweir         }
116cdf0e10cSrcweir         } catch (Exception e) {
117cdf0e10cSrcweir             log.println("Exception occured while testing property '" +
118cdf0e10cSrcweir                  name + "'");
119cdf0e10cSrcweir             e.printStackTrace(log);
120cdf0e10cSrcweir             tRes.tested(name, false);
121cdf0e10cSrcweir         }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     } // end of ChangeProp
125cdf0e10cSrcweir 
newPoints(Point[] old)126cdf0e10cSrcweir     public Point[] newPoints(Point[] old) {
127cdf0e10cSrcweir 
128cdf0e10cSrcweir         Point [] newP = new Point[3];
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         if (old == null) {
131cdf0e10cSrcweir             newP[0] = new Point(0, 2);
132cdf0e10cSrcweir             newP[1] = new Point(2, 0);
133cdf0e10cSrcweir             newP[2] = new Point(0, -2);
134cdf0e10cSrcweir         }
135cdf0e10cSrcweir         else {
136cdf0e10cSrcweir             newP = old;
137cdf0e10cSrcweir             newP[0].X += 1;
138cdf0e10cSrcweir             newP[1].X += 1;
139cdf0e10cSrcweir             newP[2].X += 1;
140cdf0e10cSrcweir         }
141cdf0e10cSrcweir         return newP;
142cdf0e10cSrcweir     }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 
147