TReportRichview and Insert* methods
Posted: Wed Sep 10, 2014 12:19 pm
We use ricvhiew to define letter templates and then generate personalized letters. Everything worked excellently until we refactored our application to multitier using datasnap technology.
Then we started getting a lot of 'Canvas' errors on server side. Searching about that topic I found that TRichviewEdit is not threadsafe and that I should use TReportRichView instead.
The main problem here is that TReportRichView is missing some important methods like:
* InsertText
* InsertItem to insert tables
* InsertRVFFromStreamEd
* InsertPageBreak
and some less important methods like:
* ApplyTextStyle (set font style to barcode)
* ApplyStyleConversion (bold, italic, underline)
* ApplyParaStyleConversion (aligment)
Is there any chance that these method will get introduced to TReportRichView?
I also included code snippet of current usage.
Currently we have partially working solution to make invisible Richview with allocated hwnd, what works most of the time, but not always
Then we started getting a lot of 'Canvas' errors on server side. Searching about that topic I found that TRichviewEdit is not threadsafe and that I should use TReportRichView instead.
The main problem here is that TReportRichView is missing some important methods like:
* InsertText
* InsertItem to insert tables
* InsertRVFFromStreamEd
* InsertPageBreak
and some less important methods like:
* ApplyTextStyle (set font style to barcode)
* ApplyStyleConversion (bold, italic, underline)
* ApplyParaStyleConversion (aligment)
Is there any chance that these method will get introduced to TReportRichView?
I also included code snippet of current usage.
Code: Select all
procedure ScanData(ARVData: TCustomRVFormattedData);
var
content, replacement: string;
replace: Boolean;
startItemNo, startItemOffs, endItemNo, EndItemOffs: Integer;
lStartItemNo, lStartItemOffs, lEndItemNo, lEndItemOffs: Integer;
offs: Integer;
rvData: TCustomRVFormattedData;
begin
rvData := TCustomRVFormattedData(ARVData.Edit);
offs := rvData.GetOffsBeforeItem(0);
rvData.SetSelectionBounds(0, offs, 0, offs); // Move to beginning
while rvData.SearchTextR(True, False, False, False, True, False, False, RVU_GetRawUnicode(StartTag)) do
begin
rvData.GetSelectionBounds(startItemNo, startItemOffs, endItemNo, EndItemOffs, True);
if not rvData.SearchTextR(True, False, False, False, True, True, False, RVU_GetRawUnicode(EndTag)) then
raise EUnclosedFieldException.Create(_('Unclosed field: %s', [StartTag]));
rvData.GetSelectionBounds(lStartItemNo, lStartItemOffs, lEndItemNo, lEndItemOffs, True);
// Select tag content
rvData.SetSelectionBounds(startItemNo, startItemOffs, lEndItemNo, lEndItemOffs);
content := Trim(RVU_RawUnicodeToWideString(rvData.GetSelTextR(True)));
content := Copy(content, Length(StartTag) + 1, Length(content) - Length(StartTag) - Length(EndTag));
if content = '' then
Continue;
replace := True;
replacement := '';
OnData(FOrigTemplate, StartTag, EndTag, content, replacement, replace);
if replace then
begin
FOrigTemplate.InsertText(replacement, True);
rvData.Format(True, False);
end;
end;
end;
Code: Select all
FHwnd := AllocateHWnd(nil);
FRichView := TRVTemplateEdit.CreateParented(FHwnd);
FRichView.Visible := False;
FRichView.Options := FRichView.Options - [rvoFormatInvalidate];