* Fixed loading of context id's from the command line

git-svn-id: trunk@30845 -
This commit is contained in:
andrew 2011-05-22 01:19:21 +00:00
parent c948e3016f
commit fa52e18965
2 changed files with 20 additions and 8 deletions

View File

@ -985,6 +985,9 @@ var
fPos: Integer;
FileIndex: Integer;
LoadTOC: Boolean;
CurCHM: TChmReader;
ContextURL,
ContextTitle: String;
begin
Result := False;
fFile := Copy(AUrl,8, Length(AURL));
@ -1003,16 +1006,27 @@ begin
else
Exit;
CurCHM := fChms.Chm[FileIndex];
if LoadTOC and (FileIndex = 0) then
begin
QueueFillToc(fChms.Chm[FileIndex]);
QueueFillToc(CurCHM);
end;
// AContext will override the url if it is found
if AContext <> -1 then
begin
ContextURL := CurCHM.LookupTopicByID(AContext, ContextTitle);
if (Length(ContextURL) > 0) and not (ContextURL[1] in ['/', '\']) then
Insert('/', ContextURL , 1);
if Length(ContextURL) > 0 then
fURL := ContextURL;
end;
if fURL <> '' then
DoLoadUri(MakeURI(fURL, fChms.Chm[FileIndex]))
DoLoadUri(MakeURI(fURL, CurCHM))
else
DoLoadUri(MakeURI(fChms.Chm[FileIndex].DefaultPage, fChms.Chm[FileIndex]));
DoLoadUri(MakeURI(CurCHM.DefaultPage, CurCHM));
Result := True;
fChms.OnOpenNewFile := @NewChmOpened;

View File

@ -476,11 +476,6 @@ begin
Application.QueueAsyncCall(TDataEvent(@LateOpenURL), PtrUInt(StrItem));
Break;
end;
//we reset the context because at this point the file has been loaded and the
//context shown
fContext := -1;
end;
procedure THelpForm.StartServer(ServerName: String);
@ -589,6 +584,9 @@ procedure THelpForm.LateOpenURL ( Url: PStringItem ) ;
begin
if OpenURL(URL^.FString, fContext) = ord(srSuccess) then
AddRecentFile(URL^.FString);
//we reset the context because at this point the file has been loaded and the
//context shown
fContext := -1;
Dispose(Url);
RefreshState;