Page 1 of 1

set PageBreaksBeforeItems directly above rve-Table

Posted: Sun Feb 01, 2009 6:19 am
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 ?

Posted: Mon Feb 02, 2009 3:31 pm
by Sergey Tkachenko
You can place the caret to the left or to the right of the table.

Posted: Mon Feb 02, 2009 3:58 pm
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;

Posted: Thu Feb 05, 2009 4:09 pm
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;

Posted: Thu Feb 05, 2009 4:37 pm
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;

Posted: Thu Feb 05, 2009 5:02 pm
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;