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