1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package mod._sc; 25 26 import java.io.PrintWriter; 27 28 import lib.StatusException; 29 import lib.TestCase; 30 import lib.TestEnvironment; 31 import lib.TestParameters; 32 import util.SOfficeFactory; 33 34 import com.sun.star.drawing.XDrawPages; 35 import com.sun.star.drawing.XDrawPagesSupplier; 36 import com.sun.star.lang.XComponent; 37 import com.sun.star.lang.XMultiServiceFactory; 38 import com.sun.star.sheet.XSpreadsheetDocument; 39 import com.sun.star.uno.UnoRuntime; 40 import com.sun.star.uno.XInterface; 41 42 /** 43 * Test for object which is represented by service 44 * <code>com.sun.star.drawing.DrawPages</code>. <p> 45 * Object implements the following interfaces : 46 * <ul> 47 * <li> <code>com::sun::star::drawing::XDrawPageExpander</code></li> 48 * <li> <code>com::sun::star::container::XIndexAccess</code></li> 49 * <li> <code>com::sun::star::drawing::XDrawPageSummarizer</code></li> 50 * <li> <code>com::sun::star::container::XElementAccess</code></li> 51 * <li> <code>com::sun::star::drawing::XDrawPages</code></li> 52 * </ul> 53 * @see com.sun.star.drawing.DrawPages 54 * @see com.sun.star.drawing.XDrawPageExpander 55 * @see com.sun.star.container.XIndexAccess 56 * @see com.sun.star.drawing.XDrawPageSummarizer 57 * @see com.sun.star.container.XElementAccess 58 * @see com.sun.star.drawing.XDrawPages 59 * @see ifc.drawing._XDrawPageExpander 60 * @see ifc.container._XIndexAccess 61 * @see ifc.drawing._XDrawPageSummarizer 62 * @see ifc.container._XElementAccess 63 * @see ifc.drawing._XDrawPages 64 */ 65 public class ScDrawPagesObj extends TestCase { 66 static XSpreadsheetDocument xSheetDoc = null; 67 68 /** 69 * Creates Spreadsheet document. 70 */ initialize( TestParameters tParam, PrintWriter log )71 protected void initialize( TestParameters tParam, PrintWriter log ) { 72 73 // get a soffice factory object 74 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); 75 76 try { 77 log.println( "creating a sheetdocument" ); 78 xSheetDoc = SOF.createCalcDoc(null); 79 } catch (com.sun.star.uno.Exception e) { 80 // Some exception occures.FAILED 81 e.printStackTrace( log ); 82 throw new StatusException( "Couldn't create document", e ); 83 } 84 } 85 86 /** 87 * Disposes Spreadsheet document. 88 */ cleanup( TestParameters tParam, PrintWriter log )89 protected void cleanup( TestParameters tParam, PrintWriter log ) { 90 log.println( " disposing xSheetDoc " ); 91 XComponent oComp = (XComponent) 92 UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ; 93 util.DesktopTools.closeDoc(oComp); 94 } 95 96 /** 97 * Creating a Testenvironment for the interfaces to be tested. 98 * Retrieves a collection of all drawpages in the document using the 99 * interface <code>XDrawPagesSupplier</code>. Creates and inserts two new 100 * drawPages into this collection. The retrieved collection is the instance 101 * of the service <code>com.sun.star.drawing.DrawPages</code>. 102 * @see com.sun.star.drawing.XDrawPagesSupplier 103 * @see com.sun.star.drawing.DrawPages 104 */ createTestEnvironment( TestParameters tParam, PrintWriter log)105 public TestEnvironment createTestEnvironment( 106 TestParameters tParam, PrintWriter log) throws StatusException { 107 108 XInterface oObj = null; 109 XDrawPages oDP = null; 110 111 // creation of testobject here 112 // first we write what we are intend to do to log file 113 log.println( "creating a test environment" ); 114 115 // get the drawpage of drawing here 116 log.println( "getting Drawpages" ); 117 XDrawPagesSupplier oDPS = (XDrawPagesSupplier) 118 UnoRuntime.queryInterface(XDrawPagesSupplier.class, xSheetDoc); 119 oDP = (XDrawPages) oDPS.getDrawPages(); 120 oDP.insertNewByIndex(1); 121 oDP.insertNewByIndex(2); 122 oObj = oDP; 123 124 log.println( "creating a new environment for drawpage object" ); 125 TestEnvironment tEnv = new TestEnvironment( oObj ); 126 127 return tEnv; 128 } // finish method getTestEnvironment 129 130 } // finish class ScDrawPagesObj 131 132