| <?xml version="1.0" encoding="UTF-8"?> |
| <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> |
| <script:module xmlns:script="http://openoffice.org/2000/script" script:name="sheet_XCellRangeMovement" script:language="StarBasic"> |
| |
| |
| '************************************************************************* |
| ' |
| ' Licensed to the Apache Software Foundation (ASF) under one |
| ' or more contributor license agreements. See the NOTICE file |
| ' distributed with this work for additional information |
| ' regarding copyright ownership. The ASF licenses this file |
| ' to you under the Apache License, Version 2.0 (the |
| ' "License"); you may not use this file except in compliance |
| ' with the License. You may obtain a copy of the License at |
| ' |
| ' http://www.apache.org/licenses/LICENSE-2.0 |
| ' |
| ' Unless required by applicable law or agreed to in writing, |
| ' software distributed under the License is distributed on an |
| ' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| ' KIND, either express or implied. See the License for the |
| ' specific language governing permissions and limitations |
| ' under the License. |
| ' |
| '************************************************************************* |
| |
| |
| |
| |
| |
| |
| |
| Sub RunTest() |
| |
| '************************************************************************* |
| ' INTERFACE: |
| ' com.sun.star.sheet.XCellRangeMovement |
| '************************************************************************* |
| On Error Goto ErrHndl |
| Dim bOK As Boolean |
| |
| Out.Log("Prepearing test...") |
| for i = 0 to 5 |
| for j = 0 to 5 |
| oObj.getCellByPosition(j, i).Value = i * 6 + j |
| next j |
| next i |
| |
| Test.StartMethod("insertCells()") |
| bOK = true |
| Dim newCellAddress As New com.sun.star.table.CellRangeAddress |
| newCellAddress.Sheet = 0 |
| newCellAddress.StartColumn = 1 |
| newCellAddress.StartRow = 1 |
| newCellAddress.EndColumn = 1 |
| newCellAddress.EndRow = 1 |
| oObj.insertCells(newCellAddress, com.sun.star.sheet.CellInsertMode.DOWN) |
| bOK = bOK AND oObj.getCellByPosition(1, 1).String = "" |
| bOK = bOK AND oObj.getCellByPosition(2, 2).Value = 14 |
| bOK = bOK AND oObj.getCellByPosition(1, 2).Value = 7 |
| bOK = bOK AND oObj.getCellByPosition(0, 2).Value = 12 |
| |
| oObj.insertCells(newCellAddress, com.sun.star.sheet.CellInsertMode.RIGHT) |
| bOK = bOK AND oObj.getCellByPosition(1, 1).String = "" |
| bOK = bOK AND oObj.getCellByPosition(3, 0).Value = 3 |
| bOK = bOK AND oObj.getCellByPosition(3, 1).Value = 8 |
| bOK = bOK AND oObj.getCellByPosition(3, 2).Value = 15 |
| |
| oObj.insertCells(newCellAddress, com.sun.star.sheet.CellInsertMode.ROWS) |
| bOK = bOK AND oObj.getCellByPosition(1, 1).String = "" |
| bOK = bOK AND oObj.getCellByPosition(4, 0).Value = 4 |
| bOK = bOK AND oObj.getCellByPosition(4, 1).String = "" |
| bOK = bOK AND oObj.getCellByPosition(4, 2).Value = 9 |
| |
| oObj.insertCells(newCellAddress, com.sun.star.sheet.CellInsertMode.COLUMNS) |
| bOK = bOK AND oObj.getCellByPosition(1, 1).String = "" |
| bOK = bOK AND oObj.getCellByPosition(0, 5).Value = 24 |
| bOK = bOK AND oObj.getCellByPosition(1, 5).String = "" |
| bOK = bOK AND oObj.getCellByPosition(2, 5).Value = 19 |
| |
| Test.MethodTested("insertCells()", bOK) |
| |
| Test.StartMethod("removeRange()") |
| bOK = true |
| oObj.removeRange(newCellAddress, com.sun.star.sheet.CellDeleteMode.ROWS) |
| bOK = bOK AND oObj.getCellByPosition(1, 1).String = "" |
| bOK = bOK AND oObj.getCellByPosition(4, 0).Value = 3 |
| bOK = bOK AND oObj.getCellByPosition(4, 1).Value = 8 |
| bOK = bOK AND oObj.getCellByPosition(4, 2).Value = 15 |
| |
| oObj.removeRange(newCellAddress, com.sun.star.sheet.CellDeleteMode.COLUMNS) |
| bOK = bOK AND oObj.getCellByPosition(1, 1).String = "" |
| bOK = bOK AND oObj.getCellByPosition(4, 0).Value = 4 |
| bOK = bOK AND oObj.getCellByPosition(4, 1).Value = 9 |
| bOK = bOK AND oObj.getCellByPosition(4, 2).Value = 16 |
| |
| oObj.removeRange(newCellAddress, com.sun.star.sheet.CellDeleteMode.UP) |
| bOK = bOK AND oObj.getCellByPosition(1, 1).Value = 7 |
| bOK = bOK AND oObj.getCellByPosition(1, 2).Value = 13 |
| bOK = bOK AND oObj.getCellByPosition(1, 3).Value = 19 |
| bOK = bOK AND oObj.getCellByPosition(0, 3).Value = 18 |
| |
| oObj.removeRange(newCellAddress, com.sun.star.sheet.CellDeleteMode.LEFT) |
| bOK = bOK AND oObj.getCellByPosition(1, 1).String = "" |
| bOK = bOK AND oObj.getCellByPosition(0, 1).Value = 6 |
| bOK = bOK AND oObj.getCellByPosition(1, 1).String = "" |
| bOK = bOK AND oObj.getCellByPosition(2, 1).Value = 8 |
| |
| Test.MethodTested("removeRange()", bOK) |
| |
| Test.StartMethod("moveRange()") |
| bOK = true |
| newCellAddress.Sheet = 0 |
| newCellAddress.StartColumn = 0 |
| newCellAddress.StartRow = 0 |
| newCellAddress.EndColumn = 1 |
| newCellAddress.EndRow = 1 |
| Dim sCell As New com.sun.star.table.CellAddress |
| sCell.Sheet = 0 |
| sCell.Column = 3 |
| sCell.Row = 3 |
| oObj.moveRange(sCell, newCellAddress) |
| |
| bOK = bOK AND oObj.getCellByPosition(0, 0).String = "" |
| bOK = bOK AND oObj.getCellByPosition(1, 0).String = "" |
| bOK = bOK AND oObj.getCellByPosition(0, 1).String = "" |
| bOK = bOK AND oObj.getCellByPosition(1, 1).String = "" |
| |
| bOK = bOK AND oObj.getCellByPosition(3, 3).Value = 0 |
| bOK = bOK AND oObj.getCellByPosition(3, 4).Value = 6 |
| bOK = bOK AND oObj.getCellByPosition(4, 3).Value = 1 |
| bOK = bOK AND oObj.getCellByPosition(4, 4).String = "" |
| |
| Test.MethodTested("moveRange()", bOK) |
| |
| Test.StartMethod("copyRange()") |
| bOK = true |
| newCellAddress.Sheet = 0 |
| newCellAddress.StartColumn = 2 |
| newCellAddress.StartRow = 2 |
| newCellAddress.EndColumn = 3 |
| newCellAddress.EndRow = 3 |
| sCell.Sheet = 0 |
| sCell.Column = 0 |
| sCell.Row = 0 |
| |
| oObj.copyRange(sCell, newCellAddress) |
| |
| bOK = bOK AND oObj.getCellByPosition(0, 0).Value = oObj.getCellByPosition(2, 2).Value |
| bOK = bOK AND oObj.getCellByPosition(0, 1).Value = oObj.getCellByPosition(2, 3).Value |
| bOK = bOK AND oObj.getCellByPosition(1, 0).Value = oObj.getCellByPosition(3, 2).Value |
| bOK = bOK AND oObj.getCellByPosition(1, 1).Value = oObj.getCellByPosition(3, 3).Value |
| |
| Test.MethodTested("copyRange()", bOK) |
| |
| Exit Sub |
| ErrHndl: |
| Test.Exception() |
| bOK = false |
| resume next |
| End Sub |
| </script:module> |