Save As - ooBasic - Impress with charts
Posted: Sat Dec 15, 2012 7:37 pm
I am trying to save (as) an Impress Presentation that was created with charts copied from a spreadsheet. Now I want to save (as) it preferably as a PPT but ODP would be OK.
____________________________________________________________________________________________
oSheet = ThisComponent.Sheets.getByIndex(0)
oDP = oSheet.DrawPage
oChartShape = oDP.getByIndex(0) 'get the chart
' URL = convertToURL("C:\PasteTarget.odp")
oPresentation = StarDesktop.loadComponentFromURL(URL, "_blank", 0, Array())
MyRect = oPresentation.createInstance("com.sun.star.drawing.OLE2Shape")
MyRect.CLSID = "12dcae26-281f-416f-a234-c3086127382e" 'Make the shape a chart
oDrawPage = oPresentation.DrawPages.getByIndex(0) 'Get the Draw page of the first slide
REM add the rect to the slide
oDrawPage.add(MyRect)
REM Do the actual copy of the chart
MyRect.Model.Diagram = oChartShape.Model.Diagram
______________________________________________________________________________________________________
NOW HOW Do I do a SaveAS??? I tried the following but I get an error with the storeAsURL (I tried StoreToURL as well)
___________________________________________________________________________________________________________
sPath = "E:\Flyit_FlightTest\Logs\Flyit_121412\"
sFileName = "MyTest.odp"
sSaveToURL = ConvertToURL(sPath & sFileName)
thisComponent.storeAsUrl(sSaveToURL, Array(MakePropertyValue("FilterName", "ODF Presentation")))
'StoreAs/ToURL?
___________________________________________________________________________________________________________
Function MakePropertyValue(Optional sName As String, Optional sValue) As com.sun.star.beans.PropertyValue
'-------------------------------------------------------------------
' Create and return a new com.sun.star.beans.PropertyValue
'-------------------------------------------------------------------
Dim oPropertyValue As New com.sun.star.beans.PropertyValue
If Not IsMissing(sName) Then
oPropertyValue.Name = sName
EndIf
If Not IsMissing(sValue) Then
oPropertyValue.Value = sValue
EndIf
MakePropertyValue() = oPropertyValue
End Function
____________________________________________________________________________________________
oSheet = ThisComponent.Sheets.getByIndex(0)
oDP = oSheet.DrawPage
oChartShape = oDP.getByIndex(0) 'get the chart
' URL = convertToURL("C:\PasteTarget.odp")
oPresentation = StarDesktop.loadComponentFromURL(URL, "_blank", 0, Array())
MyRect = oPresentation.createInstance("com.sun.star.drawing.OLE2Shape")
MyRect.CLSID = "12dcae26-281f-416f-a234-c3086127382e" 'Make the shape a chart
oDrawPage = oPresentation.DrawPages.getByIndex(0) 'Get the Draw page of the first slide
REM add the rect to the slide
oDrawPage.add(MyRect)
REM Do the actual copy of the chart
MyRect.Model.Diagram = oChartShape.Model.Diagram
______________________________________________________________________________________________________
NOW HOW Do I do a SaveAS??? I tried the following but I get an error with the storeAsURL (I tried StoreToURL as well)
___________________________________________________________________________________________________________
sPath = "E:\Flyit_FlightTest\Logs\Flyit_121412\"
sFileName = "MyTest.odp"
sSaveToURL = ConvertToURL(sPath & sFileName)
thisComponent.storeAsUrl(sSaveToURL, Array(MakePropertyValue("FilterName", "ODF Presentation")))
'StoreAs/ToURL?
___________________________________________________________________________________________________________
Function MakePropertyValue(Optional sName As String, Optional sValue) As com.sun.star.beans.PropertyValue
'-------------------------------------------------------------------
' Create and return a new com.sun.star.beans.PropertyValue
'-------------------------------------------------------------------
Dim oPropertyValue As New com.sun.star.beans.PropertyValue
If Not IsMissing(sName) Then
oPropertyValue.Name = sName
EndIf
If Not IsMissing(sValue) Then
oPropertyValue.Value = sValue
EndIf
MakePropertyValue() = oPropertyValue
End Function