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.MultiPropertyTest; 27cdf0e10cSrcweir 28cdf0e10cSrcweir import com.sun.star.container.XNamed; 29cdf0e10cSrcweir import com.sun.star.drawing.XDrawPage; 30cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 31cdf0e10cSrcweir import util.ValueChanger; 32cdf0e10cSrcweir 33cdf0e10cSrcweir /** 34cdf0e10cSrcweir * Testing <code>com.sun.star.drawing.DrawingDocumentDrawView</code> 35cdf0e10cSrcweir * service properties : 36cdf0e10cSrcweir * <ul> 37cdf0e10cSrcweir * <li><code> IsMasterPageMode</code></li> 38cdf0e10cSrcweir * <li><code> IsLayerMode</code></li> 39cdf0e10cSrcweir * </ul> <p> 40cdf0e10cSrcweir * This test needs the following object relations : 41cdf0e10cSrcweir * <ul> 42cdf0e10cSrcweir * <li> <code>'DrawPage'</code> (of type <code>XDrawPage</code>): 43cdf0e10cSrcweir * a draw page which will be current page. </li> 44cdf0e10cSrcweir * <ul> <p> 45cdf0e10cSrcweir * Properties testing is automated by <code>lib.MultiPropertyTest</code>. 46cdf0e10cSrcweir * @see com.sun.star.drawing.DrawingDocumentDrawView 47cdf0e10cSrcweir */ 48cdf0e10cSrcweir public class _DrawingDocumentDrawView extends MultiPropertyTest { 49cdf0e10cSrcweir 50cdf0e10cSrcweir XDrawPage drawPage = null; 51cdf0e10cSrcweir static String test_name = "For DrawingDocumentDrawView"; 52cdf0e10cSrcweir before()53cdf0e10cSrcweir protected void before() { 54cdf0e10cSrcweir drawPage = (XDrawPage)tEnv.getObjRelation("DrawPage"); 55cdf0e10cSrcweir XNamed xNamed = (XNamed) 56cdf0e10cSrcweir UnoRuntime.queryInterface(XNamed.class, drawPage); 57cdf0e10cSrcweir xNamed.setName(test_name); 58cdf0e10cSrcweir } 59cdf0e10cSrcweir 60cdf0e10cSrcweir /** 61cdf0e10cSrcweir * Property tester which returns new <code>XDrawPage</code> object 62cdf0e10cSrcweir * and compares draw pages. 63cdf0e10cSrcweir */ 64cdf0e10cSrcweir protected PropertyTester CurPageTester = new PropertyTester() { 65cdf0e10cSrcweir protected Object getNewValue(String propName, Object oldValue) { 66cdf0e10cSrcweir return drawPage; 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir protected boolean compare(Object obj1, Object obj2) { 70cdf0e10cSrcweir XNamed named1 = (XNamed)UnoRuntime.queryInterface(XNamed.class, obj1); 71cdf0e10cSrcweir XNamed named2 = (XNamed)UnoRuntime.queryInterface(XNamed.class, obj2); 72cdf0e10cSrcweir boolean res = false; 73cdf0e10cSrcweir 74cdf0e10cSrcweir if (named1 != null && named2 != null) { 75cdf0e10cSrcweir String name1 = named1.getName(); 76cdf0e10cSrcweir String name2 = named2.getName(); 77cdf0e10cSrcweir res = name1.equals(name2); 78cdf0e10cSrcweir } else { 79cdf0e10cSrcweir log.println("Interface XNamed not supported"); 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir return res; 83cdf0e10cSrcweir } 84cdf0e10cSrcweir 85cdf0e10cSrcweir protected String toString(Object obj) { 86cdf0e10cSrcweir XNamed named = (XNamed)UnoRuntime.queryInterface(XNamed.class, obj); 87cdf0e10cSrcweir String res = (named == null) ? "null" : named.getName(); 88cdf0e10cSrcweir return res; 89cdf0e10cSrcweir } 90cdf0e10cSrcweir } ; 91cdf0e10cSrcweir _CurrentPage()92cdf0e10cSrcweir public void _CurrentPage() { 93cdf0e10cSrcweir log.println("Testing with custom Property tester"); 94cdf0e10cSrcweir Object oldCurPage = null; 95cdf0e10cSrcweir try { 96cdf0e10cSrcweir oldCurPage = oObj.getPropertyValue("CurrentPage"); 97cdf0e10cSrcweir } catch(com.sun.star.lang.WrappedTargetException e) { 98cdf0e10cSrcweir e.printStackTrace(log); 99cdf0e10cSrcweir } catch(com.sun.star.beans.UnknownPropertyException e) { 100cdf0e10cSrcweir e.printStackTrace(log); 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir testProperty("CurrentPage", CurPageTester); 104cdf0e10cSrcweir 105cdf0e10cSrcweir try { 106cdf0e10cSrcweir log.println("Back old current page"); 107cdf0e10cSrcweir oObj.setPropertyValue("CurrentPage", oldCurPage); 108cdf0e10cSrcweir } catch(com.sun.star.lang.WrappedTargetException e) { 109cdf0e10cSrcweir e.printStackTrace(log); 110cdf0e10cSrcweir } catch(com.sun.star.beans.UnknownPropertyException e) { 111cdf0e10cSrcweir e.printStackTrace(log); 112cdf0e10cSrcweir } catch(com.sun.star.lang.IllegalArgumentException e) { 113cdf0e10cSrcweir e.printStackTrace(log); 114cdf0e10cSrcweir } catch(com.sun.star.beans.PropertyVetoException e) { 115cdf0e10cSrcweir e.printStackTrace(log); 116cdf0e10cSrcweir } 117cdf0e10cSrcweir } 118cdf0e10cSrcweir _IsMasterPageMode()119cdf0e10cSrcweir public void _IsMasterPageMode() { 120cdf0e10cSrcweir testProperty("IsMasterPageMode"); 121cdf0e10cSrcweir try { 122cdf0e10cSrcweir oObj.setPropertyValue("IsMasterPageMode", new Boolean(false)); 123cdf0e10cSrcweir } catch(com.sun.star.lang.WrappedTargetException e) { 124cdf0e10cSrcweir e.printStackTrace(log); 125cdf0e10cSrcweir } catch(com.sun.star.beans.UnknownPropertyException e) { 126cdf0e10cSrcweir e.printStackTrace(log); 127cdf0e10cSrcweir } catch(com.sun.star.lang.IllegalArgumentException e) { 128cdf0e10cSrcweir e.printStackTrace(log); 129cdf0e10cSrcweir } catch(com.sun.star.beans.PropertyVetoException e) { 130cdf0e10cSrcweir e.printStackTrace(log); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir } 133cdf0e10cSrcweir _IsLayerMode()134cdf0e10cSrcweir public void _IsLayerMode() { 135cdf0e10cSrcweir testProperty("IsLayerMode"); 136cdf0e10cSrcweir try { 137cdf0e10cSrcweir oObj.setPropertyValue("IsLayerMode", new Boolean(false)); 138cdf0e10cSrcweir } catch(com.sun.star.lang.WrappedTargetException e) { 139cdf0e10cSrcweir e.printStackTrace(log); 140cdf0e10cSrcweir } catch(com.sun.star.beans.UnknownPropertyException e) { 141cdf0e10cSrcweir e.printStackTrace(log); 142cdf0e10cSrcweir } catch(com.sun.star.lang.IllegalArgumentException e) { 143cdf0e10cSrcweir e.printStackTrace(log); 144cdf0e10cSrcweir } catch(com.sun.star.beans.PropertyVetoException e) { 145cdf0e10cSrcweir e.printStackTrace(log); 146cdf0e10cSrcweir } 147cdf0e10cSrcweir } 148cdf0e10cSrcweir _ZoomType()149cdf0e10cSrcweir public void _ZoomType() { 150cdf0e10cSrcweir Object oldValue=null; 151cdf0e10cSrcweir Object newValue=null; 152cdf0e10cSrcweir try { 153cdf0e10cSrcweir oldValue = oObj.getPropertyValue("ZoomValue"); 154cdf0e10cSrcweir Object oldZoom = oObj.getPropertyValue("ZoomType"); 155cdf0e10cSrcweir Object newZoom = ValueChanger.changePValue(oldZoom); 156cdf0e10cSrcweir oObj.setPropertyValue("ZoomType", newZoom); 157cdf0e10cSrcweir newValue = oObj.getPropertyValue("ZoomValue"); 158cdf0e10cSrcweir } catch(com.sun.star.lang.WrappedTargetException e) { 159cdf0e10cSrcweir e.printStackTrace(log); 160cdf0e10cSrcweir } catch(com.sun.star.beans.UnknownPropertyException e) { 161cdf0e10cSrcweir e.printStackTrace(log); 162cdf0e10cSrcweir } catch(com.sun.star.lang.IllegalArgumentException e) { 163cdf0e10cSrcweir e.printStackTrace(log); 164cdf0e10cSrcweir } catch(com.sun.star.beans.PropertyVetoException e) { 165cdf0e10cSrcweir e.printStackTrace(log); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir log.println("oldZoomValue: "+oldValue); 168cdf0e10cSrcweir log.println("newZoomValue: "+newValue); 169cdf0e10cSrcweir tRes.tested("ZoomType",(!oldValue.equals(newValue))); 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir } 173cdf0e10cSrcweir 174