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 .
19 package org
.openoffice
.test
.tools
;
21 import com
.sun
.star
.lang
.XMultiServiceFactory
;
22 import com
.sun
.star
.lang
.XComponent
;
23 import com
.sun
.star
.table
.XCellRange
;
24 import com
.sun
.star
.container
.XIndexAccess
;
25 import com
.sun
.star
.sheet
.XSpreadsheetDocument
;
26 import com
.sun
.star
.sheet
.XSpreadsheets
;
27 import com
.sun
.star
.uno
.UnoRuntime
;
29 public class SpreadsheetDocument
extends OfficeDocument
31 /** Creates a new blank spreadsheet document */
32 /* ------------------------------------------------------------------ */
33 public SpreadsheetDocument( XMultiServiceFactory orb
) throws com
.sun
.star
.uno
.Exception
35 super( orb
, implLoadAsComponent( orb
, "private:factory/scalc" ) );
38 /* ------------------------------------------------------------------ */
39 public SpreadsheetDocument( XMultiServiceFactory orb
, XComponent document
)
41 super( orb
, document
);
44 /* ------------------------------------------------------------------ */
45 /** returns the sheets collection
47 private XSpreadsheets
getSheets()
49 XSpreadsheetDocument spreadsheetDoc
= UnoRuntime
.queryInterface( XSpreadsheetDocument
.class, getDocument() );
50 return spreadsheetDoc
.getSheets();
53 /* ------------------------------------------------------------------ */
54 /** returns the sheet with the given index
56 public XCellRange
getSheet( int index
) throws com
.sun
.star
.uno
.Exception
58 XIndexAccess sheets
= UnoRuntime
.queryInterface( XIndexAccess
.class, getSheets() );
59 return UnoRuntime
.queryInterface( XCellRange
.class, sheets
.getByIndex( index
) );