Changeset 654 for cprs/branches/tmg-cprs/CPRS-Chart/Templates
- Timestamp:
- Jan 4, 2010, 8:02:21 AM (15 years ago)
- Location:
- cprs/branches/tmg-cprs/CPRS-Chart/Templates
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/branches/tmg-cprs/CPRS-Chart/Templates/fTemplateDialog.pas
r453 r654 6 6 uses 7 7 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 8 StdCtrls, ExtCtrls, ORCtrls, ORFn, AppEvnts, uTemplates, DKLang;8 StdCtrls, StrUtils, ExtCtrls, ORCtrls, ORFn, AppEvnts, uTemplates, DKLang; 9 9 10 10 type … … 44 44 FCheck4Required: boolean; 45 45 FSilent: boolean; 46 FHTMLMode : boolean; //kt added 12/28/09 47 FAnswerOpenTag : string; //kt added 12/28/09 48 FAnswerCloseTag : string; //kt added 12/28/09 46 49 procedure SizeFormToCancelBtn(); 47 50 procedure ChkAll(Chk: boolean); … … 59 62 procedure ParentCBEnter(Sender: TObject); 60 63 procedure ParentCBExit(Sender: TObject); 64 procedure SetAnswerHTMLTag(Value : string); //kt 12/28/09 61 65 public 62 66 property Silent: boolean read FSilent write FSilent ; 67 property HTMLMode : boolean read FHTMLMode write FHTMLMode; //kt added 12/28/09 68 property HTMLAnswerOpenTag : string read FAnswerOpenTag write SetAnswerHTMLTag; //kt added 12/28/09 69 property HTMLAnswerCloseTag : string read FAnswerCloseTag write SetAnswerHTMLTag; //kt added 12/28/09 63 70 published 64 71 end; … … 66 73 // Returns True if Cancel button is pressed 67 74 function DoTemplateDialog(SL: TStrings; const CaptionText: string; PreviewMode: boolean = FALSE): boolean; 75 function RemoveHTMLTags(Txt : string) : string; 76 function FormatHTMLTags(Txt : string): string; 68 77 procedure CheckBoilerplate4Fields(SL: TStrings; const CaptionText: string = ''; PreviewMode: boolean = FALSE); overload; 69 78 procedure CheckBoilerplate4Fields(var AText: string; const CaptionText: string = ''; PreviewMode: boolean = FALSE); overload; … … 81 90 Gap = 4; 82 91 IndentGap = 18; 92 HTMLBEGINNINGTAG = '{HTML:'; //kt 93 HTMLENDINGTAG = '}'; //kt 94 HTMLBEGINNINGTAGLEN = length(HTMLBEGINNINGTAG); //kt 95 HTMLENDINGTAGLEN = length(HTMLENDINGTAG); //kt 83 96 84 97 … … 89 102 Save, Hidden: boolean; 90 103 TmpCtrl: TStringList; 91 104 HTMLMode : boolean; //kt added 12/28/09 105 HTMLOpenTag,HTMLCloseTag : string; //kt added 12/28/09 92 106 begin 93 107 Txt := SL.Text; 94 108 SL.Clear; 95 109 TmpCtrl := TStringList.Create; 110 HTMLMode := frmTemplateDialog.HTMLMode; //kt added 12/28/09 111 HTMLOpenTag := frmTemplateDialog.HTMLAnswerOpenTag; //kt added 12/28/09 112 HTMLCloseTag := frmTemplateDialog.HTMLAnswerCloseTag; //kt added 12/28/09 113 //kt added 12/28/09 96 114 try 97 115 for i := 0 to frmTemplateDialog.sbMain.ControlCount-1 do … … 117 135 p2 := StrToInt(Piece(tmp,'~',2)); 118 136 Hidden := (copy(Piece(tmp,'~',3),2,1)=BOOLCHAR[TRUE]); 119 SL.Text := SL.Text + ResolveTemplateFields(Copy(Txt,p1,p2), FALSE, Hidden, IncludeEmbeddedFields); 137 //kt original line 12/28/09 --> SL.Text := SL.Text + ResolveTemplateFields(Copy(Txt,p1,p2), FALSE, Hidden, IncludeEmbeddedFields); 138 SL.Text := SL.Text + ResolveTemplateFields(Copy(Txt,p1,p2), FALSE, Hidden, IncludeEmbeddedFields, 139 HTMLMode, HTMLOpenTag, HTMLCloseTag ); 120 140 end; 121 141 end; … … 195 215 DlgIDCounts.Duplicates := dupError; 196 216 frmTemplateDialog.Caption := CaptionText; 217 frmTemplateDialog.HTMLMode := uTemplates.bUsingHTMLMode; //kt 218 frmTemplateDialog.HTMLAnswerOpenTag := '<I>'; //kt 12/28/09 219 //SL.Text := RemoveHTMLTags(SL.Text); //elh 197 220 AssignFieldIDs(SL); 198 221 frmTemplateDialog.SL := SL; … … 237 260 end; 238 261 frmTemplateDialog.BuildAllControls; 239 repeat 262 repeat 240 263 frmTemplateDialog.ShowModal; 241 if(frmTemplateDialog.ModalResult = mrOK) then 242 GetText(SL, TRUE) {TRUE = Include embedded fields} 243 else 264 if(frmTemplateDialog.ModalResult = mrOK) then begin 265 GetText(SL, TRUE); {TRUE = Include embedded fields} 266 if uTemplates.bUsingHTMLMode then begin 267 SL.Text := FormatHTMLTags(SL.Text); 268 end else begin 269 SL.Text := RemoveHTMLTags(SL.Text); 270 end; 271 end else begin 244 272 if (not PreviewMode) and (not frmTemplateDialog.Silent) and (not uInit.TimedOut) then 245 273 begin … … 262 290 CancelDlg := TRUE; 263 291 end; 292 end; 264 293 until CancelDlg or (frmTemplateDialog.ModalResult = mrOK) 265 294 end … … 281 310 end; 282 311 312 function RemoveHTMLTags(Txt : string): string; 313 var 314 beginning,ending : integer; 315 tempString,tempResult : string; 316 begin 317 tempString := Txt; 318 //here we will strip out all HTML formatting tags //elh 319 beginning := pos(HTMLBEGINNINGTAG, tempString); 320 if beginning = 0 then begin 321 Result := Txt; 322 end else begin 323 while beginning > 0 do 324 begin 325 tempResult := tempResult + Leftstr(tempString,beginning-1); 326 tempString := Rightstr(tempString,length(tempString)-beginning-HTMLBEGINNINGTAGLEN); 327 ending := pos(HTMLENDINGTAG, tempString); 328 tempString := Rightstr(tempString,length(tempString)-ending); 329 beginning := pos(HTMLBEGINNINGTAG, tempString); 330 // tempString := Midstr(Txt,i,HTMLBEGINNINGTAGLEN); 331 end; 332 Result := tempResult + tempString; 333 end; 334 end; 335 336 function FormatHTMLTags(Txt : string): string; 337 var 338 beginning,ending : integer; 339 tempString,tempResult : string; 340 begin 341 tempString := Txt; 342 //here we will strip out all HTML formatting tags //elh 343 beginning := pos(HTMLBEGINNINGTAG, tempString); 344 if beginning = 0 then begin 345 Result := Txt; 346 end else begin 347 while beginning > 0 do 348 begin 349 tempResult := tempResult + Leftstr(tempString,beginning-1); 350 tempString := Rightstr(tempString,length(tempString)-beginning-HTMLBEGINNINGTAGLEN+1); 351 ending := pos(HTMLENDINGTAG, tempString); 352 tempResult := tempResult + Leftstr(tempString,ending-1); 353 tempString := Rightstr(tempString,length(tempString)-ending); 354 beginning := pos(HTMLBEGINNINGTAG, tempString); 355 // tempString := Midstr(Txt,i,HTMLBEGINNINGTAGLEN); 356 end; 357 Result := tempResult + tempString; 358 end; 359 end; 360 283 361 procedure CheckBoilerplate4Fields(SL: TStrings; const CaptionText: string = ''; PreviewMode: boolean = FALSE); 284 362 begin … … 307 385 finally 308 386 tmp.free; 387 end; 388 end; 389 390 procedure TfrmTemplateDialog.SetAnswerHTMLTag(Value : string); 391 //kt 12/28/09 Added entire function 392 begin 393 if Value='' then begin 394 FAnswerOpenTag :=''; 395 FAnswerCloseTag := ''; 396 end else begin 397 if Pos('<',Value)>0 then Value := Piece(Value,'<',2); 398 if Pos('>',Value)>0 then Value := Piece(Value,'>',1); 399 if Pos('/',Value)>0 then Value := Piece(Value,'/',2); 400 FAnswerOpenTag :='<'+Value+'>'; 401 FAnswerCloseTag := '</' + Value + '>'; 309 402 end; 310 403 end; … … 460 553 end; 461 554 tmp := copy(SL.Text, p1, p2); 555 tmp := RemoveHTMLTags(tmp); 462 556 if(copy(tmp, length(tmp)-1, 2) = CRLF) then 463 557 delete(tmp, length(tmp)-1, 2); … … 637 731 procedure TfrmTemplateDialog.FormCreate(Sender: TObject); 638 732 begin 733 FHTMLMode := false; //kt added 12/28/09 639 734 BuildIdx := TStringList.Create; 640 735 Entries := TStringList.Create; -
cprs/branches/tmg-cprs/CPRS-Chart/Templates/uTemplateFields.pas
r453 r654 44 44 FPanelDying: boolean; 45 45 FOnDestroy: TNotifyEvent; 46 FHTMLMode : boolean; //kt added 12/28/09 47 FAnswerOpenTag : string; //kt added 12/28/09 48 FAnswerCloseTag : string; //kt added 12/28/09 46 49 procedure KillLabels; 47 50 function GetFieldValues: string; 48 51 procedure SetFieldValues(const Value: string); 49 52 procedure SetAutoDestroyOnPanelFree(const Value: boolean); 53 procedure SetAnswerHTMLTag(Value : string); //kt 12/28/09 54 50 55 protected 51 56 procedure UpDownChange(Sender: TObject); … … 67 72 property OnDestroy: TNotifyEvent read FOnDestroy write FOnDestroy; 68 73 property FieldValues: string read GetFieldValues write SetFieldValues; 74 property HTMLMode : boolean read FHTMLMode write FHTMLMode; //kt added 12/28/09 75 property AnswerHTMLTag : string read FAnswerOpenTag write SetAnswerHTMLTag; //kt added 12/28/09 69 76 property AutoDestroyOnPanelFree: boolean read FAutoDestroyOnPanelFree 70 77 write SetAutoDestroyOnPanelFree; … … 161 168 procedure AssignFieldIDs(var Txt: string); overload; 162 169 procedure AssignFieldIDs(SL: TStrings); overload; 163 function ResolveTemplateFields(Text: string; AutoWrap: boolean; Hidden: boolean = FALSE; IncludeEmbedded: boolean = FALSE): string; 170 //kt 12/28/09 originial --> function ResolveTemplateFields(Text: string; AutoWrap: boolean; Hidden: boolean = FALSE; IncludeEmbedded: boolean = FALSE): string; 171 function ResolveTemplateFields(Text: string; 172 AutoWrap: boolean; 173 Hidden: boolean = FALSE; 174 IncludeEmbedded: boolean = FALSE; 175 HTMLMode : boolean = FALSE; //kt added 12/28/09 176 HTMLAnswerOpenTag : string = ''; //kt added 12/28/09 177 HTMLAnswerCloseTag : string = '' //kt added 12/28/09 178 ): string; 164 179 function AreTemplateFieldsRequired(const Text: string; FldValues: TORStringList = nil): boolean; 165 180 function HasTemplateField(txt: string): boolean; … … 179 194 TemplateFieldBeginSignature = '{FLD:'; 180 195 TemplateFieldEndSignature = '}'; 196 HTMLBEGINNINGTAG = '{HTML:'; 197 HTMLENDINGTAG = '}'; 198 HTMLBEGINNINGTAGLEN = length(HTMLBEGINNINGTAG); 199 HTMLENDINGTAGLEN = length(HTMLENDINGTAG); 181 200 //MissingFieldsTxt = 'One or more required fields must still be entered.'; <-- original line. //kt 8/8/2007 182 201 function MissingFieldsTxt : string; //kt added … … 519 538 AutoWrap: boolean; 520 539 Hidden: boolean = FALSE; 521 IncludeEmbedded: boolean = FALSE): string; 540 IncludeEmbedded: boolean = FALSE; 541 HTMLMode : boolean = FALSE; //kt added 12/28/09 542 HTMLAnswerOpenTag : string = ''; //kt added 12/28/09 543 HTMLAnswerCloseTag : string = '' //kt added 12/28/09 544 ): string; 522 545 var 523 546 flen, CtrlID, i, j: integer; … … 526 549 FoundEntry: boolean; 527 550 TmplFld: TTemplateField; 551 tempSL : TStringList; 528 552 529 553 procedure AddNewTxt; … … 584 608 if (assigned(TmplFld)) and (TmplFld.DateType in DateComboTypes) then {if this is a TORDateBox} 585 609 NewTxt := Piece(NewTxt,':',1); {we only want the first piece of NewTxt} 610 //kt 12/28/09 --- Start mod to wrap answers in custom HTML tag --- 611 if (HTMLMode=true) and (NewTxt <> '') then begin 612 NewTxt := HTMLAnswerOpenTag + NewTxt + HTMLAnswerCloseTag; //kt 12/29/09 613 end; 614 //kt --- End mod to wrap answers in custom HTML tag --- 586 615 AddNewTxt; 587 616 end; … … 594 623 end; 595 624 end; 625 end else begin 626 if HTMLMode=true then begin 627 tempSL := TStringList.create; 628 tempSL.Text := Result; 629 if tempSL.Count < 3 then begin 630 Result := HTMLAnswerOpenTag + Result + HTMLAnswerCloseTag; 631 end; 632 tempSL.Free; 633 end; 596 634 end; 597 635 until(i = 0); 598 636 if not AutoWrap then 599 637 WordWrapText(Result); 638 600 639 end; 601 640 … … 1801 1840 FID := AID; 1802 1841 FText := Text; 1842 FHTMLMode := false; //kt added 12/28/09 1803 1843 FControls := TStringList.Create; 1804 1844 FIndents := TStringList.Create; … … 2223 2263 end; 2224 2264 2265 procedure TTemplateDialogEntry.SetAnswerHTMLTag(Value : string); 2266 //kt 12/28/09 Added entire function 2267 begin 2268 if Value='' then begin 2269 FAnswerOpenTag :=''; 2270 FAnswerCloseTag := ''; 2271 end else begin 2272 if Pos('<',Value)>0 then Value := Piece(Value,'<',2); 2273 if Pos('>',Value)>0 then Value := Piece(Value,'>',1); 2274 FAnswerOpenTag :='<'+Value+'>'; 2275 FAnswerCloseTag := '</' + Value + '>'; 2276 end; 2277 end; 2278 2225 2279 function TTemplateDialogEntry.GetText: string; 2226 2280 begin 2227 Result := ResolveTemplateFields(FText, FALSE); 2281 //kt Result := ResolveTemplateFields(FText, FALSE); 2282 Result := ResolveTemplateFields(FText, FALSE, FALSE, FALSE, FHTMLMode, FAnswerOpenTag, FAnswerCloseTag); //kt 12/29/09 2228 2283 end; 2229 2284 -
cprs/branches/tmg-cprs/CPRS-Chart/Templates/uTemplates.pas
r541 r654 1886 1886 Itm: string; 1887 1887 begin 1888 Result := GetBoilerplate; 1888 Result := GetBoilerplate; //ELH 1889 1889 if FIsReminderDialog or FIsCOMObject then exit; 1890 1890 Itm := ItemBoilerplate; … … 1952 1952 TmpSL.Text := rHTMLTools.Text2HTML(TmpSL); //kt 8/09 1953 1953 end; //kt 8/09 1954 bUsingHTMLMode := false; //force reset each call. //kt 8/091954 //kt 12/28/09 bUsingHTMLMode := false; //force reset each call. //kt 8/09 1955 1955 end; //kt 8/09 1956 1956 Result := TmpSL.Text;
Note:
See TracChangeset
for help on using the changeset viewer.