From: Olivier S. <ob...@us...> - 2005-08-10 15:27:22
|
Update of /cvsroot/jvcl/dev/JVCL3/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3832/dev/JVCL3/run Modified Files: JvDBHTLabel.pas Log Message: Mantis 2586: FIELDLABEL introduced and various cleanups Index: JvDBHTLabel.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/run/JvDBHTLabel.pas,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** JvDBHTLabel.pas 17 Feb 2005 10:20:21 -0000 1.12 --- JvDBHTLabel.pas 10 Aug 2005 15:27:14 -0000 1.13 *************** *** 115,123 **** function ReplaceFieldNameTag(Str: string; DataSet: TDataSet): string; var - A, FieldName, Text: string; - I, J: Integer; F: TField; const ! FieldStr: string = '<FIELD='; // non-standard html function ExtractPropertyValue(Tag, PropName: string): string; begin --- 115,125 ---- function ReplaceFieldNameTag(Str: string; DataSet: TDataSet): string; var F: TField; const ! FieldName = 'FIELD'; // non-standard html ! FieldStr = '<' + FieldName + '='; ! FieldLabelName = 'FIELDLABEL'; ! FieldLabelStr = '<' + FieldLabelName + '='; ! function ExtractPropertyValue(Tag, PropName: string): string; begin *************** *** 131,161 **** end; end; ! begin ! Result := ''; ! I := Pos(FieldStr, Str); ! while I > 0 do begin ! Result := Result + Copy(Str, 1, I - 1); ! A := Copy(Str, I, Length(Str)); ! J := Pos('>', A); ! if J > 0 then ! Delete(Str, 1, I + J - 1) ! else ! Str := ''; ! FieldName := ExtractPropertyValue(A, 'FIELD'); ! if Assigned(DataSet) and DataSet.Active then begin ! F := DataSet.FindField(FieldName); ! if F <> nil then ! Text := F.AsString else ! Text := Format('(%s)',[FieldName]); ! end ! else ! Text := Format('(%s)',[FieldName]); ! Result := Result + Text; ! I := Pos(FieldStr, Str); end; ! Result := Result + Str; end; --- 133,181 ---- end; end; ! ! function ExtractProperty(AStr: string; const PropName: string): string; ! var ! J: Integer; ! I: Integer; ! A, FieldName, Text: string; ! PropStr: string; begin ! Result := ''; ! PropStr := '<'+PropName+'='; ! I := Pos(PropStr, AStr); ! while I > 0 do begin ! Result := Result + Copy(AStr, 1, I - 1); ! A := Copy(AStr, I, Length(AStr)); ! J := Pos('>', A); ! if J > 0 then ! Delete(AStr, 1, I + J - 1) else ! AStr := ''; ! FieldName := ExtractPropertyValue(A, PropStr); ! if Assigned(DataSet) and DataSet.Active then ! begin ! F := DataSet.FindField(FieldName); ! if F <> nil then ! begin ! if PropName = FieldLabelName then ! Text := F.DisplayLabel ! else ! Text := F.DisplayText; ! end ! else ! Text := Format('(%s)', [FieldName]); ! end ! else ! Text := Format('(%s)', [FieldName]); ! Result := Result + Text; ! I := Pos(PropStr, AStr); ! end; ! Result := Result + AStr; end; ! ! begin ! Result := ExtractProperty(Str, FieldLabelName); ! Result := ExtractProperty(Result, FieldName); end; |