Page 1 of 1

Saving document with footnote/endnote as XML will cause error

Posted: Sun Jul 10, 2022 10:55 am
by edwinyzh
I'm using the latest version of RichView.
Saving document with footnote/endnote as XML will cause error.

Steps to reproduce:
- Open 'RichViewActions\Demos\DelphiUnicode\ActionTest'
- Add a TRichViewXml (component property values are as following).
- Compile and run, goto Insert -> Insert FootNote (or EndNote), now save the document as xml (code below).
- Error will now happen.

TRichViewXml properties:

Code: Select all

var
  XMLStore: TRichViewXML;
  XMLStore := TRichViewXML.Create(Self);
  XMLStore.DefaultBreakColor := clNone;
  XMLStore.DefaultBreakWidth := 1;
  XMLStore.DefaultParaNo := 0;
  XMLStore.DefaultStyleNo := 0;
  XMLStore.DefaultVAlign := rvvaBaseline;
  XMLStore.Encoding := 'UTF-8';
  XMLStore.InsLoadBackground := False;
  XMLStore.InsLoadPrint := False;
  XMLStore.InsStyleLoadingMode := slmMerge;
  XMLStore.LoadBackground := False;
  XMLStore.LoadPrint := False;
  XMLStore.LoadTagMode := True;
  XMLStore.RichView := RichViewEdit1;
  XMLStore.RootElement := 'rvxml';
  XMLStore.SaveBackground := True;
  XMLStore.SaveImgToFiles := False;
  XMLStore.SavePrint := False;
  XMLStore.SaveSelectionBackground := True;
  XMLStore.SaveSelectionImgToFiles := False;
  XMLStore.SaveSelectionPrint := False;
  XMLStore.SaveSelectionStyles := True;
  XMLStore.SaveLineBreaks := True;
  XMLStore.SaveStyleNames := True;
  XMLStore.SaveStyles := False;
  XMLStore.StyleLoadingMode := slmMerge;
  XMLStore.UseStyleNames := False;
  XMLStore.WantTabs := False;
Code to save as xml:

Code: Select all

procedure TForm3.Saveasxml1Click(Sender: TObject);
var
  fn: string;
begin
  fn := ExtractFilePath(Application.ExeName) + 'text.xml';
  XMLStore.SaveToFile(fn);
end;
Call stack produced by madExcept for 'saving footnote error':

Code: Select all

exception class    : EListError
exception message  : List index out of bounds (-1).

main thread ($1dd4):
0051e18d +015 ActionTestUni.exe System.Classes          TList.Get
006cac4a +00a ActionTestUni.exe DLines          797  +1 TRVDrawLines.Get
00877ac8 +11c ActionTestUni.exe CRVFData       5730 +46 TCustomRVFormattedData.Item2DrawItem
00bdbb0b +103 ActionTestUni.exe RVXMLRoutines  2927 +18 WriteText
00be0ca1 +045 ActionTestUni.exe RVXMLRoutines  4073  +3 AddText
00be10a3 +3df ActionTestUni.exe RVXMLRoutines  4169 +90 SaveRVDataToXML
00bdcc34 +0a0 ActionTestUni.exe RVXMLRoutines  3144  +3 WriteNoteProps
00bdcc60 +008 ActionTestUni.exe RVXMLRoutines  3153  +1 WriteFootnote
00be09f4 +330 ActionTestUni.exe RVXMLRoutines  4034 +84 AddNonTextItem
00be0fc5 +301 ActionTestUni.exe RVXMLRoutines  4154 +75 SaveRVDataToXML
00beecb8 +36c ActionTestUni.exe RVXMLRoutines  7702 +75 RVSaveToXML
00bf11fa +112 ActionTestUni.exe RichViewXML     554 +19 TRichViewXML.SaveToXML
00bf10a6 +062 ActionTestUni.exe RichViewXML     526  +4 TRichViewXML.SaveToStream
00bf0ffa +066 ActionTestUni.exe RichViewXML     513  +4 TRichViewXML.SaveToFile
00bf89b8 +054 ActionTestUni.exe Unit3Unicode    935  +2 TForm3.Saveasxml1Click
madExcept-produced call stack for the endnote saving error:

Code: Select all

exception class    : EAccessViolation
exception message  : Access violation at address 0051E17E in module 'ActionTestUni.exe'. Read of address 00000008.

main thread ($30b8):
0051e17e +006 ActionTestUni.exe System.Classes          TList.Get
006cac4a +00a ActionTestUni.exe DLines          797  +1 TRVDrawLines.Get
00877ac8 +11c ActionTestUni.exe CRVFData       5730 +46 TCustomRVFormattedData.Item2DrawItem
00bdbb0b +103 ActionTestUni.exe RVXMLRoutines  2927 +18 WriteText
00be0ca1 +045 ActionTestUni.exe RVXMLRoutines  4073  +3 AddText
00be10a3 +3df ActionTestUni.exe RVXMLRoutines  4169 +90 SaveRVDataToXML
00bdcc34 +0a0 ActionTestUni.exe RVXMLRoutines  3144  +3 WriteNoteProps
00bdcc74 +008 ActionTestUni.exe RVXMLRoutines  3158  +1 WriteEndnote
00be0a1c +358 ActionTestUni.exe RVXMLRoutines  4039 +89 AddNonTextItem
00be0fc5 +301 ActionTestUni.exe RVXMLRoutines  4154 +75 SaveRVDataToXML
00beecb8 +36c ActionTestUni.exe RVXMLRoutines  7702 +75 RVSaveToXML
00bf11fa +112 ActionTestUni.exe RichViewXML     554 +19 TRichViewXML.SaveToXML
00bf10a6 +062 ActionTestUni.exe RichViewXML     526  +4 TRichViewXML.SaveToStream
00bf0ffa +066 ActionTestUni.exe RichViewXML     513  +4 TRichViewXML.SaveToFile
00bf89b8 +054 ActionTestUni.exe Unit3Unicode    935  +2 TForm3.Saveasxml1Click

Re: Saving document with footnote/endnote as XML will cause error

Posted: Tue Jul 12, 2022 5:53 pm
by Sergey Tkachenko
Assign SaveLineBreaks property = False.
I'll fix it in the next update.
Actually, this property is not too useful: it saves line breaks in places where text wraps. These line breaks cannot be loaded.
This option does not affect saving true line breaks, they are always saved and loaded.

Re: Saving document with footnote/endnote as XML will cause error

Posted: Wed Jul 13, 2022 2:25 am
by edwinyzh
Sergey Tkachenko wrote: Tue Jul 12, 2022 5:53 pm Assign SaveLineBreaks property = False.
I'll fix it in the next update.
Actually, this property is not too useful: it saves line breaks in places where text wraps. These line breaks cannot be loaded.
This option does not affect saving true line breaks, they are always saved and loaded.
I tried, it seems fixed the issue now. Thanks!