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