Merging data from one TRichViewEdit into another
-
- Posts: 131
- Joined: Mon Aug 29, 2005 12:03 pm
Merging data from one TRichViewEdit into another
Hi there,
I'm having a problem figuring out how best to handle the merging of styles. I have two TRichViewEdit controls, each with a different default set of styles. I need to copy the contents of one into a location in the other. I'm doing this with
LoadRVFFromStreamEd
My problem is with how to handle the two sets of styles. I want to preserve the appearance of all the text which is being pasted into the target box, but I don't want to change the default set of styles in that box. As far as I can see, these are my options
rvf_sIgnore: when I choose this option, the text is not inserted for some reason. However, I don't think it's the right option anyway.
rvf_sInsertMap: This replaces the current styles in the target RVE with those from the RVF. That's not what I want at all.
rvf_sInsertMerge: Styles from RVF will be mapped to the most similar existing styles. New styles will not be added. This is not what I want either, because I need to preserve any styles in the incoming RVF which are not present in the target RVE.
I think what I need is something like what is available for RTF:
rvrsAddIfNeeded
which uses existing styles where they exist in the target RVE, but adds new ones if necessary. Is there any way to do this using InsertRVFFromStreamEd?
All help appreciated,
Martin
I'm having a problem figuring out how best to handle the merging of styles. I have two TRichViewEdit controls, each with a different default set of styles. I need to copy the contents of one into a location in the other. I'm doing this with
LoadRVFFromStreamEd
My problem is with how to handle the two sets of styles. I want to preserve the appearance of all the text which is being pasted into the target box, but I don't want to change the default set of styles in that box. As far as I can see, these are my options
rvf_sIgnore: when I choose this option, the text is not inserted for some reason. However, I don't think it's the right option anyway.
rvf_sInsertMap: This replaces the current styles in the target RVE with those from the RVF. That's not what I want at all.
rvf_sInsertMerge: Styles from RVF will be mapped to the most similar existing styles. New styles will not be added. This is not what I want either, because I need to preserve any styles in the incoming RVF which are not present in the target RVE.
I think what I need is something like what is available for RTF:
rvrsAddIfNeeded
which uses existing styles where they exist in the target RVE, but adds new ones if necessary. Is there any way to do this using InsertRVFFromStreamEd?
All help appreciated,
Martin
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Use InsertRVFFromStream (without "Ed", InsertRVFFromStreamEd is an editing method).
Example: http://www.trichview.com/forums/viewtopic.php?t=1196
Example: http://www.trichview.com/forums/viewtopic.php?t=1196
-
- Posts: 131
- Joined: Mon Aug 29, 2005 12:03 pm
When I do that, nothing is pasted. This line works:
ufrmComments.rveFeedback.InsertRVFFromStreamEd(AStream);
But this line fails:
ufrmComments.rveFeedback.InsertRVFFromStream(AStream, ufrmComments.rveFeedback.TopLevelEditor.CurItemNo);
This is what populates the stream:
rveSnippets.SaveRVFToStream(AStream, False);
AStream.Position := 0;
Can you see any problem with this? Any idea why it's failing?
Thanks,
Martin
ufrmComments.rveFeedback.InsertRVFFromStreamEd(AStream);
But this line fails:
ufrmComments.rveFeedback.InsertRVFFromStream(AStream, ufrmComments.rveFeedback.TopLevelEditor.CurItemNo);
This is what populates the stream:
rveSnippets.SaveRVFToStream(AStream, False);
AStream.Position := 0;
Can you see any problem with this? Any idea why it's failing?
Thanks,
Martin
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
InsertRVFFromStream is not an editing method.
Before displaying, call ufrmComments.rveFeedback.Format.
And I think you want to add new text to the end, so call:
Before displaying, call ufrmComments.rveFeedback.Format.
And I think you want to add new text to the end, so call:
Code: Select all
ufrmComments.rveFeedback.InsertRVFFromStream(AStream,
ufrmComments.rveFeedback.ItemCount);
ufrmComments.rveFeedback.Format;
-
- Posts: 131
- Joined: Mon Aug 29, 2005 12:03 pm
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Then use
ufrmComments.rveFeedback must be formatted before this call. Calling Format after InsertRVFFromStreamEd is not needed (like any editing method, it formats the changed paragraphs itself)
Code: Select all
ufrmComments.rveFeedback.InsertRVFFromStreamEd(AStream);
-
- Posts: 131
- Joined: Mon Aug 29, 2005 12:03 pm
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Your initial understanding of RVF style mapping options is not correct.
When loading RVF (LoadRVF or LoadRVFFromStream), in the both rvf_sInsertMap and rvf_sInsertMerge modes, styles are replaced.
However, when inserting RVF (InsertRVFFromStream, AppendRVFFromStream, InsertRVFFromStreamEd):
- rvf_sInsertMap - maps styles to the most similar existing styles; this is the analog of rvrsUseClosest for RTF.
- rvf_sInsertMerge - tries to reuse existing styles, adds new styles if necessary; this is the analog of rvrsAddIfNeeded for RTF.
When loading RVF (LoadRVF or LoadRVFFromStream), in the both rvf_sInsertMap and rvf_sInsertMerge modes, styles are replaced.
However, when inserting RVF (InsertRVFFromStream, AppendRVFFromStream, InsertRVFFromStreamEd):
- rvf_sInsertMap - maps styles to the most similar existing styles; this is the analog of rvrsUseClosest for RTF.
- rvf_sInsertMerge - tries to reuse existing styles, adds new styles if necessary; this is the analog of rvrsAddIfNeeded for RTF.
-
- Posts: 131
- Joined: Mon Aug 29, 2005 12:03 pm
rvf_sInsertMerge is what I was using, but it's having an odd effect: it seems to replace the default style in the target RVE. Where styles have the same name in the two RVStyles, the style in the target would be overwritten by the style with the same name in the source. That's why I started looking for an alternative in the first place.
How should rvf_sInsertMerge behave when both the source and the target have styles with the same name, but which are actually different?
Cheers,
Martin
How should rvf_sInsertMerge behave when both the source and the target have styles with the same name, but which are actually different?
Cheers,
Martin
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 131
- Joined: Mon Aug 29, 2005 12:03 pm
rvfo_UseStyleNames is False for both the source and the target RVE. RVFParaStylesReadMode and RVFTextStylesReadMode are both set to rvf_sInsertMerge.
This is the behaviour I see:
Cheers,
Martin
This is the behaviour I see:
- The default text style for the target RVE is Arial 10pt black.
The default text style for the source RVE is Arial 10pt green bold.
I insert the contents of the source RVE at the cursor position in the target, using InsertRVFFromStreamEd.
The default text style for the target RVE is now 10pt green bold; even when I press return to get new paragraphs, 10pt green bold persists.
Cheers,
Martin
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 131
- Joined: Mon Aug 29, 2005 12:03 pm
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 131
- Joined: Mon Aug 29, 2005 12:03 pm