Automating OpenOffice using AODL

Java, C++, C#, Delphi, ??? - Using the UNO bridges

Automating OpenOffice using AODL

Postby rahateomkar » Tue Nov 19, 2013 11:30 am

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   Expand viewCollapse view
XAccessibleText
and
Code: Select all   Expand viewCollapse view
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
rahateomkar
 
Posts: 1
Joined: Tue Nov 19, 2013 11:21 am

Re: Automating OpenOffice using AODL

Postby FJCC » Tue Nov 19, 2013 3:53 pm

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   Expand viewCollapse view
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   Expand viewCollapse view
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.
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7385
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA


Return to External Programs

Who is online

Users browsing this forum: No registered users and 2 guests