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="sheet_XSpreadsheets" script:language="StarBasic"> 4 5 6'************************************************************************* 7' 8' Licensed to the Apache Software Foundation (ASF) under one 9' or more contributor license agreements. See the NOTICE file 10' distributed with this work for additional information 11' regarding copyright ownership. The ASF licenses this file 12' to you under the Apache License, Version 2.0 (the 13' "License"); you may not use this file except in compliance 14' with the License. You may obtain a copy of the License at 15' 16' http://www.apache.org/licenses/LICENSE-2.0 17' 18' Unless required by applicable law or agreed to in writing, 19' software distributed under the License is distributed on an 20' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21' KIND, either express or implied. See the License for the 22' specific language governing permissions and limitations 23' under the License. 24' 25'************************************************************************* 26 27 28 29 30 31' Be sure that all variables are dimensioned: 32option explicit 33 34'************************************************************************* 35' This Interface/Service test depends on the following GLOBAL variables, 36' which must be specified in the object creation: 37 38' - Global nGlobalLong As Long the number of sheets 39 40'************************************************************************* 41 42 43 44 45 46 47Sub RunTest() 48 49'************************************************************************* 50' INTERFACE: 51' com.sun.star.sheet.XSpreadsheets 52'************************************************************************* 53On Error Goto ErrHndl 54 Dim bOK As Boolean 55 Dim l As Integer 56 Dim sname As String 57 Dim oSheet1, oSheet2 As Object 58 59 60 Test.StartMethod("insertNewByName()") 61 bOK = true 62 for l = 1 to nGlobalLong 63 sname = cIfcShortName & CStr(l) 64 oObj.insertNewByName(sname, l) 65 oSheet1 = oObj.getByName(sname) 66 oSheet2 = oObj.getByIndex(l) 67 bOK = bOK AND NOT isNull(oSheet1) 68 bOK = bOK AND NOT isNull(oSheet2) 69 if (bOK) then 70 bOK = bOK and oSheet1.name = oSheet2.name 71 end if 72 next l 73 Test.MethodTested("insertNewByName()", bOK) 74 75 Test.StartMethod("copyByName()") 76 bOK = true 77 l = 1 78 sname = cIfcShortName & "COPY" 79 oObj.copyByName(cIfcShortName & CStr(l), sname, l ) 80 oSheet1 = oObj.getByName(sname) 81 oSheet2 = oObj.getByIndex(l) 82 bOK = bOK AND NOT isNull(oSheet1) 83 bOK = bOK AND NOT isNull(oSheet2) 84 if (bOK) then 85 bOK = bOK AND oSheet1.name = oSheet2.name 86 end if 87 Test.MethodTested("copyByName()", bOK) 88 89 Test.StartMethod("moveByName()") 90 bOK = true 91 l = 1 92 sname = cIfcShortName & "2" 93 oObj.moveByName(sname, l) 94 oSheet1 = oObj.getByName(sname) 95 oSheet2 = oObj.getByIndex(l) 96 bOK = bOK AND NOT isNull(oSheet1) 97 bOK = bOK AND NOT isNull(oSheet2) 98 if (bOK) then 99 bOK = bOK AND oSheet1.name = oSheet2.name 100 end if 101 Out.Log(cIfcShortName & ":" & "#1 - " & bOK) 102 103 sname = cIfcShortName & "COPY" 104 l = nGlobalLong + 1 105 oObj.moveByName(sname, l) 106 l = l - 1 107 oSheet1 = oObj.getByName(sname) 108 oSheet2 = oObj.getByIndex(l) 109 bOK = bOK AND NOT isNull(oSheet1) 110 bOK = bOK AND NOT isNull(oSheet2) 111 if (bOK) then 112 bOK = bOK and oSheet1.name =oSheet2.name 113 end if 114 Test.MethodTested("moveByName()", bOK) 115 116 nGlobalLong = nGlobalLong * 2 + 1 ' nGlobalLong : 3 default sheets where already there 117 ' nGlobalLong have been inserted 118 ' + 1 has been created by Copy 119Exit Sub 120ErrHndl: 121 Test.Exception() 122 bOK = false 123 resume next 124End Sub 125</script:module> 126