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="sw_SwXTextTable" 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
41' REQUIRED VARIABLES for interface/service tests:
42
43' Requiered for  com.sun.star.lang.XComponent
44 Global oComponentInstance As Object ' it will be disposed
45
46' Requiered for  com.sun.star.chart.XChartData
47 Global oCellToChange As Object
48
49' Requiered for  com.sun.star.container.XNamed
50 Global cNameToSet As String ' "fixed" if name is fixed
51
52' Requiered for  com.sun.star.chart.XChartDataArray
53' Requiered for  com.sun.star.text.XTextTable
54 Global nTableW As Integer
55 Global nTableH As Integer
56
57'Required for sheet.XCellRangeData
58Global newData As Variant
59
60Global oXTextContent as Object
61Global oXTextContentRange as Object
62
63
64Sub CreateObj()
65
66'*************************************************************************
67' COMPONENT:
68' sw.SwXTextTable
69'*************************************************************************
70On Error Goto ErrHndl
71    Dim oCursor As Object
72    Dim i As Integer
73    Dim oInstance As Object
74
75    oDoc = utils.createDocument("swriter", cObjectName)
76    oCursor = oDoc.Text.createTextCursor()
77
78    nTableH = 5
79    nTableW = 7
80
81    for i = 1 to 2
82        oInstance = oDoc.createInstance("com.sun.star.text.TextTable")
83        oInstance.initialize(nTableH, nTableW)
84        oInstance.Name = "Table" + i
85        ' insert created Table
86        oDoc.Text.insertTextContent(oCursor, oInstance, false)
87        if (i = 1) then oComponentInstance = oInstance
88    next i
89
90    oObj = oInstance
91    oCellToChange = oObj.getCellByPosition(3, 4)
92    cNameToSet = "NewTableName"
93
94    'Required for XCellRangeData
95    newData() = Array(_
96                Array(2.5, 5.0, 2.5, 5.0, 3.0, 2.0, 1.0),_
97                Array(4.0, 9.0, 2.5, 5.0, 4.0, 1.0, 2.0),_
98                Array(2.5, 5.0, 2.5, 5.0, 3.0, 2.0, 1.0),_
99                Array(2.5, 5.0, 2.5, 5.0, 7.0, 7.0, 8.0),_
100                Array(4.0, 9.0, 2.5, 5.0, 4.0, 3.0, 2.0))
101
102	oXTextContent = oDoc.createInstance("com.sun.star.text.TextTable")
103	oXTextContentRange = oDoc.Text.createTextCursor()
104
105Exit Sub
106ErrHndl:
107    Test.Exception()
108End Sub
109
110Function modifyDescriptor(descr As Variant) As Variant
111On Error Goto ErrHndl
112    Dim i As Integer, oCell As Object
113
114    for i = 0 to nTableW - 1
115        oCell = oObj.getCellByPosition(i, 0)
116        oCell.String = "" + (nTableW - i)
117    next i
118
119    for i = 0 to ubound(descr)
120        if descr(i).Name = "SortAscending" then descr(i).Value = true
121        if descr(i).Name = "SortColumns" then descr(i).Value = true
122    next i
123
124    modifyDescriptor() = descr
125Exit Function
126ErrHndl:
127    Out.Log("Exception in SwXTextTable.modifyDescriptor() :")
128    Test.Exception()
129end Function
130
131Function checkSort() As Boolean
132On Error Goto ErrHndl
133    Dim i As Integer, oCell As Object
134    Dim bOK As Boolean
135
136    bOK = true
137    for i = 0 to nTableW - 1
138        oCell = oObj.getCellByPosition(i, 0)
139        bOK = bOK AND oCell.String = "" + (i + 1)
140    next i
141
142    checkSort() = bOK
143Exit Function
144ErrHndl:
145    Out.Log("Exception in SwXTextTable.checkSort() :")
146    Test.Exception()
147end Function
148</script:module>
149