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' 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 nGlobalLong As Long the number of sheets 44 45'************************************************************************* 46 47 48 49 50 51 52Sub RunTest() 53 54'************************************************************************* 55' INTERFACE: 56' com.sun.star.sheet.XSpreadsheets 57'************************************************************************* 58On Error Goto ErrHndl 59 Dim bOK As Boolean 60 Dim l As Integer 61 Dim sname As String 62 Dim oSheet1, oSheet2 As Object 63 64 65 Test.StartMethod("insertNewByName()") 66 bOK = true 67 for l = 1 to nGlobalLong 68 sname = cIfcShortName & CStr(l) 69 oObj.insertNewByName(sname, l) 70 oSheet1 = oObj.getByName(sname) 71 oSheet2 = oObj.getByIndex(l) 72 bOK = bOK AND NOT isNull(oSheet1) 73 bOK = bOK AND NOT isNull(oSheet2) 74 if (bOK) then 75 bOK = bOK and oSheet1.name = oSheet2.name 76 end if 77 next l 78 Test.MethodTested("insertNewByName()", bOK) 79 80 Test.StartMethod("copyByName()") 81 bOK = true 82 l = 1 83 sname = cIfcShortName & "COPY" 84 oObj.copyByName(cIfcShortName & CStr(l), sname, l ) 85 oSheet1 = oObj.getByName(sname) 86 oSheet2 = oObj.getByIndex(l) 87 bOK = bOK AND NOT isNull(oSheet1) 88 bOK = bOK AND NOT isNull(oSheet2) 89 if (bOK) then 90 bOK = bOK AND oSheet1.name = oSheet2.name 91 end if 92 Test.MethodTested("copyByName()", bOK) 93 94 Test.StartMethod("moveByName()") 95 bOK = true 96 l = 1 97 sname = cIfcShortName & "2" 98 oObj.moveByName(sname, l) 99 oSheet1 = oObj.getByName(sname) 100 oSheet2 = oObj.getByIndex(l) 101 bOK = bOK AND NOT isNull(oSheet1) 102 bOK = bOK AND NOT isNull(oSheet2) 103 if (bOK) then 104 bOK = bOK AND oSheet1.name = oSheet2.name 105 end if 106 Out.Log(cIfcShortName & ":" & "#1 - " & bOK) 107 108 sname = cIfcShortName & "COPY" 109 l = nGlobalLong + 1 110 oObj.moveByName(sname, l) 111 l = l - 1 112 oSheet1 = oObj.getByName(sname) 113 oSheet2 = oObj.getByIndex(l) 114 bOK = bOK AND NOT isNull(oSheet1) 115 bOK = bOK AND NOT isNull(oSheet2) 116 if (bOK) then 117 bOK = bOK and oSheet1.name =oSheet2.name 118 end if 119 Test.MethodTested("moveByName()", bOK) 120 121 nGlobalLong = nGlobalLong * 2 + 1 ' nGlobalLong : 3 default sheets where already there 122 ' nGlobalLong have been inserted 123 ' + 1 has been created by Copy 124Exit Sub 125ErrHndl: 126 Test.Exception() 127 bOK = false 128 resume next 129End Sub 130</script:module> 131