I finally got the snippet creator to work for me, tip
- if you are having problems delete everthing in your
userhome\OpenOffice.org2 directory.
So I would like to submit a scripting framework
snippet, but first I would like comments and I have a
question or two and some points that might be useful
for others.
First of all if you are trying to boost performance I
got the following results. I created 200 frames with
the letter A in them through normal rendering and it
took 18229 miliseconds, then I created a java class
with a XScriptContext that did the same thing and it
took 203 miliseconds.
So now I would like to try and integrate this solution
and win some performance. The only problem I am having
is that I need to pass a XTextDocument into my
"Macro". xScriptContext.getDocument() returns
a
blank document.
This also didn't work:
xScriptProviderFactory.createScriptProvider(document
);
If I try and pass it directly a XTextDocument it
moans.
com.sun.star.script.provider.ScriptFrameworkErrorException:
StrictResolver.getProxy: Cant find method:
printHW:HelloWorld.printHW(com.sun.star.script.provider.XScr
iptContext,
$Proxy0)
So I try to use Proxy as an object in the signature
instead of XTextDocument but it still moans. The
snippet is below, ideally before I submit it I would
like it to support XTextDocuments.
As this is a snippet do you reckon I can keep the
connection.getComponentContext() part? Or should I
flesh that out?
##########################
XMultiComponentFactory xMultiComponentFactory =
connection.getComponentContext()
.getServiceManager();
Object oMSPFac =
xMultiComponentFactory.createInstanceWithContext(
"com.sun.star.script.provider.MasterScriptProviderFact
ory",
connection.getComponentContext() );
XScriptProviderFactory xScriptProviderFactory = (
XScriptProviderFactory ) UnoRuntime.queryInterface(
XScriptProviderFactory.class,
oMSPFac );
Object oMSP =
xScriptProviderFactory.createScriptProvider(document
);
XScriptProvider xScriptProvider = ( XScriptProvider )
UnoRuntime.queryInterface( XScriptProvider.class, oMSP
);
XScript myScript = xScriptProvider.getScript(
"vnd.sun.star.script:HelloWorld.HelloWorld.printHW?lan
guage=Java&location=share"
);
// building all parameters : objects arrays, etc
String a;
a = "** Hi ***"; //$NON-NLS-1$
Object[] objectArray = ;
short[][] s = { { 0, 0 }, { 0, 0 } };
Object nullObject;
nullObject = null;
Object[][] object0 = { { nullObject, nullObject }, {
nullObject, nullObject } };
Object result = myScript.invoke( objectArray, s,
object0 );
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection
around
http://mail.yahoo.com
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|