Procedure

TfrmTemplateEditor.mnuExportTemplateClick

Module

fTemplateEditor

Last Modified

7/15/2014 3:26:44 PM

Visibility

Public/Published

Owner

TfrmTemplateEditor

Declaration

procedure mnuExportTemplateClick(Sender: TObject);

Calls Hierarchy


TfrmTemplateEditor.mnuExportTemplateClick
 ├TTemplate.CanExportXML
 │ ├BadTemplateName
 │ ├AddXMLData
 │ ├AddXMLBool
 │ │ └AddXMLData
 │ ├AddXMLList
 │ │ └ListTemplateFields
 │ │   └GetTemplateField
 │ │     ├LoadTemplateFieldByIEN
 │ │     ├LoadTemplateField
 │ │     └TTemplateField.Create
 │ │       ├TemplateFieldCode2Field
 │ │       └TemplateDateCode2DateType
 │ ├TTemplate.GetBoilerplate
 │ │ └GetTemplateBoilerplate
 │ ├TTemplate.GetDescription
 │ │ └LoadTemplateDescription
 │ ├TTemplate.GetItems
 │ │ └ExpandTemplate
 │ │   ├TTemplate.GetChildren
 │ │   ├GetTemplateChildren
 │ │   ├AddTemplate
 │ │   │ ├TTemplate.Create
 │ │   │ │ └TTemplate.ReminderDialogIEN
 │ │   │ └TTemplate.AddChild
 │ │   │   └TTemplate.GetItems...
 │ │   └TTemplate.ItemIENs
 │ │     └TTemplate.GetItems...
 │ └..(rec)..
 ├ExpandEmbeddedFields
 │ └GetTemplateField...
 └ExportTemplateFields
   └CallImportExportTemplateFields

Calls

Name Declaration Comments
TTemplate.CanExportXML function CanExportXML(Data, Fields: TStringList; IndentLevel: integer = 0): boolean; -
ExpandEmbeddedFields procedure ExpandEmbeddedFields(flds: TStringList); -
ExportTemplateFields function ExportTemplateFields(FldList: TStrings): TStrings; -


Source

3477  procedure TfrmTemplateEditor.mnuExportTemplateClick(Sender: TObject);
3478  var
3479    Tmpl, Flds: TStringList;
3480    i: integer;
3481    XMLDoc: IXMLDOMDocument;
3482    err: boolean;
3483  
3484  begin
3485    err := FALSE;
3486    if (assigned(FCurTree) and assigned(FCurTree.Selected) and assigned(FCurTree.Selected.Data)) then
3487    begin
3488      dlgExport.FileName := ValidFileName(TTemplate(FCurTree.Selected.Data).PrintName);
3489      if dlgExport.Execute then
3490      begin
3491        Tmpl := TStringList.Create;
3492        try
3493          Flds := TStringList.Create;
3494          try
3495            Tmpl.Add('<' + XMLHeader + '>');
3496            if TTemplate(FCurTree.Selected.Data).CanExportXML(Tmpl, Flds, 2) then
3497            begin
3498              if (Flds.Count > 0) then begin
3499                ExpandEmbeddedFields(Flds);
3500                FastAssign(ExportTemplateFields(Flds), Flds);
3501                for i := 0 to Flds.Count - 1 do
3502                  Flds[i] := '  ' + Flds[i];
3503                FastAddStrings(Flds, Tmpl);
3504              end; {if}
3505              Tmpl.Add('</' + XMLHeader + '>');
3506              try
3507                XMLDoc := CoDOMDocument.Create;
3508                try
3509                  XMLDoc.preserveWhiteSpace := TRUE;
3510                  XMLDoc.LoadXML(Tmpl.Text);
3511                  XMLDoc.Save(dlgExport.FileName);
3512                finally
3513                  XMLDoc := nil;
3514                end;
3515              except
3516                InfoBox(Format(NoIE5, ['Export']), NoIE5Header, MB_OK);
3517                err := TRUE;
3518              end;
3519              if not err then
3520                InfoBox('Template ' + TTemplate(FCurTree.Selected.Data).PrintName +
3521                  ' Exported.', 'Template Exported', MB_OK);
3522            end;
3523          finally
3524            Flds.Free;
3525          end;
3526        finally
3527          Tmpl.Free;
3528        end;
3529      end;
3530    end;
3531  end;