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 import util.ValueChanger;
28 
29 import com.sun.star.awt.Point;
30 import com.sun.star.beans.XPropertySet;
31 import com.sun.star.lang.XServiceInfo;
32 import com.sun.star.uno.UnoRuntime;
33 
34 
35 public class _LineShapeDescriptor extends MultiMethodTest {
36 
37     public XPropertySet oObj = null;        // oObj filled by MultiMethodTest
38 
39 
_LineColor()40     public void _LineColor() {
41         XServiceInfo xInfo = (XServiceInfo)
42             UnoRuntime.queryInterface(XServiceInfo.class, oObj);
43         if ( ! xInfo.supportsService
44                 ("com.sun.star.drawing.LineShapeDescriptor")) {
45             log.println("Service not available !!!!!!!!!!!!!");
46             tRes.tested("Supported", false);
47         }
48         changeProp("LineColor");
49     }
50 
_LineDash()51     public void _LineDash() {
52         changeProp("LineDash");
53     }
_LineEnd()54     public void _LineEnd() {
55         changeProp("LineEnd");
56     }
_LineEndCenter()57     public void _LineEndCenter() {
58         changeProp("LineEndCenter");
59     }
_LineEndWidth()60     public void _LineEndWidth() {
61         changeProp("LineEndWidth");
62     }
_LineJoint()63     public void _LineJoint() {
64         changeProp("LineJoint");
65     }
_LineStart()66     public void _LineStart() {
67         changeProp("LineStart");
68     }
_LineStartCenter()69     public void _LineStartCenter() {
70         changeProp("LineStartCenter");
71     }
_LineStartWidth()72     public void _LineStartWidth() {
73         changeProp("LineStartWidth");
74     }
_LineStyle()75     public void _LineStyle() {
76         changeProp("LineStyle");
77     }
_LineTransparence()78     public void _LineTransparence() {
79         changeProp("LineTransparence");
80     }
_LineWidth()81     public void _LineWidth() {
82         changeProp("LineWidth");
83     }
84 
changeProp(String name)85     public void changeProp(String name) {
86 
87         Object gValue = null;
88         Object sValue = null;
89         Object ValueToSet = null;
90 
91         try {
92             //waitForAllThreads();
93             gValue = oObj.getPropertyValue(name);
94             //waitForAllThreads();
95             if ( (name.equals("LineEnd")) || (name.equals("LineStart")) ) {
96                 if (gValue == null) gValue = newPoints(null);
97                 ValueToSet = newPoints( (Point[]) gValue);
98             }
99             else {
100                 ValueToSet = ValueChanger.changePValue(gValue);
101             }
102             //waitForAllThreads();
103             oObj.setPropertyValue(name,ValueToSet);
104             sValue = oObj.getPropertyValue(name);
105 
106 
107          //check get-set methods
108          if (gValue.equals(sValue)) {
109             log.println("Value for '"+name+"' hasn't changed");
110             tRes.tested(name, false);
111         }
112         else {
113             log.println("Property '"+name+"' OK");
114             tRes.tested(name, true);
115         }
116         } catch (Exception e) {
117             log.println("Exception occurred while testing property '" +
118                  name + "'");
119             e.printStackTrace(log);
120             tRes.tested(name, false);
121         }
122 
123 
124     } // end of ChangeProp
125 
newPoints(Point[] old)126     public Point[] newPoints(Point[] old) {
127 
128         Point [] newP = new Point[3];
129 
130         if (old == null) {
131             newP[0] = new Point(0, 2);
132             newP[1] = new Point(2, 0);
133             newP[2] = new Point(0, -2);
134         }
135         else {
136             newP = old;
137             newP[0].X += 1;
138             newP[1].X += 1;
139             newP[2].X += 1;
140         }
141         return newP;
142     }
143 
144 }
145 
146 
147