Page 1 of 1

cloning and finding EOLs

Posted: Sat Dec 10, 2005 4:02 pm
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.

Posted: Sat Dec 10, 2005 7:45 pm
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

Posted: Sat Dec 10, 2005 7:54 pm
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.

Posted: Sat Dec 10, 2005 8:31 pm
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

Posted: Sat Dec 10, 2005 9:03 pm
by toolwiz
Yup, looks like that did the trick!

Thanks
-David

Posted: Sun Dec 11, 2005 7:43 pm
by Sergey Tkachenko
About line breaks: item is started from the new line, if RichView.IsFromNewLine(ItemNo)=True.

Posted: Sun Dec 11, 2005 8:12 pm
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

Posted: Tue Dec 13, 2005 7:41 pm
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;

Posted: Tue Dec 13, 2005 7:43 pm
by Sergey Tkachenko
For saving '<', '>' and '&' to HTML unmodified, include rvteoHTMLCode in the Options property of text style.