trichview.com

trichview.support




Saving...


Return to index


Author

Message

Slavi Marinov

Posted: 11/19/2002 17:20:30


Hello Sergey,


I have a problem with HTML export. When I use RVE which is visual(visible,

on a form), and call SaveHTMLToStreamEx, it works OK when there are

hyperlinks. However, I want to create dynamiclly a RVE and save it to html

stream. So I do the following :


*******

function ExportHTML(CRVF : String):String;

Var CRVE : TRichViewEdit;

    CRVS : TRVStyle;

    MS  : TMemoryStream;

    SS  : TStringStream;

    FHTML : String;

begin

  CRVE:=nil;

  CRVS:=nil;

  CRVE:=TRichViewEdit.Create(nil);

  CRVS:=TRVStyle.Create(nil);

  try

    CRVE.Style:=CRVS;

    CRVE.RVFOptions:=CRVE.RVFOptions+[rvfoSaveBack,rvfoLoadBack];

    CRVE.Options:=CRVE.Options+[rvoTagsArePChars];

    CRVE.Parent:=RVForm;

    CRVE.OnHTMLSaveImage:=RVForm.HTMLSaveImage;

    CRVE.OnReadHyperlink:=RVForm.ReadHyperlink;

    CRVE.OnRVFPictureNeeded:=RVForm.RVFPictureNeeded;

    CRVE.OnSaveComponentToFile:=RVForm.SaveComponentToFile;

    CRVE.OnURLNeeded:=RVForm.URLNeeded;


CRVE.RVFOptions:=CRVE.RVFOptions+[rvfoSaveBack,rvfoLoadBack,rvfoSaveControls

Body,rvfoSaveBinary,rvfoSaveTextStyles,rvfoSaveParaStyles,rvfoSaveLayout,rvf

oLoadLayout];

    CRVE.RVFOptions:=CRVE.RVFOptions-[rvfoSavePicturesBody];

    CRVE.Visible:=False;

    MS :=nil;

    try

      MS := TMemoryStream.Create;

      MS.Position:=0;

      MS.WriteBuffer(Pointer(CRVF)^,Length(CRVF));

      MS.Position:=0;

      CRVE.LoadRVFFromStream(MS);

    finally

      MS.Free;

    end;

    SS := nil;

    try

      SS := TStringStream.Create('');


CRVE.SaveHTMLToStreamEx(SS,'','','','','','',[rvsoNoHypertextImageBorders,rv

soImageSizes ]);

      FHTML:=SS.DataString;

    finally

      SS.Free;

    end;

  finally

    CRVE.Free;

  end;

  Result:=FHTML;

end;

*******


where this procedure has one parameter -> a string, conatining RVF, and

returns a string with the html. Also,

RVForm.HTMLSaveImage; and so on are exactly the same as these I use for the

visual RVE. But when I try running this procedure on a document that has

hyperlinks, it crashes on the second row of


procedure TRVFOrm.URLNeeded(Sender: TCustomRichView; id: Integer;  var url:

String);

Var RVData: TCustomRVFormattedData;

    ItemNo: Integer;

begin

  RVE.GetJumpPointLocation(id,RVData,ItemNo);

  url:=PChar(RVData.GetItemTag(itemno));

end;


because itemno is -1. If there are no hyperlinks, all is OK( because the

component does not call URLNeeded). What do I miss? Why does this crash?


--Slavi





Powered by ABC Amber Outlook Express Converter