+ Patch for localization of string properties

This commit is contained in:
michael 2004-12-27 13:51:37 +00:00
parent 0a6f2109aa
commit 3eb1516253
3 changed files with 30 additions and 5 deletions

View File

@ -834,6 +834,10 @@ type
TCreateComponentEvent = procedure(Reader: TReader; TCreateComponentEvent = procedure(Reader: TReader;
ComponentClass: TComponentClass; var Component: TComponent) of object; ComponentClass: TComponentClass; var Component: TComponent) of object;
TReadWriteStringPropertyEvent = procedure(Sender:TObject;
const Instance: TPersistent; PropInfo: PPropInfo;
var Content:string) of object;
TReader = class(TFiler) TReader = class(TFiler)
private private
FDriver: TAbstractObjectReader; FDriver: TAbstractObjectReader;
@ -852,6 +856,7 @@ type
FOnCreateComponent: TCreateComponentEvent; FOnCreateComponent: TCreateComponentEvent;
FPropName: string; FPropName: string;
FCanHandleExcepts: Boolean; FCanHandleExcepts: Boolean;
FOnReadStringProperty:TReadWriteStringPropertyEvent;
procedure DoFixupReferences; procedure DoFixupReferences;
procedure FreeFixups; procedure FreeFixups;
function FindComponentClass(const AClassName: string): TComponentClass; function FindComponentClass(const AClassName: string): TComponentClass;
@ -911,6 +916,7 @@ type
property OnAncestorNotFound: TAncestorNotFoundEvent read FOnAncestorNotFound write FOnAncestorNotFound; property OnAncestorNotFound: TAncestorNotFoundEvent read FOnAncestorNotFound write FOnAncestorNotFound;
property OnCreateComponent: TCreateComponentEvent read FOnCreateComponent write FOnCreateComponent; property OnCreateComponent: TCreateComponentEvent read FOnCreateComponent write FOnCreateComponent;
property OnFindComponentClass: TFindComponentClassEvent read FOnFindComponentClass write FOnFindComponentClass; property OnFindComponentClass: TFindComponentClassEvent read FOnFindComponentClass write FOnFindComponentClass;
property OnReadStringProperty: TReadWriteStringPropertyEvent read FOnReadStringProperty write FOnReadStringProperty;
end; end;
@ -1002,6 +1008,7 @@ type
FChildPos: Integer; FChildPos: Integer;
FOnFindAncestor: TFindAncestorEvent; FOnFindAncestor: TFindAncestorEvent;
FOnWriteMethodProperty: TWriteMethodPropertyEvent; FOnWriteMethodProperty: TWriteMethodPropertyEvent;
FOnWriteStringProperty: TReadWriteStringPropertyEvent;
procedure AddToAncestorList(Component: TComponent); procedure AddToAncestorList(Component: TComponent);
procedure WriteComponentData(Instance: TComponent); procedure WriteComponentData(Instance: TComponent);
protected protected
@ -1039,6 +1046,7 @@ type
property RootAncestor: TComponent read FRootAncestor write FRootAncestor; property RootAncestor: TComponent read FRootAncestor write FRootAncestor;
property OnFindAncestor: TFindAncestorEvent read FOnFindAncestor write FOnFindAncestor; property OnFindAncestor: TFindAncestorEvent read FOnFindAncestor write FOnFindAncestor;
property OnWriteMethodProperty: TWriteMethodPropertyEvent read FOnWriteMethodProperty write FOnWriteMethodProperty; property OnWriteMethodProperty: TWriteMethodPropertyEvent read FOnWriteMethodProperty write FOnWriteMethodProperty;
property OnWriteStringProperty: TReadWriteStringPropertyEvent read FOnWriteStringProperty write FOnWriteStringProperty;
property Driver: TAbstractObjectWriter read FDriver; property Driver: TAbstractObjectWriter read FDriver;
end; end;
@ -1470,7 +1478,10 @@ function LineStart(Buffer, BufPos: PChar): PChar;
{ {
$Log$ $Log$
Revision 1.3 2004-08-07 16:32:52 florian Revision 1.4 2004-12-27 13:53:27 michael
+ Patch for localization of string properties
Revision 1.3 2004/08/07 16:32:52 florian
* tcomponent.destroying is now called in tcomponent.beforedestruction * tcomponent.destroying is now called in tcomponent.beforedestruction
Revision 1.2 2003/10/07 19:41:11 marco Revision 1.2 2003/10/07 19:41:11 marco

View File

@ -1017,6 +1017,7 @@ var
Ident: String; Ident: String;
Method: TMethod; Method: TMethod;
Handled: Boolean; Handled: Boolean;
TmpStr: String;
begin begin
if not Assigned(PPropInfo(PropInfo)^.SetProc) then if not Assigned(PPropInfo(PropInfo)^.SetProc) then
raise EReadError.Create(SReadOnlyProperty); raise EReadError.Create(SReadOnlyProperty);
@ -1072,7 +1073,12 @@ begin
end; end;
end; end;
tkSString, tkLString, tkAString, tkWString: tkSString, tkLString, tkAString, tkWString:
SetStrProp(Instance, PropInfo, ReadString); begin
TmpStr:=ReadString;
if Assigned(FOnReadStringProperty) then
FOnReadStringProperty(Self,Instance,PropInfo,TmpStr);
SetStrProp(Instance, PropInfo, TmpStr);
end;
{!!!: tkVariant} {!!!: tkVariant}
tkClass: tkClass:
case FDriver.NextValue of case FDriver.NextValue of
@ -1304,7 +1310,10 @@ end;
{ {
$Log$ $Log$
Revision 1.2 2003-12-15 08:57:24 michael Revision 1.3 2004-12-27 13:53:27 michael
+ Patch for localization of string properties
Revision 1.2 2003/12/15 08:57:24 michael
Patch from Darek Mazur for reading idents from property stream Patch from Darek Mazur for reading idents from property stream
Revision 1.2 2003/12/15 08:55:56 michael Revision 1.2 2003/12/15 08:55:56 michael
@ -1324,4 +1333,4 @@ end;
Revision 1.6 2002/09/07 15:15:25 peter Revision 1.6 2002/09/07 15:15:25 peter
* old logs removed and tabs fixed * old logs removed and tabs fixed
} }

View File

@ -697,6 +697,8 @@ begin
if StrValue <> DefStrValue then if StrValue <> DefStrValue then
begin begin
Driver.BeginProperty(FPropPath + PPropInfo(PropInfo)^.Name); Driver.BeginProperty(FPropPath + PPropInfo(PropInfo)^.Name);
if Assigned(FOnWriteStringProperty) then
FOnWriteStringProperty(Self,Instance,PropInfo,StrValue);
WriteString(StrValue); WriteString(StrValue);
Driver.EndProperty; Driver.EndProperty;
end; end;
@ -832,7 +834,10 @@ end;}
{ {
$Log$ $Log$
Revision 1.1 2003-10-06 20:33:58 peter Revision 1.2 2004-12-27 13:53:27 michael
+ Patch for localization of string properties
Revision 1.1 2003/10/06 20:33:58 peter
* classes moved to rtl for 1.1 * classes moved to rtl for 1.1
* classes .inc and classes.pp files moved to fcl/classes for * classes .inc and classes.pp files moved to fcl/classes for
backwards 1.0.x compatiblity to have it in the fcl backwards 1.0.x compatiblity to have it in the fcl