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
.container
.XIndexAccess
;
30 import com
.sun
.star
.lang
.XComponent
;
31 import com
.sun
.star
.sheet
.XSpreadsheetDocument
;
32 import com
.sun
.star
.sheet
.XSpreadsheets
;
33 import com
.sun
.star
.uno
.UnoRuntime
;
34 import com
.sun
.star
.uno
.XInterface
;
35 import com
.sun
.star
.util
.XImportable
;
40 * @see com.sun.star.sheet.DatabaseImportDescriptor
43 public class ScImportDescriptorBase
extends TestCase
{
45 XSpreadsheetDocument xSpreadsheetDoc
;
48 * in general this method creates a testdocument
50 * @param tParam class which contains additional test parameters
51 * @param log class to log the test state and result
59 protected void initialize( TestParameters tParam
, PrintWriter log
) {
60 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
63 log
.println( "creating a Spreadsheet document" );
64 xSpreadsheetDoc
= SOF
.createCalcDoc(null);
65 } catch ( com
.sun
.star
.uno
.Exception e
) {
66 // Some exception occurs.FAILED
67 e
.printStackTrace( log
);
68 throw new StatusException( "Couldn't create document", e
);
74 * in general this method disposes the testenvironment and document
76 * @param tParam class which contains additional test parameters
77 * @param log class to log the test state and result
85 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
86 log
.println( " disposing xSheetDoc " );
87 XComponent oComp
= UnoRuntime
.queryInterface
88 (XComponent
.class, xSpreadsheetDoc
) ;
89 util
.DesktopTools
.closeDoc(oComp
);
95 * creating a Testenvironment for the interfaces to be tested
97 * @param tParam class which contains additional test parameters
98 * @param log class to log the test state and result
100 * @return Status class
102 * @see TestParameters
106 public TestEnvironment
createTestEnvironment( TestParameters tParam
,
108 throws StatusException
{
110 XInterface oObj
= null;
111 XImportable xIMP
= null;
113 // creation of testobject here
114 // first we write what we are intend to do to log file
115 log
.println( "creating a test environment" );
117 // create testobject here
119 log
.println("getting sheets");
120 XSpreadsheets xSpreadsheets
= xSpreadsheetDoc
.getSheets();
121 if (xSpreadsheets
== null) log
.println("FAILED"); else log
.println("OK");
123 log
.println("getting a sheet");
124 XIndexAccess oIndexAccess
= UnoRuntime
.queryInterface(XIndexAccess
.class, xSpreadsheets
);
127 oObj
= UnoRuntime
.queryInterface(XInterface
.class,oIndexAccess
.getByIndex(0));
128 } catch (Exception e
) {
129 throw new StatusException( "Couldn't get a spreadsheet", e
);
132 xIMP
= UnoRuntime
.queryInterface(XImportable
.class,oObj
);
134 TestEnvironment tEnv
= new TestEnvironment(oObj
);
135 tEnv
.addObjRelation("xIMP",xIMP
);
138 } // finish method getTestEnvironment
140 } // finish class ScImportDescriptorBase