Joined: 05 Mar 2009
|Posted: Thu Mar 05, 2009 2:37 am Post subject: Problem about XSelectionSupplier.select() (Delphi+JNI+Java)
I'm creating an OO extension by implement/support "com.sun.star.frame.ProtocolHandler" service.
The main logic is in Delphi code, calling Java OO API through JNI.
Everything goes ok (get XTextDocument, create text cursors by range, set cursor string...), except:
When I try to select a range, by calling xSelectionSupplier.select(aRange),
the selection was applied successfully, but right after that, I got an
"Access violation at address A2FF5881. Read of address A2FF5881"
The same code(well, translated) runs well in Java.
(The xSelectionSupplier was get from controller, and getSelection() works ok)
Actually, the aRange is an XTextCursor returned by createTextCursorByRange.
I thought it was a problem about the type "Any". According to OO API document, when they need an Any,
I should pass an UNO object. But aRange/XTextCursor IS an UNO object
Then I use UnoRuntime.queryInterface to cast aRange to an XTextRange and passed to select(),
Then I create a new instance of Any by passing aRange as the parameter of Any's constructor, and
passed the instance of Any to select(), access violation
Since JNI defines all Java objects as Pointers in Delphi, I started to think maybe it's a reference-
counting problem. Then I tried to call acquire() on the aRange before passed it to the select().
But I can not find the MethodID of acquire() on the aRange/XTextCursor (signature: "()V"),
Then I use UnoRuntime.queryInterface to cast aRange to an XInterface, still, MethodID not found.
Thanks in advance.