Hi Aloizio,
please refer to http://www.netmeister.org/news/learn2quote.html for
correct quotation.
As you wrote in your other thread the snippet works for you. Please use it.
> I am using OpenOffice 2.0 and the OS is Windows XP Professional.
Using OOo 2.0.3 fixes many bugs.
> XComponentContext xContext = null;
> try
> {
> xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
> }
> catch (BootstrapException ex)
> {
> }
> System.out.println("Connected to a running office ...");
>
> // Get the remote office service manager
> XMultiComponentFactory xMCF = xContext.getServiceManager();
>
> // Get the root frame (i.e. desktop) of openoffice framework.
> Object oDesktop = null;
> try
> {
> oDesktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
> xContext);
> }
> catch (com.sun.star.uno.Exception ex1)
> {
> }
>
> // Desktop has 3 interfaces. The XComponentLoader interface provides
> ability to load
> // components.
> XComponentLoader xCompLoader = (XComponentLoader)
> UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,
> oDesktop);
>
> // URL of the component to be loaded
> String sUrl = "file:/M:/Aloizio_SS/docExemplo.doc";
>
> // the boolean property Hidden tells the office to open a file in hidden
> mode
> PropertyValue[] loadProps = new PropertyValue[1];
> loadProps[0] = new PropertyValue();
> loadProps[0].Name = "Hidden";
> loadProps[0].Value = new Boolean(true);
Is the document loaded correctly? You can test it using the Boolean
value "false".
> // Load the document, which will be displayed. More param info in apidoc
> XComponent xComp = null;
> try
> {
> xComp = xCompLoader.loadComponentFromURL(sUrl, "_blank", 0,loadProps);
> }
> catch (java.lang.Exception ex2)
> {
> ex2.printStackTrace();
> System.out.print("Erro");
> }
>
> // Get the textdocument
> XTextDocument aTextDocument = (XTextDocument)UnoRuntime.queryInterface(
> com.sun.star.text.XTextDocument.class, xComp);
>
> String storeUrl = "file:/M:/Aloizio_SS/docExemplo.rtf";
Please create a real UNO-Url for beeing platform independent:
http://codesnippets.services.openoffice.org/Office/Office.CreateUNOCompatibleURL.snip
> XStorable xStorable =
> (XStorable)UnoRuntime.queryInterface(XStorable.class, aTextDocument);
Please use instead of the XTextDocument aTextDocument the XComponent
xComp and try again.
> PropertyValue[] storeProps = new PropertyValue[1];
> storeProps[0] = new PropertyValue();
> storeProps[0].Name = "FilterName";
> storeProps[0].Value = "Rich Text Format";
>
> xStorable.storeAsURL(storeUrl, storeProps);
The rest looks good for me.
Greetings, Tobias
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]