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 import com.sun.star.uno.*;
30 import com.sun.star.lang.*;
31 import com.sun.star.frame.*;
32 import com.sun.star.sheet.*;
33 import com.sun.star.container.*;
34 
35 /**
36  *
37  * @author  fs93730
38  */
39 public class SpreadsheetView extends DocumentViewHelper
40 {
41 
42     /** Creates a new instance of SpreadsheetView */
SpreadsheetView( XMultiServiceFactory orb, DocumentHelper document, XController controller )43     public SpreadsheetView( XMultiServiceFactory orb, DocumentHelper document, XController controller )
44     {
45         super( orb, document, controller );
46     }
47 
48     /** activates the sheet with the given index
49      */
activateSheet( int sheetIndex )50     void activateSheet( int sheetIndex )
51     {
52         try
53         {
54             // get the sheet to activate
55             XSpreadsheetDocument doc = (XSpreadsheetDocument)UnoRuntime.queryInterface(
56                 XSpreadsheetDocument.class, getDocument().getDocument() );
57             XIndexAccess sheets = (XIndexAccess)UnoRuntime.queryInterface(
58                 XIndexAccess.class, doc.getSheets() );
59 
60             XSpreadsheet sheet = (XSpreadsheet)UnoRuntime.queryInterface(
61                 XSpreadsheet.class, sheets.getByIndex( sheetIndex ) );
62 
63             // activate
64             XSpreadsheetView view = (XSpreadsheetView)UnoRuntime.queryInterface(
65                 XSpreadsheetView.class, getController() );
66             view.setActiveSheet( sheet );
67         }
68         catch( com.sun.star.uno.Exception e )
69         {
70         }
71     }
72 }
73