DocX saved paragraph with single space, shows wrong in word

General TRichView support forum. Please post your questions here
Post Reply
a.weber
Posts: 63
Joined: Wed Mar 02, 2022 7:02 am

DocX saved paragraph with single space, shows wrong in word

Post by a.weber »

Hi,
my document starts with a paragraph containing only a single space and with a very small font size, after load / save with RichView Word shows the Linebreak Symbol? with the default font and size - but the paragraph (space character) has still the right style.
original.png
original.png (47.59 KiB) Viewed 59911 times
after load / save
richview.png
richview.png (49.49 KiB) Viewed 59911 times
The issue is that word seems the expect that a <w:rPr> element is allways written also if the paragraph is not empty. Currently its only written if the paragraph is empty. So the problem may be in CRVData.pas method TCustomRVData.SaveOOXMLDocumentToStream -> WriteParaProps( .. ) ? And the decision to call WriteRunProps(..) ?
(as PM you will receive my commented version of this piece of code I modified)

André
Attachments
richview.docx
(4.14 KiB) Downloaded 2192 times
original.docx
(23.14 KiB) Downloaded 2103 times
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: DocX saved paragraph with single space, shows wrong in word

Post by Sergey Tkachenko »

I can see the problem.

MS Word has invisible "end-of-paragraph mark" character that may have its own text attributes, such as font name and size.
TRichView does not have this character, so it saves its properties in DocX only if it is absolutely necessary (if the paragraph is empty).
Normally, it is not a big problem, because this character is invisible, and it does not affect line height.

But as I can see from your example, if the paragraph contains only a space character, height of end-of-paragraph mark is taken into account when calculating line height! And, as I can see, it happens if the line contains any number of whitespace characters (spaces and tabs). I did not know that before.
I think TRichView should save properties of the last text item in the paragraph as end-of-paragraph mark properties (at least, for non-bulleted paragraphs, because MS Word applies some end-of-paragraph properties to the list marker too)
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: DocX saved paragraph with single space, shows wrong in word

Post by Sergey Tkachenko »

Fixed in TRichView 22.2
a.weber
Posts: 63
Joined: Wed Mar 02, 2022 7:02 am

Re: DocX saved paragraph with single space, shows wrong in word

Post by a.weber »

Ok - tested - works - one point less on the list.
Post Reply