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 mod._sc; 29 30 import java.io.PrintWriter; 31 32 import lib.StatusException; 33 import lib.TestCase; 34 import lib.TestEnvironment; 35 import lib.TestParameters; 36 import util.SOfficeFactory; 37 38 import com.sun.star.drawing.XDrawPages; 39 import com.sun.star.drawing.XDrawPagesSupplier; 40 import com.sun.star.lang.XComponent; 41 import com.sun.star.lang.XMultiServiceFactory; 42 import com.sun.star.sheet.XSpreadsheetDocument; 43 import com.sun.star.uno.UnoRuntime; 44 import com.sun.star.uno.XInterface; 45 46 /** 47 * Test for object which is represented by service 48 * <code>com.sun.star.drawing.DrawPages</code>. <p> 49 * Object implements the following interfaces : 50 * <ul> 51 * <li> <code>com::sun::star::drawing::XDrawPageExpander</code></li> 52 * <li> <code>com::sun::star::container::XIndexAccess</code></li> 53 * <li> <code>com::sun::star::drawing::XDrawPageSummarizer</code></li> 54 * <li> <code>com::sun::star::container::XElementAccess</code></li> 55 * <li> <code>com::sun::star::drawing::XDrawPages</code></li> 56 * </ul> 57 * @see com.sun.star.drawing.DrawPages 58 * @see com.sun.star.drawing.XDrawPageExpander 59 * @see com.sun.star.container.XIndexAccess 60 * @see com.sun.star.drawing.XDrawPageSummarizer 61 * @see com.sun.star.container.XElementAccess 62 * @see com.sun.star.drawing.XDrawPages 63 * @see ifc.drawing._XDrawPageExpander 64 * @see ifc.container._XIndexAccess 65 * @see ifc.drawing._XDrawPageSummarizer 66 * @see ifc.container._XElementAccess 67 * @see ifc.drawing._XDrawPages 68 */ 69 public class ScDrawPagesObj extends TestCase { 70 static XSpreadsheetDocument xSheetDoc = null; 71 72 /** 73 * Creates Spreadsheet document. 74 */ 75 protected void initialize( TestParameters tParam, PrintWriter log ) { 76 77 // get a soffice factory object 78 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); 79 80 try { 81 log.println( "creating a sheetdocument" ); 82 xSheetDoc = SOF.createCalcDoc(null); 83 } catch (com.sun.star.uno.Exception e) { 84 // Some exception occures.FAILED 85 e.printStackTrace( log ); 86 throw new StatusException( "Couldn't create document", e ); 87 } 88 } 89 90 /** 91 * Disposes Spreadsheet document. 92 */ 93 protected void cleanup( TestParameters tParam, PrintWriter log ) { 94 log.println( " disposing xSheetDoc " ); 95 XComponent oComp = (XComponent) 96 UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ; 97 util.DesktopTools.closeDoc(oComp); 98 } 99 100 /** 101 * Creating a Testenvironment for the interfaces to be tested. 102 * Retrieves a collection of all drawpages in the document using the 103 * interface <code>XDrawPagesSupplier</code>. Creates and inserts two new 104 * drawPages into this collection. The retrieved collection is the instance 105 * of the service <code>com.sun.star.drawing.DrawPages</code>. 106 * @see com.sun.star.drawing.XDrawPagesSupplier 107 * @see com.sun.star.drawing.DrawPages 108 */ 109 public TestEnvironment createTestEnvironment( 110 TestParameters tParam, PrintWriter log) throws StatusException { 111 112 XInterface oObj = null; 113 XDrawPages oDP = null; 114 115 // creation of testobject here 116 // first we write what we are intend to do to log file 117 log.println( "creating a test environment" ); 118 119 // get the drawpage of drawing here 120 log.println( "getting Drawpages" ); 121 XDrawPagesSupplier oDPS = (XDrawPagesSupplier) 122 UnoRuntime.queryInterface(XDrawPagesSupplier.class, xSheetDoc); 123 oDP = (XDrawPages) oDPS.getDrawPages(); 124 oDP.insertNewByIndex(1); 125 oDP.insertNewByIndex(2); 126 oObj = oDP; 127 128 log.println( "creating a new environment for drawpage object" ); 129 TestEnvironment tEnv = new TestEnvironment( oObj ); 130 131 return tEnv; 132 } // finish method getTestEnvironment 133 134 } // finish class ScDrawPagesObj 135 136