- Timestamp:
- May 8, 2015, 7:52:55 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/branches/HealthSevak-CPRS/CPRS-Chart/fReportsPrint.pas
r830 r1693 44 44 procedure PrintReports(AReports: string; const AReportsTitle: string); 45 45 function StringPad(aString: string; aStringCount, aPadCount: integer): String; 46 function DeleteLineBreaks(const S: string): string; 46 47 47 48 implementation … … 115 116 ListItem: TListItem; 116 117 aWPFlag: Boolean; 118 DistanceFromLeft, DistanceRemaining, TotalSpaceAvailable: Integer; 119 SigText, LineBreak, PageBreak, LeftMask: string; 120 LinesPerPage, Limit, Z: Integer; 121 WrappedSig: TStringList; 117 122 begin 118 123 aBasket := TStringList.Create; 119 124 aBasket.Clear; 120 //frmReports.MemText.Clear;121 125 aHead := ''; 122 126 cnt := 2; 123 //aWPFlag := false;124 127 for i := 0 to uColumns.Count - 1 do 125 128 begin … … 145 148 FReportText.Lines.Add(aHead); 146 149 FReportText.Lines.Add('-------------------------------------------------------------------------------'); 147 //frmReports.memText.Lines.Add(aHead); 148 //frmReports.MemText.Lines.Add('-------------------------------------------------------------------------------'); 150 TotalSpaceAvailable := Length(FReportText.Lines[FReportText.Lines.Count - 1]); 149 151 end; 150 152 for i := 0 to frmReports.lvReports.Items.Count - 1 do … … 171 173 begin 172 174 FastAssign(TCellObject(RowObjects.ColumnList[j]).Data, aBasket); 175 if POS('SIG', piece(uColumns[StrToInt(piece(aCol, ':', 2))], '^', 1)) > 0 then begin 176 DistanceFromLeft := Length(aData); //distance from the left side of the page 177 DistanceRemaining := TotalSpaceAvailable - DistanceFromLeft; //Distance to end of page 178 LinesPerPage := 40; 179 Limit := 10; //Arbitrary limit to detrmine if there is enough space to bother with wrapping. 180 LineBreak := #13#10; 181 PageBreak := '**PAGE BREAK**'; 182 X := ''; 183 LeftMask := StringOfChar(' ', DistanceFromLeft); 184 //remove any line breaks from the text 185 SigText := StringReplace(aBasket.Text, #13#10, '', [rfReplaceAll]); 186 if DistanceRemaining < Limit then begin 187 DistanceRemaining := TotalSpaceAvailable; 188 LeftMask := ''; 189 end; 190 WrappedSig := TStringList.Create; 191 try 192 WrappedSig.Text := WrapText(SigText, LineBreak + LeftMask, [' '], DistanceRemaining); 193 For Z := 0 to WrappedSig.Count - 1 do begin 194 Inc(Cnt); 195 If Cnt > LinesPerPage then x := x + PageBreak; 196 X := X + WrappedSig.Strings[Z] + LineBreak; 197 end; 198 finally 199 FreeAndNil(WrappedSig); 200 end; 201 aData := aData + x; 202 end else begin 173 203 for k := 0 to aBasket.Count - 1 do 174 175 176 177 178 204 begin 205 L := StrToIntDef(piece(uColumns[StrToInt(piece(aCol,':',2))],'^',6),15); 206 x := StringPad(aBasket[k], L, L+1); 207 aData := aData + x; 208 end; 179 209 end; 180 210 end; 211 end; 181 212 end; 182 //frmReports.memText.Lines.Add(aData);183 213 FReportText.Lines.Add(aData); 184 214 cnt := cnt + 1; … … 186 216 begin 187 217 cnt := 0; 188 //frmReports.memText.Lines.Add('**PAGE BREAK**');189 218 FReportText.Lines.Add('**PAGE BREAK**'); 190 219 end; … … 200 229 aWPFlag := true; 201 230 FastAssign(TCellObject(RowObjects.ColumnList[j]).Data, aBasket); 202 //frmReports.MemText.Lines.Add(TCellObject(RowObjects.ColumnList[j]).Name);203 231 FReportText.Lines.Add(TCellObject(RowObjects.ColumnList[j]).Name); 204 232 cnt := cnt + 1; 205 233 for k := 0 to aBasket.Count - 1 do 206 234 begin 207 //frmReports.memText.Lines.Add(' ' + aBasket[k]); 208 FReportText.Lines.Add(' ' + aBasket[k]); 235 FReportText.Lines.Add('' + aBasket[k]); 209 236 cnt := cnt + 1; 210 237 if cnt > 40 then 211 238 begin 212 239 cnt := 0; 213 //frmReports.memText.Lines.Add('**PAGE BREAK**');214 240 FReportText.Lines.Add('**PAGE BREAK**'); 215 241 end; … … 220 246 if aWPFlag = true then 221 247 begin 222 //frmReports.MemText.Lines.Add('===============================================================================');223 248 FReportText.Lines.Add('==============================================================================='); 224 249 end; 225 250 end; 226 251 aBasket.Free; 252 end; 253 254 function DeleteLineBreaks(const S: string): string; 255 var 256 Source, SourceEnd: PChar; 257 begin 258 Source := Pointer(S); 259 SourceEnd := Source + Length(S); 260 while Source < SourceEnd do 261 begin 262 case Source^ of 263 #10: Source^ := #32; 264 #13: Source^ := #32; 265 end; 266 Inc(Source); 267 end; 268 Result := S; 227 269 end; 228 270
Note:
See TracChangeset
for help on using the changeset viewer.