Issue 118478 - To support getInvocationContext in Python scripts
Summary: To support getInvocationContext in Python scripts
Alias: None
Product: App Dev
Classification: Unclassified
Component: scripting (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC All
: P5 (lowest) Normal
Target Milestone: 4.0.0
Assignee: kay.ramme
QA Contact:
Depends on:
Reported: 2011-10-03 09:57 UTC by hanya
Modified: 2017-05-20 09:32 UTC (History)
2 users (show)

See Also:
Issue Type: PATCH
Latest Confirmation in: ---
Developer Difficulty: ---

Add getInvocationContext function to (4.19 KB, patch)
2011-10-03 09:57 UTC, hanya
no flags Details | Diff
Simple test for invocation context of python script (14.00 KB, application/octet-stream)
2011-10-03 10:07 UTC, hanya
no flags Details
Patch reconstructed for AOO (4.13 KB, patch)
2012-05-26 02:37 UTC, hanya
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description hanya 2011-10-03 09:57:17 UTC
Created attachment 76855 [details]
Add getInvocationContext function to

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 has problem about invocation context. I made a patch to fix it.
Comment 1 hanya 2011-10-03 10:07:27 UTC
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("")
	text_doc = inv.supportsService("")
	text = inv.getText()
	    "Python\n" + 
	    ("getDocument is Base Document?: %s\n" % base_doc) + 
	    ("getInvocationContext is Text Document?: %s" % text_doc))

Code for Java.
package test.macro;


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).
		boolean text_doc = UnoRuntime.queryInterface(XServiceInfo.class, inv).
		XTextDocument xTextDocument = UnoRuntime.queryInterface(XTextDocument.class, xInv);
		XText xText = xTextDocument.getText();
				"Java\n" + 
				"getDocument is Base Document?: " + base_doc + "\n"+ 
				"getInvocationContext is Text Document?: " + text_doc);
	public static void main(String[] args) {
Comment 2 Ariel Constenla-Haile 2012-05-25 12:21:57 UTC
@hanya: is the issue still present? If so, can you provide patches updated to AOO source?
Comment 3 hanya 2012-05-26 02:37:37 UTC
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.
Comment 4 Ariel Constenla-Haile 2012-05-30 04:09:24 UTC
Committed as Revision 1344092

@hanya: Many thanks for your contribution.
Comment 5 Oliver-Rainer Wittmann 2012-06-13 12:28:13 UTC
getting rid of value "enhancement" for field "severity".
For enhancement the field "issue type" shall be used.