Bug 38778 - FILESAVE: character formatting applied to fields not preserved when saving as DOC or as DOCX
Summary: FILESAVE: character formatting applied to fields not preserved when saving as...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Serge Krot (CIB)
URL:
Whiteboard: target:6.0.0
Keywords: filter:doc, filter:docx
: 45417 97413 (view as bug list)
Depends on:
Blocks: DOCX-Fields DOC-Fields
  Show dependency treegraph
 
Reported: 2011-06-29 08:23 UTC by Trevor
Modified: 2017-11-06 09:39 UTC (History)
9 users (show)

See Also:
Crash report or crash signature:


Attachments
Document that exhibits problem - look for font changes on p.4-5 (40.00 KB, application/msword)
2011-06-29 08:23 UTC, Trevor
Details
PDF showing document with TImes New Roman font - good, expected, saved form (125.06 KB, application/pdf)
2011-06-29 08:25 UTC, Trevor
Details
PDF showing document with Courier font for numbers, immediately after reopening - bad (125.20 KB, application/pdf)
2011-06-29 08:27 UTC, Trevor
Details
MS Word doc again, except default font was changed from Courier to Times New Roman. (40.00 KB, application/msword)
2011-06-29 21:48 UTC, Trevor
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Trevor 2011-06-29 08:23:59 UTC
Created attachment 48557 [details]
Document that exhibits problem - look for font changes on p.4-5

In a text document that I created using LibO 3.4.0 on my Linux box, I am having trouble saving certain formatting related to the page number fields in the footer and to the item number in numbered lists.

I set virtually all text (except some titles) to the font, Times New Roman.  I am able to print what I expect, and I can save what I expect to PDF, as long as I leave the document open.  However, whenever I save the document, close LibreOffice, and reopen the same document, the formatting is lost.  Specifically, the page number fields in the footer, and the item numbers in numbered lists have all changed to Courier.  I have to change the fonts back to Times New Roman every time I reopen the file.  It's really frustrating.

This seems to be a bug in either the importer or exporter.

The document is saved as a DOC (Microsoft Word 97/2000/XP) format.

To repeat, simply open the document, select all text below the title on page 4 through the end of page 5 and save.  Observe Courier fonts change to Times New Roman.  Restart and observe that numbers have reverted to Courier font, despite previous change.
Comment 1 Trevor 2011-06-29 08:25:33 UTC
Created attachment 48558 [details]
PDF showing document with TImes New Roman font - good, expected, saved form
Comment 2 Trevor 2011-06-29 08:27:50 UTC
Created attachment 48559 [details]
PDF showing document with Courier font for numbers, immediately after reopening - bad
Comment 3 Jeffrey 2011-06-29 19:51:34 UTC
I cannot seem to reproduce the problem on LibreOffice 3.4  340m1(Build:12) Opensuse for Linux.

Here is what I did:

1. Downloaded and saved Timothy and Titus. All font is in Times New Roman except for some of the titles.
2. Saved as Timothy and Titus PDF.
3. Open PDF -- all font stays the same.
3. Close PDF, Writer and all other LO documents.
4. Open PDF and Writer, all fonts stay the same in both. Header and footer fonts are ok, titles are ok.

Did I follow your steps correctly? If so, I understand that you have been very thorough with your explanation, but it would help me a bit if you were more explicit with bullet by bullet steps. Thanks.
Comment 4 Trevor 2011-06-29 21:33:55 UTC
Hi,

Thanks for the quick response!  Wow!!!

The PDF's are only provided as "screenshots", so you can see what I see.  As far as I can tell, the PDF export is working great.  (I have not tried to read the PDF in anything but Adobe Acrobat.)  Here's the step-by-step:

1.  Download timothy_and_titus.doc.
2.  Open it in LO Writer.  
3.  Compare to PDF's.  If you are seeing the problem that I am seeing, then your open doc should look like the "bad one", timothy_and_titus_fresh_open_bad.pdf.  Specifically, look at the question numbers on pages 4 and 5.  Page 5 is the worst.  All of the question numerals are in Courier font, which messes up the indention and looks funny, because the rest is in Times New Roman, except the titles.  At the bottom of pages 2-5, in the footer, you should also see that the page number (2, 3, 4, and 5) is in Courier, not Times New Roman.
4.  That is all wrong.  All that Courier stuff should be Times New Roman.  So, I select all the lesson text (text below the title on page 4 to the end of the document) and choose "Times New Roman" in the "Formatting" toolbar, which immediately fixes the problem.
5.  I select all the text in the footer, and similarly convert it to Times New Roman, which fixes the page number being Courier.
6.  At this point, the document should look fine, like I want it.  Please compare to timothy_and_titus_good.doc.  It should look the same as the current state of LO Writer.
7.  Save the changes to timothy_and_titus.doc.
8.  Exit LO Writer.
9.  Double-click the saved doc to re-open with LO Writer.
10. Compare results.  All my changes saved from step 4-7 are lost.  I'm back to step 3.  The contents look like the "bad" one again.

I can go round and round, repeating steps 3-10, and it never is permanently fixed.  The changes never persist from one LO Writer session to another.

If this still doesn't make sense, or if you need some real screenshots, please let me know.

Thanks!

Trevor
Comment 5 Trevor 2011-06-29 21:48:25 UTC
Created attachment 48575 [details]
MS Word doc again, except default font was changed from Courier to Times New Roman.

Incidentally, I changed ALL of my default fonts (Tools -> Options -> LibreOffice Writer -> Basic Fonts (Western)) to all "Times New Roman", and now the list numerals and page number fields are all appearing in "Times New Roman".

It smells like the MS Word 97/2000/XP importer (or maybe exporter) is somehow losing, or unable to determine the font for these numerals, and so it is reverting to the default fonts, which were previously all Courier for me.  What are your default fonts?  Are they also Courier?

I'm attaching the newly saved version, in case you can see anything different in the files, after I changed all my default fonts (Default, Caption, Heading, Index, etc.) from Courier to Times New Roman.

Thanks!
Comment 6 Jean-Baptiste Faure 2011-12-04 12:22:36 UTC
@reporter: Please could you try again with the current release (LibO 3.4.4)?
Remark: You should change the font in standard style from Courier to Time New Roman.

Best regards. JBF
Comment 7 sasha.libreoffice 2012-01-27 08:25:14 UTC
reproduced in LibO 3.6.0 master on Fedora 64 bit
steps to reproduce:
0. open first attachment in Writer
1. go to last page and select all footer
2. change font to another, for example to Nimbus
3. save document
4. do File->Reload
5. go to last page and select grey field in footer
Expected: it will Nimbus
Actually: it Curier

I done the same steps in MSWord 2003. It saves font of page number.
Comment 8 sasha.libreoffice 2012-01-27 08:28:18 UTC
@Cedric
Please, see on it. Problem is interesting
Comment 9 ign_christian 2013-06-22 09:42:03 UTC
*** Bug 45417 has been marked as a duplicate of this bug. ***
Comment 10 ign_christian 2013-06-22 09:49:45 UTC
Still reproducible (page number case) on LO 4.0.4.2 (Win7 32bit)

Bug 45417 is the opposite: Courier to Times
Comment 11 Cédric Bosdonnat 2014-01-20 08:57:56 UTC
Restricted my LibreOffice hacking area
Comment 12 Joel Madero 2015-05-02 15:44:40 UTC Comment hidden (obsolete)
Comment 13 richard.strangelove 2015-05-02 21:35:34 UTC
Tested again just now, still happens exactly the same. Current operating system: Windows 7 Ultimate (64Bit), and Libreoffice Version: 4.4.2.2
Build ID: c4c7d32d0d49397cad38d62472b0bc8acff48dd6.
Comment 14 Cor Nouws 2016-05-27 07:41:02 UTC
The formatting of the page number is done with direct formatting - the style is Courier. Direct formatting on fields is not preserved when saving as doc.

As per bug 97413: this happens for docx too.
Comment 15 Cor Nouws 2016-05-27 07:41:27 UTC
*** Bug 97413 has been marked as a duplicate of this bug. ***
Comment 16 Yousuf Philips (jay) 2017-05-10 00:19:39 UTC
For DOCX, LO is only adding the <w:highlight> tag to the first run element that make up a field.

<w:r>
  <w:rPr>
    <w:highlight w:val="yellow" /> <-- this is the highlight
  </w:rPr>
  <w:fldChar w:fldCharType="begin" w:fldLock="true"></w:fldChar>
</w:r>
<w:r> <-- highlight missing from <w:rPr> tag
  <w:instrText>TIME \@"HH:mm:ss"</w:instrText>
</w:r>
<w:r> <-- highlight missing from <w:rPr> tag
  <w:fldChar w:fldCharType="separate" />
</w:r>
<w:r> <-- highlight missing from <w:rPr> tag
  <w:t>14:01:13</w:t>
</w:r>
<w:r> <-- highlight missing from <w:rPr> tag
  <w:fldChar w:fldCharType="end" />
</w:r>

how its done in MSO 2010

<w:r w:rsidRPr="007F2374">
  <w:rPr>
    <w:highlight w:val="yellow" /> <!-- highlight
  </w:rPr>
  <w:fldChar w:fldCharType="begin" w:fldLock="1" />
</w:r>
<w:r w:rsidRPr="007F2374">
  <w:rPr>
    <w:highlight w:val="yellow" /> <!-- highlight
  </w:rPr>
  <w:instrText>TIME \@"HH:mm:ss"</w:instrText>
</w:r>
<w:r w:rsidRPr="007F2374">
  <w:rPr>
    <w:highlight w:val="yellow" /> <!-- highlight
  </w:rPr>
  <w:fldChar w:fldCharType="separate" />
</w:r>
<w:r w:rsidRPr="007F2374">
  <w:rPr>
    <w:highlight w:val="yellow" /> <!-- highlight
  </w:rPr>
  <w:t>14:01:13</w:t>
</w:r>
<w:r w:rsidRPr="007F2374">
  <w:rPr>
    <w:highlight w:val="yellow" /> <!-- highlight
  </w:rPr>
  <w:fldChar w:fldCharType="end" />
</w:r>
Comment 17 Serge Krot (CIB) 2017-10-17 17:12:01 UTC
Implemented:
* Write run properties for all w:runs in field definition during export into DOCX.
Comment 18 Andreas Brandner 2017-10-20 11:21:57 UTC
*** Bug 66401 has been marked as a duplicate of this bug. ***
Comment 19 Commit Notification 2017-10-23 15:24:58 UTC
Serge Krot committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ccf475364881cebc13d50cf2cc9af2040b416bd3

tdf#38778 fix missing run properties export for fields in docx

It will be available in 6.0.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 20 Serge Krot (CIB) 2017-10-25 10:13:05 UTC
If inside DOCX the problem was - completely missing character property set for field declaration (inside each w:run), inside DOC output the problem is different: all properties look to be exported except only one - font name.
Comment 21 Commit Notification 2017-10-25 18:45:41 UTC
Serge Krot committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b7e8c7631d3ef3af53e873a9435bd954790cab05

tdf#38778 Added colors into run properties of field run

It will be available in 6.0.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 22 Commit Notification 2017-10-28 01:32:13 UTC
Serge Krot committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=9a9cfb1d80cea14abddea3d2e18fedb1549c9293

related tdf#38778 Speed-up: Do not traverse the whole array

It will be available in 6.0.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 23 Serge Krot (CIB) 2017-11-01 16:44:33 UTC
Implemented:
-    Avoid output of the font-nodes into DOCX
-    Added unit test DECLARE_WW8EXPORT_TEST(testTdf38778, "tdf38778_properties_in_run_for_field.doc")
-    Enhanced unit test: DECLARE_RTFEXPORT_TEST(testCp1000018, "cp1000018.rtf")
-    Enabled several old unit tests under Win32 (that are currently work there without any modification). There are 3 old remaining unit tests that are disabled and failed under Win32 (it is unknown from which revision they start to fail).
Comment 24 Commit Notification 2017-11-03 10:39:20 UTC
Serge Krot committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=3f2e84b4bd0bbd936e0af845ba7cbf68cb2803d6

tdf#38778 Fix output of the font in DOC run

It will be available in 6.0.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.