get page number in splitted table

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
ccr
Posts: 8
Joined: Sat Nov 13, 2010 12:47 am

get page number in splitted table

Post by ccr »

hello,
i have a table split accross several pages. i need to find out when a table row is part of the next page.
i use the following code

Code: Select all

function GetRowPage(poTable: TRVTableItemInfo; const pnRow,pnColumn: Integer): Integer;
var
    oRvCellData: TRVTableCellData;
begin
    // FActiveScaleRichView: TSRichViewEdit
    oRvCellData := poTable.Cells[pnRow, pnColumn];
    result := FActiveScaleRichView.GetPageNo(TCustomRVFormattedData(oRvCellData.GetRVData), 0, 0);
end;
this works fine apart from the last table row on a page which returns the next page number.
what am i missing?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: get page number in splitted table

Post by Sergey Tkachenko »

I cannot reproduce this problem (in the newest version of ScaleRichView).
Can you send me a sample document where it happens?
ccr
Posts: 8
Joined: Sat Nov 13, 2010 12:47 am

Re: get page number in splitted table

Post by ccr »

hello,
thank you for the quick reply. i am on version 6.0.2. if this is fixed in newer version it might be a good reason to upgrade :)
ccr
Posts: 8
Joined: Sat Nov 13, 2010 12:47 am

Re: get page number in splitted table

Post by ccr »

hello,
i have to come back for this since even after the upgrade the problem exists. i attached the output.
my scenario is like this: user designs report with header and footer and tables with database-fields (Report Workshop wasn't available at that time) in a tdbsrichviewedit which is . when executing it the bound tdbsrichviewedit is loaded into an unbound tsrichviewedit, copying header and footer first, finally the main-body, alway replacing the database-fields.
this is done before the form is shown (maybe this plays a role ?).
the essential part is the determination of the page number. the algorith seems to be straight forward:
if the cell value or the cell page differs from the previous row then merge all equal values until the previous row.
maybe i miss something obvious:

Code: Select all

procedure TTEXTEditor.MergeColumnCellsWithSameText(poTable: TRVTableItemInfo; pnColumn: Integer);
var
  nRow: Integer;
  nMergeRow: Integer;
  bLastRow: Boolean;
  bMergeNow: Boolean;
  bSamePage: Boolean;
  cPrevRowText: string;
  cThisRowText: string;
  nMergeRowCount: Integer;
  nMergeStartRow: Integer;
  nThisCellPage: Integer;
  nPrevCellPage: Integer;
  oCell: TRVTableCellData;
  oCellRvData: TCustomRvData;
  function GetRowPage(const poCell: TRVTableCellData): Integer;
  begin
    result := FActiveScaleRichView.GetPageNo(TCustomRVFormattedData(poCell.GetRVData), 0, poCell.GetVOffs);
  end;
begin
  // initialize
  cPrevRowText := '';
  nMergeRowCount := 0;
  nPrevCellPage := GetRowPage(poTable.Cells[0, pnColumn]);

  for nRow := 1 to poTable.RowCount - 1 do
    begin
    oCell := poTable.Cells[nRow, pnColumn];
    oCellRvData := oCell.GetRvData;
    nThisCellPage := GetRowPage(oCell);
    if oCellRvData.ItemCount > 0 then
      begin
      cThisRowText :=  oCellRvData.GetItemText(oCellRvData.ItemCount - 1);
      bSamePage := nPrevCellPage = nThisCellPage;
      bLastRow := nRow = poTable.RowCount - 1;
      bMergeNow := bLastRow or not bSamePage or not THMG_Utils.Text.Same(cPrevRowText, cThisRowText);
      if not bMergeNow then
        begin
        Inc(nMergeRowCount);
        OutputDebugString(PChar(Format('Row %d %s Merge-Count %d Page %d', [nRow, cThisRowText, nMergeRowCount, nThisCellPage])));
        end
      else
        begin
        nMergeStartRow := nRow - nMergeRowCount - 1;
        for nMergeRow := nMergeStartRow to nMergeStartRow + nMergeRowCount + IfThen(bLastRow, 1) do
          begin
          // remove lower border
          poTable.SetCellVisibleBorders(oCell.VisibleBorders.Left, (nMergeRow = nMergeStartRow) and oCell.VisibleBorders.Top,
            oCell.VisibleBorders.Right, {Bottom:} False, nMergeRow, pnColumn);
          // remain first cell
          if nMergeRow > nMergeStartRow then
            begin
            poTable.Cells[nMergeRow, pnColumn].Clear;
            end;
          end;
        OutputDebugString(PChar(Format('Row %d %s Merge-Count %d Page %d Merge-Start %d', [nRow, cThisRowText, nMergeRowCount, nThisCellPage, nMergeStartRow])));
        nMergeRowCount := 0;
        end;
      cPrevRowText := cThisRowText;
      nPrevCellPage := nThisCellPage;
      end
    end

end;
you can compare the attached rvf with the outputdebugstring-messages following - there is a mismatch for the last rows of the splitted table
Row 1 2018-33 Merge-Count 0 Page 2 Merge-Start 0
Row 2 2018-33 Merge-Count 1 Page 2
Row 3 2018-33 Merge-Count 2 Page 2
Row 4 2018-33 Merge-Count 3 Page 2
Row 5 2018-33 Merge-Count 4 Page 2
Row 6 2018-33 Merge-Count 5 Page 2
Row 7 2018-33 Merge-Count 6 Page 2
Row 8 2018-33 Merge-Count 7 Page 2
Row 9 2018-33 Merge-Count 8 Page 2
Row 10 2018-33 Merge-Count 9 Page 2
Row 11 2018-33 Merge-Count 10 Page 2
Row 12 2018-33 Merge-Count 11 Page 2
Row 13 2018-33 Merge-Count 12 Page 2
Row 14 2018-33 Merge-Count 13 Page 2
Row 15 2018-33 Merge-Count 14 Page 2
Row 16 2018-33 Merge-Count 15 Page 2
Row 17 2018-33 Merge-Count 16 Page 2
Row 18 2018-33 Merge-Count 17 Page 2
Row 19 2018-33 Merge-Count 18 Page 2
Row 20 2018-33 Merge-Count 19 Page 2
Row 21 2018-33 Merge-Count 20 Page 2
Row 22 2018-33 Merge-Count 21 Page 2
Row 23 2018-33 Merge-Count 22 Page 2
Row 24 2018-34 Merge-Count 22 Page 2 Merge-Start 1
Row 25 2018-34 Merge-Count 0 Page 3 Merge-Start 24
Row 26 2018-34 Merge-Count 1 Page 3
Row 27 2018-34 Merge-Count 2 Page 3
Row 28 2018-34 Merge-Count 3 Page 3
Row 29 2018-34 Merge-Count 4 Page 3
Row 30 2018-34 Merge-Count 5 Page 3
Row 31 2018-34 Merge-Count 6 Page 3
Row 32 2018-34 Merge-Count 7 Page 3
Row 33 2018-34 Merge-Count 8 Page 3
Row 34 2018-34 Merge-Count 9 Page 3
Row 35 2018-34 Merge-Count 10 Page 3
Row 36 2018-34 Merge-Count 11 Page 3
Row 37 2018-34 Merge-Count 12 Page 3
Row 38 2018-34 Merge-Count 13 Page 3
Row 39 2018-34 Merge-Count 14 Page 3
Row 40 2018-34 Merge-Count 15 Page 3
Row 41 2018-34 Merge-Count 16 Page 3
Row 42 2018-34 Merge-Count 17 Page 3
Row 43 2018-35 Merge-Count 17 Page 3 Merge-Start 25
Row 44 2018-35 Merge-Count 1 Page 3
Row 45 2018-35 Merge-Count 2 Page 3
Row 46 2018-35 Merge-Count 3 Page 3
Row 47 2018-35 Merge-Count 4 Page 3
Row 48 2018-35 Merge-Count 5 Page 3
Row 49 2018-35 Merge-Count 6 Page 3
Row 50 2018-35 Merge-Count 7 Page 3
Row 51 2018-35 Merge-Count 7 Page 4 Merge-Start 43
Row 52 2018-35 Merge-Count 1 Page 4
Row 53 2018-35 Merge-Count 2 Page 4
Row 54 2018-35 Merge-Count 3 Page 4
Row 55 2018-35 Merge-Count 4 Page 4
Row 56 2018-35 Merge-Count 5 Page 4
Row 57 2018-35 Merge-Count 6 Page 4
Row 58 2018-35 Merge-Count 7 Page 4
Row 59 2018-35 Merge-Count 8 Page 4
Row 60 2018-35 Merge-Count 9 Page 4
Row 61 2018-35 Merge-Count 10 Page 4
Row 62 2018-35 Merge-Count 11 Page 4
Row 63 2018-35 Merge-Count 12 Page 4
Row 64 2018-35 Merge-Count 13 Page 4
Row 65 2018-35 Merge-Count 14 Page 4
Row 66 2018-36 Merge-Count 14 Page 4 Merge-Start 51
Row 67 2018-36 Merge-Count 1 Page 4
Row 68 2018-36 Merge-Count 2 Page 4
Row 69 2018-36 Merge-Count 3 Page 4
Row 70 2018-36 Merge-Count 4 Page 4
Row 71 2018-36 Merge-Count 5 Page 4
Row 72 2018-36 Merge-Count 6 Page 4
Row 73 2018-36 Merge-Count 7 Page 4
Row 74 2018-36 Merge-Count 8 Page 4
Row 75 2018-36 Merge-Count 9 Page 4
Row 76 2018-36 Merge-Count 10 Page 4
Row 77 2018-36 Merge-Count 10 Page 5 Merge-Start 66
Row 78 2018-36 Merge-Count 1 Page 5
Row 79 2018-36 Merge-Count 2 Page 5
Row 80 2018-36 Merge-Count 3 Page 5
Row 81 2018-36 Merge-Count 4 Page 5
Row 82 2018-36 Merge-Count 5 Page 5
Row 83 2018-36 Merge-Count 6 Page 5
Row 84 2018-36 Merge-Count 6 Page 5 Merge-Start 77

thank you for your help
Attachments
strangemerge.rvf
(86.41 KiB) Downloaded 3084 times
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: get page number in splitted table

Post by Sergey Tkachenko »

I confirm the problem, we fixed it in our working version. The fix will be included in the next update.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: get page number in splitted table

Post by Sergey Tkachenko »

Fixed in ScaleRichView 8.5 (just uploaded)
Post Reply