Function

TTemplate.CreateFromXML

Module

uTemplates

Last Modified

7/15/2014 3:26:44 PM

Visibility

Public

Owner

TTemplate

Declaration

class function CreateFromXML(Element: IXMLDOMNode; Owner: string): TTemplate;

Calls Hierarchy


TTemplate.CreateFromXML
 ├TTemplate.Create
 │ └TTemplate.ReminderDialogIEN
 ├TTemplate.SetBoilerplate
 │ ├TTemplate.CanModify
 │ │ ├TTemplate.ValidID
 │ │ └LockTemplate
 │ └TTemplate.ValidID
 ├TTemplate.SetDescription
 │ ├TTemplate.CanModify...
 │ └TTemplate.ValidID
 ├TTemplate.GetItems
 │ └ExpandTemplate
 │   ├TTemplate.GetChildren
 │   ├GetTemplateChildren
 │   ├AddTemplate
 │   │ ├TTemplate.Create...
 │   │ └TTemplate.AddChild
 │   │   └TTemplate.GetItems...
 │   └TTemplate.ItemIENs
 │     └TTemplate.GetItems...
 ├..(rec)..
 └TTemplate.BackupItems
   └TTemplate.ItemIENs...

Called-By Hierarchy


                       TTemplate.CreateFromXML
                                   ..(rec)..┤ 
              TfrmTemplateEditor.btnNewClick┘ 
                             EditTemplates┤   
     TfrmDCSumm.popSummMemoTemplateClick┤ │   
          TfrmDCSumm.mnuNewTemplateClick┤ │   
        TfrmDCSumm.mnuEditTemplatesClick┤ │   
  TfrmDCSumm.mnuEditSharedTemplatesClick┤ │   
    TfrmDCSumm.mnuNewSharedTemplateClick┤ │   
   TfrmConsults.popNoteMemoTemplateClick┤ │   
      TfrmConsults.mnuEditTemplatesClick┤ │   
        TfrmConsults.mnuNewTemplateClick┤ │   
TfrmConsults.mnuEditSharedTemplatesClick┤ │   
  TfrmConsults.mnuNewSharedTemplateClick┤ │   
       TfrmDrawers.mnuEditTemplatesClick┤ │   
         TfrmDrawers.mnuNewTemplateClick┤ │   
    TfrmSurgery.popNoteMemoTemplateClick┤ │   
       TfrmSurgery.mnuEditTemplatesClick┤ │   
         TfrmSurgery.mnuNewTemplateClick┤ │   
 TfrmSurgery.mnuEditSharedTemplatesClick┤ │   
   TfrmSurgery.mnuNewSharedTemplateClick┤ │   
      TfrmNotes.popNoteMemoTemplateClick┤ │   
         TfrmNotes.mnuEditTemplatesClick┤ │   
           TfrmNotes.mnuNewTemplateClick┤ │   
   TfrmNotes.mnuEditSharedTemplatesClick┤ │   
     TfrmNotes.mnuNewSharedTemplateClick┘ │   
        TfrmTemplateEditor.mnuAutoGenClick┤   
 TfrmTemplateEditor.mnuImportTemplateClick┘   

Calls

Name Declaration Comments
TTemplate.BackupItems procedure BackupItems; -
TTemplate.Create constructor Create(DataString: string); -
TTemplate.CreateFromXML class function CreateFromXML(Element: IXMLDOMNode; Owner: string): TTemplate; -
TTemplate.GetItems function GetItems: TList; -
TTemplate.SetBoilerplate procedure SetBoilerplate(Value: string); -
TTemplate.SetDescription procedure SetDescription(const Value: string); -

Called-By

Name Declaration Comments
TfrmTemplateEditor.btnNewClick procedure btnNewClick(Sender: TObject); -
TTemplate.CreateFromXML class function CreateFromXML(Element: IXMLDOMNode; Owner: string): TTemplate; -


Source

1623  class function TTemplate.CreateFromXML(Element: IXMLDOMNode; Owner: string): TTemplate;
1624  var
1625    DataStr: string;
1626    Children, Items: IXMLDOMNodeList;
1627    Child, Item: IXMLDOMNode;
1628    i, j, count, ItemCount: integer;
1629    fld: TTemplateExportField;
1630    ETag: string;
1631  
1632  begin
1633    DataStr := '0';
1634    SetPiece(DataStr, U, 4, FindXMLAttributeValue(Element, TemplateExportTag[efName]));
1635    SetPiece(DataStr, U, 7, Owner);
1636    Children := Element.Get_childNodes;
1637    try
1638      if assigned(Children) then
1639      begin
1640        count := Children.Length;
1641        for i := 0 to Count - 1 do
1642        begin
1643          Child := Children.Item[i];
1644          ETag := Child.NodeName;
1645          for fld := low(TTemplateExportField) to high(TTemplateExportField) do
1646          begin
1647            if(ExportPieces[fld] > 0) and (CompareText(ETag, TemplateExportTag[fld]) = 0) then
1648              SetPiece(DataStr, U, ExportPieces[fld], Child.Get_Text);
1649          end;
1650        end;
1651      end
1652      else
1653        Count := 0;
1654      Result := Create(DataStr);
1655      Result.FCloning := TRUE;
1656      try
1657        if assigned(Children) then
1658        begin
1659          for i := 0 to Count - 1 do
1660          begin
1661            Child := Children.Item[i];
1662            ETag := Child.NodeName;
1663            for fld := low(TTemplateExportField) to high(TTemplateExportField) do
1664            begin
1665              if(ExportPieces[fld] = 0) and (CompareText(ETag, TemplateExportTag[fld]) = 0) then
1666              begin
1667                case fld of
1668                  efBoilerplate: Result.SetBoilerplate(GetXMLWPText(Child));
1669                  efDescription: Result.SetDescription(GetXMLWPText(Child));
1670                  efItems:
1671                    begin
1672                      Result.GetItems;
1673                      Items := Child.Get_childNodes;
1674                      if assigned(Items) then
1675                      begin
1676                        ItemCount := Items.Length;
1677                        for j := 0 to ItemCount - 1 do
1678                        begin
1679                          Item := Items.Item[j];
1680                          if(CompareText(Item.NodeName, XMLTemplateTag) = 0) then
1681                            Result.FItems.Add(CreateFromXML(Item, Owner));
1682                        end;
1683                      end;
1684                    end;
1685                end;
1686              end;
1687            end;
1688          end;
1689        end;
1690      finally
1691        Result.FCloning := FALSE;
1692      end;
1693    finally
1694      Children := nil;
1695    end;
1696    Result.BackupItems;
1697    Templates.AddObject(Result.ID, Result);
1698  end;