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' This Interface/Service test depends on the following GLOBAL variables,
35' which must be specified in the object creation:
36
37' - Global aCellSeries(1) As Integer
38'           aCellSeries(0) = amount of rows of range
39'           aCellSeries(1) = amount of columns of range
40
41'*************************************************************************
42
43' Be sure that all variables are dimensioned:
44option explicit
45
46Sub RunTest()
47
48'*************************************************************************
49' INTERFACE:
50' com.sun.star.sheet.XCellSeries
51'*************************************************************************
52On Error Goto ErrHndl
53    Dim bOK As Boolean
54    Dim startValue as Integer
55    Dim nStep as Integer
56    Dim shouldValue as Integer
57    Dim filledValue as Integer
58    Dim endCell(2) as Integer
59    Dim n as Integer, m as Integer
60
61	startValue = 5
62    nStep = 2
63
64    ' if 'nStep' is not a divisor of 'aCellSeries' it must be calculated
65    ' the last filled cell
66    for n = 0 to 1
67        if (aCellSeries(n) mod nStep) &lt;&gt; 0 then
68            endCell(n) = aCellSeries(n) - (nStep-1)
69        else
70            endCell(n) = aCellSeries(n)
71        end if
72    next n
73    'make clean cells
74    for n = 0 to endCell(0)
75        for m = 0 to endCell(1)
76            oObj.getCellByPosition(n,m).setString("")
77        next
78    next
79    'set defined start value
80    oObj.getCellByPosition(0,0).setValue(startValue)
81    Test.StartMethod("fillAuto()")
82    bOK = TRUE
83    oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, nStep)
84    shouldValue = endCell(0) / nStep + startValue
85    filledValue = oObj.getCellByPosition(0,endCell(0)).getValue()
86 	bOK = bOK AND ( shouldValue = filledValue )
87    out.log("" + shouldValue + ":" + filledValue)
88    Test.MethodTested("fillAuto()", bOK)
89
90
91    Test.StartMethod("fillSeries()")
92    bOK = TRUE
93    out.log("fillSeries() 1/3")
94    oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, _
95    com.sun.star.sheet.FillMode.LINEAR, _
96    com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, nStep, 20000000)
97    shouldValue = endCell(0) * nStep + startValue
98    filledValue = oObj.getCellByPosition(0,endCell(0)).getValue()
99 	bOK = bOK and (shouldValue = filledValue)
100
101    out.log("fillSeries() 2/3")
102    oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT, _
103    com.sun.star.sheet.FillMode.LINEAR, _
104    com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, nStep, 20000000)
105    shouldValue = endCell(1) * nStep + startValue
106    filledValue = oObj.getCellByPosition(endCell(1),0).getValue()
107 	bOK = bOK and (shouldValue = filledValue)
108
109
110    out.log("fillSeries() 3/3")
111    oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, _
112    com.sun.star.sheet.FillMode.GROWTH, _
113    com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, nStep, 20000000)
114    shouldValue = startValue * nStep ^ endCell(0)
115    filledValue = oObj.getCellByPosition(0,endCell(0)).getValue()
116 	bOK = bOK and (shouldValue = filledValue)
117
118    Test.MethodTested("fillSeries()", bOK)
119
120Exit Sub
121ErrHndl:
122    Test.Exception()
123    bOK = false
124    resume next
125End Sub
126</script:module>
127