Function

DoTemplateDialog

Module

fTemplateDialog

Last Modified

7/15/2014 3:26:44 PM

Comments

Returns True if Cancel button is pressed
Returns True if Cancel button is pressed

Scope

Interfaced

Declaration

function DoTemplateDialog(SL: TStrings; const CaptionText: string; PreviewMode: boolean = FALSE): boolean;

Calls Hierarchy


DoTemplateDialog
 ├SetTemplateDialogCanceled
 ├TfrmBase508Form.Create
 │ ├TfrmBase508Form.UpdateAccessibilityActions
 │ ├UnfocusableControlEnter
 │ └AdjustControls
 │   ├TfrmBase508Form.ModifyUnfocusableControl
 │   └..(rec)..
 ├AssignFieldIDs
 │ └AssignFieldIDs
 │   └GetNewFieldID
 ├CountDlgProps
 │ └IncDlgID
 ├TfrmTemplateDialog.BuildAllControls
 │ └TfrmTemplateDialog.BuildCB
 │   ├TfrmTemplateDialog.FindObjectByID
 │   │ └TfrmTemplateDialog.GetObjectID
 │   ├GetDialogEntry
 │   │ └TTemplateDialogEntry.Create
 │   │   ├TDlgFieldPanel.Create
 │   │   ├GetTemplateField
 │   │   │ ├LoadTemplateFieldByIEN
 │   │   │ ├LoadTemplateField
 │   │   │ └TTemplateField.Create
 │   │   │   ├TemplateFieldCode2Field
 │   │   │   └TemplateDateCode2DateType
 │   │   ├TTemplateField.GetRequired
 │   │   └TTemplateField.CreateDialogControls
 │   │     ├TCPRSDialogFieldEdit.Create
 │   │     │ └TCPRSDialogComponent.Create
 │   │     ├TTemplateField.GetRequired
 │   │     ├ht
 │   │     ├wdth
 │   │     ├TTemplateField.Width
 │   │     │ └StripEmbedded
 │   │     ├TTemplateDialogEntry.DoChange
 │   │     ├TCPRSDialogComboBox.Create
 │   │     │ └TCPRSDialogComponent.Create
 │   │     ├StripEmbedded
 │   │     ├TfraTemplateFieldButton.Create
 │   │     │ ├TfraTemplateFieldButton.ButtonKeyDown
 │   │     │ │ └TfraTemplateFieldButton.pnlBtnMouseDown
 │   │     │ │   ├TfraTemplateFieldButton.GetButtonText
 │   │     │ │   └TfraTemplateFieldButton.SetButtonText
 │   │     │ ├TfraTemplateFieldButton.ButtonKeyUp
 │   │     │ │ └TfraTemplateFieldButton.pnlBtnMouseUp
 │   │     │ └TCPRSDialogComponent.Create
 │   │     ├TfraTemplateFieldButton.SetButtonText
 │   │     ├TCPRSDialogCheckBox.Create
 │   │     │ └TCPRSDialogComponent.Create
 │   │     ├UpdateIndents
 │   │     │ └wdth
 │   │     ├StrToFMDateTime
 │   │     ├TCPRSDialogDateCombo.Create
 │   │     │ └TCPRSDialogComponent.Create
 │   │     ├TCPRSDialogDateBox.Create
 │   │     │ └TCPRSDialogComponent.Create
 │   │     ├TCPRSDialogNumber.CreatePanel
 │   │     │ └TCPRSDialogComponent.Create
 │   │     ├TTemplateDialogEntry.UpDownChange
 │   │     │ ├EnsureText
 │   │     │ └TTemplateDialogEntry.DoChange
 │   │     ├TCPRSDialogHyperlinkLabel.Create
 │   │     │ ├TCPRSDialogComponent.Create
 │   │     │ └TCPRSDialogHyperlinkLabel.KeyPressed
 │   │     │   └TCPRSDialogHyperlinkLabel.Clicked
 │   │     │     └GotoWebPage
 │   │     ├TCPRSDialogHyperlinkLabel.Init
 │   │     │ └TCPRSDialogHyperlinkLabel.Clicked...
 │   │     └TCPRSDialogRichEdit.Create
 │   │       └TCPRSDialogComponent.Create
 │   ├TTemplateDialogEntry.SetAutoDestroyOnPanelFree
 │   │ └PanelDestroy
 │   ├TfrmTemplateDialog.EntryDestroyed
 │   ├TTemplateDialogEntry.GetPanel
 │   │ ├Init
 │   │ │ ├TTemplateDialogEntry.KillLabels
 │   │ │ └ScreenReaderSystem_CurrentCheckBox
 │   │ │   └ScreenReaderSystem_Stop
 │   │ │     ├UpdateCheckBox
 │   │ │     ├UpdatePending
 │   │ │     └ScreenReaderSystem_Clear
 │   │ ├Text508Work
 │   │ │ ├TTemplateDialogEntry.StripCode
 │   │ │ ├ScreenReaderSystem_Stop...
 │   │ │ ├StripSRCode
 │   │ │ └ScreenReaderSystem_Continue
 │   │ ├TTemplateDialogEntry.StripCode
 │   │ ├NextLine
 │   │ ├DoLabel
 │   │ │ ├Add2TabOrder
 │   │ │ ├ScreenReaderSystem_CurrentLabel
 │   │ │ │ └ScreenReaderSystem_Stop...
 │   │ │ └ScreenReaderSystem_AddText
 │   │ ├Ctrl508Work
 │   │ │ ├ScreenReaderSystem_CurrentLabel...
 │   │ │ ├ScreenReaderSystem_AddText
 │   │ │ ├ScreenReaderSystem_Stop...
 │   │ │ ├Add2TabOrder
 │   │ │ └ScreenReaderSystem_CurrentComponent
 │   │ │   ├UpdateCheckBox
 │   │ │   ├UpdatePending
 │   │ │   └ScreenReaderSystem_Stop...
 │   │ ├TTemplateDialogEntry.SetFieldValues
 │   │ │ └TTemplateDialogEntry.SetControlText
 │   │ │   └TfraTemplateFieldButton.SetButtonText
 │   │ └ScreenReaderSystem_Stop...
 │   ├TTemplateDialogEntry.GetText
 │   │ └ResolveTemplateFields
 │   │   ├TTemplateDialogEntry.GetControlText
 │   │   │ ├GetTemplateField...
 │   │   │ ├GetOriginalItem
 │   │   │ │ ├GetTemplateField...
 │   │   │ │ └StripEmbedded
 │   │   │ └TfraTemplateFieldButton.GetButtonText
 │   │   ├GetTemplateField...
 │   │   ├AddNewTxt
 │   │   └WordWrapText
 │   │     └WrappedText
 │   ├TfrmTemplateDialog.FieldChanged
 │   │ └TTemplateDialogEntry.GetText...
 │   ├TfrmTemplateDialog.ParentCBEnter
 │   ├TfrmTemplateDialog.ParentCBExit
 │   ├TfrmTemplateDialog.ItemChecked
 │   └NextTabCtrl
 ├GetText
 │ └ResolveTemplateFields...
 ├TimedOut
 └CheckBoilerplate4Fields
   ├HasTemplateField
   ├BoilerplateTemplateFieldsOK
   │ └ListTemplateFields
   │   └GetTemplateField...
   ├DoTemplateDialog...
   └StripScreenReaderCodes
     └StripScreenReaderCodes

Called-By Hierarchy


                                DoTemplateDialog
                       CheckBoilerplate4Fields┤ 
                         DoTemplateDialog...┤ │ 
                            ShowTemplateData┘ │ 
       TfrmDrawers.mnuPreviewTemplateClick┤   │ 
      TfrmDCSumm.popSummMemoPreviewClick┤ │   │ 
    TfrmConsults.popNoteMemoPreviewClick┤ │   │ 
     TfrmSurgery.popNoteMemoPreviewClick┤ │   │ 
       TfrmNotes.popNoteMemoPreviewClick┘ │   │ 
          TfrmTemplateEditor.mnuBPTryClick┘   │ 
        TfrmTemplateEditor.tvTreeKeyDown┘     │ 
                             TTemplate.GetText┘ 
                ExecuteTemplateOrBoilerPlate┤   
                      TfrmDrawers.InsertText┤   
           TfrmDrawers.tvTemplatesDblClick┤ │   
            TfrmDrawers.tvTemplatesKeyDown┤ │   
                TfrmDrawers.NewRECDragDrop┤ │   
          TfrmDrawers.SetRichEditControl┘ │ │   
                 TfrmDCSumm.FormCreate┤   │ │   
               TfrmConsults.FormCreate┤   │ │   
                TfrmSurgery.FormCreate┤   │ │   
                  TfrmNotes.FormCreate┘   │ │   
        TfrmDrawers.mnuInsertTemplateClick┘ │   
  TfrmDCSumm.popSummMemoInsTemplateClick┤   │   
TfrmConsults.popNoteMemoInsTemplateClick┤   │   
 TfrmSurgery.popNoteMemoInsTemplateClick┤   │   
   TfrmNotes.popNoteMemoInsTemplateClick┘   │   
      TfrmDrawers.mnuPreviewTemplateClick...┤   
            TfrmDrawers.mnuCopyTemplateClick┤   
         TfrmTemplateEditor.mnuBPTryClick...┘   

Calls

Name Declaration Comments
AssignFieldIDs procedure AssignFieldIDs(SL: TStrings); overload; -
TfrmTemplateDialog.BuildAllControls procedure BuildAllControls; -
CheckBoilerplate4Fields procedure CheckBoilerplate4Fields(SL: TStrings; const CaptionText: string = ''; PreviewMode: boolean = FALSE); overload; -
CountDlgProps procedure CountDlgProps(var DlgID: string); -
TfrmBase508Form.Create constructor Create(AOwner: TComponent); override; -
GetText procedure GetText(SL: TStrings; IncludeEmbeddedFields: Boolean); -
SetTemplateDialogCanceled procedure SetTemplateDialogCanceled(value: Boolean); -
TimedOut function TimedOut: boolean; -

Called-By

Name Declaration Comments
CheckBoilerplate4Fields procedure CheckBoilerplate4Fields(SL: TStrings; const CaptionText: string = ''; PreviewMode: boolean = FALSE); overload; -
TTemplate.GetText function GetText: string; -


Source

138   function DoTemplateDialog(SL: TStrings; const CaptionText: string; PreviewMode: boolean = FALSE): boolean;
139   var
140     i, j, idx, Indent: integer;
141     DlgProps, Txt: string;
142     DlgIDCounts: TStringList;
143     DlgInt: TIntStruc;
144     CancelDlg: Boolean;
145     CancelMsg: String;
146   
147   
148     procedure IncDlgID(var id: string); //Appends an item count in the form of id.0, id.1, id.2, etc
149     var                                 //based on what is in the StringList for id.
150       k: integer;
151   
152     begin
153       k := DlgIDCounts.IndexOf(id);
154   
155       if (k >= 0) then
156         begin
157         DlgInt := TIntStruc(DlgIDCounts.Objects[k]);
158         DlgInt.x := DlgInt.x + 1;
159         id := id + '.' + InttoStr(DlgInt.x);
160         end
161       else
162         begin
163         DlgInt := TIntStruc.Create;
164         DlgInt.x := 0;
165         DlgIDCounts.AddObject(id, DlgInt);
166         id := id + '.0';
167         end;
168   
169     end;
170   
171     procedure CountDlgProps(var DlgID: string);  //Updates the item and parent item id's with the count
172     var                                          // value id.0, id.1, id.2, id.3, etc.  The input dialog
173       x: integer;                                // id is in the form 'a;b;c;d', where c is the item id
174       id, pid: string;                           // and d is the parent item id
175   
176     begin
177       id  := piece(DlgID,';',3);
178       pid := piece(DlgID,';',4);
179   
180       if length(pid) > 0 then
181         x := DlgIDCounts.IndexOf(pid)
182       else
183         x := -1;
184   
185       if (x >= 0) then
186         begin
187         DlgInt := TIntStruc(DlgIDCounts.Objects[x]);
188         pid := pid + '.' + InttoStr(DlgInt.x);
189         end;
190   
191       if length(id) > 0 then
192         IncDlgID(id);
193   
194       SetPiece(DlgID,';',3,id);
195       SetPiece(DlgID,';',4,pid);
196     end;
197   
198   begin
199     Result := FALSE;
200     CancelDlg := FALSE;
201     SetTemplateDialogCanceled(FALSE);
202     frmTemplateDialog := TfrmTemplateDialog.Create(Application);
203     try
204       DlgIDCounts := TStringList.Create;
205       DlgIDCounts.Sorted := TRUE;
206       DlgIDCounts.Duplicates := dupError;
207       frmTemplateDialog.Caption := CaptionText;
208       AssignFieldIDs(SL);
209       frmTemplateDialog.SL := SL;
210       frmTemplateDialog.Index := '';
211       Txt := SL.Text;
212       frmTemplateDialog.OneOnly := (DelimCount(Txt, ObjMarker) = 1);
213       frmTemplateDialog.Count := 0;
214       idx := 1;
215       frmTemplateDialog.FirstIndent := 99999;
216       repeat
217         i := pos(ObjMarker, Txt);
218         if(i > 1) then
219         begin
220           j := pos(DlgPropMarker, Txt);
221           if(j > 0) then
222             begin
223             DlgProps := copy(Txt, j + DlgPropMarkerLen, (i - j - DlgPropMarkerLen));
224             CountDlgProps(DlgProps);
225             end
226           else
227             begin
228             DlgProps := '';
229             j := i;
230             end;
231           inc(frmTemplateDialog.Count);
232           frmTemplateDialog.Index := frmTemplateDialog.Index +
233                                      IntToStr(idx)+'~'+IntToStr(j-1)+'~'+DlgProps+U;
234           inc(idx,i+ObjMarkerLen-1);
235           Indent := StrToIntDef(Piece(DlgProps, ';', 5),0);
236           if(frmTemplateDialog.FirstIndent > Indent) then
237             frmTemplateDialog.FirstIndent := Indent;
238         end;
239         if(i > 0) then
240           delete(txt, 1, i + ObjMarkerLen - 1);
241       until (i = 0);
242       if(frmTemplateDialog.Count > 0) then
243       begin
244         if(frmTemplateDialog.OneOnly) then
245         begin
246           frmTemplateDialog.btnNone.Visible := FALSE;
247           frmTemplateDialog.btnAll.Visible := FALSE;
248         end;
249         frmTemplateDialog.BuildAllControls;
250         repeat                      
251            frmTemplateDialog.ShowModal;
252            if(frmTemplateDialog.ModalResult = mrOK) then
253              GetText(SL, TRUE)     {TRUE = Include embedded fields}
254            else
255             if (not PreviewMode) and (not frmTemplateDialog.Silent) and (not uInit.TimedOut) then
256               begin
257                 CancelMsg := 'If you cancel, your changes will not be saved.  Are you sure you want to cancel?';
258                 if (InfoBox(CancelMsg, 'Cancel Dialog Processing', MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) = ID_YES) then 
259                   begin
260                     SL.Clear;
261                     Result := TRUE;
262                     CancelDlg := TRUE;
263                   end
264                 else
265                   CancelDlg := FALSE;
266               end
267             else
268               begin
269                 SL.Clear;
270                 Result := TRUE;
271                 CancelDlg := TRUE;
272               end;
273         until CancelDlg or (frmTemplateDialog.ModalResult = mrOK)
274       end
275       else
276         SL.Clear;
277     finally
278       //frmTemplateDialog.Free;    v22.11e RV
279       frmTemplateDialog.Release;
280       //frmTemplateDialog := nil;  access violation source?  removed 7/28/03 RV
281       for i := 0 to DlgIDCounts.Count-1 do begin
282         DlgIDCounts.Objects[i].Free;
283       end;
284       DlgIDCounts.Free;
285     end;
286   
287     if Result then
288       SetTemplateDialogCanceled(TRUE)
289     else
290     begin
291       SetTemplateDialogCanceled(FALSE);
292       CheckBoilerplate4Fields(SL, CaptionText, PreviewMode);
293     end;
294     
295   end;