xref: /AOO41X/main/qadevOOo/tests/java/ifc/text/_TextSection.java (revision 47148b3bc50811ceb41802e4cc50a5db21535900)
1ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5ef39d40dSAndrew Rist  * distributed with this work for additional information
6ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18ef39d40dSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20ef39d40dSAndrew Rist  *************************************************************/
21ef39d40dSAndrew Rist 
22ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.text;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import lib.MultiPropertyTest;
27cdf0e10cSrcweir 
28cdf0e10cSrcweir import com.sun.star.text.XTextColumns;
29cdf0e10cSrcweir import com.sun.star.uno.AnyConverter;
30cdf0e10cSrcweir import com.sun.star.uno.Type;
31cdf0e10cSrcweir 
32cdf0e10cSrcweir /**
33cdf0e10cSrcweir  * Testing <code>com.sun.star.text.TextSection</code>
34cdf0e10cSrcweir  * service properties :
35cdf0e10cSrcweir  * <ul>
36cdf0e10cSrcweir  *  <li><code> Condition</code></li>
37cdf0e10cSrcweir  *  <li><code> IsVisible</code></li>
38cdf0e10cSrcweir  *  <li><code> IsProtected</code></li>
39cdf0e10cSrcweir  *  <li><code> FileLink</code></li>
40cdf0e10cSrcweir  *  <li><code> LinkRegion</code></li>
41cdf0e10cSrcweir  *  <li><code> DDECommandType</code></li>
42cdf0e10cSrcweir  *  <li><code> DDECommandFile</code></li>
43cdf0e10cSrcweir  *  <li><code> DDECommandElement</code></li>
44cdf0e10cSrcweir  *  <li><code> BackGraphicURL</code></li>
45cdf0e10cSrcweir  *  <li><code> BackGraphicFilter</code></li>
46cdf0e10cSrcweir  *  <li><code> BackGraphicLocation</code></li>
47cdf0e10cSrcweir  *  <li><code> FootnoteIsCollectAtTextEnd</code></li>
48cdf0e10cSrcweir  *  <li><code> FootnoteIsRestartNumbering</code></li>
49cdf0e10cSrcweir  *  <li><code> FootnoteRestartNumberingAt</code></li>
50cdf0e10cSrcweir  *  <li><code> FootnoteIsOwnNumbering</code></li>
51cdf0e10cSrcweir  *  <li><code> FootnoteNumberingType</code></li>
52cdf0e10cSrcweir  *  <li><code> FootnoteNumberingPrefix</code></li>
53cdf0e10cSrcweir  *  <li><code> FootnoteNumberingSuffix</code></li>
54cdf0e10cSrcweir  *  <li><code> EndnoteIsCollectAtTextEnd</code></li>
55cdf0e10cSrcweir  *  <li><code> EndnoteIsRestartNumbering</code></li>
56cdf0e10cSrcweir  *  <li><code> EndnoteRestartNumberingAt</code></li>
57cdf0e10cSrcweir  *  <li><code> EndnoteIsOwnNumbering</code></li>
58cdf0e10cSrcweir  *  <li><code> EndnoteNumberingType</code></li>
59cdf0e10cSrcweir  *  <li><code> EndnoteNumberingPrefix</code></li>
60cdf0e10cSrcweir  *  <li><code> EndnoteNumberingSuffix</code></li>
61cdf0e10cSrcweir  *  <li><code> IsAutomaticUpdate</code></li>
62cdf0e10cSrcweir  * </ul> <p>
63cdf0e10cSrcweir  * The following predefined files needed to complete the test:
64cdf0e10cSrcweir  * <ul>
65cdf0e10cSrcweir  *  <li> <code>crazy-blue.jpg, space-metal.jpg</code> : are used for
66cdf0e10cSrcweir  *  setting 'BackGraphicURL' property. </li>
67cdf0e10cSrcweir  * <ul> <p>
68cdf0e10cSrcweir  * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
69cdf0e10cSrcweir  * @see com.sun.star.text.TextSection
70cdf0e10cSrcweir  */
71cdf0e10cSrcweir public class _TextSection extends MultiPropertyTest {
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     /**
74cdf0e10cSrcweir      * Only image file URL can be used as a value.
75cdf0e10cSrcweir      */
_BackGraphicURL()76cdf0e10cSrcweir     public void _BackGraphicURL() {
77cdf0e10cSrcweir         log.println("Testing with custom Property tester") ;
78cdf0e10cSrcweir         testProperty("BackGraphicURL",
79cdf0e10cSrcweir         util.utils.getFullTestURL("crazy-blue.jpg"),
80cdf0e10cSrcweir         util.utils.getFullTestURL("space-metal.jpg")) ;
81cdf0e10cSrcweir     }
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     /**
84cdf0e10cSrcweir      * This property can be void, so if old value is <code> null </code>
85cdf0e10cSrcweir      * new value must be specified.
86cdf0e10cSrcweir      */
_FootnoteNumberingType()87cdf0e10cSrcweir     public void _FootnoteNumberingType() {
88cdf0e10cSrcweir         log.println("Testing with custom Property tester") ;
89cdf0e10cSrcweir         testProperty("FootnoteNumberingType",
90cdf0e10cSrcweir         new Short(com.sun.star.text.FootnoteNumbering.PER_DOCUMENT),
91cdf0e10cSrcweir         new Short(com.sun.star.text.FootnoteNumbering.PER_PAGE)) ;
92cdf0e10cSrcweir     }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     /**
96cdf0e10cSrcweir     * Custom property tester for property <code>TextColumns</code>
97cdf0e10cSrcweir     */
98cdf0e10cSrcweir     protected PropertyTester TextColumnsTester = new PropertyTester() {
99cdf0e10cSrcweir 
100cdf0e10cSrcweir         protected Object getNewValue(String propName, Object oldValue) {
101cdf0e10cSrcweir         XTextColumns TC = null;
102cdf0e10cSrcweir         short val2set = 25;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir         TC = (XTextColumns) tEnv.getObjRelation("TC");
105cdf0e10cSrcweir         try {
106cdf0e10cSrcweir             val2set += ((XTextColumns) AnyConverter.toObject(
107cdf0e10cSrcweir                 new Type(XTextColumns.class),oldValue)).getColumnCount();
108cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException iae) {
109cdf0e10cSrcweir             log.println("Couldn't change Column count");
110cdf0e10cSrcweir         }
111cdf0e10cSrcweir         TC.setColumnCount(val2set);
112cdf0e10cSrcweir 
113cdf0e10cSrcweir         return TC;
114*170fb961SPedro Giffuni         }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir         protected boolean compare(Object obj1, Object obj2) {
117cdf0e10cSrcweir             short val1 = 0;
118cdf0e10cSrcweir             short val2 = 1;
119cdf0e10cSrcweir             try {
120cdf0e10cSrcweir                 val1 = ((XTextColumns) AnyConverter.toObject(
121cdf0e10cSrcweir                     new Type(XTextColumns.class),obj1)).getColumnCount();
122cdf0e10cSrcweir                 val2 = ((XTextColumns) AnyConverter.toObject(
123cdf0e10cSrcweir                     new Type(XTextColumns.class),obj2)).getColumnCount();
124cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException iae) {
125cdf0e10cSrcweir                 log.println("comparing values failed");
126cdf0e10cSrcweir             }
127cdf0e10cSrcweir             return val1 == val2;
128cdf0e10cSrcweir         }
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         protected String toString(Object obj) {
131cdf0e10cSrcweir             return "XTextColumns: ColumnCount = "+
132cdf0e10cSrcweir                         ((XTextColumns) obj).getColumnCount();
133cdf0e10cSrcweir         }
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     };
136cdf0e10cSrcweir 
_TextColumns()137cdf0e10cSrcweir     public void _TextColumns() {
138cdf0e10cSrcweir         log.println("Testing with custom Property tester");
139cdf0e10cSrcweir         testProperty("TextColumns", TextColumnsTester);
140cdf0e10cSrcweir     }
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 
143cdf0e10cSrcweir } //finish class _TextContent
144cdf0e10cSrcweir 
145