Line 0
Link Here
|
|
|
1 |
/* 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 |
8 |
* |
9 |
* http://www.apache.org/licenses/LICENSE-2.0 |
10 |
* |
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. |
17 |
* |
18 |
*************************************************************/ |
19 |
|
20 |
|
21 |
package testcase.uno.sc.RowandColumn; |
22 |
|
23 |
import static org.junit.Assert.*; |
24 |
|
25 |
import java.util.ArrayList; |
26 |
import java.util.Arrays; |
27 |
import java.util.Collection; |
28 |
|
29 |
import org.junit.After; |
30 |
import org.junit.AfterClass; |
31 |
import org.junit.Before; |
32 |
import org.junit.BeforeClass; |
33 |
import org.junit.Test; |
34 |
import org.junit.runner.RunWith; |
35 |
import org.junit.runners.Parameterized; |
36 |
import org.junit.runners.Parameterized.Parameters; |
37 |
|
38 |
import org.openoffice.test.common.Testspace; |
39 |
import org.openoffice.test.uno.UnoApp; |
40 |
|
41 |
import com.sun.star.beans.XPropertySet; |
42 |
import com.sun.star.container.XIndexAccess; |
43 |
import com.sun.star.lang.XComponent; |
44 |
import com.sun.star.sheet.XSpreadsheet; |
45 |
import com.sun.star.sheet.XSpreadsheetDocument; |
46 |
import com.sun.star.sheet.XSpreadsheets; |
47 |
import com.sun.star.table.XCellRange; |
48 |
import com.sun.star.table.XCell; |
49 |
import com.sun.star.uno.Type; |
50 |
import com.sun.star.uno.UnoRuntime; |
51 |
import com.sun.star.util.XMergeable; |
52 |
|
53 |
/** |
54 |
* Check the content input in cell |
55 |
* @author test |
56 |
* |
57 |
*/ |
58 |
|
59 |
public class CellMerge { |
60 |
|
61 |
UnoApp unoApp = new UnoApp(); |
62 |
XSpreadsheetDocument scDocument = null; |
63 |
XComponent scComponent = null; |
64 |
|
65 |
@Before |
66 |
public void setUp() throws Exception { |
67 |
unoApp.start(); |
68 |
} |
69 |
|
70 |
@After |
71 |
public void tearDown() throws Exception { |
72 |
unoApp.closeDocument(scComponent); |
73 |
unoApp.close(); |
74 |
} |
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(); |
83 |
Object sheetObj = spreadsheets.getByName(sheetname); |
84 |
XSpreadsheet sheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, sheetObj); |
85 |
|
86 |
//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) |
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 |
|
107 |
|
108 |
} |
109 |
|
110 |
} |