Page 1 of 1

[Solved] Integration of LibreOffice with WPF

Posted: Tue Feb 25, 2014 9:57 am
by shinnguyen5589
I want to build an app, using Libreoffice api to open office documents(word, excel, powerpoint) in the same application window, writen by C#.
Can you give me some suggestions?
Thanks.

Re: Integration of LibreOffice with WPF

Posted: Tue Feb 25, 2014 11:58 am
by Villeroy
OpenOffice documents have nothing to do with Word, Excel nor Powerpoint. Nobody here knows what WTF C# means.
OpenOffice can attach all types of supported documents (including some foreign ones) to its own window tool set.
Button, new presentation and spreadsheet in one window
Button, new presentation and spreadsheet in one window
http://www.oooforum.org/forum/viewtopic.phtml?p=36664

Re: Integration of LibreOffice with WPF

Posted: Tue Feb 25, 2014 12:03 pm
by RoryOF
For information: WPF seems to stand for Windows Presentation Foundation (WPF), which links to Visual C#.

Google is your friend: start with
How to: Create a C# WPF Application

Re: Integration of LibreOffice with WPF

Posted: Tue Feb 25, 2014 12:32 pm
by shinnguyen5589
I built an C# WPF application, this app using Libreoffice api to open office documents. But documents always open in another window. My expectation is open documents in the same window with main app.
Can you give me some suggestions?
Thanks.

Re: Integration of LibreOffice with WPF

Posted: Tue Feb 25, 2014 12:39 pm
by Villeroy
Can you do that trick with some typical Windows application?
If it has to be OpenOffcie or LibreOffice, I have suggested a working solution.

Re: Integration of LibreOffice with WPF

Posted: Wed Feb 26, 2014 3:35 am
by shinnguyen5589
Hi Villeroy, I don't know exactly what you mean.
This is code I use to open document

//Get a ComponentContext
unoidl.com.sun.star.uno.XComponentContext xLocalContext =
uno.util.Bootstrap.bootstrap();
//Get MultiServiceFactory
unoidl.com.sun.star.lang.XMultiServiceFactory xRemoteFactory =
(unoidl.com.sun.star.lang.XMultiServiceFactory)xLocalContext.getServiceManager();
//Get a ComponentLoader
unoidl.com.sun.star.frame.XComponentLoader xLoader = (unoidl.com.sun.star.frame.XComponentLoader)xRemoteFactory.createInstance("com.sun.star.frame.Desktop");

//Open document
unoidl.com.sun.star.beans.PropertyValue[] Args = new unoidl.com.sun.star.beans.PropertyValue[1];
XComponent xComponent = xLoader.loadComponentFromURL(@"file:///C:/Users/Documents/demo.odt", "_blank", 0, Args);

Re: [Solved] Integration of LibreOffice with WPF

Posted: Mon Sep 29, 2014 4:24 pm
by gabrielel
Hi! I have your same problem. Can you help me? I want to open office file in a user control WPF C#.
Thanks a lot
Gabriele

shinnguyen5589 wrote:I want to build an app, using Libreoffice api to open office documents(word, excel, powerpoint) in the same application window, writen by C#.
Can you give me some suggestions?
Thanks.