Bug 73221 - Last comment text is lost if you save as .docx without shifting the focus to another text area
Summary: Last comment text is lost if you save as .docx without shifting the focus to ...
Status: RESOLVED DUPLICATE of bug 68604
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.5.0 release
Hardware: x86-64 (AMD64) All
: medium major
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: filter:docx
Depends on:
Blocks: DOCX-Comments
  Show dependency treegraph
 
Reported: 2014-01-02 12:00 UTC by Peter Robinson
Modified: 2017-10-05 21:42 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Example of docx file that will not save last comment. (9.05 KB, application/wps-office.docx)
2014-01-02 22:44 UTC, Peter Robinson
Details
odt version of problem file that shows correct output (30.93 KB, application/vnd.oasis.opendocument.text)
2014-01-02 22:50 UTC, Peter Robinson
Details
test .docx with comments created in Win7 (4.99 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2014-01-02 23:12 UTC, tommy27
Details
.odt demonstrating correct function (10.71 KB, application/vnd.oasis.opendocument.text)
2014-11-20 18:33 UTC, Matt Price
Details
.docx shows auto-inserted annotation doesn't show up. (4.77 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2014-11-20 18:34 UTC, Matt Price
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Robinson 2014-01-02 12:00:13 UTC
Document created and saved in docx format.  Comments inserted via menu item Insert/Comment.  Comments all appear correctly when typed and edited.  Document re-saved and then re-opened.  The last comment is blank.  The comment box appears but the text area is blank.  Tested on both Writer 4.1.1.? and 4.1.4.2.  Involves data loss so can be major problem, especially since the comments are usually written to be read by someone else sharing the document, who may not recognise the error.  Bug doesn't occur when saving in doc format.
Previous bug fix ID 33463 seems to be imperfect.
Comment 1 tommy27 2014-01-02 13:31:02 UTC
not reproducible in Win7 64bit with LibO 4.1.4.2

please try attaching an .odt with comments and the same file saved in .docx

edited summary notes.
Comment 2 Peter Robinson 2014-01-02 22:44:59 UTC
Created attachment 91441 [details]
Example of docx file that will not save last comment.

Further testing shows problem only arises for file originally created by someone else (in this case a student), presumably on a Windows machine.  When I try to add comments to this file on my Linux machine, the text of the last comment is lost.  If  I create a file from scratch on my own machine, no problems.
Comment 3 Peter Robinson 2014-01-02 22:50:52 UTC
Created attachment 91442 [details]
odt version of problem file that shows correct output

Student's file saved on my machine as odt document.  It shows correct output of comments.  Problems also found on other students' files, so not limited to one system.
Comment 4 tommy27 2014-01-02 23:07:40 UTC
(In reply to comment #2)
> Created attachment 91441 [details]
> Example of docx file that will not save last comment.
> 
> Further testing shows problem only arises for file originally created by
> someone else (in this case a student), presumably on a Windows machine. 

is this person using LibO 4.1.4.2 or another LibO release or MS Word?(In reply to comment #2)

> When I try to add comments to this file on my Linux machine, the text of the
> last comment is lost.  If  I create a file from scratch on my own machine,
> no problems.

these observations makes me think that the root of the bug is in the source .docx file.
Comment 5 tommy27 2014-01-02 23:12:04 UTC
Created attachment 91445 [details]
test .docx with comments created in Win7

try my file. it's a .docx with dummy text and 2 comments inside it.
it was created with LibO 4.1.4.2 under Win7 64bit.

can you add comments in your Linux machine? do you still experience issue?
Comment 6 Peter Robinson 2014-01-03 08:01:45 UTC
OK.  I think I've narrowed it down.  Different sources of files were a coincidence.  I think this replicates the behaviour for any docx file.
1. Create a file and save it as a docx file using any software.  If using LO and file includes comments, they will work correctly.
2. Close file and then re-open it in LO.
3. Insert comments.  When you write the last comment, without moving the cursor from the comment, click save button. (This is how you would interact when commenting someone else's document).
4.  The save button will grey out and disable, but in fact the last comment is not saved.  You can close the file (without getting any warning about saving) and re-open it and the last comment will be blank.
If in step 3, you move the cursor to the body of the document or to another comment before clicking save, the last comment will be saved correctly.  "ENTER-ing" comments seems to depend on shifting the focus to another text area, which may not happen naturally for the last comment.
The behaviour above is different from LO saving odt docs and MSWord saving docx files with comments added.
Comment 7 Peter Robinson 2014-01-03 08:05:12 UTC
Confirm error behaviour described occurs with your attachment 91445 [details].
Comment 8 tommy27 2014-01-03 08:37:38 UTC
> OK.  I think I've narrowed it down.  Different sources of files were a
> coincidence.  I think this replicates the behaviour for any docx file.
> ....
> "ENTER-ing" comments seems to depend on shifting the focus to another text
> area, which may not happen naturally for the last comment.
> ...


great!!! now I'm able to reproduce your bug on Windows!!! 
the key is to save without moving the cursor outside the comment window.

set status to NEW and platform to ALL.
Comment 9 tommy27 2014-01-03 11:40:46 UTC
reproduced issue with older releases up to 3.5.0 (tested with 3.4.3 too but it looses all comments after saving and reloading) with issue still present in 4.2.0.1rc

the bug is specific to .docx format and does not affect .odt and .doc

edited summary notes, changed version field and added Writer expert to CC list.
Comment 10 tommy27 2014-07-20 09:50:23 UTC
still reproducible with 4.2.5.2 and 4.4.0.0.alpha0+
Build ID: b9dca968c6fd0ab5ca140c65b0e54d153cd34986
TinderBox: Win-x86@42, Branch:master, Time: 2014-07-18_22:51:20
Comment 11 Matt Price 2014-11-20 04:08:24 UTC
I think I am experiencing this bug (lost a whole bunch of grading this week as a result!).  I have LO 4.3.3.2 from Arch Linux repos; some macro customization which I am reluctant to lose so haven't tried purging my install yet.  Please let me know if there's some work I can do to help debug.
Comment 12 Matt Price 2014-11-20 16:14:17 UTC
I am finding that the content of comments created with a macro are also not being saved to docx.  So it is not dependent just on the final state of the document -- it seems to have to do with whether the comment was ever manually exited.  

Here's the macro I'm using:  

sub createCommentwithCheckmark
    rem create the annotation object
	oAnno = ThisComponent.createInstance("com.sun.star.text.textfield.Annotation")
	rem Chr 10004 is the decimal for hex code 2714, "heavy checkmark"
	oAnno.Content = Chr(10004)
	oAnno.Author = "Matt Price"
	oText = ThisComponent.Text
	rem check to see if anything is selected
	oSels = ThisComponent.getCurrentSelection()

	If Not IsNull(oSels) Then 
	oVC = ThisComponent.CurrentController.ViewCursor
		oText.insertTextContent(oVC, oAnno, True)

	Else 
		oVC = ThisComponent.CurrentController.ViewCursor
		oText.insertTextContent(oVC.Start, oAnno, False)
	End If
end sub

I'm guessing that using "insertTextContent" is the only line that really matters here
Comment 13 Matt Price 2014-11-20 18:33:28 UTC
Created attachment 109769 [details]
.odt demonstrating correct function

.odt file saves attachments properly, even if cursor remains in final annotation, and even though first annotation was input via macro with no manual intervention.
Comment 14 Matt Price 2014-11-20 18:34:28 UTC
Created attachment 109770 [details]
.docx shows auto-inserted annotation doesn't show up.

Shows auto-inserted annotation is not saved to .docx, despite being saved to .odt.
Comment 15 Matt Price 2014-12-10 02:14:42 UTC
Since this bug appears to persist in recent builds would it be permissible to change the version to 4.3.2 or similar?
Comment 16 tommy27 2014-12-10 04:38:13 UTC
no, this is not how the version field should be edited.

try to change it to a later version and you will see this message:

"You are changing the version of the bug to a later version. As the version field of the bug should show the earliest version manifesting the bug, please reconsider, if you really want to do this. Please do not change a version, because it also manifests in a later version. for details, please see the guidelines"
Comment 17 Matt Price 2014-12-10 15:03:29 UTC
thanks for the clarification, Tommy.
Comment 18 Gordo 2015-06-25 18:29:51 UTC
Still reproducible.

This only happens if Tools -> Options -> Load/Save -> General -> Warn when not saving in ODF or default format is unchecked, otherwise the warning dialogue takes focus and the comment saves.

Version: 4.4.4.3
Build ID: 2c39ebcf046445232b798108aa8a7e7d89552ea8

Version: 5.1.0.0.alpha1+
Build ID: 89b5967658392d27fb3147e85abb2b5c1c34b101
TinderBox: Win-x86@39, Branch:master, Time: 2015-06-24_04:10:17
Comment 19 Maris Nartiss 2015-06-29 10:49:59 UTC
I got hit by a combination of Bug 85523 and this one - my last comment was empty - just contained an "X" letter.
Version: 4.4.3.2 on ~AMD64 Gentoo

There are two more bugs on saving comments in docx - blank lines or "X" letters being appended on save (Bug 85523 and Bug 92312). Would be nice if someone could take a look at comment saving in docx, as they might be related.
Comment 20 Maris Nartiss 2015-06-29 11:28:26 UTC
(In reply to Peter Robinson from comment #6)
> 4.  The save button will grey out and disable, but in fact the last comment
> is not saved.  You can close the file (without getting any warning about
> saving) and re-open it and the last comment will be blank.

I was running LO under valgrind and observed a difference in this last step:
if LO is run in a normal way, original description holds (save; close; comment lost).

if LO is run under valgrind, LO after clicking "save" icon for once, LO still considers that there are unsaved changes and a) "save" button is active b) it offers to save changes if closing the document. After second save, comment text is really saved and no data loss is observable. Also second click on "save" button disables it, LO doesn't ask to save changes on close.

Unfortunately valgrind wasn't complaining about anything on adding comments, docx open/save (still it was run on a stock version from official RPMs not a debug one).
Version: 4.4.3.2 ~AMD64 Gentoo.
Comment 21 Maris Nartiss 2016-08-29 09:26:31 UTC
I was not able to reproduce this issue any more with:
Version: 5.2.0.4
Build ID: 066b007f5ebcc236395c7d282ba488bca6720265
CPU Threads: 2; OS Version: Linux 4.7; UI Render: default;
Comment 22 Timur 2016-12-09 19:00:49 UTC
Looks similar to Bug 68604 and I'll mark so. Please feel free to reopen if proved otherwise. 
Tommy and I both reproduced that one with Save icon. Seems like not happening with Save menu and it was always OK with Save As.

*** This bug has been marked as a duplicate of bug 68604 ***