Page 1 of 1
Automating OpenOffice using AODL
Posted: Tue Nov 19, 2013 11:30 am
by rahateomkar
I am trying to automate OpenOffice 4.0.1 using Microsoft .Net c# language. I want to copy the text from one input file and paste it into another. My input file may of Microsoft word or .odt file.
To do the same in c# language its getting tougher. There are methods available in
and
interface but I am not getting anything about how to implement those.
If someone has tried it then please share any small snippet with me.
Re: Automating OpenOffice using AODL
Posted: Tue Nov 19, 2013 3:53 pm
by FJCC
The interfaces you list are intended for assistive technology. If I was trying to insert the entire contents of one document in another, I would use the insertDocumentFromURL() method. In OO Basic the code looks like
Code: Select all
oText = ThisComponent.getText()
oCurs = oText.createTextCursor()
oCurs.gotoEnd(False)
oCurs.insertDocumentFromURL("file:///c:/users/fjcc/Desktop/Insert.odt", Array())
The C# code recorded by MRI for doing the first steps of that is
Code: Select all
using System;
using unoidl.com.sun.star.text;
using unoidl.com.sun.star.uno;
public class Snippet {
public void snippet(XComponentContext xContext, object oInitialTarget)
{
XTextDocument xTextDocument = (XTextDocument) oInitialTarget;
XText xText = xTextDocument.getText();
XSimpleText xSimpleText = (XSimpleText) xText;
XTextCursor xTextCursor = xSimpleText.createTextCursor();
xTextCursor.gotoEnd(false);
}
I don't know anything about C#, so perhaps that isn't useful.
The documentation on insertDocuemntFromURL() is
here.