1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  *  The Contents of this file are made available subject to the terms of
4*cdf0e10cSrcweir  *  the BSD license.
5*cdf0e10cSrcweir  *
6*cdf0e10cSrcweir  *  Copyright 2000, 2010 Oracle and/or its affiliates.
7*cdf0e10cSrcweir  *  All rights reserved.
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  *  Redistribution and use in source and binary forms, with or without
10*cdf0e10cSrcweir  *  modification, are permitted provided that the following conditions
11*cdf0e10cSrcweir  *  are met:
12*cdf0e10cSrcweir  *  1. Redistributions of source code must retain the above copyright
13*cdf0e10cSrcweir  *     notice, this list of conditions and the following disclaimer.
14*cdf0e10cSrcweir  *  2. Redistributions in binary form must reproduce the above copyright
15*cdf0e10cSrcweir  *     notice, this list of conditions and the following disclaimer in the
16*cdf0e10cSrcweir  *     documentation and/or other materials provided with the distribution.
17*cdf0e10cSrcweir  *  3. Neither the name of Sun Microsystems, Inc. nor the names of its
18*cdf0e10cSrcweir  *     contributors may be used to endorse or promote products derived
19*cdf0e10cSrcweir  *     from this software without specific prior written permission.
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22*cdf0e10cSrcweir  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23*cdf0e10cSrcweir  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24*cdf0e10cSrcweir  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25*cdf0e10cSrcweir  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26*cdf0e10cSrcweir  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27*cdf0e10cSrcweir  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28*cdf0e10cSrcweir  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29*cdf0e10cSrcweir  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30*cdf0e10cSrcweir  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31*cdf0e10cSrcweir  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*cdf0e10cSrcweir  *
33*cdf0e10cSrcweir  *************************************************************************/
34*cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
35*cdf0e10cSrcweir import com.sun.star.beans.XPropertySet;
36*cdf0e10cSrcweir import com.sun.star.uno.XComponentContext;
37*cdf0e10cSrcweir import com.sun.star.comp.helper.Bootstrap;
38*cdf0e10cSrcweir import com.sun.star.container.XEnumeration;
39*cdf0e10cSrcweir import com.sun.star.container.XEnumerationAccess;
40*cdf0e10cSrcweir import com.sun.star.frame.XComponentLoader;
41*cdf0e10cSrcweir import com.sun.star.frame.XController;
42*cdf0e10cSrcweir import com.sun.star.frame.XModel;
43*cdf0e10cSrcweir import com.sun.star.lang.XComponent;
44*cdf0e10cSrcweir import com.sun.star.lang.XMultiComponentFactory;
45*cdf0e10cSrcweir import com.sun.star.sheet.XCellAddressable;
46*cdf0e10cSrcweir import com.sun.star.sheet.XCellRangesQuery;
47*cdf0e10cSrcweir import com.sun.star.sheet.XSheetCellRanges;
48*cdf0e10cSrcweir import com.sun.star.sheet.XSpreadsheet;
49*cdf0e10cSrcweir import com.sun.star.sheet.XSpreadsheetDocument;
50*cdf0e10cSrcweir import com.sun.star.sheet.XSpreadsheetView;
51*cdf0e10cSrcweir import com.sun.star.sheet.XSpreadsheets;
52*cdf0e10cSrcweir import com.sun.star.table.XCell;
53*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir public class FirstLoadComponent {
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir     /** Creates a new instance of FirstLoadComponent */
58*cdf0e10cSrcweir     public FirstLoadComponent() {
59*cdf0e10cSrcweir     }
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir     /**
62*cdf0e10cSrcweir      * @param args the command line arguments
63*cdf0e10cSrcweir      */
64*cdf0e10cSrcweir     public static void main(String[] args) {
65*cdf0e10cSrcweir         try {
66*cdf0e10cSrcweir             // get the remote office component context
67*cdf0e10cSrcweir             XComponentContext xRemoteContext = Bootstrap.bootstrap();
68*cdf0e10cSrcweir             if (xRemoteContext == null) {
69*cdf0e10cSrcweir                 System.err.println("ERROR: Could not bootstrap default Office.");
70*cdf0e10cSrcweir             }
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir             XMultiComponentFactory xRemoteServiceManager = xRemoteContext.getServiceManager();
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir             Object desktop = xRemoteServiceManager.createInstanceWithContext(
75*cdf0e10cSrcweir                 "com.sun.star.frame.Desktop", xRemoteContext);
76*cdf0e10cSrcweir             XComponentLoader xComponentLoader = (XComponentLoader)
77*cdf0e10cSrcweir                 UnoRuntime.queryInterface(XComponentLoader.class, desktop);
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir             PropertyValue[] loadProps = new PropertyValue[0];
80*cdf0e10cSrcweir             XComponent xSpreadsheetComponent = xComponentLoader.loadComponentFromURL("private:factory/scalc", "_blank", 0, loadProps);
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir             XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument)
83*cdf0e10cSrcweir                 UnoRuntime.queryInterface(XSpreadsheetDocument.class,
84*cdf0e10cSrcweir                                           xSpreadsheetComponent);
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir             XSpreadsheets xSpreadsheets = xSpreadsheetDocument.getSheets();
87*cdf0e10cSrcweir             xSpreadsheets.insertNewByName("MySheet", (short)0);
88*cdf0e10cSrcweir             com.sun.star.uno.Type elemType = xSpreadsheets.getElementType();
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir             System.out.println(elemType.getTypeName());
91*cdf0e10cSrcweir             Object sheet = xSpreadsheets.getByName("MySheet");
92*cdf0e10cSrcweir             XSpreadsheet xSpreadsheet = (XSpreadsheet)UnoRuntime.queryInterface(
93*cdf0e10cSrcweir                 XSpreadsheet.class, sheet);
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir             XCell xCell = xSpreadsheet.getCellByPosition(0, 0);
96*cdf0e10cSrcweir             xCell.setValue(21);
97*cdf0e10cSrcweir             xCell = xSpreadsheet.getCellByPosition(0, 1);
98*cdf0e10cSrcweir             xCell.setValue(21);
99*cdf0e10cSrcweir             xCell = xSpreadsheet.getCellByPosition(0, 2);
100*cdf0e10cSrcweir             xCell.setFormula("=sum(A1:A2)");
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir             XPropertySet xCellProps = (XPropertySet)UnoRuntime.queryInterface(
103*cdf0e10cSrcweir                 XPropertySet.class, xCell);
104*cdf0e10cSrcweir             xCellProps.setPropertyValue("CellStyle", "Result");
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir             XModel xSpreadsheetModel = (XModel)UnoRuntime.queryInterface(
107*cdf0e10cSrcweir                 XModel.class, xSpreadsheetComponent);
108*cdf0e10cSrcweir             XController xSpreadsheetController = xSpreadsheetModel.getCurrentController();
109*cdf0e10cSrcweir             XSpreadsheetView xSpreadsheetView = (XSpreadsheetView)
110*cdf0e10cSrcweir                 UnoRuntime.queryInterface(XSpreadsheetView.class,
111*cdf0e10cSrcweir                                           xSpreadsheetController);
112*cdf0e10cSrcweir             xSpreadsheetView.setActiveSheet(xSpreadsheet);
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir             // *********************************************************
115*cdf0e10cSrcweir             // example for use of enum types
116*cdf0e10cSrcweir             xCellProps.setPropertyValue("VertJustify",
117*cdf0e10cSrcweir                                         com.sun.star.table.CellVertJustify.TOP);
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir             // *********************************************************
121*cdf0e10cSrcweir             // example for a sequence of PropertyValue structs
122*cdf0e10cSrcweir             // create an array with one PropertyValue struct, it contains
123*cdf0e10cSrcweir             // references only
124*cdf0e10cSrcweir             loadProps = new PropertyValue[1];
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir             // instantiate PropertyValue struct and set its member fields
127*cdf0e10cSrcweir             PropertyValue asTemplate = new PropertyValue();
128*cdf0e10cSrcweir             asTemplate.Name = "AsTemplate";
129*cdf0e10cSrcweir             asTemplate.Value = new Boolean(true);
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir             // assign PropertyValue struct to array of references for PropertyValue
132*cdf0e10cSrcweir             // structs
133*cdf0e10cSrcweir             loadProps[0] = asTemplate;
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir             // load calc file as template
136*cdf0e10cSrcweir             //xSpreadsheetComponent = xComponentLoader.loadComponentFromURL(
137*cdf0e10cSrcweir             //    "file:///c:/temp/DataAnalysys.ods", "_blank", 0, loadProps);
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir             // *********************************************************
140*cdf0e10cSrcweir             // example for use of XEnumerationAccess
141*cdf0e10cSrcweir             XCellRangesQuery xCellQuery = (XCellRangesQuery)
142*cdf0e10cSrcweir                 UnoRuntime.queryInterface(XCellRangesQuery.class, sheet);
143*cdf0e10cSrcweir             XSheetCellRanges xFormulaCells = xCellQuery.queryContentCells(
144*cdf0e10cSrcweir                 (short)com.sun.star.sheet.CellFlags.FORMULA);
145*cdf0e10cSrcweir             XEnumerationAccess xFormulas = xFormulaCells.getCells();
146*cdf0e10cSrcweir             XEnumeration xFormulaEnum = xFormulas.createEnumeration();
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir             while (xFormulaEnum.hasMoreElements()) {
149*cdf0e10cSrcweir                 Object formulaCell = xFormulaEnum.nextElement();
150*cdf0e10cSrcweir                 xCell = (XCell)UnoRuntime.queryInterface(XCell.class, formulaCell);
151*cdf0e10cSrcweir                 XCellAddressable xCellAddress = (XCellAddressable)
152*cdf0e10cSrcweir                     UnoRuntime.queryInterface(XCellAddressable.class, xCell);
153*cdf0e10cSrcweir                 System.out.println("Formula cell in column " +
154*cdf0e10cSrcweir                                    xCellAddress.getCellAddress().Column
155*cdf0e10cSrcweir                                    + ", row " + xCellAddress.getCellAddress().Row
156*cdf0e10cSrcweir                                    + " contains " + xCell.getFormula());
157*cdf0e10cSrcweir             }
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir         }
160*cdf0e10cSrcweir         catch (java.lang.Exception e){
161*cdf0e10cSrcweir             e.printStackTrace();
162*cdf0e10cSrcweir         }
163*cdf0e10cSrcweir         finally {
164*cdf0e10cSrcweir             System.exit( 0 );
165*cdf0e10cSrcweir         }
166*cdf0e10cSrcweir     }
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir // import com.sun.star.uno.UnoRuntime;
172*cdf0e10cSrcweir // import com.sun.star.uno.XComponentContext;
173*cdf0e10cSrcweir // import com.sun.star.lang.XMultiComponentFactory;
174*cdf0e10cSrcweir // import com.sun.star.lang.XComponent;
175*cdf0e10cSrcweir // import com.sun.star.beans.XPropertySet;
176*cdf0e10cSrcweir // import com.sun.star.beans.PropertyValue;
177*cdf0e10cSrcweir // import com.sun.star.sheet.XSpreadsheetDocument;
178*cdf0e10cSrcweir // import com.sun.star.sheet.XSpreadsheets;
179*cdf0e10cSrcweir // import com.sun.star.sheet.XSpreadsheet;
180*cdf0e10cSrcweir // import com.sun.star.sheet.XSpreadsheetView;
181*cdf0e10cSrcweir // import com.sun.star.sheet.XCellRangesQuery;
182*cdf0e10cSrcweir // import com.sun.star.sheet.XSheetCellRanges;
183*cdf0e10cSrcweir // import com.sun.star.sheet.XCellAddressable;
184*cdf0e10cSrcweir // import com.sun.star.table.XCell;
185*cdf0e10cSrcweir // import com.sun.star.frame.XModel;
186*cdf0e10cSrcweir // import com.sun.star.frame.XController;
187*cdf0e10cSrcweir // import com.sun.star.frame.XComponentLoader;
188*cdf0e10cSrcweir // import com.sun.star.container.XEnumeration;
189*cdf0e10cSrcweir // import com.sun.star.container.XEnumerationAccess;
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir // import com.sun.star.uno.AnyConverter;
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir // /**
195*cdf0e10cSrcweir //  *
196*cdf0e10cSrcweir //  * @author  dschulten
197*cdf0e10cSrcweir //  */
198*cdf0e10cSrcweir // public class FirstLoadComponent {
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir //     /** Creates a new instance of FirstLoadComponent */
201*cdf0e10cSrcweir //     public FirstLoadComponent() {
202*cdf0e10cSrcweir //     }
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir //     /**
205*cdf0e10cSrcweir //      * @param args the command line arguments
206*cdf0e10cSrcweir //      */
207*cdf0e10cSrcweir //     private XComponentContext xRemoteContext = null;
208*cdf0e10cSrcweir //     private XMultiComponentFactory xRemoteServiceManager = null;
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir //     public static void main(String[] args) {
211*cdf0e10cSrcweir //         FirstLoadComponent firstLoadComponent1 = new FirstLoadComponent();
212*cdf0e10cSrcweir //         try {
213*cdf0e10cSrcweir //             firstLoadComponent1.useConnection();
214*cdf0e10cSrcweir //         }
215*cdf0e10cSrcweir //         catch (java.lang.Exception e){
216*cdf0e10cSrcweir //             System.out.println(e.getMessage());
217*cdf0e10cSrcweir //             e.printStackTrace();
218*cdf0e10cSrcweir //         }
219*cdf0e10cSrcweir //         finally {
220*cdf0e10cSrcweir //             System.exit(0);
221*cdf0e10cSrcweir //         }
222*cdf0e10cSrcweir //     }
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir //     private void useConnection() throws java.lang.Exception {
225*cdf0e10cSrcweir //         try {
226*cdf0e10cSrcweir //             // get the remote office component context
227*cdf0e10cSrcweir //             xRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
228*cdf0e10cSrcweir //             System.out.println("Connected to a running office ...");
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir //             xRemoteServiceManager = xRemoteContext.getServiceManager();
231*cdf0e10cSrcweir //         }
232*cdf0e10cSrcweir //         catch( Exception e) {
233*cdf0e10cSrcweir //             e.printStackTrace();
234*cdf0e10cSrcweir //             System.exit(1);
235*cdf0e10cSrcweir //         }
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir //         try {
238*cdf0e10cSrcweir //             Object desktop = xRemoteServiceManager.createInstanceWithContext(
239*cdf0e10cSrcweir //                 "com.sun.star.frame.Desktop", xRemoteContext);
240*cdf0e10cSrcweir //             XComponentLoader xComponentLoader = (XComponentLoader)
241*cdf0e10cSrcweir //                 UnoRuntime.queryInterface(XComponentLoader.class, desktop);
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir //             PropertyValue[] loadProps = new PropertyValue[0];
244*cdf0e10cSrcweir //             XComponent xSpreadsheetComponent = xComponentLoader.loadComponentFromURL("private:factory/scalc", "_blank", 0, loadProps);
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir //             XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument)
247*cdf0e10cSrcweir //                 UnoRuntime.queryInterface(XSpreadsheetDocument.class,
248*cdf0e10cSrcweir //                                           xSpreadsheetComponent);
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir //             XSpreadsheets xSpreadsheets = xSpreadsheetDocument.getSheets();
251*cdf0e10cSrcweir //             xSpreadsheets.insertNewByName("MySheet", (short)0);
252*cdf0e10cSrcweir //             com.sun.star.uno.Type elemType = xSpreadsheets.getElementType();
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir //             System.out.println(elemType.getTypeName());
255*cdf0e10cSrcweir //             Object sheet = xSpreadsheets.getByName("MySheet");
256*cdf0e10cSrcweir //             XSpreadsheet xSpreadsheet = (XSpreadsheet)UnoRuntime.queryInterface(
257*cdf0e10cSrcweir //                 XSpreadsheet.class, sheet);
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir //             XCell xCell = xSpreadsheet.getCellByPosition(0, 0);
260*cdf0e10cSrcweir //             xCell.setValue(21);
261*cdf0e10cSrcweir //             xCell = xSpreadsheet.getCellByPosition(0, 1);
262*cdf0e10cSrcweir //             xCell.setValue(21);
263*cdf0e10cSrcweir //             xCell = xSpreadsheet.getCellByPosition(0, 2);
264*cdf0e10cSrcweir //             xCell.setFormula("=sum(A1:A2)");
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir //             XPropertySet xCellProps = (XPropertySet)UnoRuntime.queryInterface(
267*cdf0e10cSrcweir //                 XPropertySet.class, xCell);
268*cdf0e10cSrcweir //             xCellProps.setPropertyValue("CellStyle", "Result");
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir //             XModel xSpreadsheetModel = (XModel)UnoRuntime.queryInterface(
271*cdf0e10cSrcweir //                 XModel.class, xSpreadsheetComponent);
272*cdf0e10cSrcweir //             XController xSpreadsheetController = xSpreadsheetModel.getCurrentController();
273*cdf0e10cSrcweir //             XSpreadsheetView xSpreadsheetView = (XSpreadsheetView)
274*cdf0e10cSrcweir //                 UnoRuntime.queryInterface(XSpreadsheetView.class,
275*cdf0e10cSrcweir //                                           xSpreadsheetController);
276*cdf0e10cSrcweir //             xSpreadsheetView.setActiveSheet(xSpreadsheet);
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir //             // *********************************************************
279*cdf0e10cSrcweir //             // example for use of enum types
280*cdf0e10cSrcweir //             xCellProps.setPropertyValue("VertJustify",
281*cdf0e10cSrcweir //                                         com.sun.star.table.CellVertJustify.TOP);
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir //             // *********************************************************
285*cdf0e10cSrcweir //             // example for a sequence of PropertyValue structs
286*cdf0e10cSrcweir //             // create an array with one PropertyValue struct, it contains
287*cdf0e10cSrcweir //             // references only
288*cdf0e10cSrcweir //             loadProps = new PropertyValue[1];
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir //             // instantiate PropertyValue struct and set its member fields
291*cdf0e10cSrcweir //             PropertyValue asTemplate = new PropertyValue();
292*cdf0e10cSrcweir //             asTemplate.Name = "AsTemplate";
293*cdf0e10cSrcweir //             asTemplate.Value = new Boolean(true);
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir //             // assign PropertyValue struct to array of references for PropertyValue
296*cdf0e10cSrcweir //             // structs
297*cdf0e10cSrcweir //             loadProps[0] = asTemplate;
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir //             // load calc file as template
300*cdf0e10cSrcweir //             //xSpreadsheetComponent = xComponentLoader.loadComponentFromURL(
301*cdf0e10cSrcweir //             //    "file:///c:/temp/DataAnalysys.ods", "_blank", 0, loadProps);
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir //             // *********************************************************
304*cdf0e10cSrcweir //             // example for use of XEnumerationAccess
305*cdf0e10cSrcweir //             XCellRangesQuery xCellQuery = (XCellRangesQuery)
306*cdf0e10cSrcweir //                 UnoRuntime.queryInterface(XCellRangesQuery.class, sheet);
307*cdf0e10cSrcweir //             XSheetCellRanges xFormulaCells = xCellQuery.queryContentCells(
308*cdf0e10cSrcweir //                 (short)com.sun.star.sheet.CellFlags.FORMULA);
309*cdf0e10cSrcweir //             XEnumerationAccess xFormulas = xFormulaCells.getCells();
310*cdf0e10cSrcweir //             XEnumeration xFormulaEnum = xFormulas.createEnumeration();
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir //             while (xFormulaEnum.hasMoreElements()) {
313*cdf0e10cSrcweir //                 Object formulaCell = xFormulaEnum.nextElement();
314*cdf0e10cSrcweir //                 xCell = (XCell)UnoRuntime.queryInterface(XCell.class, formulaCell);
315*cdf0e10cSrcweir //                 XCellAddressable xCellAddress = (XCellAddressable)
316*cdf0e10cSrcweir //                     UnoRuntime.queryInterface(XCellAddressable.class, xCell);
317*cdf0e10cSrcweir //                 System.out.println("Formula cell in column " +
318*cdf0e10cSrcweir //                                    xCellAddress.getCellAddress().Column
319*cdf0e10cSrcweir //                                    + ", row " + xCellAddress.getCellAddress().Row
320*cdf0e10cSrcweir //                                    + " contains " + xCell.getFormula());
321*cdf0e10cSrcweir //             }
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir //         }
324*cdf0e10cSrcweir //         catch( com.sun.star.lang.DisposedException e ) { //works from Patch 1
325*cdf0e10cSrcweir //             xRemoteContext = null;
326*cdf0e10cSrcweir //             throw e;
327*cdf0e10cSrcweir //         }
328*cdf0e10cSrcweir //     }
329*cdf0e10cSrcweir // }
330