DocX loading empty paragraphs wrong font / style assigned
Posted: Thu Nov 23, 2023 9:32 am
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: After TRichView Save all empty lines share the default font and style. (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é
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: After TRichView Save all empty lines share the default font and style. (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é