AppendRVFFromStream - No Bullets ?

General TRichView support forum. Please post your questions here
Post Reply
wray
Posts: 38
Joined: Thu Feb 14, 2008 8:36 pm
Location: Romania

AppendRVFFromStream - No Bullets ?

Post by wray »

Hi,

i use

RichViewEdit1->AddBulletEx("", 0, Form1->ImageList3, -1);
RichViewEdit1->Reformat();

to add a bullet..

But when i try:

TMemoryStream *stream = new TMemoryStream();
RichViewEdit1->SaveRVFToStream(stream,false);
stream->Seek(0,0);
tabel->Cells[0][1]->VAlign = rvvaAbsMiddle;
tabel->Cells[0][1]->AppendRVFFromStream(stream,-1,Dummy1,Dummy2);
delete stream;

I get only the text, no bullets. Is in same application.

Please advise

Also would be great for me if i could trigger the SaveRVFToStream (event), because then i itinerate the bullets when they are about to be saved in a stream and replace them back with the text corespondents ( for smileys - when i find 0 index in ImageList3, means is :) )

Regards

P.S. Please also tell me how do i get the caret position in curent line, i am using RichViewEdit1->GetCurrentItemText(); to get the text i am typing.

(i need it to replace :) with a bullet smiley)
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

When loading "bullets" or "hotspot" item from RVF, OnRVFImageListNeeded event occurs, where you need to specify the image list for this item.
For example,

Code: Select all

void __fastcall TForm1::RichViewEdit1RVFImageListNeeded(TCustomRichView *Sender,
    int ImageListTag, TCustomImageList *&il)
{
  il = ImageList3;
}
As for executing some custom code before saving. Since you save to the file yourself, you can add this code yourself before SaveRVF(). If you need to do it before copying to the clipboard, use OnCopy event.
Last edited by Sergey Tkachenko on Thu Jul 03, 2008 7:08 am, edited 1 time in total.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

As for the second question, it is OffsetInCurItem property (or better, to support tables, RichViewEdit1->TopLevelEditor->OffsetInCurItem)
The example of replacing text to emoticons on typing can be found in Demos\CBuilder\Assorted\Graphics\Emoticons
wray
Posts: 38
Joined: Thu Feb 14, 2008 8:36 pm
Location: Romania

Post by wray »

Most helpfull like always.

Thank you very much
wray
Posts: 38
Joined: Thu Feb 14, 2008 8:36 pm
Location: Romania

Post by wray »

Can you hint me what i am doing wrong with the VAlign here ?

OnKeyPress i did the emoticon replacement with align like this:

if (s[Offs-1]==':')
{
rve->SetSelectionBounds(ItemNo, Offs-1, ItemNo, Offs);
rve->InsertBullet(GetImageIndex(Key), Form1->ImageList3);
Key = 0;
((TRVBulletItemInfo*)(RichViewEdit1->GetCurrentItem()))->VAlign = rvvaAbsMiddle;
RichViewEdit1->Reformat();
}

and i get good align in RichViewEdit1 lik ein picture:

Image

but when i append it from stream in table, i get bad align...

Code is:

TMemoryStream *stream = new TMemoryStream();
RichViewEdit1->SaveRVFToStream(stream,false);
stream->Seek(0,0);
tabel->Cells[0][1]->VAlign = rvvaAbsMiddle;
tabel->Cells[0][1]->AppendRVFFromStream(stream,-1,Dummy1,Dummy2);
tabel->Cells[0][1]->VAlign = rvvaAbsMiddle;
RichView1->AddItem("Spreadsheet", tabel);
RichView1->FormatTail();

And it looks like in this picture:

Image

Thank you
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Unfortunately, VAlign of "bullets" and "hotspots" is not saved in RVF.
It will be fixed in the next update (but not sooner than after 2 weeks).
wray
Posts: 38
Joined: Thu Feb 14, 2008 8:36 pm
Location: Romania

Post by wray »

Is ok.

But can you think of a method to align them manually after they have been appended in table ?

Like for loop to scan all the items in cell and align them manually each of them ?

Regards
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Code: Select all

TMemoryStream *stream = new TMemoryStream(); 
RichViewEdit1->SaveRVFToStream(stream,false); 
stream->Seek(0,0); 
int ItemCount = tabel->Cells[0][1]->ItemCount;
tabel->Cells[0][1]->AppendRVFFromStream(stream,-1,Dummy1,Dummy2); 
for (int i =ItemCount; i<tabel->Cells[0][1]->ItemCount; i++)
  if (tabel->Cells[0][1]->GetItemStyle(i)==rvsBullet)
    ((TRVBulletItemInfo*)(tabel->Cells[0][1]->GetItem(i)))->VAlign = rvvaAbsMiddle;
RichView1->AddItem("Spreadsheet", tabel); 
RichView1->FormatTail(); 
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

And rvvaAbsMiddle is not a valid value for Cell->VAlign.
Available values for Cell->VAlign: rvcTop, rvcMiddle, rvcBottom, rvcVDefault (TRVCellVAlign type).

rvvaAbsMiddle can be used only for VAlign of items, not cells. It is of TRVVAlign type.
wray
Posts: 38
Joined: Thu Feb 14, 2008 8:36 pm
Location: Romania

Post by wray »

Thank you

Working perfectly
Post Reply