'************************************************************************* ' ' 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. ' '************************************************************************* ' Be sure that all variables are dimensioned: option explicit ' REQUIRED VARIABLES for interface/service tests: ' Requiered for com.sun.star.lang.XComponent Global oComponentInstance As Object ' it will be disposed ' Requiered for com.sun.star.chart.XChartData Global oCellToChange As Object ' Requiered for com.sun.star.container.XNamed Global cNameToSet As String ' "fixed" if name is fixed ' Requiered for com.sun.star.chart.XChartDataArray ' Requiered for com.sun.star.text.XTextTable Global nTableW As Integer Global nTableH As Integer 'Required for sheet.XCellRangeData Global newData As Variant Global oXTextContent as Object Global oXTextContentRange as Object Sub CreateObj() '************************************************************************* ' COMPONENT: ' sw.SwXTextTable '************************************************************************* On Error Goto ErrHndl Dim oCursor As Object Dim i As Integer Dim oInstance As Object oDoc = utils.createDocument("swriter", cObjectName) oCursor = oDoc.Text.createTextCursor() nTableH = 5 nTableW = 7 for i = 1 to 2 oInstance = oDoc.createInstance("com.sun.star.text.TextTable") oInstance.initialize(nTableH, nTableW) oInstance.Name = "Table" + i ' insert created Table oDoc.Text.insertTextContent(oCursor, oInstance, false) if (i = 1) then oComponentInstance = oInstance next i oObj = oInstance oCellToChange = oObj.getCellByPosition(3, 4) cNameToSet = "NewTableName" 'Required for XCellRangeData newData() = Array(_ Array(2.5, 5.0, 2.5, 5.0, 3.0, 2.0, 1.0),_ Array(4.0, 9.0, 2.5, 5.0, 4.0, 1.0, 2.0),_ Array(2.5, 5.0, 2.5, 5.0, 3.0, 2.0, 1.0),_ Array(2.5, 5.0, 2.5, 5.0, 7.0, 7.0, 8.0),_ Array(4.0, 9.0, 2.5, 5.0, 4.0, 3.0, 2.0)) oXTextContent = oDoc.createInstance("com.sun.star.text.TextTable") oXTextContentRange = oDoc.Text.createTextCursor() Exit Sub ErrHndl: Test.Exception() End Sub Function modifyDescriptor(descr As Variant) As Variant On Error Goto ErrHndl Dim i As Integer, oCell As Object for i = 0 to nTableW - 1 oCell = oObj.getCellByPosition(i, 0) oCell.String = "" + (nTableW - i) next i for i = 0 to ubound(descr) if descr(i).Name = "SortAscending" then descr(i).Value = true if descr(i).Name = "SortColumns" then descr(i).Value = true next i modifyDescriptor() = descr Exit Function ErrHndl: Out.Log("Exception in SwXTextTable.modifyDescriptor() :") Test.Exception() end Function Function checkSort() As Boolean On Error Goto ErrHndl Dim i As Integer, oCell As Object Dim bOK As Boolean bOK = true for i = 0 to nTableW - 1 oCell = oObj.getCellByPosition(i, 0) bOK = bOK AND oCell.String = "" + (i + 1) next i checkSort() = bOK Exit Function ErrHndl: Out.Log("Exception in SwXTextTable.checkSort() :") Test.Exception() end Function