RichViewEdit problem

General TRichView support forum. Please post your questions here
Post Reply
hacqing
Posts: 7
Joined: Tue Apr 29, 2014 10:05 am

RichViewEdit problem

Post by hacqing »

1. convert TRVMarkerItemInfo to TRVTextItemInfo
i use the RichViewEdit controller in my application¡£
i use ctrl + c in word(*.docx 2007) file, ctrl + v to rve, rve can accept the TRVMarkerItemInfo item£¬
i use the following code convert TRVMarkerItemInfo to TRVTextItemInfo£¬but it result WideString is null

Code: Select all

    s = "";
    this->rve->GetListMarkerInfo(i, listNo, level, startFrom, useStartFrom);
    if (listNo >= this->rve->Style->ListStyles->Count) {
        listNo = this->rve->Style->ListStyles->Count - 1;
     }

    if (listNo >= 0) {
          listStyle = this->rve->Style->ListStyles->Items[listNo];
          if (level >= listStyle->Levels->Count) {
              level = listStyle->Levels->Count - 1;
          }

           if (level >= 0) {
               if (listStyle->Levels->Items[level]->ListType == rvlstUnicodeBullet) {
                   s = listStyle->Levels->Items[level]->FormatStringW;
               } else {
		       //use debug, run in here
                    s = WideString(TRVMarkerItemInfo(this->rve->GetItem(i)).DisplayString);
               }
           }
      }

       // result: s is ""
please tell me, how convert TRVMarkerItemInfo to TRVTextItemInfo? thanks.


2. i want iterator all items in rve and get image size:

Code: Select all

    TCustomRVItemInfo *curItemInfo = NULL;
    for (int i=0; i< this->rve->ItemCounts; i++) {
        curItemInfo = this->rve->GetItem(i);
        printf("WxH: %dx%d.\n", curItemInfo->GetImageWidth(), curItemInfo->GetImageHeight());
    }
out:
WxH: 0x0.

can you tell me, how to get to the item image size? thanks.


note: i use RichView 14.12.6 version.

thank you very much¡£
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

1) Your code seems to be correct, please send me a simple project showing the problem to richviewgmailcom

2) GetImageWidth() and GetImageHeight() return nonzero values only for items containing images and controls (rvsPicture, rvsHotpicture, rvsComponent, rvsBullet, rvsHotspot, and rvsListMarker, if list type is one of rvlstImageList, rvlstImageListCounter, rvlstPicture).
hacqing
Posts: 7
Joined: Tue Apr 29, 2014 10:05 am

Post by hacqing »

i want draw all item in single line, my method is as follows:
a. get all item's size in rve.
b. calc all item's max height: maxHeight
c. sum all item's width: sumWidth
d. set rvhelper's pages size

Code: Select all

         this->rvh_->Init(this->Canvas, sumWidth);
         this->rvh_->DrawPage(1, bmp->Canvas, true, maxHeight);
    
e. convert bmp32 to png rgba, and save.

but, i cannot get item size, can you help me? thanks :D
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Assign rvh->RichView->WordWrap = false (before calling Init()).
Call Init with a small value as Width, then get a real width as rvh->RichView->RVData->DocumentWidth + rvh->RichView->LeftMargin+rvh->RichView->RightMargin.
hacqing
Posts: 7
Joined: Tue Apr 29, 2014 10:05 am

Post by hacqing »

i use the following method to solve my problem:

Code: Select all

    this->rvh_->RichView->WordWrap = false;
    this->rvh_->Init(this->Canvas, smallWidth);
    while (rvh_->FormatNextPage(Height));

    int realWidth = 0, realHeight = 0;
    realWidth = this->rvh_->RichView->RVData->DocumentWidth + this->rvh_->RichView->LeftMargin + this->rvh_->RichView->RightMargin;
    realHeight = this->rvh_->RichView->RVData->DocumentHeight + this->rvh_->RichView->BottomMargin + this->rvh_->RichView->TopMargin;
    
    //correct realWidth
    imageWidth = realWidth ;
    imageHeight = realHeight;
    this->rvh_->Init(this->Canvas, imageWidth);
    while (rvh_->FormatNextPage(Height));
thanks again. :P


:cry: now, i has other problem:
a. i set rvhelper's size.
b. i can get page counts.
c. i want get current item (rve item) at page number.
can you help me? :D
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, I do not understand your question about "get current item (rve item) at page number."
But you may look at the methods GetPageNo() and GetFirstItemOnPage().
hacqing
Posts: 7
Joined: Tue Apr 29, 2014 10:05 am

Post by hacqing »

GetPageNo() is right. can you give me about TRVReportHelper.GetPageNo's example?
my code: the GetPageNo() method return -1.

Code: Select all

     int nil = 0;
    int imageWidth = 52;
    int imageHeight = 29;
    bool ret = false;

    this->rvh_->RichView->Style = this->rvhStyle_;
    this->rvhStyle_->FontQuality = TFontQuality::fqNonAntialiased;
    this->rvh_->RichView->Color = Graphics::clNone;
    this->rvh_->RichView->LeftMargin = this->rve->LeftMargin;
    this->rvh_->RichView->TopMargin = this->rve->TopMargin;
    this->rvh_->RichView->RightMargin = this->rve->RightMargin;
    this->rvh_->RichView->BottomMargin = this->rve->BottomMargin;
    TMemoryStream* dataStream = new TMemoryStream;
    ret = this->rve->SaveRVFToStream(dataStream, false);
    if (ret == false) {
        Application->MessageBox(L"save rvf to stream is failed!", L"Error",
            MB_OK | MB_ICONSTOP);
        return;
    }
    else {
        dataStream->Position = 0;
    }

    this->rvh_->TransparentBackground = True;

    ret = this->rvh_->RichView->LoadRVFFromStream(dataStream);
    if (ret == false) {
        Application->MessageBox(L"Cannot Open File", L"Error",
            MB_OK | MB_ICONSTOP);
    }
    else {
        delete dataStream;
        dataStream = 0;
    }

    this->rvh_->RichView->WordWrap = false;
    this->rvh_->Init(this->Canvas, imageWidth);
    while (rvh_->FormatNextPage(Height));
    printf("page no: %d.\n", this->rvh_->GetPageNo(this->rve->RVData, this->rve->CurItemNo, 1));
    return ;
out: page no: -1.

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

Post by Sergey Tkachenko »

For TRVReportHelper, you must pass a location in rvh->RichView.

If documents in rve and in rvh_->RichView are identical, you can call

Code: Select all

this->rvh_->GetPageNo(this->[color=red]rvh_->RichView[/color]->RVData, 
  this->rve->CurItemNo, this->rve->OffsetInCurItem)
However, it's more complicated when the caret is in a table cell.
hacqing
Posts: 7
Joined: Tue Apr 29, 2014 10:05 am

Post by hacqing »

Code: Select all

this->rvh_->GetPageNo(this->rvh_->RichView->RVData,
  this->rve->CurItemNo, this->rve->OffsetInCurItem); 
is right.

thank you very much! :lol: :D
Post Reply