Kaydet (Commit) 61e32964 authored tarafından Kurt Zenker's avatar Kurt Zenker

INTEGRATION: CWS qadev13 (1.3.2); FILE MERGED

2003/11/07 16:20:30 sg 1.3.2.1: #112280#CHG: react on new object relations
üst 3519f1bf
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: _XCellRangesQuery.java,v $ * $RCSfile: _XCellRangesQuery.java,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change:$Date: 2003-10-06 13:31:22 $ * last change:$Date: 2003-11-18 16:24:23 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -66,6 +66,7 @@ import lib.StatusException; ...@@ -66,6 +66,7 @@ import lib.StatusException;
import com.sun.star.beans.XPropertySet; import com.sun.star.beans.XPropertySet;
import com.sun.star.sheet.CellFlags; import com.sun.star.sheet.CellFlags;
import com.sun.star.sheet.FormulaResult;
import com.sun.star.sheet.XCellRangesQuery; import com.sun.star.sheet.XCellRangesQuery;
import com.sun.star.sheet.XSheetCellRanges; import com.sun.star.sheet.XSheetCellRanges;
import com.sun.star.sheet.XSpreadsheet; import com.sun.star.sheet.XSpreadsheet;
...@@ -76,14 +77,36 @@ import com.sun.star.table.XTableColumns; ...@@ -76,14 +77,36 @@ import com.sun.star.table.XTableColumns;
import com.sun.star.table.XTableRows; import com.sun.star.table.XTableRows;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
/**
* Test the XCellRangesQuery interface.
* Needed object relations:
* <ul>
* <li>"SHEET": an XSpreadSheet object
* </li>
* <li>"XCellRangesQuery.EXPECTEDRESULTS": the expected results for the test
* methods as a String array.<br>
* @see mod._sc.ScCellCurserObj or
* @see mod._sc.ScCellObj for an example how this should look like.
* </li>
* </ul>
*/
public class _XCellRangesQuery extends MultiMethodTest { public class _XCellRangesQuery extends MultiMethodTest {
public XCellRangesQuery oObj; public XCellRangesQuery oObj;
protected XSpreadsheet oSheet; protected XSpreadsheet oSheet;
protected XTableRows oRows; protected XTableRows oRows;
protected XTableColumns oColumns; protected XTableColumns oColumns;
protected String[] mExpectedResults = null;
protected boolean bMakeEntriesAndDispose = false;
String getting = ""; String getting = "";
String expected = ""; String expected = "";
// provide the object with constants to fill the expected results array
public static final int QUERYCOLUMNDIFFERENCES = 0;
public static final int QUERYCONTENTCELLS = 1;
public static final int QUERYEMPTYCELLS = 2;
public static final int QUERYFORMULACELLS = 3;
public static final int QUERYINTERSECTION = 4;
public static final int QUERYROWDIFFERENCES = 5;
public static final int QUERYVISIBLECELLS = 6;
protected void before() { protected void before() {
oSheet = (XSpreadsheet) tEnv.getObjRelation("SHEET"); oSheet = (XSpreadsheet) tEnv.getObjRelation("SHEET");
...@@ -100,11 +123,24 @@ public class _XCellRangesQuery extends MultiMethodTest { ...@@ -100,11 +123,24 @@ public class _XCellRangesQuery extends MultiMethodTest {
} }
} }
// expected results
mExpectedResults = (String[])tEnv.getObjRelation(
"XCellRangesQuery.EXPECTEDRESULTS");
XColumnRowRange oColumnRowRange = (XColumnRowRange) UnoRuntime.queryInterface( XColumnRowRange oColumnRowRange = (XColumnRowRange) UnoRuntime.queryInterface(
XColumnRowRange.class, XColumnRowRange.class,
oSheet); oSheet);
oRows = (XTableRows) oColumnRowRange.getRows(); oRows = (XTableRows)oColumnRowRange.getRows();
oColumns = (XTableColumns) oColumnRowRange.getColumns(); oColumns = (XTableColumns) oColumnRowRange.getColumns();
// set this in object if the interface has to make its own settings
// and the environment has to be disposed: this is necessary for objects
// that do not make entries on the sheet themselves
Object o = tEnv.getObjRelation("XCellRangesQuery.CREATEENTRIES");
if (o != null && o instanceof Boolean) {
bMakeEntriesAndDispose = ((Boolean)o).booleanValue();
}
if(bMakeEntriesAndDispose) {
oRows.removeByIndex(4, oRows.getCount() - 4); oRows.removeByIndex(4, oRows.getCount() - 4);
oColumns.removeByIndex(4, oColumns.getCount() - 4); oColumns.removeByIndex(4, oColumns.getCount() - 4);
...@@ -112,6 +148,7 @@ public class _XCellRangesQuery extends MultiMethodTest { ...@@ -112,6 +148,7 @@ public class _XCellRangesQuery extends MultiMethodTest {
oSheet.getCellByPosition(1, 1).setValue(5); oSheet.getCellByPosition(1, 1).setValue(5);
oSheet.getCellByPosition(1, 2).setValue(15); oSheet.getCellByPosition(1, 2).setValue(15);
oSheet.getCellByPosition(2, 1).setFormula("=B2+B3"); oSheet.getCellByPosition(2, 1).setFormula("=B2+B3");
oSheet.getCellByPosition(1, 3).setFormula("=B2+B4");
oSheet.getCellByPosition(3, 2).setFormula(""); oSheet.getCellByPosition(3, 2).setFormula("");
oSheet.getCellByPosition(3, 3).setFormula(""); oSheet.getCellByPosition(3, 3).setFormula("");
} catch (com.sun.star.lang.IndexOutOfBoundsException e) { } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
...@@ -119,27 +156,39 @@ public class _XCellRangesQuery extends MultiMethodTest { ...@@ -119,27 +156,39 @@ public class _XCellRangesQuery extends MultiMethodTest {
} }
} }
}
/**
* Tested method returns each cell of each column that is different to the
* cell in a given row
*/
public void _queryColumnDifferences() { public void _queryColumnDifferences() {
boolean res = true; boolean res = true;
XSheetCellRanges ranges = oObj.queryColumnDifferences( XSheetCellRanges ranges = oObj.queryColumnDifferences(
new CellAddress((short) 0, 1, 1)); new CellAddress((short) 0, 1, 1));
getting = ranges.getRangeAddressesAsString(); getting = ranges.getRangeAddressesAsString();
expected = "Sheet1.B1:C1;Sheet1.B3"; expected = mExpectedResults[QUERYCOLUMNDIFFERENCES];
if (!getting.startsWith(expected)) { if (!getting.startsWith(expected)) {
log.println("Getting: " + getting); log.println("Getting: " + getting);
log.println("Should have started with: " + expected); log.println("Should have started with: " + expected);
res = false; res = false;
} }
tRes.tested("queryColumnDifferences()", res); tRes.tested("queryColumnDifferences()", res);
} }
/**
* Tested method returns all cells of a given type, defind in
* CellFlags
* @see com.sun.star.sheet.CellFlags
*/
public void _queryContentCells() { public void _queryContentCells() {
boolean res = true; boolean res = true;
XSheetCellRanges ranges = oObj.queryContentCells( XSheetCellRanges ranges = oObj.queryContentCells(
(short) CellFlags.VALUE); (short) CellFlags.VALUE);
getting = ranges.getRangeAddressesAsString(); getting = ranges.getRangeAddressesAsString();
expected = "Sheet1.B2:B3"; expected = mExpectedResults[QUERYCONTENTCELLS];
if (!getting.startsWith(expected)) { if (!getting.startsWith(expected)) {
log.println("Getting: " + getting); log.println("Getting: " + getting);
...@@ -150,16 +199,30 @@ public class _XCellRangesQuery extends MultiMethodTest { ...@@ -150,16 +199,30 @@ public class _XCellRangesQuery extends MultiMethodTest {
tRes.tested("queryContentCells()", res); tRes.tested("queryContentCells()", res);
} }
/**
* Tested method returns all empty cells of the range
*/
public void _queryEmptyCells() { public void _queryEmptyCells() {
boolean res = true; boolean res = true;
XSheetCellRanges ranges = oObj.queryEmptyCells(); XSheetCellRanges ranges = oObj.queryEmptyCells();
getting = ranges.getRangeAddressesAsString(); getting = ranges.getRangeAddressesAsString();
res &= (getting.indexOf("Sheet1.A1") > -1); expected = mExpectedResults[QUERYEMPTYCELLS];
res &= (getting.indexOf("Sheet1.B1") > 0);
res &= (getting.indexOf("Sheet1.B4") > 0); int startIndex = 0;
res &= (getting.indexOf("Sheet1.C3") > 0); int endIndex = -5;
res &= (getting.indexOf("Sheet1.D1") > 0); String checkString = null;
expected = "Sheet1.A1 ... Sheet1.B1 ... Sheet1.B4 ... Sheet1.C3 ... Sheet1.D1";
while (endIndex != -1) {
startIndex = endIndex + 5;
endIndex = expected.indexOf(" ... ", startIndex);
if (endIndex == -1) {
checkString = expected.substring(startIndex);
}
else {
checkString = expected.substring(startIndex, endIndex);
}
res &= (getting.indexOf(checkString) > -1);
}
if (!res) { if (!res) {
log.println("Getting: " + getting); log.println("Getting: " + getting);
...@@ -169,12 +232,17 @@ public class _XCellRangesQuery extends MultiMethodTest { ...@@ -169,12 +232,17 @@ public class _XCellRangesQuery extends MultiMethodTest {
tRes.tested("queryEmptyCells()", res); tRes.tested("queryEmptyCells()", res);
} }
/**
* Tested method returns all cells of a given type, defind in
* FormulaResult
* @see com.sun.star.sheet.FormulaResult
*/
public void _queryFormulaCells() { public void _queryFormulaCells() {
boolean res = true; boolean res = true;
XSheetCellRanges ranges = oObj.queryFormulaCells( XSheetCellRanges ranges = oObj.queryFormulaCells(
(short) CellFlags.VALUE); (short) FormulaResult.VALUE);
getting = ranges.getRangeAddressesAsString(); getting = ranges.getRangeAddressesAsString();
expected = "Sheet1.C2"; expected = mExpectedResults[QUERYFORMULACELLS];
if (!getting.equals(expected)) { if (!getting.equals(expected)) {
log.println("Getting: " + getting); log.println("Getting: " + getting);
...@@ -190,7 +258,7 @@ public class _XCellRangesQuery extends MultiMethodTest { ...@@ -190,7 +258,7 @@ public class _XCellRangesQuery extends MultiMethodTest {
XSheetCellRanges ranges = oObj.queryIntersection( XSheetCellRanges ranges = oObj.queryIntersection(
new CellRangeAddress((short) 0, 3, 3, 7, 7)); new CellRangeAddress((short) 0, 3, 3, 7, 7));
getting = ranges.getRangeAddressesAsString(); getting = ranges.getRangeAddressesAsString();
expected = "Sheet1.D4"; expected = mExpectedResults[QUERYINTERSECTION];
if (!getting.startsWith(expected)) { if (!getting.startsWith(expected)) {
log.println("Getting: " + getting); log.println("Getting: " + getting);
...@@ -201,12 +269,16 @@ public class _XCellRangesQuery extends MultiMethodTest { ...@@ -201,12 +269,16 @@ public class _XCellRangesQuery extends MultiMethodTest {
tRes.tested("queryIntersection()", res); tRes.tested("queryIntersection()", res);
} }
/**
* Tested method returns each cell of each row that is different to the
* cell in a given column
*/
public void _queryRowDifferences() { public void _queryRowDifferences() {
boolean res = true; boolean res = true;
XSheetCellRanges ranges = oObj.queryRowDifferences( XSheetCellRanges ranges = oObj.queryRowDifferences(
new CellAddress((short) 0, 1, 1)); new CellAddress((short) 0, 1, 1));
getting = ranges.getRangeAddressesAsString(); getting = ranges.getRangeAddressesAsString();
expected = "Sheet1.A2:A3;Sheet1.C2:D3"; expected = mExpectedResults[QUERYROWDIFFERENCES];
if (!getting.startsWith(expected)) { if (!getting.startsWith(expected)) {
log.println("Getting: " + getting); log.println("Getting: " + getting);
...@@ -223,7 +295,7 @@ public class _XCellRangesQuery extends MultiMethodTest { ...@@ -223,7 +295,7 @@ public class _XCellRangesQuery extends MultiMethodTest {
boolean res = true; boolean res = true;
XSheetCellRanges ranges = oObj.queryVisibleCells(); XSheetCellRanges ranges = oObj.queryVisibleCells();
getting = ranges.getRangeAddressesAsString(); getting = ranges.getRangeAddressesAsString();
expected = "Sheet1.A2"; expected = mExpectedResults[QUERYVISIBLECELLS];
if (!getting.startsWith(expected)) { if (!getting.startsWith(expected)) {
log.println("Getting: " + getting); log.println("Getting: " + getting);
...@@ -262,6 +334,8 @@ public class _XCellRangesQuery extends MultiMethodTest { ...@@ -262,6 +334,8 @@ public class _XCellRangesQuery extends MultiMethodTest {
* Forces environment recreation. * Forces environment recreation.
*/ */
protected void after() { protected void after() {
if(bMakeEntriesAndDispose) {
disposeEnvironment(); disposeEnvironment();
} }
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment