trichview.com

trichview.support




Re: get paragraph text, select paragraph mode.


Return to index


Author

Message

Anonymous

Posted: 10/20/2003 13:40:57


>��1.�fill�a�new�rich�view�using�existing�richview�by�selecting�only�wanted


>paragraph.�lets�say�paragraph�1,4,6�and�8




function GetParaStartItem_(rvData: TCustomRVData; ParaNo: Integer): longint;


var i: Integer;


begin


  Result:=-1;


  for i:=0 to rvData.Items.Count-1 do


  begin


    if rvData.IsParaStart(i) then


      dec(ParaNo);


    if ParaNo<0 then


    begin


      Result:=i;


      break;


    end;


  end;


end;




procedure SelectPara_(RVE: TCustomRichViewEdit; ParaNo: longint);


var


  CurNo: Integer;


  StartNo, EndNo: Integer;


  Offs, Offs2: Integer;


  function StartPara(No: Integer): Integer;


  var


    I: Integer;


  begin


    for I:=No downto 0 do


      if rve.IsParaStart(I) then Break;


    Result:=I;


  end;


  function EndPara(No: Integer): Integer;


  var


    I: Integer;


  begin


    Result:=No;


    Inc(No);


    i:=0;


    if No<>rve.ItemCount then


    begin


      for I:=No to rve.ItemCount-1 do


        if rve.IsParaStart(I) then Break;


      if i=0 then result:=0 else Result:=I-1


    end


  end;


begin


  CurNo:=GetParaStartItem_(RVE.RVData, ParaNo);


  StartNo:=StartPara(CurNo);


  EndNo:=StartNo;


  Offs:=rve.GetOffsBeforeItem(StartNo);


  EndNo:=EndPara(StartNo);


  Offs2:=rve.GetOffsAfterItem(EndNo);


  rve.SetSelectionBounds(StartNo, Offs, EndNo, Offs2);


end;






procedure CopyParaFromRVE2RVE(RVEFrom, RVETo: TCustomRichviewEdit; ParaNo: integer);


var m: TMemoryStream;


begin


  m:=TMemoryStream.Create;


  try


    SelectPara_(RVEFrom, ParaNo);


    RVEFrom.SaveRVFToStream(m, True);


    m.Position:=0;


    RVETo.InsertRVFFromStream(m, RVETo.ItemCount-1);


  finally


    m.Free;


  end;


end;




>��2.�Paragraph�selection�mode.�where�i�will�be�able�to�select�paragraph�by


>single�click.




function GetCurrParaNo_(RVEditor: TCustomRichViewEdit): longint;


var i, c: longint;


begin


  Result:=-1;


  c:=RVEditor.CurItemNo;


  for i:=0 to RVEditor.ItemCount-1 do


    begin


      if RVEditor.IsParaStart(i) then Inc(Result);


      if c=i then Break;


    end;


end;




procedure TForm1.RVERVMouseUp(Sender: TCustomRichView;


  Button: TMouseButton; Shift: TShiftState; ItemNo, X, Y: Integer);


begin


     SelectPara_(RVE, GetCurrParaNo_(RVE));


end;







Powered by ABC Amber Outlook Express Converter