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.chart; 25 26 import lib.MultiPropertyTest; 27 import lib.Status; 28 import lib.StatusException; 29 import util.utils; 30 31 import com.sun.star.chart.XChartDocument; 32 import com.sun.star.chart.XDiagram; 33 34 /** 35 * Testing <code>com.sun.star.chart.ChartDataPointProperties</code> 36 * service properties : 37 * <ul> 38 * <li><code> DataCaption</code></li> 39 * <li><code> SymbolType</code></li> 40 * <li><code> SymbolBitmapURL</code></li> 41 * </ul> <p> 42 * The following predefined files needed to complete the test: 43 * <ul> 44 * <li> <code>space-metal.jpg</code> : 45 * for test of property 'SymbolBitmapURL' </li> 46 * <ul> <p> 47 * This test needs the following object relations : 48 * <ul> 49 * <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>): 50 * to have reference to chart document </li> 51 * <li> <code>'LINE'</code> (of type <code>XDiagram</code>): 52 * relation that use as parameter for method setDiagram of chart document </li> 53 * </ul> <p> 54 * @see com.sun.star.chart.ChartDataPointProperties 55 */ 56 public class _ChartDataPointProperties extends MultiPropertyTest { 57 58 /** 59 * Retrieves object relations and prepares a chart document. 60 * @throws StatusException if one of relations not found. 61 */ before()62 protected void before() { 63 log.println("Setting Diagram type to LineDiagram"); 64 XChartDocument doc = (XChartDocument) tEnv.getObjRelation("CHARTDOC"); 65 if (doc == null) throw new StatusException(Status.failed 66 ("Relation 'CHARTDOC' not found")); 67 68 XDiagram Line = (XDiagram) tEnv.getObjRelation("LINE"); 69 if (Line == null) throw new StatusException(Status.failed 70 ("Relation 'LINE' not found")); 71 72 doc.setDiagram(Line); 73 } 74 75 protected PropertyTester URLTester = new PropertyTester() { 76 protected Object getNewValue(String propName, Object oldValue) 77 throws java.lang.IllegalArgumentException { 78 return utils.getFullTestURL("space-metal.jpg"); 79 } 80 }; 81 82 /** 83 * Tests property 'SymbolBitmapURL' using file <code>polibal.gif</code>. 84 */ _SymbolBitmapURL()85 public void _SymbolBitmapURL() { 86 try { 87 oObj.setPropertyValue( 88 "SymbolType", 89 new Integer(com.sun.star.chart.ChartSymbolType.BITMAPURL) ); 90 } catch(com.sun.star.lang.WrappedTargetException e) { 91 log.println("Exception while set property value"); 92 e.printStackTrace(log); 93 throw new StatusException("Exception while set property value", e); 94 } catch(com.sun.star.lang.IllegalArgumentException e) { 95 log.println("Exception while set property value"); 96 e.printStackTrace(log); 97 throw new StatusException("Exception while set property value", e); 98 } catch(com.sun.star.beans.PropertyVetoException e) { 99 log.println("Exception while set property value"); 100 e.printStackTrace(log); 101 throw new StatusException("Exception while set property value", e); 102 } catch(com.sun.star.beans.UnknownPropertyException e) { 103 log.println("Exception while set property value"); 104 e.printStackTrace(log); 105 throw new StatusException("Exception while set property value", e); 106 } 107 108 testProperty("SymbolBitmapURL", URLTester); 109 } 110 } 111 112