Tutorial for implementing OpenOffice in C++/C#/Java

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Netcoder1989
Posts: 7
Joined: Mon Mar 11, 2013 12:57 pm

Tutorial for implementing OpenOffice in C++/C#/Java

Post by Netcoder1989 »

is there any programming tutorial that gives the basic overview of using openoffice.

Please help me in this.
openoffice 3.4.1 on Windows7
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Tutorial for implementing OpenOffice in C++/C#/Java

Post by RoryOF »

Tha various OpenOffice APIs are linked from
http://www.openoffice.org/api/
and the Developers Guide at
http://wiki.openoffice.org/wiki/Documen ... pers_Guide
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Netcoder1989
Posts: 7
Joined: Mon Mar 11, 2013 12:57 pm

Re: Tutorial for implementing OpenOffice in C++/C#/Java

Post by Netcoder1989 »

I'm trying to implement OpenOffice/LibreOffice Impress in my program.
I've average knowledge of C++/C# but I'm unable to implement this in my code.
getting bootstrap error.
Is there any problem in SDK or what?
openoffice 3.4.1 on Windows7
darrenbang
Posts: 1
Joined: Mon Jul 15, 2013 8:30 am

Re: Tutorial for implementing OpenOffice in C++/C#/Java

Post by darrenbang »

Open Office Document formats are simple, every document is just simple Zip file containing XML files. Xml contains schema as well as data and reading them is pretty simple. If you just want to extract text out of them, then its easier, otherwise you can use System.Xml.Linq to read xml files to extract the data. To test, you can take any open office document, rename it as something.zip and extract and study its contents. You can use ISharpZip library to unzip in http://csharp.net-informations.com C# Tutorial and use Linq to study xml.

Add to references cli_bessatypes.dll, cli_cppuhelper.dll, cli_oootypes.dll, cli_uno.dll, cli_ure.dll and cli_uretypes.dll.

Code: Select all

XComponentContext oStrap = uno.util.Bootstrap.bootstrap();
XMultiServiceFactory oServMan = (XMultiServiceFactory)oStrap.getServiceManager();
XComponentLoader oLoader = (XComponentLoader)oServMan.createInstance("com.sun.star.frame.Desktop");
string fileName = "file:///" + filePath;

PropertyValue[] propVals = new PropertyValue[1];
propVals[0] = new PropertyValue();
propVals[0].Name = "Hidden";
propVals[0].Value.setValue(typeof(Boolean), true);
XComponent oXlsDocument = oLoader.loadComponentFromURL(fileName, "_default", 0, propVals);

XSpreadsheets oXlsSpreadsheet = ((XSpreadsheetDocument)oXlsDocument).getSheets();
XIndexAccess oXlsSheetIA = (XIndexAccess)oXlsSpreadsheet;
XSpreadsheet oXlsSheet = (XSpreadsheet)oXlsSheetIA.getByIndex(0).Value;
darren
balmerhevi
Posts: 2
Joined: Sat Nov 12, 2016 7:58 am

Re: Tutorial for implementing OpenOffice in C++/C#/Java

Post by balmerhevi »

use LINQ

StringBuilder result = new StringBuilder();
foreach (XElement level1Element in XElement.Load(@"D:\product.xml").Elements("Brand"))
{
result.AppendLine(level1Element.Attribute("name").Value);
foreach (XElement level2Element in level1Element.Elements("product"))
{
result.AppendLine(" " + level2Element.Attribute("name").Value);
}
}

More...Read XML

Hevi
OpenOffice 3.1 on Windows Vista
Post Reply