Apache OpenOffice (AOO) Bugzilla – Full Text Issue Listing |
Summary: | To support getInvocationContext in Python scripts | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | App Dev | Reporter: | hanya <hanya.runo> | ||||||||
Component: | scripting | Assignee: | kay.ramme | ||||||||
Status: | CLOSED FIXED | QA Contact: | |||||||||
Severity: | Normal | ||||||||||
Priority: | P5 (lowest) | CC: | arielch, issues | ||||||||
Version: | 3.3.0 or older (OOo) | ||||||||||
Target Milestone: | 4.0.0 | ||||||||||
Hardware: | PC | ||||||||||
OS: | All | ||||||||||
Issue Type: | PATCH | Latest Confirmation in: | --- | ||||||||
Developer Difficulty: | --- | ||||||||||
Attachments: |
|
Created attachment 76856 [details]
Simple test for invocation context of python script
Attached file containes a form document which has two button on it. One for Python text and another for Java's example.
When Java button is pushed, getDocument method returns the object of Base docuemnt and getInvocationContext method returns the form document object. It should be the same in Python scripting.
When Python button is pushed, getDocument should be Base document and getInvocationContext should be Text document.
The test scripts are the same as follows:
Python test
def hello(*args):
doc = XSCRIPTCONTEXT.getDocument()
inv = XSCRIPTCONTEXT.getInvocationContext()
base_doc = doc.supportsService("com.sun.star.sdb.OfficeDatabaseDocument")
text_doc = inv.supportsService("com.sun.star.text.TextDocument")
text = inv.getText()
text.setString(
"Python\n" +
("getDocument is Base Document?: %s\n" % base_doc) +
("getInvocationContext is Text Document?: %s" % text_doc))
Code for Java.
package test.macro;
import com.sun.star.awt.ActionEvent;
import com.sun.star.document.XScriptInvocationContext;
import com.sun.star.frame.XModel;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.script.provider.XScriptContext;
import com.sun.star.text.XText;
import com.sun.star.text.XTextDocument;
import com.sun.star.uno.UnoRuntime;
public class Test {
public static void test(XScriptContext xScriptContext, ActionEvent ev) {
XModel doc = xScriptContext.getDocument();
XScriptInvocationContext xInv = xScriptContext.getInvocationContext();
XModel inv = UnoRuntime.queryInterface(XModel.class, xInv);
boolean base_doc = UnoRuntime.queryInterface(XServiceInfo.class, doc).
supportsService("com.sun.star.sdb.OfficeDatabaseDocument");
boolean text_doc = UnoRuntime.queryInterface(XServiceInfo.class, inv).
supportsService("com.sun.star.text.TextDocument");
XTextDocument xTextDocument = UnoRuntime.queryInterface(XTextDocument.class, xInv);
XText xText = xTextDocument.getText();
xText.setString(
"Java\n" +
"getDocument is Base Document?: " + base_doc + "\n"+
"getInvocationContext is Text Document?: " + text_doc);
}
public static void main(String[] args) {
}
}
@hanya: is the issue still present? If so, can you provide patches updated to AOO source? Created attachment 77603 [details] Patch reconstructed for AOO (In reply to comment #2) > @hanya: is the issue still present? If so, can you provide patches updated > to AOO source? Still valid on AOO 3.4.0. new patch for recent revision 1342730. Committed as Revision 1344092 @hanya: Many thanks for your contribution. getting rid of value "enhancement" for field "severity". For enhancement the field "issue type" shall be used. |
Created attachment 76855 [details] Add getInvocationContext function to pythonscript.py When I try to execute a python script stored in the Text document as a form embedded in a Base document, script framework error causes. The pythonscript.py has problem about invocation context. I made a patch to fix it.