Save As - ooBasic - Impress with charts
Save As - ooBasic - Impress with charts
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
dhw
OpenOffice 3.1 on Windows 7
OpenOffice 3.1 on Windows 7
- Charlie Young
- Volunteer
- Posts: 1559
- Joined: Fri May 14, 2010 1:07 am
Re: Save As - ooBasic - Impress with charts
I don't think "ODF Presentation" is a valid FilterName. Try "impress8" for .odp, or "MS PowerPoint 97" for PowerPoint, though there are also a number of possibilities for XML and such.whitav8 wrote: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.Code: Select all
thisComponent.storeAsUrl(sSaveToURL, Array(MakePropertyValue("FilterName", "ODF Presentation")))
Apache OpenOffice 4.1.1
Windows XP
Windows XP
Re: Save As - ooBasic - Impress with charts
Did you manage to copy the chart from calc to impress?
Could you show the code. Thank you in advance. Your code doesn't work for me.
Could you show the code. Thank you in advance. Your code doesn't work for me.
OpenOffice 3.1 ?? Windows Vista / NeoOffice 2.2.3 ?? MacOS 10.4 / OpenOffice 2.4 ?? Ubuntu 9.04
Re: Save As - ooBasic - Impress with charts
https://wiki.openoffice.org/wiki/Saving_a_document
Filterlists for various versions of the office suite:
OpenOffice
https://wiki.openoffice.org/wiki/Framew ... st_OOo_2_1
https://wiki.openoffice.org/wiki/Framew ... st_OOo_3_0
https://wiki.openoffice.org/wiki/Docume ... er_Options
LibreOffice_:
https://ask.libreoffice.org/en/question ... t-filters/
Filterlists for various versions of the office suite:
OpenOffice
https://wiki.openoffice.org/wiki/Framew ... st_OOo_2_1
https://wiki.openoffice.org/wiki/Framew ... st_OOo_3_0
https://wiki.openoffice.org/wiki/Docume ... er_Options
LibreOffice_:
https://ask.libreoffice.org/en/question ... t-filters/
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Re: Save As - ooBasic - Impress with charts
The links describe the ability to save the file in a different format.
But I need to copy the chart from calc to impress.
That is, not the whole file, only one diagram.
And unfortunately I don’t understand how to do it. = (
Perhaps you could give an example. Thank you in advance!
PS Sorry for my bad english.
But I need to copy the chart from calc to impress.
That is, not the whole file, only one diagram.
And unfortunately I don’t understand how to do it. = (
Perhaps you could give an example. Thank you in advance!
PS Sorry for my bad english.
OpenOffice 3.1 ?? Windows Vista / NeoOffice 2.2.3 ?? MacOS 10.4 / OpenOffice 2.4 ?? Ubuntu 9.04
Re: Save As - ooBasic - Impress with charts
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Re: Save As - ooBasic - Impress with charts
I can get a graph from a calc sheet and I can also get a slide where I want to insert it
But this does not work by simple =.
I guess it should work through ".uno: Paste" / ".uno: Paste" but I still can't do it. The graph does not appear.
Here (viewtopic.php?f=20&t=97044) the topic is where I ask this question and there is code to copy the slide from one ODP to another
But when I try to copy a diagram, nothing works.
But this does not work by simple =.
I guess it should work through ".uno: Paste" / ".uno: Paste" but I still can't do it. The graph does not appear.
Here (viewtopic.php?f=20&t=97044) the topic is where I ask this question and there is code to copy the slide from one ODP to another
But when I try to copy a diagram, nothing works.
OpenOffice 3.1 ?? Windows Vista / NeoOffice 2.2.3 ?? MacOS 10.4 / OpenOffice 2.4 ?? Ubuntu 9.04
Re: Save As - ooBasic - Impress with charts
A quick workaround would be to take a screenshot of the chart or diagram, then insert that into the Impress file. Of course that is a static image and would not reflect the current state of the data generating the chart.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: Save As - ooBasic - Impress with charts
It is necessary to save the diagram
OpenOffice 3.1 ?? Windows Vista / NeoOffice 2.2.3 ?? MacOS 10.4 / OpenOffice 2.4 ?? Ubuntu 9.04
Re: Save As - ooBasic - Impress with charts
Task:
1) I need from 1 calc sheet to copy 1 graph (first) and paste it on the 1st slide. Impress
How I try to do it
Can you tell me in the right direction?
1) I need from 1 calc sheet to copy 1 graph (first) and paste it on the 1st slide. Impress
How I try to do it
Code: Select all
import sys
import os
import time
import uno
import pyuno
def mergeFromExcelURL():
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)
ctx = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
desk = ctx.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)
# ODP
doc1 = desk.loadComponentFromURL(fileNameToUrl('default.odp'), "_blank", 0, ())
dispatcher = ctx.ServiceManager.createInstanceWithContext("com.sun.star.frame.DispatchHelper", ctx)
DrawPageODP = doc1.DrawPages.getByIndex(0)
ShapeODP = DrawPageODP.getByIndex(0)
ctr1 = doc1.getCurrentController()
frame1 = ctr1.Frame
#ODS
doc2 = desk.loadComponentFromURL(fileNameToUrl('bubble.ods'), "_blank", 0, ())
ctr2 = doc2.getCurrentController()
frame2 = ctr2.Frame
dispatcher.executeDispatch(frame1, ".uno:DiaMode", "", 0, ())
dispatcher.executeDispatch(frame2, ".uno:DiaMode", "", 0, ())
ChartSheet = doc2.Sheets.getByName('Chart')
DrawPage = ChartSheet.DrawPage
ChartShape = DrawPage.getByIndex(0)
Diagram = ChartShape.Model.Diagram
EmbObj = ChartShape.EmbeddedObject
#SElect2
ctr2.select(ChartShape) # This is not true most likely. probably it is necessary to choose a diagram, but it does not work. ????????????????????
dispatcher.executeDispatch(frame2, ".uno:Copy", "", 0, ())
# SElect1
ctr1.setCurrentPage(DrawPageODP) # What is there to choose? ????????????????????
dispatcher.executeDispatch(frame1, ".uno:Paste", "", 0, ())
dispatcher.executeDispatch(frame1, ".uno:DrawingMode", "", 0, ()) #?????????????????????????
outfile = "output.odp"
doc1.storeAsURL(fileNameToUrl(outfile), ())
doc1.close(False)
doc2.close(True)
OpenOffice 3.1 ?? Windows Vista / NeoOffice 2.2.3 ?? MacOS 10.4 / OpenOffice 2.4 ?? Ubuntu 9.04