From: <jfu...@us...> - 2013-04-09 22:22:39
|
Revision: 13503 http://jvcl.svn.sourceforge.net/jvcl/?rev=13503&view=rev Author: jfudickar Date: 2013-04-09 22:22:31 +0000 (Tue, 09 Apr 2013) Log Message: ----------- TJvCustomAppStorage.SetXMLProperty and TJvCustomAppXMLStorage.DoSetXMLProperty Added This enables the possibility to save additional xml properties when generating xml files. Modified Paths: -------------- trunk/jvcl/run/JvAppStorage.pas trunk/jvcl/run/JvAppXMLStorage.pas Modified: trunk/jvcl/run/JvAppStorage.pas =================================================================== --- trunk/jvcl/run/JvAppStorage.pas 2013-03-24 21:24:15 UTC (rev 13502) +++ trunk/jvcl/run/JvAppStorage.pas 2013-04-09 22:22:31 UTC (rev 13503) @@ -426,10 +426,14 @@ function GetPhysicalReadOnly: Boolean; virtual; property SubStorages: TJvAppSubStorages read FSubStorages write SetSubStorages; - function DecodeStrToDateTime(Value: string): TDateTime; virtual; + function DecodeStrToDateTime(const Value: string): TDateTime; virtual; function EncodeDateTimeToStr(Value: TDateTime): string; virtual; procedure Loaded; override; procedure DoError(const msg: string); + //1 Sets a xml property for a given path, this is only implemented for XML Appstorage + procedure DoSetXMLProperty(const Path, Name, Value : string); virtual; + //1 Sets a xml property for a given path, this is only implemented for XML Appstorage + procedure SetXMLPropertyInt(const Path, Name, Value : string); virtual; function GetFormatSettings: TFormatSettings; function ReadListItemCount(const Path: string; const ItemName: string = cItem): Integer; virtual; procedure WriteListItemCount(const Path: string; const ItemCount: Integer; const ItemName: string = cItem); virtual; @@ -654,6 +658,8 @@ procedure EnablePropertyValueCrypt; { Disables the Cryption of Property-Values (Only String-Values) } procedure DisablePropertyValueCrypt; + //1 Sets a xml property for a given path, this is only implemented for XML Appstorage + procedure SetXMLProperty(const Path, Name, Value : string); { Returns the current state if Property-Value Cryption is enabled } function IsPropertyValueCryptEnabled: Boolean; function ItemNameIndexPath(const ItemName: string; const Index: Integer): string; virtual; @@ -3170,7 +3176,7 @@ end; end; -function TJvCustomAppStorage.DecodeStrToDateTime(Value: string): TDateTime; +function TJvCustomAppStorage.DecodeStrToDateTime(const Value: string): TDateTime; begin if StorageOptions.UseTranslateStringEngineDateTimeFormats then try @@ -3183,6 +3189,26 @@ Result := StrToDateTime(Value); end; +procedure TJvCustomAppStorage.DoSetXMLProperty(const Path, Name, Value : string); +begin + +end; + +procedure TJvCustomAppStorage.SetXMLProperty(const Path, Name, Value : string); +var + TargetStore: TJvCustomAppStorage; + TargetPath: string; +begin + ResolvePath(Path, TargetStore, TargetPath); + if not TargetStore.ReadOnly then + TargetStore.SetXMLPropertyInt(TargetPath, Name, Value); +end; + +procedure TJvCustomAppStorage.SetXMLPropertyInt(const Path, Name, Value : string); +begin + DoSetXMLProperty(Path, Name, Value); +end; + function TJvCustomAppStorage.EncodeDateTimeToStr(Value: TDateTime): string; begin if StorageOptions.UseTranslateStringEngineDateTimeFormats then Modified: trunk/jvcl/run/JvAppXMLStorage.pas =================================================================== --- trunk/jvcl/run/JvAppXMLStorage.pas 2013-03-24 21:24:15 UTC (rev 13502) +++ trunk/jvcl/run/JvAppXMLStorage.pas 2013-04-09 22:22:31 UTC (rev 13503) @@ -166,6 +166,8 @@ public constructor Create(AOwner: TComponent); override; destructor Destroy; override; + //1 Sets a xml property for a given path + procedure DoSetXMLProperty(const Path, Name, Value : string); override; published property StorageOptions: TJvAppXMLStorageOptions read GetStorageOptions write SetStorageOptions; end; @@ -961,6 +963,18 @@ Result := 'xml'; end; +procedure TJvCustomAppXMLStorage.DoSetXMLProperty(const Path, Name, Value : string); +var + ANode: TJvSimpleXmlElem; +begin + ReloadIfNeeded; + ANode := CreateAndSetNode(Path); + Xml.Options := Xml.Options + [sxoAutoCreate]; + ANode.Properties.ItemNamed[Name].Value := Value; + Xml.Options := Xml.Options - [sxoAutoCreate]; + FlushIfNeeded; +end; + function TJvCustomAppXMLStorage.GetOnDecodeValue: TJvSimpleXMLEncodeEvent; begin Result := FXml.OnDecodeValue; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |