Page 1 of 1

DocX loading empty paragraphs wrong font / style assigned

Posted: Thu Nov 23, 2023 9:32 am
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 48593 times
After TRichView Save all empty lines share the default font and style.
newsaved.png
newsaved.png (13.24 KiB) Viewed 48593 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é

Re: DocX loading empty paragraphs wrong font / style assigned

Posted: Thu Nov 23, 2023 9:39 am
by Sergey Tkachenko
What version of TRichView do you use?

Re: DocX loading empty paragraphs wrong font / style assigned

Posted: Thu Nov 23, 2023 9:49 am
by a.weber
My version info says 21.7.3 installed with the binary from 03.11.2023 (signature timestamp) ?

Re: DocX loading empty paragraphs wrong font / style assigned

Posted: Thu Nov 23, 2023 11:03 am
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.

Re: DocX loading empty paragraphs wrong font / style assigned

Posted: Thu Nov 23, 2023 11:18 am
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)

Re: DocX loading empty paragraphs wrong font / style assigned

Posted: Sun Dec 03, 2023 3:15 pm
by Sergey Tkachenko
Fixed in TRichView v22.1

Re: DocX loading empty paragraphs wrong font / style assigned

Posted: Mon Dec 04, 2023 1:07 pm
by a.weber
Thanks. I will give it a try.

Re: DocX loading empty paragraphs wrong font / style assigned

Posted: Mon Jan 08, 2024 12:28 pm
by a.weber
Is working now. Thank you.