Стартовый пул

This commit is contained in:
2024-04-02 08:46:59 +03:00
parent fd57fffd3a
commit 3bb34d000b
5591 changed files with 3291734 additions and 0 deletions

View File

@@ -0,0 +1,471 @@
{ rxConfigValues unit
Copyright (C) 2005-2017 Lagunov Aleksey alexs75@yandex.ru and Lazarus team
original conception from rx library for Delphi (c)
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version with the following modification:
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,and
to copy and distribute the resulting executable under terms of your choice,
provided that you also meet, for each linked independent module, the terms
and conditions of the license of that module. An independent module is a
module which is not derived from or based on this library. If you modify
this library, you may extend this exception to your version of the library,
but you are not obligated to do so. If you do not wish to do so, delete this
exception statement from your version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
unit rxConfigValues;
{$I rx.inc}
interface
uses
Classes, SysUtils;
const
cvtInteger = 1; // целое
cvtString = 2; // строка
cvtBoolean = 3; // логическая
cvtDateTime = 4; // дата
cvtFloat = 5; // вещественное
type
TConfigValuesEnumerator = class;
{ TConfigValue }
TConfigValue = class
private
FModified:boolean;
FName: string;
FDataType:byte;
FValue:Variant;
function GetAsBoolean: boolean;
function GetAsDateTime: TDateTime;
function GetAsFloat: Double;
function GetAsInteger: integer;
function GetAsString: string;
procedure SetAsBoolean(const AValue: boolean);
procedure SetAsDateTime(const AValue: TDateTime);
procedure SetAsFloat(const AValue: Double);
procedure SetAsInteger(const AValue: integer);
procedure SetAsString(const AValue: string);
function GetValue: string;
public
constructor Create;
destructor Destroy; override;
property Name:string read FName;
property AsString:string read GetAsString write SetAsString;
property AsInteger:integer read GetAsInteger write SetAsInteger;
property AsFloat:Double read GetAsFloat write SetAsFloat;
property AsBoolean:boolean read GetAsBoolean write SetAsBoolean;
property AsDateTime:TDateTime read GetAsDateTime write SetAsDateTime;
property Modified:boolean read FModified write FModified;
property DataType:byte read FDataType;
property Value:string read GetValue;
end;
{ TConfigValues }
TConfigValues = class
private
FItems:TList;
function CreateValue(AName:string; AType:byte):TConfigValue;
function GetCount: integer;
function GetItem(Index:Integer): TConfigValue;
public
constructor Create;
destructor Destroy; override;
procedure BeginUpdate;
procedure EndUpdate;
procedure Clear;
function ParamByName(AName:string):TConfigValue;
function ByNameAsInteger(AName:string; DefValue:integer):integer;
function ByNameAsString(AName:string; DefValue:string):string;
function ByNameAsFloat(AName:string; DefValue:Double):Double;
function ByNameAsBoolean(AName:string; DefValue:Boolean):Boolean;
function ByNameAsDateTime(AName:string; DefValue:TDateTime):TDateTime;
procedure SetByNameAsInteger(AName:string; AValue:integer);
procedure SetByNameAsString(AName:string; AValue:string);
procedure SetByNameAsFloat(AName:string; ADefValue:Double);
procedure SetByNameAsBoolean(AName:string; ADefValue:Boolean);
procedure SetByNameAsDateTime(AName:string; ADefValue:TDateTime);
function GetEnumerator: TConfigValuesEnumerator;
public
property Items[Index:Integer]:TConfigValue read GetItem;default;
property Count:integer read GetCount;
end;
{ TConfigValuesEnumerator }
TConfigValuesEnumerator = class
private
FList: TConfigValues;
FPosition: Integer;
public
constructor Create(AList: TConfigValues);
function GetCurrent: TConfigValue;
function MoveNext: Boolean;
property Current: TConfigValue read GetCurrent;
end;
implementation
uses rxconst;
{ TConfigValuesEnumerator }
constructor TConfigValuesEnumerator.Create(AList: TConfigValues);
begin
FList := AList;
FPosition := -1;
end;
function TConfigValuesEnumerator.GetCurrent: TConfigValue;
begin
Result := FList[FPosition];
end;
function TConfigValuesEnumerator.MoveNext: Boolean;
begin
Inc(FPosition);
Result := FPosition < FList.Count;
end;
{ TConfigValues }
function TConfigValues.CreateValue(AName: string; AType: byte): TConfigValue;
begin
Result:=TConfigValue.Create;
Result.FDataType:=AType;
Result.FName:=AName;
FItems.Add(Result);
end;
function TConfigValues.GetCount: integer;
begin
Result:=FItems.Count;
end;
function TConfigValues.GetItem(Index:Integer): TConfigValue;
begin
Result:=TConfigValue(FItems[Index]);
end;
constructor TConfigValues.Create;
begin
inherited Create;
FItems:=TList.Create;
end;
destructor TConfigValues.Destroy;
begin
Clear;
FreeAndNil(FItems);
inherited Destroy;
end;
procedure TConfigValues.BeginUpdate;
begin
end;
procedure TConfigValues.EndUpdate;
var
i:integer;
begin
for i:=0 to FItems.Count - 1 do
TConfigValue(FItems[i]).FModified:=false;
end;
procedure TConfigValues.Clear;
var
i:integer;
begin
for i:=0 to FItems.Count - 1 do
TConfigValue(FItems[i]).Free;
FItems.Clear;
end;
function TConfigValues.ParamByName(AName: string): TConfigValue;
var
i:integer;
begin
AName:=AnsiUpperCase(AName);
Result:=nil;
for i:=0 to FItems.Count - 1 do
begin
if AnsiUpperCase(TConfigValue(FItems[i]).FName) = AName then
begin
Result:=TConfigValue(FItems[i]);
exit;
end;
end;
end;
function TConfigValues.ByNameAsInteger(AName: string; DefValue: integer
): integer;
var
P:TConfigValue;
begin
P:=ParamByName(AName);
if Assigned(P) then
Result:=P.AsInteger
else
Result:=DefValue;
end;
function TConfigValues.ByNameAsString(AName: string; DefValue: string): string;
var
P:TConfigValue;
begin
P:=ParamByName(AName);
if Assigned(P) then
Result:=P.AsString
else
Result:=DefValue;
end;
function TConfigValues.ByNameAsFloat(AName: string; DefValue: Double): Double;
var
P:TConfigValue;
begin
P:=ParamByName(AName);
if Assigned(P) then
Result:=P.AsFloat
else
Result:=DefValue;
end;
function TConfigValues.ByNameAsBoolean(AName: string; DefValue: Boolean
): Boolean;
var
P:TConfigValue;
begin
P:=ParamByName(AName);
if Assigned(P) then
Result:=P.AsBoolean
else
Result:=DefValue;
end;
function TConfigValues.ByNameAsDateTime(AName: string; DefValue: TDateTime
): TDateTime;
var
P:TConfigValue;
begin
P:=ParamByName(AName);
if Assigned(P) then
Result:=P.AsDateTime
else
Result:=DefValue;
end;
procedure TConfigValues.SetByNameAsInteger(AName: string; AValue: integer);
var
P:TConfigValue;
begin
P:=ParamByName(AName);
if not Assigned(P) then
P:=CreateValue(AName, cvtInteger);
P.AsInteger:=AValue;
end;
procedure TConfigValues.SetByNameAsString(AName: string; AValue: string);
var
P:TConfigValue;
begin
P:=ParamByName(AName);
if not Assigned(P) then
P:=CreateValue(AName, cvtString);
P.AsString:=AValue;
end;
procedure TConfigValues.SetByNameAsFloat(AName: string; ADefValue: Double);
var
P:TConfigValue;
begin
P:=ParamByName(AName);
if not Assigned(P) then
P:=CreateValue(AName, cvtFloat);
P.AsFloat:=ADefValue;
end;
procedure TConfigValues.SetByNameAsBoolean(AName: string; ADefValue: Boolean);
var
P:TConfigValue;
begin
P:=ParamByName(AName);
if not Assigned(P) then
P:=CreateValue(AName, cvtBoolean);
P.AsBoolean:=ADefValue;
end;
procedure TConfigValues.SetByNameAsDateTime(AName: string; ADefValue: TDateTime
);
var
P:TConfigValue;
begin
P:=ParamByName(AName);
if not Assigned(P) then
P:=CreateValue(AName, cvtDateTime);
P.AsDateTime:=ADefValue;
end;
function TConfigValues.GetEnumerator: TConfigValuesEnumerator;
begin
Result:=TConfigValuesEnumerator.Create(Self);
end;
{ TConfigValue }
function TConfigValue.GetAsBoolean: boolean;
begin
if FDataType = cvtBoolean then
Result:=FValue
else
raise Exception.CreateFmt(sVariableIsNotBoolean, [FName]);
end;
function TConfigValue.GetAsDateTime: TDateTime;
begin
if FDataType = cvtDateTime then
Result:=FValue
else
raise Exception.CreateFmt(sVariableIsNotDT, [FName]);
end;
function TConfigValue.GetAsFloat: Double;
begin
if FDataType = cvtFloat then
Result:=FValue
else
raise Exception.CreateFmt(sVariableIsNotFloat, [FName]);
end;
function TConfigValue.GetAsInteger: integer;
begin
if FDataType = cvtInteger then
Result:=FValue
else
raise Exception.CreateFmt(sVariableIsNotInteger, [FName]);
end;
function TConfigValue.GetAsString: string;
begin
if FDataType = cvtString then
Result:=FValue
else
raise Exception.CreateFmt(sVariableIsNotString, [FName]);
end;
procedure TConfigValue.SetAsBoolean(const AValue: boolean);
begin
if FDataType = cvtBoolean then
begin
if FValue<>AValue then
begin
FValue:=AValue;
FModified:=true;
end
end
else
raise Exception.CreateFmt(sVariableIsNotBoolean, [FName]);
end;
procedure TConfigValue.SetAsDateTime(const AValue: TDateTime);
begin
if FDataType = cvtDateTime then
begin
if FValue<>AValue then
begin
FValue:=AValue;
FModified:=true;
end
end
else
raise Exception.CreateFmt(sVariableIsNotDT, [FName]);
end;
procedure TConfigValue.SetAsFloat(const AValue: Double);
begin
if FDataType = cvtFloat then
begin
if FValue<>AValue then
begin
FValue:=AValue;
FModified:=true;
end
end
else
raise Exception.CreateFmt(sVariableIsNotFloat, [FName]);
end;
procedure TConfigValue.SetAsInteger(const AValue: integer);
begin
if FDataType = cvtInteger then
begin
if (FValue = null) or (FValue<>AValue) then
begin
FValue:=AValue;
FModified:=true;
end
end
else
raise Exception.CreateFmt(sVariableIsNotInteger, [FName]);
end;
procedure TConfigValue.SetAsString(const AValue: string);
begin
if FDataType = cvtString then
begin
if FValue<>AValue then
begin
FValue:=AValue;
FModified:=true;
end
end
else
raise Exception.CreateFmt(sVariableIsNotString, [FName]);
end;
constructor TConfigValue.Create;
begin
inherited Create;
FModified:=false;
FValue:=null;
end;
destructor TConfigValue.Destroy;
begin
inherited Destroy;
end;
function TConfigValue.GetValue: string;
begin
case FDataType of
cvtInteger : Result:=IntToStr(AsInteger);
cvtString : Result:=AsString;
cvtBoolean : Result:=IntToStr(Ord(AsBoolean));
cvtDateTime: Result:=DateTimeToStr(AsDateTime);
cvtFloat : Str(AsFloat, Result);
end;
end;
end.

137
RXLib/rxtools/rxconst.pas Normal file
View File

@@ -0,0 +1,137 @@
{ rxconst unit
Copyright (C) 2005-2017 Lagunov Aleksey alexs75@yandex.ru and Lazarus team
original conception from rx library for Delphi (c)
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version with the following modification:
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,and
to copy and distribute the resulting executable under terms of your choice,
provided that you also meet, for each linked independent module, the terms
and conditions of the license of that module. An independent module is a
module which is not derived from or based on this library. If you modify
this library, you may extend this exception to your version of the library,
but you are not obligated to do so. If you do not wish to do so, delete this
exception statement from your version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
unit rxconst;
interface
{$I RX.INC}
const
RX_VERSION = $0002004B; { 2.75 }
resourcestring
sBrowse = 'Browse';
sDefaultFilter = 'All files (*.*)|*.*';
sDateDlgTitle = 'Select a Date';
sNextYear = 'Next Year|';
sNextMonth = 'Next Month|';
sPrevYear = 'Previous Year|';
sPrevMonth = 'Previous Month|';
sNotImplemented = 'Function not yet implemented';
sFileNotExec = 'File specified is not an executable file, dynamic-link library, or icon file';
sLoadLibError = 'Could not load ''%s'' library';
sDetails = 'Details';
sWindowsIcoFiles = 'Windows Ico files (*.ico)|*.ico|All files (*.*)|*.*';
sToCurDate = 'Set current date';
//TDualListDialog
SDualListSrcCaption = 'Source';
SDualListDestCaption = 'Destination';
SDualListCaption = 'Dual list dialog';
//TToolPanelSetupForm
sToolPanelSetup = 'Tool panel setup';
sVisibleButtons = 'Visible buttons';
sOptions = 'Options';
sAvaliableButtons = 'Avaliable buttons';
sShowCaption = 'Show caption';
sToolBarStyle = 'Tool bar style';
sToolBarStyle1 = 'Standard';
sToolBarStyle2 = 'Windows XP';
sToolBarStyle3 = 'Native';
sFlatButtons = 'Flat buttons';
sTransparent = 'Transparent';
sShowHint = 'Show hint';
sButtonAlign = 'Button align';
sButtonAlign1 = 'None';
sButtonAlign2 = 'Left';
sButtonAlign3 = 'Right';
// sGTKWidgetSet = 'GTK widget set';
// sGTK2WidgetSet = 'GTK 2 widget set';
// sWin32_64WidgetSet = 'Win32/Win64 widget set';
// sWinCEWidgetSet = 'WinCE widget set';
// sCarbonWidgetSet = 'Carbon widget set';
// sQTWidgetSet = 'QT widget set';
// sFpGUIWidgetSet = 'FpGUI widget set';
// sOtherGUIWidgetSet = 'Other gui';
sWidget = 'Widget : ';
sAppVersion = 'Version : ';
sLCLVersion = 'LCL Version: ';
sFpcVersion = 'FPC version : ';
sTargetCPU = 'Target CPU : ';
sTargetOS = 'Target OS : ';
sBuildDate = 'Build date : ';
sAbout = 'About';
sGeneral = 'General';
sLicense = 'License';
SOutOfRange = 'Out of range %d %d %d %d';
{ TRxHistoryNavigator }
sHistoryDesc = 'History - "%s"';
{ RxCloseFormValidator }
sCloseValidError = 'Error. Expected values...';
sReqValue = 'Error. Expected value for field %s.';
sExptControlNotFound = 'Control not found in validate %s.';
{ RxMDI }
sCloseWindows = 'Close window';
sCloseAllExceptThis = 'Close all except this';
sCloseAllWindows = 'Close all windows';
sErrorLinkedTaskPanel = 'Not assigned task panel';//Нет связанной панели задач';
{ TRxDateRangeEdit }
sFirstQuarter = 'First quarter';
sSecondQuarter = 'Second quarter';
sThirdQuarter = 'Third quarter';
sFourthQuarter = 'Fourth quarter';
sFirstHalfOfYear = 'First half of year';
sSecondHalfOfYear = 'Second half of year';
{ TFolderLister }
sFolderListerErr = '%s. Not assigned property MenuItem';
{ TConfigValues }
sVariableIsNotString = 'Variable %s is not string';
sVariableIsNotInteger = 'Variable %s is not integer';
sVariableIsNotFloat = 'Variable %s is not float';
sVariableIsNotDT = 'Variable %s is not date/time';
sVariableIsNotBoolean = 'Variable %s is not boolean';
{ TRxNotifierForm }
sClose = 'Close';
sCloseAfterSec = 'Close after %d sec';
implementation
end.

92
RXLib/rxtools/rxcrc.pas Normal file
View File

@@ -0,0 +1,92 @@
{ rxCRC unit
Copyright (C) 2005-2017 Lagunov Aleksey alexs@yandex.ru and Lazarus team
original conception from rx library for Delphi (c)
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version with the following modification:
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,and
to copy and distribute the resulting executable under terms of your choice,
provided that you also meet, for each linked independent module, the terms
and conditions of the license of that module. An independent module is a
module which is not derived from or based on this library. If you modify
this library, you may extend this exception to your version of the library,
but you are not obligated to do so. If you do not wish to do so, delete this
exception statement from your version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
unit rxCRC;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
function rxCRC8(Buffer:String;Polynom,Initial:Cardinal):Cardinal; overload;
function rxCRC8(Buffer:PByteArray; BufferLen:Cardinal; Polynom,Initial:Cardinal):Cardinal; overload;
implementation
{autor - hansotten
http://forum.lazarus.freepascal.org/index.php?topic=31532.msg202338#msg202338
}
function rxCRC8(Buffer:String;Polynom,Initial:Cardinal):Cardinal;
var
i,j : Integer;
begin
{ Result:=Initial;
for i:=1 to Length(Buffer) do
begin
Result:=Result xor Ord(buffer[i]);
for j:=0 to 7 do
begin
if (Result and $80)<>0 then
Result:=(Result shl 1) xor Polynom
else
Result:=Result shl 1;
end;
end;
Result:=Result and $ff;}
if Length(Buffer) > 0 then
Result:=rxCRC8(@Buffer[1], Length(Buffer), Polynom, Initial)
else
Result:=Initial;
end;
function rxCRC8(Buffer: PByteArray; BufferLen: Cardinal; Polynom, Initial: Cardinal
): Cardinal;
var
i,j : Integer;
begin
Result:=Initial;
for i:=0 to BufferLen-1 do
begin
Result:=Result xor Buffer^[i];
for j:=0 to 7 do
begin
if (Result and $80)<>0 then
Result:=(Result shl 1) xor Polynom
else
Result:=Result shl 1;
end;
end;
Result:=Result and $ff;
end;
end.

View File

@@ -0,0 +1,650 @@
{ DateUtil unit
Copyright (C) 2005-2017 Lagunov Aleksey alexs@yandex.ru and Lazarus team
original conception from rx library for Delphi (c)
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version with the following modification:
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,and
to copy and distribute the resulting executable under terms of your choice,
provided that you also meet, for each linked independent module, the terms
and conditions of the license of that module. An independent module is a
module which is not derived from or based on this library. If you modify
this library, you may extend this exception to your version of the library,
but you are not obligated to do so. If you do not wish to do so, delete this
exception statement from your version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
unit rxdateutil;
{$I rx.inc}
interface
function CurrentYear: Word;
function IsLeapYear(AYear: Integer): Boolean;
function DaysPerMonth(AYear, AMonth: Integer): Integer;
function FirstDayOfPrevMonth: TDateTime;
function LastDayOfPrevMonth: TDateTime;
function FirstDayOfNextMonth: TDateTime;
function ExtractDay(ADate: TDateTime): Word;
function ExtractMonth(ADate: TDateTime): Word;
function ExtractYear(ADate: TDateTime): Word;
function IncDate(ADate: TDateTime; Days, Months, Years: Integer): TDateTime;
function IncDay(ADate: TDateTime; Delta: Integer): TDateTime;
function IncMonth(ADate: TDateTime; Delta: Integer): TDateTime;
function IncYear(ADate: TDateTime; Delta: Integer): TDateTime;
function ValidDate(ADate: TDateTime): Boolean;
procedure DateDiff(Date1, Date2: TDateTime; var Days, Months, Years: Word);
function MonthsBetween(Date1, Date2: TDateTime): Double;
function DaysInPeriod(Date1, Date2: TDateTime): Longint;
{ Count days between Date1 and Date2 + 1, so if Date1 = Date2 result = 1 }
function DaysBetween(Date1, Date2: TDateTime): Longint;
{ The same as previous but if Date2 < Date1 result = 0 }
function IncTime(ATime: TDateTime; Hours, Minutes, Seconds, MSecs: Integer): TDateTime;
function IncHour(ATime: TDateTime; Delta: Integer): TDateTime;
function IncMinute(ATime: TDateTime; Delta: Integer): TDateTime;
function IncSecond(ATime: TDateTime; Delta: Integer): TDateTime;
function IncMSec(ATime: TDateTime; Delta: Integer): TDateTime;
function CutTime(ADate: TDateTime): TDateTime; { Set time to 00:00:00:00 }
type
TDateOrder = (doMDY, doDMY, doYMD);
TDayOfWeekName = (Sun, Mon, Tue, Wed, Thu, Fri, Sat);
TDaysOfWeek = set of TDayOfWeekName;
{ String to date conversions }
function GetDateOrder(const DateFormat: string): TDateOrder;
function MonthFromName(const S: string; MaxLen: Byte): Byte;
function StrToDateDef(const S: string; Default: TDateTime): TDateTime;
function StrToDateFmt(const DateFormat, S: string): TDateTime;
function StrToDateFmtDef(const DateFormat, S: string; Default: TDateTime): TDateTime;
function DefDateFormat(FourDigitYear: Boolean): string;
function DefDateMask(BlanksChar: Char; FourDigitYear: Boolean): string;
function NvlDate(DateValue, DefaultValue: TDateTime): TDateTime;
{$IFDEF WIN32}
function FormatLongDate(Value: TDateTime): string;
function FormatLongDateTime(Value: TDateTime): string;
{$ENDIF}
const
DefaultDateOrder = doDMY;
{$IFDEF USE_FOUR_DIGIT_YEAR}
var
FourDigitYear: Boolean;
{$ELSE}
function FourDigitYear: Boolean;
{$ENDIF USE_FOUR_DIGIT_YEAR}
const
CenturyOffset: Byte = 60;
NullDate: TDateTime = 0;
implementation
uses DateUtils, SysUtils, RXStrUtils, rxdconst{, DBConsts }{$IFDEF WIN32}, Windows{$ENDIF};
function NvlDate(DateValue, DefaultValue: TDateTime): TDateTime;
begin
if DateValue = NullDate then Result := DefaultValue
else Result := DateValue;
end;
function IsLeapYear(AYear: Integer): Boolean;
begin
Result := (AYear mod 4 = 0) and ((AYear mod 100 <> 0) or (AYear mod 400 = 0));
end;
function DaysPerMonth(AYear, AMonth: Integer): Integer;
const
DaysInMonth: array[1..12] of Integer =
(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
begin
Result := DaysInMonth[AMonth];
if (AMonth = 2) and IsLeapYear(AYear) then Inc(Result); { leap-year Feb is special }
end;
function FirstDayOfNextMonth: TDateTime;
var
Year, Month, Day: Word;
begin
DecodeDate(Date, Year, Month, Day);
Day := 1;
if Month < 12 then Inc(Month)
else begin
Inc(Year);
Month := 1;
end;
Result := EncodeDate(Year, Month, Day);
end;
function FirstDayOfPrevMonth: TDateTime;
var
Year, Month, Day: Word;
begin
DecodeDate(Date, Year, Month, Day);
Day := 1;
if Month > 1 then Dec(Month)
else begin
Dec(Year);
Month := 12;
end;
Result := EncodeDate(Year, Month, Day);
end;
function LastDayOfPrevMonth: TDateTime;
var
D: TDateTime;
Year, Month, Day: Word;
begin
D := FirstDayOfPrevMonth;
DecodeDate(D, Year, Month, Day);
Day := DaysPerMonth(Year, Month);
Result := EncodeDate(Year, Month, Day);
end;
function ExtractDay(ADate: TDateTime): Word;
var
M, Y: Word;
begin
DecodeDate(ADate, Y, M, Result);
end;
function ExtractMonth(ADate: TDateTime): Word;
var
D, Y: Word;
begin
DecodeDate(ADate, Y, Result, D);
end;
function ExtractYear(ADate: TDateTime): Word;
var
D, M: Word;
begin
DecodeDate(ADate, Result, M, D);
end;
function IncDate(ADate: TDateTime; Days, Months, Years: Integer): TDateTime;
var
D, M, Y: Word;
Day, Month, Year: Longint;
begin
DecodeDate(ADate, Y, M, D);
Year := Y; Month := M; Day := D;
Inc(Year, Years);
Inc(Year, Months div 12);
Inc(Month, Months mod 12);
if Month < 1 then begin
Inc(Month, 12);
Dec(Year);
end
else if Month > 12 then begin
Dec(Month, 12);
Inc(Year);
end;
if Day > DaysPerMonth(Year, Month) then Day := DaysPerMonth(Year, Month);
Result := EncodeDate(Year, Month, Day) + Days + Frac(ADate);
end;
procedure DateDiff(Date1, Date2: TDateTime; var Days, Months, Years: Word);
{ Corrected by Anatoly A. Sanko (2:450/73) }
var
DtSwap: TDateTime;
Day1, Day2, Month1, Month2, Year1, Year2: Word;
begin
if Date1 > Date2 then begin
DtSwap := Date1;
Date1 := Date2;
Date2 := DtSwap;
end;
DecodeDate(Date1, Year1, Month1, Day1);
DecodeDate(Date2, Year2, Month2, Day2);
Years := Year2 - Year1;
Months := 0;
Days := 0;
if Month2 < Month1 then begin
Inc(Months, 12);
Dec(Years);
end;
Inc(Months, Month2 - Month1);
if Day2 < Day1 then begin
Inc(Days, DaysPerMonth(Year1, Month1));
if Months = 0 then begin
Dec(Years);
Months := 11;
end
else Dec(Months);
end;
Inc(Days, Day2 - Day1);
end;
function IncDay(ADate: TDateTime; Delta: Integer): TDateTime;
begin
Result := ADate + Delta;
end;
function IncMonth(ADate: TDateTime; Delta: Integer): TDateTime;
begin
Result := IncDate(ADate, 0, Delta, 0);
end;
function IncYear(ADate: TDateTime; Delta: Integer): TDateTime;
begin
Result := IncDate(ADate, 0, 0, Delta);
end;
function MonthsBetween(Date1, Date2: TDateTime): Double;
var
D, M, Y: Word;
begin
DateDiff(Date1, Date2, D, M, Y);
Result := 12 * Y + M;
if (D > 1) and (D < 7) then Result := Result + 0.25
else if (D >= 7) and (D < 15) then Result := Result + 0.5
else if (D >= 15) and (D < 21) then Result := Result + 0.75
else if (D >= 21) then Result := Result + 1;
end;
function IsValidDate(Y, M, D: Word): Boolean;
begin
Result := (Y >= 1) and (Y <= 9999) and (M >= 1) and (M <= 12) and
(D >= 1) and (D <= DaysPerMonth(Y, M));
end;
function ValidDate(ADate: TDateTime): Boolean;
var
Year, Month, Day: Word;
begin
try
DecodeDate(ADate, Year, Month, Day);
Result := IsValidDate(Year, Month, Day);
except
Result := False;
end;
end;
function DaysInPeriod(Date1, Date2: TDateTime): Longint;
begin
if ValidDate(Date1) and ValidDate(Date2) then
Result := Abs(Trunc(Date2) - Trunc(Date1)) + 1
else Result := 0;
end;
function DaysBetween(Date1, Date2: TDateTime): Longint;
begin
Result := Trunc(Date2) - Trunc(Date1) + 1;
if Result < 0 then Result := 0;
end;
function IncTime(ATime: TDateTime; Hours, Minutes, Seconds,
MSecs: Integer): TDateTime;
begin
Result := ATime + (Hours div 24) + (((Hours mod 24) * 3600000 +
Minutes * 60000 + Seconds * 1000 + MSecs) / MSecsPerDay);
if Result < 0 then Result := Result + 1;
end;
function IncHour(ATime: TDateTime; Delta: Integer): TDateTime;
begin
Result := IncTime(ATime, Delta, 0, 0, 0);
end;
function IncMinute(ATime: TDateTime; Delta: Integer): TDateTime;
begin
Result := IncTime(ATime, 0, Delta, 0, 0);
end;
function IncSecond(ATime: TDateTime; Delta: Integer): TDateTime;
begin
Result := IncTime(ATime, 0, 0, Delta, 0);
end;
function IncMSec(ATime: TDateTime; Delta: Integer): TDateTime;
begin
Result := IncTime(ATime, 0, 0, 0, Delta);
end;
function CutTime(ADate: TDateTime): TDateTime;
begin
Result := Trunc(ADate);
end;
function CurrentYear: Word;
var
SystemTime: TSystemTime;
begin
GetLocalTime(SystemTime);
Result := SystemTime.Year;
end;
{ String to date conversions. Copied from SYSUTILS.PAS unit. }
procedure ScanBlanks(const S: string; var Pos: Integer);
var
I: Integer;
begin
I := Pos;
while (I <= Length(S)) and (S[I] = ' ') do Inc(I);
Pos := I;
end;
function ScanNumber(const S: string; MaxLength: Integer; var Pos: Integer;
var Number: Longint): Boolean;
var
I: Integer;
N: Word;
begin
Result := False;
ScanBlanks(S, Pos);
I := Pos;
N := 0;
while (I <= Length(S)) and (Longint(I - Pos) < MaxLength) and
(S[I] in ['0'..'9']) and (N < 1000) do
begin
N := N * 10 + (Ord(S[I]) - Ord('0'));
Inc(I);
end;
if I > Pos then begin
Pos := I;
Number := N;
Result := True;
end;
end;
function ScanChar(const S: string; var Pos: Integer; Ch: Char): Boolean;
begin
Result := False;
ScanBlanks(S, Pos);
if (Pos <= Length(S)) and (S[Pos] = Ch) then begin
Inc(Pos);
Result := True;
end;
end;
{$IFDEF RX_D3}
procedure ScanToNumber(const S: string; var Pos: Integer);
begin
while (Pos <= Length(S)) and not (S[Pos] in ['0'..'9']) do begin
if S[Pos] in LeadBytes then Inc(Pos);
Inc(Pos);
end;
end;
{$ENDIF}
function GetDateOrder(const DateFormat: string): TDateOrder;
var
I: Integer;
begin
Result := DefaultDateOrder;
I := 1;
while I <= Length(DateFormat) do begin
case Chr(Ord(DateFormat[I]) and $DF) of
{$IFDEF RX_D3}
'E': Result := doYMD;
{$ENDIF}
'Y': Result := doYMD;
'M': Result := doMDY;
'D': Result := doDMY;
else
Inc(I);
Continue;
end;
Exit;
end;
Result := DefaultDateOrder; { default }
end;
function ExpandYear(Year: Integer): Integer;
var
N: Longint;
begin
Result := Year;
if Result < 100 then begin
N := CurrentYear - CenturyOffset;
Inc(Result, N div 100 * 100);
if (CenturyOffset > 0) and (Result < N) then
Inc(Result, 100);
end;
end;
function ScanDate(const S, DateFormat: string; var Pos: Integer;
var Y, M, D: Integer): Boolean;
var
DateOrder: TDateOrder;
N1, N2, N3: Longint;
begin
Result := False;
Y := 0; M := 0; D := 0;
DateOrder := GetDateOrder(DateFormat);
if DefaultFormatSettings.ShortDateFormat[1] = 'g' then { skip over prefix text }
ScanToNumber(S, Pos);
if not (ScanNumber(S, MaxInt, Pos, N1) and ScanChar(S, Pos, DefaultFormatSettings.DateSeparator) and
ScanNumber(S, MaxInt, Pos, N2)) then Exit;
if ScanChar(S, Pos, DateSeparator) then begin
if not ScanNumber(S, MaxInt, Pos, N3) then Exit;
case DateOrder of
doMDY: begin Y := N3; M := N1; D := N2; end;
doDMY: begin Y := N3; M := N2; D := N1; end;
doYMD: begin Y := N1; M := N2; D := N3; end;
end;
Y := ExpandYear(Y);
end
else begin
Y := CurrentYear;
if DateOrder = doDMY then begin
D := N1; M := N2;
end
else begin
M := N1; D := N2;
end;
end;
ScanChar(S, Pos, DefaultFormatSettings.DateSeparator);
ScanBlanks(S, Pos);
(*
{$IFDEF RX_D3}
if SysLocale.FarEast and (System.Pos('ddd', ShortDateFormat) <> 0) then
begin { ignore trailing text }
if ShortTimeFormat[1] in ['0'..'9'] then { stop at time digit }
ScanToNumber(S, Pos)
else { stop at time prefix }
repeat
while (Pos <= Length(S)) and (S[Pos] <> ' ') do Inc(Pos);
ScanBlanks(S, Pos);
until (Pos > Length(S)) or
(AnsiCompareText(TimeAMString, Copy(S, Pos, Length(TimeAMString))) = 0) or
(AnsiCompareText(TimePMString, Copy(S, Pos, Length(TimePMString))) = 0);
end;
{$ENDIF RX_D3}
*)
Result := IsValidDate(Y, M, D) and (Pos > Length(S));
end;
function MonthFromName(const S: string; MaxLen: Byte): Byte;
begin
if Length(S) > 0 then
for Result := 1 to 12 do begin
if (Length(DefaultFormatSettings.LongMonthNames[Result]) > 0) and
(AnsiCompareText(Copy(S, 1, MaxLen),
Copy(DefaultFormatSettings.LongMonthNames[Result], 1, MaxLen)) = 0) then Exit;
end;
Result := 0;
end;
procedure ExtractMask(const Format, S: string; Ch: Char; Cnt: Integer;
var I: Integer; Blank, Default: Integer);
var
Tmp: string[20];
J, L: Integer;
begin
I := Default;
Ch := UpCase(Ch);
L := Length(Format);
if Length(S) < L then L := Length(S)
else if Length(S) > L then Exit;
J := Pos(MakeStr(Ch, Cnt), AnsiUpperCase(Format));
if J <= 0 then Exit;
Tmp := '';
while (UpCase(Format[J]) = Ch) and (J <= L) do begin
if S[J] <> ' ' then Tmp := Tmp + S[J];
Inc(J);
end;
if Tmp = '' then I := Blank
else if Cnt > 1 then begin
I := MonthFromName(Tmp, Length(Tmp));
if I = 0 then I := -1;
end
else I := StrToIntDef(Tmp, -1);
end;
function ScanDateStr(const Format, S: string; var D, M, Y: Integer): Boolean;
var
Pos: Integer;
begin
ExtractMask(Format, S, 'm', 3, M, -1, 0); { short month name? }
if M = 0 then ExtractMask(Format, S, 'm', 1, M, -1, 0);
ExtractMask(Format, S, 'd', 1, D, -1, 1);
ExtractMask(Format, S, 'y', 1, Y, -1, CurrentYear);
Y := ExpandYear(Y);
Result := IsValidDate(Y, M, D);
if not Result then begin
Pos := 1;
Result := ScanDate(S, Format, Pos, Y, M, D);
end;
end;
function InternalStrToDate(const DateFormat, S: string;
var Date: TDateTime): Boolean;
var
D, M, Y: Integer;
begin
if S = '' then begin
Date := NullDate;
Result := True;
end
else begin
Result := ScanDateStr(DateFormat, S, D, M, Y);
if Result then
try
Date := EncodeDate(Y, M, D);
except
Result := False;
end;
end;
end;
function StrToDateFmt(const DateFormat, S: string): TDateTime;
begin
if not InternalStrToDate(DateFormat, S, Result) then
raise EConvertError.CreateFmt({$IFDEF RX_D3} SInvalidDate {$ELSE}
LoadStr(SInvalidDate) {$ENDIF}, [S]);
end;
function StrToDateDef(const S: string; Default: TDateTime): TDateTime;
begin
if not InternalStrToDate(DefaultFormatSettings.ShortDateFormat, S, Result) then
Result := Trunc(Default);
end;
function StrToDateFmtDef(const DateFormat, S: string; Default: TDateTime): TDateTime;
begin
if not InternalStrToDate(DateFormat, S, Result) then
Result := Trunc(Default);
end;
function DefDateFormat(FourDigitYear: Boolean): string;
begin
if FourDigitYear then begin
case GetDateOrder(DefaultFormatSettings.ShortDateFormat) of
doMDY: Result := 'MM/DD/YYYY';
doDMY: Result := 'DD/MM/YYYY';
doYMD: Result := 'YYYY/MM/DD';
end;
end
else begin
case GetDateOrder(DefaultFormatSettings.ShortDateFormat) of
doMDY: Result := 'MM/DD/YY';
doDMY: Result := 'DD/MM/YY';
doYMD: Result := 'YY/MM/DD';
end;
end;
end;
function DefDateMask(BlanksChar: Char; FourDigitYear: Boolean): string;
begin
if FourDigitYear then begin
case GetDateOrder(DefaultFormatSettings.ShortDateFormat) of
doMDY, doDMY: Result := '!99/99/9999;1;';
doYMD: Result := '!9999/99/99;1;';
end;
end
else begin
case GetDateOrder(DefaultFormatSettings.ShortDateFormat) of
doMDY, doDMY: Result := '!99/99/99;1;';
doYMD: Result := '!99/99/99;1;';
end;
end;
if Result <> '' then Result := Result + BlanksChar;
end;
{$IFDEF WIN32}
function FormatLongDate(Value: TDateTime): string;
var
Buffer: array[0..1023] of Char;
SystemTime: TSystemTime;
begin
{$IFDEF RX_D3}
DateTimeToSystemTime(Value, SystemTime);
{$ELSE}
with SystemTime do
begin
DecodeDate(Value, wYear, wMonth, wDay);
DecodeTime(Value, wHour, wMinute, wSecond, wMilliseconds);
end;
{$ENDIF}
SetString(Result, Buffer, GetDateFormat(GetThreadLocale, DATE_LONGDATE,
@SystemTime, nil, Buffer, SizeOf(Buffer) - 1));
Result := TrimRight(Result);
end;
function FormatLongDateTime(Value: TDateTime): string;
begin
if Value <> NullDate then
Result := FormatLongDate(Value) + FormatDateTime(' tt', Value)
else Result := '';
end;
{$ENDIF WIN32}
{$IFNDEF USE_FOUR_DIGIT_YEAR}
function FourDigitYear: Boolean;
begin
Result := Pos('YYYY', AnsiUpperCase(DefaultFormatSettings.ShortDateFormat)) > 0;
end;
{$ENDIF}
{$IFDEF USE_FOUR_DIGIT_YEAR}
initialization
FourDigitYear := Pos('YYYY', AnsiUpperCase(ShortDateFormat)) > 0;
{$ENDIF}
end.

280
RXLib/rxtools/rxdconst.pas Normal file
View File

@@ -0,0 +1,280 @@
{ string const unit fo DB-aware modules
Copyright (C) 2005-2017 Lagunov Aleksey alexs75@yandex.ru and Lazarus team
original conception from rx library for Delphi (c)
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version with the following modification:
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,and
to copy and distribute the resulting executable under terms of your choice,
provided that you also meet, for each linked independent module, the terms
and conditions of the license of that module. An independent module is a
module which is not derived from or based on this library. If you modify
this library, you may extend this exception to your version of the library,
but you are not obligated to do so. If you do not wish to do so, delete this
exception statement from your version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
unit rxdconst;
interface
resourcestring
{ RxDBCtrl }
SLocalDatabase = 'Unable complete this operation on local dataset';
SRetryLogin = 'Retry to connect with database?';
SExprNotBoolean = 'Field ''%s'' is not boolean';
SExprBadNullTest = 'NULL-values enabled in ''='' and ''<>''';
SExprBadField = 'Field ''%s'' not used in filter expression';
SCaptureFilter = 'Control locked by filter';
SNotCaptureFilter = 'Control needs to be locked by filter';
SInactiveData = 'inactive';
SBrowseData = 'browse';
SEditData = 'editing';
SInsertData = 'append';
SSetKeyData = 'find';
SCalcFieldsData = 'calc';
SRegistration = 'Register';
SAppTitleLabel = 'Application "%s"';
SHintLabel = 'Enter your user name and password';
SUserNameLabel = '&User name:';
SPasswordLabel = '&Password:';
SMore1 = '&More >>';
SMore2 = '&Less <<';
SInvalidUserName = 'User name or password is not valid';
SChangePassword = 'Change password';
SOldPasswordLabel = '&Old password:';
SNewPasswordLabel = '&New password:';
SConfirmPasswordLabel = '&Confirm:';
SPasswordChanged = 'Password changed';
SPasswordNotChanged = 'Password not changed';
SPasswordsMismatch = 'New password and confirmation not equal';
SDBExceptCaption = 'Error in DB engine';
SServerErrorLabel = 'Server error';
SErrorMsgLabel = 'Error message';
SNextButton = '&Next';
SPrevButton = '&Prior';
SExprIncorrect = 'Error in filter expression';
SExprTermination = 'Error in filter end';
SExprNameError = 'Error in filed name';
SExprStringError = 'Error in string const';
SExprInvalidChar = 'Error symbol in expression: ''%s''';
SExprNoRParen = 'Error '')'', error: %s';
SExprExpected = 'Error %s';
SExprBadCompare = 'Compare opertion needs field and const';
SConfirmSave = 'Data changed. Save?';
SDatabaseName = 'Database locked: %s';
SUnlockCaption = 'Unlock';
SUnlockHint = 'Enter your password';
SDeleteMultipleRecords = 'Delete all selected records?';
SDBComboBoxFieldNotAssigned = '%s:TDBComboBox - DataField not assigned';
//SPropDefByLookup = 'PropDefByLookup';
//SDataSourceFixed = 'SDataSourceFixed';
SCircularDataLink = 'Circular data link';
sRxAscendign = 'Ascendign';
sRxDescending = 'Descending';
sRxAllFields = 'All fields';
sRxFieldsLookupDisplay = 'Fields as LookupDisplay';
sRxFillFieldsLookupDisp = 'Fill fields in LookupDisplay property';
sRxSortFieldsDisplay = 'Fields as SortField';
sRxFillSortFieldsDisp = 'Fill fields in SortField property';
SDeleteRecordQuestion = 'Delete record?';
SFieldTypeMismatch = 'Type mismatch for field ''%s'', expecting: %s actual: %s';
SInvalidDate = 'Invalid Date';
SFieldRequired = 'Field ''%s'' must have a value';
SNotEditing = 'Dataset not in edit or insert mode';
SUnknownFieldType = 'SUnknownFieldType %s';
SFieldReadOnly = 'SFieldReadOnly %s';
//RXDBgrid
sRxDBGridFind = 'Find data';
sRxDBGridFilter = 'Filter data';
sRxDBGridFilterSimple = 'Filter in table';
sRxDBGridFilterClear = 'Clear filter';
sRxDBGridSortByColumns = 'Sort data for columns';
sRxDBGridSelectColumns = 'Select visible columns';
sRxDBGridEmptyFilter = '(Empty)';
sRxDBGridAllFilter = '(All values)';
sRxDBGridNotEmptyFilter = '(Not empty)';
sRxDBGridSelectAllRows = 'Select all rows';
sRxDBGridCopyCellValue = 'Copy cell value';
sRxDBGridOptimizeColWidth = 'Optimize column width';
//RxDBGrid filter form
sRxFilterFormSelectExp = 'Enter filter expression for data in table:';
sRxFilterFormOnField = 'On field :';
sRxFilterFormOperaion = 'Operation :';
sRxFilterFormCondition = 'Condition :';
sRxFilterFormOperand = 'Operand :';
sRxFilterFormEnd = 'end.';
sRxFilterFormClear = 'Clear filter';
sRxFilterFormCancel = 'Cancel';
sRxFilterFormApply = 'Apply';
sRxFilterFormCaption = 'Filter conditions';
//TrxSortByForm
sRxSortByFormCaption = 'Sort on field';
sRxSortByFormAllFields = '&Fields in dataset:';
sRxSortByFormSortFields = '&Selected fields:';
sRxSortByFormSortOrder = 'Select f&ield for sort data:';
sRxSortByFormAddField = '&Add field';
sRxSortByFormRemoveField = '&Remove';
sRxSortByFormMoveUpField = '&Up';
sRxSortByFormMoveDnField = '&Down';
sRxSortByFormCaseInsens = '&Case insensitive sort';
//TRxMemoryData
SMemNoRecords = 'No data found';
SInvalidFields = 'No fields defined';
//TrxDBGridFindForm
sRxDbGridFindCaption = 'Find data';
sRxDbGridFindText = 'Text to find';
sRxDbGridFindOnField = 'Find on field';
sRxDbGridFindCaseSens = 'Case sensetive';
sRxDbGridFindPartial = 'Partial key';
sRxDbGridFindDirecion = 'Direction';
sRxDbGridFindRangeAll = 'All';
sRxDbGridFindRangeForw = 'Forward';
sRxDbGridFindRangeBack = 'Backward';
sRxFindMore = 'Find more';
//TrxDBGridColumsForm
sRxDbGridSelColCaption = 'Grid columns';
sRxDbGridSelColHint1 = 'Move selected column up';
sRxDbGridSelColHint2 = 'Move selected column down';
sRxDbGridSelApplyCaption = 'Apply';
sRxDbGridSelApplyHint = 'Apply current column settings';
//seldsfrm
sRxBorrowStructure = 'Borrow structure...';
sRxSelectDatasetStruct = 'Select dataset to copy to';
sRxCopyOnlyMetadata = 'Copy only metadata';
sRxSourceDataset = 'Source dataset';
sUnknownXMLDatasetFormat = 'Unknown XML Dataset format';
sExportParams = 'Export params';
sToolsExportSpeadSheet = 'Export to speadsheet';
sToolsExportPDF = 'Export to PDF file';
sExportFileName = 'Export file name';
sOpenAfterExport = 'Open after export';
sPageName = 'Page name';
sExportColumnHeader = 'Export column header';
sExportColumnFooter = 'Export column footer';
sExportCellColors = 'Export cell colors';
sExportFormula = 'Export footer formula';
sExportImages = 'Export images';
sExportSelectedRows = 'Export only selected rows';
sExportHideZeroValues = 'Hide zero values';
sMergeCells = 'Merge cell''s';
sExportGroupData = 'Export group data';
sOverwriteExisting = 'Overwrite existing';
sShowColumnHeaderOnAllPage = 'Show column header on all pages';
sPageMargins = 'Page margins';
sLeftCaption = 'Left';
sTopCaption = 'Top';
sRightCaption = 'Right';
sBottomCaption = 'Bottom';
sReportTitle = 'Report title';
sOrientation = 'Orientation';
sPortrait = 'Portrait';
sLandscape = 'Landscape';
sPrintOptions = 'Print options';
sPaperType = 'Paper type';
sTitleColor = 'Title color';
sGlobal = 'Global';
sPDFOptions = 'PDF options';
sOutLine = 'Out line';
sCompressText = 'Compress text';
sCompressFonts = 'Compress fonts';
sCompressImages = 'Compress images';
sUseRawJPEG = 'Use raw JPEG';
sShowTitle = 'Show column title';
sShowFooter = 'Show footer';
sShowFooterColor = 'Show footer color';
sShowGridColor = 'Show grid color';
sShowReportTitle = 'Show report title';
sPrintGrid = 'Print grid';
sHideZeroValues = 'Hide zero values';
sRxDBGridToolsCaption = 'Totals row';
sfvtNon = 'None';
sfvtSum = 'Sum';
sfvtAvg = 'AVG';
sfvtCount = 'Count';
sfvtFieldValue = 'Field value';
sfvtStaticText = 'Static text';
sfvtMax = 'Max value';
sfvtMin = 'Min value';
sfvtRecNo = 'Record no';
sSetupTotalRow = 'Setup total row';
sCollumnName = 'Column name';
sFunction = 'Function';
sBlobText = '(blob)';
sOtherOptions = 'Other options';
sFooterRowColor = 'Footer row color';
//TRxDBGrid_PopUpFilterForm
sHintShowOnlyCurrentItem = 'Show only current item';
sHintHideOnlyCurrentItem = 'Hide only current item';
sSorting = 'Sorting';
sAscending = 'Ascending';
sDescending = 'Descending';
sQuickFilter = 'Quick filter';
sClearFilter = 'Clear filter';
sEmptyValues = 'Empty values';
sNotEmpty = 'Not empty';
sStandartFilter = 'Standart filter';
sAllValues = 'All values';
const
{ The following strings should not be localized }
sAction = '.Action';
sCount = '.Count';
sVisible = '.Visible';
sItem = '.Item';
sWidth = '.Width';
sTop = '.Top';
sVersion = '.Version';
sLeft = '.Left';
sShowHint = '.ShowHint';
sShowCaption = '.ShowCaption';
sToolBarStyle = '.ToolBarStyle';
sButtonAllign = '.ButtonAllign';
sOptions = '.Options';
sCaption = '.Caption';
sIndex = '.Index';
sSortMarker = '.SortMarker';
sSortField = '.SortField';
sShortCut = '.ShortCut';
implementation
end.

View File

@@ -0,0 +1,247 @@
{ rxFileUtils is part of RxFPC library
Copyright (C) 2005-2017 Lagunov Aleksey alexs@yandex.ru and Lazarus team
original conception from rx library for Delphi (c)
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version with the following modification:
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,and
to copy and distribute the resulting executable under terms of your choice,
provided that you also meet, for each linked independent module, the terms
and conditions of the license of that module. An independent module is a
module which is not derived from or based on this library. If you modify
this library, you may extend this exception to your version of the library,
but you are not obligated to do so. If you do not wish to do so, delete this
exception statement from your version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
unit rxFileUtils;
{$I rx.inc}
interface
uses
SysUtils;
function GetFileOwnerUser(const SearchDomain, FileName:String):String;
procedure GetFileOwnerData(const SearchDomain, FileName:String;out UserName, DomainName:string);
function NormalizeDirectoryName(const DirName:string):string;
function GetUserName:string;
function IsValidFileNameChar(const AChar: Char): Boolean;inline;
function NormalizeFileName(const FileName:string; AReplaceChar:char = '_'):string; //funtion only for filename - without folder name
const
{$IFDEF WINDOWS}
FileNameDisabledChars = [#0 .. #31, '"', '*', '/', ':', '<', '>', '?', '\' , '|'];
{$ELSE}
FileNameDisabledChars = [#0 .. #31, '/', '~'];
{$ENDIF}
implementation
uses
strutils
{$IFDEF WINDOWS}
, Windows
{$ENDIF}
{$IFDEF LINUX}
, BaseUnix, users
{$ENDIF}
;
{$IF DEFINED(WINDOWS) AND NOT DEFINED(WINCE)}
function LStrError(const Ernum: Longint; const UseUTF8: Boolean = False): string;
const
MAX_ERROR = 1024;
var
Tmp: string;
TmpW: widestring;
begin
Result := ' [' + IntToStr(Ernum) + ']: ';
if USEUtf8 then begin
SetLength(TmpW, MAX_ERROR);
SetLength(TmpW, FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM or
FORMAT_MESSAGE_IGNORE_INSERTS or
FORMAT_MESSAGE_ARGUMENT_ARRAY,
nil, Ernum, 0, @TmpW[1], MAX_ERROR, nil));
Tmp := UTF8Encode(TmpW);
end else begin
SetLength(Tmp, MAX_ERROR);
SetLength(Tmp, FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM or
FORMAT_MESSAGE_IGNORE_INSERTS or
FORMAT_MESSAGE_ARGUMENT_ARRAY,
nil, Ernum, 0, @Tmp[1], MAX_ERROR, nil));
end;
if Length(Tmp) > 2 then
Delete(Tmp, Length(Tmp)-1, 2);
Result := Result + Tmp;
end;
procedure GetFileNameOwner(const SearchDomain, FileName: String; out UserName, DomainName: string);
var
RCode, RC1:WINBOOL;
SDSize:DWORD; // Size of security descriptor
FAccountName:PChar; // Account name
lngAccountLen:DWORD; // Length of account name
FDomainName:PChar; // Domain name
lngDomainLen:DWORD; // Length of domain name
ptrUse:SID_NAME_USE; // Pointer to SID_NAME_USE
ptrOwner:PSID;
P:PByteArray;
begin
ptrOwner:=nil;
SDSize:=0;
P:=nil;
UserName:='';
DomainName:='';
RCode := GetFileSecurity(PChar(FileName), OWNER_SECURITY_INFORMATION, nil, 0, @SDSize);
GetMem(P, SDSize);
FillChar(P^, SDSize, 0);
RCode := GetFileSecurity(PChar(FileName), OWNER_SECURITY_INFORMATION, Pointer(P), SDSize, @SDSize);
if not RCode then
raise Exception.Create(LStrError(GetLastError, true));
RCode := GetSecurityDescriptorOwner(Pointer(P), ptrOwner, @RC1);
if not RCode then
raise Exception.Create(LStrError(GetLastError, true));
lngAccountLen:=0;
lngDomainLen:=0;
RCode := LookupAccountSid(PChar(SearchDomain), ptrOwner, nil, lngAccountLen, nil, lngDomainLen, ptrUse);
//' Configure the strings' buffer sizes
GetMem(FAccountName, lngAccountLen);
FillChar(FAccountName^, lngAccountLen, 0);
GetMem(FDomainName, lngDomainLen);
FillChar(FDomainName^, lngDomainLen, 0);
RCode:=LookupAccountSid(PChar(SearchDomain), ptrOwner, FAccountName, lngAccountLen, FDomainName, lngDomainLen, ptrUse);
if not RCode then
raise Exception.Create(LStrError(GetLastError, true));
UserName:=FAccountName;
DomainName:=FDomainName;
Freemem(P, SDSize);
Freemem(FAccountName, lngAccountLen);
Freemem(FDomainName, lngDomainLen);
end;
{$ELSE}
{$ENDIF}
function GetFileOwnerUser(const SearchDomain, FileName: String): String;
var
S:string;
{$IFDEF LINUX}
FStat: stat;
{$ENDIF}
begin
Result:='';
{$IF DEFINED(WINDOWS) AND NOT DEFINED(WINCE)}
(* GetFileNameOwner(UTF8ToSys(SearchDomain), UTF8ToSys(FileName), Result, S);
Result:=UTF8Encode(Result);*)
GetFileNameOwner(SearchDomain, FileName, Result, S);
{$ENDIF}
{$IFDEF LINUX}
if FpStat(FileName, FStat) = 0 then
Result:=users.GetUserName(FStat.uid);
{$ENDIF}
end;
procedure GetFileOwnerData(const SearchDomain, FileName: String; out UserName,
DomainName: string);
{$IF DEFINED(WINDOWS) AND NOT DEFINED(WINCE)}
{$ENDIF}
{$IFDEF LINUX}
var
SR: stat;
{$ENDIF}
begin
UserName:='';
DomainName:='';
{$IF DEFINED(WINDOWS) AND NOT DEFINED(WINCE)}
{ GetFileNameOwner(UTF8ToSys(SearchDomain), UTF8ToSys(FileName), UserName, DomainName);
UserName:=UTF8Encode(UserName);
DomainName:=UTF8Encode(DomainName);}
GetFileNameOwner(SearchDomain, FileName, UserName, DomainName);
{$ENDIF}
{$IFDEF LINUX}
FpStat(FileName, SR);
UserName:=users.GetUserName(SR.uid);
if Pos('\', UserName) > 0 then
DomainName:=Copy2SymbDel(UserName, '\') //for unix samba WinBIND
else
DomainName:='';//IntToStr( SR.gid);
{$ENDIF}
end;
{replase any dir separators '\' or '/' to system directory separator }
function NormalizeDirectoryName(const DirName: string): string;
var
i:integer;
begin
Result:=DirName;
for i:=1 to Length(Result) do
if Result[i] in ['/', '\'] then
Result[i]:=DirectorySeparator;
end;
function GetUserName: string;
{$IF DEFINED(WINDOWS) AND NOT DEFINED(WINCE)}
var
A:array [0..256] of Char;
L:DWORD;
{$ENDIF}
begin
{$IF DEFINED(WINDOWS) AND NOT DEFINED(WINCE)}
FillChar(A, SizeOf(A), 0);
L:=SizeOf(A)-1;
if Windows.GetUserNameA(@A, L) then
begin
(* Result:=SysToUTF8(StrPas(@A)); *)
Result:=StrPas(@A);
end
else
(*Result:=GetEnvironmentVariableUTF8('USERNAME');*)
Result:=SysUtils.GetEnvironmentVariable('USERNAME');
{$ELSE}
Result:=GetEnvironmentVariable('USER');
{$ENDIF}
end;
function IsValidFileNameChar(const AChar: Char): Boolean;
begin
Result:=not (AChar in FileNameDisabledChars);
end;
function NormalizeFileName(const FileName: string; AReplaceChar:char = '_'): string;
var
i:integer;
begin
Result:=FileName;
for i:=1 to Length(Result) do
if not IsValidFileNameChar(Result[i]) then
Result[i]:=AReplaceChar;
end;
end.

1132
RXLib/rxtools/rxstrutils.pas Normal file

File diff suppressed because it is too large Load Diff

120
RXLib/rxtools/rxutils.pas Normal file
View File

@@ -0,0 +1,120 @@
{ RxStrUtils unit
Copyright (C) 2005-2017 Lagunov Aleksey alexs@yandex.ru and Lazarus team
original conception from rx library for Delphi (c)
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version with the following modification:
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,and
to copy and distribute the resulting executable under terms of your choice,
provided that you also meet, for each linked independent module, the terms
and conditions of the license of that module. An independent module is a
module which is not derived from or based on this library. If you modify
this library, you may extend this exception to your version of the library,
but you are not obligated to do so. If you do not wish to do so, delete this
exception statement from your version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
unit rxutils;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
procedure SwapValues (var X, Y : Byte); inline; overload;
procedure SwapValues (var X, Y : Word); inline; overload;
procedure SwapValues (var X, Y : Integer); inline; overload;
//procedure SwapValues (var X, Y : Longint); inline; overload;
procedure SwapValues (var X, Y : Cardinal); inline; overload;
procedure SwapValues (var X, Y : QWord); inline; overload;
procedure SwapValues (var X, Y : Int64); inline; overload;
{procedure Swap (X : Integer) : Integer;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_word];
function swap (X : Longint) : Longint;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_long];
function Swap (X : Cardinal) : Cardinal;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_long];
function Swap (X : QWord) : QWord;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_qword];
function swap (X : Int64) : Int64;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_qword];
}
implementation
procedure SwapValues(var X, Y: Byte);
var
T: Byte;
begin
T:=X;
X:=Y;
Y:=T;
end;
procedure SwapValues(var X, Y: Word);
var
T: Word;
begin
T:=X;
X:=Y;
Y:=T;
end;
procedure SwapValues(var X, Y: Integer);
var
T: Integer;
begin
T:=X;
X:=Y;
Y:=T;
end;
{
procedure SwapValues(var X, Y: Longint);
var
T: LongInt;
begin
T:=X;
X:=Y;
Y:=T;
end;
}
procedure SwapValues(var X, Y: Cardinal);
var
T: Cardinal;
begin
T:=X;
X:=Y;
Y:=T;
end;
procedure SwapValues(var X, Y: QWord);
var
T: QWord;
begin
T:=X;
X:=Y;
Y:=T;
end;
procedure SwapValues(var X, Y: Int64);
var
T: Int64;
begin
T:=X;
X:=Y;
Y:=T;
end;
end.