We have a letter editor that may work with RTF letters or plain text emails, depending upon what is selected from a dropdown. When saving changes to any of the letters, a check is done to ensure that any email with content also has a Subject.
We are using Editor.SaveToStream to save the editor content back to the appropriate letter/email whenever the combo box changed, or the Done button was clicked. In WPTools 4, this worked. In version 5.20.8, it has the following problem. If we delete the content of an email and its Subject, we receive a warning that no subject exists for an email with content.
procedure TsViewEditFormLetterDialog.GetLetterFromEditor;var lActiveLetter: TStringStream;begin lActiveLetter := GetActiveLetter(); if StringIsNotEmpty(lActiveLetter.DataString) or StringIsNotEmpty(Editor.Text) then begin if fEditorIsInEditMode then Editor.SaveToStream(lActiveLetter) else fTemplateStorage.RTFText.SaveToStream(lActiveLetter); end;end;
We discovered that the blank email was still seen by the system to contain content because of the RTF codes that were still present after deleting all the words.
I modified the code as shown below to special case the emails to use Editor.SaveToStream(s, 'ANSI').
procedure TsViewEditFormLetterDialog.GetLetterFromEditor;
var
lActiveLetter: TStringStream;
begin
lActiveLetter := GetActiveLetter();
if StringIsNotEmpty(lActiveLetter.DataString) or StringIsNotEmpty(Editor.Text) then
begin
case fActiveLetterLanguage of
fllEnglish, fllSpanish, fllFrench, fllOther :
if fEditorIsInEditMode then
Editor.SaveToStream(lActiveLetter)
else
fTemplateStorage.RTFText.SaveToStream(lActiveLetter);
fllEnglishEmail, fllSpanishEmail, fllFrenchEmail, fllOtherEmail :
if fEditorIsInEditMode then
Editor.SaveToStream(lActiveLetter, 'ANSI')
else
fTemplateStorage.RTFText.SaveToStream(lActiveLetter);
end;
end;
end;
Alles anzeigen
When using this code, lActiveLetter did NOT get emptied by the SaveToStream(lActiveletter, 'ANSI') statement when the Editor had no content.
When SaveToStream is used with no parameters, the visible words DO get removed from lActiveletter when the Editor had no content.
Is this a bug in the ANSI version of SaveToStream? It appears so to me.