1*b1cdbd2cSJim Jagielski<?xml version="1.0" encoding="UTF-8"?>
2*b1cdbd2cSJim Jagielski<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3*b1cdbd2cSJim Jagielski<script:module xmlns:script="http://openoffice.org/2000/script" script:name="sch_ChXDiagram" script:language="StarBasic">
4*b1cdbd2cSJim Jagielski
5*b1cdbd2cSJim Jagielski
6*b1cdbd2cSJim Jagielski'*************************************************************************
7*b1cdbd2cSJim Jagielski'
8*b1cdbd2cSJim Jagielski'  Licensed to the Apache Software Foundation (ASF) under one
9*b1cdbd2cSJim Jagielski'  or more contributor license agreements.  See the NOTICE file
10*b1cdbd2cSJim Jagielski'  distributed with this work for additional information
11*b1cdbd2cSJim Jagielski'  regarding copyright ownership.  The ASF licenses this file
12*b1cdbd2cSJim Jagielski'  to you under the Apache License, Version 2.0 (the
13*b1cdbd2cSJim Jagielski'  "License"); you may not use this file except in compliance
14*b1cdbd2cSJim Jagielski'  with the License.  You may obtain a copy of the License at
15*b1cdbd2cSJim Jagielski'
16*b1cdbd2cSJim Jagielski'    http://www.apache.org/licenses/LICENSE-2.0
17*b1cdbd2cSJim Jagielski'
18*b1cdbd2cSJim Jagielski'  Unless required by applicable law or agreed to in writing,
19*b1cdbd2cSJim Jagielski'  software distributed under the License is distributed on an
20*b1cdbd2cSJim Jagielski'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21*b1cdbd2cSJim Jagielski'  KIND, either express or implied.  See the License for the
22*b1cdbd2cSJim Jagielski'  specific language governing permissions and limitations
23*b1cdbd2cSJim Jagielski'  under the License.
24*b1cdbd2cSJim Jagielski'
25*b1cdbd2cSJim Jagielski'*************************************************************************
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielski
28*b1cdbd2cSJim Jagielski
29*b1cdbd2cSJim Jagielski
30*b1cdbd2cSJim Jagielski
31*b1cdbd2cSJim Jagielski' Be sure that all variables are dimensioned:
32*b1cdbd2cSJim Jagielskioption explicit
33*b1cdbd2cSJim Jagielski
34*b1cdbd2cSJim Jagielski
35*b1cdbd2cSJim JagielskiDim nCol As Integer
36*b1cdbd2cSJim JagielskiDim nRow As Integer
37*b1cdbd2cSJim Jagielski
38*b1cdbd2cSJim Jagielski' REQUIRED VARIABLES for interface/service tests:
39*b1cdbd2cSJim JagielskiGlobal oLineDiagram As Object
40*b1cdbd2cSJim JagielskiGlobal oStackDiagram As Object
41*b1cdbd2cSJim JagielskiGlobal oStockDiagram As Object
42*b1cdbd2cSJim JagielskiGlobal oBarDiagram As Object
43*b1cdbd2cSJim JagielskiGlobal nGlobalBarDiagram As Long
44*b1cdbd2cSJim Jagielski
45*b1cdbd2cSJim Jagielski' For drawing.XShapeDescriptor
46*b1cdbd2cSJim JagielskiGlobal cShapeType As String
47*b1cdbd2cSJim Jagielski
48*b1cdbd2cSJim Jagielski
49*b1cdbd2cSJim JagielskiSub CreateObj()
50*b1cdbd2cSJim Jagielski
51*b1cdbd2cSJim Jagielski'*************************************************************************
52*b1cdbd2cSJim Jagielski' COMPONENT:
53*b1cdbd2cSJim Jagielski' sch.ChXDiagram
54*b1cdbd2cSJim Jagielski'*************************************************************************
55*b1cdbd2cSJim JagielskiOn Error Goto ErrHndl
56*b1cdbd2cSJim Jagielski    Dim oCharts As Object
57*b1cdbd2cSJim Jagielski    Dim oChart As Object
58*b1cdbd2cSJim Jagielski    Dim cType(4) As String
59*b1cdbd2cSJim Jagielski    Dim mRangeAddress(0) As New com.sun.star.table.CellRangeAddress
60*b1cdbd2cSJim Jagielski    Dim aRect As New com.sun.star.awt.Rectangle
61*b1cdbd2cSJim Jagielski    Dim n As Integer
62*b1cdbd2cSJim Jagielski
63*b1cdbd2cSJim Jagielski    oDoc = utils.createDocument("scalc", cObjectName)
64*b1cdbd2cSJim Jagielski
65*b1cdbd2cSJim Jagielski    cType(0) = "StockDiagram"
66*b1cdbd2cSJim Jagielski    cType(1) = "BarDiagram"
67*b1cdbd2cSJim Jagielski    cType(2) = "XYDiagram"
68*b1cdbd2cSJim Jagielski    cType(3) = "StackableDiagram"
69*b1cdbd2cSJim Jagielski    cType(4) = "LineDiagram"
70*b1cdbd2cSJim Jagielski
71*b1cdbd2cSJim Jagielski    nCol = 5
72*b1cdbd2cSJim Jagielski    nRow = 6
73*b1cdbd2cSJim Jagielski    FillCells()
74*b1cdbd2cSJim Jagielski
75*b1cdbd2cSJim Jagielski    aRect.Width = 5000
76*b1cdbd2cSJim Jagielski    aRect.Height = 5000
77*b1cdbd2cSJim Jagielski    mRangeAddress(0).Sheet = 0
78*b1cdbd2cSJim Jagielski    mRangeAddress(0).StartColumn = 0
79*b1cdbd2cSJim Jagielski    mRangeAddress(0).StartRow = 0
80*b1cdbd2cSJim Jagielski    mRangeAddress(0).EndColumn = nCol
81*b1cdbd2cSJim Jagielski    mRangeAddress(0).EndRow = nRow
82*b1cdbd2cSJim Jagielski
83*b1cdbd2cSJim Jagielski    for n = 0 to 4
84*b1cdbd2cSJim Jagielski        aRect.X = 500 * n
85*b1cdbd2cSJim Jagielski        aRect.Y = 3000 * n
86*b1cdbd2cSJim Jagielski        oCharts = oDoc.Sheets(0).Charts
87*b1cdbd2cSJim Jagielski        oCharts.addNewByName(cObjectName + cType(n) + n, aRect, mRangeAddress(), true, true)
88*b1cdbd2cSJim Jagielski        oChart = oCharts.getByName(cObjectName + cType(n) + n).EmbeddedObject
89*b1cdbd2cSJim Jagielski        oChart.Diagram = oChart.createInstance("com.sun.star.chart." + cType(n))
90*b1cdbd2cSJim Jagielski    next n
91*b1cdbd2cSJim Jagielski
92*b1cdbd2cSJim Jagielski    oStockDiagram = oCharts.getByName(cObjectName + cType(0) + 0).EmbeddedObject.Diagram
93*b1cdbd2cSJim Jagielski    oBarDiagram   = oCharts.getByName(cObjectName + cType(1) + 1).EmbeddedObject.Diagram
94*b1cdbd2cSJim Jagielski    oLineDiagram  = oCharts.getByName(cObjectName + cType(2) + 2).EmbeddedObject.Diagram
95*b1cdbd2cSJim Jagielski    oStackDiagram = oCharts.getByName(cObjectName + cType(3) + 3).EmbeddedObject.Diagram
96*b1cdbd2cSJim Jagielski    oObj          = oCharts.getByName(cObjectName + cType(4) + 4).EmbeddedObject.Diagram
97*b1cdbd2cSJim Jagielski
98*b1cdbd2cSJim Jagielski    nGlobalBarDiagram = 4
99*b1cdbd2cSJim Jagielski
100*b1cdbd2cSJim Jagielski    ' For drawing.XShapeDescriptor
101*b1cdbd2cSJim Jagielski    cShapeType = "com.sun.star.chart.Diagram"
102*b1cdbd2cSJim Jagielski
103*b1cdbd2cSJim JagielskiExit Sub
104*b1cdbd2cSJim JagielskiErrHndl:
105*b1cdbd2cSJim Jagielski    Test.Exception()
106*b1cdbd2cSJim JagielskiEnd Sub
107*b1cdbd2cSJim Jagielski
108*b1cdbd2cSJim JagielskiSub FillCells()
109*b1cdbd2cSJim Jagielski    Dim oCell As Object
110*b1cdbd2cSJim Jagielski    Dim oRange As Object
111*b1cdbd2cSJim Jagielski    Dim n1 As Integer
112*b1cdbd2cSJim Jagielski    Dim n2 As Integer
113*b1cdbd2cSJim Jagielski    Dim oFormats As Variant
114*b1cdbd2cSJim Jagielski    Dim nFormat As Integer
115*b1cdbd2cSJim Jagielski    Dim nKey As Integer
116*b1cdbd2cSJim Jagielski    Dim aLanguage As New com.sun.star.lang.Locale
117*b1cdbd2cSJim Jagielski
118*b1cdbd2cSJim Jagielski    oRange = oDoc.Sheets(0).getCellRangeByPosition(0, 0, nCol, nRow)
119*b1cdbd2cSJim Jagielski
120*b1cdbd2cSJim Jagielski    for n1 = 1 to nCol - 1
121*b1cdbd2cSJim Jagielski        For n2 = 1 To nRow - 1
122*b1cdbd2cSJim Jagielski            oRange.getCellByPosition(n1, n2).Value = n2 * (n1 + 1)
123*b1cdbd2cSJim Jagielski        Next n2
124*b1cdbd2cSJim Jagielski    next n1
125*b1cdbd2cSJim Jagielski
126*b1cdbd2cSJim Jagielski    for n1 = 1 to nCol - 1
127*b1cdbd2cSJim Jagielski        oRange.getCellByPosition(n1, 0).String = "Col " + n1
128*b1cdbd2cSJim Jagielski    next n1
129*b1cdbd2cSJim Jagielski    for n2 = 1 to nRow - 1
130*b1cdbd2cSJim Jagielski        oRange.getCellByPosition(0, n2).String = "Row " + n2
131*b1cdbd2cSJim Jagielski    next n2
132*b1cdbd2cSJim Jagielski
133*b1cdbd2cSJim Jagielski    oFormats = oDoc.NumberFormats
134*b1cdbd2cSJim Jagielski    nFormat = com.sun.star.util.NumberFormat.CURRENCY
135*b1cdbd2cSJim Jagielski    nKey = oFormats.getStandardFormat(nFormat, aLanguage)
136*b1cdbd2cSJim Jagielski    oRange.NumberFormat = nKey
137*b1cdbd2cSJim JagielskiEnd Sub
138*b1cdbd2cSJim Jagielski</script:module>
139