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 30 import com.sun.star.beans.XPropertySet; 31 import com.sun.star.chart.XChartDocument; 32 import com.sun.star.chart.XDiagram; 33 import com.sun.star.uno.UnoRuntime; 34 35 /** 36 * Testing <code>com.sun.star.chart.ChartTwoAxisYSupplier</code> 37 * service properties : 38 * <ul> 39 * <li><code> HasSecondaryYAxis</code></li> 40 * <li><code> HasSecondaryYAxisDescription</code></li> 41 * </ul> <p> 42 * This test needs the following object relations : 43 * <ul> 44 * <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>): 45 * to have reference to chart document </li> 46 * <li> <code>'BAR'</code> (of type <code>XDiagram</code>): 47 * relation that use as parameter for method setDiagram of chart document </li> 48 * </ul> <p> 49 * @see com.sun.star.chart.ChartTwoAxisYSupplier 50 */ 51 public class _ChartTwoAxisYSupplier extends MultiPropertyTest { 52 53 XChartDocument doc = null; 54 XDiagram oldDiagram = null; 55 56 /** 57 * Retrieves object relations and prepares a chart document. 58 * @throws StatusException if one of relations not found. 59 */ before()60 protected void before() { 61 log.println("Setting Diagram type to BarDiagram"); 62 doc = (XChartDocument) tEnv.getObjRelation("CHARTDOC"); 63 if (doc == null) throw new StatusException(Status.failed 64 ("Relation 'CHARTDOC' not found")); 65 66 XDiagram bar = (XDiagram) tEnv.getObjRelation("BAR"); 67 if (bar == null) throw new StatusException(Status.failed 68 ("Relation 'BAR' not found")); 69 70 oldDiagram = doc.getDiagram(); 71 72 doc.setDiagram(bar); 73 log.println("Set it to 3D"); 74 oObj = (XPropertySet) 75 UnoRuntime.queryInterface( XPropertySet.class, doc.getDiagram() ); 76 try { 77 oObj.setPropertyValue("Dim3D", new Boolean(true)); 78 } catch(com.sun.star.lang.WrappedTargetException e) { 79 log.println("Exception while set property value"); 80 e.printStackTrace(log); 81 throw new StatusException("Exception while set property value", e); 82 } catch(com.sun.star.lang.IllegalArgumentException e) { 83 log.println("Exception while set property value"); 84 e.printStackTrace(log); 85 throw new StatusException("Exception while set property value", e); 86 } catch(com.sun.star.beans.PropertyVetoException e) { 87 log.println("Exception while set property value"); 88 e.printStackTrace(log); 89 throw new StatusException("Exception while set property value", e); 90 } catch(com.sun.star.beans.UnknownPropertyException e) { 91 log.println("Exception while set property value"); 92 e.printStackTrace(log); 93 throw new StatusException("Exception while set property value", e); 94 } 95 } 96 97 /** 98 * Sets the old diagram for a chart document. 99 */ after()100 protected void after() { 101 doc.setDiagram(oldDiagram); 102 } 103 } // EOF ChartTwoAxisYSupplier 104 105