Ignore:
Timestamp:
Mar 31, 2010, 5:06:56 PM (14 years ago)
Author:
Kevin Toppenberg
Message:

Added functions to Templates, and Images tab

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/branches/tmg-cprs/CPRS-Chart/Templates/fTemplateDialog.pas

    r698 r729  
    4747    FAnswerOpenTag : string; //kt added 12/28/09
    4848    FAnswerCloseTag : string; //kt added 12/28/09
     49    NameToObjID : TStringList; //kt added 3/26/10
     50    Formulas  : TStringList; //kt added 3/26/10
     51    TxtObjects  : TStringList; //kt added 3/28/10
    4952    procedure SizeFormToCancelBtn();
    5053    procedure ChkAll(Chk: boolean);
     
    8184  frmTemplateDialog: TfrmTemplateDialog;
    8285
    83 const
    84   HTMLBEGINNINGTAG = '{HTML:';   //kt
    85   HTMLENDINGTAG = '}';       //kt
    86   HTMLBEGINNINGTAGLEN = length(HTMLBEGINNINGTAG);  //kt
    87   HTMLENDINGTAGLEN = length(HTMLENDINGTAG);   //kt
    88 
    8986implementation
    9087
     
    153150  i, j, idx, Indent: integer;
    154151  DlgProps, Txt: string;
     152  Temp : string; //kt
     153  Changed : boolean; //kt
    155154  DlgIDCounts: TStringList;
    156155  DlgInt: TIntStruc;
    157156  CancelDlg: Boolean;
    158157  CancelMsg: String;
    159 
    160158
    161159  procedure IncDlgID(var id: string); //Appends an item count in the form of id.0, id.1, id.2, etc
     
    221219    frmTemplateDialog.HTMLAnswerOpenTag := '<I>'; //kt 12/28/09
    222220    //SL.Text := RemoveHTMLTags(SL.Text);  //elh
    223     AssignFieldIDs(SL);
     221    AssignFieldIDs(SL,frmTemplateDialog.NameToObjID);   //kt  added NameToObjID param 3/26/10
     222    HideFormulas(SL,frmTemplateDialog.Formulas); //kt added 3/26/10
     223    HideTxtObjects(SL,frmTemplateDialog.TxtObjects); //kt added 3/28/10
    224224    frmTemplateDialog.SL := SL;
    225225    frmTemplateDialog.Index := '';
     
    231231    repeat
    232232      i := pos(ObjMarker, Txt);
    233       if(i > 1) then
    234       begin
     233      if(i > 1) then begin
    235234        j := pos(DlgPropMarker, Txt);
    236         if(j > 0) then
    237           begin
     235        if(j > 0) then begin
    238236          DlgProps := copy(Txt, j + DlgPropMarkerLen, (i - j - DlgPropMarkerLen));
    239237          CountDlgProps(DlgProps);
    240           end
    241         else
    242           begin
     238        end else begin
    243239          DlgProps := '';
    244240          j := i;
    245           end;
     241        end;
    246242        inc(frmTemplateDialog.Count);
    247243        frmTemplateDialog.Index := frmTemplateDialog.Index +
     
    249245        inc(idx,i+ObjMarkerLen-1);
    250246        Indent := StrToIntDef(Piece(DlgProps, ';', 5),0);
    251         if(frmTemplateDialog.FirstIndent > Indent) then
     247        if(frmTemplateDialog.FirstIndent > Indent) then begin
    252248          frmTemplateDialog.FirstIndent := Indent;
    253       end;
    254       if(i > 0) then
     249        end;
     250      end;
     251      if(i > 0) then begin
    255252        delete(txt, 1, i + ObjMarkerLen - 1);
     253      end;
    256254    until (i = 0);
    257     if(frmTemplateDialog.Count > 0) then
    258     begin
    259       if(frmTemplateDialog.OneOnly) then
    260       begin
     255    if(frmTemplateDialog.Count > 0) then begin
     256      if(frmTemplateDialog.OneOnly) then begin
    261257        frmTemplateDialog.btnNone.Visible := FALSE;
    262258        frmTemplateDialog.btnAll.Visible := FALSE;
     
    264260      frmTemplateDialog.BuildAllControls;
    265261      repeat
    266          if (assigned(frmNotes)) and (frmTemplateDialog.HTMLMode) then frmNotes.HTMLEditor.SetMsgActive(False);  //kt 2-1-10
    267          frmTemplateDialog.ShowModal;
    268          if (assigned(frmNotes)) and (frmTemplateDialog.HTMLMode) then frmNotes.HTMLEditor.SetMsgActive(True);   //kt 2-1-10
    269          if(frmTemplateDialog.ModalResult = mrOK) then begin
    270            GetText(SL, TRUE);     {TRUE = Include embedded fields}
    271            {
    272            if uTemplates.bUsingHTMLMode then begin
    273               SL.Text := FormatHTMLTags(SL.Text);
    274            end else begin
    275               SL.Text := RemoveHTMLTags(SL.Text);
    276            end;
    277            }
    278          end else begin
    279           if (not PreviewMode) and (not frmTemplateDialog.Silent) and (not uInit.TimedOut) then
    280             begin
    281 //            CancelMsg := 'If you cancel, your changes will not be saved.  Are you sure you want to cancel?';  <-- original line.  //kt 8/8/2007
    282               CancelMsg := DKLangConstW('fTemplateDialog_If_you_cancelx_your_changes_will_not_be_savedx__Are_you_sure_you_want_to_cancelx'); //kt added 8/8/2007
    283 //            if (InfoBox(CancelMsg, 'Cancel Dialog Processing', MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) = ID_YES) then   <-- original line.  //kt 8/8/2007
    284               if (InfoBox(CancelMsg, DKLangConstW('fTemplateDialog_Cancel_Dialog_Processing'), MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) = ID_YES) then  //kt added 8/8/2007
    285                 begin
    286                   SL.Clear;
    287                   Result := TRUE;
    288                   CancelDlg := TRUE;
    289                 end
    290               else
    291                 CancelDlg := FALSE;
    292             end
    293           else
    294             begin
     262        if (assigned(frmNotes)) and (frmTemplateDialog.HTMLMode) then frmNotes.HTMLEditor.SetMsgActive(False);  //kt 2-1-10
     263        frmTemplateDialog.ShowModal;
     264        if (assigned(frmNotes)) and (frmTemplateDialog.HTMLMode) then frmNotes.HTMLEditor.SetMsgActive(True);   //kt 2-1-10
     265        if(frmTemplateDialog.ModalResult = mrOK) then begin
     266          //kt -- begin mod --  3/27/10
     267          Changed := RestoreTransformTxtObjects(SL, frmTemplateDialog.TxtObjects, frmTemplateDialog.NameToObjID);
     268          Changed := RestoreTransformFormulas(SL, frmTemplateDialog.Formulas, frmTemplateDialog.NameToObjID) or Changed;
     269          if Changed then begin //kt 3/27/10
     270            Txt := SL.Text;
     271            i := pos(ObjMarker, Txt);
     272            if(i > 1) then begin
     273              j := pos(DlgPropMarker, Txt);
     274              if (j <= 0) then j := i;
     275              Temp := frmTemplateDialog.Index;
     276              SetPiece(Temp,'~',2,IntToStr(j-1));
     277              frmTemplateDialog.Index := Temp;
     278            end;
     279          end;
     280          //kt -- end mod --
     281          GetText(SL, TRUE);     {TRUE = Include embedded fields}
     282          {
     283          if uTemplates.bUsingHTMLMode then begin
     284             SL.Text := FormatHTMLTags(SL.Text);
     285          end else begin
     286             SL.Text := RemoveHTMLTags(SL.Text);
     287          end;
     288          }
     289        end else begin
     290          if (not PreviewMode) and (not frmTemplateDialog.Silent) and (not uInit.TimedOut) then begin
     291//          CancelMsg := 'If you cancel, your changes will not be saved.  Are you sure you want to cancel?';  <-- original line.  //kt 8/8/2007
     292            CancelMsg := DKLangConstW('fTemplateDialog_If_you_cancelx_your_changes_will_not_be_savedx__Are_you_sure_you_want_to_cancelx'); //kt added 8/8/2007
     293//          if (InfoBox(CancelMsg, 'Cancel Dialog Processing', MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) = ID_YES) then   <-- original line.  //kt 8/8/2007
     294            if (InfoBox(CancelMsg, DKLangConstW('fTemplateDialog_Cancel_Dialog_Processing'), MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) = ID_YES) then begin  //kt added 8/8/2007
    295295              SL.Clear;
    296296              Result := TRUE;
    297297              CancelDlg := TRUE;
     298            end else begin
     299              CancelDlg := FALSE;
    298300            end;
    299          end;     
     301          end else begin
     302            SL.Clear;
     303            Result := TRUE;
     304            CancelDlg := TRUE;
     305          end;
     306        end;
    300307      until CancelDlg or (frmTemplateDialog.ModalResult = mrOK)
    301     end
    302     else
     308    end else begin
    303309      SL.Clear;
     310    end;
    304311  finally
    305312    //frmTemplateDialog.Free;    v22.11e RV
     
    324331  tempString := Txt;
    325332  //here we will strip out all HTML formatting tags  //elh
    326   beginning := pos(HTMLBEGINNINGTAG, tempString);
     333  beginning := pos(HTML_BEGIN_TAG, tempString);
    327334  if beginning = 0 then begin
    328335     Result := Txt;
     
    331338    begin
    332339      tempResult := tempResult + Leftstr(tempString,beginning-1);
    333       tempString := Rightstr(tempString,length(tempString)-beginning-HTMLBEGINNINGTAGLEN);
    334       ending := pos(HTMLENDINGTAG, tempString);
     340      tempString := Rightstr(tempString,length(tempString)-beginning-HTML_BEGIN_TAGLEN);
     341      ending := pos(HTML_ENDING_TAG, tempString);
    335342      tempString := Rightstr(tempString,length(tempString)-ending);
    336       beginning := pos(HTMLBEGINNINGTAG, tempString);
    337   //    tempString := Midstr(Txt,i,HTMLBEGINNINGTAGLEN);
     343      beginning := pos(HTML_BEGIN_TAG, tempString);
     344  //    tempString := Midstr(Txt,i,HTML_BEGIN_TAGLEN);
    338345    end;
    339346    Result := tempResult + tempString;
     
    348355  tempString := Txt;
    349356  //here we will strip out all HTML formatting tags  //elh
    350   beginning := pos(HTMLBEGINNINGTAG, tempString);
     357  beginning := pos(HTML_BEGIN_TAG, tempString);
    351358  if beginning = 0 then begin
    352359     Result := Txt;
     
    355362    begin
    356363      tempResult := tempResult + Leftstr(tempString,beginning-1);
    357       tempString := Rightstr(tempString,length(tempString)-beginning-HTMLBEGINNINGTAGLEN+1);
    358       ending := pos(HTMLENDINGTAG, tempString);
     364      tempString := Rightstr(tempString,length(tempString)-beginning-HTML_BEGIN_TAGLEN+1);
     365      ending := pos(HTML_ENDING_TAG, tempString);
    359366      tempResult := tempResult + Leftstr(tempString,ending-1);
    360367      tempString := Rightstr(tempString,length(tempString)-ending);
    361       beginning := pos(HTMLBEGINNINGTAG, tempString);
    362   //    tempString := Midstr(Txt,i,HTMLBEGINNINGTAGLEN);
     368      beginning := pos(HTML_BEGIN_TAG, tempString);
     369  //    tempString := Midstr(Txt,i,HTML_BEGIN_TAGLEN);
    363370    end;
    364371    Result := tempResult + tempString;
     
    565572  end;
    566573  tmp := copy(SL.Text, p1, p2);
    567   tmp := RemoveHTMLTags(tmp);
     574  tmp := RemoveHTMLTags(tmp);  //kt
    568575  if(copy(tmp, length(tmp)-1, 2) = CRLF) then
    569576    delete(tmp, length(tmp)-1, 2);
     
    747754  Entries := TStringList.Create;
    748755  NoTextID := TStringList.Create;
     756  NameToObjID := TStringList.Create ; //kt
     757  Formulas  := TStringList.Create ; //kt
     758  TxtObjects  := TStringList.Create; //kt added 3/28/10
    749759  FOldHintEvent := Application.OnShowHint;
    750760  Application.OnShowHint := AppShowHint;
     
    774784  Entries.Free;
    775785  BuildIdx.Free;
     786  NameToObjID.Free; //kt
     787  Formulas.Free; //kt
     788  TxtObjects.Free; //kt
    776789end;
    777790
Note: See TracChangeset for help on using the changeset viewer.