Synchronous API equivalent for executeDispatch(.uno:UpdateAl

Keyboard macros or custom scripts

Synchronous API equivalent for executeDispatch(.uno:UpdateAl

Postby Jambunathan K » Sat Dec 29, 2018 6:54 am

I am looking for a Synchronous API equivalent for executeDispatch(.uno:UpdateAll).

Context:

I produce ODT documents by running an Emacs Org-mode document (a plaintext markup format like Markdown). The document so produced is then passed through a Basic Macro via a command line. This macro does exactly what Tools->Update->Update All does. Passing the document through a macro ensures that (pagenos in) TOC of the ODT document is up to date.

The macro is invoked via command line as below

soffice --norestore --invisible --headless macro:///OrgMode.Utilities.Reload(file:///home/kjambunathan/Downloads/test.odt)


and

OrgMode.Utilities.Reload is a just a shim over

executeDispatch(..., ".uno:UpdateAll", "", 0, Array())


Problem:

When working with large documents, the above "UpdateAll" fails. This is probably because the macro's Subroutine exits even before the executeDispatch has finished its work. I have read through the forums, and one of the suggested workarounds for this problem is to add a wait after a dispatch. I am not comfortable with this workaround, I would prefer a macro (Basic, Python or Java whatever) that would __guarantee__ me that the fields are up to date before the shell command exits.

So, Can someone help me with Synchronous API equivalent for executeDispatch(.uno:UpdateAll).
LibreOffice 6.1.0.3 [Debian GNU/Linux unstable (sid)]
Jambunathan K
 
Posts: 2
Joined: Sat Aug 11, 2018 1:17 pm

Re: Synchronous API equivalent for executeDispatch(.uno:Upda

Postby Villeroy » Sat Dec 29, 2018 12:04 pm

doc.updateAll() updates all external links but I'm not sure if this is the only thing you want to update because the user interface command updates all links, fields, indexes, tables of contents, and page formatting in the current document. I'm not familiar with Writer and finding adequate API methods is a nightmare even though I'm very familiar with my object inspector and the general concepts of this API.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26553
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Synchronous API equivalent for executeDispatch(.uno:Upda

Postby Villeroy » Sat Dec 29, 2018 1:21 pm

oDocumentIndexes = ThisComponent.getDocumentIndexes() returns a collection of indices ( TOC, table index, picture index). Each one seems to have an update() method.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26553
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Synchronous API equivalent for executeDispatch(.uno:Upda

Postby Jambunathan K » Sat Dec 29, 2018 4:02 pm

Villeroy wrote:doc.updateAll() updates all external links but I'm not sure if this is the only thing you want to update because the user interface command updates all links, fields, indexes, tables of contents, and page formatting in the current document.


My little research suggests that .uno:UpdateAll maps to FN_UPDATE_ALL. (See https://wiki.openoffice.org/wiki/Framew ... x_Commands)

And FN_UPDATE_ALL does precisely this https://github.com/LibreOffice/core/blo ... h.cxx#L667.

One of the things that FN_UPDATE_ALL does is to do FN_UPDATE_FIELDS (See https://github.com/LibreOffice/core/blo ... h.cxx#L645)

FN_UPDATE_FIELDS does

rSh.SwViewShell::UpdateFields(true);


SwViewShell::UpdateFields is documented here https://docs.libreoffice.org/sw/html/cl ... 9f931c059a and it does exactly this https://docs.libreoffice.org/sw/html/vi ... tml#l00655.

Now, I have trouble mapping

GetDoc()->getIDocumentFieldsAccess().UpdateFields(bCloseDB);


to something that could be done starting with an SwXTextDocument object (See https://docs.libreoffice.org/sw/html/cl ... ument.html)

[At this point, I realized that I was too deep in a rabbit hole, abandoned further pursuit and posted my query]

---------------

Villeroy wrote: I'm not familiar with Writer and finding adequate API methods is a nightmare even though I'm very familiar with my object inspector and the general concepts of this API.


I believe you are refering to the XRay tool (See https://wiki.openoffice.org/wiki/Extens ... #Xray_tool). I have the XRay tool and I am comfortable using it. I have also looked at the Andrew's Macro document (See http://www.openoffice.org/documentation ... wMacro.odt). Despite all these efforts, I am a bit stuck with this specific problem--the problem of asynchronous dispatch). I was hoping that someone here would have a quick answer for it.
LibreOffice 6.1.0.3 [Debian GNU/Linux unstable (sid)]
Jambunathan K
 
Posts: 2
Joined: Sat Aug 11, 2018 1:17 pm


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 3 guests