1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 /* 24 * SpreadsheetView.java 25 * 26 * Created on 2. Oktober 2003, 14:02 27 */ 28 29 package integration.forms; 30 31 import com.sun.star.uno.*; 32 import com.sun.star.lang.*; 33 import com.sun.star.frame.*; 34 import com.sun.star.sheet.*; 35 import com.sun.star.container.*; 36 37 import integration.forms.DocumentViewHelper; 38 import integration.forms.DocumentHelper; 39 40 /** 41 * 42 * @author fs93730 43 */ 44 public class SpreadsheetView extends integration.forms.DocumentViewHelper 45 { 46 47 /** Creates a new instance of SpreadsheetView */ SpreadsheetView( XMultiServiceFactory orb, DocumentHelper document, XController controller )48 public SpreadsheetView( XMultiServiceFactory orb, DocumentHelper document, XController controller ) 49 { 50 super( orb, document, controller ); 51 } 52 53 /** activates the sheet with the given index 54 */ activateSheet( int sheetIndex )55 void activateSheet( int sheetIndex ) 56 { 57 try 58 { 59 // get the sheet to activate 60 XSpreadsheetDocument doc = (XSpreadsheetDocument)UnoRuntime.queryInterface( 61 XSpreadsheetDocument.class, getDocument().getDocument() ); 62 XIndexAccess sheets = (XIndexAccess)UnoRuntime.queryInterface( 63 XIndexAccess.class, doc.getSheets() ); 64 65 XSpreadsheet sheet = (XSpreadsheet)UnoRuntime.queryInterface( 66 XSpreadsheet.class, sheets.getByIndex( sheetIndex ) ); 67 68 // activate 69 XSpreadsheetView view = (XSpreadsheetView)UnoRuntime.queryInterface( 70 XSpreadsheetView.class, getController() ); 71 view.setActiveSheet( sheet ); 72 } 73 catch( com.sun.star.uno.Exception e ) 74 { 75 } 76 } 77 } 78