merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / basic / ifc / sheet / XSpreadsheets / sheet_XSpreadsheets.xba
blob39f544cf73d7c3ab659f455ddb81c5251e01abbb
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">
6 '*************************************************************************
8 ' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9 '
10 ' Copyright 2008 by Sun Microsystems, Inc.
12 ' OpenOffice.org - a multi-platform office productivity suite
14 ' $RCSfile: sheet_XSpreadsheets.xba,v $
16 ' $Revision: 1.3 $
18 ' This file is part of OpenOffice.org.
20 ' OpenOffice.org is free software: you can redistribute it and/or modify
21 ' it under the terms of the GNU Lesser General Public License version 3
22 ' only, as published by the Free Software Foundation.
24 ' OpenOffice.org is distributed in the hope that it will be useful,
25 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
26 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 ' GNU Lesser General Public License version 3 for more details
28 ' (a copy is included in the LICENSE file that accompanied this code).
30 ' You should have received a copy of the GNU Lesser General Public License
31 ' version 3 along with OpenOffice.org. If not, see
32 ' <http://www.openoffice.org/license.html>
33 ' for a copy of the LGPLv3 License.
35 '*************************************************************************
36 '*************************************************************************
40 ' Be sure that all variables are dimensioned:
41 option explicit
43 '*************************************************************************
44 ' This Interface/Service test depends on the following GLOBAL variables,
45 ' which must be specified in the object creation:
47 ' - Global nGlobalLong As Long the number of sheets
49 '*************************************************************************
56 Sub RunTest()
58 '*************************************************************************
59 ' INTERFACE:
60 ' com.sun.star.sheet.XSpreadsheets
61 '*************************************************************************
62 On Error Goto ErrHndl
63 Dim bOK As Boolean
64 Dim l As Integer
65 Dim sname As String
66 Dim oSheet1, oSheet2 As Object
69 Test.StartMethod("insertNewByName()")
70 bOK = true
71 for l = 1 to nGlobalLong
72 sname = cIfcShortName &amp; CStr(l)
73 oObj.insertNewByName(sname, l)
74 oSheet1 = oObj.getByName(sname)
75 oSheet2 = oObj.getByIndex(l)
76 bOK = bOK AND NOT isNull(oSheet1)
77 bOK = bOK AND NOT isNull(oSheet2)
78 if (bOK) then
79 bOK = bOK and oSheet1.name = oSheet2.name
80 end if
81 next l
82 Test.MethodTested("insertNewByName()", bOK)
84 Test.StartMethod("copyByName()")
85 bOK = true
86 l = 1
87 sname = cIfcShortName &amp; "COPY"
88 oObj.copyByName(cIfcShortName &amp; CStr(l), sname, l )
89 oSheet1 = oObj.getByName(sname)
90 oSheet2 = oObj.getByIndex(l)
91 bOK = bOK AND NOT isNull(oSheet1)
92 bOK = bOK AND NOT isNull(oSheet2)
93 if (bOK) then
94 bOK = bOK AND oSheet1.name = oSheet2.name
95 end if
96 Test.MethodTested("copyByName()", bOK)
98 Test.StartMethod("moveByName()")
99 bOK = true
100 l = 1
101 sname = cIfcShortName &amp; "2"
102 oObj.moveByName(sname, l)
103 oSheet1 = oObj.getByName(sname)
104 oSheet2 = oObj.getByIndex(l)
105 bOK = bOK AND NOT isNull(oSheet1)
106 bOK = bOK AND NOT isNull(oSheet2)
107 if (bOK) then
108 bOK = bOK AND oSheet1.name = oSheet2.name
109 end if
110 Out.Log(cIfcShortName &amp; ":" &amp; "#1 - " &amp; bOK)
112 sname = cIfcShortName &amp; "COPY"
113 l = nGlobalLong + 1
114 oObj.moveByName(sname, l)
115 l = l - 1
116 oSheet1 = oObj.getByName(sname)
117 oSheet2 = oObj.getByIndex(l)
118 bOK = bOK AND NOT isNull(oSheet1)
119 bOK = bOK AND NOT isNull(oSheet2)
120 if (bOK) then
121 bOK = bOK and oSheet1.name =oSheet2.name
122 end if
123 Test.MethodTested("moveByName()", bOK)
125 nGlobalLong = nGlobalLong * 2 + 1 ' nGlobalLong : 3 default sheets where already there
126 ' nGlobalLong have been inserted
127 ' + 1 has been created by Copy
128 Exit Sub
129 ErrHndl:
130 Test.Exception()
131 bOK = false
132 resume next
133 End Sub
134 </script:module>