CellMerge.java (eba4d44a) CellMerge.java (916729d0)
1/* Licensed to the Apache Software Foundation (ASF) under one
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
2 * or more contributor license agreements. See the NOTICE file
3 * distributed with this work for additional information
4 * regarding copyright ownership. The ASF licenses this file
5 * to you under the Apache License, Version 2.0 (the
6 * "License"); you may not use this file except in compliance
7 * with the License. You may obtain a copy of the License at
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
8 *
10 *
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * http://www.apache.org/licenses/LICENSE-2.0
10 *
12 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
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.
17 *
19 *
18 *************************************************************/
19
20 *************************************************************/
21
20
21package fvt.uno.sc.rowcolumn;
22
23import static org.junit.Assert.*;
24
25import java.util.ArrayList;
26import java.util.Arrays;
27import java.util.Collection;
28

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

75
76 @Test
77 public void testCellMerge() throws Exception {
78
79 String sheetname = "sheet1";
80 scComponent = unoApp.newDocument("scalc");
81 scDocument = (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, scComponent);
82 XSpreadsheets spreadsheets = scDocument.getSheets();
22package fvt.uno.sc.rowcolumn;
23
24import static org.junit.Assert.*;
25
26import java.util.ArrayList;
27import java.util.Arrays;
28import java.util.Collection;
29

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

76
77 @Test
78 public void testCellMerge() throws Exception {
79
80 String sheetname = "sheet1";
81 scComponent = unoApp.newDocument("scalc");
82 scDocument = (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, scComponent);
83 XSpreadsheets spreadsheets = scDocument.getSheets();
83 Object sheetObj = spreadsheets.getByName(sheetname);
84 Object sheetObj = spreadsheets.getByName(sheetname);
84 XSpreadsheet sheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, sheetObj);
85
85 XSpreadsheet sheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, sheetObj);
86
86 //Select A1 and input "12"
87 // Select A1 and input "12"
87 XCell cell = sheet.getCellByPosition(0, 0);
88 cell.setValue(12);
89
90 // Get cell range A1:B1 by position - (column, row, column, row)
88 XCell cell = sheet.getCellByPosition(0, 0);
89 cell.setValue(12);
90
91 // Get cell range A1:B1 by position - (column, row, column, row)
91 XCellRange CellRange = sheet.getCellRangeByPosition( 0, 0, 1, 0 );
92 //XCellRange CellRange = sheet.getCellRangeByName("A1:B1");
93
94 //Merge cell range A1:B1 into one cell
95 XMergeable xMerge = (XMergeable) UnoRuntime.queryInterface(XMergeable.class, CellRange);
96 xMerge.merge(true);
97
98 //Verify if the cell range A1:B1 is completely merged
99 assertEquals("Verify if the cell range A1:B1 is completely merged",true, xMerge.getIsMerged());
100
101 //Undo Merge cell range A1:B1 into one cell
102 xMerge.merge(false);
103
104 //Verify if the cell range A1:B1 is no longer merged
105 assertEquals("Verify if the cell range A1:B1 is no longer merged",false, xMerge.getIsMerged());
106
92 XCellRange CellRange = sheet.getCellRangeByPosition( 0, 0, 1, 0 );
93 //XCellRange CellRange = sheet.getCellRangeByName("A1:B1");
107
94
95 // Merge cell range A1:B1 into one cell
96 XMergeable xMerge = (XMergeable) UnoRuntime.queryInterface(XMergeable.class, CellRange);
97 xMerge.merge(true);
98
99 // Verify if the cell range A1:B1 is completely merged
100 assertEquals("Verify if the cell range A1:B1 is completely merged",true, xMerge.getIsMerged());
101
102 // Undo Merge cell range A1:B1 into one cell
103 xMerge.merge(false);
104
105 // Verify if the cell range A1:B1 is no longer merged
106 assertEquals("Verify if the cell range A1:B1 is no longer merged",false, xMerge.getIsMerged());
107
108 }
109
110}
108 }
109
110}