Difference between revisions of "API/Samples/StarBasic/Impress/Insert a Chart"
From Apache OpenOffice Wiki
(Compressed the summary) |
(added some comments) |
||
| Line 9: | Line 9: | ||
<code>[starbasic] | <code>[starbasic] | ||
Sub Main | Sub Main | ||
| + | ' get the first slide | ||
Set oPage = ThisComponent.getDrawPages().getByIndex(0) | Set oPage = ThisComponent.getDrawPages().getByIndex(0) | ||
| + | ' create an OLE2Shape | ||
Set oOLEShape = ThisComponent.createInstance( "com.sun.star.drawing.OLE2Shape" ) | Set oOLEShape = ThisComponent.createInstance( "com.sun.star.drawing.OLE2Shape" ) | ||
| Line 15: | Line 17: | ||
oPage.add( oOLEShape ) | oPage.add( oOLEShape ) | ||
| − | ' make the OLE object a chart | + | ' then make the OLE object a chart. The class-id is for charts, use exactly this one |
oOLEShape.CLSID = "12dcae26-281f-416f-a234-c3086127382e" | oOLEShape.CLSID = "12dcae26-281f-416f-a234-c3086127382e" | ||
| + | ' get the chart's model for modification | ||
Set oChartModel = oOLEShape.Model | Set oChartModel = oOLEShape.Model | ||
If Not IsNull( oChartModel ) Then | If Not IsNull( oChartModel ) Then | ||
| + | ' e.g., Set a main title | ||
oChartModel.HasMainTitle = True | oChartModel.HasMainTitle = True | ||
oChartModel.Title.String = "Created via UNO API" | oChartModel.Title.String = "Created via UNO API" | ||
Revision as of 12:43, 27 August 2007
| Description: | Create a new Chart object on a slide of a presentation or the page of a draw document. |
| Programming Language: | StarBasic |
| Author: | Björn Milcke, 2007 |
[starbasic]
Sub Main
' get the first slide
Set oPage = ThisComponent.getDrawPages().getByIndex(0)
' create an OLE2Shape
Set oOLEShape = ThisComponent.createInstance( "com.sun.star.drawing.OLE2Shape" )
' important: first add the shape
oPage.add( oOLEShape )
' then make the OLE object a chart. The class-id is for charts, use exactly this one
oOLEShape.CLSID = "12dcae26-281f-416f-a234-c3086127382e"
' get the chart's model for modification
Set oChartModel = oOLEShape.Model
If Not IsNull( oChartModel ) Then
' e.g., Set a main title
oChartModel.HasMainTitle = True
oChartModel.Title.String = "Created via UNO API"
EndIf
End Sub