merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / drawing / _XShapeGrouper.java
blob6a20bb3c399b60a84ece7b683f6ad8b6d10dbbc8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XShapeGrouper.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 package ifc.drawing;
33 import lib.MultiMethodTest;
34 import lib.Status;
35 import lib.StatusException;
37 import com.sun.star.drawing.XShape;
38 import com.sun.star.drawing.XShapeGroup;
39 import com.sun.star.drawing.XShapeGrouper;
40 import com.sun.star.drawing.XShapes;
41 import com.sun.star.uno.UnoRuntime;
43 /**
44 * Testing <code>com.sun.star.drawing.XShapeGrouper</code>
45 * interface methods :
46 * <ul>
47 * <li><code> group()</code></li>
48 * <li><code> ungroup()</code></li>
49 * </ul> <p>
50 * This test needs the following object relations :
51 * <ul>
52 * <li> <code>'DrawPage'</code> (must implement <code>XShapes</code>):
53 * the collection of shapes in a document which used to create a group.</li>
54 * <ul> <p>
55 * Test is <b> NOT </b> multithread compilant. <p>
56 * @see com.sun.star.drawing.XShapeGrouper
58 public class _XShapeGrouper extends MultiMethodTest {
60 public XShapeGrouper oObj = null; // oObj filled by MultiMethodTest
61 XShape oGroup = null;
62 int countAfterGr = 0;
63 XShapes oShapes = null;
65 /**
66 * Retrieves draw page collection from relation and groups them. <p>
67 * Has <b> OK </b> status if the shape group returned is not null. <p>
69 public void _group() {
70 Object dp = tEnv.getObjRelation("DrawPage");
71 if (dp == null)
72 throw new StatusException(Status.failed("Relation not found")) ;
74 oShapes = (XShapes)UnoRuntime.queryInterface( XShapes.class, dp );
75 boolean result = false;
76 log.println("Grouping " + oShapes.getCount() + " shapes ... ");
78 int countBeforeGr = oShapes.getCount();
79 oGroup = oObj.group(oShapes);
80 countAfterGr = oShapes.getCount();
81 log.println("Number of shapes after grouping: " + countAfterGr);
82 result = oGroup != null ;
83 result &= countAfterGr < countBeforeGr;
85 tRes.tested("group()", result);
88 /**
89 * Ungroups the group created before. <p>
90 * Has <b> OK </b> status if the method successfully returns
91 * and no exceptions were thrown. <p>
92 * The following method tests are to be completed successfully before :
93 * <ul>
94 * <li> <code> group() </code> : to create a shape group </li>
95 * </ul>
97 public void _ungroup() {
98 requiredMethod("group()");
99 boolean result = false;
100 log.println("ungrouping the shape...");
102 oObj.ungroup((XShapeGroup)oGroup);
103 int countAfterUnGr = oShapes.getCount();
104 log.println("Number of shapes after ungrouping: " + countAfterUnGr);
106 result = countAfterUnGr != countAfterGr;
108 tRes.tested("ungroup()", result);