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' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7'
8' Copyright 2000, 2010 Oracle and/or its affiliates.
9'
10' OpenOffice.org - a multi-platform office productivity suite
11'
12' This file is part of OpenOffice.org.
13'
14' OpenOffice.org is free software: you can redistribute it and/or modify
15' it under the terms of the GNU Lesser General Public License version 3
16' only, as published by the Free Software Foundation.
17'
18' OpenOffice.org is distributed in the hope that it will be useful,
19' but WITHOUT ANY WARRANTY; without even the implied warranty of
20' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21' GNU Lesser General Public License version 3 for more details
22' (a copy is included in the LICENSE file that accompanied this code).
23'
24' You should have received a copy of the GNU Lesser General Public License
25' version 3 along with OpenOffice.org.  If not, see
26' <http://www.openoffice.org/license.html>
27' for a copy of the LGPLv3 License.
28'
29'*************************************************************************
30*****
31'*************************************************************************
32
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 aCellSeries(1) As Integer
39'           aCellSeries(0) = amount of rows of range
40'           aCellSeries(1) = amount of columns of range
41
42'*************************************************************************
43
44' Be sure that all variables are dimensioned:
45option explicit
46
47Sub RunTest()
48
49'*************************************************************************
50' INTERFACE:
51' com.sun.star.sheet.XCellSeries
52'*************************************************************************
53On Error Goto ErrHndl
54    Dim bOK As Boolean
55    Dim startValue as Integer
56    Dim nStep as Integer
57    Dim shouldValue as Integer
58    Dim filledValue as Integer
59    Dim endCell(2) as Integer
60    Dim n as Integer, m as Integer
61
62	startValue = 5
63    nStep = 2
64
65    ' if 'nStep' is not a divisor of 'aCellSeries' it must be calculated
66    ' the last filled cell
67    for n = 0 to 1
68        if (aCellSeries(n) mod nStep) &lt;&gt; 0 then
69            endCell(n) = aCellSeries(n) - (nStep-1)
70        else
71            endCell(n) = aCellSeries(n)
72        end if
73    next n
74    'make clean cells
75    for n = 0 to endCell(0)
76        for m = 0 to endCell(1)
77            oObj.getCellByPosition(n,m).setString("")
78        next
79    next
80    'set defined start value
81    oObj.getCellByPosition(0,0).setValue(startValue)
82    Test.StartMethod("fillAuto()")
83    bOK = TRUE
84    oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, nStep)
85    shouldValue = endCell(0) / nStep + startValue
86    filledValue = oObj.getCellByPosition(0,endCell(0)).getValue()
87 	bOK = bOK AND ( shouldValue = filledValue )
88    out.log("" + shouldValue + ":" + filledValue)
89    Test.MethodTested("fillAuto()", bOK)
90
91
92    Test.StartMethod("fillSeries()")
93    bOK = TRUE
94    out.log("fillSeries() 1/3")
95    oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, _
96    com.sun.star.sheet.FillMode.LINEAR, _
97    com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, nStep, 20000000)
98    shouldValue = endCell(0) * nStep + startValue
99    filledValue = oObj.getCellByPosition(0,endCell(0)).getValue()
100 	bOK = bOK and (shouldValue = filledValue)
101
102    out.log("fillSeries() 2/3")
103    oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT, _
104    com.sun.star.sheet.FillMode.LINEAR, _
105    com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, nStep, 20000000)
106    shouldValue = endCell(1) * nStep + startValue
107    filledValue = oObj.getCellByPosition(endCell(1),0).getValue()
108 	bOK = bOK and (shouldValue = filledValue)
109
110
111    out.log("fillSeries() 3/3")
112    oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, _
113    com.sun.star.sheet.FillMode.GROWTH, _
114    com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, nStep, 20000000)
115    shouldValue = startValue * nStep ^ endCell(0)
116    filledValue = oObj.getCellByPosition(0,endCell(0)).getValue()
117 	bOK = bOK and (shouldValue = filledValue)
118
119    Test.MethodTested("fillSeries()", bOK)
120
121Exit Sub
122ErrHndl:
123    Test.Exception()
124    bOK = false
125    resume next
126End Sub
127</script:module>
128