I'm developping a component for Writer which has been tested with
Windows and works fine on different machines with different OpenOffice
Versions starting from 2.0.2 to 2.0.4.
Now that I'm almost finished with it, I wanted to test the tool on a Mac
and on Linux. Surprisingly it failed and I don't really understand how
this could happen.
On Linux (Gentoo) with OO.org 2.0.3 and 2.0.4 it fails and on Mac
(Intel/PowerPC) it fails with NeoOffice (OO.org 2.0.3). The main problem
which I figured out is on startup where the JobExecutor initializes
several things.
The following code works with Windows but not with the other ones:
xComponent = xDesktop.getCurrentComponent();
xDesktop has been initialized but getCurrentComponent() doesn't give
anything back, it does so with Windows! (How is this even possible?)
Here's my startup Class:
----------------------------------------------------------
public ElmlEditor(XComponentContext xCompContext) {
xComponentContext = xCompContext;
try {
xMCF = xComponentContext.getServiceManager();
desktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xComponentContext);
xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class,
desktop);
xCLoader = (XComponentLoader) UnoRuntime.queryInterface(
XComponentLoader.class, desktop);
} catch (java.lang.Exception e) {
e.printStackTrace(System.err);
}
}
-------------------------------------------------------
And my AsyncJob
--------------------------------------------------------
public synchronized void executeAsync(
com.sun.star.beans.NamedValue[] lArgs,
com.sun.star.task.XJobListener xListener)
throws com.sun.star.lang.IllegalArgumentException {
// For asynchronous jobs a valid listener reference is guranteed
normaly
// ...
if (xListener == null)
throw new com.sun.star.lang.IllegalArgumentException(
"invalid listener");
// extract all possible sub list of given argument list
com.sun.star.beans.NamedValue[] lGenericConfig = null;
com.sun.star.beans.NamedValue[] lJobConfig = null;
com.sun.star.beans.NamedValue[] lEnvironment = null;
com.sun.star.beans.NamedValue[] lDynamicData = null;
int c = lArgs.length;
for (int i = 0; i < c; ++i) {
if (lArgs[i].Name.equals("Config"))
lGenericConfig = (com.sun.star.beans.NamedValue[])
com.sun.star.uno.AnyConverter
.toArray(lArgs[i].Value);
else if (lArgs[i].Name.equals("JobConfig"))
lJobConfig = (com.sun.star.beans.NamedValue[])
com.sun.star.uno.AnyConverter
.toArray(lArgs[i].Value);
else if (lArgs[i].Name.equals("Environment"))
lEnvironment = (com.sun.star.beans.NamedValue[])
com.sun.star.uno.AnyConverter
.toArray(lArgs[i].Value);
else if (lArgs[i].Name.equals("DynamicData"))
lDynamicData = (com.sun.star.beans.NamedValue[])
com.sun.star.uno.AnyConverter
.toArray(lArgs[i].Value);
}
// Analyze the environment info. This sub list is the only
guarenteed
// one!
if (lEnvironment == null)
throw new com.sun.star.lang.IllegalArgumentException(
"no environment");
java.lang.String sEnvType = null;
java.lang.String sEventName = null;
c = lEnvironment.length;
for (int i = 0; i < c; ++i) {
if (lEnvironment[i].Name.equals("EnvType"))
sEnvType = com.sun.star.uno.AnyConverter
.toString(lEnvironment[i].Value);
else if (lEnvironment[i].Name.equals("EventName"))
sEventName = com.sun.star.uno.AnyConverter
.toString(lEnvironment[i].Value);
else if (lEnvironment[i].Name.equals("Model"))
xModel = (com.sun.star.frame.XModel)
com.sun.star.uno.AnyConverter
.toObject(new com.sun.star.uno.Type(
com.sun.star.frame.XModel.class),
lEnvironment[i].Value);
}
// Further the environment property "EnvType" is required as
minimum.
if (
(sEnvType==null) ||
(
(!sEnvType.equals("EXECUTOR" )) &&
(!sEnvType.equals("DISPATCH" )) &&
(!sEnvType.equals("DOCUMENTEVENT"))
)
)
{
throw new com.sun.star.lang.IllegalArgumentException("no
valid value for EnvType");
}
convertElml = new XmlConverter();
xController = xModel.getCurrentController();
xComponent = xDesktop.getCurrentComponent();
........
------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]