2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 import com
.sun
.star
.awt
.Point
;
21 import com
.sun
.star
.container
.XIndexContainer
;
22 import com
.sun
.star
.uno
.UnoRuntime
;
24 import java
.util
.Random
;
26 import lib
.MultiPropertyTest
;
32 * Testing <code>com.sun.star.text.TextGraphicObject</code>
33 * service properties :
35 * <li><code> ImageMap</code></li>
36 * <li><code> ContentProtected</code></li>
37 * <li><code> SurroundContour</code></li>
38 * <li><code> ContourOutside</code></li>
39 * <li><code> ContourPolyPolygon</code></li>
40 * <li><code> GraphicCrop</code></li>
41 * <li><code> HoriMirroredOnEvenPages</code></li>
42 * <li><code> HoriMirroredOnOddPages</code></li>
43 * <li><code> VertMirrored</code></li>
44 * <li><code> GraphicURL</code></li>
45 * <li><code> GraphicFilter</code></li>
46 * <li><code> ActualSize</code></li>
47 * <li><code> AdjustLuminance</code></li>
48 * <li><code> AdjustContrast</code></li>
49 * <li><code> AdjustRed</code></li>
50 * <li><code> AdjustGreen</code></li>
51 * <li><code> AdjustBlue</code></li>
52 * <li><code> Gamma</code></li>
53 * <li><code> GraphicIsInverted</code></li>
54 * <li><code> Transparency</code></li>
55 * <li><code> GraphicColorMode</code></li>
57 * This test needs the following object relations :
59 * <li> <code>'ImageMap'</code> (an inmplementation of
60 * <code>com.sun.star.image.ImageMapObject</code>):
61 * is used to insert a new Map into collection
62 * from 'ImageMap' property. </li>
64 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
65 * @see com.sun.star.text.TextGraphicObject
67 public class _TextGraphicObject
extends MultiPropertyTest
{
68 public Random rdm
= new Random();
71 * The tester which can change a sequence of <code>Point</code>'s
72 * or create a new one if necessary.
74 protected PropertyTester PointTester
= new PropertyTester() {
75 protected Object
getNewValue(String propName
, Object oldValue
)
76 throws java
.lang
.IllegalArgumentException
{
77 if (utils
.isVoid(oldValue
)) {
80 return changePoint((Point
[][]) oldValue
);
86 * Tested with custom <code>PointTester</code>.
88 public void _ContourPolyPolygon() {
89 log
.println("Testing with custom Property tester");
90 testProperty("ContourPolyPolygon", PointTester
);
94 * Retrieves an ImageMap from relation and inserts it to the collection
95 * obtained as property value. Then this collection is set back.
96 * After that property value is get again. The number of elements
97 * in the old collection and in just gotten collection is checked.
99 * Has <b>OK</b> status if the number of elements in the new obtained
100 * collection is greater than in old one.
102 public void _ImageMap() {
103 boolean result
= true;
106 XIndexContainer imgMap
= UnoRuntime
.queryInterface(
107 XIndexContainer
.class,
108 oObj
.getPropertyValue("ImageMap"));
109 int previous
= imgMap
.getCount();
110 log
.println("Count (previous) " + previous
);
112 Object im
= tEnv
.getObjRelation("IMGMAP");
113 imgMap
.insertByIndex(0, im
);
114 oObj
.setPropertyValue("ImageMap", imgMap
);
115 imgMap
= UnoRuntime
.queryInterface(
116 XIndexContainer
.class,
117 oObj
.getPropertyValue("ImageMap"));
119 int after
= imgMap
.getCount();
120 log
.println("Count (after) " + after
);
121 result
= previous
< after
;
122 } catch (Exception ex
) {
126 tRes
.tested("ImageMap", result
);
130 * Creates a new random points sequence.
132 public Point
[][] newPoint() {
133 Point
[][] res
= new Point
[1][185];
135 for (int i
= 0; i
< res
[0].length
; i
++) {
136 res
[0][i
] = new Point();
137 res
[0][i
].X
= rd() * rd() * rd();
138 res
[0][i
].Y
= rd() * rd() * rd();
145 return rdm
.nextInt(6);
149 * Changes the existing point sequence.
151 public Point
[][] changePoint(Point
[][] oldPoint
) {
152 Point
[][] res
= oldPoint
;
154 for (int i
= 0; i
< res
[0].length
; i
++) {
161 } // finish class _TextGraphicObject