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' Be sure that all variables are dimensioned:
37option explicit
38
39'*************************************************************************
40' This Interface/Service test depends on the following GLOBAL variables,
41' which must be specified in the object creation:
42
43'     - Global nTableW As Integer
44'     - Global nTableH As Integer
45
46'*************************************************************************
47
48
49
50
51
52Sub RunTest()
53
54'*************************************************************************
55' INTERFACE:
56' com.sun.star.text.XTextTable
57'*************************************************************************
58On Error Goto ErrHndl
59    Dim bOK As Boolean
60    Dim i As Integer, j As Integer
61    Dim oRows As Object, oColumns As Object
62    Dim oCursor As Object, oCell As Object
63    Dim aNames As Variant
64    Dim nDscColumns As Integer, nDscRows As Integer
65
66    Test.StartMethod("initialize()")
67    bOK = true
68    ' Object is already was initialized, when it was created... So, assume that this is OK.
69
70    For i = 0 to nTableW - 1
71        For j = 0 to nTableH - 1
72            oObj.getCellByPosition(i, j).Value = i + j * nTableW
73        Next j
74    Next i
75
76    nDscColumns = ubound(oObj.getColumnDescriptions()) + 1
77    nDscRows = ubound(oObj.getRowDescriptions()) + 1
78
79    bOK = bOK AND nDscRows = nTableH AND nDscColumns = nTableW
80    if NOT bOK then
81        Out.Log("The table must have size (" + nTableW + "," + nTableH + _
82            "), but descriptions returned for size (" + nDscColumns + "," + nDscRows + ")")
83    endif
84    Test.MethodTested("initialize()", bOK)
85
86    Test.StartMethod("getRows()")
87    bOK = true
88
89    oRows = oObj.getRows()
90
91    bOK = bOK AND hasUnoInterfaces(oRows, "com.sun.star.table.XTableRows")
92    bOK = bOK AND oRows.getCount() = nTableH
93    Test.MethodTested("getRows()", bOK)
94
95    Test.StartMethod("getColumns()")
96    bOK = true
97
98    oColumns = oObj.getColumns()
99
100    bOK = bOK AND hasUnoInterfaces(oColumns, "com.sun.star.table.XTableColumns")
101    bOK = bOK AND oColumns.getCount() = nTableW
102    Test.MethodTested("getColumns()", bOK)
103
104
105    Test.StartMethod("createCursorByCellName()")
106    bOK = true
107    oCursor = oObj.createCursorByCellName("B2")
108    bOK = bOK AND hasUnoInterfaces(oCursor, "com.sun.star.text.XTextTableCursor")
109    bOK = bOK AND oCursor.getRangeName() = "B2"
110    Test.MethodTested("createCursorByCellName()", bOK)
111
112    oCursor.splitRange(1, true)
113    oCursor.splitRange(1, false)
114
115    Test.StartMethod("getCellNames()")
116    bOK = true
117    aNames = oObj.getCellNames()
118    bOK = bOK AND ubound(aNames) = nTableW * nTableH + 1 ' = nTableW * nTableH - 1 + 2(after splitting)
119    Test.MethodTested("getCellNames()", bOK)
120
121    Test.StartMethod("getCellByName()")
122    bOK = true
123    oCell = oObj.getCellByPosition(0,0)
124    oCell.String = "A1"
125    oCell = oObj.getCellByName("A1")
126    bOK = bOK AND oCell.String = "A1"
127
128    oCell = oObj.getCellByName("B2.2.1")
129    bOK = bOK AND hasUnoInterfaces(oCell, "com.sun.star.table.XCell")
130
131    Test.MethodTested("getCellByName()", bOK)
132
133    ReCreateObj()
134Exit Sub
135ErrHndl:
136    Test.Exception()
137    bOK = false
138    resume next
139End Sub
140</script:module>
141