SCUtil.java (1ea6643f) SCUtil.java (d01630b6)
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

--- 17 unchanged lines hidden (view full) ---

26
27import org.openoffice.test.common.FileUtil;
28import org.openoffice.test.common.Testspace;
29import org.openoffice.test.uno.UnoApp;
30
31import com.sun.star.beans.PropertyValue;
32import com.sun.star.beans.XPropertySet;
33import com.sun.star.container.XIndexAccess;
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

--- 17 unchanged lines hidden (view full) ---

26
27import org.openoffice.test.common.FileUtil;
28import org.openoffice.test.common.Testspace;
29import org.openoffice.test.uno.UnoApp;
30
31import com.sun.star.beans.PropertyValue;
32import com.sun.star.beans.XPropertySet;
33import com.sun.star.container.XIndexAccess;
34import com.sun.star.container.XNamed;
34import com.sun.star.frame.XController;
35import com.sun.star.frame.XModel;
36import com.sun.star.frame.XStorable;
37import com.sun.star.lang.XComponent;
38import com.sun.star.sheet.XSpreadsheet;
39import com.sun.star.sheet.XSpreadsheetDocument;
40import com.sun.star.sheet.XSpreadsheetView;
41import com.sun.star.sheet.XSpreadsheets;

--- 62 unchanged lines hidden (view full) ---

104 (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
105 XSpreadsheet xSpreadsheet =
106 (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, xIndexAccess.getByIndex(index));
107
108 return xSpreadsheet;
109 }
110
111 /**
35import com.sun.star.frame.XController;
36import com.sun.star.frame.XModel;
37import com.sun.star.frame.XStorable;
38import com.sun.star.lang.XComponent;
39import com.sun.star.sheet.XSpreadsheet;
40import com.sun.star.sheet.XSpreadsheetDocument;
41import com.sun.star.sheet.XSpreadsheetView;
42import com.sun.star.sheet.XSpreadsheets;

--- 62 unchanged lines hidden (view full) ---

105 (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
106 XSpreadsheet xSpreadsheet =
107 (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, xIndexAccess.getByIndex(index));
108
109 return xSpreadsheet;
110 }
111
112 /**
113 * Get sheet name by sheet index
114 *
115 * @param xSpreadsheetDocument
116 * @param index
117 * (Short) 0,1,2,...
118 * @return
119 * @throws Exception
120 */
121 public static String getSCSheetNameByIndex(
122 XSpreadsheetDocument xSpreadsheetDocument, short index)
123 throws Exception {
124 XSpreadsheets xSpreadsheets = xSpreadsheetDocument.getSheets();
125 XIndexAccess xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface(
126 XIndexAccess.class, xSpreadsheets);
127 XSpreadsheet xSpreadsheet = (XSpreadsheet) UnoRuntime.queryInterface(
128 XSpreadsheet.class, xIndexAccess.getByIndex(index));
129 XNamed xsheetname = (XNamed) UnoRuntime.queryInterface(XNamed.class,
130 xSpreadsheet);
131 return xsheetname.getName();
132 }
133
134 /**
135 * Set sheet name by sheet index
136 *
137 * @param xSpreadsheetDocument
138 * @param index
139 * (Short) 0,1,2,...
140 * @return
141 * @throws Exception
142 */
143 public static void setSCSheetNameByIndex(
144 XSpreadsheetDocument xSpreadsheetDocument, short index,
145 String sheetname) throws Exception {
146 XSpreadsheets xSpreadsheets = xSpreadsheetDocument.getSheets();
147 XIndexAccess xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface(
148 XIndexAccess.class, xSpreadsheets);
149 XSpreadsheet xSpreadsheet = (XSpreadsheet) UnoRuntime.queryInterface(
150 XSpreadsheet.class, xIndexAccess.getByIndex(index));
151 XNamed xsheetname = (XNamed) UnoRuntime.queryInterface(XNamed.class,
152 xSpreadsheet);
153 xsheetname.setName(sheetname);
154 }
155
156 /**
112 * Get rows object
113 * @param xSpreadsheet
114 * @return
115 * @throws Exception
116 */
117 public static XTableRows getSCRows(XSpreadsheet xSpreadsheet) throws Exception {
118 XColumnRowRange xColumnRowRange =
119 (XColumnRowRange) UnoRuntime.queryInterface(XColumnRowRange.class, xSpreadsheet);

--- 233 unchanged lines hidden (view full) ---

353 XController xController = xModel.getCurrentController();
354 XSpreadsheetView xSpreadsheetView = (XSpreadsheetView) UnoRuntime.queryInterface(XSpreadsheetView.class, xController);
355 XSpreadsheet xSpreadsheet = xSpreadsheetView.getActiveSheet();
356
357 return xSpreadsheet;
358 }
359
360 /**
157 * Get rows object
158 * @param xSpreadsheet
159 * @return
160 * @throws Exception
161 */
162 public static XTableRows getSCRows(XSpreadsheet xSpreadsheet) throws Exception {
163 XColumnRowRange xColumnRowRange =
164 (XColumnRowRange) UnoRuntime.queryInterface(XColumnRowRange.class, xSpreadsheet);

--- 233 unchanged lines hidden (view full) ---

398 XController xController = xModel.getCurrentController();
399 XSpreadsheetView xSpreadsheetView = (XSpreadsheetView) UnoRuntime.queryInterface(XSpreadsheetView.class, xController);
400 XSpreadsheet xSpreadsheet = xSpreadsheetView.getActiveSheet();
401
402 return xSpreadsheet;
403 }
404
405 /**
406 * Get sheet object by sheet index
407 *
408 * @param xSpreadsheetDocument
409 * @return
410 * @throws Exception
411 */
412 public static String getSCActiveSheetName(
413 XSpreadsheetDocument xSpreadsheetDocument) throws Exception {
414 XModel xSpreadsheetModel = (XModel) UnoRuntime.queryInterface(
415 XModel.class, xSpreadsheetDocument);
416 XSpreadsheetView xSpeadsheetView = (XSpreadsheetView) UnoRuntime
417 .queryInterface(XSpreadsheetView.class,
418 xSpreadsheetModel.getCurrentController());
419 XSpreadsheet activesheet = xSpeadsheetView.getActiveSheet();
420 XNamed activesheetName = (XNamed) UnoRuntime.queryInterface(
421 XNamed.class, activesheet);
422 return activesheetName.getName();
423 }
424
425 /**
361 * Set value of specific property from a cell
362 * @param xCell
363 * @param propName
364 * @param value
365 * @throws Exception
366 */
367 public static void setCellProperties(XCell xCell, String propName, Object value) throws Exception {
368

--- 44 unchanged lines hidden (view full) ---

413 storeProps[1].Value = new Boolean(true);
414
415 XStorable scStorable =
416 (XStorable) UnoRuntime.queryInterface(XStorable.class, scComponent);
417 scStorable.storeAsURL(storeUrl, storeProps);
418 }
419
420 /**
426 * Set value of specific property from a cell
427 * @param xCell
428 * @param propName
429 * @param value
430 * @throws Exception
431 */
432 public static void setCellProperties(XCell xCell, String propName, Object value) throws Exception {
433

--- 44 unchanged lines hidden (view full) ---

478 storeProps[1].Value = new Boolean(true);
479
480 XStorable scStorable =
481 (XStorable) UnoRuntime.queryInterface(XStorable.class, scComponent);
482 scStorable.storeAsURL(storeUrl, storeProps);
483 }
484
485 /**
486 * Save file after open file.
487 *
488 * @param xSpreadsheetDocument
489 * @throws Exception
490 */
491 public static void save(XSpreadsheetDocument xSpreadsheetDocument)
492 throws Exception {
493
494 XStorable scStorable = (XStorable) UnoRuntime.queryInterface(
495 XStorable.class, xSpreadsheetDocument);
496 scStorable.store();
497
498 }
499
500
501 /**
421 * Close specific opening spreadsheet file which has been saved
422 * @param xSpreadsheetDocument
423 * @throws Exception
424 */
425 public static void closeFile(XSpreadsheetDocument xSpreadsheetDocument) throws Exception {
426 XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, xSpreadsheetDocument);
427 xCloseable.close(false);
428 }

--- 35 unchanged lines hidden ---
502 * Close specific opening spreadsheet file which has been saved
503 * @param xSpreadsheetDocument
504 * @throws Exception
505 */
506 public static void closeFile(XSpreadsheetDocument xSpreadsheetDocument) throws Exception {
507 XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, xSpreadsheetDocument);
508 xCloseable.close(false);
509 }

--- 35 unchanged lines hidden ---