cloning and finding EOLs

General TRichView support forum. Please post your questions here
Post Reply
toolwiz
Posts: 150
Joined: Wed Nov 30, 2005 3:27 am

cloning and finding EOLs

Post by toolwiz »

How does one go about creating a "clone" of one RVE into another RVE, including item tag values and newlines?

Also, if I'm iterating over rve.RVData.Items (so to speak), how do I detect the presence of newlines?

I tried copying all RVData items from one to the other, but it lost page formatting.
Michel
Posts: 92
Joined: Fri Oct 14, 2005 2:56 pm
Contact:

Post by Michel »

Take a look at SaveRVFToStream() and related functions. A search for this (or some related) function names on this forum should turn up a few threads.
Basically, stream RV_A to a stream; "rewind" the stream (Position := 0); stream it into RV_B.

HTH,

Michel
toolwiz
Posts: 150
Joined: Wed Nov 30, 2005 3:27 am

Post by toolwiz »

Hi, Michel

I tried something similar to that. But in RV_B I need the same item attributes (ie., hyperlinks) on the same words as in RV_A. Streaming doesn't accomplish that.
Michel
Posts: 92
Joined: Fri Oct 14, 2005 2:56 pm
Contact:

Post by Michel »

Hi David,

Streaming most certainly can accomplish what you want. Could your problem be related to styles not being added properly? Specifically, perhaps RVFTextStylesReadMode is not rvf_sInsertMerge in your case? Assuming you are using 2 different RVStyle components, that is.

See if it's something like that. Or post more info if everything seems to be already as it should be, - because it should definitely work.

Good luck,

Michel
toolwiz
Posts: 150
Joined: Wed Nov 30, 2005 3:27 am

Post by toolwiz »

Yup, looks like that did the trick!

Thanks
-David
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

About line breaks: item is started from the new line, if RichView.IsFromNewLine(ItemNo)=True.
toolwiz
Posts: 150
Joined: Wed Nov 30, 2005 3:27 am

Post by toolwiz »

How would I go through a document and prep it for viewing in HTML by changing single newlines to <BR> and double newlines to <P> tags?

I've got other HTML tags in this document, and when I use SaveToHTML, it escapes the tags so they show up as text rather than "real tags". That is, I've got HTML Anchor tags in the text that I want to appear as live links in the browser. Perhaps there's some way to tell RVE not to do this?

Thanks
-David
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

This procedure converts all single line breaks to "soft" line breaks (which can be added by Shift+Return keys). Double line breaks remain paragraph breaks (which can be added by Return key), but empty line is removed (actually, all empty lines are removed)

Code: Select all

procedure NormalizeLineBreaks(RVData: TCustomRVData);
var i,r,c: Integer;
    table: TRVTableItemInfo;
begin
  for i := RVData.ItemCount-1 downto 0 do begin
    if RVData.IsParaStart(i) then begin
      // removing empty line
      if RVData.IsParaStart(i) and (RVData.GetItemStyle(i)>=0) and
         (RVData.ItemCount>0) then begin
        RVData.DeleteItems(i,1);
        continue;
      end;
      // converting "Return-linebreak" to "Shift+Return-linebreak", if
      // there is no empty line before. Making sure that this conversion is
      // not applied to tables and breaks, items after them, and the very first
      // item
      if (i>0) and not RVData.GetItem(i).GetBoolValue(rvbpFullWidth) and
         not RVData.GetItem(i-1).GetBoolValue(rvbpFullWidth) and
         not ((RVData.GetItemStyle(i-1)>=0) and (RVData.GetItemText(i-1)='')) then
        RVData.GetItem(i).BR := True;
        continue;
      end;
      // recursive table traversal
      if RVData.GetItemStyle(i)=rvsTable then begin
        table := TRVTableItemInfo(RVData.GetItem(i));
        for r := 0 to table.Rows.Count-1 do
          for c := 0 to table.Rows[r].Count-1 do
            if table.Cells[r,c]<>nil then
              NormalizeLineBreaks(table.Cells[r,c].GetRVData);
      end;
    end;
end;
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

For saving '<', '>' and '&' to HTML unmodified, include rvteoHTMLCode in the Options property of text style.
Post Reply