View | Details | Raw Unified | Return to issue 120645
Collapse All | Expand All

(-)source/testlib/uno/ShapeUtil.java (-20 / +41 lines)
Lines 25-30 Link Here
25
25
26
import com.sun.star.uno.Exception;
26
import com.sun.star.uno.Exception;
27
import com.sun.star.uno.UnoRuntime;
27
import com.sun.star.uno.UnoRuntime;
28
import com.sun.star.lang.IndexOutOfBoundsException;
28
import com.sun.star.lang.WrappedTargetException;
29
import com.sun.star.lang.WrappedTargetException;
29
import com.sun.star.lang.XComponent;
30
import com.sun.star.lang.XComponent;
30
import com.sun.star.lang.XMultiServiceFactory;
31
import com.sun.star.lang.XMultiServiceFactory;
Lines 37-43 Link Here
37
import com.sun.star.container.NoSuchElementException;
38
import com.sun.star.container.NoSuchElementException;
38
import com.sun.star.container.XEnumeration;
39
import com.sun.star.container.XEnumeration;
39
import com.sun.star.container.XEnumerationAccess;
40
import com.sun.star.container.XEnumerationAccess;
41
import com.sun.star.container.XIndexAccess;
40
42
43
import com.sun.star.drawing.XDrawPage;
44
import com.sun.star.drawing.XDrawPages;
45
import com.sun.star.drawing.XDrawPagesSupplier;
41
import com.sun.star.drawing.XShape;
46
import com.sun.star.drawing.XShape;
42
import com.sun.star.drawing.XShapes;
47
import com.sun.star.drawing.XShapes;
43
48
Lines 75-101 Link Here
75
		return xShape;
80
		return xShape;
76
	}
81
	}
77
82
78
	/**
79
	 * try to get shape according position
80
	 * 
81
	 * @param aPos
82
	 * @return
83
	 */
84
	public static XShape getShape(XComponent xDrawDoc, Point aPos,
85
			String sShapeType) {
86
		XShape xShape = null;
87
		try {
88
			XMultiServiceFactory xFactory = (XMultiServiceFactory) UnoRuntime
89
					.queryInterface(XMultiServiceFactory.class, xDrawDoc);
90
			Object xObj = xFactory.createInstance(sShapeType);
91
			xShape = (XShape) UnoRuntime.queryInterface(XShape.class, xObj);
92
		} catch (Exception e) {
93
			// TODO Auto-generated catch block
94
			e.printStackTrace();
95
		}
96
		return xShape;
97
	}
98
83
84
99
	/**
85
	/**
100
	 * add text to a shape. the return value is the PropertySet of the text
86
	 * add text to a shape. the return value is the PropertySet of the text
101
	 * range that has been added
87
	 * range that has been added
Lines 187-190 Link Here
187
			}
173
			}
188
		}
174
		}
189
	}
175
	}
176
	/**
177
	 * Get shapes in specific page
178
	 * @param impressDocument
179
	 * @param pageIndex
180
	 * @return
181
	 * @throws Exception
182
	 */
183
	public static XShapes getShapes(XComponent impressDocument, int pageIndex) throws Exception{
184
185
		XDrawPagesSupplier drawsupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface(
186
				XDrawPagesSupplier.class, impressDocument);
187
		XDrawPages drawpages = drawsupplier.getDrawPages();
188
		XDrawPage xpage=(XDrawPage)UnoRuntime.queryInterface(XDrawPage.class, drawpages.getByIndex(pageIndex));
189
		XShapes xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
190
		return xShapes;
191
192
	}
193
	
194
	/**
195
	 * Remove the specific shape in specific page
196
	 * @param impressDocument
197
	 * @param pageIndex
198
	 * @param shapeIndex
199
	 * @throws Exception
200
	 */
201
	public static void removeOneShape(XComponent impressDocument, int pageIndex, int shapeIndex) throws Exception{
202
		XDrawPagesSupplier drawsupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface(
203
				XDrawPagesSupplier.class, impressDocument);
204
		XDrawPages drawpages = drawsupplier.getDrawPages();
205
		XDrawPage xpage=(XDrawPage)UnoRuntime.queryInterface(XDrawPage.class, drawpages.getByIndex(pageIndex));
206
		XShapes xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
207
		XShape xShape = (XShape) UnoRuntime.queryInterface(XShape.class, xShapes.getByIndex(shapeIndex));
208
		xShapes.remove(xShape);
209
210
	}
190
}
211
}
(-)source/testcase/uno/sd/ShapeProperties.java (-111 / +236 lines)
Lines 20-25 Link Here
20
 *************************************************************/
20
 *************************************************************/
21
package testcase.uno.sd;
21
package testcase.uno.sd;
22
22
23
import java.awt.geom.AffineTransform;
23
import java.io.File;
24
import java.io.File;
24
import java.io.IOException;
25
import java.io.IOException;
25
26
Lines 35-41 Link Here
35
36
36
import testlib.uno.PageUtil;
37
import testlib.uno.PageUtil;
37
import testlib.uno.ShapeUtil;
38
import testlib.uno.ShapeUtil;
39
import testlib.uno.TestUtil;
38
40
41
import com.sun.star.text.WrapTextMode;
42
import com.sun.star.text.XText;
43
import com.sun.star.text.XTextContent;
39
import com.sun.star.uno.UnoRuntime;
44
import com.sun.star.uno.UnoRuntime;
40
import com.sun.star.presentation.XPresentation;
45
import com.sun.star.presentation.XPresentation;
41
import com.sun.star.presentation.XPresentationSupplier;
46
import com.sun.star.presentation.XPresentationSupplier;
Lines 45-53 Link Here
45
import com.sun.star.awt.Point;
50
import com.sun.star.awt.Point;
46
import com.sun.star.beans.PropertyValue;
51
import com.sun.star.beans.PropertyValue;
47
import com.sun.star.beans.XPropertySet;
52
import com.sun.star.beans.XPropertySet;
53
import com.sun.star.drawing.DashStyle;
48
import com.sun.star.drawing.FillStyle;
54
import com.sun.star.drawing.FillStyle;
49
import com.sun.star.drawing.Hatch;
55
import com.sun.star.drawing.Hatch;
50
import com.sun.star.drawing.HatchStyle;
56
import com.sun.star.drawing.HatchStyle;
57
import com.sun.star.drawing.HomogenMatrix3;
58
import com.sun.star.drawing.LineDash;
59
import com.sun.star.drawing.LineStyle;
51
import com.sun.star.drawing.XDrawPage;
60
import com.sun.star.drawing.XDrawPage;
52
import com.sun.star.drawing.XDrawPages;
61
import com.sun.star.drawing.XDrawPages;
53
import com.sun.star.drawing.XDrawPagesSupplier;
62
import com.sun.star.drawing.XDrawPagesSupplier;
Lines 69-75 Link Here
69
	XDrawPages drawpages = null;
78
	XDrawPages drawpages = null;
70
	XShapes xShapes = null;
79
	XShapes xShapes = null;
71
	XDrawPage xpage = null;
80
	XDrawPage xpage = null;
72
	String filePath=null;
81
	String filePath = null;
73
82
74
	@Before
83
	@Before
75
	public void setUp() throws Exception {
84
	public void setUp() throws Exception {
Lines 82-88 Link Here
82
		unoApp.closeDocument(impressDocument);
91
		unoApp.closeDocument(impressDocument);
83
		unoApp.closeDocument(reLoadFile);
92
		unoApp.closeDocument(reLoadFile);
84
		unoApp.close();
93
		unoApp.close();
85
		if(filePath!=null)
94
		if (filePath != null)
86
			FileUtil.deleteFile(filePath);
95
			FileUtil.deleteFile(filePath);
87
	}
96
	}
88
97
Lines 91-218 Link Here
91
	 * 
100
	 * 
92
	 * @throws Exception
101
	 * @throws Exception
93
	 */
102
	 */
94
	@Test
103
	 @Test
95
	public void testInsertShape() throws Exception {
104
	 public void testInsertShape() throws Exception {
96
		Point po = new Point(1000, 8000);
105
	 Point po = new Point(1000, 8000);
97
		xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
106
	 xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
98
		XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
107
	 XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
99
				5000, 5000), "com.sun.star.drawing.EllipseShape");
108
	 5000, 5000), "com.sun.star.drawing.EllipseShape");
100
		xShapes.add(xShape);
109
	 xShapes.add(xShape);
101
		XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
110
	 XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
102
				XPropertySet.class, xShape);
111
	 XPropertySet.class, xShape);
103
		xPropSet.setPropertyValue("Name", "test");
112
	 xPropSet.setPropertyValue("Name", "test");
104
		XShape shap = ShapeUtil.getShape(impressDocument, po,
113
	 
105
				"com.sun.star.drawing.EllipseShape");
114
	 xShape=saveAndLoadShape(1,0);
106
		XPropertySet xPropSet2 = (XPropertySet) UnoRuntime.queryInterface(
115
	 XPropertySet xPropSet2 = (XPropertySet) UnoRuntime.queryInterface(
107
				XPropertySet.class, xShape);
116
	 XPropertySet.class, xShape);
108
		assertEquals("Not the same shape","test",xPropSet2.getPropertyValue("Name"));
117
	 assertEquals("Not the same shape","test",xPropSet2.getPropertyValue("Name"));
109
		assertEquals("Not EllopseShape","com.sun.star.drawing.EllipseShape",shap.getShapeType());
118
	 assertEquals("Not EllopseShape","com.sun.star.drawing.EllipseShape",xShape.getShapeType());
110
	}
119
	 }
120
	
121
	 /**
122
	 * test Insert text to an EllopseShape
123
	 *
124
	 * @throws Exception
125
	 */
126
	 @Test
127
	 public void testInsertTextToShape() throws Exception {
128
	 Point po = new Point(1000, 8000);
129
	 xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
130
	 XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
131
	 5000, 5000), "com.sun.star.drawing.EllipseShape");
132
	 xShapes.add(xShape);
133
	 xShape=saveAndLoadShape(1,0);
134
	 ShapeUtil.addPortion(xShape, "test", false);
135
	 assertEquals("Not put text correctly","test",ShapeUtil.getPortion(xShape));
136
	 }
137
	
138
	 /**
139
	 * test Shape fill with Gradient
140
	 *
141
	 * @throws Exception
142
	 */
143
	 @Test
144
	 public void testShapeFillGradient() throws Exception {
145
	 Point po = new Point(1000, 8000);
146
	 xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
147
	 XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
148
	 5000, 5000), "com.sun.star.drawing.EllipseShape");
149
	 xShapes.add(xShape);
150
	 XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
151
	 XPropertySet.class, xShape);
152
	 xPropSet.setPropertyValue("FillStyle", FillStyle.GRADIENT);
153
	 Gradient aGradient = new Gradient();
154
	 aGradient.Style = GradientStyle.LINEAR;
155
	 aGradient.StartColor = 0x00ff00;
156
	 aGradient.EndColor = 0xffff00;
157
	 aGradient.Angle = 450;
158
	 aGradient.Border = 0;
159
	 aGradient.XOffset = 0;
160
	 aGradient.YOffset = 0;
161
	 aGradient.StartIntensity = 100;
162
	 aGradient.EndIntensity = 100;
163
	 aGradient.StepCount = 10;
164
	 xPropSet.setPropertyValue("FillGradient", aGradient);
165
	 // --------------------------
166
	 xShape=saveAndLoadShape(1,0);
167
	 xPropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xShape);
168
	 // ----------------------------
169
	 assertEquals("Not Gradient Fill Style",FillStyle.GRADIENT,xPropSet.getPropertyValue("FillStyle"));
170
	 aGradient=(Gradient) xPropSet.getPropertyValue("FillGradient");
171
	 assertEquals("Not Linear Gradient",GradientStyle.LINEAR,aGradient.Style);
172
	 }
173
	
174
	 /**
175
	 * test Shape fill with yellow color
176
	 *
177
	 * @throws Exception
178
	 */
179
	 @Test
180
	 public void testShapeFillColor() throws Exception {
181
	 Point po = new Point(1000, 8000);
182
	 xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
183
	 XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
184
	 5000, 5000), "com.sun.star.drawing.EllipseShape");
185
	 xShapes.add(xShape);
186
	 XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
187
	 XPropertySet.class, xShape);
188
	 xPropSet.setPropertyValue("FillStyle", FillStyle.SOLID);
189
	 xPropSet.setPropertyValue("FillColor", 0xffff00);
190
	 // --------------------------
191
	 xShape=saveAndLoadShape(1,0);
192
	 xPropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xShape);
193
	 // ----------------------------------------------------
194
	 assertEquals("Not Color Fill Style",FillStyle.SOLID,xPropSet.getPropertyValue("FillStyle"));
195
	 assertEquals("Not Yellow Color Fill",0xffff00,xPropSet.getPropertyValue("FillColor"));
196
	 }
197
	
198
	 /**
199
	 * test shape fill with Hatch Style(Pattern in MS)
200
	 * @throws Exception
201
	 */
202
	 @Test
203
	 public void testShapeFillHatch() throws Exception {
204
	 Point po = new Point(1000, 8000);
205
	 xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
206
	 XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
207
	 5000, 5000), "com.sun.star.drawing.EllipseShape");
208
	 xShapes.add(xShape);
209
	 XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
210
	 XPropertySet.class, xShape);
211
	 xPropSet.setPropertyValue("FillStyle", FillStyle.HATCH);
212
	 Hatch aHatch=new Hatch();
213
	 aHatch.Style=HatchStyle.DOUBLE;
214
	 aHatch.Color=0x00ff00;
215
	 aHatch.Distance=100;
216
	 aHatch.Angle=450;
217
	 xPropSet.setPropertyValue("FillHatch", aHatch);
218
	
219
	 // --------------------------
220
	 xShape=saveAndLoadShape(1,0);
221
	 xPropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xShape);
222
	 // ----------------------------
223
	 assertEquals("Not Gradient Fill Style",FillStyle.HATCH,xPropSet.getPropertyValue("FillStyle"));
224
	 aHatch=(Hatch) xPropSet.getPropertyValue("FillHatch");
225
	 assertEquals("Not Double Hatch",HatchStyle.DOUBLE,aHatch.Style);
226
	 }
111
227
228
	// ------------Shape Line-----------------------------
112
	/**
229
	/**
113
	 * test Insert text to an EllopseShape
230
	 * test Shape Line style DASH
114
	 * 
231
	 * 
115
	 * @throws Exception
232
	 * @throws Exception
116
	 */
233
	 */
117
	@Test
234
	 @Test
118
	public void testInsertTextToShape() throws Exception {
235
	 public void testShapeLineStyle() throws Exception {
119
		Point po = new Point(1000, 8000);
236
	 Point po = new Point(1000, 8000);
120
		xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
237
	 xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
121
		XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
238
	 XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
122
				5000, 5000), "com.sun.star.drawing.EllipseShape");
239
	 5000, 5000), "com.sun.star.drawing.EllipseShape");
123
		xShapes.add(xShape);
240
	 xShapes.add(xShape);
124
		ShapeUtil.addPortion(xShape, "test", false);
241
	
125
		assertEquals("Not put text correctly","test",ShapeUtil.getPortion(xShape));
242
	 XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
126
	}
243
	 XPropertySet.class, xShape);
244
	 xPropSet.setPropertyValue("LineStyle", LineStyle.DASH);
245
	
246
	 LineDash aLineDash=new LineDash();
247
	 aLineDash.Style=DashStyle.ROUND;
248
	 aLineDash.Dots=2;
249
	 aLineDash.DashLen=100;
250
	 aLineDash.Distance=50;
251
	 xPropSet.setPropertyValue("LineDash", aLineDash);
252
	
253
	 // --------------------------
254
	 xShape=saveAndLoadShape(1,0);
255
	 xPropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xShape);
256
	 // ----------------------------
257
	 assertEquals("Not Dash Line Style",LineStyle.DASH,xPropSet.getPropertyValue("LineStyle"));
258
	 aLineDash=(LineDash) xPropSet.getPropertyValue("LineDash");
259
	 assertEquals("Not Round Dash Style", DashStyle.ROUND ,aLineDash.Style);
260
	 }
261
	
262
	 /**
263
	 * test Shape Line Color
264
	 * @throws Exception
265
	 */
266
	
267
	 @Test
268
	 public void testShapeLineColor() throws Exception {
269
	 Point po = new Point(1000, 8000);
270
	 xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
271
	 XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
272
	 5000, 5000), "com.sun.star.drawing.EllipseShape");
273
	 xShapes.add(xShape);
274
	 XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
275
	 XPropertySet.class, xShape);
276
	 xPropSet.setPropertyValue("LineStyle", LineStyle.DASH);
277
	 xPropSet.setPropertyValue("LineColor", 0x00ff00);
278
	 xShape=saveAndLoadShape(1,0);
279
	 xPropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xShape);
280
	 // ----------------------------
281
	 assertEquals("Not Dash Line Style",LineStyle.DASH,xPropSet.getPropertyValue("LineStyle"));
282
	 assertEquals("wrong line color", 0x00ff00,xPropSet.getPropertyValue("LineColor"));
283
	 }
127
284
128
	/**
285
	/**
129
	 * test Shape fill with Gradient
286
	 * test Shape position and size
130
	 * 
287
	 * 
131
	 * @throws Exception
288
	 * @throws Exception
132
	 */
289
	 */
133
	@Test
290
	 @Test
134
	public void testShapeFillGradient() throws Exception {
291
	 public void testShapePositionSize() throws Exception {
135
		Point po = new Point(1000, 8000);
292
	 Point po = new Point(1000, 8000);
136
		xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
293
	 xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
137
		XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
294
	 XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
138
				5000, 5000), "com.sun.star.drawing.EllipseShape");
295
	 5000, 5000), "com.sun.star.drawing.EllipseShape");
139
		xShapes.add(xShape);
296
	 xShapes.add(xShape);
140
		XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
297
	 xShape=saveAndLoadShape(1,0);
141
				XPropertySet.class, xShape);
298
	 assertEquals("wrong shape position",1000,xShape.getPosition().X);
142
		xPropSet.setPropertyValue("FillStyle", FillStyle.GRADIENT);
299
	 assertEquals("wrong shape Height", 5000 ,xShape.getSize().Height);
143
		Gradient aGradient = new Gradient();
300
	 }
144
		aGradient.Style = GradientStyle.LINEAR;
145
		aGradient.StartColor = 0x00ff00;
146
		aGradient.EndColor = 0xffff00;
147
		aGradient.Angle = 450;
148
		aGradient.Border = 0;
149
		aGradient.XOffset = 0;
150
		aGradient.YOffset = 0;
151
		aGradient.StartIntensity = 100;
152
		aGradient.EndIntensity = 100;
153
		aGradient.StepCount = 10;
154
		xPropSet.setPropertyValue("FillGradient", aGradient);
155
		// --------------------------
156
		xShape = saveAndLoadShape(po, "com.sun.star.drawing.EllipseShape");
157
		// ----------------------------
158
		assertEquals("Not Gradient Fill Style",FillStyle.GRADIENT,xPropSet.getPropertyValue("FillStyle"));
159
		aGradient=(Gradient) xPropSet.getPropertyValue("FillGradient");
160
		assertEquals("Not Linear Gradient",GradientStyle.LINEAR,aGradient.Style);
161
	}
162
301
163
	/**
302
	/**
164
	 * test Shape fill with yellow color
303
	 * test Shape rotate with 25 degree.
165
	 * 
166
	 * @throws Exception
304
	 * @throws Exception
167
	 */
305
	 */
168
	@Test
306
	@Test
169
	public void testShapeFillColor() throws Exception {
307
	public void testShapeRotation() throws Exception {
170
		Point po = new Point(1000, 8000);
308
		Point po = new Point(1000, 8000);
171
		xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
309
		xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
172
		XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
310
		XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
173
				5000, 5000), "com.sun.star.drawing.EllipseShape");
311
				5000, 5000), "com.sun.star.drawing.RectangleShape");
174
		xShapes.add(xShape);
312
		xShapes.add(xShape);
175
		XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
313
		XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
176
				XPropertySet.class, xShape);
314
				XPropertySet.class, xShape);
177
		xPropSet.setPropertyValue("FillStyle", FillStyle.SOLID);
315
		xPropSet.setPropertyValue("RotateAngle", 2500);
178
		xPropSet.setPropertyValue("FillColor", 0xffff00);
316
		xShape=saveAndLoadShape(1,0);
179
		// --------------------------
317
		xPropSet = (XPropertySet) UnoRuntime.queryInterface(
180
		xShape = saveAndLoadShape(po, "com.sun.star.drawing.EllipseShape");
318
				 XPropertySet.class, xShape);
181
		// ----------------------------------------------------
319
		assertEquals("RotateAngle is not 2500", 2500 , xPropSet.getPropertyValue("RotateAngle"));
182
		assertEquals("Not Color Fill Style",FillStyle.SOLID,xPropSet.getPropertyValue("FillStyle"));
183
		assertEquals("Not Yellow Color Fill",0xffff00,xPropSet.getPropertyValue("FillColor"));
184
	}
320
	}
185
	
321
322
323
	// ------------------Shape Remove----------------------------
186
	/**
324
	/**
187
	 * test shape fill with Hatch Style(Pattern in MS)
325
	 * test Remove shape from impress Document
326
	 * 
188
	 * @throws Exception
327
	 * @throws Exception
189
	 */
328
	 */
190
	@Test
329
	 @Test
191
	public void testShapeFillHatch() throws Exception {
330
	 public void testShapeRemove() throws Exception {
192
		Point po = new Point(1000, 8000);
331
	 Point aPos=null;
193
		xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
332
	 Size aSize=new Size(4000,4000);
194
		XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
333
	 for(int i=0;i<=4;i++){
195
				5000, 5000), "com.sun.star.drawing.EllipseShape");
334
	 aPos=new Point(1000, 3000*i);
196
		xShapes.add(xShape);
335
	 xShapes=ShapeUtil.getShapes(impressDocument, 0);
197
		XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
336
	 ShapeUtil.createAndInsertShape(impressDocument, xShapes, aPos, aSize,
198
				XPropertySet.class, xShape);
337
	 "com.sun.star.drawing.EllipseShape");
199
		xPropSet.setPropertyValue("FillStyle", FillStyle.HATCH);
338
	 }
200
		Hatch aHatch=new Hatch();
339
	 int countBeforeRemove=ShapeUtil.getShapes(impressDocument, 0).getCount();
201
		aHatch.Style=HatchStyle.DOUBLE;
340
	 ShapeUtil.removeOneShape(impressDocument, 0, 2);
202
		aHatch.Color=0x00ff00;
341
	 int countAfterRemove=ShapeUtil.getShapes(impressDocument, 0).getCount();
203
		aHatch.Distance=100;
342
	 assertEquals("Not remove shape successfully",1,countBeforeRemove-countAfterRemove);
204
		aHatch.Angle=450;
343
	 reLoadFile = saveAndReloadDoc(impressDocument,
205
		xPropSet.setPropertyValue("FillHatch", aHatch);
344
	 "StarOffice XML (Impress)", "odp");
206
		
345
	 xShapes=ShapeUtil.getShapes(reLoadFile, 0);
207
		// --------------------------
346
	 assertEquals("Shape count is wrong after reload",6,xShapes.getCount());
208
		xShape = saveAndLoadShape(po, "com.sun.star.drawing.EllipseShape");
347
	 }
209
		// ----------------------------
348
210
		assertEquals("Not Gradient Fill Style",FillStyle.HATCH,xPropSet.getPropertyValue("FillStyle"));
211
	
212
		aHatch=(Hatch) xPropSet.getPropertyValue("FillHatch");
213
		assertEquals("Not Double Hatch",HatchStyle.DOUBLE,aHatch.Style);
214
	}
215
	
216
	/**
349
	/**
217
	 * create a new presentation document and insert a new slide.
350
	 * create a new presentation document and insert a new slide.
218
	 * 
351
	 * 
Lines 236-254 Link Here
236
	 * @return
369
	 * @return
237
	 * @throws Exception
370
	 * @throws Exception
238
	 */
371
	 */
239
	public XShape saveAndLoadShape(Point po, String shapeType) throws Exception {
372
	public XShape saveAndLoadShape(int pageIndex, int shapeIndex) throws Exception {
240
		reLoadFile = saveAndReloadDoc(impressDocument,
373
		reLoadFile = saveAndReloadDoc(impressDocument,
241
				"StarOffice XML (Impress)", "odp");
374
				"StarOffice XML (Impress)", "odp");
242
		drawsupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface(
375
		xShapes=ShapeUtil.getShapes(reLoadFile, pageIndex);
243
				XDrawPagesSupplier.class, reLoadFile);
376
		return  (XShape) UnoRuntime.queryInterface(XShape.class, xShapes.getByIndex(shapeIndex));
244
		drawpages = drawsupplier.getDrawPages();
245
		xpage = PageUtil.getDrawPageByIndex(impressDocument, 1);
246
		xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
247
		XShape shap = ShapeUtil.getShape(impressDocument, po,
248
				"com.sun.star.drawing.EllipseShape");
249
		return shap;
250
	}
377
	}
251
252
	/**
378
	/**
253
	 * save and reload Presentation document.
379
	 * save and reload Presentation document.
254
	 * 
380
	 * 
Lines 260-267 Link Here
260
	 */
386
	 */
261
	private XComponent saveAndReloadDoc(XComponent presentationDocument,
387
	private XComponent saveAndReloadDoc(XComponent presentationDocument,
262
			String sFilter, String sExtension) throws Exception {
388
			String sFilter, String sExtension) throws Exception {
263
		filePath = Testspace.getPath("tmp/presentationtest."
389
		filePath = Testspace.getPath("tmp/presentationtest." + sExtension);
264
				+ sExtension);
265
		PropertyValue[] aStoreProperties = new PropertyValue[2];
390
		PropertyValue[] aStoreProperties = new PropertyValue[2];
266
		aStoreProperties[0] = new PropertyValue();
391
		aStoreProperties[0] = new PropertyValue();
267
		aStoreProperties[1] = new PropertyValue();
392
		aStoreProperties[1] = new PropertyValue();

Return to issue 120645