Apache OpenOffice (AOO) Bugzilla – Issue 115741
Modify event fired before model modified when paragraph deleted
Last modified: 2017-05-20 10:44:04 UTC
when paragraph is deleted from document modified(EventObject event) method from XModifyListener is executed before model is changed. Method to reproduce problem : 1)create document <start of document> 1 3 <end of document> (each line is a separate paragraph) 2) attach ModifyListener to document : public class DocumentEventListener extends WeakBase implements XModifyListener { /*** * @param model - model of document we want listen to */ public DocumentEventListener(XModel model) { super(); XModifiable xmod = (XModifiable) UnoRuntime.queryInterface(XModifiable.class, model); xmod.addModifyListener(this); } @Override public void modified(EventObject event) { System.out.println("----modify-start----"); XTextDocument xtd = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, event.Source); System.out.println(xtd.getText().getString()); System.out.println("----modify-end------"); } public void disposing(EventObject event) { XModifiable xmod = (XModifiable) UnoRuntime.queryInterface(XModifiable.class, event.Source); xmod.removeModifyListener(this); } } 3) remove empty paragraph ("backspace it") from the empty line (or line below, does not matter). output of listener will be : ----modification-start---- 1 3 ----modification-end------ while I believe it should be : ----modification-start---- 1 3 ----modification-end------ problem does not appear when deleting line from multi line paragraph. Not tested on other OS/platforms This also occurred on OO 3.2 and 3.2.1 (not tested on older versions)
MRU->OS: could please give a short evaluation on this?
@TBO: as discussed with JJ, please take over.
I was promised a basic dialect problem. This looks like some c code. Passing on to OS: MRU->OS: could please give a short evaluation on this?
DocumentEventListener is a java class. I forgot to write about it. i'm sorry
Created attachment 84685 [details] Contains macros to observe document modifications Run Initialize to set up listener Modify the document and observe the captured text states Check with GetString at the end
I'll confirm this right now running version 4.0.1. Both in my C++ extension and in the attached document with Basic macros, the modified event is not sent after the modification is complete if there is a paragraph break among the deleted characters. At times it is sent after some of the characters have been deleted, but while the paragraph marker is still present. No event is sent at the end after all the modifications are complete. If I manually query the text afterwards, I find that the remaining changes have been completed without notification. This is a major problem for us, because we are trying to track changes to a document. If the user makes a modification and we go to check what the text now is, we can't read it correctly if a paragraph break has been deleted. For example, starting with text where \r means CR or paragraph break 1a\r 2\r \r if I delete a\r by selecting both characters and pressing DEL, the text read after the modify event occurs is 1\r2\r. (actually \r\n because this is on a PC and the final \r or \r\n is never returned for getString()). If I query the text afterwards, it is 12\r as expected. In the attached document run the Initialize macro to set up the listener, then edit the document. Run GetString to see what's in the document.
Reset the assignee to the default "issues@openoffice.apache.org".