Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / text / _TextSection.java
blob74e153006ee6fd34cd1330c00525d901d698404f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _TextSection.java,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.text;
33 import lib.MultiPropertyTest;
35 import com.sun.star.text.XTextColumns;
36 import com.sun.star.uno.AnyConverter;
37 import com.sun.star.uno.Type;
39 /**
40 * Testing <code>com.sun.star.text.TextSection</code>
41 * service properties :
42 * <ul>
43 * <li><code> Condition</code></li>
44 * <li><code> IsVisible</code></li>
45 * <li><code> IsProtected</code></li>
46 * <li><code> FileLink</code></li>
47 * <li><code> LinkRegion</code></li>
48 * <li><code> DDECommandType</code></li>
49 * <li><code> DDECommandFile</code></li>
50 * <li><code> DDECommandElement</code></li>
51 * <li><code> BackGraphicURL</code></li>
52 * <li><code> BackGraphicFilter</code></li>
53 * <li><code> BackGraphicLocation</code></li>
54 * <li><code> FootnoteIsCollectAtTextEnd</code></li>
55 * <li><code> FootnoteIsRestartNumbering</code></li>
56 * <li><code> FootnoteRestartNumberingAt</code></li>
57 * <li><code> FootnoteIsOwnNumbering</code></li>
58 * <li><code> FootnoteNumberingType</code></li>
59 * <li><code> FootnoteNumberingPrefix</code></li>
60 * <li><code> FootnoteNumberingSuffix</code></li>
61 * <li><code> EndnoteIsCollectAtTextEnd</code></li>
62 * <li><code> EndnoteIsRestartNumbering</code></li>
63 * <li><code> EndnoteRestartNumberingAt</code></li>
64 * <li><code> EndnoteIsOwnNumbering</code></li>
65 * <li><code> EndnoteNumberingType</code></li>
66 * <li><code> EndnoteNumberingPrefix</code></li>
67 * <li><code> EndnoteNumberingSuffix</code></li>
68 * <li><code> IsAutomaticUpdate</code></li>
69 * </ul> <p>
70 * The following predefined files needed to complete the test:
71 * <ul>
72 * <li> <code>crazy-blue.jpg, space-metal.jpg</code> : are used for
73 * setting 'BackGraphicURL' property. </li>
74 * <ul> <p>
75 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
76 * @see com.sun.star.text.TextSection
78 public class _TextSection extends MultiPropertyTest {
80 /**
81 * Only image file URL can be used as a value.
83 public void _BackGraphicURL() {
84 log.println("Testing with custom Property tester") ;
85 testProperty("BackGraphicURL",
86 util.utils.getFullTestURL("crazy-blue.jpg"),
87 util.utils.getFullTestURL("space-metal.jpg")) ;
90 /**
91 * This property can be void, so if old value is <code> null </code>
92 * new value must be specified.
94 public void _FootnoteNumberingType() {
95 log.println("Testing with custom Property tester") ;
96 testProperty("FootnoteNumberingType",
97 new Short(com.sun.star.text.FootnoteNumbering.PER_DOCUMENT),
98 new Short(com.sun.star.text.FootnoteNumbering.PER_PAGE)) ;
103 * Custom property tester for property <code>TextColumns</code>
105 protected PropertyTester TextColumnsTester = new PropertyTester() {
107 protected Object getNewValue(String propName, Object oldValue) {
108 XTextColumns TC = null;
109 short val2set = 25;
111 TC = (XTextColumns) tEnv.getObjRelation("TC");
112 try {
113 val2set += ((XTextColumns) AnyConverter.toObject(
114 new Type(XTextColumns.class),oldValue)).getColumnCount();
115 } catch (com.sun.star.lang.IllegalArgumentException iae) {
116 log.println("Couldn't change Column count");
118 TC.setColumnCount(val2set);
120 return TC;
123 protected boolean compare(Object obj1, Object obj2) {
124 short val1 = 0;
125 short val2 = 1;
126 try {
127 val1 = ((XTextColumns) AnyConverter.toObject(
128 new Type(XTextColumns.class),obj1)).getColumnCount();
129 val2 = ((XTextColumns) AnyConverter.toObject(
130 new Type(XTextColumns.class),obj2)).getColumnCount();
131 } catch (com.sun.star.lang.IllegalArgumentException iae) {
132 log.println("comparing values failed");
134 return val1 == val2;
137 protected String toString(Object obj) {
138 return "XTextColumns: ColumnCount = "+
139 ((XTextColumns) obj).getColumnCount();
144 public void _TextColumns() {
145 log.println("Testing with custom Property tester");
146 testProperty("TextColumns", TextColumnsTester);
150 } //finish class _TextContent