git-svn-id: trunk@31740 -
This commit is contained in:
mattias 2011-07-18 20:17:02 +00:00
parent 1a5ecc177b
commit b518b70fa5
3 changed files with 35 additions and 20 deletions

View File

@ -759,11 +759,8 @@ begin
h:=s; h:=s;
Tree.Add(Pointer(h)); Tree.Add(Pointer(h));
Pointer(h):=nil; // keep refcount Pointer(h):=nil; // keep refcount
//debugln(['TStringTree.ReplaceString NewString="',dbgstr(s),'"']); end else
end else begin
s:=AnsiString(Node.Data); s:=AnsiString(Node.Data);
//debugln(['TStringTree.ReplaceString OldString="',dbgstr(s),'"']);
end;
end; end;
function TStringTree.CalcMemSize: PtrUInt; function TStringTree.CalcMemSize: PtrUInt;

View File

@ -166,7 +166,7 @@ const
'-', '''', '(', ')', '+', ',', '.', '/', ':', '=', '?', ';', '!', '*', '-', '''', '(', ')', '+', ',', '.', '/', ':', '=', '?', ';', '!', '*',
'#', '@', '$', '_', '%']; '#', '@', '$', '_', '%'];
var var
{$IFDEF UseUTF8} {$IF SizeOf(DOMChar)<2}
IsNameStartChar, IsNameChar: array[char] of boolean; IsNameStartChar, IsNameChar: array[char] of boolean;
{$ENDIF} {$ENDIF}
@ -527,7 +527,6 @@ begin
end; end;
end; end;
{$IFDEF UseUTF8}
function WriteUTF8(u: cardinal; var OutBuf: DOMPChar; var OutCnt: Cardinal): boolean; inline; function WriteUTF8(u: cardinal; var OutBuf: DOMPChar; var OutCnt: Cardinal): boolean; inline;
begin begin
case u of case u of
@ -570,7 +569,6 @@ begin
end; end;
Result:=true; Result:=true;
end; end;
{$ENDIF}
function Decode_UCS2(Context: Pointer; InBuf: PChar; var InCnt: Cardinal; OutBuf: DOMPChar; var OutCnt: Cardinal): Integer; stdcall; function Decode_UCS2(Context: Pointer; InBuf: PChar; var InCnt: Cardinal; OutBuf: DOMPChar; var OutCnt: Cardinal): Integer; stdcall;
{$IFDEF UseUTF8} {$IFDEF UseUTF8}
@ -1686,7 +1684,7 @@ begin
repeat repeat
if NameStartFlag then if NameStartFlag then
begin begin
if {$IFDEF UseWideString} if {$IF SizeOf(DOMChar)=2}
(Byte(p^) in NamingBitmap[FNamePages^[hi(Word(p^))]]) (Byte(p^) in NamingBitmap[FNamePages^[hi(Word(p^))]])
{$ELSE} {$ELSE}
IsNameStartChar[p^] IsNameStartChar[p^]
@ -1695,7 +1693,7 @@ begin
begin begin
Inc(p); Inc(p);
end end
{$IFDEF UseWideString} {$IF SizeOf(DOMChar)=2}
else if FXML11 and ((p^ >= #$D800) and (p^ <= #$DB7F) and else if FXML11 and ((p^ >= #$D800) and (p^ <= #$DB7F) and
(p[1] >= #$DC00) and (p[1] <= #$DFFF)) then (p[1] >= #$DC00) and (p[1] <= #$DFFF)) then
begin begin
@ -1713,7 +1711,7 @@ begin
NameStartFlag := False; NameStartFlag := False;
end; end;
{$IFDEF UseWideString} {$IF SizeOf(DOMChar)=2}
if FXML11 then begin if FXML11 then begin
repeat repeat
if Byte(p^) in NamingBitmap[FNamePages^[$100+hi(Word(p^))]] then if Byte(p^) in NamingBitmap[FNamePages^[$100+hi(Word(p^))]] then
@ -3064,12 +3062,15 @@ begin
repeat repeat
old := FBuf; old := FBuf;
repeat repeat
{$IFDEF UseWideString} {$IF SizeOf(DOMChar)=2}
// skip common white spaces // skip common white spaces
while FBuf^ in [' ',#9] do inc(FBuf); while FBuf^ in [' ',#9] do inc(FBuf);
wc := FBuf^; wc := FBuf^;
//writeln('TXMLDecodingSource.SkipUntil ',ord(wc)); //writeln('TXMLDecodingSource.SkipUntil ',ord(wc));
if ((wc = #10) or (wc = #13) if ((wc = #10) or (wc = #13)
{$IF SizeOf(DOMChar)=2}
or (FXML11Rules and ((wc = #$85) or (wc = #$2028)))
{$ENDIF}
) and (not AllowSpecialChars) ) and (not AllowSpecialChars)
then begin then begin
BufAppendChunk(ToFill, old, FBuf); BufAppendChunk(ToFill, old, FBuf);
@ -3082,12 +3083,17 @@ begin
end end
else if (not AllowSpecialChars) else if (not AllowSpecialChars)
and ( ((wc < #32) and (not ((wc = #0) and (FBuf >= FBufEnd))) and (wc <> #9)) and ( ((wc < #32) and (not ((wc = #0) and (FBuf >= FBufEnd))) and (wc <> #9))
{$IF SizeOf(DOMChar)=2}
or (wc > #$FFFD)
{$ENDIF}
or (FXML11Rules and (wc >= #$7F) and (wc <= #$9F)) ) or (FXML11Rules and (wc >= #$7F) and (wc <= #$9F)) )
then then
FReader.FatalError('Invalid character') FReader.FatalError('Invalid character')
else if (wc=#0) and (FBuf < FBufEnd) then else if (wc=#0) and (FBuf < FBufEnd) then
FReader.FatalError('Invalid #0 character'); FReader.FatalError('Invalid #0 character');
if (Char(ord(wc)) in Delim) then if {$IF SizeOf(DOMChar)=2}(wc < #255) and{$ENDIF}
(Char(ord(wc)) in Delim)
then
Break; Break;
// the checks above filter away everything below #32 that isn't a whitespace // the checks above filter away everything below #32 that isn't a whitespace
if wc > #32 then if wc > #32 then
@ -4213,12 +4219,12 @@ begin
end; end;
procedure InitXMLRead; procedure InitXMLRead;
{$IFDEF UseUTF8} {$IF SizeOf(DOMChar)<2}
var var
c: Char; c: Char;
{$ENDIF} {$ENDIF}
begin begin
{$IFDEF UseUTF8} {$IF SizeOf(DOMChar)<2}
for c:=low(char) to high(char) do begin for c:=low(char) to high(char) do begin
IsNameStartChar[c]:=c in ['A'..'Z','a'..'z','_',#128..#255]; IsNameStartChar[c]:=c in ['A'..'Z','a'..'z','_',#128..#255];
IsNameChar[c]:=c in ['A'..'Z','a'..'z','_','0'..'9','-','.',#128..#255]; IsNameChar[c]:=c in ['A'..'Z','a'..'z','_','0'..'9','-','.',#128..#255];

View File

@ -50,12 +50,11 @@ type
procedure ListBoxDblClick(Sender: TObject); procedure ListBoxDblClick(Sender: TObject);
procedure ListBoxSelectionChange(Sender: TObject; User: boolean); procedure ListBoxSelectionChange(Sender: TObject; User: boolean);
private private
FProjectDescriptor: TProjectDescriptor;
procedure FillHelpLabel; procedure FillHelpLabel;
procedure SetupComponents; procedure SetupComponents;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
property ProjectDescriptor: TProjectDescriptor read FProjectDescriptor; function GetProjectDescriptor: TProjectDescriptor;
end; end;
function ChooseNewProject(var ProjectDesc: TProjectDescriptor): TModalResult; function ChooseNewProject(var ProjectDesc: TProjectDescriptor): TModalResult;
@ -73,7 +72,7 @@ begin
try try
Result:=NewProjectDialog.ShowModal; Result:=NewProjectDialog.ShowModal;
if Result=mrOk then if Result=mrOk then
ProjectDesc:=NewProjectDialog.ProjectDescriptor; ProjectDesc:=NewProjectDialog.GetProjectDescriptor;
finally finally
NewProjectDialog.Free; NewProjectDialog.Free;
end; end;
@ -89,10 +88,23 @@ begin
FillHelpLabel; FillHelpLabel;
end; end;
function TNewProjectDialog.GetProjectDescriptor: TProjectDescriptor;
var
i: LongInt;
s: string;
begin
Result:=ProjectDescriptorApplication;
i:=ListBox.ItemIndex;
if (i<0) then exit;
s:=ListBox.Items[i];
for i:=0 to ProjectDescriptors.Count-1 do
if ProjectDescriptors[i].GetLocalizedName=s then
exit(ProjectDescriptors[i]);
end;
procedure TNewProjectDialog.FillHelpLabel; procedure TNewProjectDialog.FillHelpLabel;
begin begin
FProjectDescriptor := TProjectDescriptor(ListBox.Items.Objects[ListBox.ItemIndex]); HelpLabel.Caption:=GetProjectDescriptor.GetLocalizedDescription;
HelpLabel.Caption:=FProjectDescriptor.GetLocalizedDescription;
HelpLabel.Width:=Self.ClientWidth-HelpLabel.Left-10; HelpLabel.Width:=Self.ClientWidth-HelpLabel.Left-10;
end; end;
@ -105,7 +117,7 @@ begin
BeginUpdate; BeginUpdate;
for i:=0 to ProjectDescriptors.Count-1 do begin for i:=0 to ProjectDescriptors.Count-1 do begin
if ProjectDescriptors[i].VisibleInNewDialog then if ProjectDescriptors[i].VisibleInNewDialog then
AddObject(ProjectDescriptors[i].GetLocalizedName, ProjectDescriptors[i]); Add(ProjectDescriptors[i].GetLocalizedName);
end; end;
EndUpdate; EndUpdate;
end; end;