1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="text_XTextTable" script:language="StarBasic">
4
5
6'*************************************************************************
7'
8' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9'
10' Copyright 2000, 2010 Oracle and/or its affiliates.
11'
12' OpenOffice.org - a multi-platform office productivity suite
13'
14' This file is part of OpenOffice.org.
15'
16' OpenOffice.org is free software: you can redistribute it and/or modify
17' it under the terms of the GNU Lesser General Public License version 3
18' only, as published by the Free Software Foundation.
19'
20' OpenOffice.org is distributed in the hope that it will be useful,
21' but WITHOUT ANY WARRANTY; without even the implied warranty of
22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23' GNU Lesser General Public License version 3 for more details
24' (a copy is included in the LICENSE file that accompanied this code).
25'
26' You should have received a copy of the GNU Lesser General Public License
27' version 3 along with OpenOffice.org.  If not, see
28' <http://www.openoffice.org/license.html>
29' for a copy of the LGPLv3 License.
30'
31'*************************************************************************
32*****
33'*************************************************************************
34
35
36
37' Be sure that all variables are dimensioned:
38option explicit
39
40'*************************************************************************
41' This Interface/Service test depends on the following GLOBAL variables,
42' which must be specified in the object creation:
43
44'     - Global nTableW As Integer
45'     - Global nTableH As Integer
46
47'*************************************************************************
48
49
50
51
52
53Sub RunTest()
54
55'*************************************************************************
56' INTERFACE:
57' com.sun.star.text.XTextTable
58'*************************************************************************
59On Error Goto ErrHndl
60    Dim bOK As Boolean
61    Dim i As Integer, j As Integer
62    Dim oRows As Object, oColumns As Object
63    Dim oCursor As Object, oCell As Object
64    Dim aNames As Variant
65    Dim nDscColumns As Integer, nDscRows As Integer
66
67    Test.StartMethod("initialize()")
68    bOK = true
69    ' Object is already was initialized, when it was created... So, assume that this is OK.
70
71    For i = 0 to nTableW - 1
72        For j = 0 to nTableH - 1
73            oObj.getCellByPosition(i, j).Value = i + j * nTableW
74        Next j
75    Next i
76
77    nDscColumns = ubound(oObj.getColumnDescriptions()) + 1
78    nDscRows = ubound(oObj.getRowDescriptions()) + 1
79
80    bOK = bOK AND nDscRows = nTableH AND nDscColumns = nTableW
81    if NOT bOK then
82        Out.Log("The table must have size (" + nTableW + "," + nTableH + _
83            "), but descriptions returned for size (" + nDscColumns + "," + nDscRows + ")")
84    endif
85    Test.MethodTested("initialize()", bOK)
86
87    Test.StartMethod("getRows()")
88    bOK = true
89
90    oRows = oObj.getRows()
91
92    bOK = bOK AND hasUnoInterfaces(oRows, "com.sun.star.table.XTableRows")
93    bOK = bOK AND oRows.getCount() = nTableH
94    Test.MethodTested("getRows()", bOK)
95
96    Test.StartMethod("getColumns()")
97    bOK = true
98
99    oColumns = oObj.getColumns()
100
101    bOK = bOK AND hasUnoInterfaces(oColumns, "com.sun.star.table.XTableColumns")
102    bOK = bOK AND oColumns.getCount() = nTableW
103    Test.MethodTested("getColumns()", bOK)
104
105
106    Test.StartMethod("createCursorByCellName()")
107    bOK = true
108    oCursor = oObj.createCursorByCellName("B2")
109    bOK = bOK AND hasUnoInterfaces(oCursor, "com.sun.star.text.XTextTableCursor")
110    bOK = bOK AND oCursor.getRangeName() = "B2"
111    Test.MethodTested("createCursorByCellName()", bOK)
112
113    oCursor.splitRange(1, true)
114    oCursor.splitRange(1, false)
115
116    Test.StartMethod("getCellNames()")
117    bOK = true
118    aNames = oObj.getCellNames()
119    bOK = bOK AND ubound(aNames) = nTableW * nTableH + 1 ' = nTableW * nTableH - 1 + 2(after splitting)
120    Test.MethodTested("getCellNames()", bOK)
121
122    Test.StartMethod("getCellByName()")
123    bOK = true
124    oCell = oObj.getCellByPosition(0,0)
125    oCell.String = "A1"
126    oCell = oObj.getCellByName("A1")
127    bOK = bOK AND oCell.String = "A1"
128
129    oCell = oObj.getCellByName("B2.2.1")
130    bOK = bOK AND hasUnoInterfaces(oCell, "com.sun.star.table.XCell")
131
132    Test.MethodTested("getCellByName()", bOK)
133
134    ReCreateObj()
135Exit Sub
136ErrHndl:
137    Test.Exception()
138    bOK = false
139    resume next
140End Sub
141</script:module>
142