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 10cdf0e10cSrcweir * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package ifc.text; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import lib.MultiPropertyTest; 27cdf0e10cSrcweir 28cdf0e10cSrcweir import com.sun.star.container.XNameContainer; 29cdf0e10cSrcweir import com.sun.star.uno.AnyConverter; 30cdf0e10cSrcweir import com.sun.star.uno.Type; 31cdf0e10cSrcweir import com.sun.star.xml.AttributeData; 32cdf0e10cSrcweir 33cdf0e10cSrcweir /** 34cdf0e10cSrcweir * Testing <code>com.sun.star.text.CellProperties</code> 35cdf0e10cSrcweir * service properties : 36cdf0e10cSrcweir * <ul> 37cdf0e10cSrcweir * <li><code> BackColor</code></li> 38cdf0e10cSrcweir * <li><code> BackGraphicURL</code></li> 39cdf0e10cSrcweir * <li><code> BackGraphicFilter</code></li> 40cdf0e10cSrcweir * <li><code> BackGraphicLocation</code></li> 41cdf0e10cSrcweir * <li><code> NumberFormat</code></li> 42cdf0e10cSrcweir * <li><code> BackTransparent</code></li> 43cdf0e10cSrcweir * <li><code> LeftBorder</code></li> 44cdf0e10cSrcweir * <li><code> RightBorder</code></li> 45cdf0e10cSrcweir * <li><code> TopBorder</code></li> 46cdf0e10cSrcweir * <li><code> BottomBorder</code></li> 47cdf0e10cSrcweir * <li><code> LeftBorderDistance</code></li> 48cdf0e10cSrcweir * <li><code> RightBorderDistance</code></li> 49cdf0e10cSrcweir * <li><code> TopBorderDistance</code></li> 50cdf0e10cSrcweir * <li><code> BottomBorderDistance</code></li> 51cdf0e10cSrcweir * <li><code> UserDefinedAttributes</code></li> 52cdf0e10cSrcweir * <li><code> TextSection</code></li> 53cdf0e10cSrcweir * <li><code> IsProtected</code></li> 54cdf0e10cSrcweir * </ul> <p> 55cdf0e10cSrcweir * This test needs the following object relations : 56cdf0e10cSrcweir * <ul> 57cdf0e10cSrcweir * <li> <code>'CellProperties.TextSection'</code> (of type 58cdf0e10cSrcweir * <code>XInterface</code>): 59cdf0e10cSrcweir * instance of <code>com.sun.star.text.TextSection</code></li> 60cdf0e10cSrcweir * </ul> <p> 61cdf0e10cSrcweir * The following predefined files needed to complete the test: 62cdf0e10cSrcweir * <ul> 63cdf0e10cSrcweir * <li> <code> crazy-blue.jpg </code> : jpeg image used to test 64cdf0e10cSrcweir * BackGraphicURL()</li> 65cdf0e10cSrcweir * <li> <code> space-metal.jpg </code> : jpeg image used to test 66cdf0e10cSrcweir * BackGraphicURL()</li> 67cdf0e10cSrcweir * </ul> <p> 68cdf0e10cSrcweir * Properties testing is automated by <code>lib.MultiPropertyTest</code>. 69cdf0e10cSrcweir * @see com.sun.star.text.CellProperties 70cdf0e10cSrcweir */ 71cdf0e10cSrcweir public class _CellProperties extends MultiPropertyTest { 72cdf0e10cSrcweir 73cdf0e10cSrcweir /** 74cdf0e10cSrcweir * This property can be void, so new value must be specified from 75cdf0e10cSrcweir * corresponding object relation. 76cdf0e10cSrcweir */ _TextSection()77cdf0e10cSrcweir public void _TextSection() { 78cdf0e10cSrcweir log.println("Testing with custom Property tester") ; 79cdf0e10cSrcweir testProperty("TextSection", new PropertyTester() { 80cdf0e10cSrcweir protected Object getNewValue(String propName, Object oldValue) { 81cdf0e10cSrcweir return tEnv.getObjRelation("CellProperties.TextSection"); 82cdf0e10cSrcweir } 83cdf0e10cSrcweir }); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir 87cdf0e10cSrcweir /** 88cdf0e10cSrcweir * Redefined method returns value, that differs from property value. 89cdf0e10cSrcweir */ _BackColor()90cdf0e10cSrcweir public void _BackColor() { 91cdf0e10cSrcweir final Short val1 = new Short( (short) 4 ); 92cdf0e10cSrcweir final Short val2 = new Short( (short) 6 ); 93cdf0e10cSrcweir log.println("Testing with custom Property tester") ; 94cdf0e10cSrcweir testProperty("BackColor", new PropertyTester() { 95cdf0e10cSrcweir protected Object getNewValue(String propName, Object oldValue) { 96cdf0e10cSrcweir if ( oldValue.equals(val1) ) 97cdf0e10cSrcweir return val2; 98cdf0e10cSrcweir else 99cdf0e10cSrcweir return val1; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir }); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir 105cdf0e10cSrcweir /** 106cdf0e10cSrcweir * Redefined method returns value, that differs from property value. 107cdf0e10cSrcweir */ _BackGraphicURL()108cdf0e10cSrcweir public void _BackGraphicURL() { 109cdf0e10cSrcweir log.println("Testing with custom Property tester") ; 110cdf0e10cSrcweir testProperty("BackGraphicURL", new PropertyTester() { 111cdf0e10cSrcweir protected Object getNewValue(String propName, Object oldValue) { 112cdf0e10cSrcweir if (oldValue.equals(util.utils.getFullTestURL 113cdf0e10cSrcweir ("space-metal.jpg"))) 114cdf0e10cSrcweir return util.utils.getFullTestURL("crazy-blue.jpg"); 115cdf0e10cSrcweir else 116cdf0e10cSrcweir return util.utils.getFullTestURL("space-metal.jpg"); 117cdf0e10cSrcweir } 118cdf0e10cSrcweir }); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir 122cdf0e10cSrcweir /** 123cdf0e10cSrcweir * Redefined method returns object, that contains changed property value. 124cdf0e10cSrcweir */ _UserDefinedAttributes()125cdf0e10cSrcweir public void _UserDefinedAttributes() { 126cdf0e10cSrcweir log.println("Testing with custom property tester"); 127cdf0e10cSrcweir testProperty("UserDefinedAttributes", new PropertyTester() { 128cdf0e10cSrcweir protected Object getNewValue(String propName, Object oldValue) { 129cdf0e10cSrcweir XNameContainer NC = null; 130cdf0e10cSrcweir try { 131cdf0e10cSrcweir NC = (XNameContainer) 132cdf0e10cSrcweir AnyConverter.toObject(new Type(XNameContainer.class),oldValue); 133cdf0e10cSrcweir NC.insertByName("MyAttribute", 134cdf0e10cSrcweir new AttributeData("","CDATA","Value")); 135cdf0e10cSrcweir } catch ( com.sun.star.lang.IllegalArgumentException e ) { 136cdf0e10cSrcweir log.println("Failed to check 'UserDefinedAttributes'"); 137cdf0e10cSrcweir e.printStackTrace(log); 138cdf0e10cSrcweir } catch ( com.sun.star.lang.WrappedTargetException e ) { 139cdf0e10cSrcweir log.println("Failed to check 'UserDefinedAttributes'"); 140cdf0e10cSrcweir e.printStackTrace(log); 141cdf0e10cSrcweir } catch ( com.sun.star.container.ElementExistException e ) { 142cdf0e10cSrcweir log.println("Failed to check 'UserDefinedAttributes'"); 143cdf0e10cSrcweir e.printStackTrace(log); 144cdf0e10cSrcweir } 145cdf0e10cSrcweir return NC; 146cdf0e10cSrcweir } 147cdf0e10cSrcweir }); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir } //finish class _CellProperties 151cdf0e10cSrcweir 152