Inserting TRichViewEdit content into several table cells
Posted: Tue Aug 28, 2007 8:49 pm
Hello!
I have an application where i want to store the content of a TRichViewEdit into several table cells, the content is saved to a memorystream using SaveRVFToStream() and later on retrieved from the memory stream and inserted into a new TRichViewEdit that has a large table where every cell corresponds to the content of the first TRichViewEdit (it is loaded into the table using table.Cells[x,x].LoadRVFFromStream().
The reasoning behind this complicated way of doing things is that the application is a subtitle editor and every subtitle needs to be edited as though it was a standalone document, although with only one page, and finally saved out into RTF format in a single table.
However the application fails when trying to save in RTF format and i get a "List index out of bounds (xx)" in the first line of the function:
TRVFontInfoCacheFast.GetItems(Index: Integer): TRVFontInfoCacheItem;
The application looks like this:
DubEditexporter is a TRichViewEdit control
DubTextStream := TMemoryStream.Create();
DubEditexporter.Clear();
DubEditexporter.DeleteUnusedStyles(true, true, true);
table := TRVTableItemInfo.CreateEx(m_MemManager.Count + 1, 4, DubEditexporter.RVData);
table.Cells[0, 0].Clear;
table.Cells[0, 1].Clear;
table.Cells[0, 2].Clear;
table.Cells[0, 3].Clear;
// Width
table.SetCellBestWidth(100, 0, 0);
table.SetCellBestWidth(80, 0, 1);
table.SetCellBestWidth(100, 0, 2);
table.SetCellBestWidth(320, 0, 3);
table.Cells[0, 0].AddNL('Character: ', 6, 1);
table.Cells[0, 1].AddNL('Timecode: ', 6, 1);
table.Cells[0, 2].AddNL('Note: ', 6, 1);
table.Cells[0, 3].AddNL('Line: ', 6, 1);
table.BorderWidth := 0;
table.CellBorderWidth := 0;
tableColor := DubEditexporter.Color;
for t := 0 to m_MemManager.Count - 1 do begin
txt := m_MemManager.Get(t);
table.Cells[t + 1, 0].Clear;
table.Cells[t + 1, 1].Clear;
table.Cells[t + 1, 2].Clear;
table.Cells[t + 1, 3].Clear;
table.Cells[t + 1, 0].AddNL(txt.Speaker, 0, 1);
table.Cells[t + 1, 1].AddNL(TCEdit.MiliToTC(txt.InTime), 0, 1);
table.Cells[t + 1, 2].AddNL(txt.Notes, 0, 1);
txt.DubTextStream.Position := 0;
table.Cells[t + 1, 3].LoadRVFFromStream(txt.DubTextStream, tableColor, DubEditexporter.Background, nil);
table.Cells[t + 1, 3].Format(true);
end;
DubEditexporter.AddItem('ContentTable', table);
DubEditexporter.Format();
DubEditexporter.SaveRTF(sFileName, false);
Forgot to mention that i have a registered version of TRichViewEdit and its version is RichView 1.9.44.2
I have an application where i want to store the content of a TRichViewEdit into several table cells, the content is saved to a memorystream using SaveRVFToStream() and later on retrieved from the memory stream and inserted into a new TRichViewEdit that has a large table where every cell corresponds to the content of the first TRichViewEdit (it is loaded into the table using table.Cells[x,x].LoadRVFFromStream().
The reasoning behind this complicated way of doing things is that the application is a subtitle editor and every subtitle needs to be edited as though it was a standalone document, although with only one page, and finally saved out into RTF format in a single table.
However the application fails when trying to save in RTF format and i get a "List index out of bounds (xx)" in the first line of the function:
TRVFontInfoCacheFast.GetItems(Index: Integer): TRVFontInfoCacheItem;
The application looks like this:
DubEditexporter is a TRichViewEdit control
DubTextStream := TMemoryStream.Create();
DubEditexporter.Clear();
DubEditexporter.DeleteUnusedStyles(true, true, true);
table := TRVTableItemInfo.CreateEx(m_MemManager.Count + 1, 4, DubEditexporter.RVData);
table.Cells[0, 0].Clear;
table.Cells[0, 1].Clear;
table.Cells[0, 2].Clear;
table.Cells[0, 3].Clear;
// Width
table.SetCellBestWidth(100, 0, 0);
table.SetCellBestWidth(80, 0, 1);
table.SetCellBestWidth(100, 0, 2);
table.SetCellBestWidth(320, 0, 3);
table.Cells[0, 0].AddNL('Character: ', 6, 1);
table.Cells[0, 1].AddNL('Timecode: ', 6, 1);
table.Cells[0, 2].AddNL('Note: ', 6, 1);
table.Cells[0, 3].AddNL('Line: ', 6, 1);
table.BorderWidth := 0;
table.CellBorderWidth := 0;
tableColor := DubEditexporter.Color;
for t := 0 to m_MemManager.Count - 1 do begin
txt := m_MemManager.Get(t);
table.Cells[t + 1, 0].Clear;
table.Cells[t + 1, 1].Clear;
table.Cells[t + 1, 2].Clear;
table.Cells[t + 1, 3].Clear;
table.Cells[t + 1, 0].AddNL(txt.Speaker, 0, 1);
table.Cells[t + 1, 1].AddNL(TCEdit.MiliToTC(txt.InTime), 0, 1);
table.Cells[t + 1, 2].AddNL(txt.Notes, 0, 1);
txt.DubTextStream.Position := 0;
table.Cells[t + 1, 3].LoadRVFFromStream(txt.DubTextStream, tableColor, DubEditexporter.Background, nil);
table.Cells[t + 1, 3].Format(true);
end;
DubEditexporter.AddItem('ContentTable', table);
DubEditexporter.Format();
DubEditexporter.SaveRTF(sFileName, false);
Forgot to mention that i have a registered version of TRichViewEdit and its version is RichView 1.9.44.2