trichview.com

trichview.support




Re: C++ Example: converting table to text???


Return to index


Author

Message

Sergey Tkachenko

Posted: 11/09/2004 17:41:45


void ConvertTableToText(TCustomRichViewEdit* RichViewEdit)

{

  TCustomRVItemInfo   *item;

  TCustomRichViewEdit *rve;

  if (! RichViewEdit->GetCurrentItemEx(__classid(TRVTableItemInfo), rve,

item))

    return;

  TRVTableItemInfo*table = (TRVTableItemInfo*)item;

  TRichView* rv = new TRichView((TComponent*)NULL);

  rv->Visible = false;

  rv->Parent  = RichViewEdit->Parent;

  rv->Style   = RichViewEdit->Style;

  rv->RVFTextStylesReadMode = rvf_sIgnore;

  rv->RVFParaStylesReadMode = rvf_sIgnore;

  for (int r=0; r<table->Rows->Count; r++)

    for (int c=0; c<table->Rows->Items[r]->Count; c++)

      if (table->Cells[r][c])

      {

        TMemoryStream*Stream = new TMemoryStream;

        table->Cells[r][c]->GetRVData()->SaveRVFToStream(Stream, false,

          clNone, NULL, NULL);

        Stream->Position = 0;

        rv->InsertRVFFromStream(Stream, rv->ItemCount);

        delete Stream;

      }

  int ItemNo = table->GetMyItemNo();

  TMemoryStream*Stream = new TMemoryStream;

  rv->SaveRVFToStream(Stream, false);

  Stream->Position = 0;

  rve->SetSelectionBounds(ItemNo, 0, ItemNo, 1);

  rve->InsertRVFFromStreamEd(Stream);

  delete Stream;

  delete rv;

}





Powered by ABC Amber Outlook Express Converter