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
.XEnumerationAccess
;
30 import com
.sun
.star
.container
.XNameAccess
;
31 import com
.sun
.star
.lang
.XComponent
;
32 import com
.sun
.star
.lang
.XMultiServiceFactory
;
33 import com
.sun
.star
.sheet
.XSpreadsheet
;
34 import com
.sun
.star
.sheet
.XSpreadsheetDocument
;
35 import com
.sun
.star
.sheet
.XSpreadsheets
;
36 import com
.sun
.star
.table
.XColumnRowRange
;
37 import com
.sun
.star
.table
.XTableColumns
;
38 import com
.sun
.star
.uno
.AnyConverter
;
39 import com
.sun
.star
.uno
.Type
;
40 import com
.sun
.star
.uno
.UnoRuntime
;
41 import com
.sun
.star
.uno
.XInterface
;
43 public class ScIndexEnumeration_TableColumnsEnumeration
extends TestCase
{
44 private XSpreadsheetDocument xSheetDoc
= null;
47 * Creates Spreadsheet document.
49 protected void initialize( TestParameters tParam
, PrintWriter log
) {
50 // get a soffice factory object
51 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF());
54 log
.println( "creating a sheetdocument" );
55 xSheetDoc
= SOF
.createCalcDoc(null);
56 } catch (com
.sun
.star
.uno
.Exception e
) {
57 // Some exception occurs.FAILED
58 e
.printStackTrace( log
);
59 throw new StatusException( "Couldn't create document", e
);
64 * Disposes Spreadsheet document.
66 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
67 log
.println( " disposing xSheetDoc " );
68 XComponent oComp
= UnoRuntime
.queryInterface (XComponent
.class, xSheetDoc
) ;
69 util
.DesktopTools
.closeDoc(oComp
);
72 protected synchronized TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
74 XInterface oObj
= null;
76 // creation of the testobject here
77 // first we write what we are intend to do to log file
78 log
.println("craeting a test environment");
80 log
.println("getting column");
81 XSpreadsheets xSpreadsheets
= xSheetDoc
.getSheets();
82 XNameAccess oNames
= UnoRuntime
.queryInterface( XNameAccess
.class, xSpreadsheets
);
83 XSpreadsheet xSpreadsheet
= null;
85 xSpreadsheet
= (XSpreadsheet
) AnyConverter
.toObject(
86 new Type(XSpreadsheet
.class),
87 oNames
.getByName(oNames
.getElementNames()[0]));
88 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
89 e
.printStackTrace(log
);
90 throw new StatusException("Couldn't get spreadsheet", e
);
91 } catch (com
.sun
.star
.container
.NoSuchElementException e
) {
92 e
.printStackTrace(log
);
93 throw new StatusException("Couldn't get spreadsheet", e
);
94 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
95 e
.printStackTrace(log
);
96 throw new StatusException("Couldn't get spreadsheet", e
);
99 XColumnRowRange oColumnRowRange
= UnoRuntime
.queryInterface(XColumnRowRange
.class, xSpreadsheet
);
100 XTableColumns oColumns
= oColumnRowRange
.getColumns();
103 log
.println("creating a new environment for object");
104 XEnumerationAccess ea
= UnoRuntime
.queryInterface(XEnumerationAccess
.class,oObj
);
106 oObj
= ea
.createEnumeration();
108 log
.println("ImplementationName: "+util
.utils
.getImplName(oObj
));
109 // creating test environment
110 TestEnvironment tEnv
= new TestEnvironment( oObj
);
112 tEnv
.addObjRelation("ENUM",ea
);