set PageBreaksBeforeItems directly above rve-Table

General TRichView support forum. Please post your questions here
Post Reply
j&b
Posts: 184
Joined: Mon Sep 05, 2005 1:35 pm

set PageBreaksBeforeItems directly above rve-Table

Post by j&b »

Hello,

I want to set a 'PageBreaksBeforeItems' directly above a rv-table. To do that I must set caret left beneath rve-table and press button 'Page-Break'.

This is not always easy (rve-table stands very near at the left memo-border, I am not in the first cell so that pressing vk_left (or another shortcut) sets caret left beneath rve-table).

Is there a method to set pageBreak directly above a rv-table if I stand anywhere in rve-table ?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

You can place the caret to the left or to the right of the table.
j&b
Posts: 184
Joined: Mon Sep 05, 2005 1:35 pm

Post by j&b »

First,
thanks for your answere.

I know, but users who work with my program don't know that.
Therefore - I thought - user use the button (in my program) for setting/deleting page-break


procedure TForm1.hmPageBreakOnOffClick(Sender: TObject);
var ItemNo: Integer;
pb: Boolean;
begin
if memo.InplaceEditor<>nil then begin // rve-table has focus
//inputquery 'Shall pageBreak set directly above rve-table ?
//if no then exit
//else jump beneath left rve-table border
and go on
end;
ItemNo := memo.CurItemNo;
if memo.OffsetInCurItem > memo.GetOffsBeforeItem(ItemNo) then pb:= False
else begin
if (ItemNo>0) and (memo.GetItemStyle(ItemNo-1)=rvsListMarker) then dec(ItemNo);
pb:= memo.PageBreaksBeforeItems[ItemNo];
end;
if pb then memo.RemoveCurrentPageBreak else memo.InsertPageBreak;
end;
j&b
Posts: 184
Joined: Mon Sep 05, 2005 1:35 pm

Post by j&b »

Has someone a better solution ?

procedure TForm1.hmBearbeitenUmbruchEinClick(Sender: TObject);
var ItemNo: Integer;
pb,flag: Boolean;
begin
flag:= false;
if memo.InplaceEditor<>nil then begin //Tabelle hat den Fokus
if messageDlg('Seitenumbruch direkt über die/der Tabelle setzen/entfernen ?',
mtConfirmation,[mbYes,mbNo],0)=mrNo then exit
else begin
if (memo.CanChange) and (memo.GetCurrentItemEx(TRVTableItemInfo, rve, TCustomRVItemInfo(rveTable))) then begin
rveTable.EditCell(0,0);
sendKeys('^{LEFT}',true);
flag:= true;
Application.ProcessMessages;
end;
end;


ItemNo := memo.CurItemNo;
if memo.OffsetInCurItem > memo.GetOffsBeforeItem(ItemNo) then pb:= False
else begin
if (ItemNo>0) and (memo.GetItemStyle(ItemNo-1)=rvsListMarker) then dec(ItemNo);
pb:= memo.PageBreaksBeforeItems[ItemNo];
end;
if pb then memo.RemoveCurrentPageBreak else memo.InsertPageBreak;
if flag=true then sendKeys('{RIGHT}',true);
end;
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Code: Select all

uses RVLinear;
...
var rve: TCustomRichViewEdit;
    TableItemNo: Integer;
    SelInfo: TRVSelection;
    RVData: TCustomRVFormattedData;
begin

  if RichViewEdit1.InplaceEditor=nil then
    exit;
  RVGetSelectionEx(RichViewEdit1, SelInfo);
  rve := RichViewEdit1.TopLevelEditor;
  TableItemNo := TRVTableInplaceEdit(rve).FCell.GetTable.GetMyItemNo;
  RVData := TCustomRVFormattedData(TRVTableInplaceEdit(rve).FCell.GetAbsoluteParentData);
  RVData.SetSelectionBounds(TableItemNo, 0, TableItemNo, 0);
  RichViewEdit1.InsertPageBreak;
  RVSetSelectionEx(RichViewEdit1, SelInfo);
end;
j&b
Posts: 184
Joined: Mon Sep 05, 2005 1:35 pm

Post by j&b »

Thanks, Sergey

procedure TForm1.sbPageBreakClick(Sender: TObject);
var rve: TCustomRichViewEdit;
SelInfo: TRVSelection;
RVData: TCustomRVFormattedData;
ItemNo: Integer;
pb: Boolean;
begin
if memo.InplaceEditor<>nil then begin //Tabelle hat den Fokus
if messageDlg('Seitenumbruch direkt über die/der Tabelle setzen/entfernen ?',
mtConfirmation,[mbYes,mbNo],0)=mrNo then exit
else begin
RVGetSelectionEx(memo, SelInfo);
rve := memo.TopLevelEditor;
ItemNo := TRVTableInplaceEdit(rve).FCell.GetTable.GetMyItemNo;
RVData := TCustomRVFormattedData(TRVTableInplaceEdit(rve).FCell.GetAbsoluteParentData);
RVData.SetSelectionBounds(ItemNo, 0, ItemNo, 0);
pb:= memo.PageBreaksBeforeItems[ItemNo];
if pb then memo.RemoveCurrentPageBreak else memo.InsertPageBreak;
RVSetSelectionEx(memo, SelInfo);
exit;

end;
end;
ItemNo := memo.CurItemNo;
if memo.OffsetInCurItem > memo.GetOffsBeforeItem(ItemNo) then pb:= False
else begin
if (ItemNo>0) and (memo.GetItemStyle(ItemNo-1)=rvsListMarker) then dec(ItemNo);
pb:= memo.PageBreaksBeforeItems[ItemNo];
end;
if pb then memo.RemoveCurrentPageBreak else memo.InsertPageBreak;
end;
Post Reply