Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / runner / util / ValueChanger.java
blob32586c6a0f3bcb5199a2a9efa1e3e9c91a8f3681
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 ************************************************************************/
28 package util;
30 import com.sun.star.awt.Point;
31 import com.sun.star.beans.PropertyValue;
32 import com.sun.star.drawing.PolygonFlags;
33 //import util.BitmapLoader;
34 import com.sun.star.uno.Enum ;
35 import java.lang.reflect.Field ;
36 import java.lang.reflect.Method ;
37 import java.lang.reflect.Modifier ;
38 import java.lang.reflect.Array ;
39 import com.sun.star.uno.Any;
40 import com.sun.star.uno.AnyConverter;
43 public class ValueChanger {
46 // Method to change a Value, thought for properties
47 public static Object changePValue( Object oldValue ) {
49 Object newValue = null;
51 if (oldValue instanceof com.sun.star.uno.Any) {
52 try {
53 oldValue = AnyConverter.toObject(((Any) oldValue).getType(),oldValue);
54 } catch (com.sun.star.lang.IllegalArgumentException iae) {
58 if (oldValue == null)
59 return null;
61 if (oldValue instanceof Boolean) {
62 boolean oldbool = ((Boolean) oldValue).booleanValue();
63 newValue = new Boolean(!oldbool);
64 } else
66 if (oldValue instanceof Integer) {
67 int oldint = ((Integer) oldValue).intValue();
68 newValue = new Integer(oldint+5);
69 } else
71 if (oldValue instanceof Long) {
72 long oldlong = ((Long) oldValue).longValue();
73 newValue = new Long(oldlong + 15);
74 } else
76 if (oldValue instanceof Short) {
77 short oldshort = ((Short) oldValue).shortValue();
78 newValue = new Short((short) (oldshort + 1));
79 } else
81 if (oldValue instanceof Byte) {
82 byte oldbyte = ((Byte) oldValue).byteValue();
83 newValue = new Byte((byte) (oldbyte + 1));
84 } else
86 if (oldValue instanceof Float) {
87 float oldfloat = ((Float) oldValue).floatValue();
88 newValue = new Float((float) (oldfloat + 16.7));
89 } else
91 if (oldValue instanceof Double) {
92 double olddouble = ((Double) oldValue).doubleValue();
93 newValue = new Double(olddouble + 17.8);
94 } else
96 if (oldValue instanceof String) {
97 String oldString = (String) oldValue;
98 newValue = oldString + "New";
99 } else
102 if (oldValue instanceof com.sun.star.chart.ChartAxisArrangeOrderType) {
103 Object AO1 = com.sun.star.chart.ChartAxisArrangeOrderType.AUTO;
104 Object AO2= com.sun.star.chart.ChartAxisArrangeOrderType.SIDE_BY_SIDE;
105 Object AO3= com.sun.star.chart.ChartAxisArrangeOrderType.STAGGER_EVEN;
106 Object AO4= com.sun.star.chart.ChartAxisArrangeOrderType.STAGGER_ODD;
108 if (oldValue.equals(AO1)) newValue = AO2;
109 if (oldValue.equals(AO2)) newValue = AO3;
110 if (oldValue.equals(AO3)) newValue = AO4;
111 if (oldValue.equals(AO4)) newValue = AO1;
112 } else
114 if (oldValue instanceof com.sun.star.view.PaperOrientation) {
115 Object OR1 = com.sun.star.view.PaperOrientation.LANDSCAPE;
116 Object OR2 = com.sun.star.view.PaperOrientation.PORTRAIT;
118 if (oldValue.equals(OR1)) newValue = OR2;
119 else newValue = OR1;
120 } else
122 if (oldValue instanceof com.sun.star.lang.Locale) {
123 Object Loc1 = new com.sun.star.lang.Locale("en","US","");
124 Object Loc2 = new com.sun.star.lang.Locale("de","DE","");
126 if (oldValue.equals(Loc1)) newValue = Loc2;
127 else newValue = Loc1;
128 } else
130 if (oldValue instanceof com.sun.star.style.ParagraphAdjust) {
131 Object PA1 = com.sun.star.style.ParagraphAdjust.LEFT;
132 Object PA2 = com.sun.star.style.ParagraphAdjust.CENTER;
134 if (oldValue.equals(PA1)) newValue = PA2;
135 else newValue = PA1;
136 } else
138 if (oldValue instanceof com.sun.star.style.LineSpacing) {
139 com.sun.star.style.LineSpacing LS = new com.sun.star.style.LineSpacing();
140 com.sun.star.style.LineSpacing LSold = (com.sun.star.style.LineSpacing) oldValue;
141 LS.Height = (short) ((LSold.Height)+1);
142 LS.Mode = (short) ((LSold.Mode)+1);
143 newValue = LS;
144 } else
146 if (oldValue instanceof com.sun.star.drawing.Direction3D) {
147 com.sun.star.drawing.Direction3D D3D = new com.sun.star.drawing.Direction3D();
148 com.sun.star.drawing.Direction3D D3Dold = (com.sun.star.drawing.Direction3D) oldValue;
149 D3D.DirectionX = D3Dold.DirectionX + .5;
150 D3D.DirectionY = D3Dold.DirectionY + .5;
151 D3D.DirectionZ = D3Dold.DirectionZ + .5;
152 newValue = D3D;
153 } else
155 if (oldValue instanceof com.sun.star.style.GraphicLocation) {
156 Object GL1 = com.sun.star.style.GraphicLocation.AREA;
157 Object GL2 = com.sun.star.style.GraphicLocation.LEFT_BOTTOM;
159 if (oldValue.equals(GL1)) newValue = GL2;
160 else newValue = GL1;
161 } else
163 if (oldValue instanceof com.sun.star.style.TabStop) {
164 com.sun.star.style.TabStop TS = new com.sun.star.style.TabStop();
165 com.sun.star.style.TabStop TSold = (com.sun.star.style.TabStop) oldValue;
166 com.sun.star.style.TabAlign TA1 = com.sun.star.style.TabAlign.CENTER;
167 com.sun.star.style.TabAlign TA2 = com.sun.star.style.TabAlign.RIGHT;
169 if ((TSold.Alignment).equals(TA1)) TS.Alignment = TA2;
170 else TS.Alignment = TA1;
172 TS.Position = ((TSold.Position)+1);
174 newValue = TS;
175 } else
177 if (oldValue instanceof com.sun.star.style.DropCapFormat) {
178 com.sun.star.style.DropCapFormat DCF = new com.sun.star.style.DropCapFormat();
179 com.sun.star.style.DropCapFormat DCFold = (com.sun.star.style.DropCapFormat) oldValue;
180 DCF.Count = (byte) ((DCFold.Count)+1);
181 DCF.Distance = (short) ((DCFold.Distance)+1);
182 DCF.Lines = (byte) ((DCFold.Lines)+1);
183 newValue = DCF;
184 } else
186 if (oldValue instanceof com.sun.star.text.TextContentAnchorType) {
187 com.sun.star.text.TextContentAnchorType TCAT1 = com.sun.star.text.TextContentAnchorType.AS_CHARACTER;
188 com.sun.star.text.TextContentAnchorType TCAT2 = com.sun.star.text.TextContentAnchorType.AT_CHARACTER;
189 com.sun.star.text.TextContentAnchorType TCAT3 = com.sun.star.text.TextContentAnchorType.AT_FRAME;
190 com.sun.star.text.TextContentAnchorType TCAT4 = com.sun.star.text.TextContentAnchorType.AT_PAGE;
191 com.sun.star.text.TextContentAnchorType TCAT5 = com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH;
192 if (oldValue.equals(TCAT1)) newValue = TCAT2;
193 if (oldValue.equals(TCAT2)) newValue = TCAT3;
194 if (oldValue.equals(TCAT3)) newValue = TCAT4;
195 if (oldValue.equals(TCAT4)) newValue = TCAT5;
196 if (oldValue.equals(TCAT5)) newValue = TCAT1;
197 } else
199 if (oldValue instanceof com.sun.star.text.WrapTextMode) {
200 com.sun.star.text.WrapTextMode WTM1 = com.sun.star.text.WrapTextMode.DYNAMIC;
201 com.sun.star.text.WrapTextMode WTM2 = com.sun.star.text.WrapTextMode.LEFT;
202 com.sun.star.text.WrapTextMode WTM3 = com.sun.star.text.WrapTextMode.NONE;
203 com.sun.star.text.WrapTextMode WTM4 = com.sun.star.text.WrapTextMode.PARALLEL;
204 com.sun.star.text.WrapTextMode WTM5 = com.sun.star.text.WrapTextMode.RIGHT;
205 com.sun.star.text.WrapTextMode WTM6 = com.sun.star.text.WrapTextMode.THROUGHT;
206 if (oldValue.equals(WTM1)) newValue = WTM2;
207 if (oldValue.equals(WTM2)) newValue = WTM3;
208 if (oldValue.equals(WTM3)) newValue = WTM4;
209 if (oldValue.equals(WTM4)) newValue = WTM5;
210 if (oldValue.equals(WTM5)) newValue = WTM6;
211 if (oldValue.equals(WTM6)) newValue = WTM1;
212 } else
214 if (oldValue instanceof com.sun.star.awt.Size) {
215 com.sun.star.awt.Size oldSize = (com.sun.star.awt.Size) oldValue;
216 com.sun.star.awt.Size newSize = new com.sun.star.awt.Size();
217 newSize.Height = oldSize.Height +1;
218 newSize.Width = oldSize.Width +1;
219 newValue = newSize;
220 } else
222 if (oldValue instanceof com.sun.star.awt.Rectangle) {
223 com.sun.star.awt.Rectangle oldRectangle = (com.sun.star.awt.Rectangle) oldValue;
224 com.sun.star.awt.Rectangle newRectangle = new com.sun.star.awt.Rectangle();
225 newRectangle.Height =oldRectangle.Height +1;
226 newRectangle.Width = oldRectangle.Width +1;
227 newRectangle.X =oldRectangle.Y +1;
228 newRectangle.Y = oldRectangle.X +1;
229 newValue = newRectangle;
230 } else
232 if (oldValue instanceof com.sun.star.awt.Point) {
233 com.sun.star.awt.Point oldPoint = (com.sun.star.awt.Point) oldValue;
234 com.sun.star.awt.Point newPoint = new com.sun.star.awt.Point();
235 newPoint.X = oldPoint.X +1;
236 newPoint.Y = oldPoint.Y +1;
237 newValue = newPoint;
238 } else
240 if (oldValue instanceof com.sun.star.table.ShadowFormat) {
241 com.sun.star.table.ShadowFormat SF = new com.sun.star.table.ShadowFormat();
242 com.sun.star.table.ShadowFormat SFold = (com.sun.star.table.ShadowFormat) oldValue;
243 SF.IsTransparent = (! SFold.IsTransparent);
244 SF.ShadowWidth = (short) ((SFold.ShadowWidth)+1);
245 newValue = SF;
246 } else
248 if (oldValue instanceof com.sun.star.awt.FontSlant) {
249 com.sun.star.awt.FontSlant FS1 = com.sun.star.awt.FontSlant.DONTKNOW;
250 com.sun.star.awt.FontSlant FS2 = com.sun.star.awt.FontSlant.ITALIC;
251 com.sun.star.awt.FontSlant FS3 = com.sun.star.awt.FontSlant.NONE;
252 com.sun.star.awt.FontSlant FS4 = com.sun.star.awt.FontSlant.OBLIQUE;
253 com.sun.star.awt.FontSlant FS5 = com.sun.star.awt.FontSlant.REVERSE_ITALIC;
254 com.sun.star.awt.FontSlant FS6 = com.sun.star.awt.FontSlant.REVERSE_OBLIQUE;
255 if (oldValue.equals(FS1)) newValue = FS2;
256 if (oldValue.equals(FS2)) newValue = FS3;
257 if (oldValue.equals(FS3)) newValue = FS4;
258 if (oldValue.equals(FS4)) newValue = FS5;
259 if (oldValue.equals(FS5)) newValue = FS6;
260 if (oldValue.equals(FS6)) newValue = FS1;
261 } else
263 if (oldValue instanceof com.sun.star.table.CellHoriJustify) {
264 com.sun.star.table.CellHoriJustify CHJ1 = com.sun.star.table.CellHoriJustify.BLOCK;
265 com.sun.star.table.CellHoriJustify CHJ2 = com.sun.star.table.CellHoriJustify.CENTER;
266 com.sun.star.table.CellHoriJustify CHJ3 = com.sun.star.table.CellHoriJustify.LEFT;
267 com.sun.star.table.CellHoriJustify CHJ4 = com.sun.star.table.CellHoriJustify.REPEAT;
268 com.sun.star.table.CellHoriJustify CHJ5 = com.sun.star.table.CellHoriJustify.RIGHT;
269 com.sun.star.table.CellHoriJustify CHJ6 = com.sun.star.table.CellHoriJustify.STANDARD;
270 if (oldValue.equals(CHJ1)) newValue = CHJ2;
271 if (oldValue.equals(CHJ2)) newValue = CHJ3;
272 if (oldValue.equals(CHJ3)) newValue = CHJ4;
273 if (oldValue.equals(CHJ4)) newValue = CHJ5;
274 if (oldValue.equals(CHJ5)) newValue = CHJ6;
275 if (oldValue.equals(CHJ6)) newValue = CHJ1;
276 } else
278 if (oldValue instanceof com.sun.star.table.CellVertJustify) {
279 com.sun.star.table.CellVertJustify CVJ1 = com.sun.star.table.CellVertJustify.BOTTOM;
280 com.sun.star.table.CellVertJustify CVJ2 = com.sun.star.table.CellVertJustify.CENTER;
281 com.sun.star.table.CellVertJustify CVJ3 = com.sun.star.table.CellVertJustify.STANDARD;
282 com.sun.star.table.CellVertJustify CVJ4 = com.sun.star.table.CellVertJustify.TOP;
283 if (oldValue.equals(CVJ1)) newValue = CVJ2;
284 if (oldValue.equals(CVJ2)) newValue = CVJ3;
285 if (oldValue.equals(CVJ3)) newValue = CVJ4;
286 if (oldValue.equals(CVJ4)) newValue = CVJ1;
287 } else
289 if (oldValue instanceof com.sun.star.table.CellOrientation) {
290 com.sun.star.table.CellOrientation CO1 = com.sun.star.table.CellOrientation.BOTTOMTOP;
291 com.sun.star.table.CellOrientation CO2 = com.sun.star.table.CellOrientation.STACKED;
292 com.sun.star.table.CellOrientation CO3 = com.sun.star.table.CellOrientation.STANDARD;
293 com.sun.star.table.CellOrientation CO4 = com.sun.star.table.CellOrientation.TOPBOTTOM;
294 if (oldValue.equals(CO1)) newValue = CO2;
295 if (oldValue.equals(CO2)) newValue = CO3;
296 if (oldValue.equals(CO3)) newValue = CO4;
297 if (oldValue.equals(CO4)) newValue = CO1;
298 } else
300 if (oldValue instanceof com.sun.star.util.CellProtection) {
301 com.sun.star.util.CellProtection CP = new com.sun.star.util.CellProtection();
302 com.sun.star.util.CellProtection CPold = (com.sun.star.util.CellProtection) oldValue;
303 CP.IsFormulaHidden = (! CPold.IsFormulaHidden);
304 CP.IsHidden = (! CPold.IsHidden);
305 CP.IsLocked = (! CPold.IsLocked);
306 CP.IsPrintHidden = (! CPold.IsPrintHidden);
307 newValue = CP;
308 } else
310 if (oldValue instanceof com.sun.star.table.TableBorder) {
311 com.sun.star.table.TableBorder TBold = (com.sun.star.table.TableBorder) oldValue;
312 com.sun.star.table.TableBorder TB = new com.sun.star.table.TableBorder();
313 TB.IsBottomLineValid = (! TBold.IsBottomLineValid);
314 TB.IsDistanceValid = (! TBold.IsDistanceValid);
315 TB.IsRightLineValid = (! TBold.IsRightLineValid);
316 TB.IsTopLineValid = (! TBold.IsTopLineValid);
317 newValue = TB;
318 } else
320 if (oldValue instanceof com.sun.star.awt.XBitmap) {
321 newValue = new BitmapLoader();
324 if (oldValue instanceof com.sun.star.drawing.FillStyle) {
325 com.sun.star.drawing.FillStyle FS1 = com.sun.star.drawing.FillStyle.NONE;
326 com.sun.star.drawing.FillStyle FS2 = com.sun.star.drawing.FillStyle.SOLID;
327 com.sun.star.drawing.FillStyle FS3 = com.sun.star.drawing.FillStyle.GRADIENT;
328 com.sun.star.drawing.FillStyle FS4 = com.sun.star.drawing.FillStyle.HATCH;
329 com.sun.star.drawing.FillStyle FS5 = com.sun.star.drawing.FillStyle.BITMAP;
330 if (oldValue.equals(FS1)) newValue = FS2;
331 if (oldValue.equals(FS2)) newValue = FS3;
332 if (oldValue.equals(FS3)) newValue = FS4;
333 if (oldValue.equals(FS4)) newValue = FS5;
334 if (oldValue.equals(FS5)) newValue = FS1;
335 } else
337 if (oldValue instanceof com.sun.star.awt.Gradient){
338 com.sun.star.awt.Gradient _newValue = (com.sun.star.awt.Gradient)oldValue;
339 _newValue.Angle += 10;
340 _newValue.Border += 1;
341 _newValue.EndColor += 1000;
342 _newValue.EndIntensity -= 10;
343 _newValue.StartColor += 500;
344 _newValue.StartIntensity += 10;
345 _newValue.StepCount += 50;
346 _newValue.Style = com.sun.star.awt.GradientStyle.RADIAL;
347 _newValue.XOffset += 10;
348 _newValue.YOffset += 10;
349 newValue = _newValue;
350 } else
352 if (oldValue instanceof com.sun.star.text.GraphicCrop){
353 com.sun.star.text.GraphicCrop _newValue = (com.sun.star.text.GraphicCrop)oldValue;
354 _newValue.Bottom += 10;
355 _newValue.Left += 10;
356 _newValue.Right += 10;
357 _newValue.Top += 10;
358 newValue = _newValue;
359 } else
361 if (oldValue instanceof com.sun.star.drawing.BitmapMode){
362 com.sun.star.drawing.BitmapMode bm1 = com.sun.star.drawing.BitmapMode.NO_REPEAT;
363 com.sun.star.drawing.BitmapMode bm2 = com.sun.star.drawing.BitmapMode.REPEAT;
364 com.sun.star.drawing.BitmapMode bm3 = com.sun.star.drawing.BitmapMode.STRETCH;
365 if (oldValue.equals(bm1)) newValue = bm2;
366 if (oldValue.equals(bm2)) newValue = bm3;
367 if (oldValue.equals(bm3)) newValue = bm3;
368 } else
370 if (oldValue instanceof com.sun.star.drawing.TextAdjust){
371 com.sun.star.drawing.TextAdjust TA1 = com.sun.star.drawing.TextAdjust.BLOCK;
372 com.sun.star.drawing.TextAdjust TA2 = com.sun.star.drawing.TextAdjust.CENTER;
373 com.sun.star.drawing.TextAdjust TA3 = com.sun.star.drawing.TextAdjust.LEFT;
374 com.sun.star.drawing.TextAdjust TA4 = com.sun.star.drawing.TextAdjust.RIGHT;
375 com.sun.star.drawing.TextAdjust TA5 = com.sun.star.drawing.TextAdjust.STRETCH;
376 if (oldValue.equals(TA1)) newValue = TA2;
377 if (oldValue.equals(TA2)) newValue = TA3;
378 if (oldValue.equals(TA3)) newValue = TA4;
379 if (oldValue.equals(TA4)) newValue = TA5;
380 if (oldValue.equals(TA5)) newValue = TA1;
381 } else
382 if (oldValue instanceof com.sun.star.drawing.TextFitToSizeType){
383 com.sun.star.drawing.TextFitToSizeType TF1 = com.sun.star.drawing.TextFitToSizeType.ALLLINES;
384 com.sun.star.drawing.TextFitToSizeType TF2 = com.sun.star.drawing.TextFitToSizeType.NONE;
385 com.sun.star.drawing.TextFitToSizeType TF3 = com.sun.star.drawing.TextFitToSizeType.PROPORTIONAL;
386 com.sun.star.drawing.TextFitToSizeType TF4 = com.sun.star.drawing.TextFitToSizeType.AUTOFIT;
387 if (oldValue.equals(TF1)) newValue = TF2;
388 if (oldValue.equals(TF2)) newValue = TF3;
389 if (oldValue.equals(TF3)) newValue = TF4;
390 if (oldValue.equals(TF4)) newValue = TF1;
391 } else
392 if (oldValue instanceof com.sun.star.drawing.TextAnimationKind){
393 com.sun.star.drawing.TextAnimationKind AK1 = com.sun.star.drawing.TextAnimationKind.NONE;
394 com.sun.star.drawing.TextAnimationKind AK2 = com.sun.star.drawing.TextAnimationKind.SLIDE;
395 com.sun.star.drawing.TextAnimationKind AK3 = com.sun.star.drawing.TextAnimationKind.SCROLL;
396 com.sun.star.drawing.TextAnimationKind AK4 = com.sun.star.drawing.TextAnimationKind.BLINK;
397 com.sun.star.drawing.TextAnimationKind AK5 = com.sun.star.drawing.TextAnimationKind.ALTERNATE;
399 if (oldValue.equals(AK1)) newValue = AK2;
400 if (oldValue.equals(AK2)) newValue = AK3;
401 if (oldValue.equals(AK3)) newValue = AK4;
402 if (oldValue.equals(AK4)) newValue = AK5;
403 if (oldValue.equals(AK5)) newValue = AK1;
404 } else
405 if (oldValue instanceof com.sun.star.drawing.TextAnimationDirection){
406 com.sun.star.drawing.TextAnimationDirection AD1 = com.sun.star.drawing.TextAnimationDirection.LEFT;
407 com.sun.star.drawing.TextAnimationDirection AD2 = com.sun.star.drawing.TextAnimationDirection.RIGHT;
408 com.sun.star.drawing.TextAnimationDirection AD3 = com.sun.star.drawing.TextAnimationDirection.DOWN;
409 com.sun.star.drawing.TextAnimationDirection AD4 = com.sun.star.drawing.TextAnimationDirection.UP;
410 if (oldValue.equals(AD1)) newValue = AD2;
411 if (oldValue.equals(AD2)) newValue = AD3;
412 if (oldValue.equals(AD3)) newValue = AD4;
413 if (oldValue.equals(AD4)) newValue = AD1;
414 } else
415 if (oldValue instanceof com.sun.star.drawing.LineStyle){
416 com.sun.star.drawing.LineStyle LS1 = com.sun.star.drawing.LineStyle.NONE;
417 com.sun.star.drawing.LineStyle LS2 = com.sun.star.drawing.LineStyle.DASH;
418 com.sun.star.drawing.LineStyle LS3 = com.sun.star.drawing.LineStyle.SOLID;
419 if (oldValue.equals(LS1)) newValue = LS2;
420 if (oldValue.equals(LS2)) newValue = LS3;
421 if (oldValue.equals(LS3)) newValue = LS1;
422 } else
423 if (oldValue instanceof com.sun.star.drawing.LineJoint){
424 com.sun.star.drawing.LineJoint LJ1 = com.sun.star.drawing.LineJoint.BEVEL;
425 com.sun.star.drawing.LineJoint LJ2 = com.sun.star.drawing.LineJoint.MIDDLE;
426 com.sun.star.drawing.LineJoint LJ3 = com.sun.star.drawing.LineJoint.MITER;
427 com.sun.star.drawing.LineJoint LJ4 = com.sun.star.drawing.LineJoint.NONE;
428 com.sun.star.drawing.LineJoint LJ5 = com.sun.star.drawing.LineJoint.ROUND;
429 if (oldValue.equals(LJ1)) newValue = LJ2;
430 if (oldValue.equals(LJ2)) newValue = LJ3;
431 if (oldValue.equals(LJ3)) newValue = LJ4;
432 if (oldValue.equals(LJ4)) newValue = LJ5;
433 if (oldValue.equals(LJ5)) newValue = LJ1;
434 } else
435 if (oldValue instanceof com.sun.star.drawing.LineDash){
436 com.sun.star.drawing.LineDash _newValue = (com.sun.star.drawing.LineDash)oldValue;
437 _newValue.Dashes += 1;
438 _newValue.DashLen += 10;
439 _newValue.Distance += 20;
440 _newValue.DotLen += 10;
441 _newValue.Dots += 10;
442 _newValue.Style = com.sun.star.drawing.DashStyle.RECT;
443 newValue = _newValue;
444 } else
445 if (oldValue instanceof com.sun.star.drawing.Hatch){
446 com.sun.star.drawing.Hatch _newValue = (com.sun.star.drawing.Hatch) oldValue;
447 _newValue.Angle += 10;
448 _newValue.Color += 1000;
449 _newValue.Distance += 10;
450 _newValue.Style = com.sun.star.drawing.HatchStyle.DOUBLE;
451 } else
452 if (oldValue instanceof com.sun.star.drawing.RectanglePoint){
453 com.sun.star.drawing.RectanglePoint RP1 = com.sun.star.drawing.RectanglePoint.LEFT_BOTTOM;
454 com.sun.star.drawing.RectanglePoint RP2 = com.sun.star.drawing.RectanglePoint.LEFT_MIDDLE;
455 com.sun.star.drawing.RectanglePoint RP3 = com.sun.star.drawing.RectanglePoint.LEFT_TOP;
456 com.sun.star.drawing.RectanglePoint RP4 = com.sun.star.drawing.RectanglePoint.MIDDLE_BOTTOM;
457 com.sun.star.drawing.RectanglePoint RP5 = com.sun.star.drawing.RectanglePoint.MIDDLE_MIDDLE;
458 com.sun.star.drawing.RectanglePoint RP6 = com.sun.star.drawing.RectanglePoint.MIDDLE_TOP;
459 com.sun.star.drawing.RectanglePoint RP7 = com.sun.star.drawing.RectanglePoint.RIGHT_BOTTOM;
460 com.sun.star.drawing.RectanglePoint RP8 = com.sun.star.drawing.RectanglePoint.RIGHT_MIDDLE;
461 com.sun.star.drawing.RectanglePoint RP9 = com.sun.star.drawing.RectanglePoint.RIGHT_TOP;
463 if (oldValue.equals(RP1)) newValue = RP2;
464 if (oldValue.equals(RP2)) newValue = RP3;
465 if (oldValue.equals(RP3)) newValue = RP4;
466 if (oldValue.equals(RP4)) newValue = RP5;
467 if (oldValue.equals(RP5)) newValue = RP6;
468 if (oldValue.equals(RP6)) newValue = RP7;
469 if (oldValue.equals(RP7)) newValue = RP8;
470 if (oldValue.equals(RP8)) newValue = RP9;
471 if (oldValue.equals(RP9)) newValue = RP1;
473 } else
474 if (oldValue instanceof com.sun.star.chart.ChartErrorCategory){
475 com.sun.star.chart.ChartErrorCategory CC1 = com.sun.star.chart.ChartErrorCategory.CONSTANT_VALUE;
476 com.sun.star.chart.ChartErrorCategory CC2 = com.sun.star.chart.ChartErrorCategory.ERROR_MARGIN;
477 com.sun.star.chart.ChartErrorCategory CC3 = com.sun.star.chart.ChartErrorCategory.NONE;
478 com.sun.star.chart.ChartErrorCategory CC4 = com.sun.star.chart.ChartErrorCategory.PERCENT;
479 com.sun.star.chart.ChartErrorCategory CC5 = com.sun.star.chart.ChartErrorCategory.STANDARD_DEVIATION;
480 com.sun.star.chart.ChartErrorCategory CC6 = com.sun.star.chart.ChartErrorCategory.VARIANCE;
481 if (oldValue.equals(CC1)) newValue = CC2;
482 if (oldValue.equals(CC2)) newValue = CC3;
483 if (oldValue.equals(CC3)) newValue = CC4;
484 if (oldValue.equals(CC4)) newValue = CC5;
485 if (oldValue.equals(CC5)) newValue = CC6;
486 if (oldValue.equals(CC6)) newValue = CC1;
487 } else
488 if (oldValue instanceof com.sun.star.chart.ChartErrorIndicatorType){
489 com.sun.star.chart.ChartErrorIndicatorType IT1 = com.sun.star.chart.ChartErrorIndicatorType.LOWER;
490 com.sun.star.chart.ChartErrorIndicatorType IT2 = com.sun.star.chart.ChartErrorIndicatorType.NONE;
491 com.sun.star.chart.ChartErrorIndicatorType IT3 = com.sun.star.chart.ChartErrorIndicatorType.TOP_AND_BOTTOM;
492 com.sun.star.chart.ChartErrorIndicatorType IT4 = com.sun.star.chart.ChartErrorIndicatorType.UPPER;
493 if (oldValue.equals(IT1)) newValue = IT2;
494 if (oldValue.equals(IT2)) newValue = IT3;
495 if (oldValue.equals(IT3)) newValue = IT4;
496 if (oldValue.equals(IT4)) newValue = IT1;
497 } else
498 if (oldValue instanceof com.sun.star.chart.ChartRegressionCurveType){
499 com.sun.star.chart.ChartRegressionCurveType CT1 = com.sun.star.chart.ChartRegressionCurveType.EXPONENTIAL;
500 com.sun.star.chart.ChartRegressionCurveType CT2 = com.sun.star.chart.ChartRegressionCurveType.LINEAR;
501 com.sun.star.chart.ChartRegressionCurveType CT3 = com.sun.star.chart.ChartRegressionCurveType.LOGARITHM;
502 com.sun.star.chart.ChartRegressionCurveType CT4 = com.sun.star.chart.ChartRegressionCurveType.NONE;
503 com.sun.star.chart.ChartRegressionCurveType CT5 = com.sun.star.chart.ChartRegressionCurveType.POLYNOMIAL;
504 com.sun.star.chart.ChartRegressionCurveType CT6 = com.sun.star.chart.ChartRegressionCurveType.POWER;
505 if (oldValue.equals(CT1)) newValue = CT2;
506 if (oldValue.equals(CT2)) newValue = CT3;
507 if (oldValue.equals(CT3)) newValue = CT4;
508 if (oldValue.equals(CT4)) newValue = CT5;
509 if (oldValue.equals(CT5)) newValue = CT6;
510 if (oldValue.equals(CT6)) newValue = CT1;
512 } else
513 if (oldValue instanceof com.sun.star.chart.ChartDataRowSource){
514 com.sun.star.chart.ChartDataRowSource RS1 = com.sun.star.chart.ChartDataRowSource.COLUMNS;
515 com.sun.star.chart.ChartDataRowSource RS2 = com.sun.star.chart.ChartDataRowSource.ROWS;
516 if (oldValue.equals(RS1)) newValue = RS2;
517 if (oldValue.equals(RS2)) newValue = RS1;
518 } else
519 if (oldValue instanceof com.sun.star.awt.FontDescriptor){
520 com.sun.star.awt.FontDescriptor _newValue = (com.sun.star.awt.FontDescriptor)oldValue;
521 _newValue.CharacterWidth += 5;
522 _newValue.CharSet = com.sun.star.awt.CharSet.ANSI;
523 _newValue.Family = com.sun.star.awt.FontFamily.DECORATIVE;
524 _newValue.Height += 2;
525 _newValue.Kerning = !_newValue.Kerning;
526 _newValue.Name = "Courier";
527 _newValue.Orientation += 45;
528 _newValue.Pitch = com.sun.star.awt.FontPitch.VARIABLE;
529 _newValue.Slant = com.sun.star.awt.FontSlant.REVERSE_ITALIC;
530 _newValue.Strikeout = com.sun.star.awt.FontStrikeout.X;
531 _newValue.StyleName = "Bold";
532 _newValue.Type = com.sun.star.awt.FontType.SCALABLE;
533 _newValue.Underline = com.sun.star.awt.FontUnderline.BOLDDASHDOTDOT;
534 _newValue.Weight += 5;
535 _newValue.Width += 6;
536 _newValue.WordLineMode = !_newValue.WordLineMode;
538 newValue = _newValue;
539 } else
540 if (oldValue instanceof com.sun.star.form.NavigationBarMode){
541 com.sun.star.form.NavigationBarMode BM1 = com.sun.star.form.NavigationBarMode.CURRENT;
542 com.sun.star.form.NavigationBarMode BM2 = com.sun.star.form.NavigationBarMode.NONE;
543 com.sun.star.form.NavigationBarMode BM3 = com.sun.star.form.NavigationBarMode.PARENT;
544 if (oldValue.equals(BM1)) newValue = BM2;
545 if (oldValue.equals(BM2)) newValue = BM3;
546 if (oldValue.equals(BM3)) newValue = BM1;
547 } else
548 if (oldValue instanceof com.sun.star.form.FormSubmitEncoding){
549 com.sun.star.form.FormSubmitEncoding SE1 = com.sun.star.form.FormSubmitEncoding.MULTIPART;
550 com.sun.star.form.FormSubmitEncoding SE2 = com.sun.star.form.FormSubmitEncoding.TEXT;
551 com.sun.star.form.FormSubmitEncoding SE3 = com.sun.star.form.FormSubmitEncoding.URL;
552 if (oldValue.equals(SE1)) newValue = SE2;
553 if (oldValue.equals(SE2)) newValue = SE3;
554 if (oldValue.equals(SE3)) newValue = SE1;
555 } else
556 if (oldValue instanceof com.sun.star.form.FormSubmitMethod){
557 com.sun.star.form.FormSubmitMethod FM1 = com.sun.star.form.FormSubmitMethod.GET;
558 com.sun.star.form.FormSubmitMethod FM2 = com.sun.star.form.FormSubmitMethod.POST;
559 if (oldValue.equals(FM1)) newValue = FM2;
560 if (oldValue.equals(FM2)) newValue = FM1;
561 } else
563 if (oldValue instanceof com.sun.star.text.SectionFileLink){
564 com.sun.star.text.SectionFileLink _newValue =
565 new com.sun.star.text.SectionFileLink();
567 _newValue.FileURL = util.utils.getFullTestURL("SwXTextSection.sdw");
568 newValue=_newValue;
569 } else
571 if (oldValue instanceof com.sun.star.table.BorderLine){
572 com.sun.star.table.BorderLine _newValue = (com.sun.star.table.BorderLine)oldValue;
573 _newValue.Color += 2;
574 _newValue.InnerLineWidth += 2;
575 _newValue.LineDistance += 2;
576 _newValue.OuterLineWidth += 3;
577 newValue=_newValue;
578 } else
580 if (oldValue instanceof com.sun.star.text.XTextColumns){
581 com.sun.star.text.XTextColumns _newValue = (com.sun.star.text.XTextColumns)oldValue;
582 _newValue.setColumnCount((short)1);
583 newValue=_newValue;
584 } else
586 if (oldValue instanceof com.sun.star.form.FormButtonType){
587 com.sun.star.form.FormButtonType BT1 = com.sun.star.form.FormButtonType.PUSH;
588 com.sun.star.form.FormButtonType BT2 = com.sun.star.form.FormButtonType.RESET;
589 com.sun.star.form.FormButtonType BT3 = com.sun.star.form.FormButtonType.SUBMIT;
590 com.sun.star.form.FormButtonType BT4 = com.sun.star.form.FormButtonType.URL;
592 if (oldValue.equals(BT1)) newValue = BT2;
593 if (oldValue.equals(BT2)) newValue = BT3;
594 if (oldValue.equals(BT3)) newValue = BT4;
595 if (oldValue.equals(BT4)) newValue = BT1;
597 } else
598 if (oldValue instanceof com.sun.star.form.ListSourceType){
599 com.sun.star.form.ListSourceType ST1 = com.sun.star.form.ListSourceType.QUERY;
600 com.sun.star.form.ListSourceType ST2 = com.sun.star.form.ListSourceType.SQL;
601 com.sun.star.form.ListSourceType ST3 = com.sun.star.form.ListSourceType.SQLPASSTHROUGH;
602 com.sun.star.form.ListSourceType ST4 = com.sun.star.form.ListSourceType.TABLE;
603 com.sun.star.form.ListSourceType ST5 = com.sun.star.form.ListSourceType.TABLEFIELDS;
604 com.sun.star.form.ListSourceType ST6 = com.sun.star.form.ListSourceType.VALUELIST;
605 if (oldValue.equals(ST1)) newValue = ST2;
606 if (oldValue.equals(ST2)) newValue = ST3;
607 if (oldValue.equals(ST3)) newValue = ST4;
608 if (oldValue.equals(ST4)) newValue = ST5;
609 if (oldValue.equals(ST5)) newValue = ST6;
610 if (oldValue.equals(ST6)) newValue = ST1;
611 } else
612 if (oldValue instanceof com.sun.star.table.BorderLine){
613 com.sun.star.table.BorderLine _newValue = (com.sun.star.table.BorderLine)oldValue;
614 _newValue.Color += 1000;
615 _newValue.InnerLineWidth += 2;
616 _newValue.LineDistance +=3;
617 _newValue.OuterLineWidth += 3;
618 newValue = _newValue;
619 } else
620 if (oldValue instanceof com.sun.star.sheet.DataPilotFieldOrientation) {
621 com.sun.star.sheet.DataPilotFieldOrientation FO1 = com.sun.star.sheet.DataPilotFieldOrientation.PAGE;
622 com.sun.star.sheet.DataPilotFieldOrientation FO2 = com.sun.star.sheet.DataPilotFieldOrientation.COLUMN;
623 com.sun.star.sheet.DataPilotFieldOrientation FO3 = com.sun.star.sheet.DataPilotFieldOrientation.DATA;
624 com.sun.star.sheet.DataPilotFieldOrientation FO4 = com.sun.star.sheet.DataPilotFieldOrientation.HIDDEN;
625 com.sun.star.sheet.DataPilotFieldOrientation FO5 = com.sun.star.sheet.DataPilotFieldOrientation.ROW;
626 if (oldValue.equals(FO1)) newValue = FO2;
627 if (oldValue.equals(FO2)) newValue = FO3;
628 if (oldValue.equals(FO3)) newValue = FO4;
629 if (oldValue.equals(FO4)) newValue = FO5;
630 if (oldValue.equals(FO5)) newValue = FO1;
631 } else
632 if (oldValue instanceof com.sun.star.sheet.GeneralFunction) {
633 com.sun.star.sheet.GeneralFunction GF1 = com.sun.star.sheet.GeneralFunction.NONE;
634 com.sun.star.sheet.GeneralFunction GF2 = com.sun.star.sheet.GeneralFunction.AVERAGE;
635 com.sun.star.sheet.GeneralFunction GF3 = com.sun.star.sheet.GeneralFunction.COUNT;
636 com.sun.star.sheet.GeneralFunction GF4 = com.sun.star.sheet.GeneralFunction.COUNTNUMS;
637 com.sun.star.sheet.GeneralFunction GF5 = com.sun.star.sheet.GeneralFunction.MAX;
638 com.sun.star.sheet.GeneralFunction GF6 = com.sun.star.sheet.GeneralFunction.MIN;
639 com.sun.star.sheet.GeneralFunction GF7 = com.sun.star.sheet.GeneralFunction.AUTO;
640 com.sun.star.sheet.GeneralFunction GF8 = com.sun.star.sheet.GeneralFunction.PRODUCT;
641 com.sun.star.sheet.GeneralFunction GF9 = com.sun.star.sheet.GeneralFunction.STDEV;
642 com.sun.star.sheet.GeneralFunction GF10 = com.sun.star.sheet.GeneralFunction.STDEVP;
643 com.sun.star.sheet.GeneralFunction GF11 = com.sun.star.sheet.GeneralFunction.SUM;
644 com.sun.star.sheet.GeneralFunction GF12 = com.sun.star.sheet.GeneralFunction.VAR;
645 com.sun.star.sheet.GeneralFunction GF13 = com.sun.star.sheet.GeneralFunction.VARP;
647 if (oldValue.equals(GF1)) newValue = GF2;
648 if (oldValue.equals(GF2)) newValue = GF3;
649 if (oldValue.equals(GF3)) newValue = GF4;
650 if (oldValue.equals(GF4)) newValue = GF5;
651 if (oldValue.equals(GF5)) newValue = GF6;
652 if (oldValue.equals(GF6)) newValue = GF7;
653 if (oldValue.equals(GF7)) newValue = GF8;
654 if (oldValue.equals(GF8)) newValue = GF9;
655 if (oldValue.equals(GF9)) newValue = GF10;
656 if (oldValue.equals(GF10)) newValue = GF11;
657 if (oldValue.equals(GF11)) newValue = GF12;
658 if (oldValue.equals(GF12)) newValue = GF13;
659 if (oldValue.equals(GF13)) newValue = GF1;
660 } else
662 if (oldValue instanceof com.sun.star.table.CellAddress){
663 com.sun.star.table.CellAddress _newValue = (com.sun.star.table.CellAddress)oldValue;
664 _newValue.Column += 1;
665 _newValue.Row += 1;
666 newValue = _newValue;
667 } else
669 if (oldValue instanceof com.sun.star.table.TableOrientation){
670 com.sun.star.table.TableOrientation TO1 = com.sun.star.table.TableOrientation.COLUMNS;
671 com.sun.star.table.TableOrientation TO2 = com.sun.star.table.TableOrientation.ROWS;
672 if (oldValue.equals(TO1)) newValue = TO2; else newValue = TO1;
673 } else
675 if (oldValue instanceof com.sun.star.sheet.DataImportMode){
676 com.sun.star.sheet.DataImportMode DIM1 = com.sun.star.sheet.DataImportMode.NONE;
677 com.sun.star.sheet.DataImportMode DIM2 = com.sun.star.sheet.DataImportMode.QUERY;
678 com.sun.star.sheet.DataImportMode DIM3 = com.sun.star.sheet.DataImportMode.SQL;
679 com.sun.star.sheet.DataImportMode DIM4 = com.sun.star.sheet.DataImportMode.TABLE;
681 if (oldValue.equals(DIM1)) newValue = DIM2;
682 if (oldValue.equals(DIM2)) newValue = DIM3;
683 if (oldValue.equals(DIM3)) newValue = DIM4;
684 if (oldValue.equals(DIM4)) newValue = DIM1;
686 } else
688 // if (oldValue instanceof com.sun.star.text.TableColumnSeparator[]){
689 // com.sun.star.text.TableColumnSeparator[] _newValue = (com.sun.star.text.TableColumnSeparator[]) oldValue;
690 // com.sun.star.text.TableColumnSeparator sep = new com.sun.star.text.TableColumnSeparator();
691 // sep.IsVisible = ! _newValue[0].IsVisible;
692 // _newValue[0] = sep;
693 // newValue = _newValue;
694 // } else
696 if (oldValue instanceof com.sun.star.style.BreakType){
697 com.sun.star.style.BreakType BT1 = com.sun.star.style.BreakType.COLUMN_AFTER;
698 com.sun.star.style.BreakType BT2 = com.sun.star.style.BreakType.COLUMN_BEFORE;
699 com.sun.star.style.BreakType BT3 = com.sun.star.style.BreakType.COLUMN_BOTH;
700 com.sun.star.style.BreakType BT4 = com.sun.star.style.BreakType.PAGE_AFTER;
701 com.sun.star.style.BreakType BT5 = com.sun.star.style.BreakType.PAGE_BEFORE;
702 com.sun.star.style.BreakType BT6 = com.sun.star.style.BreakType.PAGE_BOTH;
703 com.sun.star.style.BreakType BT7 = com.sun.star.style.BreakType.NONE;
704 if (oldValue.equals(BT1)) newValue = BT2;
705 if (oldValue.equals(BT2)) newValue = BT3;
706 if (oldValue.equals(BT3)) newValue = BT4;
707 if (oldValue.equals(BT4)) newValue = BT5;
708 if (oldValue.equals(BT6)) newValue = BT6;
709 if (oldValue.equals(BT6)) newValue = BT7;
710 if (oldValue.equals(BT7)) newValue = BT1;
711 } else
712 if (oldValue instanceof PropertyValue){
713 PropertyValue newVal = new PropertyValue();
714 newVal.Name = ((PropertyValue)oldValue).Name;
715 newVal.Value = changePValue(((PropertyValue)oldValue).Value);
716 newValue = newVal;
717 } else
718 if (oldValue instanceof com.sun.star.sheet.ValidationAlertStyle){
719 com.sun.star.sheet.ValidationAlertStyle VAS1 = com.sun.star.sheet.ValidationAlertStyle.INFO;
720 com.sun.star.sheet.ValidationAlertStyle VAS2 = com.sun.star.sheet.ValidationAlertStyle.MACRO;
721 com.sun.star.sheet.ValidationAlertStyle VAS3 = com.sun.star.sheet.ValidationAlertStyle.STOP;
722 com.sun.star.sheet.ValidationAlertStyle VAS4 = com.sun.star.sheet.ValidationAlertStyle.WARNING;
724 if (oldValue.equals(VAS1)) newValue = VAS2;
725 if (oldValue.equals(VAS2)) newValue = VAS3;
726 if (oldValue.equals(VAS3)) newValue = VAS4;
727 if (oldValue.equals(VAS4)) newValue = VAS1;
729 } else
730 if (oldValue instanceof com.sun.star.sheet.ValidationType){
731 com.sun.star.sheet.ValidationType VT1 = com.sun.star.sheet.ValidationType.ANY;
732 com.sun.star.sheet.ValidationType VT2 = com.sun.star.sheet.ValidationType.CUSTOM;
733 com.sun.star.sheet.ValidationType VT3 = com.sun.star.sheet.ValidationType.DATE;
734 com.sun.star.sheet.ValidationType VT4 = com.sun.star.sheet.ValidationType.DECIMAL;
735 com.sun.star.sheet.ValidationType VT5 = com.sun.star.sheet.ValidationType.LIST;
736 com.sun.star.sheet.ValidationType VT6 = com.sun.star.sheet.ValidationType.TEXT_LEN;
737 com.sun.star.sheet.ValidationType VT7 = com.sun.star.sheet.ValidationType.TIME;
738 com.sun.star.sheet.ValidationType VT8 = com.sun.star.sheet.ValidationType.WHOLE;
740 if (oldValue.equals(VT1)) newValue = VT2;
741 if (oldValue.equals(VT2)) newValue = VT3;
742 if (oldValue.equals(VT3)) newValue = VT4;
743 if (oldValue.equals(VT4)) newValue = VT5;
744 if (oldValue.equals(VT5)) newValue = VT6;
745 if (oldValue.equals(VT6)) newValue = VT7;
746 if (oldValue.equals(VT7)) newValue = VT8;
747 if (oldValue.equals(VT8)) newValue = VT1;
749 } else
750 if (oldValue instanceof com.sun.star.text.WritingMode){
751 if (oldValue.equals(com.sun.star.text.WritingMode.LR_TB)) {
752 newValue = com.sun.star.text.WritingMode.TB_RL;
753 } else {
754 newValue = com.sun.star.text.WritingMode.LR_TB;
756 } else
757 if (oldValue instanceof com.sun.star.uno.Enum) {
758 // universal changer for Enumerations
759 try {
760 Class enumClass = oldValue.getClass() ;
761 Field[] flds = enumClass.getFields() ;
763 newValue = null ;
765 for (int i = 0; i < flds.length; i++) {
766 if (Enum.class.equals(flds[i].getType().getSuperclass())) {
768 Enum value = (Enum) flds[i].get(null) ;
769 if (newValue == null && !value.equals(oldValue)) {
770 newValue = value ;
771 break ;
775 } catch (Exception e) {
776 System.err.println("Exception occurred while changing Enumeration value:") ;
777 e.printStackTrace(System.err) ;
779 if (newValue == null) newValue = oldValue ;
781 } else
782 if (oldValue instanceof com.sun.star.style.TabStop[]){
783 com.sun.star.style.TabStop[] _newValue = (com.sun.star.style.TabStop[]) oldValue;
784 if (_newValue.length == 0) {
785 _newValue = new com.sun.star.style.TabStop[1];
787 com.sun.star.style.TabStop sep = new com.sun.star.style.TabStop();
788 sep.Position += 1;
789 _newValue[0] = sep;
790 newValue = _newValue;
791 } else
792 if (oldValue instanceof short[]){
793 short[] oldArr = (short[])oldValue;
794 int len = oldArr.length;
795 short[] newArr = new short[len + 1];
796 for (int i = 0; i < len; i++) {
797 newArr[i] = (short)(oldArr[i] + 1);
799 newArr[len] = 5;
800 newValue = newArr;
801 } else
802 if (oldValue instanceof String[]){
803 String[] oldArr = (String[])oldValue;
804 int len = oldArr.length;
805 String[] newArr = new String[len + 1];
806 for (int i = 0; i < len; i++) {
807 newArr[i] = "_" + oldArr[i];
809 newArr[len] = "_dummy";
810 newValue = newArr;
811 } else
812 if (oldValue instanceof PropertyValue){
813 PropertyValue newVal = new PropertyValue();
814 newVal.Name = ((PropertyValue)oldValue).Name;
815 newVal.Value = changePValue(((PropertyValue)oldValue).Value);
816 newValue = newVal;
817 } else
818 if (oldValue instanceof com.sun.star.util.DateTime) {
819 com.sun.star.util.DateTime oldDT = (com.sun.star.util.DateTime) oldValue;
820 com.sun.star.util.DateTime newDT = new com.sun.star.util.DateTime();
821 newDT.Day = (short) (oldDT.Day+(short) 1);
822 newDT.Hours = (short) (oldDT.Hours+(short) 1);
823 newValue = newDT;
824 } else
825 if (oldValue instanceof com.sun.star.text.TableColumnSeparator) {
826 com.sun.star.text.TableColumnSeparator oldTCS = (com.sun.star.text.TableColumnSeparator) oldValue;
827 com.sun.star.text.TableColumnSeparator newTCS = new com.sun.star.text.TableColumnSeparator();
828 newTCS.IsVisible = !(oldTCS.IsVisible);
829 newTCS.Position = (short) (oldTCS.Position+(short) 1);
830 newValue = newTCS;
831 } else
832 if (oldValue instanceof com.sun.star.drawing.HomogenMatrix3) {
833 com.sun.star.drawing.HomogenMatrix3 oldHM = (com.sun.star.drawing.HomogenMatrix3) oldValue;
834 com.sun.star.drawing.HomogenMatrix3 newHM = new com.sun.star.drawing.HomogenMatrix3();
835 newHM.Line1.Column1 = oldHM.Line1.Column1+1;
836 newHM.Line2.Column2 = oldHM.Line2.Column2+1;
837 newHM.Line3.Column3 = oldHM.Line3.Column3+1;
838 newValue = newHM;
839 } else
841 if (oldValue instanceof com.sun.star.drawing.PolyPolygonBezierCoords) {
842 com.sun.star.drawing.PolyPolygonBezierCoords oldPPC = (com.sun.star.drawing.PolyPolygonBezierCoords) oldValue;
843 com.sun.star.drawing.PolyPolygonBezierCoords newPPC = new com.sun.star.drawing.PolyPolygonBezierCoords();
844 newPPC.Coordinates = oldPPC.Coordinates;
845 newPPC.Flags = oldPPC.Flags;
846 PolygonFlags[][] fArray = new PolygonFlags[1][1];
847 PolygonFlags[] flags = new PolygonFlags[1];
848 flags[0] = PolygonFlags.NORMAL;
849 fArray[0] = flags;
850 Point[][] pArray = new Point[1][1];
851 Point[] points = new Point[1];
852 Point aPoint = new Point();
853 aPoint.X = 1;
854 aPoint.Y = 2;
855 points[0] = aPoint;
856 pArray[0] = points;
857 if ( oldPPC.Coordinates.length == 0 ) {
858 newPPC.Coordinates = pArray;
859 newPPC.Flags = fArray;
860 } else {
861 if ( oldPPC.Coordinates[0].length == 0 ) {
862 newPPC.Coordinates = pArray;
863 newPPC.Flags = fArray;
864 } else {
865 newPPC.Coordinates[0][0].X = oldPPC.Coordinates[0][0].X +1;
866 newPPC.Coordinates[0][0].Y = oldPPC.Coordinates[0][0].Y +1;
869 newValue = newPPC;
870 } else
871 if (oldValue.getClass().isArray()) {
872 // changer for arrays : changes all elements
873 Class arrType = oldValue.getClass().getComponentType() ;
874 newValue = Array.newInstance(arrType, Array.getLength(oldValue)) ;
875 for (int i = 0; i < Array.getLength(newValue); i++) {
876 if (!arrType.isPrimitive()) {
877 Object elem = changePValue(Array.get(oldValue, i)) ;
878 Array.set(newValue, i, elem);
879 } else {
880 if (Boolean.TYPE.equals(arrType)) {
881 Array.setBoolean(newValue, i, !Array.getBoolean(oldValue, i));
882 } else
883 if (Byte.TYPE.equals(arrType)) {
884 Array.setByte(newValue, i,
885 (byte) (Array.getByte(oldValue, i) + 1));
886 } else
887 if (Character.TYPE.equals(arrType)) {
888 Array.setChar(newValue, i,
889 (char) (Array.getChar(oldValue, i) + 1));
890 } else
891 if (Double.TYPE.equals(arrType)) {
892 Array.setDouble(newValue, i, Array.getDouble(oldValue, i) + 1);
893 } else
894 if (Float.TYPE.equals(arrType)) {
895 Array.setFloat(newValue, i, Array.getFloat(oldValue, i) + 1);
896 } else
897 if (Integer.TYPE.equals(arrType)) {
898 Array.setInt(newValue, i, Array.getInt(oldValue, i) + 1);
899 } else
900 if (Long.TYPE.equals(arrType)) {
901 Array.setLong(newValue, i, Array.getLong(oldValue, i) + 1);
902 } else
903 if (Short.TYPE.equals(arrType)) {
904 Array.setShort(newValue, i,
905 (short) (Array.getShort(oldValue, i) + 1));
909 } else
910 if (isStructure(oldValue)) {
911 // universal changer for structures
912 Class clazz = oldValue.getClass() ;
913 try {
914 newValue = clazz.newInstance() ;
915 Field[] fields = clazz.getFields();
916 for (int i = 0; i < fields.length; i++) {
917 if ((fields[i].getModifiers() & Modifier.PUBLIC) != 0) {
918 Class fType = fields[i].getType() ;
919 Field field = fields[i] ;
920 if (!fType.isPrimitive()) {
921 field.set(newValue, changePValue(field.get(oldValue)));
922 } else {
923 if (Boolean.TYPE.equals(fType)) {
924 field.setBoolean(newValue, !field.getBoolean(oldValue));
925 } else
926 if (Byte.TYPE.equals(fType)) {
927 field.setByte(newValue, (byte) (field.getByte(oldValue) + 1));
928 } else
929 if (Character.TYPE.equals(fType)) {
930 field.setChar(newValue, (char) (field.getChar(oldValue) + 1));
931 } else
932 if (Double.TYPE.equals(fType)) {
933 field.setDouble(newValue, field.getDouble(oldValue) + 1);
934 } else
935 if (Float.TYPE.equals(fType)) {
936 field.setFloat(newValue, field.getFloat(oldValue) + 1);
937 } else
938 if (Integer.TYPE.equals(fType)) {
939 field.setInt(newValue, field.getInt(oldValue) + 1);
940 } else
941 if (Long.TYPE.equals(fType)) {
942 field.setLong(newValue, field.getLong(oldValue) + 1);
943 } else
944 if (Short.TYPE.equals(fType)) {
945 field.setShort(newValue, (short) (field.getShort(oldValue) + 1));
950 } catch (IllegalAccessException e) {
951 e.printStackTrace() ;
952 } catch (InstantiationException e) {
953 e.printStackTrace() ;
956 } else
958 System.out.println("ValueChanger don't know type " + oldValue.getClass());
961 return newValue;
963 } // end of Change PValue
966 * Checks if the passed value is the API structure.
967 * The value assumed to be a structure if there are no public
968 * methods, and all public fields are not static or final.
970 * @param val the value to be checked.
971 * @return <code>true</code> if the value is acssumed to be a
972 * structure.
974 private static boolean isStructure(Object val) {
975 boolean result = true ;
977 Class clazz = val.getClass() ;
979 Method[] meth = clazz.getDeclaredMethods() ;
980 for (int i = 0; i < meth.length; i++) {
981 result &= (meth[i].getModifiers() & Modifier.PUBLIC) == 0 ;
984 Field[] fields = clazz.getDeclaredFields() ;
985 for (int i = 0; i < fields.length; i++) {
986 int mod = fields[i].getModifiers() ;
987 // If the field is PUBLIC it must not be STATIC or FINAL
988 result &= ((mod & Modifier.PUBLIC) == 0) ||
989 (((mod & Modifier.STATIC) == 0) && ((mod & Modifier.FINAL) == 0)) ;
992 return result ;