1<?xml version="1.0" encoding="UTF-8"?>
2<script:module xmlns:script="http://openoffice.org/2000/script" script:name="sheet_XCellSeries" script:language="StarBasic">
3
4'*************************************************************************
5'
6'  Licensed to the Apache Software Foundation (ASF) under one
7'  or more contributor license agreements.  See the NOTICE file
8'  distributed with this work for additional information
9'  regarding copyright ownership.  The ASF licenses this file
10'  to you under the Apache License, Version 2.0 (the
11'  "License"); you may not use this file except in compliance
12'  with the License.  You may obtain a copy of the License at
13'
14'    http://www.apache.org/licenses/LICENSE-2.0
15'
16'  Unless required by applicable law or agreed to in writing,
17'  software distributed under the License is distributed on an
18'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19'  KIND, either express or implied.  See the License for the
20'  specific language governing permissions and limitations
21'  under the License.
22'
23'*************************************************************************
24
25
26
27
28'*************************************************************************
29' This Interface/Service test depends on the following GLOBAL variables,
30' which must be specified in the object creation:
31
32' - Global aCellSeries(1) As Integer
33'           aCellSeries(0) = amount of rows of range
34'           aCellSeries(1) = amount of columns of range
35
36'*************************************************************************
37
38' Be sure that all variables are dimensioned:
39option explicit
40
41Sub RunTest()
42
43'*************************************************************************
44' INTERFACE:
45' com.sun.star.sheet.XCellSeries
46'*************************************************************************
47On Error Goto ErrHndl
48    Dim bOK As Boolean
49    Dim startValue as Integer
50    Dim nStep as Integer
51    Dim shouldValue as Integer
52    Dim filledValue as Integer
53    Dim endCell(2) as Integer
54    Dim n as Integer, m as Integer
55
56	startValue = 5
57    nStep = 2
58
59    ' if 'nStep' is not a divisor of 'aCellSeries' it must be calculated
60    ' the last filled cell
61    for n = 0 to 1
62        if (aCellSeries(n) mod nStep) &lt;&gt; 0 then
63            endCell(n) = aCellSeries(n) - (nStep-1)
64        else
65            endCell(n) = aCellSeries(n)
66        end if
67    next n
68    'make clean cells
69    for n = 0 to endCell(0)
70        for m = 0 to endCell(1)
71            oObj.getCellByPosition(n,m).setString("")
72        next
73    next
74    'set defined start value
75    oObj.getCellByPosition(0,0).setValue(startValue)
76    Test.StartMethod("fillAuto()")
77    bOK = TRUE
78    oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, nStep)
79    shouldValue = endCell(0) / nStep + startValue
80    filledValue = oObj.getCellByPosition(0,endCell(0)).getValue()
81 	bOK = bOK AND ( shouldValue = filledValue )
82    out.log("" + shouldValue + ":" + filledValue)
83    Test.MethodTested("fillAuto()", bOK)
84
85
86    Test.StartMethod("fillSeries()")
87    bOK = TRUE
88    out.log("fillSeries() 1/3")
89    oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, _
90    com.sun.star.sheet.FillMode.LINEAR, _
91    com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, nStep, 20000000)
92    shouldValue = endCell(0) * nStep + startValue
93    filledValue = oObj.getCellByPosition(0,endCell(0)).getValue()
94 	bOK = bOK and (shouldValue = filledValue)
95
96    out.log("fillSeries() 2/3")
97    oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT, _
98    com.sun.star.sheet.FillMode.LINEAR, _
99    com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, nStep, 20000000)
100    shouldValue = endCell(1) * nStep + startValue
101    filledValue = oObj.getCellByPosition(endCell(1),0).getValue()
102 	bOK = bOK and (shouldValue = filledValue)
103
104
105    out.log("fillSeries() 3/3")
106    oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, _
107    com.sun.star.sheet.FillMode.GROWTH, _
108    com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, nStep, 20000000)
109    shouldValue = startValue * nStep ^ endCell(0)
110    filledValue = oObj.getCellByPosition(0,endCell(0)).getValue()
111 	bOK = bOK and (shouldValue = filledValue)
112
113    Test.MethodTested("fillSeries()", bOK)
114
115Exit Sub
116ErrHndl:
117    Test.Exception()
118    bOK = false
119    resume next
120End Sub
121</script:module>
122