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 .
21 import lib
.MultiMethodTest
;
23 import com
.sun
.star
.drawing
.XDrawPage
;
24 import com
.sun
.star
.drawing
.XShape
;
25 import com
.sun
.star
.drawing
.XShapeCombiner
;
26 import com
.sun
.star
.drawing
.XShapes
;
27 import com
.sun
.star
.uno
.UnoRuntime
;
30 * Testing <code>com.sun.star.drawing.XShapeCombiner</code>
33 * <li><code> combine()</code></li>
34 * <li><code> split()</code></li>
36 * This test needs the following object relations :
38 * <li> <code>'DrawPage'</code> (must implement <code>XShapes</code>):
39 * the collection of shapes in a document which used to create a group.</li>
41 * Test is <b> NOT </b> multithread compliant. <p>
42 * @see com.sun.star.drawing.XShapeCombiner
44 public class _XShapeCombiner
extends MultiMethodTest
{
46 public XShapeCombiner oObj
= null; //filled by MultiMethodTest
47 protected XShape oGroup
= null;
48 int countBeforeComb
= 0;
49 XShapes oShapes
= null;
52 * Retrieves draw page collection from relation and combines them. <p>
53 * Has <b> OK </b> status if the shape group returned is not null nd
54 * number of shapes in collection is 1 (shapes are combined into a single
57 public void _combine () {
58 XDrawPage dp
= (XDrawPage
) tEnv
.getObjRelation("DrawPage");
59 oShapes
= UnoRuntime
.queryInterface( XShapes
.class, dp
);
61 boolean result
= false;
63 log
.println("testing combine() ... ");
64 countBeforeComb
= oShapes
.getCount();
65 log
.println("Count before combining:" + countBeforeComb
);
66 oGroup
= oObj
.combine(oShapes
);
67 int countAfterComb
= oShapes
.getCount();
68 log
.println("Count after combining:" + countAfterComb
);
69 result
= oGroup
!= null && countAfterComb
== 1;
71 tRes
.tested("combine()", result
);
75 * Splits the group created before. <p>
77 * Has <b> OK </b> status if number of shapes in collection after
78 * <code>split</code> is the same as before <code>combine</code>. <p>
80 * The following method tests are to be completed successfully before :
82 * <li> <code> combine() </code> : to create a shape group </li>
85 public void _split() {
86 requiredMethod("combine()");
88 boolean result
= false;
90 log
.println("splitting the shape...");
93 int countAfterSplit
= oShapes
.getCount();
94 log
.println("Count after split:" + countAfterSplit
);
95 result
= countAfterSplit
== countBeforeComb
;
97 tRes
.tested("split()", result
);
100 } // end of XShapeCombiner