[Solved] Inserting a chart with OO Basic

Java, C++, C#, Delphi... - Using the UNO bridges
saleem145
Posts: 130
Joined: Mon Jul 02, 2012 4:47 pm

Re: [Solved] Inserting a chart with OO Basic

Post by saleem145 »

I'm not sure what your problem is with the dialogs. You're trying to put these in an .OXT file?
Exactly. My manifest.xml looks like

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd">
<manifest:manifest xmlns:manifest="http://openoffice.org/2001/manifest">
         <manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-typelibrary;type=RDB"
                manifest:full-path="CppComponent.uno.rdb"/>
         <manifest:file-entry manifest:media-type="text/xml" manifest:full-path=Dialogs/dialog-lc.xml>
         <manifest:file-entry manifest:media-type="text/xml" manifest:full-path=Dialogs/Standard/dialog-lb.xml>
         <manifest:file-entry manifest:media-type="text/xml" manifest:full-path=Dialogs/Standard/Dialog1.xml>
         <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data"
                manifest:full-path="CalcAddIn.xcu"/>
         <manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-components"
                manifest:full-path="MakeChart.py"/>
         <manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-components;platform=MacOSX_x86"
                manifest:full-path="CppComponent.components"/>
</manifest:manifest>
My oxt, in addition to the old stuff associated with the oxt contains MakeChart.py and Dialogs subfolder. Dialogs subfolder contains Standard and dialog-lc.xml. Standard folder contains Dialog1.xml dialog-lb.xml.

When I create a hyperlink and run MakeChart I get

"A Scripting Framework error occurred while running the Python script vnd.sun.start.script:MakeChart.py$MakeChart?language=Python&location=document. Message: pythonscript.com.sun.star.ucb.ContentCreationException: Unable to create Content!"

Its complaining about getModuleByUrl() and getScript() which means it cannot find the script.
OpenOffice 3.4.0
Mac OS X 10.5.8
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: [Solved] Inserting a chart with OO Basic

Post by Charlie Young »

It looks like you're trying to treat an addon as an addin, and they are two different things. Since there is no way for an addin function to generate a chart, and since I don't really know much about addons, I think you'd better do some googling, and also maybe ask some questions in a different thread, trying to get the attention of our resident addon experts.
Apache OpenOffice 4.1.1
Windows XP
saleem145
Posts: 130
Joined: Mon Jul 02, 2012 4:47 pm

Re: [Solved] Inserting a chart with OO Basic

Post by saleem145 »

Ok another question -- how do I put in a button instead of a hyperlink. Thanks.

Saleem
OpenOffice 3.4.0
Mac OS X 10.5.8
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: [Solved] Inserting a chart with OO Basic

Post by Charlie Young »

saleem145 wrote:Ok another question -- how do I put in a button instead of a hyperlink. Thanks.

Saleem
View > Toolbars > Form Controls. Insert a button, then assign the macro under Control > Events > Execute Action.
Apache OpenOffice 4.1.1
Windows XP
saleem145
Posts: 130
Joined: Mon Jul 02, 2012 4:47 pm

Re: [Solved] Inserting a chart with OO Basic

Post by saleem145 »

Yes I know this. But there is no macro, only the url?? How can I deal with the url. You mentioned it was complicated, so if it's not too complicated I would like to replace the hyperlink with a macro and button
OpenOffice 3.4.0
Mac OS X 10.5.8
saleem145
Posts: 130
Joined: Mon Jul 02, 2012 4:47 pm

Re: [Solved] Inserting a chart with OO Basic

Post by saleem145 »

I have figured this one out --

Code: Select all

Const URL_Main = "vnd.sun.star.script:MakeChart.py$" 
Const URL_Args = "?language=Python&location=document"
 
sub Main
 
   Dim scriptPro As Object, myScript As Object
    
   scriptPro = ThisComponent.getScriptProvider()
 
   sURL = URL_Main & "MakeChart" & URL_Args 
 
   myScript = scriptPro.getScript(sURL)

   myScript.invoke(Array(), Array(), Array()) 

end sub
The macro can be called when a button is clicked...and it will call the python code...not sure if there is a simpler way to do it.

I wish I could package the whole thing in an addon.
OpenOffice 3.4.0
Mac OS X 10.5.8
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: [Solved] Inserting a chart with OO Basic

Post by Charlie Young »

saleem145 wrote:I have figured this one out --

Code: Select all

Const URL_Main = "vnd.sun.star.script:MakeChart.py$" 
Const URL_Args = "?language=Python&location=document"
 
sub Main
 
   Dim scriptPro As Object, myScript As Object
    
   scriptPro = ThisComponent.getScriptProvider()
 
   sURL = URL_Main & "MakeChart" & URL_Args 
 
   myScript = scriptPro.getScript(sURL)

   myScript.invoke(Array(), Array(), Array()) 

end sub
The macro can be called when a button is clicked...and it will call the python code...not sure if there is a simpler way to do it.

I wish I could package the whole thing in an addon.
The Python macro should be directly accessible to a button without having to wrap it in Basic. I see you're making some progress with the addon, I'm hoping to learn something from that.
Apache OpenOffice 4.1.1
Windows XP
Post Reply