Bug 112797 - FILEOPEN: DOCX - Document set to modified on opening (<w:instrText> PAGEREF \h </w:instrText>)
Summary: FILEOPEN: DOCX - Document set to modified on opening (<w:instrText> PAGEREF ...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: lowest minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: filter:docx
: 140491 (view as bug list)
Depends on:
Blocks: DOCX-Fields ModifiedStatus
  Show dependency treegraph
 
Reported: 2017-10-01 07:26 UTC by Mike
Modified: 2022-10-03 20:58 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
test case (127.42 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2017-10-01 07:26 UTC, Mike
Details
Image of issue (142.56 KB, application/pdf)
2017-10-01 07:28 UTC, Mike
Details
Test case opened and saved with 'ThinkFree Office Word' (19.91 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2017-10-01 07:48 UTC, Mike
Details
Test case opened and saved with 'TextMaker 2016' (121.09 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2017-10-01 07:48 UTC, Mike
Details
Minimum test case (4.35 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2017-11-02 05:58 UTC, Mike
Details
Screenshots and description (214.73 KB, application/pdf)
2017-11-02 05:59 UTC, Mike
Details
Manually fixed Minimum test case (4.27 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2017-11-19 09:20 UTC, Mike
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike 2017-10-01 07:26:08 UTC
Description:
Writer shows immediately after opening this file the 'There are 
changes to be saved' icon with the star.
If you save the file as a docx, close Writer and open the docx 
with Writer again, the "changes to be saved" icon shows up 
again. This icon disappears if you save the document as a odt 
file and open that odt file.
I prefer ODT anyway, but in my opinion this issue is an 
interesting behaviour, that is worth a report.

Steps to Reproduce:
1. Open File


Actual Results:  
In the menu bar should be the "normal" save icon (floppy disk icon).

Expected Results:
In the menu bar is the "there are changes to be saved icon (floppy disk icon with star"-


Reproducible: Always

User Profile Reset: No

Additional Info:
Searched via "file open save changes icon" for dupes, but did not found one


Version: 5.4.1.2 (x64)
Build-ID: ea7cb86e6eeb2bf3a5af73a8f7777ac570321527
CPU-Threads: 4; Betriebssystem:Windows 6.19; UI-Render: Standard; 
Gebietsschema: de-DE (de_DE); Calc: group


User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0
Comment 1 Mike 2017-10-01 07:26:53 UTC Comment hidden (obsolete)
Comment 2 Mike 2017-10-01 07:28:03 UTC Comment hidden (obsolete)
Comment 3 Mike 2017-10-01 07:34:18 UTC Comment hidden (obsolete)
Comment 4 Mike 2017-10-01 07:47:24 UTC Comment hidden (obsolete)
Comment 5 Mike 2017-10-01 07:48:11 UTC Comment hidden (obsolete)
Comment 6 Mike 2017-10-01 07:48:39 UTC Comment hidden (obsolete)
Comment 7 Mike 2017-10-01 07:51:11 UTC Comment hidden (obsolete)
Comment 8 Mike 2017-10-01 07:53:18 UTC Comment hidden (obsolete)
Comment 9 Dieter 2017-10-01 09:02:38 UTC Comment hidden (obsolete)
Comment 10 Xisco Faulí 2017-10-01 22:00:52 UTC Comment hidden (obsolete)
Comment 11 Mike 2017-11-02 05:58:39 UTC
Created attachment 137437 [details]
Minimum test case
Comment 12 Mike 2017-11-02 05:59:13 UTC
Created attachment 137438 [details]
Screenshots and description
Comment 13 Mike 2017-11-02 06:01:57 UTC
The issue with “thesis.docx” could not be confirmed by another member. 

Out of curiosity I mailed the test case to a Linux user, who could confirm the issue. He uses Ubuntu 17.02 and LO 5.3.1.2. Then I created and tested this minimum test case.

Would someone be so nice and open the attached file “FILEOPEN DOCX - file in modified state directly after opening of file.docx”? This is a minimum test case (5 kb) of the original file, that I attached to this report (“thesis.docx”)

I had the issue in

Version: 6.0.0.0.alpha1+ (x64)
Build ID: 9ea8686d3573540b697b51d1e2e00bfe2d57d872
CPU threads: 4; OS: Windows 10.0; UI render: default; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2017-10-29_07:23:44
Locale: de-DE (de_DE); Calc: CL

And 

Version 3.6.4.3 (Build ID: 2ef5aff)

I did not have the issue in LO 3.3.0, so it is not inherited.

LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4

Can someone confirm this issue? I attached a PDF with screenshots.
Many thanks in advance! :-)


P. S. MS’s ‘Open XML Productivity Tool’ found no error.
Comment 14 Dieter 2017-11-02 06:51:37 UTC Comment hidden (obsolete)
Comment 15 Buovjaga 2017-11-10 15:20:46 UTC
(In reply to Mike from comment #11)
> Created attachment 137437 [details]
> Minimum test case

I confirm the problem with the file.

Version: 6.0.0.0.alpha1+ (x64)
Build ID: 4058d85963e371be657f531d8f30e31381a9ccab
CPU threads: 4; OS: Windows 10.0; UI render: default; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2017-11-05_22:51:05
Locale: fi-FI (fi_FI); Calc: group

Arch Linux 64-bit, KDE Plasma 5
Version: 6.0.0.0.alpha1+
Build ID: 1aba1955f161cc112dab80b6b3e78ec7761616fc
CPU threads: 8; OS: Linux 4.13; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on November 10th 2017
Comment 16 Mike 2017-11-19 09:20:10 UTC
Created attachment 137846 [details]
Manually fixed Minimum test case

I have NOT a coder, but I did some trial-and-error with the minimum test case and found a hint:

1. Open minimum test case ("FILEOPEN DOCX - file in modified state directly after opening of file.docx", 5kb only)
2. Open word\document.xml in the DOCX
3. Delete the lines 

<w:r>
<w:instrText> PAGEREF  \h </w:instrText>
</w:r>

4. Save the test case again as a DOCX
5. Open the new DOCX
6. New DOCX is not opened in "modified state".

P.S.
I opened the lines in Open XML Productivity tool and they mean:

          Run run2 = new Run();
          FieldCode fieldCode1 = new FieldCode();
          fieldCode1.Text = " PAGEREF \\h ";

(Can't understand it, I'm not a coder)
Comment 17 Mike 2017-11-19 09:24:57 UTC Comment hidden (obsolete)
Comment 18 Yousuf Philips (jay) (retired) 2017-11-19 13:07:31 UTC
So the issue is inherited from OOo, though earlier versions didnt have the changed saved icon, but closing the document will then ask to save changes. Assume the issue boys down to fields being update on opening.

@Dieter: The DOCX-Opening meta tag is for docx files that arent able to open, not bugs that have a bug in them after opening.
Comment 19 QA Administrators 2018-11-20 03:43:06 UTC Comment hidden (obsolete)
Comment 20 NISZ LibreOffice Team 2020-11-26 14:20:39 UTC
Still a problem in:

Version: 7.2.0.0.alpha0+ (x64)
Build ID: cb084f475db33a2cfc62bc9c8de37b8c3c87b3c7
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: Skia/Raster; VCL: win
Locale: hu-HU (hu_HU); UI: en-US
Calc: CL
Comment 21 Timur 2022-10-03 09:33:10 UTC
*** Bug 140491 has been marked as a duplicate of this bug. ***
Comment 22 Timur 2022-10-03 09:33:22 UTC
*** Bug 143845 has been marked as a duplicate of this bug. ***
Comment 23 Timur 2022-10-03 09:34:52 UTC
It's about missing reference. 
I'm not sure this should be fixed, my take is WontFix.
Comment 24 Justin L 2022-10-03 20:58:06 UTC
The code being called is sw/source/core/doc/DocumentStateManager.cxx DocumentStateManager::SetModified() which can run if IsEnableSetModified().

This is triggered by DocumentFieldsManager::UpdateFields which ALWAYS marks as modified every time it is run.

UpdateFields is called by writerfilter/source/dmapper/ModelEventListener.cxx via a rather generic uno "refresh()" call. The only way around this that I can imagine is to extend the uno call to accept "bEnableSetModified".

Unless we can get away with doing this (it passes a make check):
+        IDocumentState& rIDS = GetDoc()->getIDocumentState();
+        const bool bOldSetModified = rIDS.IsEnableSetModified();
+        if (bOldSetModified)
+            rIDS.SetEnableSetModified(false);
        GetDoc()->getIDocumentStatistics().UpdateDocStat( false, true );
        GetDoc()->getIDocumentFieldsAccess().UpdateFields(false);
+        if (bOldSetModified)
+            rIDS.SetEnableSetModified(true);