1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package ifc.table; 29 30 import lib.MultiPropertyTest; 31 32 import com.sun.star.container.XNameContainer; 33 import com.sun.star.uno.AnyConverter; 34 import com.sun.star.uno.Type; 35 import com.sun.star.xml.AttributeData; 36 37 /** 38 * Testing <code>com.sun.star.table.CellProperties</code> 39 * service properties : 40 * <ul> 41 * <li><code> CellStyle</code></li> 42 * <li><code> CellBackColor</code></li> 43 * <li><code> IsCellBackgroundTransparent</code></li> 44 * <li><code> NumberFormat</code></li> 45 * <li><code> ShadowFormat</code></li> 46 * <li><code> HoriJustify</code></li> 47 * <li><code> VertJustify</code></li> 48 * <li><code> Orientation</code></li> 49 * <li><code> CellProtection</code></li> 50 * <li><code> TableBorder</code></li> 51 * <li><code> IsTextWrapped</code></li> 52 * <li><code> RotateAngle</code></li> 53 * <li><code> RotateReference</code></li> 54 * </ul> <p> 55 * Properties testing is automated by <code>lib.MultiPropertyTest</code>. 56 * @see com.sun.star.table.CellProperties 57 */ 58 public class _CellProperties extends MultiPropertyTest { 59 60 61 /** 62 * This property is tested with custom property tester which 63 * switches between 'Default' and 'Result' style names. 64 */ 65 public void _CellStyle() { 66 testProperty("CellStyle", new PropertyTester() { 67 protected Object getNewValue(String name, Object old) { 68 return "Default".equals(old) ? "Result" : "Default" ; 69 } 70 }) ; 71 } 72 73 public void _UserDefinedAttributes() { 74 XNameContainer uda = null; 75 boolean res = false; 76 try { 77 uda = (XNameContainer) AnyConverter.toObject( 78 new Type(XNameContainer.class), 79 oObj.getPropertyValue("UserDefinedAttributes")); 80 AttributeData attr = new AttributeData(); 81 attr.Namespace = "http://www.sun.com/staroffice/apitest/Cellprop"; 82 attr.Type="CDATA"; 83 attr.Value="true"; 84 uda.insertByName("Cellprop:has-first-alien-attribute",attr); 85 String[] els = uda.getElementNames(); 86 oObj.setPropertyValue("UserDefinedAttributes",uda); 87 uda = (XNameContainer) AnyConverter.toObject( 88 new Type(XNameContainer.class), 89 oObj.getPropertyValue("UserDefinedAttributes")); 90 els = uda.getElementNames(); 91 Object obj = uda.getByName("Cellprop:has-first-alien-attribute"); 92 res = true; 93 } catch (com.sun.star.beans.UnknownPropertyException upe) { 94 log.println("Don't know the Property 'UserDefinedAttributes'"); 95 } catch (com.sun.star.lang.WrappedTargetException wte) { 96 log.println("WrappedTargetException while getting Property 'UserDefinedAttributes'"); 97 } catch (com.sun.star.container.NoSuchElementException nee) { 98 log.println("added Element isn't part of the NameContainer"); 99 } catch (com.sun.star.lang.IllegalArgumentException iae) { 100 log.println("IllegalArgumentException while getting Property 'UserDefinedAttributes'"); 101 } catch (com.sun.star.beans.PropertyVetoException pve) { 102 log.println("PropertyVetoException while getting Property 'UserDefinedAttributes'"); 103 } catch (com.sun.star.container.ElementExistException eee) { 104 log.println("ElementExistException while getting Property 'UserDefinedAttributes'"); 105 } 106 tRes.tested("UserDefinedAttributes",res); 107 } 108 109 } // finish class _CellProperties 110 111