RichViewEdit format without a component

General TRichView support forum. Please post your questions here
Post Reply
jgkoehn
Posts: 306
Joined: Thu Feb 20, 2020 9:32 pm

RichViewEdit format without a component

Post by jgkoehn »

I am using the following code TRichViewEditEx is basically TRichViewEdit with a bit more.
I need to run rv.Format but I get a parent error. The reason I need to run format is I am having trouble with some links not being the same. Either that or I am missing something else.
It is a tricky bug in my code to trace down and I would like to at least rv.Format as the solution. I would rather not use it if I can. I think rv.format maybe joins some bad links together which is fine some text has multiple links of the same link.
Gen. 1:1 has a link for example on Gen then same again on . then again on 1 then again on :1 just for example. (we can blame the original data conversion.) Is there a function in rv.format that merges these links together like a concat function or group function. Maybe that is all I need.

[/b]

Code: Select all

  rv := TRichViewEditEx{TRichView}.Create(nil);
  //rv := TCustomRichViewEdit.Create(nil);
  rvs := TRVStyle.Create(nil);
  ms := TMemoryStream.Create;
  RefErrorList := TSTringList.Create;
  RefErrorBool := _confBool('referror_files');
  try
    RVSwitchOffUniscribeIfUnderWine(rvs);
    rvs.TextStyles[0].Unicode := True;
    rv.Style := rvs;
    ShowMsgs := True;

    //rv.Options := rv.Options  + [rvoTagsArePChars];
    rv.Options := rv.Options
      +  [rvoAllowSelection,rvoShowCheckpoints,rvoShowPageBreaks,rvoShowHiddenText,
         rvoTagsArePChars,rvoAutoCopyText,rvoAutoCopyUnicodeText,rvoAutoCopyRVF,
         rvoAutoCopyImage,rvoAutoCopyRTF,rvoFormatInvalidate,rvoFastFormatting];
    rv.RTFOptions := [rvrtfSaveEMFAsWMF,rvrtfSaveJpegAsJpeg,rvrtfSavePngAsPng,rvrtfSavePicturesBinary];
    rv.RTFReadProperties.ParaStyleMode := rvrsAddIfNeeded;
    rv.RTFReadProperties.SkipHiddenText := True;
    rv.RTFReadProperties.TextStyleMode := rvrsAddIfNeeded;
    rv.RVFOptions :=  [rvfoSavePicturesBody,rvfoSaveControlsBody,rvfoSaveBinary,
         rvfoSaveTextStyles,rvfoSaveParaStyles,rvfoSaveLayout,rvfoLoadLayout,
         rvfoSaveDocProperties,rvfoLoadDocProperties];
    rv.RVFParaStylesReadMode :=  rvf_sInsertMerge;
    rv.RVFTextStylesReadMode :=  rvf_sInsertMerge;
jgkoehn
Posts: 306
Joined: Thu Feb 20, 2020 9:32 pm

Re: RichViewEdit format without a component

Post by jgkoehn »

Or does rvdata.NormalizeDocument(0,True); essentially concate as needed? If so perhaps I am missing something else in my code.
Sergey Tkachenko
Site Admin
Posts: 17679
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: RichViewEdit format without a component

Post by Sergey Tkachenko »

TRichView and TRichViewEdit components really need a parent for formatting. You can make them invisible and place on a form, or create an invisible form and place them there.
Another solution is using TRVReportHelper component. It contains an invisible TRichView component (accessible as RVReportHelper.RichView) that does not need a parent. But it must be formatted using RVReportHelper.Init, not using RVReportHelper.RichView.Format).

However, Format does not modify document (the only exception is adding an empty text to empty documents when necessary).
Yes, rvdata.NormalizeDocument(0,True) joins adjacent items having identical properties and performs some more fixes. Probably this is what you need.
Post Reply