K
Klaus Friese
Hi,
i'm currently working on a plugin for Adobe InDesign and i have some
problems with that. I'm not really a c++ guru, maybe somebody here has
an idea how to solve this.
The plugin is written in C++ and it's calling a java application. This
application displays a window and pushing a button is calling back the
c++-plugin again.
// The plugin class. CActionComponent is part of the InDesign SDK
class MyJNIComponent : public CActionComponent {
public:
...
static void onCreateDocument();
...
private:
...
void registerCallbacks();
...
}
// this is called from the java application
JNIEXPORT void JNICALL Java_createDocument(JNIEnv *e, jobject o);
// this is called from Java_createDocument()
void MyJNIComponent:nCreateDocument() {
...
// Here i'm using SDK-methods and functions to create and display a
document.
// And here is the problem - i get an assertion from the SDK.
// The code to create the document is ok, i used this code before
and i can
// call this method from inside the plugin without assertion
...
}
// Register Callback from the Java Application back to the Plugin
void MyJNIComponent::registerCallbacks() {
jint res;
JNINativeMethod nm;
// if this method is called in the java application ..
CJavaClassInstance layoutSystemToolBox("path/to/my/java/class");
nm.name="createDocument";
nm.signature="()V";
// .. call this function in the plugin
nm.fnPtr=Java_createDocument;
res=CJavaVM::env()->RegisterNatives(layoutSystemToolBox.getClassDefinition(),&nm,1);
if (res!=0) {
CJavaVM::reportError("Can't find the Java_createDocument
method.");
return ;
}
}
// this function is called from java
JNIEXPORT void JNICALL Java_createDocument(JNIEnv *e, jobject o){
CJavaVM::env()->ExceptionClear();
// calling method in plugin class
MyJNIComponent:nCreateDocument();
}
I think the problem is, that Java_createDocument() is not part of the
MyJNIComponent class and when i'm calling
MyJNIComponent:nCreateDocument() from Java_createDocument() some
variables are not proper initialized.
And i don't know how to make Java_createDocument() part of the class.
Or if there is another way to solve this?
Thanks for any suggestions.
i'm currently working on a plugin for Adobe InDesign and i have some
problems with that. I'm not really a c++ guru, maybe somebody here has
an idea how to solve this.
The plugin is written in C++ and it's calling a java application. This
application displays a window and pushing a button is calling back the
c++-plugin again.
// The plugin class. CActionComponent is part of the InDesign SDK
class MyJNIComponent : public CActionComponent {
public:
...
static void onCreateDocument();
...
private:
...
void registerCallbacks();
...
}
// this is called from the java application
JNIEXPORT void JNICALL Java_createDocument(JNIEnv *e, jobject o);
// this is called from Java_createDocument()
void MyJNIComponent:nCreateDocument() {
...
// Here i'm using SDK-methods and functions to create and display a
document.
// And here is the problem - i get an assertion from the SDK.
// The code to create the document is ok, i used this code before
and i can
// call this method from inside the plugin without assertion
...
}
// Register Callback from the Java Application back to the Plugin
void MyJNIComponent::registerCallbacks() {
jint res;
JNINativeMethod nm;
// if this method is called in the java application ..
CJavaClassInstance layoutSystemToolBox("path/to/my/java/class");
nm.name="createDocument";
nm.signature="()V";
// .. call this function in the plugin
nm.fnPtr=Java_createDocument;
res=CJavaVM::env()->RegisterNatives(layoutSystemToolBox.getClassDefinition(),&nm,1);
if (res!=0) {
CJavaVM::reportError("Can't find the Java_createDocument
method.");
return ;
}
}
// this function is called from java
JNIEXPORT void JNICALL Java_createDocument(JNIEnv *e, jobject o){
CJavaVM::env()->ExceptionClear();
// calling method in plugin class
MyJNIComponent:nCreateDocument();
}
I think the problem is, that Java_createDocument() is not part of the
MyJNIComponent class and when i'm calling
MyJNIComponent:nCreateDocument() from Java_createDocument() some
variables are not proper initialized.
And i don't know how to make Java_createDocument() part of the class.
Or if there is another way to solve this?
Thanks for any suggestions.