Page 1 of 1

Time new Roman on Paste HTML Text

Posted: Wed Feb 22, 2006 4:14 pm
by eddiev
Every Time i paste html text the RichviewEdit change me the style to Time new Roman but it dosen't change the size.
What i want is that the RichviewEdit don't change me nothing and use the Font and Size that is select at that time. How can i do that?.

Regards.

Posted: Wed Feb 22, 2006 4:16 pm
by eddiev
Sorry i forgot another question. When i import HTML text with HTMLImporter i can no Undo the Paste. How can i Undo what i import with HTMLImporter?.

Regards.

Posted: Wed Feb 22, 2006 7:40 pm
by Sergey Tkachenko
First, I do not know how you paste HTML.
Do you use Paste method, or paste it via RvHtmlImporter?
If you use Paste method, document is pasted in RTF format, and font cannot be changed.
If you use RvHtmlImporter, it has properties: DefaultFontName, DefaultFontSize.

Yes, RvHtmlImporter does not perform editing operations, so they cannot be undone.
But you can paste HTML in temporal hidden TRichView, then save document in TMemoryStream using SaveRVFFromStream, then insert in editor using InsertRVFFromStreamEd. This technique is used in RichViewActions when pasting HTML or inserting it from file.

Posted: Wed Feb 22, 2006 8:59 pm
by eddiev
Thanks for asking my question and sorry :oops: , i forgot to put that i am using HtmlImporter. I found the DefaultFontName and DefaultSize and when i set the properties in the VCL component the HtmlImporter change the font and the size but when i change the properties in runtime the HtmlImporter still using the font and size that i set in the component properties.

I hope you can understand me, i you can't tell me and i will try to put it in another way.

Regards.

Posted: Wed Feb 22, 2006 9:25 pm
by Sergey Tkachenko
I'll answer this weekend, I will be away for a couple of days.

Posted: Tue Feb 28, 2006 12:20 am
by eddiev
thanks for the help. Now i can undo the HMTL Imported with the RVHtmlImporter. But now when i paste the HTML Imported using the InsertRVFFromStreamEd the background color doesn't change.

Is there an option that i am missing to copy the background style from TempRichView to RichViewEdit?.

Here is the code that i am using:

//---------------------------------------------------------------------------
void __fastcall TProdNewsWindow::RichViewEditProdPaste(
TCustomRichViewEdit *Sender, bool &DoDefault)
{
UINT CF;
TMemoryStream *MemStream;

CF = RegisterClipboardFormat("HTML Format");
if (IsClipboardFormatAvailable(CF)) {
MemStream = new TMemoryStream();
try {
RvHtmlImporter->DefaultFontName = cmbFont->Text;
RvHtmlImporter->DefaultCFontName = cmbFont->Text;
RvHtmlImporter->DefaultFontSize = StrToInt(cmbFontSize->Text);
RvHtmlImporter->DefaultCFontSize = StrToInt(cmbFontSize->Text);
RvHtmlImporter->LoadFromClipboard();
RichViewProdTemp->Format();
RichViewProdTemp->SaveRVFToStream(MemStream, false);
MemStream->Position = 0;
DoDefault = !RichViewEditProd->InsertRVFFromStreamEd(MemStream);
if (!DoDefault) {
RichViewEditProd->Format();
}
} __finally {
delete MemStream;
}
}
}


Regards.