1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ScSortDescriptorBase.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import java
.io
.PrintWriter
;
35 import lib
.StatusException
;
37 import lib
.TestEnvironment
;
38 import lib
.TestParameters
;
39 import util
.SOfficeFactory
;
41 import com
.sun
.star
.container
.XIndexAccess
;
42 import com
.sun
.star
.lang
.XComponent
;
43 import com
.sun
.star
.lang
.XMultiServiceFactory
;
44 import com
.sun
.star
.sheet
.XSpreadsheetDocument
;
45 import com
.sun
.star
.sheet
.XSpreadsheets
;
46 import com
.sun
.star
.uno
.UnoRuntime
;
47 import com
.sun
.star
.uno
.XInterface
;
48 import com
.sun
.star
.util
.XSortable
;
54 * @see com.sun.star.beans.XPropertySet
55 * @see com.sun.star.sheet.SheetSortDescriptor
58 public class ScSortDescriptorBase
extends TestCase
{
60 static XSpreadsheetDocument xSpreadsheetDoc
;
63 * in general this method creates a testdocument
65 * @param tParam class which contains additional test parameters
66 * @param log class to log the test state and result
73 protected void initialize( TestParameters tParam
, PrintWriter log
) {
74 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
) tParam
.getMSF() );
77 log
.println( "creating a Spreadsheet document" );
78 xSpreadsheetDoc
= 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
);
88 * in general this method disposes the testenvironment and document
90 * @param tParam class which contains additional test parameters
91 * @param log class to log the test state and result
98 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
99 log
.println( " disposing xSheetDoc " );
100 XComponent oComp
= (XComponent
) UnoRuntime
.queryInterface
101 (XComponent
.class, xSpreadsheetDoc
) ;
102 util
.DesktopTools
.closeDoc(oComp
);
108 * creating a Testenvironment for the interfaces to be tested
110 * @param tParam class which contains additional test parameters
111 * @param log class to log the test state and result
113 * @return Status class
115 * @see TestParameters
118 public TestEnvironment
createTestEnvironment( TestParameters tParam
,
120 throws StatusException
{
122 XInterface oObj
= null;
123 XSortable xSORT
= null;
125 // creation of testobject here
126 // first we write what we are intend to do to log file
127 log
.println( "creating a test environment" );
129 // create testobject here
131 log
.println("getting sheets");
132 XSpreadsheets xSpreadsheets
= (XSpreadsheets
)xSpreadsheetDoc
.getSheets();
133 if (xSpreadsheets
== null) log
.println("FAILED"); else log
.println("OK");
135 log
.println("getting a sheet");
136 XIndexAccess oIndexAccess
= (XIndexAccess
)
137 UnoRuntime
.queryInterface(XIndexAccess
.class, xSpreadsheets
);
140 oObj
= (XInterface
) UnoRuntime
.queryInterface(XInterface
.class,oIndexAccess
.getByIndex(0));
141 } catch (Exception e
) {
142 throw new StatusException( "Couldn't get a spreadsheet", e
);
145 xSORT
= (XSortable
) UnoRuntime
.queryInterface(XSortable
.class,oObj
);
147 TestEnvironment tEnv
= new TestEnvironment(oObj
);
148 tEnv
.addObjRelation("xSORT",xSORT
);
151 } // finish method getTestEnvironment
153 } // finish class ScSortDescriptorBase