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