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