OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

C# coding with OpenOffice

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
kumarvidhani
General User
General User


Joined: 06 Nov 2008
Posts: 8

PostPosted: Fri Nov 07, 2008 1:08 am    Post subject: C# coding with OpenOffice Reply with quote

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
View user's profile Send private message
parc
Power User
Power User


Joined: 09 Nov 2007
Posts: 55
Location: Hamburg

PostPosted: Mon Nov 10, 2008 1:10 pm    Post subject: Re: C# coding with OpenOffice Reply with quote

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
View user's profile Send private message Visit poster's website
kumarvidhani
General User
General User


Joined: 06 Nov 2008
Posts: 8

PostPosted: Thu Nov 13, 2008 6:01 am    Post subject: Reply with quote

thanks man
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group