Produced by Araxis Merge on 7/13/2017 1:08:07 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | v31B.zip\v31B\377\OR_30_377V235_SRC\Templates | uTemplateFields.pas | Wed May 17 14:56:10 2017 UTC |
| 2 | v31B.zip\v31B\377\OR_30_377V235_SRC\Templates | uTemplateFields.pas | Thu Jul 13 14:46:52 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 6 | 5298 |
| Changed | 5 | 10 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | unit uTemp lateFields ; | |
| 2 | ||
| 3 | interface | |
| 4 | ||
| 5 | uses | |
| 6 | Forms, S ysUtils, C lasses, Di alogs, Std Ctrls, Ext Ctrls, Con trols, Con tnrs, | |
| 7 | Graphics , ORClasse s, ComCtrl s, ORDtTm, uDlgCompo nents, Typ Info, ORFn , StrUtils , uConst; | |
| 8 | ||
| 9 | type | |
| 10 | TTemplat eFieldType = (dftUnk nown, dftE ditBox, df tComboBox, dftButton , dftCheck Boxes, | |
| 11 | dftRad ioButtons, dftDate, dftNumber, dftHyperl ink, dftWP , dftText, | |
| 12 | // keep df tScreenRea der as las t entry - users can not create this type of field | |
| 13 | dftScr eenReader) ; | |
| 14 | ||
| 15 | TTmplFld DateType = (dtUnknow n, dtDate, dtDateTim e, dtDateR eqTime, | |
| 16 | dtCombo , dtYear, dtYearMont h); | |
| 17 | ||
| 18 | const | |
| 19 | FldItemT ypes = [d ftComboBox , dftButto n, dftChec kBoxes, df tRadioButt ons, dftWP , dftText] ; | |
| 20 | SepLines Types = [d ftCheckBox es, dftRad ioButtons] ; | |
| 21 | EditLenT ypes = [d ftEditBox, dftComboB ox, dftWP] ; | |
| 22 | EditDflt Types = [d ftEditBox, dftHyperl ink]; | |
| 23 | EditDflt Type2 = [d ftEditBox, dftHyperl ink, dftDa te]; | |
| 24 | ItemDflt Types = [d ftComboBox , dftButto n, dftChec kBoxes, df tRadioButt ons]; | |
| 25 | NoRequir ed = [d ftHyperlin k, dftText ]; | |
| 26 | ExcludeT ext = [d ftHyperlin k, dftText ]; | |
| 27 | DateComb oTypes = [ dtCombo, d tYear, dtY earMonth]; | |
| 28 | ||
| 29 | type | |
| 30 | TTemplat eDialogEnt ry = class (TObject) | |
| 31 | private | |
| 32 | FID: s tring; | |
| 33 | FFont: TFont; | |
| 34 | FPanel : TDlgFiel dPanel; | |
| 35 | FContr ols: TStri ngList; | |
| 36 | FInden ts: TStrin gList; | |
| 37 | FFirst Build: boo lean; | |
| 38 | FOnCha nge: TNoti fyEvent; | |
| 39 | FText: string; | |
| 40 | FInter nalID: str ing; | |
| 41 | FObj: TObject; | |
| 42 | FField Values: st ring; | |
| 43 | FUpdat ing: boole an; | |
| 44 | FAutoD estroyOnPa nelFree: b oolean; | |
| 45 | FPanel Dying: boo lean; | |
| 46 | FOnDes troy: TNot ifyEvent; | |
| 47 | proced ure KillLa bels; | |
| 48 | functi on GetFiel dValues: s tring; | |
| 49 | proced ure SetFie ldValues(c onst Value : string); | |
| 50 | proced ure SetAut oDestroyOn PanelFree( const Valu e: boolean ); | |
| 51 | functi on StripCo de(var txt : string; code: char ): boolean ; | |
| 52 | protecte d | |
| 53 | proced ure UpDown Change(Sen der: TObje ct); | |
| 54 | proced ure DoChan ge(Sender: TObject); | |
| 55 | functi on GetCont rolText(Ct rlID: inte ger; NoCom mas: boole an; | |
| 56 | va r FoundEnt ry: boolea n; AutoWra p: boolean ; | |
| 57 | em Field: str ing = ''; CrntLnTxt: String = ''; AutoW rapIndent: Integer = 0; | |
| 58 | No Format: Bo olean = fa lse): stri ng; | |
| 59 | proced ure SetCon trolText(C trlID: int eger; ATex t: string) ; | |
| 60 | public | |
| 61 | constr uctor Crea te(AParent : TWinCont rol; AID, Text: stri ng); | |
| 62 | destru ctor Destr oy; overri de; | |
| 63 | functi on GetPane l(MaxLen: integer; A Parent: TW inControl; | |
| 64 | OwningCh eckBox: TC PRSDialogP arentCheck Box): TDlg FieldPanel ; | |
| 65 | functi on GetText : string; | |
| 66 | proper ty Text: s tring read FText wri te FText; | |
| 67 | proper ty Interna lID: strin g read FIn ternalID w rite FInte rnalID; | |
| 68 | proper ty ID: str ing read F ID; | |
| 69 | proper ty Obj: TO bject read FObj writ e FObj; | |
| 70 | proper ty OnChang e: TNotify Event read FOnChange write FOn Change; | |
| 71 | proper ty OnDestr oy: TNotif yEvent rea d FOnDestr oy write F OnDestroy; | |
| 72 | proper ty FieldVa lues: stri ng read Ge tFieldValu es write S etFieldVal ues; | |
| 73 | proper ty AutoDes troyOnPane lFree: boo lean read FAutoDestr oyOnPanelF ree | |
| 74 | write SetAutoDe stroyOnPan elFree; | |
| 75 | end; | |
| 76 | ||
| 77 | TTemplat eField = c lass(TObje ct) | |
| 78 | private | |
| 79 | FMaxLe n: integer ; | |
| 80 | FFldNa me: string ; | |
| 81 | FNameC hanged: bo olean; | |
| 82 | FLMTex t: string; | |
| 83 | FEditD efault: st ring; | |
| 84 | FNotes : string; | |
| 85 | FItems : string; | |
| 86 | FInact ive: boole an; | |
| 87 | FItemD efault: st ring; | |
| 88 | FFldTy pe: TTempl ateFieldTy pe; | |
| 89 | FRequi red: boole an; | |
| 90 | FSepLi nes: boole an; | |
| 91 | FTextL en: intege r; | |
| 92 | FInden t: integer ; | |
| 93 | FPad: integer; | |
| 94 | FMinVa l: integer ; | |
| 95 | FMaxVa l: integer ; | |
| 96 | FIncre ment: inte ger; | |
| 97 | FURL: string; | |
| 98 | FDateT ype: TTmpl FldDateTyp e; | |
| 99 | FModif ied: boole an; | |
| 100 | FID: s tring; | |
| 101 | FLocke d: boolean ; | |
| 102 | proced ure SetEdi tDefault(c onst Value : string); | |
| 103 | proced ure SetFld Name(const Value: st ring); | |
| 104 | proced ure SetFld Type(const Value: TT emplateFie ldType); | |
| 105 | proced ure SetIna ctive(cons t Value: b oolean); | |
| 106 | proced ure SetReq uired(cons t Value: b oolean); | |
| 107 | proced ure SetSep Lines(cons t Value: b oolean); | |
| 108 | proced ure SetIte mDefault(c onst Value : string); | |
| 109 | proced ure SetIte ms(const V alue: stri ng); | |
| 110 | proced ure SetLMT ext(const Value: str ing); | |
| 111 | proced ure SetMax Len(const Value: int eger); | |
| 112 | proced ure SetNot es(const V alue: stri ng); | |
| 113 | proced ure SetID( const Valu e: string) ; | |
| 114 | proced ure SetInc rement(con st Value: integer); | |
| 115 | proced ure SetInd ent(const Value: int eger); | |
| 116 | proced ure SetMax Val(const Value: int eger); | |
| 117 | proced ure SetMin Val(const Value: int eger); | |
| 118 | proced ure SetPad (const Val ue: intege r); | |
| 119 | proced ure SetTex tLen(const Value: in teger); | |
| 120 | proced ure SetURL (const Val ue: string ); | |
| 121 | functi on GetTemp lateFieldD efault: st ring; | |
| 122 | proced ure Create DialogCont rols(Entry : TTemplat eDialogEnt ry; | |
| 123 | var I ndex: Inte ger; CtrlI D: integer ); | |
| 124 | functi on SaveErr or: string ; | |
| 125 | functi on Width: integer; | |
| 126 | functi on GetRequ ired: bool ean; | |
| 127 | proced ure SetDat eType(cons t Value: T TmplFldDat eType); | |
| 128 | public | |
| 129 | constr uctor Crea te(AData: TStrings); | |
| 130 | destru ctor Destr oy; overri de; | |
| 131 | proced ure Assign (AFld: TTe mplateFiel d); | |
| 132 | functi on NewFiel d: boolean ; | |
| 133 | functi on CanModi fy: boolea n; | |
| 134 | proper ty ID: str ing read F ID write S etID; | |
| 135 | proper ty FldName : string r ead FFldNa me write S etFldName; | |
| 136 | proper ty NameCha nged: bool ean read F NameChange d; | |
| 137 | proper ty FldType : TTemplat eFieldType read FFld Type write SetFldTyp e; | |
| 138 | proper ty MaxLen: integer r ead FMaxLe n write Se tMaxLen; | |
| 139 | proper ty EditDef ault: stri ng read FE ditDefault write Set EditDefaul t; | |
| 140 | proper ty Items: string rea d FItems w rite SetIt ems; | |
| 141 | proper ty ItemDef ault: stri ng read FI temDefault write Set ItemDefaul t; | |
| 142 | proper ty LMText: string re ad FLMText write Set LMText; | |
| 143 | proper ty Inactiv e: boolean read FIna ctive writ e SetInact ive; | |
| 144 | proper ty Require d: boolean read GetR equired wr ite SetReq uired; | |
| 145 | proper ty SepLine s: boolean read FSep Lines writ e SetSepLi nes; | |
| 146 | proper ty TextLen : integer read FText Len write SetTextLen ; | |
| 147 | proper ty Indent: integer r ead FInden t write Se tIndent; | |
| 148 | proper ty Pad: in teger read FPad writ e SetPad; | |
| 149 | proper ty MinVal: integer r ead FMinVa l write Se tMinVal; | |
| 150 | proper ty MaxVal: integer r ead FMaxVa l write Se tMaxVal; | |
| 151 | proper ty Increme nt: intege r read FIn crement wr ite SetInc rement; | |
| 152 | proper ty URL: st ring read FURL write SetURL; | |
| 153 | proper ty DateTyp e: TTmplFl dDateType read FDate Type write SetDateTy pe; | |
| 154 | proper ty Notes: string rea d FNotes w rite SetNo tes; | |
| 155 | proper ty Templat eFieldDefa ult: strin g read Get TemplateFi eldDefault ; | |
| 156 | end; | |
| 157 | ||
| 158 | TIntStru c = class( TObject) | |
| 159 | public | |
| 160 | x: int eger; | |
| 161 | end; | |
| 162 | ||
| 163 | function G etDialogEn try(AParen t: TWinCon trol; AID, AText: st ring): TTe mplateDial ogEntry; | |
| 164 | procedure FreeEntrie s(SL: TStr ings); | |
| 165 | procedure AssignFiel dIDs(var T xt: string ); overloa d; | |
| 166 | procedure AssignFiel dIDs(SL: T Strings); overload; | |
| 167 | function R esolveTemp lateFields (Text: str ing; AutoW rap: boole an; Hidden : boolean = FALSE; I ncludeEmbe dded: bool ean = FALS E; AutoWra pIndent: I nteger = 0 ): string; | |
| 168 | function A reTemplate FieldsRequ ired(const Text: str ing; FldVa lues: TORS tringList = nil): b oolean; | |
| 169 | function H asTemplate Field(txt: string): boolean; | |
| 170 | ||
| 171 | function G etTemplate Field(ATem plateField : string; ByIEN: boo lean): TTe mplateFiel d; | |
| 172 | function T emplateFie ldNameProb lem(Fld: T TemplateFi eld): bool ean; | |
| 173 | function S aveTemplat eFieldErro rs: string ; | |
| 174 | procedure ClearModif iedTemplat eFields; | |
| 175 | function A nyTemplate FieldsModi fied: bool ean; | |
| 176 | procedure ListTempla teFields(c onst AText : string; AList: TSt rings; Lis tErrors: b oolean = F ALSE); | |
| 177 | function B oilerplate TemplateFi eldsOK(con st AText: string; Ms g: string = ''): boo lean; | |
| 178 | procedure EnsureText (edt: TEdi t; ud: TUp Down); | |
| 179 | procedure ConvertCod es2Text(sl : TStrings ; Short: b oolean); | |
| 180 | function S tripEmbedd ed(iItems: string): string; | |
| 181 | procedure StripScree nReaderCod es(var Tex t: string) ; overload ; | |
| 182 | procedure StripScree nReaderCod es(SL: TSt rings); ov erload; | |
| 183 | function H asScreenRe aderBreakC odes(SL: T Strings): boolean; | |
| 184 | ||
| 185 | const | |
| 186 | Template FieldSigna ture = '{F LD'; | |
| 187 | Template FieldBegin Signature = Template FieldSigna ture + ':' ; | |
| 188 | Template FieldEndSi gnature = '}'; | |
| 189 | ScreenRe aderCodeSi gnature = '{SR-'; | |
| 190 | ScreenRe aderCodeTy pe = ' Sc reen Reade r Code'; | |
| 191 | ScreenRe aderCodeCo unt = 2; | |
| 192 | ScreenRe aderShownC ount = 1; | |
| 193 | ScreenRe aderStopCo de = Scree nReaderCod eSignature + 'STOP' + Template FieldEndSi gnature; | |
| 194 | ScreenRe aderStopCo deLen = Le ngth(Scree nReaderSto pCode); | |
| 195 | ScreenRe aderStopCo deID = '-4 3'; | |
| 196 | ScreenRe aderStopNa me = 'SCRE EN READER STOP CODE **'; | |
| 197 | ScreenRe aderStopCo deLine = S creenReade rStopCodeI D + U + Sc reenReader StopName + U + Scree nReaderCod eType; | |
| 198 | ScreenRe aderContin ueCode = S creenReade rCodeSigna ture + 'CO NT' + Temp lateFieldE ndSignatur e; | |
| 199 | ScreenRe aderContin ueCodeLen = Length(S creenReade rContinueC ode); | |
| 200 | ScreenRe aderContin ueCodeOld = ScreenRe aderCodeSi gnature + 'CONTINUE' + Templat eFieldEndS ignature; | |
| 201 | ScreenRe aderContin ueCodeOldL en = Lengt h(ScreenRe aderContin ueCodeOld) ; | |
| 202 | ScreenRe aderContin ueCodeID = '-44'; | |
| 203 | ScreenRe aderContin ueCodeName = 'SCREEN READER CO NTINUE COD E ***'; | |
| 204 | ScreenRe aderContin ueCodeLine = ScreenR eaderConti nueCodeID + U + Scre enReaderCo ntinueCode Name + U + ScreenRea derCodeTyp e; | |
| 205 | MissingF ieldsTxt = 'One or m ore requir ed fields must still be entere d.'; | |
| 206 | ||
| 207 | ScreenRe aderCodes: array [0..Screen ReaderCode Count] of string = | |
| 208 | (Scr eenReaderS topCode, S creenReade rContinueC ode, Scree nReaderCon tinueCodeO ld); | |
| 209 | ScreenRe aderCodeLe ns: array [0..Screen ReaderCode Count] of integer = | |
| 210 | (Scr eenReaderS topCodeLen , ScreenRe aderContin ueCodeLen, ScreenRea derContinu eCodeOldLe n); | |
| 211 | ScreenRe aderCodeID s: array [0..Screen ReaderShow nCount] of string = | |
| 212 | (Scr eenReaderS topCodeID, ScreenRea derContinu eCodeID); | |
| 213 | ScreenRe aderCodeLi nes: array [0..Screen ReaderShow nCount] of string = | |
| 214 | (Scr eenReaderS topCodeLin e, ScreenR eaderConti nueCodeLin e); | |
| 215 | ||
| 216 | Template FieldTypeC odes: arra y[TTemplat eFieldType ] of strin g = | |
| 217 | { df tUnknown } ('', | |
| 218 | { df tEditBox } 'E' , | |
| 219 | { df tComboBox } 'C' , | |
| 220 | { df tButton } 'B' , | |
| 221 | { df tCheckBoxe s } 'X' , | |
| 222 | { df tRadioButt ons } 'R' , | |
| 223 | { df tDate } 'D' , | |
| 224 | { df tNumber } 'N' , | |
| 225 | { df tHyperlink } 'H' , | |
| 226 | { df tWP } 'W' , | |
| 227 | { df tText } 'T' , | |
| 228 | { df tScreenRea der } 'S' ); | |
| 229 | ||
| 230 | Template FieldTypeD esc: array [TTemplate FieldType, boolean] of string = | |
| 231 | { df tUnknown } (('' ,''), | |
| 232 | { df tEditBox } ('E dit Box', 'Edit'), | |
| 233 | { df tComboBox } ('C ombo Box', 'Combo'), | |
| 234 | { df tButton } ('B utton', 'Button'), | |
| 235 | { df tCheckBoxe s } ('C heck Boxes ', 'Check'), | |
| 236 | { df tRadioButt ons } ('R adio Butto ns', 'Radio'), | |
| 237 | { df tDate } ('D ate', 'Date'), | |
| 238 | { df tNumber } ('N umber', 'Num'), | |
| 239 | { df tHyperlink } ('H yperlink', 'Link'), | |
| 240 | { df tWP } ('W ord Proces sing', 'WP'), | |
| 241 | { df tText } ('D isplay Tex t', 'Text'), | |
| 242 | { df tScreenRea der } ('S creen Read er Stop', 'SRStop')) ; | |
| 243 | ||
| 244 | Template DateTypeDe sc: array[ TTmplFldDa teType, bo olean] of string = | |
| 245 | { dtU nknown } (('' ,''), | |
| 246 | { dtD ate } ('D ate', 'Dat e'), | |
| 247 | { dtD ateTime } ('D ate & Time ', 'Tim e'), | |
| 248 | { dtD ateReqTime } ('D ate & Req Time','R.T ime'), | |
| 249 | { dtC ombo } ('D ate Combo' , 'C.D ate'), | |
| 250 | { dtY ear } ('Y ear', 'Yea r'), | |
| 251 | { dtY earMonth } ('Y ear & Mont h', 'Mon th')); | |
| 252 | ||
| 253 | FldNames : array[TT emplateFie ldType] of string = | |
| 254 | { dftUnknow n } ('', | |
| 255 | { dftEditBo x } 'EDIT', | |
| 256 | { dftComboB ox } 'LIST', | |
| 257 | { dftButton } 'BTTN', | |
| 258 | { dftCheckB oxes } 'CBOX', | |
| 259 | { dftRadioB uttons } 'RBTN', | |
| 260 | { dftDate } 'DATE', | |
| 261 | { dftNumber } 'NUMB', | |
| 262 | { dftHyperl ink } 'LINK', | |
| 263 | { dftWP } 'WRDP', | |
| 264 | { dftTExt } 'TEXT', | |
| 265 | { dftScreen Reader } 'SRST'); | |
| 266 | ||
| 267 | Template FieldDateC odes: arra y[TTmplFld DateType] of string = | |
| 268 | { dtU nknown } ('', | |
| 269 | { dtD ate } 'D' , | |
| 270 | { dtD ateTime } 'T' , | |
| 271 | { dtD ateReqTime } 'R' , | |
| 272 | { dtC ombo } 'C' , | |
| 273 | { dtY ear } 'Y' , | |
| 274 | { dtY earMonth } 'M' ); | |
| 275 | ||
| 276 | MaxTFWPL ines = 20; | |
| 277 | MaxTFEdt Len = 70; | |
| 278 | ||
| 279 | var | |
| 280 | MAX_WR AP_WIDTH: integer = MAX_ENTRY_ WIDTH; / /MAX_WRAP_ WIDTH used to set th e line wra p limit fo r template field tex t | |
| 281 | / /Consults requires 7 4 characte rs; 80 for everythin g else | |
| 282 | implementa tion | |
| 283 | ||
| 284 | uses | |
| 285 | rTemplat es, ORCtrl s, mTempla teFieldBut ton, dShar ed, uCore, rCore, Wi ndows, | |
| 286 | VAUtils, VA508Acce ssibilityM anager, VA 508Accessi bilityRout er, System .UITypes, System.Typ es; | |
| 287 | ||
| 288 | ||
| 289 | const | |
| 290 | NewTempl ateField = 'NEW TEMP LATE FIELD '; | |
| 291 | Template FieldSigna tureLen = length(Tem plateField BeginSigna ture); | |
| 292 | Template FieldSigna tureEndLen = length( TemplateFi eldEndSign ature); | |
| 293 | ||
| 294 | var | |
| 295 | uTmplFld s: TList = nil; | |
| 296 | uEntries : TStringL ist = nil; | |
| 297 | ||
| 298 | uNewTemp lateFieldI DCnt: long int = 0; | |
| 299 | uRadioGr oupIndex: integer = 0; | |
| 300 | ||
| 301 | uInterna lFieldIDCo unt: integ er = 0; | |
| 302 | ||
| 303 | ||
| 304 | ||
| 305 | const | |
| 306 | FieldIDD elim = '`' ; | |
| 307 | FieldIDL en = 6; | |
| 308 | NewLine = 'NL'; | |
| 309 | ||
| 310 | function G etNewField ID: string ; | |
| 311 | begin | |
| 312 | inc(uInt ernalField IDCount); | |
| 313 | Result : = IntToStr (uInternal FieldIDCou nt); | |
| 314 | Result : = FieldIDD elim + | |
| 315 | copy(Str ingOfChar( '0', Field IDLen-2) + Result, l ength(Resu lt), Field IDLen-1); | |
| 316 | end; | |
| 317 | ||
| 318 | function G etDialogEn try(AParen t: TWinCon trol; AID, AText: st ring): TTe mplateDial ogEntry; | |
| 319 | var | |
| 320 | idx: int eger; | |
| 321 | ||
| 322 | begin | |
| 323 | Result : = nil; | |
| 324 | if AID = '' then e xit; | |
| 325 | if(not a ssigned(uE ntries)) t hen | |
| 326 | uEntri es := TStr ingList.Cr eate; | |
| 327 | idx := u Entries.In dexOf(AID) ; | |
| 328 | if(idx < 0) then | |
| 329 | begin | |
| 330 | Result := TTempl ateDialogE ntry.Creat e(AParent, AID, ATex t); | |
| 331 | uEntri es.AddObje ct(AID, Re sult); | |
| 332 | end | |
| 333 | else | |
| 334 | Result := TTempl ateDialogE ntry(uEntr ies.Object s[idx]); | |
| 335 | end; | |
| 336 | ||
| 337 | procedure FreeEntrie s(SL: TStr ings); | |
| 338 | var | |
| 339 | i, idx, cnt: integ er; | |
| 340 | ||
| 341 | begin | |
| 342 | if(assig ned(uEntri es)) then | |
| 343 | begin | |
| 344 | for i := SL.Coun t-1 downto 0 do | |
| 345 | begin | |
| 346 | idx := uEntrie s.IndexOf( SL[i]); | |
| 347 | if(i dx >= 0) t hen | |
| 348 | begi n | |
| 349 | cn t := uEntr ies.Count; | |
| 350 | if (assigned( uEntries.O bjects[idx ])) then | |
| 351 | be gin | |
| 352 | TTemplateD ialogEntry (uEntries. Objects[id x]).AutoDe stroyOnPan elFree := FALSE; | |
| 353 | uEntries.O bjects[idx ].Free; | |
| 354 | en d; | |
| 355 | if cnt = uEn tries.Coun t then | |
| 356 | uEntries.D elete(idx) ; | |
| 357 | end; | |
| 358 | end; | |
| 359 | if(uEn tries.Coun t = 0) the n | |
| 360 | uInt ernalField IDCount := 0; | |
| 361 | end; | |
| 362 | end; | |
| 363 | ||
| 364 | procedure AssignFiel dIDs(var T xt: string ); | |
| 365 | var | |
| 366 | i: integ er; | |
| 367 | ||
| 368 | begin | |
| 369 | i := 0; | |
| 370 | while (i < length( Txt)) do | |
| 371 | begin | |
| 372 | inc(i) ; | |
| 373 | if(cop y(Txt,i,Te mplateFiel dSignature Len) = Tem plateField BeginSigna ture) then | |
| 374 | begin | |
| 375 | inc( i,Template FieldSigna tureLen); | |
| 376 | if(i < length( Txt)) and (copy(Txt, i,1) <> Fi eldIDDelim ) then | |
| 377 | begi n | |
| 378 | in sert(GetNe wFieldID, Txt, i); | |
| 379 | in c(i, Field IDLen); | |
| 380 | end; | |
| 381 | end; | |
| 382 | end; | |
| 383 | end; | |
| 384 | ||
| 385 | procedure AssignFiel dIDs(SL: T Strings); | |
| 386 | var | |
| 387 | i: integ er; | |
| 388 | txt: str ing; | |
| 389 | ||
| 390 | begin | |
| 391 | for i := 0 to SL.C ount-1 do | |
| 392 | begin | |
| 393 | txt := SL[i]; | |
| 394 | Assign FieldIDs(t xt); | |
| 395 | SL[i] := txt; | |
| 396 | end; | |
| 397 | end; | |
| 398 | ||
| 399 | procedure WordWrapTe xt(var Txt : string); | |
| 400 | var | |
| 401 | TmpSL: T StringList ; | |
| 402 | i: integ er; | |
| 403 | ||
| 404 | function WrappedTe xt(const S tr: string ): string; | |
| 405 | var | |
| 406 | i, i2, j, k: int eger; | |
| 407 | Temp: string; | |
| 408 | ||
| 409 | begin | |
| 410 | Temp : = Str; | |
| 411 | Result := ''; | |
| 412 | i2 := 0; | |
| 413 | ||
| 414 | repeat | |
| 415 | i := pos(Templ ateFieldBe ginSignatu re, Temp); | |
| 416 | ||
| 417 | if i >0 then | |
| 418 | j := pos(Tem plateField EndSignatu re, copy(T emp, i, Ma xInt)) | |
| 419 | else | |
| 420 | j := 0; | |
| 421 | ||
| 422 | if ( j > 0) the n | |
| 423 | be gin | |
| 424 | i2 := pos(Te mplateFiel dBeginSign ature, cop y(Temp, i+ TemplateFi eldSignatu reLen, Max Int)); | |
| 425 | if (i2 = 0) then | |
| 426 | i2 := MaxI nt | |
| 427 | el se | |
| 428 | i2 := i + TemplateFi eldSignatu reLen + i2 - 1; | |
| 429 | en d; | |
| 430 | ||
| 431 | if ( i>0) and ( j=0) then | |
| 432 | i := 0; | |
| 433 | ||
| 434 | if ( i>0) and ( j>0) then | |
| 435 | if (j > i2) then | |
| 436 | begin | |
| 437 | Result := Result + c opy(Temp, 1, i2-1); | |
| 438 | delete(Tem p, 1, i2-1 ); | |
| 439 | end | |
| 440 | el se | |
| 441 | begin | |
| 442 | for k := ( i+Template FieldSigna tureLen) t o (i+j-2) do | |
| 443 | if Temp[ k]=' ' the n | |
| 444 | Temp[k ]:= #1; | |
| 445 | i := i + j - 1; | |
| 446 | Result := Result + c opy(Temp,1 ,i); | |
| 447 | delete(Tem p,1,i); | |
| 448 | end; | |
| 449 | ||
| 450 | until (i = 0); | |
| 451 | ||
| 452 | Result := Result + Temp; | |
| 453 | Result := WrapTe xt(Result, #13#10, [ ' '], MAX_ WRAP_WIDTH ); | |
| 454 | repeat | |
| 455 | i := pos(#1, R esult); | |
| 456 | if i > 0 then | |
| 457 | Re sult[i] := ' '; | |
| 458 | until i = 0; | |
| 459 | end; | |
| 460 | ||
| 461 | begin | |
| 462 | if lengt h(Txt) > M AX_WRAP_WI DTH then | |
| 463 | begin | |
| 464 | TmpSL := TString List.Creat e; | |
| 465 | try | |
| 466 | TmpS L.Text := Txt; | |
| 467 | Txt := ''; | |
| 468 | for i := 0 to TmpSL.Coun t-1 do | |
| 469 | begi n | |
| 470 | if Txt <> '' then | |
| 471 | Txt := Txt + CRLF; | |
| 472 | Tx t := Txt + WrappedTe xt(TmpSL[i ]); | |
| 473 | end; | |
| 474 | finall y | |
| 475 | TmpS L.Free; | |
| 476 | end; | |
| 477 | end; | |
| 478 | end; | |
| 479 | ||
| 480 | function R esolveTemp lateFields (Text: str ing; | |
| 481 | AutoWrap: boolean; | |
| 482 | Hidden: b oolean = F ALSE; | |
| 483 | IncludeEm bedded: bo olean = FA LSE; | |
| 484 | AutoWrapI ndent: Int eger = 0): string; | |
| 485 | var | |
| 486 | flen, Ct rlID, i, j : integer; | |
| 487 | Entry: T TemplateDi alogEntry; | |
| 488 | iField, Temp, NewT xt, Fld: s tring; | |
| 489 | FoundEnt ry: boolea n; | |
| 490 | TmplFld: TTemplate Field; | |
| 491 | TempCopy : String; | |
| 492 | ||
| 493 | procedur e AddNewTx t; | |
| 494 | begin | |
| 495 | if(New Txt <> '') then | |
| 496 | begin | |
| 497 | inse rt(StringO fChar('x', length(New Txt)), Tem p, i); | |
| 498 | inse rt(NewTxt, Result, i ); | |
| 499 | inc( i, length( NewTxt)); | |
| 500 | end; | |
| 501 | end; | |
| 502 | ||
| 503 | begin | |
| 504 | if(not a ssigned(uE ntries)) t hen | |
| 505 | uEntri es := TStr ingList.Cr eate; | |
| 506 | Result : = Text; | |
| 507 | Temp := Text; // U se Temp to allow tem plate fiel ds to cont ain other template f ield refer ences | |
| 508 | repeat | |
| 509 | i := p os(Templat eFieldBegi nSignature , Temp); | |
| 510 | if(i > 0) then | |
| 511 | begin | |
| 512 | Ctrl ID := 0; | |
| 513 | if(c opy(Temp, i + Templa teFieldSig natureLen, 1) = Fiel dIDDelim) then | |
| 514 | begi n | |
| 515 | Ct rlID := St rToIntDef( copy(Temp, i + Templ ateFieldSi gnatureLen + 1, Fiel dIDLen-1), 0); | |
| 516 | de lete(Temp, i + Templa teFieldSig natureLen, FieldIDLe n); | |
| 517 | de lete(Resul t,i + Temp lateFieldS ignatureLe n, FieldID Len); | |
| 518 | end; | |
| 519 | j := pos(Templ ateFieldEn dSignature , copy(Tem p, i + Tem plateField SignatureL en, MaxInt )); | |
| 520 | Fld := ''; | |
| 521 | if(j > 0) then | |
| 522 | begi n | |
| 523 | in c(j, i + T emplateFie ldSignatur eLen - 1); | |
| 524 | fl en := j - i - Templa teFieldSig natureLen; | |
| 525 | Fl d := copy( Temp,i + T emplateFie ldSignatur eLen, flen ); | |
| 526 | de lete(Temp, i,flen + T emplateFie ldSignatur eLen + 1); | |
| 527 | de lete(Resul t,i,flen + TemplateF ieldSignat ureLen + 1 ); | |
| 528 | end | |
| 529 | else | |
| 530 | begi n | |
| 531 | de lete(Temp, i,Template FieldSigna tureLen); | |
| 532 | de lete(Resul t,i,Templa teFieldSig natureLen) ; | |
| 533 | end; | |
| 534 | if(C trlID > 0) then | |
| 535 | begi n | |
| 536 | Fo undEntry : = FALSE; | |
| 537 | fo r j := 0 t o uEntries .Count-1 d o | |
| 538 | be gin | |
| 539 | Entry := T TemplateDi alogEntry( uEntries.O bjects[j]) ; | |
| 540 | if(assigne d(Entry)) then | |
| 541 | begin | |
| 542 | if Inclu deEmbedded then | |
| 543 | iField := Fld | |
| 544 | else | |
| 545 | iField := ''; | |
| 546 | TempCopy := copy(T emp, 1, i - 1); | |
| 547 | if POS(C RLF, TempC opy) > 0 t hen | |
| 548 | TempCo py := Copy (TempCopy, LastDelim iter(CRLF, TempCopy) + 1, i); | |
| 549 | ||
| 550 | NewTxt : = Entry.Ge tControlTe xt(CtrlID, FALSE, Fo undEntry, AutoWrap, iField, Te mpCopy, Au toWrapInde nt); | |
| 551 | TmplFld := GetTemp lateField( Fld, FALSE ); | |
| 552 | if (assi gned(TmplF ld)) and ( TmplFld.Da teType in DateComboT ypes) then {if this is a TORDa teBox} | |
| 553 | NewTx t := Piece (NewTxt,': ',1); {we o nly want t he first p iece of Ne wTxt} | |
| 554 | AddNewTx t; | |
| 555 | end; | |
| 556 | if FoundEn try then b reak; | |
| 557 | en d; | |
| 558 | if Hidden an d (not Fou ndEntry) a nd (Fld <> '') then | |
| 559 | be gin | |
| 560 | NewTxt := TemplateFi eldBeginSi gnature + Fld + Temp lateFieldE ndSignatur e; | |
| 561 | AddNewTxt; | |
| 562 | en d; | |
| 563 | end; | |
| 564 | end; | |
| 565 | until(i = 0); | |
| 566 | if not A utoWrap th en | |
| 567 | WordWr apText(Res ult); | |
| 568 | end; | |
| 569 | ||
| 570 | function A reTemplate FieldsRequ ired(const Text: str ing; FldVa lues: TORS tringList = nil): b oolean; | |
| 571 | var | |
| 572 | flen, Ct rlID, i, j : integer; | |
| 573 | Entry: T TemplateDi alogEntry; | |
| 574 | Fld: TTe mplateFiel d; | |
| 575 | Temp, Ne wTxt, FldN ame: strin g; | |
| 576 | FoundEnt ry: boolea n; | |
| 577 | ||
| 578 | begin | |
| 579 | if(not a ssigned(uE ntries)) t hen | |
| 580 | uEntri es := TStr ingList.Cr eate; | |
| 581 | Temp := Text; | |
| 582 | Result : = FALSE; | |
| 583 | repeat | |
| 584 | i := p os(Templat eFieldBegi nSignature , Temp); | |
| 585 | if(i > 0) then | |
| 586 | begin | |
| 587 | Ctrl ID := 0; | |
| 588 | if(c opy(Temp, i + Templa teFieldSig natureLen, 1) = Fiel dIDDelim) then | |
| 589 | begi n | |
| 590 | Ct rlID := St rToIntDef( copy(Temp, i + Templ ateFieldSi gnatureLen + 1, Fiel dIDLen-1), 0); | |
| 591 | de lete(Temp, i + Templa teFieldSig natureLen, FieldIDLe n); | |
| 592 | end; | |
| 593 | j := pos(Templ ateFieldEn dSignature , copy(Tem p, i + Tem plateField SignatureL en, MaxInt )); | |
| 594 | if(j > 0) then | |
| 595 | begi n | |
| 596 | in c(j, i + T emplateFie ldSignatur eLen - 1); | |
| 597 | fl en := j - i - Templa teFieldSig natureLen; | |
| 598 | Fl dName := c opy(Temp, i + Templa teFieldSig natureLen, flen); | |
| 599 | Fl d := GetTe mplateFiel d(FldName, FALSE); | |
| 600 | de lete(Temp, i,flen + T emplateFie ldSignatur eLen + 1); | |
| 601 | end | |
| 602 | else | |
| 603 | begi n | |
| 604 | de lete(Temp, i,Template FieldSigna tureLen); | |
| 605 | Fl d := nil; | |
| 606 | end; | |
| 607 | if(C trlID > 0) and (assi gned(Fld)) and (Fld. Required) then | |
| 608 | begi n | |
| 609 | Fo undEntry : = FALSE; | |
| 610 | fo r j := 0 t o uEntries .Count-1 d o | |
| 611 | be gin | |
| 612 | Entry := T TemplateDi alogEntry( uEntries.O bjects[j]) ; | |
| 613 | if(assigne d(Entry)) then | |
| 614 | begin | |
| 615 | NewTxt : = Entry.Ge tControlTe xt(CtrlID, TRUE, Fou ndEntry, F ALSE); | |
| 616 | if FoundEn try and (N ewTxt = '' ) then{(Tr im(NewTxt) = '') the n //CODE A DDED BACK IN - DN S BELLC} | |
| 617 | Result := TRUE; | |
| 618 | end; | |
| 619 | if FoundEn try then b reak; | |
| 620 | en d; | |
| 621 | if (not Foun dEntry) an d assigned (FldValues ) then | |
| 622 | be gin | |
| 623 | j := FldVa lues.Index OfPiece(In tToStr(Ctr lID)); | |
| 624 | if(j < 0) or (Piece( FldValues[ j],U,2) = '') then | |
| 625 | Result : = TRUE; | |
| 626 | en d; | |
| 627 | end; | |
| 628 | end; | |
| 629 | until((i = 0) or R esult); | |
| 630 | end; | |
| 631 | ||
| 632 | function H asTemplate Field(txt: string): boolean; | |
| 633 | begin | |
| 634 | Result : = (pos(Tem plateField BeginSigna ture, txt) > 0); | |
| 635 | end; | |
| 636 | ||
| 637 | function G etTemplate Field(ATem plateField : string; ByIEN: boo lean): TTe mplateFiel d; | |
| 638 | var | |
| 639 | i, idx: integer; | |
| 640 | aData: T StringList ; | |
| 641 | begin | |
| 642 | Result : = nil; | |
| 643 | if (not assigned(u TmplFlds)) then | |
| 644 | uTmplF lds := TLi st.Create; | |
| 645 | idx := - 1; | |
| 646 | for i := 0 to uTmp lFlds.Coun t - 1 do | |
| 647 | begin | |
| 648 | if ( ByIEN) the n | |
| 649 | be gin | |
| 650 | if (TTempl ateField(u TmplFlds[i ]).FID = A TemplateFi eld) then | |
| 651 | begin | |
| 652 | idx := i; | |
| 653 | break; | |
| 654 | end; | |
| 655 | en d | |
| 656 | else | |
| 657 | be gin | |
| 658 | if (TTempl ateField(u TmplFlds[i ]).FFldNam e = ATempl ateField) then | |
| 659 | begin | |
| 660 | idx := i; | |
| 661 | break; | |
| 662 | end; | |
| 663 | en d; | |
| 664 | end; | |
| 665 | if (idx < 0) then | |
| 666 | begin | |
| 667 | ADat a := TStri ngList.Cre ate; | |
| 668 | try | |
| 669 | if (ByIEN) t hen | |
| 670 | LoadTempla teFieldByI EN(ATempla teField, a Data) | |
| 671 | el se | |
| 672 | LoadTempla teField(AT emplateFie ld, AData) ; | |
| 673 | if (AData.Co unt > 1) t hen | |
| 674 | Result := TTemplateF ield.Creat e(AData); | |
| 675 | fina lly | |
| 676 | Fr eeAndNil(A Data); | |
| 677 | end; | |
| 678 | end | |
| 679 | else | |
| 680 | Result := TTempl ateField(u TmplFlds[i dx]); | |
| 681 | end; | |
| 682 | ||
| 683 | function T emplateFie ldNameProb lem(Fld: T TemplateFi eld): bool ean; | |
| 684 | const | |
| 685 | DUPFLD = 'Field Na me is not unique'; | |
| 686 | ||
| 687 | var | |
| 688 | i: integ er; | |
| 689 | msg: str ing; | |
| 690 | ||
| 691 | begin | |
| 692 | msg := ' '; | |
| 693 | if(Fld.F ldName = N ewTemplate Field) the n | |
| 694 | msg := 'Field Na me can not be ' + Ne wTemplateF ield | |
| 695 | else | |
| 696 | if(lengt h(Fld.FldN ame) < 3) then | |
| 697 | msg := 'Field Na me must be at least three char acters in length' | |
| 698 | else | |
| 699 | if(not C harInSet(F ld.FldName [1], ['A'. .'Z','0'.. '9'])) the n | |
| 700 | msg := 'First Fi eld Name c haracter m ust be "A" - "Z", or "0" - "9" ' | |
| 701 | else | |
| 702 | if(assig ned(uTmplF lds)) then | |
| 703 | begin | |
| 704 | for i := 0 to uT mplFlds.Co unt-1 do | |
| 705 | begin | |
| 706 | if(F ld <> uTmp lFlds[i]) and | |
| 707 | (C ompareText (TTemplate Field(uTmp lFlds[i]). FFldName, Fld.FFldNa me) = 0) t hen | |
| 708 | begi n | |
| 709 | ms g := DUPFL D; | |
| 710 | br eak; | |
| 711 | end; | |
| 712 | end; | |
| 713 | end; | |
| 714 | if(msg = '') and ( not IsTemp lateFieldN ameUnique( Fld.FFldNa me, Fld.ID )) then | |
| 715 | msg := DUPFLD; | |
| 716 | Result : = (msg <> ''); | |
| 717 | if(Resul t) then | |
| 718 | ShowMs g(msg); | |
| 719 | end; | |
| 720 | ||
| 721 | function S aveTemplat eFieldErro rs: string ; | |
| 722 | var | |
| 723 | i: integ er; | |
| 724 | Errors: TStringLis t; | |
| 725 | Fld: TTe mplateFiel d; | |
| 726 | msg: str ing; | |
| 727 | ||
| 728 | begin | |
| 729 | Result : = ''; | |
| 730 | if(assig ned(uTmplF lds)) then | |
| 731 | begin | |
| 732 | Errors := nil; | |
| 733 | try | |
| 734 | for i := 0 to uTmplFlds. Count-1 do | |
| 735 | begi n | |
| 736 | Fl d := TTemp lateField( uTmplFlds[ i]); | |
| 737 | if (Fld.FModi fied) then | |
| 738 | be gin | |
| 739 | msg := Fld .SaveError ; | |
| 740 | if(msg <> '') then | |
| 741 | begin | |
| 742 | if(not a ssigned(Er rors)) the n | |
| 743 | begin | |
| 744 | Errors := TStrin gList.Crea te; | |
| 745 | Errors .Add('The following template f ield save errors hav e occurred :'); | |
| 746 | Errors .Add(''); | |
| 747 | end; | |
| 748 | Errors.A dd(' ' + Fld.FldNam e + ': ' + msg); | |
| 749 | end; | |
| 750 | en d; | |
| 751 | end; | |
| 752 | finall y | |
| 753 | if(a ssigned(Er rors)) the n | |
| 754 | begi n | |
| 755 | Re sult := Er rors.Text; | |
| 756 | Er rors.Free; | |
| 757 | end; | |
| 758 | end; | |
| 759 | end; | |
| 760 | end; | |
| 761 | ||
| 762 | procedure ClearModif iedTemplat eFields; | |
| 763 | var | |
| 764 | i: integ er; | |
| 765 | Fld: TTe mplateFiel d; | |
| 766 | ||
| 767 | begin | |
| 768 | if(assig ned(uTmplF lds)) then | |
| 769 | begin | |
| 770 | for i := uTmplFl ds.Count-1 downto 0 do | |
| 771 | begin | |
| 772 | Fld := TTempla teField(uT mplFlds[i] ); | |
| 773 | if(a ssigned(Fl d)) and (F ld.FModifi ed) then | |
| 774 | begi n | |
| 775 | if Fld.FLock ed then | |
| 776 | UnlockTemp lateField( Fld.FID); | |
| 777 | Fl d.Free; | |
| 778 | end; | |
| 779 | end; | |
| 780 | end; | |
| 781 | end; | |
| 782 | ||
| 783 | function A nyTemplate FieldsModi fied: bool ean; | |
| 784 | var | |
| 785 | i: integ er; | |
| 786 | ||
| 787 | begin | |
| 788 | Result : = FALSE; | |
| 789 | if(assig ned(uTmplF lds)) then | |
| 790 | begin | |
| 791 | for i := 0 to uT mplFlds.Co unt-1 do | |
| 792 | begin | |
| 793 | if(T TemplateFi eld(uTmplF lds[i]).FM odified) t hen | |
| 794 | begi n | |
| 795 | Re sult := TR UE; | |
| 796 | br eak; | |
| 797 | end; | |
| 798 | end; | |
| 799 | end; | |
| 800 | end; | |
| 801 | ||
| 802 | procedure ListTempla teFields(c onst AText : string; AList: TSt rings; Lis tErrors: b oolean = F ALSE); | |
| 803 | var | |
| 804 | i, j, k, flen, Bad Count: int eger; | |
| 805 | flddesc, tmp, fld: string; | |
| 806 | TmpList: TStringLi st; | |
| 807 | Inactive List: TStr ingList; | |
| 808 | FldObj: TTemplateF ield; | |
| 809 | ||
| 810 | begin | |
| 811 | if(AText = '') the n exit; | |
| 812 | BadCount := 0; | |
| 813 | Inactive List := TS tringList. Create; | |
| 814 | try | |
| 815 | TmpLis t := TStri ngList.Cre ate; | |
| 816 | try | |
| 817 | TmpL ist.Text : = AText; | |
| 818 | for k := 0 to TmpList.Co unt-1 do | |
| 819 | begi n | |
| 820 | tm p := TmpLi st[k]; | |
| 821 | re peat | |
| 822 | i := pos(T emplateFie ldBeginSig nature, tm p); | |
| 823 | if(i > 0) then | |
| 824 | begin | |
| 825 | fld := ' '; | |
| 826 | j := pos (TemplateF ieldEndSig nature, co py(tmp, i + Template FieldSigna tureLen, M axInt)); | |
| 827 | if(j > 0 ) then | |
| 828 | begin | |
| 829 | inc(j, i + Templ ateFieldSi gnatureLen - 1); | |
| 830 | flen : = j - i - TemplateFi eldSignatu reLen; | |
| 831 | fld := copy(tmp, i + Templa teFieldSig natureLen, flen); | |
| 832 | delete (tmp, i, f len + Temp lateFieldS ignatureLe n + 1); | |
| 833 | end | |
| 834 | else | |
| 835 | begin | |
| 836 | delete (tmp,i,Tem plateField SignatureL en); | |
| 837 | inc(Ba dCount); | |
| 838 | end; | |
| 839 | if(fld < > '') then | |
| 840 | begin | |
| 841 | if Lis tErrors th en | |
| 842 | begin | |
| 843 | FldO bj := GetT emplateFie ld(fld, FA LSE); | |
| 844 | if a ssigned(Fl dObj) then | |
| 845 | begi n | |
| 846 | if FldObj.In active the n | |
| 847 | InactiveLi st.Add(' "' + fld + '"'); | |
| 848 | fl ddesc := ' '; | |
| 849 | end | |
| 850 | else | |
| 851 | fl ddesc := ' "' + fld + '"'; | |
| 852 | end | |
| 853 | else | |
| 854 | fldd esc := fld ; | |
| 855 | if(fld desc <> '' ) and (ALi st.IndexOf (flddesc) < 0) then | |
| 856 | ALis t.Add(fldd esc) | |
| 857 | end; | |
| 858 | end; | |
| 859 | un til (i = 0 ); | |
| 860 | end; | |
| 861 | finall y | |
| 862 | TmpL ist.Free; | |
| 863 | end; | |
| 864 | if Lis tErrors th en | |
| 865 | begin | |
| 866 | if(A List.Count > 0) then | |
| 867 | AL ist.Insert (0, 'The f ollowing t emplate fi elds were not found: '); | |
| 868 | if ( BadCount > 0) then | |
| 869 | begi n | |
| 870 | if (BadCount = 1) then | |
| 871 | tmp := 'A template f ield marke r "' + Tem plateField BeginSigna ture + | |
| 872 | '" was found without a' | |
| 873 | el se | |
| 874 | tmp := Int ToStr(BadC ount) + ' template f ield marke rs "' + Te mplateFiel dBeginSign ature + | |
| 875 | '" were found without'; | |
| 876 | if (AList.Cou nt > 0) th en | |
| 877 | AList.Add( ''); | |
| 878 | AL ist.Add(tm p + ' matc hing "' + TemplateFi eldEndSign ature + '" '); | |
| 879 | end; | |
| 880 | if(I nactiveLis t.Count > 0) then | |
| 881 | begi n | |
| 882 | if (AList.Cou nt > 0) th en | |
| 883 | AList.Add( ''); | |
| 884 | AL ist.Add('T he followi ng inactiv e template fields we re found:' ); | |
| 885 | Fa stAddStrin gs(Inactiv eList, ALi st); | |
| 886 | end; | |
| 887 | if(A List.Count > 0) then | |
| 888 | begi n | |
| 889 | AL ist.Insert (0, 'Text contains t emplate fi eld errors :'); | |
| 890 | AL ist.Insert (1, ''); | |
| 891 | end; | |
| 892 | end; | |
| 893 | finally | |
| 894 | Inacti veList.Fre e; | |
| 895 | end; | |
| 896 | end; | |
| 897 | ||
| 898 | function B oilerplate TemplateFi eldsOK(con st AText: string; Ms g: string = ''): boo lean; | |
| 899 | var | |
| 900 | Errors: TStringLis t; | |
| 901 | btns: TM sgDlgButto ns; | |
| 902 | ||
| 903 | begin | |
| 904 | Result : = TRUE; | |
| 905 | Errors : = TStringL ist.Create ; | |
| 906 | try | |
| 907 | ListTe mplateFiel ds(AText, Errors, TR UE); | |
| 908 | if(Err ors.Count > 0) then | |
| 909 | begin | |
| 910 | if(M sg = 'OK') then | |
| 911 | bt ns := [mbO K] | |
| 912 | else | |
| 913 | begi n | |
| 914 | bt ns := [mbA bort, mbIg nore]; | |
| 915 | Er rors.Add(' '); | |
| 916 | if (Msg = '') then | |
| 917 | Msg := 'te xt inserti on'; | |
| 918 | Er rors.Add(' Do you wan t to Abort ' + Msg + ', or Ign ore the er ror and co ntinue?'); | |
| 919 | end; | |
| 920 | Resu lt := (Mes sageDlg(Er rors.Text, mtError, btns, 0) = mrIgnore) ; | |
| 921 | end; | |
| 922 | finally | |
| 923 | Errors .Free; | |
| 924 | end; | |
| 925 | end; | |
| 926 | ||
| 927 | procedure EnsureText (edt: TEdi t; ud: TUp Down); | |
| 928 | var | |
| 929 | v: integ er; | |
| 930 | s: strin g; | |
| 931 | ||
| 932 | begin | |
| 933 | if assig ned(ud.Ass ociate) th en | |
| 934 | begin | |
| 935 | v := S trToIntDef (edt.Text, ud.Positi on); | |
| 936 | if (v < ud.Min) or (v > ud .Max) then | |
| 937 | v := ud.Positi on; | |
| 938 | s := I ntToStr(v) ; | |
| 939 | if edt .Text <> s then | |
| 940 | edt. Text := s; | |
| 941 | end; | |
| 942 | edt.SelS tart := ed t.GetTextL en; | |
| 943 | end; | |
| 944 | ||
| 945 | function T emplateFie ldCode2Fie ld(const C ode: strin g): TTempl ateFieldTy pe; | |
| 946 | var | |
| 947 | typ: TTe mplateFiel dType; | |
| 948 | ||
| 949 | begin | |
| 950 | Result : = dftUnkno wn; | |
| 951 | for typ := low(TTe mplateFiel dType) to high(TTemp lateFieldT ype) do | |
| 952 | if Cod e = Templa teFieldTyp eCodes[typ ] then | |
| 953 | begin | |
| 954 | Resu lt := typ; | |
| 955 | brea k; | |
| 956 | end; | |
| 957 | end; | |
| 958 | ||
| 959 | function T emplateDat eCode2Date Type(const Code: str ing): TTmp lFldDateTy pe; | |
| 960 | var | |
| 961 | typ: TTm plFldDateT ype; | |
| 962 | ||
| 963 | begin | |
| 964 | Result : = dtUnknow n; | |
| 965 | for typ := low(TTm plFldDateT ype) to hi gh(TTmplFl dDateType) do | |
| 966 | if Cod e = Templa teFieldDat eCodes[typ ] then | |
| 967 | begin | |
| 968 | Resu lt := typ; | |
| 969 | brea k; | |
| 970 | end; | |
| 971 | end; | |
| 972 | ||
| 973 | procedure ConvertCod es2Text(sl : TStrings ; Short: b oolean); | |
| 974 | var | |
| 975 | i: integ er; | |
| 976 | tmp, out put: strin g; | |
| 977 | ftype: T TemplateFi eldType; | |
| 978 | dtype: T TmplFldDat eType; | |
| 979 | ||
| 980 | begin | |
| 981 | for i := 0 to sl.C ount-1 do | |
| 982 | begin | |
| 983 | tmp := sl[i]; | |
| 984 | if pie ce(tmp,U,4 ) = BOOLCH AR[TRUE] t hen | |
| 985 | outp ut := '* ' | |
| 986 | else | |
| 987 | outp ut := ' ' ; | |
| 988 | ftype := Templat eFieldCode 2Field(Pie ce(tmp, U, 3)); | |
| 989 | if fty pe = dftDa te then | |
| 990 | begin | |
| 991 | dtyp e := Templ ateDateCod e2DateType (Piece(tmp , U, 5)); | |
| 992 | outp ut := outp ut + Templ ateDateTyp eDesc[dtyp e, short]; | |
| 993 | end | |
| 994 | else | |
| 995 | outp ut := outp ut + Templ ateFieldTy peDesc[fty pe, short] ; | |
| 996 | SetPie ce(tmp, U, 3, output ); | |
| 997 | sl[i] := tmp; | |
| 998 | end; | |
| 999 | end; | |
| 1000 | ||
| 1001 | { TTemplat eField } | |
| 1002 | ||
| 1003 | constructo r TTemplat eField.Cre ate(AData: TStrings) ; | |
| 1004 | var | |
| 1005 | tmp, p1: string; | |
| 1006 | AFID, i, idx,cnt: i nteger; | |
| 1007 | ||
| 1008 | begin | |
| 1009 | AFID := 0; | |
| 1010 | if(assig ned(AData) ) then | |
| 1011 | begin | |
| 1012 | if ADa ta.Count > 0 then | |
| 1013 | AFID := StrToI ntDef(ADat a[0],0); | |
| 1014 | if(AFI D > 0) and (AData.Co unt > 1) t hen | |
| 1015 | begin | |
| 1016 | FID := IntToSt r(AFID); | |
| 1017 | FFld Name := Pi ece(AData[ 1],U,1); | |
| 1018 | FFld Type := Te mplateFiel dCode2Fiel d(Piece(AD ata[1],U,2 )); | |
| 1019 | FIna ctive := ( Piece(ADat a[1],U,3) = '1'); | |
| 1020 | FMax Len := Str ToIntDef(P iece(AData [1],U,4),0 ); | |
| 1021 | FEdi tDefault : = Piece(AD ata[1],U,5 ); | |
| 1022 | FLMT ext := Pie ce(AData[1 ],U,6); | |
| 1023 | idx := StrToIn tDef(Piece (AData[1], U,7),0); | |
| 1024 | cnt := 0; | |
| 1025 | for i := 2 to AData.Coun t-1 do | |
| 1026 | begi n | |
| 1027 | tm p := AData [i]; | |
| 1028 | p1 := Piece( tmp,U,1); | |
| 1029 | tm p := Piece (tmp,U,2); | |
| 1030 | if (p1 = 'D') then | |
| 1031 | FNotes := FNotes + t mp + CRLF | |
| 1032 | el se | |
| 1033 | if (p1 = 'U') then | |
| 1034 | FURL := tm p | |
| 1035 | el se | |
| 1036 | if (p1 = 'I') then | |
| 1037 | be gin | |
| 1038 | inc(cnt); | |
| 1039 | FItems := FItems + t mp + CRLF; | |
| 1040 | if(cnt=idx ) then | |
| 1041 | FItemDef ault := tm p; | |
| 1042 | en d; | |
| 1043 | end; | |
| 1044 | FReq uired := (Piece(ADa ta[1],U,8) = '1'); | |
| 1045 | FSep Lines := (Piece(ADa ta[1],U,9) = '1'); | |
| 1046 | FTex tLen := StrToIntDe f(Piece(AD ata[1],U,1 0),0); | |
| 1047 | FInd ent := StrToIntDe f(Piece(AD ata[1],U,1 1),0); | |
| 1048 | FPad := StrToIntDe f(Piece(AD ata[1],U,1 2),0); | |
| 1049 | FMin Val := StrToIntDe f(Piece(AD ata[1],U,1 3),0); | |
| 1050 | FMax Val := StrToIntDe f(Piece(AD ata[1],U,1 4),0); | |
| 1051 | FInc rement := StrToIntDe f(Piece(AD ata[1],U,1 5),0); | |
| 1052 | FDat eType := TemplateDa teCode2Dat eType(Piec e(AData[1] ,U,16)); | |
| 1053 | FMod ified := FALSE; | |
| 1054 | FNam eChanged : = FALSE; | |
| 1055 | end; | |
| 1056 | end; | |
| 1057 | if(AFID = 0) then | |
| 1058 | begin | |
| 1059 | inc(uN ewTemplate FieldIDCnt ); | |
| 1060 | FID := IntToStr( -uNewTempl ateFieldID Cnt); | |
| 1061 | FFldNa me := NewT emplateFie ld; | |
| 1062 | FModif ied := TRU E; | |
| 1063 | end; | |
| 1064 | if(not a ssigned(uT mplFlds)) then | |
| 1065 | uTmplF lds := TLi st.Create; | |
| 1066 | uTmplFld s.Add(Self ); | |
| 1067 | end; | |
| 1068 | ||
| 1069 | function T TemplateFi eld.GetTem plateField Default: s tring; | |
| 1070 | begin | |
| 1071 | case F FldType of | |
| 1072 | dftE ditBox, df tNumber: Result := FEditDefau lt; | |
| 1073 | ||
| 1074 | dftC omboBox, | |
| 1075 | dftB utton, | |
| 1076 | dftC heckBoxes, {Clear out embedded fields} | |
| 1077 | dftR adioButton s: Result := StripEmbed ded(FItemD efault); | |
| 1078 | ||
| 1079 | dftD ate: if FEditDe fault <> ' ' then Res ult := FEd itDefault; | |
| 1080 | ||
| 1081 | dftH yperlink, dftText: if FEditDe fault <> ' ' then | |
| 1082 | Result := StripEm bedded(FEd itDefault) | |
| 1083 | else | |
| 1084 | Result := URL; | |
| 1085 | ||
| 1086 | dftW P: Result := Items; | |
| 1087 | end; | |
| 1088 | end; | |
| 1089 | ||
| 1090 | procedure TTemplateF ield.Creat eDialogCon trols(Entr y: TTempla teDialogEn try; | |
| 1091 | var Index: In teger; Ctr lID: integ er); | |
| 1092 | ||
| 1093 | var | |
| 1094 | i, Aht, w, tmp, AW dth: integ er; | |
| 1095 | STmp: st ring; | |
| 1096 | TmpSL: T StringList ; | |
| 1097 | edt: TEd it; | |
| 1098 | cbo: TOR ComboBox; | |
| 1099 | cb: TORC heckBox; | |
| 1100 | btn: Tfr aTemplateF ieldButton ; | |
| 1101 | dbox: TO RDateBox; | |
| 1102 | dcbo: TO RDateCombo ; | |
| 1103 | lbl: TCP RSTemplate FieldLabel ; | |
| 1104 | re: TRic hEdit; | |
| 1105 | pnl: TCP RSDialogNu mber; | |
| 1106 | DefDate: TFMDateTi me; | |
| 1107 | ctrl: TC ontrol; | |
| 1108 | ||
| 1109 | function wdth: int eger; | |
| 1110 | begin | |
| 1111 | if(Awd th < 0) th en | |
| 1112 | Awdt h := FontW idthPixel( Entry.FFon t.Handle); | |
| 1113 | Result := Awdth; | |
| 1114 | end; | |
| 1115 | ||
| 1116 | function ht: integ er; | |
| 1117 | begin | |
| 1118 | if(Aht < 0) then | |
| 1119 | Aht := FontHei ghtPixel(E ntry.FFont .Handle); | |
| 1120 | Result := Aht; | |
| 1121 | end; | |
| 1122 | ||
| 1123 | procedur e UpdateIn dents(ACon trol: TCon trol); | |
| 1124 | var | |
| 1125 | idx: i nteger; | |
| 1126 | ||
| 1127 | begin | |
| 1128 | if (FI ndent > 0) or (FPad > 0) then | |
| 1129 | begin | |
| 1130 | idx := Entry.F Indents.In dexOfObjec t(AControl ); | |
| 1131 | if i dx < 0 the n | |
| 1132 | En try.FInden ts.AddObje ct(IntToSt r(FIndent * wdth) + U + IntToS tr(FPad), AControl); | |
| 1133 | end; | |
| 1134 | end; | |
| 1135 | ||
| 1136 | begin | |
| 1137 | if(not F Inactive) and (FFldT ype <> dft Unknown) t hen | |
| 1138 | begin | |
| 1139 | AWdth := -1; | |
| 1140 | Aht := -1; | |
| 1141 | ctrl : = nil; | |
| 1142 | ||
| 1143 | case F FldType of | |
| 1144 | dftE ditBox: | |
| 1145 | be gin | |
| 1146 | edt := TCP RSDialogFi eldEdit.Cr eate(nil); | |
| 1147 | (edt as IC PRSDialogC omponent). RequiredFi eld := Req uired; | |
| 1148 | edt.Parent := Entry. FPanel; | |
| 1149 | edt.Border Style := b sNone; | |
| 1150 | edt.Height := ht; | |
| 1151 | edt.Width := (wdth * Width + 4 ); | |
| 1152 | if FTextLe n > 0 then | |
| 1153 | edt.MaxL ength := F TextLen | |
| 1154 | else | |
| 1155 | edt.MaxL ength := F MaxLen; | |
| 1156 | edt.Text : = FEditDef ault; | |
| 1157 | edt.Tag := CtrlID; | |
| 1158 | edt.OnChan ge := Entr y.DoChange ; | |
| 1159 | UpdateColo rsFor508Co mpliance(e dt, TRUE); | |
| 1160 | ctrl := ed t; | |
| 1161 | en d; | |
| 1162 | ||
| 1163 | dftC omboBox: | |
| 1164 | be gin | |
| 1165 | cbo := TCP RSDialogCo mboBox.Cre ate(nil); | |
| 1166 | (cbo as IC PRSDialogC omponent). RequiredFi eld := Req uired; | |
| 1167 | cbo.Parent := Entry. FPanel; | |
| 1168 | cbo.Templa teField := TRUE; | |
| 1169 | w := Width ; | |
| 1170 | cbo.MaxLen gth := w; | |
| 1171 | if FTextLe n > 0 then | |
| 1172 | cbo.MaxL ength := F TextLen | |
| 1173 | else | |
| 1174 | cbo.List ItemsOnly := TRUE; | |
| 1175 | {Clear out embedded fields} | |
| 1176 | cbo.Items. Text := St ripEmbedde d(Items); | |
| 1177 | cbo.Select ByID(Strip Embedded(F ItemDefaul t)); | |
| 1178 | cbo.Tag := CtrlID; | |
| 1179 | cbo.OnChan ge := Entr y.DoChange ; | |
| 1180 | ||
| 1181 | if cbo.Ite ms.Count > 12 then | |
| 1182 | begin | |
| 1183 | cbo.Widt h := (wdth * w) + Sc rollBarWid th + 8; | |
| 1184 | cbo.Drop DownCount := 12; | |
| 1185 | end | |
| 1186 | else | |
| 1187 | begin | |
| 1188 | cbo.Widt h := (wdth * w) + 18 ; | |
| 1189 | cbo.Drop DownCount := cbo.Ite ms.Count; | |
| 1190 | end; | |
| 1191 | UpdateColo rsFor508Co mpliance(c bo, TRUE); | |
| 1192 | ctrl := cb o; | |
| 1193 | en d; | |
| 1194 | ||
| 1195 | dftB utton: | |
| 1196 | be gin | |
| 1197 | btn := Tfr aTemplateF ieldButton .Create(ni l); | |
| 1198 | (btn as IC PRSDialogC omponent). RequiredFi eld := Req uired; | |
| 1199 | btn.Parent := Entry. FPanel; | |
| 1200 | {Clear out embedded fields} | |
| 1201 | btn.Items. Text := St ripEmbedde d(Items); | |
| 1202 | btn.Button Text := St ripEmbedde d(FItemDef ault); | |
| 1203 | btn.Height := ht; | |
| 1204 | btn.Width := (wdth * Width) + 6; | |
| 1205 | btn.Tag := CtrlID; | |
| 1206 | btn.OnChan ge := Entr y.DoChange ; | |
| 1207 | UpdateColo rsFor508Co mpliance(b tn); | |
| 1208 | ctrl := bt n; | |
| 1209 | en d; | |
| 1210 | ||
| 1211 | dftC heckBoxes, dftRadioB uttons: | |
| 1212 | be gin | |
| 1213 | if FFldTyp e = dftRad ioButtons then | |
| 1214 | inc(uRad ioGroupInd ex); | |
| 1215 | TmpSL := T StringList .Create; | |
| 1216 | try | |
| 1217 | {Clear o ut embedde d fields} | |
| 1218 | TmpSL.Te xt := Stri pEmbedded( Items); | |
| 1219 | for i := 0 to TmpS L.Count-1 do | |
| 1220 | begin | |
| 1221 | cb := TCPRSDialo gCheckBox. Create(nil ); | |
| 1222 | if i = 0 then | |
| 1223 | (cb as ICPRSDi alogCompon ent).Requi redField : = Required ; | |
| 1224 | cb.Par ent := Ent ry.FPanel; | |
| 1225 | cb.Cap tion := Tm pSL[i]; | |
| 1226 | cb.Aut oSize := T RUE; | |
| 1227 | cb.Aut oAdjustSiz e; | |
| 1228 | // cb .AutoSize := FALSE; | |
| 1229 | // cb .Height := ht; | |
| 1230 | if FFl dType = df tRadioButt ons then | |
| 1231 | begin | |
| 1232 | cb.G roupIndex := uRadioG roupIndex; | |
| 1233 | cb.R adioStyle := TRUE; | |
| 1234 | end; | |
| 1235 | if(Tmp SL[i] = St ripEmbedde d(FItemDef ault)) the n | |
| 1236 | cb.C hecked := TRUE; | |
| 1237 | cb.Tag := CtrlID ; | |
| 1238 | if FSe pLines and (FFldType in SepLin esTypes) t hen | |
| 1239 | cb.S tringData := NewLine ; | |
| 1240 | cb.OnC lick := En try.DoChan ge; | |
| 1241 | Update ColorsFor5 08Complian ce(cb); | |
| 1242 | inc(In dex); | |
| 1243 | Entry. FControls. InsertObje ct(Index, '', cb); | |
| 1244 | if (i= 0) or FSep Lines then | |
| 1245 | Upda teIndents( cb); | |
| 1246 | end; | |
| 1247 | finally | |
| 1248 | TmpSL.Fr ee; | |
| 1249 | end; | |
| 1250 | en d; | |
| 1251 | ||
| 1252 | dftD ate: | |
| 1253 | be gin | |
| 1254 | if FEditDe fault <> ' ' then | |
| 1255 | DefDate := StrToFM DateTime(F EditDefaul t) | |
| 1256 | else | |
| 1257 | DefDate := 0; | |
| 1258 | if FDateTy pe in Date ComboTypes then | |
| 1259 | begin | |
| 1260 | dcbo := TCPRSDialo gDateCombo .Create(ni l); | |
| 1261 | (dcbo as ICPRSDial ogComponen t).Require dField := Required; | |
| 1262 | dcbo.Par ent := Ent ry.FPanel; | |
| 1263 | dcbo.Tag := CtrlID ; | |
| 1264 | dcbo.Inc ludeBtn := (FDateTyp e = dtComb o); | |
| 1265 | dcbo.Inc ludeDay := (FDateTyp e = dtComb o); | |
| 1266 | dcbo.Inc ludeMonth := (FDateT ype <> dtY ear); | |
| 1267 | dcbo.FMD ate := Def Date; | |
| 1268 | dcbo.Tem plateField := TRUE; | |
| 1269 | dcbo.OnC hange := E ntry.DoCha nge; | |
| 1270 | UpdateCo lorsFor508 Compliance (dcbo, TRU E); | |
| 1271 | ctrl := dcbo; | |
| 1272 | end | |
| 1273 | else | |
| 1274 | begin | |
| 1275 | dbox := TCPRSDialo gDateBox.C reate(nil) ; | |
| 1276 | (dbox as ICPRSDial ogComponen t).Require dField := Required; | |
| 1277 | dbox.Par ent := Ent ry.FPanel; | |
| 1278 | dbox.Tag := CtrlID ; | |
| 1279 | dbox.Dat eOnly := ( FDateType = dtDate); | |
| 1280 | dbox.Req uireTime : = (FDateTy pe = dtDat eReqTime); | |
| 1281 | dbox.Tem plateField := TRUE; | |
| 1282 | dbox.FMD ateTime := DefDate; | |
| 1283 | if (FDat eType = dt Date) then | |
| 1284 | tmp := 11 | |
| 1285 | else | |
| 1286 | tmp := 17; | |
| 1287 | dbox.Wid th := (wdt h * tmp) + 18; | |
| 1288 | dbox.OnC hange := E ntry.DoCha nge; | |
| 1289 | UpdateCo lorsFor508 Compliance (dbox, TRU E); | |
| 1290 | ctrl := dbox; | |
| 1291 | end; | |
| 1292 | en d; | |
| 1293 | ||
| 1294 | dftN umber: | |
| 1295 | be gin | |
| 1296 | pnl := TCP RSDialogNu mber.Creat ePanel(nil ); | |
| 1297 | (pnl as IC PRSDialogC omponent). RequiredFi eld := Req uired; | |
| 1298 | pnl.Parent := Entry. FPanel; | |
| 1299 | pnl.BevelO uter := bv None; | |
| 1300 | pnl.Tag := CtrlID; | |
| 1301 | pnl.Edit.H eight := h t; | |
| 1302 | pnl.Edit.W idth := (w dth * 5 + 4); | |
| 1303 | pnl.UpDown .Min := Mi nVal; | |
| 1304 | pnl.UpDown .Max := Ma xVal; | |
| 1305 | pnl.UpDown .Min := Mi nVal; // B oth ud.Min settings are needee d! | |
| 1306 | i := Incre ment; | |
| 1307 | if i < 1 t hen i := 1 ; | |
| 1308 | pnl.UpDown .Increment := i; | |
| 1309 | pnl.UpDown .Position := StrToIn tDef(EditD efault, 0) ; | |
| 1310 | pnl.Edit.O nChange := Entry.UpD ownChange; | |
| 1311 | pnl.Height := pnl.Ed it.Height; | |
| 1312 | pnl.Width := pnl.Edi t.Width + pnl.UpDown .Width; | |
| 1313 | UpdateColo rsFor508Co mpliance(p nl, TRUE); | |
| 1314 | //CQ 17597 wat | |
| 1315 | pnl.Edit.A lign := al Left; | |
| 1316 | pnl.UpDown .Align := alLeft; | |
| 1317 | //end 1759 7 | |
| 1318 | ctrl := pn l; | |
| 1319 | en d; | |
| 1320 | ||
| 1321 | dftH yperlink, dftText: | |
| 1322 | be gin | |
| 1323 | if (FFldTy pe = dftHy perlink) a nd User.We bAccess th en | |
| 1324 | lbl := T CPRSDialog HyperlinkL abel.Creat e(nil) | |
| 1325 | else | |
| 1326 | lbl := T CPRSTempla teFieldLab el.Create( nil); | |
| 1327 | lbl.Parent := Entry. FPanel; | |
| 1328 | lbl.ShowAc celChar := FALSE; | |
| 1329 | lbl.Exclud e := FSepL ines; | |
| 1330 | if (FFldTy pe = dftHy perlink) t hen | |
| 1331 | begin | |
| 1332 | if FEdit Default <> '' then | |
| 1333 | lbl.Ca ption := S tripEmbedd ed(FEditDe fault) | |
| 1334 | else | |
| 1335 | lbl.Ca ption := U RL; | |
| 1336 | end | |
| 1337 | else | |
| 1338 | begin | |
| 1339 | STmp := StripEmbed ded(Items) ; | |
| 1340 | if copy( STmp,lengt h(STmp)-1, 2) = CRLF then | |
| 1341 | delete (STmp,leng th(STmp)-1 ,2); | |
| 1342 | lbl.Capt ion := STm p; | |
| 1343 | end; | |
| 1344 | if lbl is TCPRSDialo gHyperlink Label then | |
| 1345 | TCPRSDia logHyperli nkLabel(lb l).Init(FU RL); | |
| 1346 | lbl.Tag := CtrlID; | |
| 1347 | UpdateColo rsFor508Co mpliance(l bl); | |
| 1348 | ctrl := lb l; | |
| 1349 | en d; | |
| 1350 | ||
| 1351 | dftW P: | |
| 1352 | be gin | |
| 1353 | re := TCPR SDialogRic hEdit.Crea te(nil); | |
| 1354 | (re as ICP RSDialogCo mponent).R equiredFie ld := Requ ired; | |
| 1355 | re.Parent := Entry.F Panel; | |
| 1356 | re.Tag := CtrlID; | |
| 1357 | tmp := FMa xLen; | |
| 1358 | if tmp < 5 then | |
| 1359 | tmp := 5 ; | |
| 1360 | re.Width : = wdth * t mp; | |
| 1361 | tmp := FTe xtLen; | |
| 1362 | if tmp < 2 then | |
| 1363 | tmp := 2 | |
| 1364 | else | |
| 1365 | if tmp > M axTFWPLine s then | |
| 1366 | tmp := M axTFWPLine s; | |
| 1367 | re.Height := ht * tm p; | |
| 1368 | re.BorderS tyle := bs None; | |
| 1369 | re.ScrollB ars := ssV ertical; | |
| 1370 | re.Lines.T ext := Ite ms; | |
| 1371 | re.OnChang e := Entry .DoChange; | |
| 1372 | UpdateColo rsFor508Co mpliance(r e, TRUE); | |
| 1373 | ctrl := re ; | |
| 1374 | en d; | |
| 1375 | end; | |
| 1376 | if ass igned(ctrl ) then | |
| 1377 | begin | |
| 1378 | inc( Index); | |
| 1379 | Entr y.FControl s.InsertOb ject(Index , '', ctrl ); | |
| 1380 | Upda teIndents( ctrl); | |
| 1381 | end; | |
| 1382 | end; | |
| 1383 | end; | |
| 1384 | ||
| 1385 | function T TemplateFi eld.CanMod ify: boole an; | |
| 1386 | begin | |
| 1387 | if((not FModified) and (not FLocked) a nd (StrToI ntDef(FID, 0) > 0)) t hen | |
| 1388 | begin | |
| 1389 | FLocke d := LockT emplateFie ld(FID); | |
| 1390 | Result := FLocke d; | |
| 1391 | if(not FLocked) then | |
| 1392 | Show Msg('Templ ate Field ' + FFldNa me + ' is currently being edit ed by anot her user.' ); | |
| 1393 | end | |
| 1394 | else | |
| 1395 | Result := TRUE; | |
| 1396 | if(Resul t) then FM odified := TRUE; | |
| 1397 | end; | |
| 1398 | ||
| 1399 | procedure TTemplateF ield.SetEd itDefault( const Valu e: string) ; | |
| 1400 | begin | |
| 1401 | if(FEdit Default <> Value) an d CanModif y then | |
| 1402 | FEditD efault := Value; | |
| 1403 | end; | |
| 1404 | ||
| 1405 | procedure TTemplateF ield.SetFl dName(cons t Value: s tring); | |
| 1406 | begin | |
| 1407 | if(FFldN ame <> Val ue) and Ca nModify th en | |
| 1408 | begin | |
| 1409 | FFldNa me := Valu e; | |
| 1410 | FNameC hanged := TRUE; | |
| 1411 | end; | |
| 1412 | end; | |
| 1413 | ||
| 1414 | procedure TTemplateF ield.SetFl dType(cons t Value: T TemplateFi eldType); | |
| 1415 | begin | |
| 1416 | if(FFldT ype <> Val ue) and Ca nModify th en | |
| 1417 | begin | |
| 1418 | FFldTy pe := Valu e; | |
| 1419 | if(Val ue = dftEd itBox) the n | |
| 1420 | begin | |
| 1421 | if ( FMaxLen < 1) then | |
| 1422 | FM axLen := 1 ; | |
| 1423 | if F TextLen < FMaxLen th en | |
| 1424 | FT extLen := FMaxLen; | |
| 1425 | end | |
| 1426 | else | |
| 1427 | if(Val ue = dftHy perlink) a nd (FURL = '') then | |
| 1428 | FURL := 'http: //' | |
| 1429 | else | |
| 1430 | if(Val ue = dftCo mboBox) an d (FMaxLen < 1) then | |
| 1431 | begin | |
| 1432 | FMax Len := Wid th; | |
| 1433 | if F MaxLen < 1 then | |
| 1434 | FM axLen := 1 ; | |
| 1435 | end | |
| 1436 | else | |
| 1437 | if(Val ue = dftWP ) then | |
| 1438 | begin | |
| 1439 | if ( FMaxLen = 0) then | |
| 1440 | FM axLen := M AX_WRAP_WI DTH | |
| 1441 | else | |
| 1442 | if ( FMaxLen < 5) then | |
| 1443 | FMaxLen := 5; | |
| 1444 | if F TextLen < 2 then | |
| 1445 | FT extLen := 2; | |
| 1446 | end | |
| 1447 | else | |
| 1448 | if(Val ue = dftDa te) and (F DateType = dtUnknown ) then | |
| 1449 | FDat eType := d tDate; | |
| 1450 | end; | |
| 1451 | end; | |
| 1452 | ||
| 1453 | procedure TTemplateF ield.SetID (const Val ue: string ); | |
| 1454 | begin | |
| 1455 | // if(FID <> Value) and CanMo dify then | |
| 1456 | FID := Value; | |
| 1457 | end; | |
| 1458 | ||
| 1459 | procedure TTemplateF ield.SetIn active(con st Value: boolean); | |
| 1460 | begin | |
| 1461 | if(FInac tive <> Va lue) and C anModify t hen | |
| 1462 | FInact ive := Val ue; | |
| 1463 | end; | |
| 1464 | ||
| 1465 | procedure TTemplateF ield.SetIt emDefault( const Valu e: string) ; | |
| 1466 | begin | |
| 1467 | if(FItem Default <> Value) an d CanModif y then | |
| 1468 | FItemD efault := Value; | |
| 1469 | end; | |
| 1470 | ||
| 1471 | procedure TTemplateF ield.SetIt ems(const Value: str ing); | |
| 1472 | begin | |
| 1473 | if(FItem s <> Value ) and CanM odify then | |
| 1474 | FItems := Value; | |
| 1475 | end; | |
| 1476 | ||
| 1477 | procedure TTemplateF ield.SetLM Text(const Value: st ring); | |
| 1478 | begin | |
| 1479 | if(FLMTe xt <> Valu e) and Can Modify the n | |
| 1480 | FLMTex t := Value ; | |
| 1481 | end; | |
| 1482 | ||
| 1483 | procedure TTemplateF ield.SetMa xLen(const Value: in teger); | |
| 1484 | begin | |
| 1485 | if(FMaxL en <> Valu e) and Can Modify the n | |
| 1486 | FMaxLe n := Value ; | |
| 1487 | end; | |
| 1488 | ||
| 1489 | procedure TTemplateF ield.SetNo tes(const Value: str ing); | |
| 1490 | begin | |
| 1491 | if(FNote s <> Value ) and CanM odify then | |
| 1492 | FNotes := Value; | |
| 1493 | end; | |
| 1494 | ||
| 1495 | function T TemplateFi eld.SaveEr ror: strin g; | |
| 1496 | var | |
| 1497 | TmpSL, F ldSL: TStr ingList; | |
| 1498 | AID,Res: string; | |
| 1499 | idx, i: integer; | |
| 1500 | IEN64: I nt64; | |
| 1501 | NewRec: boolean; | |
| 1502 | ||
| 1503 | begin | |
| 1504 | if(FFldN ame = NewT emplateFie ld) then | |
| 1505 | begin | |
| 1506 | Result := 'Templ ate Field can not be named "' + NewTempl ateField + '"'; | |
| 1507 | exit; | |
| 1508 | end; | |
| 1509 | Result : = ''; | |
| 1510 | NewRec : = (StrToIn tDef(FID,0 ) < 0); | |
| 1511 | if(FModi fied or Ne wRec) then | |
| 1512 | begin | |
| 1513 | TmpSL := TString List.Creat e; | |
| 1514 | try | |
| 1515 | FldS L := TStri ngList.Cre ate; | |
| 1516 | try | |
| 1517 | if (StrToIntD ef(FID,0) > 0) then | |
| 1518 | AID := FID | |
| 1519 | el se | |
| 1520 | AID := '0' ; | |
| 1521 | Fl dSL.Add('. 01='+FFldN ame); | |
| 1522 | Fl dSL.Add('. 02='+Templ ateFieldTy peCodes[FF ldType]); | |
| 1523 | Fl dSL.Add('. 03='+BOOLC HAR[FInact ive]); | |
| 1524 | Fl dSL.Add('. 04='+IntTo Str(FMaxLe n)); | |
| 1525 | Fl dSL.Add('. 05='+FEdit Default); | |
| 1526 | Fl dSL.Add('. 06='+FLMTe xt); | |
| 1527 | id x := -1; | |
| 1528 | if (FItems <> '') and ( FItemDefau lt <> '') then | |
| 1529 | be gin | |
| 1530 | TmpSL.Text := FItems ; | |
| 1531 | for i := 0 to TmpSL. Count-1 do | |
| 1532 | if(FItem Default = TmpSL[i]) then | |
| 1533 | begin | |
| 1534 | idx := i; | |
| 1535 | break; | |
| 1536 | end; | |
| 1537 | en d; | |
| 1538 | Fl dSL.Add('. 07='+IntTo Str(Idx+1) ); | |
| 1539 | Fl dSL.Add('. 08='+BOOLC HAR[fRequi red]); | |
| 1540 | Fl dSL.Add('. 09='+BOOLC HAR[fSepLi nes]); | |
| 1541 | Fl dSL.Add('. 1=' +IntTo Str(FTextL en)); | |
| 1542 | Fl dSL.Add('. 11='+IntTo Str(FInden t)); | |
| 1543 | Fl dSL.Add('. 12='+IntTo Str(FPad)) ; | |
| 1544 | Fl dSL.Add('. 13='+IntTo Str(FMinVa l)); | |
| 1545 | Fl dSL.Add('. 14='+IntTo Str(FMaxVa l)); | |
| 1546 | Fl dSL.Add('. 15='+IntTo Str(FIncre ment)); | |
| 1547 | if FDateType = dtUnkno wn then | |
| 1548 | FldSL.Add( '.16=@') | |
| 1549 | el se | |
| 1550 | FldSL.Add( '.16='+Tem plateField DateCodes[ FDateType] ); | |
| 1551 | ||
| 1552 | if FURL='' t hen | |
| 1553 | FldSL.Add( '3=@') | |
| 1554 | el se | |
| 1555 | FldSL.Add( '3='+FURL) ; | |
| 1556 | ||
| 1557 | if (FNotes <> '') or (n ot NewRec) then | |
| 1558 | be gin | |
| 1559 | if(FNotes = '') then | |
| 1560 | FldSL.Ad d('2,1=@') | |
| 1561 | else | |
| 1562 | begin | |
| 1563 | TmpSL.Te xt := FNot es; | |
| 1564 | for i := 0 to TmpS L.Count-1 do | |
| 1565 | FldSL. Add('2,'+I ntToStr(i+ 1)+',0='+T mpSL[i]); | |
| 1566 | end; | |
| 1567 | en d; | |
| 1568 | if ((FItems < > '') or ( not NewRec )) then | |
| 1569 | be gin | |
| 1570 | if(FItems = '') then | |
| 1571 | FldSL.Ad d('10,1=@' ) | |
| 1572 | else | |
| 1573 | begin | |
| 1574 | TmpSL.Te xt := FIte ms; | |
| 1575 | for i := 0 to TmpS L.Count-1 do | |
| 1576 | FldSL. Add('10,'+ IntToStr(i +1)+',0='+ TmpSL[i]); | |
| 1577 | end; | |
| 1578 | en d; | |
| 1579 | ||
| 1580 | Re s := Updat eTemplateF ield(AID, FldSL); | |
| 1581 | IE N64 := Str ToInt64Def (Piece(Res ,U,1),0); | |
| 1582 | if (IEN64 > 0 ) then | |
| 1583 | be gin | |
| 1584 | if(NewRec) then | |
| 1585 | FID := I ntToStr(IE N64) | |
| 1586 | else | |
| 1587 | UnlockTe mplateFiel d(FID); | |
| 1588 | FModified := FALSE; | |
| 1589 | FNameChang ed := FALS E; | |
| 1590 | FLocked := FALSE; | |
| 1591 | en d | |
| 1592 | el se | |
| 1593 | Result := Piece(Res, U, 2); | |
| 1594 | fina lly | |
| 1595 | Fl dSL.Free; | |
| 1596 | end; | |
| 1597 | finall y | |
| 1598 | TmpS L.Free; | |
| 1599 | end; | |
| 1600 | end; | |
| 1601 | end; | |
| 1602 | ||
| 1603 | procedure TTemplateF ield.Assig n(AFld: TT emplateFie ld); | |
| 1604 | begin | |
| 1605 | FMaxLen := AFld.FMaxL en; | |
| 1606 | FFldName := AFld.FFldN ame; | |
| 1607 | FLMText := AFld.FLMTe xt; | |
| 1608 | FEditDef ault := AFld.FEdit Default; | |
| 1609 | FNotes := AFld.FNote s; | |
| 1610 | FItems := AFld.FItem s; | |
| 1611 | FInactiv e := AFld.FInac tive; | |
| 1612 | FItemDef ault := AFld.FItem Default; | |
| 1613 | FFldType := AFld.FFldT ype; | |
| 1614 | FRequire d := AFld.FRequ ired; | |
| 1615 | FSepLine s := AFld.FSepL ines; | |
| 1616 | FTextLen := AFld.FText Len; | |
| 1617 | FIndent := AFld.FInde nt; | |
| 1618 | FPad := AFld.FPad; | |
| 1619 | FMinVal := AFld.FMinV al; | |
| 1620 | FMaxVal := AFld.FMaxV al; | |
| 1621 | FIncreme nt := AFld.FIncr ement; | |
| 1622 | FDateTyp e := AFld.FDate Type; | |
| 1623 | FURL := AFld.FURL; | |
| 1624 | end; | |
| 1625 | ||
| 1626 | function T TemplateFi eld.Width: integer; | |
| 1627 | var | |
| 1628 | i, ilen: integer; | |
| 1629 | TmpSL: T StringList ; | |
| 1630 | ||
| 1631 | begin | |
| 1632 | if(FFldT ype = dftE ditBox) th en | |
| 1633 | Result := FMaxLe n | |
| 1634 | else | |
| 1635 | begin | |
| 1636 | if FMa xLen > 0 t hen | |
| 1637 | Resu lt := FMax Len | |
| 1638 | else | |
| 1639 | begin | |
| 1640 | Resu lt := -1; | |
| 1641 | TmpS L := TStri ngList.Cre ate; | |
| 1642 | try | |
| 1643 | Tm pSL.Text : = StripEmb edded(FIte ms); | |
| 1644 | fo r i := 0 t o TmpSL.Co unt-1 do | |
| 1645 | be gin | |
| 1646 | ilen := le ngth(TmpSL [i]); | |
| 1647 | if(Result < ilen) th en | |
| 1648 | Result : = ilen; | |
| 1649 | en d; | |
| 1650 | fina lly | |
| 1651 | Tm pSL.Free; | |
| 1652 | end; | |
| 1653 | end; | |
| 1654 | end; | |
| 1655 | if Resul t > MaxTFE dtLen then | |
| 1656 | Result := MaxTFE dtLen; | |
| 1657 | end; | |
| 1658 | ||
| 1659 | destructor TTemplate Field.Dest roy; | |
| 1660 | begin | |
| 1661 | uTmplFld s.Remove(S elf); | |
| 1662 | inherite d; | |
| 1663 | end; | |
| 1664 | ||
| 1665 | procedure TTemplateF ield.SetRe quired(con st Value: boolean); | |
| 1666 | begin | |
| 1667 | if(FRequ ired <> Va lue) and C anModify t hen | |
| 1668 | FRequi red := Val ue; | |
| 1669 | end; | |
| 1670 | ||
| 1671 | function T TemplateFi eld.NewFie ld: boolea n; | |
| 1672 | begin | |
| 1673 | Result : = (StrToIn tDef(FID,0 ) <= 0); | |
| 1674 | end; | |
| 1675 | ||
| 1676 | procedure TTemplateF ield.SetSe pLines(con st Value: boolean); | |
| 1677 | begin | |
| 1678 | if(FSepL ines <> Va lue) and C anModify t hen | |
| 1679 | FSepLi nes := Val ue | |
| 1680 | end; | |
| 1681 | ||
| 1682 | procedure TTemplateF ield.SetIn crement(co nst Value: integer); | |
| 1683 | begin | |
| 1684 | if(FIncr ement <> V alue) and CanModify then | |
| 1685 | FIncre ment := Va lue; | |
| 1686 | end; | |
| 1687 | ||
| 1688 | procedure TTemplateF ield.SetIn dent(const Value: in teger); | |
| 1689 | begin | |
| 1690 | if(FInde nt <> Valu e) and Can Modify the n | |
| 1691 | FInden t := Value ; | |
| 1692 | end; | |
| 1693 | ||
| 1694 | procedure TTemplateF ield.SetMa xVal(const Value: in teger); | |
| 1695 | begin | |
| 1696 | if(FMaxV al <> Valu e) and Can Modify the n | |
| 1697 | FMaxVa l := Value ; | |
| 1698 | end; | |
| 1699 | ||
| 1700 | procedure TTemplateF ield.SetMi nVal(const Value: in teger); | |
| 1701 | begin | |
| 1702 | if(FMinV al <> Valu e) and Can Modify the n | |
| 1703 | FMinVa l := Value ; | |
| 1704 | end; | |
| 1705 | ||
| 1706 | procedure TTemplateF ield.SetPa d(const Va lue: integ er); | |
| 1707 | begin | |
| 1708 | if(FPad <> Value) and CanMod ify then | |
| 1709 | FPad : = Value; | |
| 1710 | end; | |
| 1711 | ||
| 1712 | procedure TTemplateF ield.SetTe xtLen(cons t Value: i nteger); | |
| 1713 | begin | |
| 1714 | if(FText Len <> Val ue) and Ca nModify th en | |
| 1715 | FTextL en := Valu e; | |
| 1716 | end; | |
| 1717 | ||
| 1718 | procedure TTemplateF ield.SetUR L(const Va lue: strin g); | |
| 1719 | begin | |
| 1720 | if(FURL <> Value) and CanMod ify then | |
| 1721 | FURL : = Value; | |
| 1722 | end; | |
| 1723 | ||
| 1724 | function T TemplateFi eld.GetReq uired: boo lean; | |
| 1725 | begin | |
| 1726 | if FFldT ype in NoR equired th en | |
| 1727 | Result := FALSE | |
| 1728 | else | |
| 1729 | Result := FRequi red; | |
| 1730 | end; | |
| 1731 | ||
| 1732 | procedure TTemplateF ield.SetDa teType(con st Value: TTmplFldDa teType); | |
| 1733 | begin | |
| 1734 | if(FDate Type <> Va lue) and C anModify t hen | |
| 1735 | FDateT ype := Val ue; | |
| 1736 | end; | |
| 1737 | ||
| 1738 | { TTemplat eDialogEnt ry } | |
| 1739 | const | |
| 1740 | EOL_MARK ER = #182; | |
| 1741 | SR_BREAK = #186; | |
| 1742 | ||
| 1743 | procedure PanelDestr oy(AData: Pointer; S ender: TOb ject); | |
| 1744 | var | |
| 1745 | idx: int eger; | |
| 1746 | dlg: TTe mplateDial ogEntry; | |
| 1747 | ||
| 1748 | begin | |
| 1749 | dlg := T TemplateDi alogEntry( AData); | |
| 1750 | idx := u Entries.In dexOf(dlg. FID); | |
| 1751 | if(idx > = 0) then | |
| 1752 | uEntri es.Delete( idx); | |
| 1753 | dlg.FPan elDying := TRUE; | |
| 1754 | dlg.Free ; | |
| 1755 | end; | |
| 1756 | ||
| 1757 | constructo r TTemplat eDialogEnt ry.Create( AParent: T WinControl ; AID, Tex t: string) ; | |
| 1758 | var | |
| 1759 | CtrlID, idx, i, j, flen: int eger; | |
| 1760 | txt, Fld Name: stri ng; | |
| 1761 | Fld: TTe mplateFiel d; | |
| 1762 | ||
| 1763 | begin | |
| 1764 | FID := A ID; | |
| 1765 | FText := Text; | |
| 1766 | FControl s := TStri ngList.Cre ate; | |
| 1767 | FIndents := TStrin gList.Crea te; | |
| 1768 | FFont := TFont.Cre ate; | |
| 1769 | FFont.As sign(TOREx posedContr ol(AParent ).Font); | |
| 1770 | FControl s.Text := Text; | |
| 1771 | if(FCont rols.Count > 1) then | |
| 1772 | begin | |
| 1773 | for i := 1 to FC ontrols.Co unt-1 do | |
| 1774 | FCon trols[i] : = EOL_MARK ER + FCont rols[i]; | |
| 1775 | if not ScreenRea derSystemA ctive then | |
| 1776 | Stri pScreenRea derCodes(F Controls); | |
| 1777 | end; | |
| 1778 | FFirstBu ild := TRU E; | |
| 1779 | FPanel : = TDlgFiel dPanel.Cre ate(AParen t.Owner); | |
| 1780 | FPanel.P arent := A Parent; | |
| 1781 | FPanel.B evelOuter := bvNone; | |
| 1782 | FPanel.C aption := ''; | |
| 1783 | FPanel.F ont.Assign (FFont); | |
| 1784 | UpdateCo lorsFor508 Compliance (FPanel, T RUE); | |
| 1785 | idx := 0 ; | |
| 1786 | while (i dx < FCont rols.Count ) do | |
| 1787 | begin | |
| 1788 | txt := FControls [idx]; | |
| 1789 | i := p os(Templat eFieldBegi nSignature , txt); | |
| 1790 | if(i > 0) then | |
| 1791 | begin | |
| 1792 | if(c opy(txt, i + Templat eFieldSign atureLen, 1) = Field IDDelim) t hen | |
| 1793 | begi n | |
| 1794 | Ct rlID := St rToIntDef( copy(txt, i + Templa teFieldSig natureLen + 1, Field IDLen-1), 0); | |
| 1795 | de lete(txt,i + Templat eFieldSign atureLen, FieldIDLen ); | |
| 1796 | end | |
| 1797 | else | |
| 1798 | Ct rlID := 0; | |
| 1799 | j := pos(Templ ateFieldEn dSignature , copy(txt , i + Temp lateFieldS ignatureLe n, MaxInt) ); | |
| 1800 | if(j > 0) then | |
| 1801 | begi n | |
| 1802 | in c(j, i + T emplateFie ldSignatur eLen - 1); | |
| 1803 | fl en := j - i - Templa teFieldSig natureLen; | |
| 1804 | Fl dName := c opy(txt, i + Templat eFieldSign atureLen, flen); | |
| 1805 | Fl d := GetTe mplateFiel d(FldName, FALSE); | |
| 1806 | de lete(txt,i ,flen + Te mplateFiel dSignature Len + 1); | |
| 1807 | if (assigned( Fld)) then | |
| 1808 | be gin | |
| 1809 | FControls[ idx] := co py(txt,1,i -1); | |
| 1810 | if(Fld.Req uired) the n | |
| 1811 | begin | |
| 1812 | if Scree nReaderSys temActive then | |
| 1813 | begin | |
| 1814 | if Fld .FFldType in [dftChe ckBoxes, d ftRadioBut tons] then | |
| 1815 | FCon trols[idx] := FContr ols[idx] + ScreenRea derStopCod e; | |
| 1816 | end; | |
| 1817 | FControl s[idx] := FControls[ idx] + '*' ; | |
| 1818 | end; | |
| 1819 | Fld.Create DialogCont rols(Self, idx, Ctrl ID); | |
| 1820 | FControls. Insert(idx +1,copy(tx t,i,MaxInt )); | |
| 1821 | en d | |
| 1822 | el se | |
| 1823 | be gin | |
| 1824 | FControls[ idx] := tx t; | |
| 1825 | dec(idx); | |
| 1826 | en d; | |
| 1827 | end | |
| 1828 | else | |
| 1829 | begi n | |
| 1830 | de lete(txt,i ,TemplateF ieldSignat ureLen); | |
| 1831 | FC ontrols[id x] := txt; | |
| 1832 | de c(idx); | |
| 1833 | end; | |
| 1834 | end; | |
| 1835 | inc(id x); | |
| 1836 | end; | |
| 1837 | if Scree nReaderSys temActive then | |
| 1838 | begin | |
| 1839 | idx := 0; | |
| 1840 | while (idx < FCo ntrols.Cou nt) do | |
| 1841 | begin | |
| 1842 | txt := FContro ls[idx]; | |
| 1843 | i := pos(Scree nReaderSto pCode, txt ); | |
| 1844 | if i > 0 then | |
| 1845 | begi n | |
| 1846 | FC ontrols[id x] := copy (txt, 1, i -1); | |
| 1847 | tx t := copy( txt, i + S creenReade rStopCodeL en, MaxInt ); | |
| 1848 | FC ontrols.In sert(idx+1 , SR_BREAK + txt); | |
| 1849 | end; | |
| 1850 | inc( idx); | |
| 1851 | end; | |
| 1852 | end; | |
| 1853 | end; | |
| 1854 | ||
| 1855 | destructor TTemplate DialogEntr y.Destroy; | |
| 1856 | begin | |
| 1857 | if assig ned(FOnDes troy) then | |
| 1858 | FOnDes troy(Self) ; | |
| 1859 | KillLabe ls; | |
| 1860 | KillObj( @FControls , TRUE); | |
| 1861 | if FPane lDying the n | |
| 1862 | FPanel := nil | |
| 1863 | else | |
| 1864 | FreeAn dNil(FPane l); | |
| 1865 | FreeAndN il(FFont); | |
| 1866 | FreeAndN il(FIndent s); | |
| 1867 | inherite d; | |
| 1868 | end; | |
| 1869 | ||
| 1870 | procedure TTemplateD ialogEntry .DoChange( Sender: TO bject); | |
| 1871 | begin | |
| 1872 | if (not FUpdating) and assig ned(FOnCha nge) then | |
| 1873 | FOnCha nge(Self); | |
| 1874 | end; | |
| 1875 | ||
| 1876 | function T TemplateDi alogEntry. GetControl Text(CtrlI D: integer ; NoCommas : boolean; var Found Entry: boo lean; Auto Wrap: bool ean; emFie ld: string = ''; Crn tLnTxt: St ring = ''; AutoWrapI ndent: int eger = 0; NoFormat: boolean = false): st ring; | |
| 1877 | var | |
| 1878 | x, i, j, ind, idx: integer; | |
| 1879 | ctrl: TC ontrol; | |
| 1880 | Done: bo olean; | |
| 1881 | iString: string; | |
| 1882 | iField: TTemplateF ield; | |
| 1883 | iTemp: T StringList ; | |
| 1884 | TmpChar: integer; | |
| 1885 | TmpStrin g: String; | |
| 1886 | TmpEvt: TNotifyEve nt; | |
| 1887 | TmpSelSt art: Integ er; | |
| 1888 | ||
| 1889 | function GetOrigin alItem(ist r: string) : string; | |
| 1890 | begin | |
| 1891 | Result := ''; | |
| 1892 | if emF ield <> '' then | |
| 1893 | begin | |
| 1894 | iFie ld := GetT emplateFie ld(emField , false); | |
| 1895 | iTem p := nil; | |
| 1896 | if i Field <> n il then | |
| 1897 | tr y | |
| 1898 | iTemp := T StringList .Create; | |
| 1899 | iTemp.Text := StripE mbedded(iF ield.Items ); | |
| 1900 | x := iTemp .IndexOf(i str); | |
| 1901 | if x >= 0 then | |
| 1902 | begin | |
| 1903 | iTemp.Te xt := iFie ld.Items; | |
| 1904 | Result : = iTemp.St rings[x]; | |
| 1905 | end; | |
| 1906 | fi nally | |
| 1907 | iTemp.Free ; | |
| 1908 | en d; | |
| 1909 | end; | |
| 1910 | end; | |
| 1911 | ||
| 1912 | begin | |
| 1913 | Result : = ''; | |
| 1914 | Done := false; | |
| 1915 | ind := - 1; | |
| 1916 | TmpEvt : = nil; | |
| 1917 | for i := 0 to FCon trols.Coun t - 1 do | |
| 1918 | begin | |
| 1919 | ctrl : = TControl (FControls .Objects[i ]); | |
| 1920 | if (as signed(ctr l)) and (c trl.Tag = CtrlID) th en | |
| 1921 | begin | |
| 1922 | Foun dEntry := TRUE; | |
| 1923 | Done := TRUE; | |
| 1924 | if i nd < 0 the n | |
| 1925 | begi n | |
| 1926 | id x := FInde nts.IndexO fObject(ct rl); | |
| 1927 | if idx >= 0 then | |
| 1928 | ind := Str ToIntDef(P iece(FInde nts[idx], U, 2), 0) | |
| 1929 | el se | |
| 1930 | ind := 0; | |
| 1931 | end; | |
| 1932 | if ( ctrl is TC PRSTemplat eFieldLabe l) then | |
| 1933 | begi n | |
| 1934 | if not TCPRS TemplateFi eldLabel(c trl).Exclu de then | |
| 1935 | be gin | |
| 1936 | if emField <> '' the n | |
| 1937 | begin | |
| 1938 | iField : = GetTempl ateField(e mField, fa lse); | |
| 1939 | case iFi eld.FldTyp e of | |
| 1940 | dftHyp erlink: | |
| 1941 | if i Field.Edit Default <> '' then | |
| 1942 | Re sult := iF ield.EditD efault | |
| 1943 | else | |
| 1944 | Re sult := iF ield.URL; | |
| 1945 | dftTex t: | |
| 1946 | begi n | |
| 1947 | iS tring := i Field.Item s; | |
| 1948 | if copy(iStr ing, Lengt h(iString) - 1, 2) = CRLF then | |
| 1949 | Delete(iSt ring, Leng th(iString ) - 1, 2); | |
| 1950 | Re sult := iS tring; | |
| 1951 | end; | |
| 1952 | else { c ase } | |
| 1953 | Result := TCPRST emplateFie ldLabel(ct rl).Captio n | |
| 1954 | end; { c ase iField .FldType } | |
| 1955 | end { if e mField } | |
| 1956 | else | |
| 1957 | Result : = TCPRSTem plateField Label(ctrl ).Caption; | |
| 1958 | en d; | |
| 1959 | end | |
| 1960 | else | |
| 1961 | // !!!!!! CODE ADDED BACK IN - DN S BELLC !!!! !! | |
| 1962 | if (ctrl is TEdit) the n | |
| 1963 | Result := TEdit(ctrl ).Text | |
| 1964 | el se if (ctr l is TORCo mboBox) th en | |
| 1965 | be gin | |
| 1966 | Result := TORComboBo x(ctrl).Te xt; | |
| 1967 | iString := GetOrigin alItem(Res ult); | |
| 1968 | if iString <> '' the n | |
| 1969 | Result : = iString; | |
| 1970 | en d | |
| 1971 | el se if (ctr l is TORDa teCombo) t hen | |
| 1972 | Result := TORDateCom bo(ctrl).T ext + ':' + FloatToS tr(TORDate Combo(ctrl ).FMDate) | |
| 1973 | el se | |
| 1974 | { !!!!!! T HIS HAS BE EN REMOVED AS IT CAU SED PROBLE MS WITH RE MINDER DIA LOGS - DN S BELLC !!!! !! | |
| 1975 | if(Ctrl is TORDate Box) then begin | |
| 1976 | if TORDa teBox(Ctrl ).IsValid then | |
| 1977 | Result : = TORDateB ox(Ctrl).T ext | |
| 1978 | else | |
| 1979 | Result : = ''; | |
| 1980 | end else | |
| 1981 | } | |
| 1982 | // !!!!!! CODE ADDED BACK IN - DN S BELLC !!!! !! | |
| 1983 | if (ctrl i s TORDateB ox) then | |
| 1984 | Result : = TORDateB ox(ctrl).T ext | |
| 1985 | else if (c trl is TRi chEdit) th en | |
| 1986 | begin | |
| 1987 | // If we do not ne ed to form at this (R eminder va lues) or t here is no indent an d not auto wrap | |
| 1988 | if ((ind = 0) and (not AutoW rap)) or N oFormat th en | |
| 1989 | //Resu lt := TRic hEdit(ctrl ).Lines.Te xt | |
| 1990 | Result := TRichE dit(ctrl). Text | |
| 1991 | else | |
| 1992 | begin | |
| 1993 | { for j := 0 to TRichEdit( Ctrl).Line s.Count-1 do | |
| 1994 | begi n | |
| 1995 | if A utoWrap th en | |
| 1996 | begi n | |
| 1997 | if(R esult <> ' ') then | |
| 1998 | Resu lt := Resu lt + ' '; | |
| 1999 | Resu lt := Resu lt + TRich Edit(Ctrl) .Lines[j]; | |
| 2000 | end | |
| 2001 | else | |
| 2002 | begi n | |
| 2003 | if(R esult <> ' ') then | |
| 2004 | Resu lt := Resu lt + CRLF; | |
| 2005 | Resu lt := Resu lt + Strin gOfChar(' ', ind) + TRichEdit( Ctrl).Line s[j]; | |
| 2006 | end; | |
| 2007 | end; } | |
| 2008 | // If the object shares a line with text than take this into accou nt | |
| 2009 | If Len gth(CrntLn Txt) > 0 t hen | |
| 2010 | begin | |
| 2011 | // S ave the pr evious ver sion of th e text | |
| 2012 | TmpS tring := T RichEdit(c trl).Text; | |
| 2013 | // W e nee di d isable the onchange event temp orarily (R eminders) | |
| 2014 | TmpE vt := nil; | |
| 2015 | TmpE vt := TRic hEdit(ctrl ).OnChange ; | |
| 2016 | TRic hEdit(ctrl ).OnChange := nil; | |
| 2017 | TmpS elStart := TRichEdit (ctrl).Sel Start; | |
| 2018 | // A dd the hea der to our text but remove the indent le ngth | |
| 2019 | TRic hEdit(ctrl ).Text := CrntLnTxt + TRichEdi t(ctrl).Te xt; | |
| 2020 | TRic hEdit(ctrl ).Text := copy(TRich Edit(ctrl) .Text, ind + 1, Leng th(TRichEd it(ctrl).T ext)); | |
| 2021 | if T RichEdit(c trl).SelSt art <> Tmp SelStart t hen | |
| 2022 | TR ichEdit(ct rl).SelSta rt := TmpS elStart; | |
| 2023 | end; | |
| 2024 | // If we are add ing CTLF a nd we exce ed MAX_WRA P_WIDTH ch aracters | |
| 2025 | if (no t AutoWrap ) and ((in d + Length (TRichEdit (ctrl).Lin es[0])) > MAX_WRAP_W IDTH) then | |
| 2026 | begin | |
| 2027 | // I f we are s haring a l ine, do no t add lead ing indent | |
| 2028 | if L ength(Crnt LnTxt) > 0 then | |
| 2029 | Re sult := St ringReplac e(WrapText (StringRep lace(TRich Edit(ctrl) .Text, ''' ', '''''', [rfReplac eAll, rfIg noreCase]) , CRLF + S tringOfCha r(' ', ind ), [' '], (MAX_WRAP_ WIDTH - in d)), ''''' ', '''', [ rfReplaceA ll, rfIgno reCase]) | |
| 2030 | else | |
| 2031 | Re sult := St ringOfChar (' ', ind) + StringR eplace(Wra pText(Stri ngReplace( TRichEdit( ctrl).Text , '''', '' '''', [rfR eplaceAll, rfIgnoreC ase]), CRL F + String OfChar(' ' , ind), [' '], (MAX_ WRAP_WIDTH - ind)), '''''', '' '', [rfRep laceAll, r fIgnoreCas e]); | |
| 2032 | end | |
| 2033 | else | |
| 2034 | begin | |
| 2035 | // I f this is autowrap t hen wrap w ith END OF LINE ASCI I char | |
| 2036 | if A utoWrap th en | |
| 2037 | Re sult := St ringReplac e(WrapText (StringRep lace(TRich Edit(ctrl) .Text, ''' ', '''''', [rfReplac eAll, rfIg noreCase]) , #3 + Str ingOfChar( ' ', ind), [' '], (A utoWrapInd ent - ind) ), '''''', '''', [rf ReplaceAll , rfIgnore Case]) | |
| 2038 | else | |
| 2039 | begi n | |
| 2040 | // we can fi t our text within MA X_WRAP_WID TH. | |
| 2041 | fo r j := 0 t o TRichEdi t(ctrl).Li nes.Count - 1 do | |
| 2042 | be gin | |
| 2043 | if (Result <> '') th en | |
| 2044 | Result : = Result + CRLF + St ringOfChar (' ', ind) ; | |
| 2045 | if (Length (CrntLnTxt ) = 0) and (Result = '') then | |
| 2046 | Result : = StringOf Char(' ', ind) + TRi chEdit(ctr l).Lines[j ] | |
| 2047 | else | |
| 2048 | Result : = Result + TRichEdit (ctrl).Lin es[j]; | |
| 2049 | en d; | |
| 2050 | end; | |
| 2051 | end; | |
| 2052 | // If we are sha ring a lin e then we need to re move its t ext from t he | |
| 2053 | if Len gth(CrntLn Txt) > 0 t hen | |
| 2054 | begin | |
| 2055 | for TmpChar := 0 to ((Le ngth(CrntL nTxt) - in d) - 1) do | |
| 2056 | begi n | |
| 2057 | De lete(Resul t, 1, 1); | |
| 2058 | end; | |
| 2059 | // R eset text and change event | |
| 2060 | TmpS elStart := TRichEdit (ctrl).Sel Start; | |
| 2061 | TRic hEdit(ctrl ).Text := TmpString; | |
| 2062 | if T RichEdit(c trl).SelSt art <> Tmp SelStart t hen | |
| 2063 | TR ichEdit(ct rl).SelSta rt := TmpS elStart; | |
| 2064 | TRic hEdit(ctrl ).OnChange := TmpEvt ; | |
| 2065 | TmpE vt := nil; | |
| 2066 | end; | |
| 2067 | ind := 0; | |
| 2068 | end; | |
| 2069 | end | |
| 2070 | else | |
| 2071 | { !!!!!! T HIS HAS BE EN REMOVED AS IT CAU SED PROBLE MS WITH RE MINDER DIA LOGS - DN S BELLC !!!! !! | |
| 2072 | if(Ctr l is TEdit ) then | |
| 2073 | Result := TEdit( Ctrl).Text | |
| 2074 | else } | |
| 2075 | if (ctrl is TORChe ckBox) the n | |
| 2076 | begin | |
| 2077 | Done : = false; | |
| 2078 | if (TO RCheckBox( ctrl).Chec ked) then | |
| 2079 | begin | |
| 2080 | if ( Result <> '') then | |
| 2081 | begi n | |
| 2082 | if NoCommas then | |
| 2083 | Result := Result + ' |' | |
| 2084 | el se | |
| 2085 | Result := Result + ' , '; | |
| 2086 | end; | |
| 2087 | iStr ing := Get OriginalIt em(TORChec kBox(ctrl) .Caption); | |
| 2088 | if i String <> '' then | |
| 2089 | Re sult := Re sult + iSt ring | |
| 2090 | else | |
| 2091 | Re sult := Re sult + TOR CheckBox(c trl).Capti on; | |
| 2092 | end; | |
| 2093 | end | |
| 2094 | else if (ctrl is T fraTemplat eFieldButt on) then | |
| 2095 | begin | |
| 2096 | Result := TfraTe mplateFiel dButton(ct rl).Button Text; | |
| 2097 | iStrin g := GetOr iginalItem (Result); | |
| 2098 | if iSt ring <> '' then | |
| 2099 | Resu lt := iStr ing; | |
| 2100 | end | |
| 2101 | else if (ctrl is T Panel) the n | |
| 2102 | begin | |
| 2103 | for j := 0 to ct rl.Compone ntCount - 1 do | |
| 2104 | if c trl.Compon ents[j] is TUpDown t hen | |
| 2105 | begi n | |
| 2106 | Re sult := In tToStr(TUp Down(ctrl. Components [j]).Posit ion); | |
| 2107 | br eak; | |
| 2108 | end; | |
| 2109 | end; | |
| 2110 | end; | |
| 2111 | if Don e then | |
| 2112 | brea k; | |
| 2113 | end; | |
| 2114 | if (ind > 0) and ( not NoComm as) then | |
| 2115 | Result := String OfChar(' ' , ind) + R esult; | |
| 2116 | end; | |
| 2117 | ||
| 2118 | function T TemplateDi alogEntry. GetFieldVa lues: stri ng; | |
| 2119 | var | |
| 2120 | i: integ er; | |
| 2121 | Ctrl: TC ontrol; | |
| 2122 | CtrlID: integer; | |
| 2123 | TmpIDs: TList; | |
| 2124 | TmpSL: T StringList ; | |
| 2125 | Dummy: b oolean; | |
| 2126 | ||
| 2127 | begin | |
| 2128 | Result : = ''; | |
| 2129 | TmpIDs : = TList.Cr eate; | |
| 2130 | try | |
| 2131 | TmpSL := TString List.Creat e; | |
| 2132 | try | |
| 2133 | for i := 0 to FControls. Count-1 do | |
| 2134 | begi n | |
| 2135 | Ct rl := TCon trol(FCont rols.Objec ts[i]); | |
| 2136 | if (assigned( Ctrl)) the n | |
| 2137 | be gin | |
| 2138 | CtrlID := Ctrl.Tag; | |
| 2139 | if(TmpIDs. IndexOf(Po inter(Ctrl ID)) < 0) then | |
| 2140 | begin | |
| 2141 | TmpSL.Ad d(IntToStr (CtrlID) + U + Strin gReplace(G etControlT ext(CtrlID ,TRUE, Dum my, FALSE, '','',0,t rue), CRLF , '',[rfRe placeAll, rfIgnoreCa se])); | |
| 2142 | TmpIDs.A dd(Pointer (CtrlID)); | |
| 2143 | end; | |
| 2144 | en d; | |
| 2145 | end; | |
| 2146 | Resu lt := TmpS L.CommaTex t; | |
| 2147 | finall y | |
| 2148 | TmpS L.Free; | |
| 2149 | end; | |
| 2150 | finally | |
| 2151 | TmpIDs .Free; | |
| 2152 | end; | |
| 2153 | end; | |
| 2154 | ||
| 2155 | function T TemplateDi alogEntry. GetPanel(M axLen: int eger; APar ent: TWinC ontrol; | |
| 2156 | O wningCheck Box: TCPRS DialogPare ntCheckBox ): TDlgFie ldPanel; | |
| 2157 | var | |
| 2158 | i, x, y, cnt, idx, ind, yinc , ybase, M axX: integ er; | |
| 2159 | MaxTextL en: intege r; {Max n um of char s per line in pixels } | |
| 2160 | MaxChars : integer; {Max n um of char s per line } | |
| 2161 | txt: str ing; | |
| 2162 | ctrl: TC ontrol; | |
| 2163 | LastLine Blank: boo lean; | |
| 2164 | sLbl: TC PRSDialogS taticLabel ; | |
| 2165 | nLbl: TV A508Chaine dLabel; | |
| 2166 | sLblHeig ht: intege r; | |
| 2167 | TabOrdr: integer; | |
| 2168 | const | |
| 2169 | FOCUS_RE CT_MARGIN = 2; {The margin aro und the pa nel so the label won 't | |
| 2170 | overla y the focu s rect on its parent panel.} | |
| 2171 | ||
| 2172 | procedur e Add2TabO rder(ctrl: TWinContr ol); | |
| 2173 | begin | |
| 2174 | ctrl.T abOrder := TabOrdr; | |
| 2175 | inc(Ta bOrdr); | |
| 2176 | end; | |
| 2177 | ||
| 2178 | function StripSRCo de(var txt : string; code: stri ng; len: i nteger): i nteger; | |
| 2179 | begin | |
| 2180 | Result := pos(co de, txt); | |
| 2181 | if Res ult > 0 th en | |
| 2182 | begin | |
| 2183 | dele te(txt,Res ult,len); | |
| 2184 | dec( Result); | |
| 2185 | end | |
| 2186 | else | |
| 2187 | Resu lt := -1; | |
| 2188 | end; | |
| 2189 | ||
| 2190 | procedur e DoLabel( Atxt: stri ng); | |
| 2191 | var | |
| 2192 | ctrl: TControl; | |
| 2193 | tempLb l: TVA508C hainedLabe l; | |
| 2194 | ||
| 2195 | begin | |
| 2196 | if Scr eenReaderS ystemActiv e then | |
| 2197 | begin | |
| 2198 | if a ssigned(sL bl) then | |
| 2199 | begi n | |
| 2200 | te mpLbl := T VA508Chain edLabel.Cr eate(nil); | |
| 2201 | if assigned( nLbl) then | |
| 2202 | nLbl.NextL abel := te mpLbl | |
| 2203 | el se | |
| 2204 | sLbl.NextL abel := te mpLbl; | |
| 2205 | nL bl := temp Lbl; | |
| 2206 | ct rl := nLbl ; | |
| 2207 | end | |
| 2208 | else | |
| 2209 | begi n | |
| 2210 | sL bl := TCPR SDialogSta ticLabel.C reate(nil) ; | |
| 2211 | ct rl := sLbl ; | |
| 2212 | end; | |
| 2213 | end | |
| 2214 | else | |
| 2215 | ctrl := TLabel .Create(ni l); | |
| 2216 | SetOrd Prop(ctrl, ShowAccel CharProper ty, ord(FA LSE)); | |
| 2217 | SetStr Prop(ctrl, CaptionPr operty, At xt); | |
| 2218 | ctrl.P arent := F Panel; | |
| 2219 | ctrl.L eft := x; | |
| 2220 | ctrl.T op := y; | |
| 2221 | if ctr l = sLbl t hen | |
| 2222 | begin | |
| 2223 | Add2 TabOrder(s Lbl); | |
| 2224 | sLbl .Height := sLblHeigh t; | |
| 2225 | Scre enReaderSy stem_Curre ntLabel(sL bl); | |
| 2226 | end; | |
| 2227 | if Scr eenReaderS ystemActiv e then | |
| 2228 | Scre enReaderSy stem_AddTe xt(Atxt); | |
| 2229 | Update ColorsFor5 08Complian ce(ctrl); | |
| 2230 | inc(x, ctrl.Widt h); | |
| 2231 | end; | |
| 2232 | ||
| 2233 | procedur e Init; | |
| 2234 | var | |
| 2235 | lbl : TLabel; | |
| 2236 | begin | |
| 2237 | if(FFi rstBuild) then | |
| 2238 | FFir stBuild := FALSE | |
| 2239 | else | |
| 2240 | Kill Labels; | |
| 2241 | y := F OCUS_RECT_ MARGIN; {p lacement o f labels o n panel so they don' t cover th e} | |
| 2242 | x := F OCUS_RECT_ MARGIN; {f ocus recta ngle} | |
| 2243 | MaxX : = 0; | |
| 2244 | //ybas e := FontH eightPixel (FFont.Han dle) + 1 + (FOCUS_RE CT_MARGIN * 2); AGP commentou t line for | |
| 2245 | //rem inder spac ing | |
| 2246 | ybase := FontHei ghtPixel(F Font.Handl e) + 2; | |
| 2247 | yinc : = ybase; | |
| 2248 | LastLi neBlank := FALSE; | |
| 2249 | sLbl : = nil; | |
| 2250 | nLbl : = nil; | |
| 2251 | TabOrd r := 0; | |
| 2252 | if Scr eenReaderS ystemActiv e then | |
| 2253 | begin | |
| 2254 | Scre enReaderSy stem_Curre ntCheckBox (OwningChe ckBox); | |
| 2255 | lbl := TLabel. Create(nil ); | |
| 2256 | try | |
| 2257 | lb l.Parent : = FPanel; | |
| 2258 | sL blHeight : = lbl.Heig ht + 2; | |
| 2259 | fina lly | |
| 2260 | lb l.Free; | |
| 2261 | end; | |
| 2262 | ||
| 2263 | end; | |
| 2264 | end; | |
| 2265 | ||
| 2266 | procedur e Text508W ork; | |
| 2267 | var | |
| 2268 | Contin ueCode: bo olean; | |
| 2269 | begin | |
| 2270 | if Str ipCode(txt , SR_BREAK ) then | |
| 2271 | begin | |
| 2272 | Scre enReaderSy stem_Stop; | |
| 2273 | nLbl := nil; | |
| 2274 | sLbl := nil; | |
| 2275 | end; | |
| 2276 | ||
| 2277 | Contin ueCode := FALSE; | |
| 2278 | while StripSRCod e(txt, Scr eenReaderC ontinueCod e, ScreenR eaderConti nueCodeLen ) >= 0 do | |
| 2279 | Cont inueCode : = TRUE; | |
| 2280 | while StripSRCod e(txt, Scr eenReaderC ontinueCod eOld, Scre enReaderCo ntinueCode OldLen) >= 0 do | |
| 2281 | Cont inueCode : = TRUE; | |
| 2282 | if Con tinueCode then | |
| 2283 | Scre enReaderSy stem_Conti nue; | |
| 2284 | end; | |
| 2285 | ||
| 2286 | procedur e Ctrl508W ork(ctrl: TControl); | |
| 2287 | var | |
| 2288 | lbl: T CPRSTempla teFieldLab el; | |
| 2289 | begin | |
| 2290 | if (Ct rl is TCPR STemplateF ieldLabel) and (not (Ctrl is T CPRSDialog HyperlinkL abel)) the n | |
| 2291 | begin | |
| 2292 | lbl := Ctrl as TCPRSTemp lateFieldL abel; | |
| 2293 | if t rim(lbl.Ca ption) <> '' then | |
| 2294 | begi n | |
| 2295 | Sc reenReader System_Cur rentLabel( lbl); | |
| 2296 | Sc reenReader System_Add Text(lbl.C aption); | |
| 2297 | end | |
| 2298 | else | |
| 2299 | begi n | |
| 2300 | lb l.TabStop := FALSE; | |
| 2301 | Sc reenReader System_Sto p; | |
| 2302 | end; | |
| 2303 | Add2 TabOrder(T WinControl (ctrl)); | |
| 2304 | end | |
| 2305 | else | |
| 2306 | begin | |
| 2307 | if c trl is TWi nControl t hen | |
| 2308 | Ad d2TabOrder (TWinContr ol(ctrl)); | |
| 2309 | if S upports(ct rl, ICPRSD ialogCompo nent) then | |
| 2310 | Sc reenReader System_Cur rentCompon ent(ctrl a s ICPRSDia logCompone nt); | |
| 2311 | end; | |
| 2312 | sLbl : = nil; | |
| 2313 | nLbl : = nil; | |
| 2314 | end; | |
| 2315 | ||
| 2316 | procedur e NextLine ; | |
| 2317 | begin | |
| 2318 | if(Max X < x) the n | |
| 2319 | MaxX := x; | |
| 2320 | x := F OCUS_RECT_ MARGIN; { leave two pixels on the left f or the Foc us Rect} | |
| 2321 | inc(y, yinc); | |
| 2322 | yinc : = ybase; | |
| 2323 | end; | |
| 2324 | ||
| 2325 | begin | |
| 2326 | MaxTextL en := MaxL en - (FOCU S_RECT_MAR GIN * 2);{ save room for the fo cus rectan gle on the panel} | |
| 2327 | if(FFirs tBuild or (FPanel.Wi dth <> Max Len)) then | |
| 2328 | begin | |
| 2329 | Init; | |
| 2330 | for i := 0 to FC ontrols.Co unt-1 do | |
| 2331 | begin | |
| 2332 | txt := FContro ls[i]; | |
| 2333 | if S creenReade rSystemAct ive then | |
| 2334 | Te xt508Work; | |
| 2335 | if S tripCode(t xt,EOL_MAR KER) then | |
| 2336 | begi n | |
| 2337 | if ((x <> 0) or LastLin eBlank) th en | |
| 2338 | NextLine; | |
| 2339 | La stLineBlan k := (txt = ''); | |
| 2340 | end; | |
| 2341 | if(t xt <> '') then | |
| 2342 | begi n | |
| 2343 | wh ile(txt <> '') do | |
| 2344 | be gin | |
| 2345 | cnt := Num CharsFitIn Width(FFon t.Handle, txt, MaxTe xtLen-x); | |
| 2346 | MaxChars : = cnt; | |
| 2347 | if(cnt >= length(txt )) then | |
| 2348 | begin | |
| 2349 | DoLabel( txt); | |
| 2350 | txt := ' '; | |
| 2351 | end | |
| 2352 | else | |
| 2353 | if(cnt < 1 ) then | |
| 2354 | NextLine | |
| 2355 | else | |
| 2356 | begin | |
| 2357 | repeat | |
| 2358 | if(txt [cnt+1] = ' ') then | |
| 2359 | begin | |
| 2360 | DoLa bel(copy(t xt,1,cnt)) ; | |
| 2361 | Next Line; | |
| 2362 | txt := copy(tx t, cnt + 1 , MaxInt); | |
| 2363 | brea k; | |
| 2364 | end | |
| 2365 | else | |
| 2366 | dec( cnt); | |
| 2367 | until(cn t = 0); | |
| 2368 | if(cnt = 0) then | |
| 2369 | begin | |
| 2370 | if(x = FOCUS_REC T_MARGIN) then {If x is at the far left margin...} | |
| 2371 | begin | |
| 2372 | DoLa bel(Copy(t xt,1,MaxCh ars)); | |
| 2373 | Next Line; | |
| 2374 | txt := copy(tx t, MaxChar s + 1, Max Int); | |
| 2375 | end | |
| 2376 | else | |
| 2377 | Next Line; | |
| 2378 | end; | |
| 2379 | end; | |
| 2380 | en d; | |
| 2381 | end | |
| 2382 | else | |
| 2383 | begi n | |
| 2384 | ct rl := TCon trol(FCont rols.Objec ts[i]); | |
| 2385 | if (assigned( ctrl)) the n | |
| 2386 | be gin | |
| 2387 | if ScreenR eaderSyste mActive th en | |
| 2388 | Ctrl508W ork(ctrl); | |
| 2389 | idx := FIn dents.Inde xOfObject( Ctrl); | |
| 2390 | if idx >= 0 then | |
| 2391 | ind := S trToIntDef (Piece(FIn dents[idx] , U, 1), 0 ) | |
| 2392 | else | |
| 2393 | ind := 0 ; | |
| 2394 | if(x > 0) then | |
| 2395 | begin | |
| 2396 | if (x < MaxLen) an d (Ctrl is TORCheckB ox) and (T ORCheckBox (Ctrl).Str ingData = NewLine) t hen | |
| 2397 | x := M axLen; | |
| 2398 | if((ctrl .Width + x + ind) > MaxLen) th en | |
| 2399 | NextLi ne; | |
| 2400 | end; | |
| 2401 | inc(x,ind) ; | |
| 2402 | Ctrl.Left := x; | |
| 2403 | Ctrl.Top : = y; | |
| 2404 | inc(x, Ctr l.Width + 4); | |
| 2405 | if yinc <= Ctrl.Heig ht then | |
| 2406 | yinc := Ctrl.Heigh t + 2; | |
| 2407 | if (x < Ma xLen) and ((Ctrl is TRichEdit) or | |
| 2408 | ((Ctrl is TLabel) and (pos( CRLF, TLab el(Ctrl).C aption) > 0))) then | |
| 2409 | x := Max Len; | |
| 2410 | en d; | |
| 2411 | end; | |
| 2412 | end; | |
| 2413 | NextLi ne; | |
| 2414 | FPanel .Height := (y-1) + ( FOCUS_RECT _MARGIN * 2); //AGP added Focu s_rect_mar gin for Re minder spa cing | |
| 2415 | FPanel .Width := MaxX + FOC US_RECT_MA RGIN; | |
| 2416 | end; | |
| 2417 | if(FFiel dValues <> '') then | |
| 2418 | SetFie ldValues(F FieldValue s); | |
| 2419 | if Scree nReaderSys temActive then | |
| 2420 | Screen ReaderSyst em_Stop; | |
| 2421 | Result : = FPanel; | |
| 2422 | end; | |
| 2423 | ||
| 2424 | function T TemplateDi alogEntry. GetText: s tring; | |
| 2425 | begin | |
| 2426 | Result : = ResolveT emplateFie lds(FText, FALSE); | |
| 2427 | end; | |
| 2428 | ||
| 2429 | procedure TTemplateD ialogEntry .KillLabel s; | |
| 2430 | var | |
| 2431 | i, idx: integer; | |
| 2432 | obj: TOb ject; | |
| 2433 | max: int eger; | |
| 2434 | ||
| 2435 | begin | |
| 2436 | if(assig ned(FPanel )) then | |
| 2437 | begin | |
| 2438 | max := FPanel.Co ntrolCount -1; | |
| 2439 | for i := max dow nto 0 do | |
| 2440 | begin | |
| 2441 | // deletin g TVA508St aticText c an delete several TV A508Chaine dLabel com ponents | |
| 2442 | if i < FPanel. ControlCou nt then | |
| 2443 | begi n | |
| 2444 | ob j := FPane l.Controls [i]; | |
| 2445 | if (not (obj is TVA508 ChainedLab el)) and | |
| 2446 | ((obj is TLabel) or (obj is T VA508Stati cText)) th en | |
| 2447 | be gin | |
| 2448 | idx := FCo ntrols.Ind exOfObject (obj); | |
| 2449 | if idx < 0 then | |
| 2450 | obj.Free ; | |
| 2451 | en d; | |
| 2452 | end; | |
| 2453 | end; | |
| 2454 | end; | |
| 2455 | end; | |
| 2456 | ||
| 2457 | procedure TTemplateD ialogEntry .SetAutoDe stroyOnPan elFree( | |
| 2458 | const Va lue: boole an); | |
| 2459 | var | |
| 2460 | M: TMeth od; | |
| 2461 | ||
| 2462 | begin | |
| 2463 | FAutoDes troyOnPane lFree := V alue; | |
| 2464 | if(Value ) then | |
| 2465 | begin | |
| 2466 | M.Data := Self; | |
| 2467 | M.Code := @Panel Destroy; | |
| 2468 | FPanel .OnDestroy := TNotif yEvent(M); | |
| 2469 | end | |
| 2470 | else | |
| 2471 | FPanel .OnDestroy := nil; | |
| 2472 | end; | |
| 2473 | ||
| 2474 | procedure TTemplateD ialogEntry .SetContro lText(Ctrl ID: intege r; AText: string); | |
| 2475 | var | |
| 2476 | cnt, i, j: integer ; | |
| 2477 | Ctrl: TC ontrol; | |
| 2478 | Done: bo olean; | |
| 2479 | ||
| 2480 | begin | |
| 2481 | FUpdatin g := TRUE; | |
| 2482 | try | |
| 2483 | Done : = FALSE; | |
| 2484 | cnt := 0; | |
| 2485 | for i := 0 to FC ontrols.Co unt-1 do | |
| 2486 | begin | |
| 2487 | Ctrl := TContr ol(FContro ls.Objects [i]); | |
| 2488 | if(a ssigned(Ct rl)) and ( Ctrl.Tag = CtrlID) t hen | |
| 2489 | begi n | |
| 2490 | Do ne := TRUE ; | |
| 2491 | if (Ctrl is T Label) the n | |
| 2492 | TLabel(Ctr l).Caption := AText | |
| 2493 | el se | |
| 2494 | if (Ctrl is T Edit) then | |
| 2495 | TEdit(Ctrl ).Text := AText | |
| 2496 | el se | |
| 2497 | if (Ctrl is T ORComboBox ) then | |
| 2498 | TORComboBo x(Ctrl).Se lectByID(A Text) | |
| 2499 | el se | |
| 2500 | if (Ctrl is T RichEdit) then | |
| 2501 | TRichEdit( Ctrl).Line s.Text := AText | |
| 2502 | el se | |
| 2503 | if (Ctrl is T ORDateComb o) then | |
| 2504 | TORDateCom bo(Ctrl).F MDate := M akeFMDateT ime(piece( AText,':', 2)) | |
| 2505 | el se | |
| 2506 | if (Ctrl is T ORDateBox) then | |
| 2507 | TORDateBox (Ctrl).Tex t := AText | |
| 2508 | el se | |
| 2509 | if (Ctrl is T ORCheckBox ) then | |
| 2510 | be gin | |
| 2511 | Done := FA LSE; | |
| 2512 | TORCheckBo x(Ctrl).Ch ecked := F ALSE; //<-PSI -06-170-AD DED THIS L INE - v27. 23 - RV | |
| 2513 | if(cnt = 0 ) then | |
| 2514 | cnt := D elimCount( AText, '|' ) + 1; | |
| 2515 | for j := 1 to cnt do | |
| 2516 | begin | |
| 2517 | if(TORCh eckBox(Ctr l).Caption = piece(A Text,'|',j )) then | |
| 2518 | TORChe ckBox(Ctrl ).Checked := TRUE; | |
| 2519 | end; | |
| 2520 | en d | |
| 2521 | el se | |
| 2522 | if (Ctrl is T fraTemplat eFieldButt on) then | |
| 2523 | TfraTempla teFieldBut ton(Ctrl). ButtonText := AText | |
| 2524 | el se | |
| 2525 | if (Ctrl is T Panel) the n | |
| 2526 | be gin | |
| 2527 | for j := 0 to Ctrl.C omponentCo unt-1 do | |
| 2528 | if Ctrl. Components [j] is TUp Down then | |
| 2529 | begin | |
| 2530 | TUpDow n(Ctrl.Com ponents[j] ).Position := StrToI ntDef(ATex t,0); | |
| 2531 | break; | |
| 2532 | end; | |
| 2533 | en d; | |
| 2534 | end; | |
| 2535 | if D one then b reak; | |
| 2536 | end; | |
| 2537 | finally | |
| 2538 | FUpdat ing := FAL SE; | |
| 2539 | end; | |
| 2540 | end; | |
| 2541 | ||
| 2542 | procedure TTemplateD ialogEntry .SetFieldV alues(cons t Value: s tring); | |
| 2543 | var | |
| 2544 | i: integ er; | |
| 2545 | TmpSL: T StringList ; | |
| 2546 | ||
| 2547 | begin | |
| 2548 | FFieldVa lues := Va lue; | |
| 2549 | TmpSL := TStringLi st.Create; | |
| 2550 | try | |
| 2551 | TmpSL. CommaText := Value; | |
| 2552 | for i := 0 to Tm pSL.Count- 1 do | |
| 2553 | SetC ontrolText (StrToIntD ef(Piece(T mpSL[i], U , 1), 0), Piece(TmpS L[i], U, 2 )); | |
| 2554 | finally | |
| 2555 | TmpSL. Free; | |
| 2556 | end; | |
| 2557 | end; | |
| 2558 | ||
| 2559 | function T TemplateDi alogEntry. StripCode( var txt: s tring; cod e: char): boolean; | |
| 2560 | var | |
| 2561 | p: integ er; | |
| 2562 | begin | |
| 2563 | p := pos (code, txt ); | |
| 2564 | Result : = (p > 0); | |
| 2565 | if Resul t then | |
| 2566 | begin | |
| 2567 | while p > 0 do | |
| 2568 | begin | |
| 2569 | dele te(txt, p, 1); | |
| 2570 | p := pos(code, txt); | |
| 2571 | end; | |
| 2572 | end; | |
| 2573 | end; | |
| 2574 | ||
| 2575 | procedure TTemplateD ialogEntry .UpDownCha nge(Sender : TObject) ; | |
| 2576 | begin | |
| 2577 | EnsureTe xt(TEdit(S ender), TU pDown(TEdi t(Sender). Tag)); | |
| 2578 | DoChange (Sender); | |
| 2579 | end; | |
| 2580 | ||
| 2581 | function S tripEmbedd ed(iItems: string): string; | |
| 2582 | {7/26/01 S Monson | |
| 2583 | Returns the field will all e mbedded fi elds remov ed} | |
| 2584 | var | |
| 2585 | p1, p2, icur: inte ger; | |
| 2586 | Begin | |
| 2587 | p1 := po s(Template FieldBegin Signature, iItems); | |
| 2588 | icur := 0; | |
| 2589 | while p1 > 0 do | |
| 2590 | begin | |
| 2591 | p2 : = pos(Temp lateFieldE ndSignatur e,copy(iIt ems,icur+p 1+Template FieldSigna tureLen,ma xint)); | |
| 2592 | if p2 > 0 the n | |
| 2593 | be gin | |
| 2594 | delete(iIt ems,p1+icu r,Template FieldSigna tureLen+p2 +TemplateF ieldSignat ureEndLen- 1); | |
| 2595 | icur := ic ur + p1 - 1; | |
| 2596 | p1 := pos( TemplateFi eldBeginSi gnature,co py(iItems, icur+1,max int)); | |
| 2597 | en d | |
| 2598 | else | |
| 2599 | p1 := 0; | |
| 2600 | end; | |
| 2601 | Result : = iItems; | |
| 2602 | end; | |
| 2603 | ||
| 2604 | procedure StripScree nReaderCod es(var Tex t: string) ; | |
| 2605 | var | |
| 2606 | p, j: in teger; | |
| 2607 | begin | |
| 2608 | for j := low(Scree nReaderCod es) to hig h(ScreenRe aderCodes) do | |
| 2609 | begin | |
| 2610 | p := 1 ; | |
| 2611 | while (p > 0) do | |
| 2612 | begin | |
| 2613 | p := posex(Scr eenReaderC odes[j], T ext, p); | |
| 2614 | if p > 0 then | |
| 2615 | de lete(Text, p, Screen ReaderCode Lens[j]); | |
| 2616 | end; | |
| 2617 | end; | |
| 2618 | end; | |
| 2619 | ||
| 2620 | procedure StripScree nReaderCod es(SL: TSt rings); | |
| 2621 | var | |
| 2622 | temp: st ring; | |
| 2623 | i: integ er; | |
| 2624 | ||
| 2625 | begin | |
| 2626 | for i := 0 to SL.C ount - 1 d o | |
| 2627 | begin | |
| 2628 | temp : = SL[i]; | |
| 2629 | StripS creenReade rCodes(tem p); | |
| 2630 | SL[i] := temp; | |
| 2631 | end; | |
| 2632 | end; | |
| 2633 | ||
| 2634 | function H asScreenRe aderBreakC odes(SL: T Strings): boolean; | |
| 2635 | var | |
| 2636 | i: integ er; | |
| 2637 | ||
| 2638 | begin | |
| 2639 | Result : = TRUE; | |
| 2640 | for i := 0 to SL.C ount - 1 d o | |
| 2641 | begin | |
| 2642 | if pos (ScreenRea derCodeSig nature, SL [i]) > 0 t hen | |
| 2643 | exit ; | |
| 2644 | end; | |
| 2645 | Result : = FALSE; | |
| 2646 | end; | |
| 2647 | ||
| 2648 | initializa tion | |
| 2649 | ||
| 2650 | finalizati on | |
| 2651 | KillObj( @uTmplFlds , TRUE); | |
| 2652 | KillObj( @uEntries, TRUE); | |
| 2653 | ||
| 2654 | end. |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.