1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XShapeCombiner.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiMethodTest
;
35 import com
.sun
.star
.drawing
.XDrawPage
;
36 import com
.sun
.star
.drawing
.XShape
;
37 import com
.sun
.star
.drawing
.XShapeCombiner
;
38 import com
.sun
.star
.drawing
.XShapes
;
39 import com
.sun
.star
.uno
.UnoRuntime
;
42 * Testing <code>com.sun.star.drawing.XShapeCombiner</code>
45 * <li><code> combine()</code></li>
46 * <li><code> split()</code></li>
48 * This test needs the following object relations :
50 * <li> <code>'DrawPage'</code> (must implement <code>XShapes</code>):
51 * the collection of shapes in a document which used to create a group.</li>
53 * Test is <b> NOT </b> multithread compilant. <p>
54 * @see com.sun.star.drawing.XShapeCombiner
56 public class _XShapeCombiner
extends MultiMethodTest
{
58 public XShapeCombiner oObj
= null; //filled by MultiMethodTest
59 protected XShape oGroup
= null;
60 int countBeforeComb
= 0;
61 XShapes oShapes
= null;
64 * Retrieves draw page collection from relation and combines them. <p>
65 * Has <b> OK </b> status if the shape group returned is not null nd
66 * number of shapes in collection is 1 (shapes are combined into a single
69 public void _combine () {
70 XDrawPage dp
= (XDrawPage
) tEnv
.getObjRelation("DrawPage");
71 oShapes
= (XShapes
)UnoRuntime
.queryInterface( XShapes
.class, dp
);
73 boolean result
= false;
75 log
.println("testing combine() ... ");
76 countBeforeComb
= oShapes
.getCount();
77 log
.println("Count before combining:" + countBeforeComb
);
78 oGroup
= oObj
.combine(oShapes
);
79 int countAfterComb
= oShapes
.getCount();
80 log
.println("Count after combining:" + countAfterComb
);
81 result
= oGroup
!= null && countAfterComb
== 1;
83 tRes
.tested("combine()", result
);
87 * Splits the group created before. <p>
89 * Has <b> OK </b> status if number of shapes in collection after
90 * <code>split</code> is the same as before <code>combine</code>. <p>
92 * The following method tests are to be completed successfully before :
94 * <li> <code> combine() </code> : to create a shape group </li>
97 public void _split() {
98 requiredMethod("combine()");
100 boolean result
= false;
102 log
.println("spiltting the shape...");
105 int countAfterSplit
= oShapes
.getCount();
106 log
.println("Count after split:" + countAfterSplit
);
107 result
= countAfterSplit
== countBeforeComb
;
109 tRes
.tested("split()", result
);
112 } // end of XShapeCombiner