1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
29 import com
.sun
.star
.awt
.Point
;
30 import com
.sun
.star
.container
.XIndexContainer
;
31 import com
.sun
.star
.uno
.UnoRuntime
;
33 import java
.util
.Random
;
35 import lib
.MultiPropertyTest
;
41 * Testing <code>com.sun.star.text.TextGraphicObject</code>
42 * service properties :
44 * <li><code> ImageMap</code></li>
45 * <li><code> ContentProtected</code></li>
46 * <li><code> SurroundContour</code></li>
47 * <li><code> ContourOutside</code></li>
48 * <li><code> ContourPolyPolygon</code></li>
49 * <li><code> GraphicCrop</code></li>
50 * <li><code> HoriMirroredOnEvenPages</code></li>
51 * <li><code> HoriMirroredOnOddPages</code></li>
52 * <li><code> VertMirrored</code></li>
53 * <li><code> GraphicURL</code></li>
54 * <li><code> GraphicFilter</code></li>
55 * <li><code> ActualSize</code></li>
56 * <li><code> AdjustLuminance</code></li>
57 * <li><code> AdjustContrast</code></li>
58 * <li><code> AdjustRed</code></li>
59 * <li><code> AdjustGreen</code></li>
60 * <li><code> AdjustBlue</code></li>
61 * <li><code> Gamma</code></li>
62 * <li><code> GraphicIsInverted</code></li>
63 * <li><code> Transparency</code></li>
64 * <li><code> GraphicColorMode</code></li>
66 * This test needs the following object relations :
68 * <li> <code>'ImageMap'</code> (an inmplementation of
69 * <code>com.sun.star.image.ImageMapObject</code>):
70 * is used to insert a new Map into collection
71 * from 'ImageMap' property. </li>
73 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
74 * @see com.sun.star.text.TextGraphicObject
76 public class _TextGraphicObject
extends MultiPropertyTest
{
77 public Random rdm
= new Random();
80 * The tester which can change a sequence of <code>Point</code>'s
81 * or create a new one if necessary.
83 protected PropertyTester PointTester
= new PropertyTester() {
84 protected Object
getNewValue(String propName
, Object oldValue
)
85 throws java
.lang
.IllegalArgumentException
{
86 if (utils
.isVoid(oldValue
)) {
89 return changePoint((Point
[][]) oldValue
);
95 * Tested with custom <code>PointTester</code>.
97 public void _ContourPolyPolygon() {
98 log
.println("Testing with custom Property tester");
99 testProperty("ContourPolyPolygon", PointTester
);
103 * Retrieves an ImageMap from relation and inserts it to the collection
104 * obtained as property value. Then this collection is set back.
105 * After that property value is get again. The number of elements
106 * in the old collection and in just gotten collection is checked.
108 * Has <b>OK</b> status if the number of elements in the new obtained
109 * collection is greater than in old one.
111 public void _ImageMap() {
112 boolean result
= true;
115 XIndexContainer imgMap
= (XIndexContainer
) UnoRuntime
.queryInterface(
116 XIndexContainer
.class,
117 oObj
.getPropertyValue("ImageMap"));
118 int previous
= imgMap
.getCount();
119 log
.println("Count (previous) " + previous
);
121 Object im
= tEnv
.getObjRelation("IMGMAP");
122 imgMap
.insertByIndex(0, im
);
123 oObj
.setPropertyValue("ImageMap", imgMap
);
124 imgMap
= (XIndexContainer
) UnoRuntime
.queryInterface(
125 XIndexContainer
.class,
126 oObj
.getPropertyValue("ImageMap"));
128 int after
= imgMap
.getCount();
129 log
.println("Count (after) " + after
);
130 result
= previous
< after
;
131 } catch (Exception ex
) {
135 tRes
.tested("ImageMap", result
);
139 * Creates a new random points sequence.
141 public Point
[][] newPoint() {
142 Point
[][] res
= new Point
[1][185];
144 for (int i
= 0; i
< res
[0].length
; i
++) {
145 res
[0][i
] = new Point();
146 res
[0][i
].X
= rd() * rd() * rd();
147 res
[0][i
].Y
= rd() * rd() * rd();
155 return rdm
.nextInt(6);
159 * Changes the existing point sequence.
161 public Point
[][] changePoint(Point
[][] oldPoint
) {
162 Point
[][] res
= oldPoint
;
164 for (int i
= 0; i
< res
[0].length
; i
++) {
171 } // finish class _TextGraphicObject