DocX loading empty paragraphs wrong font / style assigned

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

DocX loading empty paragraphs wrong font / style assigned

Post by a.weber »

Hello,
docx files saved with Word are missing <w:r> .. </w:r> element for empty paragraphs there is only a <w:pPr> element setting font and style and so on inside <w:rPr>, but currently this element is not taken into account durring loading. The result is that empty paragraphs get the default font and style assigned.

Original in Word - the empty paragraphs have a different Font / Size Syle:
original.png
original.png (14.42 KiB) Viewed 47076 times
After TRichView Save all empty lines share the default font and style.
newsaved.png
newsaved.png (13.24 KiB) Viewed 47076 times
(TRichView currently saves a <w:r> element also for empty paragraphs is this really required for some word process application?)

I tried to fix this and modified: (I am not sure if this breaks something else?)

TRVDocXReader.LoadParagraph( ... )

procedure LoadParaProps( .. )
begin
... your code ...
// and inserted these lines just before end;
if PropNode <> nil then
begin
// Weber: 23.11.23 empty paragraphs in MSWord DocX doesnt' have a <w:r> element, so we must read the <r:rPr>
// from the paragraph?
ReadCharProperties := [];
LoadCharProperties(FParaCharProperties, FindChildNode(PropNode, 'w:rPr', RVDOCX_XMLNS_W), ReadCharProperties);
// is this correct to set these flags in this location in that case?
FCurParaCharPropSet := FCurParaCharPropSet + ReadCharProperties;
end;
end;

André
Attachments
EmptyParagraph.docx
Sample Document
(13.09 KiB) Downloaded 2832 times
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: DocX loading empty paragraphs wrong font / style assigned

Post by Sergey Tkachenko »

What version of TRichView do you use?
a.weber
Posts: 63
Joined: Wed Mar 02, 2022 7:02 am

Re: DocX loading empty paragraphs wrong font / style assigned

Post by a.weber »

My version info says 21.7.3 installed with the binary from 03.11.2023 (signature timestamp) ?
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: DocX loading empty paragraphs wrong font / style assigned

Post by Sergey Tkachenko »

Ok, I'll check this problem at the beginning of the next week.
I already uploaded Delphi12-compatible versions of TRichView, but I still need to update RVMedia ASAP.
a.weber
Posts: 63
Joined: Wed Mar 02, 2022 7:02 am

Re: DocX loading empty paragraphs wrong font / style assigned

Post by a.weber »

That is ok - my fix has some other effects if there are true styles assigned in the docx the style must win and the other properties ignoriert.
(it is not so trivial like I thought)
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: DocX loading empty paragraphs wrong font / style assigned

Post by Sergey Tkachenko »

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

Re: DocX loading empty paragraphs wrong font / style assigned

Post by a.weber »

Thanks. I will give it a try.
a.weber
Posts: 63
Joined: Wed Mar 02, 2022 7:02 am

Re: DocX loading empty paragraphs wrong font / style assigned

Post by a.weber »

Is working now. Thank you.
Post Reply