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: ScIndexEnumeration_SpreadsheetViewPanesEnumeration.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
.XEnumerationAccess
;
42 import com
.sun
.star
.container
.XIndexAccess
;
43 import com
.sun
.star
.frame
.XController
;
44 import com
.sun
.star
.frame
.XModel
;
45 import com
.sun
.star
.lang
.XComponent
;
46 import com
.sun
.star
.lang
.XMultiServiceFactory
;
47 import com
.sun
.star
.sheet
.XSpreadsheetDocument
;
48 import com
.sun
.star
.uno
.AnyConverter
;
49 import com
.sun
.star
.uno
.Type
;
50 import com
.sun
.star
.uno
.UnoRuntime
;
51 import com
.sun
.star
.uno
.XInterface
;
53 public class ScIndexEnumeration_SpreadsheetViewPanesEnumeration
extends TestCase
{
54 private static XSpreadsheetDocument xSpreadsheetDoc
;
55 private static SOfficeFactory SOF
;
56 private static XInterface oObj
;
59 * Creates Spreadsheet document.
61 public void initialize( TestParameters Param
, PrintWriter log
) {
62 // get a soffice factory object
63 SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)Param
.getMSF());
66 log
.println("creating a spreadsheetdocument");
67 xSpreadsheetDoc
= SOF
.createCalcDoc(null);
68 } catch (com
.sun
.star
.uno
.Exception e
) {
69 e
.printStackTrace( log
);
70 throw new StatusException( "Couldn't create document ", e
);
75 * Disposes Spreadsheet document.
77 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
78 log
.println("disposing xSpreadsheetDocument");
79 XComponent oComp
= (XComponent
)
80 UnoRuntime
.queryInterface(XComponent
.class, xSpreadsheetDoc
);
81 util
.DesktopTools
.closeDoc(oComp
);
84 protected TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
87 UnoRuntime
.queryInterface(XModel
.class, xSpreadsheetDoc
);
88 XController xc
= xm
.getCurrentController();
89 XIndexAccess xIA
= (XIndexAccess
)
90 UnoRuntime
.queryInterface(XIndexAccess
.class, xc
);
92 oObj
= (XInterface
) AnyConverter
.toObject(
93 new Type(XInterface
.class),xIA
.getByIndex(0));
94 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
95 e
.printStackTrace(log
);
96 throw new StatusException("Couldn't get by index", e
);
97 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
98 e
.printStackTrace(log
);
99 throw new StatusException("Couldn't get by index", e
);
100 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
101 e
.printStackTrace(log
);
102 throw new StatusException("Couldn't get by index", e
);
105 XEnumerationAccess ea
= (XEnumerationAccess
)
106 UnoRuntime
.queryInterface(XEnumerationAccess
.class,xIA
);
108 oObj
= ea
.createEnumeration();
110 log
.println("ImplementationName: "+util
.utils
.getImplName(oObj
));
111 // creating test environment
112 TestEnvironment tEnv
= new TestEnvironment( oObj
);
114 tEnv
.addObjRelation("ENUM",ea
);