1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir package ifc.drawing; 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir import lib.MultiPropertyTest; 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir import com.sun.star.container.XNamed; 33*cdf0e10cSrcweir import com.sun.star.drawing.XDrawPage; 34*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 35*cdf0e10cSrcweir import util.ValueChanger; 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir /** 38*cdf0e10cSrcweir * Testing <code>com.sun.star.drawing.DrawingDocumentDrawView</code> 39*cdf0e10cSrcweir * service properties : 40*cdf0e10cSrcweir * <ul> 41*cdf0e10cSrcweir * <li><code> IsMasterPageMode</code></li> 42*cdf0e10cSrcweir * <li><code> IsLayerMode</code></li> 43*cdf0e10cSrcweir * </ul> <p> 44*cdf0e10cSrcweir * This test needs the following object relations : 45*cdf0e10cSrcweir * <ul> 46*cdf0e10cSrcweir * <li> <code>'DrawPage'</code> (of type <code>XDrawPage</code>): 47*cdf0e10cSrcweir * a draw page which will be current page. </li> 48*cdf0e10cSrcweir * <ul> <p> 49*cdf0e10cSrcweir * Properties testing is automated by <code>lib.MultiPropertyTest</code>. 50*cdf0e10cSrcweir * @see com.sun.star.drawing.DrawingDocumentDrawView 51*cdf0e10cSrcweir */ 52*cdf0e10cSrcweir public class _DrawingDocumentDrawView extends MultiPropertyTest { 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir XDrawPage drawPage = null; 55*cdf0e10cSrcweir static String test_name = "For DrawingDocumentDrawView"; 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir protected void before() { 58*cdf0e10cSrcweir drawPage = (XDrawPage)tEnv.getObjRelation("DrawPage"); 59*cdf0e10cSrcweir XNamed xNamed = (XNamed) 60*cdf0e10cSrcweir UnoRuntime.queryInterface(XNamed.class, drawPage); 61*cdf0e10cSrcweir xNamed.setName(test_name); 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir /** 65*cdf0e10cSrcweir * Property tester which returns new <code>XDrawPage</code> object 66*cdf0e10cSrcweir * and compares draw pages. 67*cdf0e10cSrcweir */ 68*cdf0e10cSrcweir protected PropertyTester CurPageTester = new PropertyTester() { 69*cdf0e10cSrcweir protected Object getNewValue(String propName, Object oldValue) { 70*cdf0e10cSrcweir return drawPage; 71*cdf0e10cSrcweir } 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir protected boolean compare(Object obj1, Object obj2) { 74*cdf0e10cSrcweir XNamed named1 = (XNamed)UnoRuntime.queryInterface(XNamed.class, obj1); 75*cdf0e10cSrcweir XNamed named2 = (XNamed)UnoRuntime.queryInterface(XNamed.class, obj2); 76*cdf0e10cSrcweir boolean res = false; 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir if (named1 != null && named2 != null) { 79*cdf0e10cSrcweir String name1 = named1.getName(); 80*cdf0e10cSrcweir String name2 = named2.getName(); 81*cdf0e10cSrcweir res = name1.equals(name2); 82*cdf0e10cSrcweir } else { 83*cdf0e10cSrcweir log.println("Interface XNamed not supported"); 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir return res; 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir protected String toString(Object obj) { 90*cdf0e10cSrcweir XNamed named = (XNamed)UnoRuntime.queryInterface(XNamed.class, obj); 91*cdf0e10cSrcweir String res = (named == null) ? "null" : named.getName(); 92*cdf0e10cSrcweir return res; 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir } ; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir public void _CurrentPage() { 97*cdf0e10cSrcweir log.println("Testing with custom Property tester"); 98*cdf0e10cSrcweir Object oldCurPage = null; 99*cdf0e10cSrcweir try { 100*cdf0e10cSrcweir oldCurPage = oObj.getPropertyValue("CurrentPage"); 101*cdf0e10cSrcweir } catch(com.sun.star.lang.WrappedTargetException e) { 102*cdf0e10cSrcweir e.printStackTrace(log); 103*cdf0e10cSrcweir } catch(com.sun.star.beans.UnknownPropertyException e) { 104*cdf0e10cSrcweir e.printStackTrace(log); 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir testProperty("CurrentPage", CurPageTester); 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir try { 110*cdf0e10cSrcweir log.println("Back old current page"); 111*cdf0e10cSrcweir oObj.setPropertyValue("CurrentPage", oldCurPage); 112*cdf0e10cSrcweir } catch(com.sun.star.lang.WrappedTargetException e) { 113*cdf0e10cSrcweir e.printStackTrace(log); 114*cdf0e10cSrcweir } catch(com.sun.star.beans.UnknownPropertyException e) { 115*cdf0e10cSrcweir e.printStackTrace(log); 116*cdf0e10cSrcweir } catch(com.sun.star.lang.IllegalArgumentException e) { 117*cdf0e10cSrcweir e.printStackTrace(log); 118*cdf0e10cSrcweir } catch(com.sun.star.beans.PropertyVetoException e) { 119*cdf0e10cSrcweir e.printStackTrace(log); 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir public void _IsMasterPageMode() { 124*cdf0e10cSrcweir testProperty("IsMasterPageMode"); 125*cdf0e10cSrcweir try { 126*cdf0e10cSrcweir oObj.setPropertyValue("IsMasterPageMode", new Boolean(false)); 127*cdf0e10cSrcweir } catch(com.sun.star.lang.WrappedTargetException e) { 128*cdf0e10cSrcweir e.printStackTrace(log); 129*cdf0e10cSrcweir } catch(com.sun.star.beans.UnknownPropertyException e) { 130*cdf0e10cSrcweir e.printStackTrace(log); 131*cdf0e10cSrcweir } catch(com.sun.star.lang.IllegalArgumentException e) { 132*cdf0e10cSrcweir e.printStackTrace(log); 133*cdf0e10cSrcweir } catch(com.sun.star.beans.PropertyVetoException e) { 134*cdf0e10cSrcweir e.printStackTrace(log); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir public void _IsLayerMode() { 139*cdf0e10cSrcweir testProperty("IsLayerMode"); 140*cdf0e10cSrcweir try { 141*cdf0e10cSrcweir oObj.setPropertyValue("IsLayerMode", new Boolean(false)); 142*cdf0e10cSrcweir } catch(com.sun.star.lang.WrappedTargetException e) { 143*cdf0e10cSrcweir e.printStackTrace(log); 144*cdf0e10cSrcweir } catch(com.sun.star.beans.UnknownPropertyException e) { 145*cdf0e10cSrcweir e.printStackTrace(log); 146*cdf0e10cSrcweir } catch(com.sun.star.lang.IllegalArgumentException e) { 147*cdf0e10cSrcweir e.printStackTrace(log); 148*cdf0e10cSrcweir } catch(com.sun.star.beans.PropertyVetoException e) { 149*cdf0e10cSrcweir e.printStackTrace(log); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir public void _ZoomType() { 154*cdf0e10cSrcweir Object oldValue=null; 155*cdf0e10cSrcweir Object newValue=null; 156*cdf0e10cSrcweir try { 157*cdf0e10cSrcweir oldValue = oObj.getPropertyValue("ZoomValue"); 158*cdf0e10cSrcweir Object oldZoom = oObj.getPropertyValue("ZoomType"); 159*cdf0e10cSrcweir Object newZoom = ValueChanger.changePValue(oldZoom); 160*cdf0e10cSrcweir oObj.setPropertyValue("ZoomType", newZoom); 161*cdf0e10cSrcweir newValue = oObj.getPropertyValue("ZoomValue"); 162*cdf0e10cSrcweir } catch(com.sun.star.lang.WrappedTargetException e) { 163*cdf0e10cSrcweir e.printStackTrace(log); 164*cdf0e10cSrcweir } catch(com.sun.star.beans.UnknownPropertyException e) { 165*cdf0e10cSrcweir e.printStackTrace(log); 166*cdf0e10cSrcweir } catch(com.sun.star.lang.IllegalArgumentException e) { 167*cdf0e10cSrcweir e.printStackTrace(log); 168*cdf0e10cSrcweir } catch(com.sun.star.beans.PropertyVetoException e) { 169*cdf0e10cSrcweir e.printStackTrace(log); 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir log.println("oldZoomValue: "+oldValue); 172*cdf0e10cSrcweir log.println("newZoomValue: "+newValue); 173*cdf0e10cSrcweir tRes.tested("ZoomType",(!oldValue.equals(newValue))); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir 178