0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
| | Sub chart2_1
oDoc = ThisComponent
oCharts = oDoc.getSheets().getByIndex(0).getCharts()
Dim aRange(1) As New com.sun.star.table.CellRangeAddress
Dim aRectangle As New com.sun.star.awt.Rectangle
sChartName = "Chart2"
aRange(0) = make_CellRangeAddress(0, 0, 0, 2, 6)
aRange(1) = make_CellRangeAddress(0, 1, 1, 2, 6)
aRectangle = make_Rectangle(1300, 11300, 7000, 5000)
If NOT oCharts.hasByName(sChartName) Then
oCharts.addNewByName(sChartName,aRectangle,aRange,False,False)
oChartObj = oCharts.getByName(sChartName)
oChart = oCharts.getByName(sChartName).getEmbeddedObject()
oChart.setDiagram( _
oChart.createInstance("com.sun.star.chart.XYDiagram"))
oDiagram = oChart.getDiagram()
End If
End Sub
Function make_CellRangeAddress( _
nSheet As Integer, _
nStartColumn As Long, nEndColumn As Long, _
nStartRow As Long, nEndRow As Long ) _
As com.sun.star.table.CellRangeAddress
Dim aRangeAddress As New com.sun.star.table.CellRangeAddress
With aRangeAddress
.Sheet = nSheet
.StartColumn = nStartColumn
.EndColumn = nEndColumn
.StartRow = nStartRow
.EndRow = nEndRow
End With
make_CellRangeAddress = aRangeAddress
End Function
Function make_Rectangle( _
nX As Long, nY As Long, _
nWidth As Long, nHeight As Long ) _
As com.sun.star.awt.Rectangle
Dim aRectangle As New com.sun.star.awt.Rectangle
With aRectangle
.X = nX
.Y = nY
.Width = nWidth
.Height = nHeight
End With
make_Rectangle = aRectangle
End Function
|