I got the XMultiServiceFactory of the text document with:
        XMultiServiceFactory cMSF= (XMultiServiceFactory)
UnoRuntime.queryInterface(XMultiServiceFactory.class, 
myDoc);
where myDoc is a XTextDocument. But this did not make any 
difference. It seems that things go wrong at 
xMSF.createInstance
("com.sun.star.text.textfield.Annotation"), where a 
com.sun.star.uno.Exception is caught. Any idea? Thank you 
in advance!

Regards,

Yu

----------------------原邮件-------------------
Hi,

which service factory do you use? Is xMSF the global 
service factory or
the text document factory. Not all services can be 
instantiated at the
global service factory (service manager). Query your text 
document
object for XMultiServiceFactory and use this interface to 
create the
text field.

Juergen

Liao Yu wrote:
> Here is the code that I wrote to insert an annotation, 
> referring to the example in section 7.3.5 of Developer's 
> Guide:
> ...
>         try {
>             com.sun.star.text.XTextField aNote= 
> (com.sun.star.text.XTextField)UnoRuntime.queryInterface
> (XTextField.class, xMSF.createInstance
> ("com.sun.star.text.textfield.Annotation"));
>             xText.insertTextContent(xText.getEnd(),  
> aNote,  true);
>             
>         }
>         catch(com.sun.star.uno.Exception e){
>         System.out.println("111");
>         }
> ...
> However, what I get is no more than the 
> com.sun.star.uno.Exception that createInstance() throws. 
> Could anyone please tell me what's going wrong with that 
> piece of code? Thank you!
> 
> Regards,
> 
> Yu
> 
> ----------------------------------------------------------
-----------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: dev-
[EMAIL PROTECTED]
> 

------------------------------------------------------------
---------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to