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