Automating OpenOffice using AODL

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
rahateomkar
Posts: 1
Joined: Tue Nov 19, 2013 11:21 am

Automating OpenOffice using AODL

Post 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

Code: Select all

 XAccessibleText
and

Code: Select all

XAccessibleEditableText
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.
OpenOffice ver 4.0.1 Windows 7
FJCC
Moderator
Posts: 9278
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Automating OpenOffice using AODL

Post 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.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Post Reply