Changeset 518


Ignore:
Timestamp:
Aug 31, 2018, 3:28:41 PM (6 years ago)
Author:
chronos
Message:
  • Modified: Updated Common package files.
Location:
Common
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Common/UCommon.pas

    r517 r518  
    7272function MergeArray(A, B: array of string): TArrayOfString;
    7373function LoadFileToStr(const FileName: TFileName): AnsiString;
     74procedure SaveStringToFile(S, FileName: string);
    7475procedure SearchFiles(AList: TStrings; Dir: string;
    7576  FilterMethod: TFilterMethodMethod = nil);
    7677function GetStringPart(var Text: string; Separator: string): string;
     78function StripTags(const S: string): string;
    7779function PosFromIndex(SubStr: string; Text: string;
    7880  StartIndex: Integer): Integer;
     
    527529end;
    528530
     531procedure SaveStringToFile(S, FileName: string);
     532var
     533  F: TextFile;
     534begin
     535  AssignFile(F, FileName);
     536  try
     537    ReWrite(F);
     538    Write(F, S);
     539  finally
     540    CloseFile(F);
     541  end;
     542end;
     543
    529544procedure SearchFiles(AList: TStrings; Dir: string;
    530545  FilterMethod: TFilterMethodMethod = nil);
     
    561576  Result := Trim(Result);
    562577  Text := Trim(Text);
     578end;
     579
     580function StripTags(const S: string): string;
     581var
     582  Len: Integer;
     583
     584  function ReadUntil(const ReadFrom: Integer; const C: Char): Integer;
     585  var
     586    J: Integer;
     587  begin
     588    for J := ReadFrom to Len do
     589      if (S[j] = C) then
     590      begin
     591        Result := J;
     592        Exit;
     593      end;
     594    Result := Len + 1;
     595  end;
     596
     597var
     598  I, APos: Integer;
     599begin
     600  Len := Length(S);
     601  I := 0;
     602  Result := '';
     603  while (I <= Len) do begin
     604    Inc(I);
     605    APos := ReadUntil(I, '<');
     606    Result := Result + Copy(S, I, APos - i);
     607    I := ReadUntil(APos + 1, '>');
     608  end;
    563609end;
    564610
     
    608654end;
    609655
     656
    610657initialization
    611658
  • Common/ULastOpenedList.pas

    r510 r518  
    3030    procedure SaveToXMLConfig(XMLConfig: TXMLConfig; Path: string);
    3131    procedure AddItem(FileName: string);
     32    function GetFirstFileName: string;
    3233  published
    3334    property MaxCount: Integer read FMaxCount write SetMaxCount;
     
    185186end;
    186187
     188function TLastOpenedList.GetFirstFileName: string;
     189begin
     190  if Items.Count > 0 then Result := Items[0]
     191    else Result := '';
     192end;
     193
    187194end.
    188195
  • Common/UScaleDPI.pas

    r511 r518  
    289289  //OldAutoSize: Boolean;
    290290begin
     291  //if not (Control is TCustomPage) then
     292  // Resize childs first
     293  if Control is TWinControl then begin
     294    WinControl := TWinControl(Control);
     295    if WinControl.ControlCount > 0 then begin
     296      for I := 0 to WinControl.ControlCount - 1 do begin
     297        if WinControl.Controls[I] is TControl then begin
     298          ScaleControl(WinControl.Controls[I], FromDPI);
     299        end;
     300      end;
     301    end;
     302  end;
     303
    291304  //if Control is TMemo then Exit;
    292305  //if Control is TForm then
     
    340353  end;
    341354
    342   //if not (Control is TCustomPage) then
    343   if Control is TWinControl then begin
    344     WinControl := TWinControl(Control);
    345     if WinControl.ControlCount > 0 then begin
    346       for I := 0 to WinControl.ControlCount - 1 do begin
    347         if WinControl.Controls[I] is TControl then begin
    348           ScaleControl(WinControl.Controls[I], FromDPI);
    349         end;
    350       end;
    351     end;
    352   end;
    353355  //if Control is TForm then
    354356  //  Control.EnableAutoSizing;
  • Common/UXMLUtils.pas

    r510 r518  
    77uses
    88  {$IFDEF WINDOWS}Windows,{$ENDIF}
    9   Classes, SysUtils, DateUtils, DOM;
     9  Classes, SysUtils, DateUtils, DOM, xmlread;
    1010
    1111function XMLTimeToDateTime(XMLDateTime: string): TDateTime;
     
    2121function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string;
    2222function ReadDateTime(Node: TDOMNode; Name: string; DefaultValue: TDateTime): TDateTime;
     23procedure ReadXMLFileParser(out Doc: TXMLDocument; FileName: string);
    2324
    2425
    2526implementation
     27
     28procedure ReadXMLFileParser(out Doc: TXMLDocument; FileName: string);
     29var
     30  Parser: TDOMParser;
     31  Src: TXMLInputSource;
     32  InFile: TFileStream;
     33begin
     34  try
     35    InFile := TFileStream.Create(FileName, fmOpenRead);
     36    Src := TXMLInputSource.Create(InFile);
     37    Parser := TDOMParser.Create;
     38    Parser.Options.PreserveWhitespace := True;
     39    Parser.Parse(Src, Doc);
     40  finally
     41    Src.Free;
     42    Parser.Free;
     43    InFile.Free;
     44  end;
     45end;
    2646
    2747function GetTimeZoneBias: Integer;
Note: See TracChangeset for help on using the changeset viewer.