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