Page 1 of 1
Best way to stop nested tables.
Posted: Thu Jul 19, 2012 12:54 am
by vizualweb
Hi All,
I'm trying to stop nested tables in my TDBRichViewEdit.
Im using the following to test if a user is trying to INSERT a table while currently inside a table.
if (LetterRichViewEdit->InplaceEditor == NULL)
That works fine, but what about pasting? How can I stop a user pasting a table inside another table.
Basically any form of nested tables must be disallowed as the FastReport RichText object can't display nested tables and instead just shows the raw RTF instead of the RichEdit output.
Cheers!
Posted: Thu Jul 19, 2012 3:59 pm
by Sergey Tkachenko
Unfortunately, there is no such property.
The most universal way is using OnPaste event. If InplaceEdit!=NULL, then paste into a hidden editor, remove tables in it, save to stream (SaveRVFToStream), insert in the main editor (InsertRVFFromStreamEd), set DoDefault parameter = False.
To remove tables in a hidden editor, you can use this procedure:
http://www.trichview.com/forums/viewtop ... =581#16214
Posted: Thu Jul 19, 2012 4:00 pm
by Sergey Tkachenko
Besides, exclude RTF and RVF from AcceptDragDropFormat, because there is no event like OnPaste for drag&drop.
Posted: Fri Jul 20, 2012 3:41 am
by vizualweb
Thanks Sergey,
The ConvertAllTablesToText worked a treat (I'm using C++ Builder XE, but just added the procedure to a .pas unit and used it from there.
Also the OnPaste worked perfectly (just incase its useful for others).
Code: Select all
void __fastcall TMailEditor::LetterRichViewEditPaste(TCustomRichViewEdit *Sender, bool &DoDefault)
{
// If inside a table when pasting, run the ConvertAllTablesToText function to stip the table.
if (LetterRichViewEdit->InplaceEditor != NULL)
{
DoDefault = false;
TRichViewEdit *rvTemp = new TRichViewEdit((TComponent*)NULL);
rvTemp->Style = MailRVStyle;
rvTemp->Parent = MailEditor;
rvTemp->Paste();
ConvertAllTablesToText(rvTemp->RVData, true);
rvTemp->Format();
TMemoryStream *MemStream = new TMemoryStream();
rvTemp->SaveRVFToStream(MemStream, false);
MemStream->Position = 0;
LetterRichViewEdit->InsertRVFFromStreamEd(MemStream);// LoadRVFFromStream(MemStream);
LetterRichViewEdit->Format();
delete rvTemp, MemStream;
MessageDlg("You tried to paste a table inside another table,\nthis is not allowed. Only the table contents\nhas been copied!", mtWarning, TMsgDlgButtons() << mbOK, 0);
}
}
//---------------------------------------------------------------------------