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!
Best way to stop nested tables.
-
- Site Admin
- Posts: 17572
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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
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
-
- Site Admin
- Posts: 17572
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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).
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);
}
}
//---------------------------------------------------------------------------