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.text; 29 30 import lib.MultiPropertyTest; 31 32 import com.sun.star.text.XTextColumns; 33 import com.sun.star.uno.AnyConverter; 34 import com.sun.star.uno.Type; 35 36 /** 37 * Testing <code>com.sun.star.text.TextSection</code> 38 * service properties : 39 * <ul> 40 * <li><code> Condition</code></li> 41 * <li><code> IsVisible</code></li> 42 * <li><code> IsProtected</code></li> 43 * <li><code> FileLink</code></li> 44 * <li><code> LinkRegion</code></li> 45 * <li><code> DDECommandType</code></li> 46 * <li><code> DDECommandFile</code></li> 47 * <li><code> DDECommandElement</code></li> 48 * <li><code> BackGraphicURL</code></li> 49 * <li><code> BackGraphicFilter</code></li> 50 * <li><code> BackGraphicLocation</code></li> 51 * <li><code> FootnoteIsCollectAtTextEnd</code></li> 52 * <li><code> FootnoteIsRestartNumbering</code></li> 53 * <li><code> FootnoteRestartNumberingAt</code></li> 54 * <li><code> FootnoteIsOwnNumbering</code></li> 55 * <li><code> FootnoteNumberingType</code></li> 56 * <li><code> FootnoteNumberingPrefix</code></li> 57 * <li><code> FootnoteNumberingSuffix</code></li> 58 * <li><code> EndnoteIsCollectAtTextEnd</code></li> 59 * <li><code> EndnoteIsRestartNumbering</code></li> 60 * <li><code> EndnoteRestartNumberingAt</code></li> 61 * <li><code> EndnoteIsOwnNumbering</code></li> 62 * <li><code> EndnoteNumberingType</code></li> 63 * <li><code> EndnoteNumberingPrefix</code></li> 64 * <li><code> EndnoteNumberingSuffix</code></li> 65 * <li><code> IsAutomaticUpdate</code></li> 66 * </ul> <p> 67 * The following predefined files needed to complete the test: 68 * <ul> 69 * <li> <code>crazy-blue.jpg, space-metal.jpg</code> : are used for 70 * setting 'BackGraphicURL' property. </li> 71 * <ul> <p> 72 * Properties testing is automated by <code>lib.MultiPropertyTest</code>. 73 * @see com.sun.star.text.TextSection 74 */ 75 public class _TextSection extends MultiPropertyTest { 76 77 /** 78 * Only image file URL can be used as a value. 79 */ 80 public void _BackGraphicURL() { 81 log.println("Testing with custom Property tester") ; 82 testProperty("BackGraphicURL", 83 util.utils.getFullTestURL("crazy-blue.jpg"), 84 util.utils.getFullTestURL("space-metal.jpg")) ; 85 } 86 87 /** 88 * This property can be void, so if old value is <code> null </code> 89 * new value must be specified. 90 */ 91 public void _FootnoteNumberingType() { 92 log.println("Testing with custom Property tester") ; 93 testProperty("FootnoteNumberingType", 94 new Short(com.sun.star.text.FootnoteNumbering.PER_DOCUMENT), 95 new Short(com.sun.star.text.FootnoteNumbering.PER_PAGE)) ; 96 } 97 98 99 /** 100 * Custom property tester for property <code>TextColumns</code> 101 */ 102 protected PropertyTester TextColumnsTester = new PropertyTester() { 103 104 protected Object getNewValue(String propName, Object oldValue) { 105 XTextColumns TC = null; 106 short val2set = 25; 107 108 TC = (XTextColumns) tEnv.getObjRelation("TC"); 109 try { 110 val2set += ((XTextColumns) AnyConverter.toObject( 111 new Type(XTextColumns.class),oldValue)).getColumnCount(); 112 } catch (com.sun.star.lang.IllegalArgumentException iae) { 113 log.println("Couldn't change Column count"); 114 } 115 TC.setColumnCount(val2set); 116 117 return TC; 118 }; 119 120 protected boolean compare(Object obj1, Object obj2) { 121 short val1 = 0; 122 short val2 = 1; 123 try { 124 val1 = ((XTextColumns) AnyConverter.toObject( 125 new Type(XTextColumns.class),obj1)).getColumnCount(); 126 val2 = ((XTextColumns) AnyConverter.toObject( 127 new Type(XTextColumns.class),obj2)).getColumnCount(); 128 } catch (com.sun.star.lang.IllegalArgumentException iae) { 129 log.println("comparing values failed"); 130 } 131 return val1 == val2; 132 } 133 134 protected String toString(Object obj) { 135 return "XTextColumns: ColumnCount = "+ 136 ((XTextColumns) obj).getColumnCount(); 137 } 138 139 }; 140 141 public void _TextColumns() { 142 log.println("Testing with custom Property tester"); 143 testProperty("TextColumns", TextColumnsTester); 144 } 145 146 147 } //finish class _TextContent 148 149