trichview.support
Re: page break in TRVreporthelper |
Author |
Message |
Frank Kroeger |
Posted: 07/27/2003 15:42:55 Hi Gabriel, my solution does the following: 1) determin if there is a sentence delimiter in the last line of a page. ( delimiters: . ! ? : ; ) 2) If yes insert a page break at this position, so that the page ends with a full sentence. 3) If not, keep everything as it is (long sentences can span multiple lines and I don't want to move these long sentences completely to the next page, as this could lead to quite a large empty space on the previous page). As I am using TRVReportHelper I can't insert a page break as easy as in RichviewEdit. Because the pagebreak can or most likely will be inside a paragraph I split this paragraph into two items and use the array RVReportHelper.Richview.PageBreaksBeforeItems to insert the break. Therefor I have to copy all items to a temporary richview until the item with my desired break, split this item and then copy all the rest to the temporary richview. This then has to be done for all pages iteratively. So simply put I do the following: rvh : TRVReportHelper; rvh.GetFirstItemOnPage(PageNo, ItemNo, ItemOffset); txt := Copy(rvh.Richview.GetItemText(ItemNo, 1, ItemOffset-1); If (Pos('.',txt)<>0) or Pos('!',txt)<>0) etc. then begin // Find the last delimiter in this paragraph. txt can hold // multiple lines. k := length(txt); While (k>0) and ( not (txt[k] in delimiters) ) do dec(k);
If k>0 then begin rvhelp.Richview.clear; for i:=0 to ItemNo-1 do begin // is the item i a new paragraph or just new text style If rvh.richview.IsParaStart(i) then rvhelp.richview.addTextNl(textofitem, styleofitem, paraofitem, paraofitem) else rvhelp.richview.AddNl(textofitem, styleofitem, -1); end; // add the new paragraph helptxt := copy(txt,1,k); rvhelp.richview.addNl(help,styleofitem,paraofitem); helptxt := Trim(copy(txt,k+1,length(txt)-k) + Copy(rvh.richview.getitemtext(itemNo),ItemOffset,length({item}-ItemOffset+1)); rvhelp.richview.AddNL(helptxt,styleofitem,paraofitem); rvhelp.richview.PagebreaksBeforeItems[rvhelp.richview.itemcount-1] := True; // Now copy the rest For i:=ItemNo+1 to rvh.richview.ItemCount-1 do begin If rvh.richview.IsParastart(i) etc. // same as above end; // Now I have to copy everything back to the original richview For i:=0 to rvhelp.richview.ItemCount-1 do begin // Same copy routine as above just vica versa. end; // some other stuff // with UnformatLastPage I can now let reporthelper reformat the changed page end; end; I would really like to simplify this. But as my project had to be ready by last wednesday I used this rather ugly routine. My project only uses richview for text entries. So I do not have to bother with images, URLs etc. If I would use items other than text the copy routine would have to be different. What I would wish for is an event of richview something like this: OnPageBreak(itemtext:string;var offset:integer) where offset would be the offset in the item where the page break occurs and the user would be able to change this offset (to smaller values only of course ( 0 <= offset )). Greetings, Frank "Gabriel Padilla" <gpadilla@starstream.net> wrote: > >To Frank, > >I have a similar problem in that I am trying to implement footnotes. My >client says footnotes is an absolute requirement. Since this is not a priority >for Sergey, I also need a way to adjust where the page breaks occur. I have >not finalized the solution yet but I am looking into using: > > rvprint.GetFirstItemOnPage(i, ItemNo, offsetInItem); > >to determine the first item on each page and add extra paragraph spacing >to certain items and iteratively adjust until I get the desired page breaks. > This may be a kludge but I need a workaround. > >I am curious as to the progress of any solution you use. > >Gabriel Padilla > > |
Powered by ABC Amber Outlook Express Converter