Page 1 of 1

DocX saved paragraph with single space, shows wrong in word

Posted: Tue Jan 09, 2024 10:26 am
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 46962 times
after load / save
richview.png
richview.png (49.49 KiB) Viewed 46962 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é

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

Posted: Tue Jan 09, 2024 2:03 pm
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)

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

Posted: Sun Jan 28, 2024 12:19 pm
by Sergey Tkachenko
Fixed in TRichView 22.2

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

Posted: Tue Apr 02, 2024 7:04 am
by a.weber
Ok - tested - works - one point less on the list.