How to replace text in with RVF-document.

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
Nofate
Posts: 11
Joined: Thu Feb 14, 2008 11:11 am

How to replace text in with RVF-document.

Post by Nofate »

Hello. I have the following problem.

I have RVF document loaded in TSRichViewEdit. The document contains special text tags like [FRAGMENT(1)]. Several RVF-documents are stored in database with TRichViewEdit.SaveRVFToStream.

I need to substitute tags with corresponding RVF-documents from DB. I tried something like this and it worked fine:

Code: Select all

// rvOutput - TSRichViewEdit, containing main document
// stream - TStream, containing RVF-document, which we are going to insert
// i - index of current item, which we are going to replace
rvOutput.RichViewEdit.DeleteItems(i, 1);
rvOutput.RichViewEdit.InsertRVFFromStream(stream, i);
Pretty simple. But now we have more complex documents with tables etc (Our tags can bne placed in table cells). So I need to rewrite my code to work with TCustomRVData rather than with TSRichView. Any ideas how I can achieve this?

Code: Select all

// rvOutput - TCustomRVData, containing main document
// stream - TStream, containing RVF-document, which we are going to insert
// i - index of current item, which we are going to replace

... some code ...
Sergey Tkachenko
Site Admin
Posts: 17553
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

It's not that simple.
First, it may create incorrect document, for example with two list markers followed after another. Second, table cells do not support documents with text and paragraph styles. Third, if you define field as text inside [], DeleteItem will delete the whole text item containing field as a substring.

See the demo in the ScaleRichView demos:
Demos\RVDemos\Assorted\Fields\MailMerg2\
It does almost completely what you need.
Post Reply