Page 2 of 2

Re: [Solved] Inserting a chart with OO Basic

Posted: Sun Jul 29, 2012 12:44 pm
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.

Re: [Solved] Inserting a chart with OO Basic

Posted: Sun Jul 29, 2012 5:06 pm
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.

Re: [Solved] Inserting a chart with OO Basic

Posted: Sun Jul 29, 2012 5:45 pm
by saleem145
Ok another question -- how do I put in a button instead of a hyperlink. Thanks.

Saleem

Re: [Solved] Inserting a chart with OO Basic

Posted: Sun Jul 29, 2012 5:52 pm
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.

Re: [Solved] Inserting a chart with OO Basic

Posted: Mon Jul 30, 2012 2:32 am
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

Re: [Solved] Inserting a chart with OO Basic

Posted: Mon Jul 30, 2012 5:30 pm
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.

Re: [Solved] Inserting a chart with OO Basic

Posted: Tue Jul 31, 2012 7:13 am
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.