Sergey,
I read your previous posts about needing a separate TRichView component to update styles using InsertRVFFromStream since inserting into table cells does not update styles.
Unfortunately I am still having problems. I create a document with many tables, some of which contain RVF text. These tables are 1 row, 1 column. The first table always populates correctly, and all tables after that are fine until I insert RVF text that contains styles that do not exist so far. In other words, the first RVF inserted that contains new styles inserts correctly, but every RVF inserted after that with *different* styles than those already added simply does not display at all.
I have monitored the number of styles being added, and new styles are always added where appropriate, even for the inserts where the text does not display.
Here is my code to create the table (the CreateRVTable method is central code for creating a table with the specifications in rcTableInfo):
procedure TfmAccountInquiry.CreateNotesDetailTable;
var
NotesDetailTable : TRVTableItemInfo;
begin
// create private payment detail table
InitializeTableInfo;
with rcTableInfo do begin
TableBorderColor := clMaroon;
TableBorderWidth := 1;
TableRows := 1;
TableColumns := 1;
TextColor := clWhite;
TextBorderWidth := 1;
TextBorderColor := clMaroon;
end;
// create table
CreateRVTable(NotesDetailTable, rcTableInfo, rvDetail.RVData);
dmAcctInquiryMod.DisplayNoteDetail(NotesDetailTable, rv1, rv2);
end;
Here is the code for the last line above (DisplayNoteDetail). Note that I pass a variable (NotesDetailTable) of type TRVTableItemInfo:
procedure TdmAcctInquiryMod.DisplayNoteDetail(TableInstance : TRVTableItemInfo;
rv1, rv2 : TRichView);
begin
with tbNotesDetail do begin
FillRVTableCellWithRVF(TableInstance, 0, 0, clUseExisting,
psLeftIndentNoWrap, TBlobField(FieldByName('not_rvf')), rv1, rv2);
end;
end;
finally, I call FillRVTableCellWithRVF:
procedure TdmAcctInquiryMod.FillRVTableCellWithRVF(TableInstance : TRVTableItemInfo;
TableRow, TableColumn : word; CellColor : TColor; TextParaNo : word;
RVFField : TBlobField; rv1, rv2 : TRichView);
var
MS_Source : TMemoryStream;
MS_Dest : TMemoryStream;
Dummy1 : TColor;
Dummy2, Dummy3 : Pointer;
begin
// add RVF to individual cell
Dummy1 := clNone;
Dummy2 := nil;
Dummy3 := nil;
try
MS_Source := TMemoryStream.Create;
MS_Dest := TMemoryStream.Create;
RVFField.SaveToStream(MS_Source);
with TableInstance.Cells[TableRow, TableColumn] do begin
Clear;
dmGeneralMod.UncompressBLOB(MS_Source, MS_Dest);
// override colors?
if CellColor <> clUseExisting then
Color := CellColor;
// write directly to TRichView object first so styles are merged ...
// cell-based RVF functions do not merge styles
MS_Dest.Position := 0;
rv1.Clear;
rv1.InsertRVFFromStream(MS_Dest, 0); // inserting will merge styles;
MS_Dest.Clear;
rv1.SaveRVFToStream(MS_Dest, False);
MS_Dest.Position := 0;
MS_Dest.Position := 0;
InsertRVFFromStream(MS_Dest, 0, Dummy1, Dummy2, Dummy3, False);
end;
finally
MS_Source.Free;
MS_Dest.Free;
end;
end;
Note that I am passing parameters for rv1 and rv2. I use rv1 to update the styles as in your mailmerge2 demo. The other one, rv2, is for testing purposes. I wanted to make sure the RVF code is not corrupted, so I swapped out the last InsertRVFFromStream and replaced it with rv2.InsertRVFFromStream(MS_Dest, 0). This worked fine, but of course it was not within table cells.
I am not sure what to do from here ...
InsertRVFFromStream in Table Cells
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 27
- Joined: Mon Aug 29, 2005 7:08 pm
Sergey,
Sorry for the bother. I figured it out. I plugged my database into your Mailmerge2 demo code and the table populated fine.
After looking through your code, I noticed I was missing the following:
rvDetail.RVFParaStylesReadMode := rvf_sIgnore;
rvDetail.RVFTextStylesReadMode := rvf_sIgnore;
Once these were added, everything was fine.
Sorry for the bother. I figured it out. I plugged my database into your Mailmerge2 demo code and the table populated fine.
After looking through your code, I noticed I was missing the following:
rvDetail.RVFParaStylesReadMode := rvf_sIgnore;
rvDetail.RVFTextStylesReadMode := rvf_sIgnore;
Once these were added, everything was fine.