1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: version.cs,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 using unoidl
.com
.sun
.star
.lang
;
33 using unoidl
.com
.sun
.star
.uno
;
34 using unoidl
.com
.sun
.star
.frame
;
35 using unoidl
.com
.sun
.star
.util
;
45 // System.Diagnostics.Debugger.Launch();
47 //link with cli_ure.dll
48 uno
.util
.WeakBase wb
= new uno
.util
.WeakBase();
49 using ( SpreadsheetSample aSample
= new SpreadsheetSample() )
51 aSample
.doCellRangeSamples();
55 catch (System
.Exception
)
57 //This exception is thrown if we link with a library which is not
64 class SpreadsheetSample
: SpreadsheetDocHelper
66 public SpreadsheetSample()
69 /** All samples regarding the service com.sun.star.sheet.SheetCellRange. */
70 public void doCellRangeSamples()
72 unoidl
.com
.sun
.star
.sheet
.XSpreadsheet xSheet
= getSpreadsheet( 0 );
73 unoidl
.com
.sun
.star
.table
.XCellRange xCellRange
= null;
74 unoidl
.com
.sun
.star
.beans
.XPropertySet xPropSet
= null;
75 unoidl
.com
.sun
.star
.table
.CellRangeAddress aRangeAddress
= null;
78 setFormula( xSheet
, "B5", "First cell" );
79 setFormula( xSheet
, "B6", "Second cell" );
80 // Get cell range B5:B6 by position - (column, row, column, row)
81 xCellRange
= xSheet
.getCellRangeByPosition( 1, 4, 1, 5 );
84 // --- Change cell range properties. ---
85 xPropSet
= (unoidl
.com
.sun
.star
.beans
.XPropertySet
) xCellRange
;
86 // from com.sun.star.styles.CharacterProperties
87 xPropSet
.setPropertyValue(
88 "CharColor", new uno
.Any( (Int32
) 0x003399 ) );
89 xPropSet
.setPropertyValue(
90 "CharHeight", new uno
.Any( (Single
) 20.0 ) );
91 // from com.sun.star.styles.ParagraphProperties
92 xPropSet
.setPropertyValue(
93 "ParaLeftMargin", new uno
.Any( (Int32
) 500 ) );
94 // from com.sun.star.table.CellProperties
95 xPropSet
.setPropertyValue(
96 "IsCellBackgroundTransparent", new uno
.Any( false ) );
97 xPropSet
.setPropertyValue(
98 "CellBackColor", new uno
.Any( (Int32
) 0x99CCFF ) );
101 // --- Replace text in all cells. ---
102 unoidl
.com
.sun
.star
.util
.XReplaceable xReplace
=
103 (unoidl
.com
.sun
.star
.util
.XReplaceable
) xCellRange
;
104 unoidl
.com
.sun
.star
.util
.XReplaceDescriptor xReplaceDesc
=
105 xReplace
.createReplaceDescriptor();
106 xReplaceDesc
.setSearchString( "cell" );
107 xReplaceDesc
.setReplaceString( "text" );
108 // property SearchWords searches for whole cells!
109 xReplaceDesc
.setPropertyValue( "SearchWords", new uno
.Any( false ) );
110 int nCount
= xReplace
.replaceAll( xReplaceDesc
);
112 // --- Merge cells. ---
113 xCellRange
= xSheet
.getCellRangeByName( "F3:G6" );
114 prepareRange( xSheet
, "E1:H7", "XMergeable" );
115 unoidl
.com
.sun
.star
.util
.XMergeable xMerge
=
116 (unoidl
.com
.sun
.star
.util
.XMergeable
) xCellRange
;
117 xMerge
.merge( true );
120 // --- Column properties. ---
121 xCellRange
= xSheet
.getCellRangeByName( "B1" );
122 unoidl
.com
.sun
.star
.table
.XColumnRowRange xColRowRange
=
123 (unoidl
.com
.sun
.star
.table
.XColumnRowRange
) xCellRange
;
124 unoidl
.com
.sun
.star
.table
.XTableColumns xColumns
=
125 xColRowRange
.getColumns();
127 uno
.Any aColumnObj
= xColumns
.getByIndex( 0 );
128 xPropSet
= (unoidl
.com
.sun
.star
.beans
.XPropertySet
) aColumnObj
.Value
;
129 xPropSet
.setPropertyValue( "Width", new uno
.Any( (Int32
) 6000 ) );
131 unoidl
.com
.sun
.star
.container
.XNamed xNamed
=
132 (unoidl
.com
.sun
.star
.container
.XNamed
) aColumnObj
.Value
;
134 // --- Cell range data ---
135 prepareRange( xSheet
, "A9:C30", "XCellRangeData" );
137 xCellRange
= xSheet
.getCellRangeByName( "A10:C30" );
138 unoidl
.com
.sun
.star
.sheet
.XCellRangeData xData
=
139 (unoidl
.com
.sun
.star
.sheet
.XCellRangeData
) xCellRange
;
140 uno
.Any
[][] aValues
=
142 new uno
.Any
[] { new uno
.Any( "Name" ),
143 new uno
.Any( "Fruit" ),
144 new uno
.Any( "Quantity" ) },
145 new uno
.Any
[] { new uno
.Any( "Alice" ),
146 new uno
.Any( "Apples" ),
147 new uno
.Any( (Double
) 3.0 ) },
148 new uno
.Any
[] { new uno
.Any( "Alice" ),
149 new uno
.Any( "Oranges" ),
150 new uno
.Any( (Double
) 7.0 ) },
151 new uno
.Any
[] { new uno
.Any( "Bob" ),
152 new uno
.Any( "Apples" ),
153 new uno
.Any( (Double
) 3.0 ) },
154 new uno
.Any
[] { new uno
.Any( "Alice" ),
155 new uno
.Any( "Apples" ),
156 new uno
.Any( (Double
) 9.0 ) },
157 new uno
.Any
[] { new uno
.Any( "Bob" ),
158 new uno
.Any( "Apples" ),
159 new uno
.Any( (Double
) 5.0 ) },
160 new uno
.Any
[] { new uno
.Any( "Bob" ),
161 new uno
.Any( "Oranges" ),
162 new uno
.Any( (Double
) 6.0 ) },
163 new uno
.Any
[] { new uno
.Any( "Alice" ),
164 new uno
.Any( "Oranges" ),
165 new uno
.Any( (Double
) 3.0 ) },
166 new uno
.Any
[] { new uno
.Any( "Alice" ),
167 new uno
.Any( "Apples" ),
168 new uno
.Any( (Double
) 8.0 ) },
169 new uno
.Any
[] { new uno
.Any( "Alice" ),
170 new uno
.Any( "Oranges" ),
171 new uno
.Any( (Double
) 1.0 ) },
172 new uno
.Any
[] { new uno
.Any( "Bob" ),
173 new uno
.Any( "Oranges" ),
174 new uno
.Any( (Double
) 2.0 ) },
175 new uno
.Any
[] { new uno
.Any( "Bob" ),
176 new uno
.Any( "Oranges" ),
177 new uno
.Any( (Double
) 7.0 ) },
178 new uno
.Any
[] { new uno
.Any( "Bob" ),
179 new uno
.Any( "Apples" ),
180 new uno
.Any( (Double
) 1.0 ) },
181 new uno
.Any
[] { new uno
.Any( "Alice" ),
182 new uno
.Any( "Apples" ),
183 new uno
.Any( (Double
) 8.0 ) },
184 new uno
.Any
[] { new uno
.Any( "Alice" ),
185 new uno
.Any( "Oranges" ),
186 new uno
.Any( (Double
) 8.0 ) },
187 new uno
.Any
[] { new uno
.Any( "Alice" ),
188 new uno
.Any( "Apples" ),
189 new uno
.Any( (Double
) 7.0 ) },
190 new uno
.Any
[] { new uno
.Any( "Bob" ),
191 new uno
.Any( "Apples" ),
192 new uno
.Any( (Double
) 1.0 ) },
193 new uno
.Any
[] { new uno
.Any( "Bob" ),
194 new uno
.Any( "Oranges" ),
195 new uno
.Any( (Double
) 9.0 ) },
196 new uno
.Any
[] { new uno
.Any( "Bob" ),
197 new uno
.Any( "Oranges" ),
198 new uno
.Any( (Double
) 3.0 ) },
199 new uno
.Any
[] { new uno
.Any( "Alice" ),
200 new uno
.Any( "Oranges" ),
201 new uno
.Any( (Double
) 4.0 ) },
202 new uno
.Any
[] { new uno
.Any( "Alice" ),
203 new uno
.Any( "Apples" ),
204 new uno
.Any( (Double
) 9.0 ) }
206 xData
.setDataArray( aValues
);
209 // --- Get cell range address. ---
210 unoidl
.com
.sun
.star
.sheet
.XCellRangeAddressable xRangeAddr
=
211 (unoidl
.com
.sun
.star
.sheet
.XCellRangeAddressable
) xCellRange
;
212 aRangeAddress
= xRangeAddr
.getRangeAddress();
214 // --- Sheet operation. ---
215 // uses the range filled with XCellRangeData
216 unoidl
.com
.sun
.star
.sheet
.XSheetOperation xSheetOp
=
217 (unoidl
.com
.sun
.star
.sheet
.XSheetOperation
) xData
;
218 double fResult
= xSheetOp
.computeFunction(
219 unoidl
.com
.sun
.star
.sheet
.GeneralFunction
.AVERAGE
);
221 // --- Fill series ---
222 // Prepare the example
223 setValue( xSheet
, "E10", 1 );
224 setValue( xSheet
, "E11", 4 );
225 setDate( xSheet
, "E12", 30, 1, 2002 );
226 setFormula( xSheet
, "I13", "Text 10" );
227 setFormula( xSheet
, "E14", "Jan" );
228 setValue( xSheet
, "K14", 10 );
229 setValue( xSheet
, "E16", 1 );
230 setValue( xSheet
, "F16", 2 );
231 setDate( xSheet
, "E17", 28, 2, 2002 );
232 setDate( xSheet
, "F17", 28, 1, 2002 );
233 setValue( xSheet
, "E18", 6 );
234 setValue( xSheet
, "F18", 4 );
238 /** Returns the XCellSeries interface of a cell range.
239 @param xSheet The spreadsheet containing the cell range.
240 @param aRange The address of the cell range.
241 @return The XCellSeries interface. */
242 private unoidl
.com
.sun
.star
.sheet
.XCellSeries
getCellSeries(
243 unoidl
.com
.sun
.star
.sheet
.XSpreadsheet xSheet
, String aRange
)
245 return (unoidl
.com
.sun
.star
.sheet
.XCellSeries
)
246 xSheet
.getCellRangeByName( aRange
);
251 /** This is a helper class for the spreadsheet and table samples.
252 It connects to a running office and creates a spreadsheet document.
253 Additionally it contains various helper functions.
255 class SpreadsheetDocHelper
: System
.IDisposable
258 // __ private members ___________________________________________
260 private const String msDataSheetName
= "Data";
262 private unoidl
.com
.sun
.star
.uno
.XComponentContext m_xContext
;
263 private unoidl
.com
.sun
.star
.lang
.XMultiServiceFactory mxMSFactory
;
264 private unoidl
.com
.sun
.star
.sheet
.XSpreadsheetDocument mxDocument
;
266 // ________________________________________________________________
268 public SpreadsheetDocHelper()
270 // System.Diagnostics.Debugger.Launch();
271 // Connect to a running office and get the service manager
272 mxMSFactory
= connect();
273 // Create a new spreadsheet document
274 mxDocument
= initDocument();
277 // __ helper methods ____________________________________________
279 /** Returns the service manager.
280 @return XMultiServiceFactory interface of the service manager. */
281 public unoidl
.com
.sun
.star
.lang
.XMultiServiceFactory
getServiceManager()
286 /** Returns the whole spreadsheet document.
287 @return XSpreadsheetDocument interface of the document. */
288 public unoidl
.com
.sun
.star
.sheet
.XSpreadsheetDocument
getDocument()
293 /** Returns the spreadsheet with the specified index (0-based).
294 @param nIndex The index of the sheet.
295 @return XSpreadsheet interface of the sheet. */
296 public unoidl
.com
.sun
.star
.sheet
.XSpreadsheet
getSpreadsheet( int nIndex
)
298 // Collection of sheets
299 unoidl
.com
.sun
.star
.sheet
.XSpreadsheets xSheets
=
300 mxDocument
.getSheets();
302 unoidl
.com
.sun
.star
.container
.XIndexAccess xSheetsIA
=
303 (unoidl
.com
.sun
.star
.container
.XIndexAccess
) xSheets
;
305 unoidl
.com
.sun
.star
.sheet
.XSpreadsheet xSheet
=
306 (unoidl
.com
.sun
.star
.sheet
.XSpreadsheet
)
307 xSheetsIA
.getByIndex( nIndex
).Value
;
312 /** Inserts a new empty spreadsheet with the specified name.
313 @param aName The name of the new sheet.
314 @param nIndex The insertion index.
315 @return The XSpreadsheet interface of the new sheet. */
316 public unoidl
.com
.sun
.star
.sheet
.XSpreadsheet
insertSpreadsheet(
317 String aName
, short nIndex
)
319 // Collection of sheets
320 unoidl
.com
.sun
.star
.sheet
.XSpreadsheets xSheets
=
321 mxDocument
.getSheets();
323 xSheets
.insertNewByName( aName
, nIndex
);
324 unoidl
.com
.sun
.star
.sheet
.XSpreadsheet xSheet
=
325 (unoidl
.com
.sun
.star
.sheet
.XSpreadsheet
)
326 xSheets
.getByName( aName
).Value
;
331 // ________________________________________________________________
332 // Methods to fill values into cells.
334 /** Writes a double value into a spreadsheet.
335 @param xSheet The XSpreadsheet interface of the spreadsheet.
336 @param aCellName The address of the cell (or a named range).
337 @param fValue The value to write into the cell. */
338 public void setValue(
339 unoidl
.com
.sun
.star
.sheet
.XSpreadsheet xSheet
,
343 xSheet
.getCellRangeByName( aCellName
).getCellByPosition(
344 0, 0 ).setValue( fValue
);
347 /** Writes a formula into a spreadsheet.
348 @param xSheet The XSpreadsheet interface of the spreadsheet.
349 @param aCellName The address of the cell (or a named range).
350 @param aFormula The formula to write into the cell. */
351 public void setFormula(
352 unoidl
.com
.sun
.star
.sheet
.XSpreadsheet xSheet
,
356 xSheet
.getCellRangeByName( aCellName
).getCellByPosition(
357 0, 0 ).setFormula( aFormula
);
360 /** Writes a date with standard date format into a spreadsheet.
361 @param xSheet The XSpreadsheet interface of the spreadsheet.
362 @param aCellName The address of the cell (or a named range).
363 @param nDay The day of the date.
364 @param nMonth The month of the date.
365 @param nYear The year of the date. */
367 unoidl
.com
.sun
.star
.sheet
.XSpreadsheet xSheet
,
369 int nDay
, int nMonth
, int nYear
)
371 // Set the date value.
372 unoidl
.com
.sun
.star
.table
.XCell xCell
=
373 xSheet
.getCellRangeByName( aCellName
).getCellByPosition( 0, 0 );
374 String aDateStr
= nMonth
+ "/" + nDay
+ "/" + nYear
;
375 xCell
.setFormula( aDateStr
);
377 // Set standard date format.
378 unoidl
.com
.sun
.star
.util
.XNumberFormatsSupplier xFormatsSupplier
=
379 (unoidl
.com
.sun
.star
.util
.XNumberFormatsSupplier
) getDocument();
380 unoidl
.com
.sun
.star
.util
.XNumberFormatTypes xFormatTypes
=
381 (unoidl
.com
.sun
.star
.util
.XNumberFormatTypes
)
382 xFormatsSupplier
.getNumberFormats();
383 int nFormat
= xFormatTypes
.getStandardFormat(
384 unoidl
.com
.sun
.star
.util
.NumberFormat
.DATE
,
385 new unoidl
.com
.sun
.star
.lang
.Locale() );
387 unoidl
.com
.sun
.star
.beans
.XPropertySet xPropSet
=
388 (unoidl
.com
.sun
.star
.beans
.XPropertySet
) xCell
;
389 xPropSet
.setPropertyValue(
391 new uno
.Any( (Int32
) nFormat
) );
394 /** Draws a colored border around the range and writes the headline
397 @param xSheet The XSpreadsheet interface of the spreadsheet.
398 @param aRange The address of the cell range (or a named range).
399 @param aHeadline The headline text. */
400 public void prepareRange(
401 unoidl
.com
.sun
.star
.sheet
.XSpreadsheet xSheet
,
402 String aRange
, String aHeadline
)
404 unoidl
.com
.sun
.star
.beans
.XPropertySet xPropSet
= null;
405 unoidl
.com
.sun
.star
.table
.XCellRange xCellRange
= null;
408 xCellRange
= xSheet
.getCellRangeByName( aRange
);
409 xPropSet
= (unoidl
.com
.sun
.star
.beans
.XPropertySet
) xCellRange
;
410 unoidl
.com
.sun
.star
.table
.BorderLine aLine
=
411 new unoidl
.com
.sun
.star
.table
.BorderLine();
412 aLine
.Color
= 0x99CCFF;
413 aLine
.InnerLineWidth
= aLine
.LineDistance
= 0;
414 aLine
.OuterLineWidth
= 100;
415 unoidl
.com
.sun
.star
.table
.TableBorder aBorder
=
416 new unoidl
.com
.sun
.star
.table
.TableBorder();
417 aBorder
.TopLine
= aBorder
.BottomLine
= aBorder
.LeftLine
=
418 aBorder
.RightLine
= aLine
;
419 aBorder
.IsTopLineValid
= aBorder
.IsBottomLineValid
= true;
420 aBorder
.IsLeftLineValid
= aBorder
.IsRightLineValid
= true;
421 xPropSet
.setPropertyValue(
424 typeof (unoidl
.com
.sun
.star
.table
.TableBorder
), aBorder
) );
427 unoidl
.com
.sun
.star
.sheet
.XCellRangeAddressable xAddr
=
428 (unoidl
.com
.sun
.star
.sheet
.XCellRangeAddressable
) xCellRange
;
429 unoidl
.com
.sun
.star
.table
.CellRangeAddress aAddr
=
430 xAddr
.getRangeAddress();
432 xCellRange
= xSheet
.getCellRangeByPosition(
434 aAddr
.StartRow
, aAddr
.EndColumn
, aAddr
.StartRow
);
436 xPropSet
= (unoidl
.com
.sun
.star
.beans
.XPropertySet
) xCellRange
;
437 xPropSet
.setPropertyValue(
438 "CellBackColor", new uno
.Any( (Int32
) 0x99CCFF ) );
440 unoidl
.com
.sun
.star
.table
.XCell xCell
=
441 xCellRange
.getCellByPosition( 0, 0 );
442 xCell
.setFormula( aHeadline
);
443 xPropSet
= (unoidl
.com
.sun
.star
.beans
.XPropertySet
) xCell
;
444 xPropSet
.setPropertyValue(
445 "CharColor", new uno
.Any( (Int32
) 0x003399 ) );
446 xPropSet
.setPropertyValue(
448 new uno
.Any( (Single
) unoidl
.com
.sun
.star
.awt
.FontWeight
.BOLD
) );
451 // ________________________________________________________________
452 // Methods to create cell addresses and range addresses.
454 /** Creates a unoidl.com.sun.star.table.CellAddress and initializes it
455 with the given range.
456 @param xSheet The XSpreadsheet interface of the spreadsheet.
457 @param aCell The address of the cell (or a named cell). */
458 public unoidl
.com
.sun
.star
.table
.CellAddress
createCellAddress(
459 unoidl
.com
.sun
.star
.sheet
.XSpreadsheet xSheet
,
462 unoidl
.com
.sun
.star
.sheet
.XCellAddressable xAddr
=
463 (unoidl
.com
.sun
.star
.sheet
.XCellAddressable
)
464 xSheet
.getCellRangeByName( aCell
).getCellByPosition( 0, 0 );
465 return xAddr
.getCellAddress();
468 /** Creates a unoidl.com.sun.star.table.CellRangeAddress and initializes
469 it with the given range.
470 @param xSheet The XSpreadsheet interface of the spreadsheet.
471 @param aRange The address of the cell range (or a named range). */
472 public unoidl
.com
.sun
.star
.table
.CellRangeAddress
createCellRangeAddress(
473 unoidl
.com
.sun
.star
.sheet
.XSpreadsheet xSheet
, String aRange
)
475 unoidl
.com
.sun
.star
.sheet
.XCellRangeAddressable xAddr
=
476 (unoidl
.com
.sun
.star
.sheet
.XCellRangeAddressable
)
477 xSheet
.getCellRangeByName( aRange
);
478 return xAddr
.getRangeAddress();
481 // ________________________________________________________________
482 // Methods to convert cell addresses and range addresses to strings.
484 /** Returns the text address of the cell.
485 @param nColumn The column index.
486 @param nRow The row index.
487 @return A string containing the cell address. */
488 public String
getCellAddressString( int nColumn
, int nRow
)
492 aStr
+= (char) ('A' + nColumn
/ 26 - 1);
493 aStr
+= (char) ('A' + nColumn
% 26);
498 /** Returns the text address of the cell range.
499 @param aCellRange The cell range address.
500 @return A string containing the cell range address. */
501 public String
getCellRangeAddressString(
502 unoidl
.com
.sun
.star
.table
.CellRangeAddress aCellRange
)
505 getCellAddressString( aCellRange
.StartColumn
, aCellRange
.StartRow
)
507 + getCellAddressString( aCellRange
.EndColumn
, aCellRange
.EndRow
);
510 /** Returns the text address of the cell range.
511 @param xCellRange The XSheetCellRange interface of the cell range.
512 @param bWithSheet true = Include sheet name.
513 @return A string containing the cell range address. */
514 public String
getCellRangeAddressString(
515 unoidl
.com
.sun
.star
.sheet
.XSheetCellRange xCellRange
, bool bWithSheet
)
520 unoidl
.com
.sun
.star
.sheet
.XSpreadsheet xSheet
=
521 xCellRange
.getSpreadsheet();
522 unoidl
.com
.sun
.star
.container
.XNamed xNamed
=
523 (unoidl
.com
.sun
.star
.container
.XNamed
) xSheet
;
524 aStr
+= xNamed
.getName() + ".";
526 unoidl
.com
.sun
.star
.sheet
.XCellRangeAddressable xAddr
=
527 (unoidl
.com
.sun
.star
.sheet
.XCellRangeAddressable
) xCellRange
;
528 aStr
+= getCellRangeAddressString( xAddr
.getRangeAddress() );
532 /** Returns a list of addresses of all cell ranges contained in the
535 @param xRangesIA The XIndexAccess interface of the collection.
536 @return A string containing the cell range address list. */
537 public String
getCellRangeListString(
538 unoidl
.com
.sun
.star
.container
.XIndexAccess xRangesIA
)
541 int nCount
= xRangesIA
.getCount();
542 for (int nIndex
= 0; nIndex
< nCount
; ++nIndex
)
546 uno
.Any aRangeObj
= xRangesIA
.getByIndex( nIndex
);
547 unoidl
.com
.sun
.star
.sheet
.XSheetCellRange xCellRange
=
548 (unoidl
.com
.sun
.star
.sheet
.XSheetCellRange
) aRangeObj
.Value
;
549 aStr
+= getCellRangeAddressString( xCellRange
, false );
554 // ________________________________________________________________
556 /** Connect to a running office that is accepting connections.
557 @return The ServiceManager to instantiate office components. */
558 private XMultiServiceFactory
connect()
561 m_xContext
= uno
.util
.Bootstrap
.bootstrap();
563 return (XMultiServiceFactory
) m_xContext
.getServiceManager();
566 public void Dispose()
571 /** Creates an empty spreadsheet document.
572 @return The XSpreadsheetDocument interface of the document. */
573 private unoidl
.com
.sun
.star
.sheet
.XSpreadsheetDocument
initDocument()
575 XComponentLoader aLoader
= (XComponentLoader
)
576 mxMSFactory
.createInstance( "com.sun.star.frame.Desktop" );
578 XComponent xComponent
= aLoader
.loadComponentFromURL(
579 "private:factory/scalc", "_blank", 0,
580 new unoidl
.com
.sun
.star
.beans
.PropertyValue
[0] );
582 return (unoidl
.com
.sun
.star
.sheet
.XSpreadsheetDocument
) xComponent
;
586 public void terminate()
588 XModifiable xMod
= (XModifiable
) mxDocument
;
590 xMod
.setModified(false);
591 XDesktop aDesktop
= (XDesktop
)
592 mxMSFactory
.createInstance( "com.sun.star.frame.Desktop" );
593 if (aDesktop
!= null)
597 aDesktop
.terminate();
599 catch (DisposedException d
)
601 //This exception may be thrown because shutting down OOo using
602 //XDesktop terminate does not really work. In the case of the
603 //Exception OOo will still terminate.
608 // ________________________________________________________________