0

I'm creating a java extension for open office and I need it to use the open office undo method. I've found the documentation about XUndoManager but since I'm quite unexperienced with the API I don't know how to use it in my code.

Furthermore, I want this extension to do things before openning the document, I've found about onStartApp but, again due to my non experience, I don't know how to use it on my code.

Could someone help me ? Thanks in advance !

Benjamin
  • 5
  • 4

1 Answers1

0

For Undo, use a dispatcher call as shown in listing 4.3 of Andrew Pitonyak's macro document.

For OnStartApp, I did not find a lot of documentation. Create a file called Events.xcu with code like the following:

<node oor:name="ApplicationEvents">
    <node oor:name="Bindings">
        <node oor:name="OnStartApp" oor:op="replace">
            <prop oor:name="BindingURL" oor:type="xs:string">
                <value>vnd.sun.star.script:events.py$OnStartApp?language=Python&amp;location=application</value>

Change the value of vnd.sun.star.script for use with Java, according to this documentation.

Then add this to manifest.xml:

<manifest:file-entry
    manifest:media-type="application/vnd.sun.star.configuration-data"
      manifest:full-path="Events.xcu" />

The CTLO project at GitHub is an example of using Events.xcu and manifest.xml in this way.

EDIT:

Here is an example of a dispatcher call in Java:

PropertyValue[] printProperties = new PropertyValue[1];
printProperties[0] = new PropertyValue();
printProperties[0].Name = "Print";
printProperties[0].Value = new Boolean(true);
XDispatchProvider xDispatchProvider = (XDispatchProvider)
    UnoRuntime.queryInterface (XDispatchProvider.class, xDesktop);
dispatcher.executeDispatch(
    xDispatchProvider, ".uno:Print","_self", 0, printProperties);
Jim K
  • 12,824
  • 2
  • 22
  • 51
  • 1
    Why should all the documentation about open office extension be for basic... I don't find the equivalent of createUnoService or execute dispatch in java... – Benjamin Jul 13 '16 at 08:53
  • There are some examples around, such as the [XDispatch API page](https://www.openoffice.org/api/docs/common/ref/com/sun/star/frame/XDispatch.html). But it does not seem to be as common for people who write Java code to use the dispatcher. I edited my answer to show an example. By the way, creating an UNO service is done with [XMultiServiceFactory](https://www.openoffice.org/api/docs/common/ref/com/sun/star/lang/XMultiServiceFactory.html) in Java. – Jim K Jul 13 '16 at 14:51