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
.sheet
.XSpreadsheetDocument
;
33 import com
.sun
.star
.uno
.UnoRuntime
;
34 import com
.sun
.star
.uno
.XInterface
;
37 * Test for object which is represented by service
38 * <code>com.sun.star.drawing.DrawPages</code>. <p>
39 * Object implements the following interfaces :
41 * <li> <code>com::sun::star::drawing::XDrawPageExpander</code></li>
42 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
43 * <li> <code>com::sun::star::drawing::XDrawPageSummarizer</code></li>
44 * <li> <code>com::sun::star::container::XElementAccess</code></li>
45 * <li> <code>com::sun::star::drawing::XDrawPages</code></li>
47 * @see com.sun.star.drawing.DrawPages
48 * @see com.sun.star.drawing.XDrawPageExpander
49 * @see com.sun.star.container.XIndexAccess
50 * @see com.sun.star.drawing.XDrawPageSummarizer
51 * @see com.sun.star.container.XElementAccess
52 * @see com.sun.star.drawing.XDrawPages
53 * @see ifc.drawing._XDrawPageExpander
54 * @see ifc.container._XIndexAccess
55 * @see ifc.drawing._XDrawPageSummarizer
56 * @see ifc.container._XElementAccess
57 * @see ifc.drawing._XDrawPages
59 public class ScDrawPagesObj
extends TestCase
{
60 private XSpreadsheetDocument xSheetDoc
= null;
63 * Creates Spreadsheet document.
66 protected void initialize( TestParameters tParam
, PrintWriter log
) {
68 // get a soffice factory object
69 SOfficeFactory SOF
= SOfficeFactory
.getFactory( 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.
85 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
86 log
.println( " disposing xSheetDoc " );
87 XComponent oComp
= UnoRuntime
.queryInterface (XComponent
.class, xSheetDoc
) ;
88 util
.DesktopTools
.closeDoc(oComp
);
92 * Creating a Testenvironment for the interfaces to be tested.
93 * Retrieves a collection of all drawpages in the document using the
94 * interface <code>XDrawPagesSupplier</code>. Creates and inserts two new
95 * drawPages into this collection. The retrieved collection is the instance
96 * of the service <code>com.sun.star.drawing.DrawPages</code>.
97 * @see com.sun.star.drawing.XDrawPagesSupplier
98 * @see com.sun.star.drawing.DrawPages
101 public TestEnvironment
createTestEnvironment(
102 TestParameters tParam
, PrintWriter log
) throws StatusException
{
104 XInterface oObj
= null;
105 XDrawPages oDP
= null;
107 // creation of testobject here
108 // first we write what we are intend to do to log file
109 log
.println( "creating a test environment" );
111 // get the drawpage of drawing here
112 log
.println( "getting Drawpages" );
113 XDrawPagesSupplier oDPS
= UnoRuntime
.queryInterface(XDrawPagesSupplier
.class, xSheetDoc
);
114 oDP
= oDPS
.getDrawPages();
115 oDP
.insertNewByIndex(1);
116 oDP
.insertNewByIndex(2);
119 log
.println( "creating a new environment for drawpage object" );
120 TestEnvironment tEnv
= new TestEnvironment( oObj
);
123 } // finish method getTestEnvironment
125 } // finish class ScDrawPagesObj