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.style; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import com.sun.star.container.XNameContainer; 27cdf0e10cSrcweir import com.sun.star.uno.AnyConverter; 28cdf0e10cSrcweir import com.sun.star.uno.Type; 29cdf0e10cSrcweir import com.sun.star.xml.AttributeData; 30cdf0e10cSrcweir import lib.MultiPropertyTest; 31cdf0e10cSrcweir 32cdf0e10cSrcweir /** 33cdf0e10cSrcweir * Test page properties. 34cdf0e10cSrcweir * Testing is done by lib.MultiPropertyTest, except for properties 35cdf0e10cSrcweir * <ul> 36cdf0e10cSrcweir * <li>PrinterPaperTray</li> 37cdf0e10cSrcweir * <li>UserDefinedAttribures</li> 38cdf0e10cSrcweir * </ul> 39cdf0e10cSrcweir */ 40cdf0e10cSrcweir public class _PageProperties extends MultiPropertyTest { 41cdf0e10cSrcweir 42cdf0e10cSrcweir /** 43cdf0e10cSrcweir * Switch on Header and Footer properties 44cdf0e10cSrcweir * so all props can be tested. 45cdf0e10cSrcweir */ 46cdf0e10cSrcweir protected void before() { 47cdf0e10cSrcweir try { 48cdf0e10cSrcweir oObj.setPropertyValue("HeaderIsOn", Boolean.TRUE); 49cdf0e10cSrcweir oObj.setPropertyValue("FooterIsOn", Boolean.TRUE); 50cdf0e10cSrcweir } catch (com.sun.star.beans.UnknownPropertyException upe) { 51cdf0e10cSrcweir log.println("Don't know the Property 'HeaderIsOn' or 'FooterIsOn'"); 52cdf0e10cSrcweir } catch (com.sun.star.lang.WrappedTargetException wte) { 53cdf0e10cSrcweir log.println("WrappedTargetException while setting Property 'HeaderIsOn' or 'FooterIsOn'"); 54cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException iae) { 55cdf0e10cSrcweir log.println("IllegalArgumentException while setting Property 'HeaderIsOn' or 'FooterIsOn'"); 56cdf0e10cSrcweir } catch (com.sun.star.beans.PropertyVetoException pve) { 57cdf0e10cSrcweir log.println("PropertyVetoException while setting Property 'HeaderIsOn' or 'FooterIsOn'"); 58cdf0e10cSrcweir } 59cdf0e10cSrcweir } 60cdf0e10cSrcweir 61cdf0e10cSrcweir /** 62cdf0e10cSrcweir * This property is system dependent and printer dependent. 63cdf0e10cSrcweir * So only reading it does make sense, since it cannot be determined, if 64cdf0e10cSrcweir * it is set to a allowed value. 65cdf0e10cSrcweir */ 66cdf0e10cSrcweir public void _PrinterPaperTray() { 67cdf0e10cSrcweir boolean res = false; 68cdf0e10cSrcweir String setting = null; 69cdf0e10cSrcweir try { 70cdf0e10cSrcweir setting = (String)oObj.getPropertyValue("PrinterPaperTray"); 71cdf0e10cSrcweir log.println("Property 'PrinterPaperTray' is set to '" + setting + "'."); 72cdf0e10cSrcweir res = setting != null; 73cdf0e10cSrcweir } 74cdf0e10cSrcweir catch(com.sun.star.beans.UnknownPropertyException e) { 75cdf0e10cSrcweir log.println("Don't know the Property 'PrinterPaperTray'"); 76cdf0e10cSrcweir } catch (com.sun.star.lang.WrappedTargetException wte) { 77cdf0e10cSrcweir log.println("WrappedTargetException while getting Property 'PrinterPaperTray'"); 78cdf0e10cSrcweir } 79cdf0e10cSrcweir tRes.tested("PrinterPaperTray", res); 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir /** 83cdf0e10cSrcweir * Create some valid user defined attributes 84cdf0e10cSrcweir */ 85cdf0e10cSrcweir public void _UserDefinedAttributes() { 86cdf0e10cSrcweir XNameContainer uda = null; 87cdf0e10cSrcweir boolean res = false; 88cdf0e10cSrcweir try { 89cdf0e10cSrcweir uda = (XNameContainer) AnyConverter.toObject( 90cdf0e10cSrcweir new Type(XNameContainer.class), 91cdf0e10cSrcweir oObj.getPropertyValue("UserDefinedAttributes")); 92cdf0e10cSrcweir AttributeData attr = new AttributeData(); 93cdf0e10cSrcweir attr.Namespace = "http://www.sun.com/staroffice/apitest/Cellprop"; 94cdf0e10cSrcweir attr.Type="CDATA"; 95cdf0e10cSrcweir attr.Value="true"; 96cdf0e10cSrcweir uda.insertByName("Cellprop:has-first-alien-attribute",attr); 97cdf0e10cSrcweir String[] els = uda.getElementNames(); 98cdf0e10cSrcweir oObj.setPropertyValue("UserDefinedAttributes",uda); 99cdf0e10cSrcweir uda = (XNameContainer) AnyConverter.toObject( 100cdf0e10cSrcweir new Type(XNameContainer.class), 101cdf0e10cSrcweir oObj.getPropertyValue("UserDefinedAttributes")); 102cdf0e10cSrcweir els = uda.getElementNames(); 103cdf0e10cSrcweir Object obj = uda.getByName("Cellprop:has-first-alien-attribute"); 104cdf0e10cSrcweir res = true; 105cdf0e10cSrcweir } catch (com.sun.star.beans.UnknownPropertyException upe) { 106cdf0e10cSrcweir log.println("Don't know the Property 'UserDefinedAttributes'"); 107cdf0e10cSrcweir } catch (com.sun.star.lang.WrappedTargetException wte) { 108cdf0e10cSrcweir log.println("WrappedTargetException while getting Property 'UserDefinedAttributes'"); 109cdf0e10cSrcweir } catch (com.sun.star.container.NoSuchElementException nee) { 110cdf0e10cSrcweir log.println("added Element isn't part of the NameContainer"); 111cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException iae) { 112cdf0e10cSrcweir log.println("IllegalArgumentException while getting Property 'UserDefinedAttributes'"); 113cdf0e10cSrcweir } catch (com.sun.star.beans.PropertyVetoException pve) { 114cdf0e10cSrcweir log.println("PropertyVetoException while getting Property 'UserDefinedAttributes'"); 115cdf0e10cSrcweir } catch (com.sun.star.container.ElementExistException eee) { 116cdf0e10cSrcweir log.println("ElementExistException while getting Property 'UserDefinedAttributes'"); 117cdf0e10cSrcweir } 118cdf0e10cSrcweir tRes.tested("UserDefinedAttributes",res); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir } 122