Update ooo320-m1
[ooovba.git] / qadevOOo / tests / basic / ifc / sheet / XNamedRanges / sheet_XNamedRanges.xba
blobd9ec5f6510382b096a71663bfac3582c6b98180f
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_XNamedRanges" 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_XNamedRanges.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
45 Sub RunTest()
47 '*************************************************************************
48 ' INTERFACE:
49 ' com.sun.star.sheet.XNamedRanges
50 '*************************************************************************
51 On Error Goto ErrHndl
52 Dim bOK As Boolean
53 Dim count As Integer
54 Dim outRange As New com.sun.star.table.CellAddress
55 Dim range As New com.sun.star.table.CellRangeAddress
56 Dim i As Integer
58 Test.StartMethod("addNewByName()")
59 bOK = true
60 outRange.Sheet = 0
61 outRange.Row = 1
62 outRange.Column = 1
63 count = oObj.Count
64 oObj.addNewByName(cIfcShortName, "T4:Y7", outRange, 0)
65 bOK = bOK AND oObj.count = count + 1
66 bOK = bOK AND oObj.hasByName(cIfcShortName)
67 Test.MethodTested("addNewByName()", bOK)
69 Test.StartMethod("addNewFromTitles()")
70 bOK = true
71 count = oObj.count
73 range.Sheet = 0
74 range.StartRow = 1
75 range.StartColumn = 2
76 range.EndRow = 3
77 range.EndColumn = 4
79 for i = 1 to 5
80 oDoc.Sheets(0).getCellByPosition(i, 1).String = "Col" &amp; i
81 next i
83 oObj.addNewFromTitles(range, com.sun.star.sheet.Border.TOP)
85 bOK = bOK AND (oObj.count = count + 3)
87 bOK = bOK AND NOT oObj.hasByName("Col1")
88 bOK = bOK AND oObj.hasByName("Col2")
89 bOK = bOK AND oObj.hasByName("Col3")
90 bOK = bOK AND oObj.hasByName("Col4")
91 bOK = bOK AND NOT oObj.hasByName("Col5")
92 Test.MethodTested("addNewFromTitles()", bOK)
94 Test.StartMethod("removeByName()")
95 bOK = true
96 count = oObj.Count
97 oObj.removeByName(cIfcShortName)
98 bOK = bOK AND (count = oObj.count + 1)
99 bOK = bOK AND NOT oObj.hasByName(cIfcShortName)
100 Test.MethodTested("removeByName()", bOK)
102 Test.StartMethod("outputList()")
103 bOK = true
104 outRange.Sheet = 0
105 outRange.Row = 5
106 outRange.Column = 5
108 count = oObj.count
109 for i = 4 to 5 + count
110 oDoc.Sheets(0).getCellByPosition(5, i).String = "a"
111 oDoc.Sheets(0).getCellByPosition(6, i).String = "b"
112 next i
114 oObj.outputList(outRange)
116 bOK = bOK AND oDoc.Sheets(0).getCellByPosition(5, 4).String = "a"
117 bOK = bOK AND oDoc.Sheets(0).getCellByPosition(6, 4).String = "b"
118 bOK = bOK AND oDoc.Sheets(0).getCellByPosition(5, 5 + count).String = "a"
119 bOK = bOK AND oDoc.Sheets(0).getCellByPosition(6, 5 + count).String = "b"
121 for i = 5 to 4 + count
122 bOK = bOK AND oDoc.Sheets(0).getCellByPosition(5, i).String &lt;&gt; "a"
123 bOK = bOK AND oDoc.Sheets(0).getCellByPosition(6, i).String &lt;&gt; "b"
124 bOK = bOK AND oObj.hasByName(oDoc.Sheets(0).getCellByPosition(5, i).String)
125 next i
127 Test.MethodTested("outputList()", bOK)
129 Exit Sub
130 ErrHndl:
131 Test.Exception()
132 bOK = false
133 resume next
134 End Sub
135 </script:module>