XUndoManager for SpreadsheetDocument service

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

XUndoManager for SpreadsheetDocument service

Postby cgalli » Fri Feb 12, 2016 5:29 pm

Hi everybody.

I am developing a calc add-on in Java, and I need to manage the undo stack when some operations on the document's sheets are executed by this extension.
I can't find documentation about undo management (besides the javadoc html's, which are not enough to clarify the use of XUndoManager), nor good examples.

For example, I can't explain this behavior:

- Initially, an XUndoManager interface is obtained using the XUndoManagerSupplier interface queried from the document (a XSpreadsheetDocument, to be accurate).
- Also, a XLockable is queryed from the XUndoManger, to lock/unlock the XUndoManager.
- Then, the XUndoManager is used to create an undo context (thru XUndoManager::enterUndoContext method).
- Inmediately after, the undo context created is blocked (thru the XLockable::lock method). I verifyed it using XLockable::isLocked method. The idea here is to block the context in order to prevent the operations to perform automatically by the extension are added to the stack.
- Then, the add-on fires a sheet's insertion (i.e. a new sheet is inserted into the document). Unexpectedly, this action removes the lock over the undo context, (i.e., somebody else is unlocking the context), so the insertion and all subsequent operations are added to the stack.
- After that, any call to XLockable::lock method fails to lock the context.

Does anybody knows why is that, and how to fix it?

Regards to all.
Last edited by cgalli on Sat Feb 13, 2016 3:58 pm, edited 1 time in total.
OpenOffice 4.1.2 on Fedora 22
Posts: 9
Joined: Mon Jul 28, 2014 11:38 pm

Re: XUndoManager for SpreadsheetDocument service

Postby cgalli » Sat Feb 13, 2016 1:13 am


it seems that undo locks are "consummed", i.e.: once locked, the lock is valid just for 1 action on the document, meaning that only that action is skipped in the undo stack.
Also, to lock the undo manager again, before calling the lock() method it is necessary calling unlock() method 2 times per modification (don't know why).
It's insane!
OpenOffice 4.1.2 on Fedora 22
Posts: 9
Joined: Mon Jul 28, 2014 11:38 pm

Return to External Programs

Who is online

Users browsing this forum: No registered users and 1 guest