How to access in a python script/ macro the same data in libreoffice manage track changes

please, how to access in a python script/ macro the same data in libreoffice manage track changes.

I need to create a script that lists the records in “manage track changes” form and based on some conditions accepts or rejects each record. That data exists and can be accessed through the UI but i cannot find where in the object model this can be accomplished.

thank you

Hi,
it is easy to find the changes (Redlines in OO language), see below in Basic. I did not find a way to accept or reject them, though
Hope that helps a bit,
ms777

Sub Main
oRedlines = ThisComponent.Redlines
for k=0 to oRedlines.Count-1
	oRedline = oRedlines.getByIndex(k)
	xray oRedline
next k
end sub

Thank you very much, ms777.
Tried the code and it replies with : <>. I have version 7.4.3.2, can you clarify on which LO version the code above worked?

correction, the message is: property or method not found: Redlines.

But It finds ThisComponent.

Is track changes active in your document?

yes, i did: edit->track changes->record, changed the value in a cell then with same navigation->manage i see that change: action/position/author/date/comment with : cell e27 changed from 111 to 222.

When running the code above, the error is raised.
thank you Wanderer

It looks like the getRedlines method of the XRedlinesSupplier interface in LO is implemented in text documents and not implemented in spreadsheet documents.

i am just [not even] a beginner at LO, but if the form “manage changes” displays this data, it must exist somewhere in the object model, right ?

Undoubtedly, but the search task is not always trivial. :slightly_smiling_face:

I’m not so sure about that. My impression is that some things are not exposed to the API. Since red cells are saved with the document, they should be readable from the document source which is zipped XML.

the changes can be read [interactively] from “manage track changes” even when the spreadsheet is newly created and not yet saved to hdd as an ods file.

Correct. Even if it was, I’m not sure it would actually be useful, because it would be a 4D (or 3.5D?) representation of actions, i.e. cell positions, formula references and content changes depend on inserted and deleted rows/columns over time and everything is intertwined pointing to each other where necessary. Accepting or rejecting an action is not always possible per single action; e.g. content changes in an inserted column are to be discarded (rejected as well) if the column insertion is rejected, or accepting content changes in a deleted column is of course not possible until the column deletion is rejected, and with each rejection of an insertion or deletion all formula references crossing/intersecting those have to be adjusted. This is all handled by the Manage Changes dialog and the underlying model. To be able to do the same through UNO API it would need a specialized controlling interface.

Stored in document is the serialized sequence of actions and dependencies, see ODF v1.3: 9.9 Change Tracking in Spreadsheets, that is more suitable to obtain information, but also not directly actionable.

1 Like