| View previous topic :: View next topic |
| Author |
Message |
kumarvidhani General User

Joined: 06 Nov 2008 Posts: 8
|
Posted: Fri Nov 07, 2008 1:08 am Post subject: C# coding with OpenOffice |
|
|
Hi,
I am trying to connect to OpenOffice through C# code. I am able to successfully connect
to it. Following is the code for it:
string fileName = @"c:\tmp\firstprogram.odt";
XComponentContext localContext = uno.util.Bootstrap.bootstrap();
XMultiServiceFactory xMultiServiceFactory = (XMultiServiceFactory)localContext.getServiceManager();
XComponentLoader componentLoader = (XComponentLoader)xMultiServiceFactory.createInstance("com.sun.star.frame.Desktop");
PropertyValue[] loadArgs = new PropertyValue[0];
//bool val = false;
uno.Any val1 = new Boolean();
loadArgs[0].Name = "hidden";
loadArgs[0].Value = val1;
XComponent xComponent = componentLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
XTextDocument xTextDocument = (XTextDocument)xComponent;
xTextDocument.getText().setString("This is first doc");
XStorable xStorable = (XStorable)xComponent;
xStorable.storeToURL(PathConverter(fileName), new unoidl.com.sun.star.beans.PropertyValue[0]);
This code is working well but it writing string "This is first doc" in firstprogram.odt file.
Problem:
But when running this code it is opening new Untitiled document and writing this same
string into it also. So how to stop from opening new document. |
|
| Back to top |
|
 |
parc Power User

Joined: 09 Nov 2007 Posts: 55 Location: Hamburg
|
Posted: Mon Nov 10, 2008 1:10 pm Post subject: Re: C# coding with OpenOffice |
|
|
| kumarvidhani wrote: |
XComponent xComponent = componentLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
So how to stop from opening new document. |
Then change the line opening a new empty window and use a file-url to open an existing file .... |
|
| Back to top |
|
 |
kumarvidhani General User

Joined: 06 Nov 2008 Posts: 8
|
Posted: Thu Nov 13, 2008 6:01 am Post subject: |
|
|
| thanks man |
|
| Back to top |
|
 |
|