Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / text / _TextGraphicObject.java
blob613eec4d373ef213f3dbf424050b50bd4b1ebcda
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: _TextGraphicObject.java,v $
10 * $Revision: 1.5 $
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 ************************************************************************/
30 package ifc.text;
32 import com.sun.star.awt.Point;
33 import com.sun.star.container.XIndexContainer;
34 import com.sun.star.uno.UnoRuntime;
36 import java.util.Random;
38 import lib.MultiPropertyTest;
40 import util.utils;
43 /**
44 * Testing <code>com.sun.star.text.TextGraphicObject</code>
45 * service properties :
46 * <ul>
47 * <li><code> ImageMap</code></li>
48 * <li><code> ContentProtected</code></li>
49 * <li><code> SurroundContour</code></li>
50 * <li><code> ContourOutside</code></li>
51 * <li><code> ContourPolyPolygon</code></li>
52 * <li><code> GraphicCrop</code></li>
53 * <li><code> HoriMirroredOnEvenPages</code></li>
54 * <li><code> HoriMirroredOnOddPages</code></li>
55 * <li><code> VertMirrored</code></li>
56 * <li><code> GraphicURL</code></li>
57 * <li><code> GraphicFilter</code></li>
58 * <li><code> ActualSize</code></li>
59 * <li><code> AdjustLuminance</code></li>
60 * <li><code> AdjustContrast</code></li>
61 * <li><code> AdjustRed</code></li>
62 * <li><code> AdjustGreen</code></li>
63 * <li><code> AdjustBlue</code></li>
64 * <li><code> Gamma</code></li>
65 * <li><code> GraphicIsInverted</code></li>
66 * <li><code> Transparency</code></li>
67 * <li><code> GraphicColorMode</code></li>
68 * </ul> <p>
69 * This test needs the following object relations :
70 * <ul>
71 * <li> <code>'ImageMap'</code> (an inmplementation of
72 * <code>com.sun.star.image.ImageMapObject</code>):
73 * is used to insert a new Map into collection
74 * from 'ImageMap' property. </li>
75 * <ul> <p>
76 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
77 * @see com.sun.star.text.TextGraphicObject
79 public class _TextGraphicObject extends MultiPropertyTest {
80 public Random rdm = new Random();
82 /**
83 * The tester which can change a sequence of <code>Point</code>'s
84 * or create a new one if necessary.
86 protected PropertyTester PointTester = new PropertyTester() {
87 protected Object getNewValue(String propName, Object oldValue)
88 throws java.lang.IllegalArgumentException {
89 if (utils.isVoid(oldValue)) {
90 return newPoint();
91 } else {
92 return changePoint((Point[][]) oldValue);
97 /**
98 * Tested with custom <code>PointTester</code>.
100 public void _ContourPolyPolygon() {
101 log.println("Testing with custom Property tester");
102 testProperty("ContourPolyPolygon", PointTester);
106 * Retrieves an ImageMap from relation and inserts it to the collection
107 * obtained as property value. Then this collection is set back.
108 * After that property value is get again. The number of elements
109 * in the old collection and in just gotten collection is checked.
111 * Has <b>OK</b> status if the number of elements in the new obtained
112 * collection is greater than in old one.
114 public void _ImageMap() {
115 boolean result = true;
117 try {
118 XIndexContainer imgMap = (XIndexContainer) UnoRuntime.queryInterface(
119 XIndexContainer.class,
120 oObj.getPropertyValue("ImageMap"));
121 int previous = imgMap.getCount();
122 log.println("Count (previous) " + previous);
124 Object im = tEnv.getObjRelation("IMGMAP");
125 imgMap.insertByIndex(0, im);
126 oObj.setPropertyValue("ImageMap", imgMap);
127 imgMap = (XIndexContainer) UnoRuntime.queryInterface(
128 XIndexContainer.class,
129 oObj.getPropertyValue("ImageMap"));
131 int after = imgMap.getCount();
132 log.println("Count (after) " + after);
133 result = previous < after;
134 } catch (Exception ex) {
135 result = false;
138 tRes.tested("ImageMap", result);
142 * Creates a new random points sequence.
144 public Point[][] newPoint() {
145 Point[][] res = new Point[1][185];
147 for (int i = 0; i < res[0].length; i++) {
148 res[0][i] = new Point();
149 res[0][i].X = rd() * rd() * rd();
150 res[0][i].Y = rd() * rd() * rd();
154 return res;
157 public int rd() {
158 return rdm.nextInt(6);
162 * Changes the existing point sequence.
164 public Point[][] changePoint(Point[][] oldPoint) {
165 Point[][] res = oldPoint;
167 for (int i = 0; i < res[0].length; i++) {
168 res[0][i].X += 1;
169 res[0][i].Y += 1;
172 return res;
174 } // finish class _TextGraphicObject