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' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9'
10' Copyright 2000, 2010 Oracle and/or its affiliates.
11'
12' OpenOffice.org - a multi-platform office productivity suite
13'
14' This file is part of OpenOffice.org.
15'
16' OpenOffice.org is free software: you can redistribute it and/or modify
17' it under the terms of the GNU Lesser General Public License version 3
18' only, as published by the Free Software Foundation.
19'
20' OpenOffice.org is distributed in the hope that it will be useful,
21' but WITHOUT ANY WARRANTY; without even the implied warranty of
22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23' GNU Lesser General Public License version 3 for more details
24' (a copy is included in the LICENSE file that accompanied this code).
25'
26' You should have received a copy of the GNU Lesser General Public License
27' version 3 along with OpenOffice.org.  If not, see
28' <http://www.openoffice.org/license.html>
29' for a copy of the LGPLv3 License.
30'
31'*************************************************************************
32'*************************************************************************
33
34
35
36' Be sure that all variables are dimensioned:
37option explicit
38
39
40Dim nCol As Integer
41Dim nRow As Integer
42
43' REQUIRED VARIABLES for interface/service tests:
44Global oLineDiagram As Object
45Global oStackDiagram As Object
46Global oStockDiagram As Object
47Global oBarDiagram As Object
48Global nGlobalBarDiagram As Long
49
50' For drawing.XShapeDescriptor
51Global cShapeType As String
52
53
54Sub CreateObj()
55
56'*************************************************************************
57' COMPONENT:
58' sch.ChXDiagram
59'*************************************************************************
60On Error Goto ErrHndl
61    Dim oCharts As Object
62    Dim oChart As Object
63    Dim cType(4) As String
64    Dim mRangeAddress(0) As New com.sun.star.table.CellRangeAddress
65    Dim aRect As New com.sun.star.awt.Rectangle
66    Dim n As Integer
67
68    oDoc = utils.createDocument("scalc", cObjectName)
69
70    cType(0) = "StockDiagram"
71    cType(1) = "BarDiagram"
72    cType(2) = "XYDiagram"
73    cType(3) = "StackableDiagram"
74    cType(4) = "LineDiagram"
75
76    nCol = 5
77    nRow = 6
78    FillCells()
79
80    aRect.Width = 5000
81    aRect.Height = 5000
82    mRangeAddress(0).Sheet = 0
83    mRangeAddress(0).StartColumn = 0
84    mRangeAddress(0).StartRow = 0
85    mRangeAddress(0).EndColumn = nCol
86    mRangeAddress(0).EndRow = nRow
87
88    for n = 0 to 4
89        aRect.X = 500 * n
90        aRect.Y = 3000 * n
91        oCharts = oDoc.Sheets(0).Charts
92        oCharts.addNewByName(cObjectName + cType(n) + n, aRect, mRangeAddress(), true, true)
93        oChart = oCharts.getByName(cObjectName + cType(n) + n).EmbeddedObject
94        oChart.Diagram = oChart.createInstance("com.sun.star.chart." + cType(n))
95    next n
96
97    oStockDiagram = oCharts.getByName(cObjectName + cType(0) + 0).EmbeddedObject.Diagram
98    oBarDiagram   = oCharts.getByName(cObjectName + cType(1) + 1).EmbeddedObject.Diagram
99    oLineDiagram  = oCharts.getByName(cObjectName + cType(2) + 2).EmbeddedObject.Diagram
100    oStackDiagram = oCharts.getByName(cObjectName + cType(3) + 3).EmbeddedObject.Diagram
101    oObj          = oCharts.getByName(cObjectName + cType(4) + 4).EmbeddedObject.Diagram
102
103    nGlobalBarDiagram = 4
104
105    ' For drawing.XShapeDescriptor
106    cShapeType = "com.sun.star.chart.Diagram"
107
108Exit Sub
109ErrHndl:
110    Test.Exception()
111End Sub
112
113Sub FillCells()
114    Dim oCell As Object
115    Dim oRange As Object
116    Dim n1 As Integer
117    Dim n2 As Integer
118    Dim oFormats As Variant
119    Dim nFormat As Integer
120    Dim nKey As Integer
121    Dim aLanguage As New com.sun.star.lang.Locale
122
123    oRange = oDoc.Sheets(0).getCellRangeByPosition(0, 0, nCol, nRow)
124
125    for n1 = 1 to nCol - 1
126        For n2 = 1 To nRow - 1
127            oRange.getCellByPosition(n1, n2).Value = n2 * (n1 + 1)
128        Next n2
129    next n1
130
131    for n1 = 1 to nCol - 1
132        oRange.getCellByPosition(n1, 0).String = "Col " + n1
133    next n1
134    for n2 = 1 to nRow - 1
135        oRange.getCellByPosition(0, n2).String = "Row " + n2
136    next n2
137
138    oFormats = oDoc.NumberFormats
139    nFormat = com.sun.star.util.NumberFormat.CURRENCY
140    nKey = oFormats.getStandardFormat(nFormat, aLanguage)
141    oRange.NumberFormat = nKey
142End Sub
143</script:module>
144