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