Problem inserting textfield

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem inserting textfield

James White-2
Hi all, I have being trying to implement the code below (from developers
guide p.548) and I constantly run into problems, could anyone suggest a
solution or point me in the right direction to fixing the problem?

The exception I get varies but is always one of the following:

1. java.lang.NullPointerException
2. com.sun.star.lang.IllegalArgumentException: second parameter invalid




                        XTextDocument td =
(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,xDesktop.getCurrentComponent());
                        XTextCursor tc = td.getText().createTextCursor();
                       Object bookmark =
oobean.getMultiServiceFactory().createInstance (
"com.sun.star.text.Bookmark" );
                        XNamed xNamed = (XNamed)
UnoRuntime.queryInterface ( XNamed.class, bookmark );
                        xNamed.setName("MyUniqueBookmarkName");
                        XTextContent xTextContent = (XTextContent)
UnoRuntime.queryInterface (XTextContent.class, bookmark );
                        td.getText().insertTextContent (
td.getText().getEnd(), xTextContent, false );
                       


Thanks in advance for your help,

James

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Problem inserting textfield

Tom Schindl
Hi,

you should ask this question on [hidden email] and if you
provide the line failing with the exception it surely helps to find a
solution.

Tom

James White wrote:

> Hi all, I have being trying to implement the code below (from developers
> guide p.548) and I constantly run into problems, could anyone suggest a
> solution or point me in the right direction to fixing the problem?
>
> The exception I get varies but is always one of the following:
>
> 1. java.lang.NullPointerException
> 2. com.sun.star.lang.IllegalArgumentException: second parameter invalid
>
>
>
>
>                        XTextDocument td =
> (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,xDesktop.getCurrentComponent());
>
>                        XTextCursor tc = td.getText().createTextCursor();
>                       Object bookmark =
> oobean.getMultiServiceFactory().createInstance (
> "com.sun.star.text.Bookmark" );
>                        XNamed xNamed = (XNamed)
> UnoRuntime.queryInterface ( XNamed.class, bookmark );
>                        xNamed.setName("MyUniqueBookmarkName");
>                        XTextContent xTextContent = (XTextContent)
> UnoRuntime.queryInterface (XTextContent.class, bookmark );
>                        td.getText().insertTextContent (
> td.getText().getEnd(), xTextContent, false );
>                      
>
> Thanks in advance for your help,
>
> James
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Problem inserting textfield

James White-2
Thanks Tom,

I will mail that problem to [hidden email] , and the line in
question is :

td.getText().insertTextContent (td.getText().getEnd(), xTextContent, false );

James



Tom Schindl wrote:

> Hi,
>
> you should ask this question on [hidden email] and if you
> provide the line failing with the exception it surely helps to find a
> solution.
>
> Tom
>
> James White wrote:
>  
>> Hi all, I have being trying to implement the code below (from developers
>> guide p.548) and I constantly run into problems, could anyone suggest a
>> solution or point me in the right direction to fixing the problem?
>>
>> The exception I get varies but is always one of the following:
>>
>> 1. java.lang.NullPointerException
>> 2. com.sun.star.lang.IllegalArgumentException: second parameter invalid
>>
>>
>>
>>
>>                        XTextDocument td =
>> (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,xDesktop.getCurrentComponent());
>>
>>                        XTextCursor tc = td.getText().createTextCursor();
>>                       Object bookmark =
>> oobean.getMultiServiceFactory().createInstance (
>> "com.sun.star.text.Bookmark" );
>>                        XNamed xNamed = (XNamed)
>> UnoRuntime.queryInterface ( XNamed.class, bookmark );
>>                        xNamed.setName("MyUniqueBookmarkName");
>>                        XTextContent xTextContent = (XTextContent)
>> UnoRuntime.queryInterface (XTextContent.class, bookmark );
>>                        td.getText().insertTextContent (
>> td.getText().getEnd(), xTextContent, false );
>>                      
>>
>> Thanks in advance for your help,
>>
>> James
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>>
>>    
>
>