trichview.com

trichview.support




Bug in RichView - merging styles of newly inserted rvf documents.


Return to index


Author

Message

John Wertz

Posted: 04/28/2003 0:37:33


Sergey:


I have outlined the problem and my current solution below. I believe this is

a bug and would appreciate your feedback and alternative fix if necessary. I

am using Delphi 7 Enterprise and RichView 1.7.13


Problem:

My application uses the RichViewEdit component and displays rvf documents

generated at runtime using both custom items (using RichView.Addxxx methods)

and rvf documents stored in memory streams. The stream rvf files have

RVStyles stored with them and I have both RVFParaStylesReadMode and

RVFTextStylesReadMode set to rvf_sInsertMerge. The problem is that only the

styles in the first streamed rvf file inserted into richview are merged.

None of the styles defined in rvf files added after the first one are merged

into the defined styles and therefore the rvf files do not display in

richview unless it's styles are already defined.


I have confirmed that the styles are not being added by both tracing into

the InsertRVFFromStream function and by using the TRVStyle.SaveINI method to

save the currently defined styles at various points in my program. The

InsertRVFFromStream method contains a While loop which calls ReadDocProperty

which in turn calls MergeStyles. Before taking any action, the MergeStyles

procedure checks several conditions including: (Mapping<>nil), if this is

true, no action is taken. This is where the problem is. When the first rvf

file is inserted into richview, Mapping will be = NIL since

PTextStylesMapping, PParaStylesMapping, and PListStylesMapping have not

previously been assigned and the styles are properly merged with the current

richview component styles. However, these pointers are never released and

therefore on each subsequent entry into MergeStyles the (Mapping<>nil) is

always False and no additional styles are merged.


Solution:

After the While loop in InsertRVFFromStream you have a call to the

DoneStyleMappings procedure which has no code and simply exits without doing

anything. I have added the following code:


if PTextStylesMapping^ <> NIL then

    FreeAndNil(PTextStylesMapping^);

if PParaStylesMapping^ <> NIL then

    FreeAndNil(PParaStylesMapping^);

if PListStylesMapping^ <> NIL then

    FreeAndNil(PListStylesMapping^);


As far as I can tell, this has fixed the problem in my application. Please

review this issue and let me know if there is a better solution for this

problem.


Thanks in advance


John






Powered by ABC Amber Outlook Express Converter