|
@@ -111,6 +111,7 @@ type
|
|
|
procedure DocTableItem(Entered: boolean); virtual;
|
|
|
procedure DocHorizontalRuler; virtual;
|
|
|
function CanonicalizeURL(const Base,Relative:String):string; virtual;
|
|
|
+ procedure Resolve( href: ansistring; var AFileId,ALinkId : sw_integer); virtual;
|
|
|
public
|
|
|
function GetSectionColor(Section: THTMLSection; var Color: byte): boolean; virtual;
|
|
|
private
|
|
@@ -133,6 +134,7 @@ type
|
|
|
CurHeadLevel: integer;
|
|
|
PAlign: TParagraphAlign;
|
|
|
LinkIndexes: array[0..MaxTopicLinks] of sw_integer;
|
|
|
+ FileIDLinkIndexes: array[0..MaxTopicLinks] of sw_integer;
|
|
|
LinkPtr: sw_integer;
|
|
|
LastTextChar: char;
|
|
|
{ Anchor: TAnchor;}
|
|
@@ -148,6 +150,7 @@ type
|
|
|
PCHMTopicRenderer = ^TCHMTopicRenderer;
|
|
|
TCHMTopicRenderer = object(THTMLTopicRenderer)
|
|
|
function CanonicalizeURL(const Base,Relative:String):string; virtual;
|
|
|
+ procedure Resolve( href: ansistring; var AFileId,ALinkId : sw_integer); virtual;
|
|
|
end;
|
|
|
|
|
|
PCustomHTMLHelpFile = ^TCustomHTMLHelpFile;
|
|
@@ -624,6 +627,7 @@ end;
|
|
|
|
|
|
procedure THTMLTopicRenderer.DocAnchor(Entered: boolean);
|
|
|
var HRef,Name: string;
|
|
|
+ lfileid,llinkid : sw_integer;
|
|
|
begin
|
|
|
if Entered and InAnchor then DocAnchor(false);
|
|
|
if Entered then
|
|
@@ -655,7 +659,9 @@ begin
|
|
|
if pos('#',HRef)=1 then
|
|
|
Href:=NameAndExtOf(GetFilename)+Href;
|
|
|
HRef:=canonicalizeURL(URL,HRef);
|
|
|
- LinkIndexes[LinkPtr]:=TopicLinks^.AddItem(HRef);
|
|
|
+ Resolve(Href,lfileid,llinkid);
|
|
|
+ LinkIndexes[LinkPtr]:=llinkid;
|
|
|
+ FileIDLinkIndexes[LinkPtr]:=lfileid;
|
|
|
{$IFDEF WDEBUG}
|
|
|
DebugMessageS({$i %file%},' Adding Link2 "'+HRef+'"',{$i %line%},'1',0,0);
|
|
|
{$ENDIF WDEBUG}
|
|
@@ -723,6 +729,16 @@ begin
|
|
|
CanonicalizeURL:=CompleteURL(Base,relative);
|
|
|
end;
|
|
|
|
|
|
+procedure THTMLTopicRenderer.Resolve( href: ansistring; var AFileId,ALinkId : sw_integer);
|
|
|
+begin
|
|
|
+{$IFDEF WDEBUG}
|
|
|
+ DebugMessageS({$i %file%},' htmlresolve "'+HRef+'"',{$i %line%},'1',0,0);
|
|
|
+{$ENDIF WDEBUG}
|
|
|
+
|
|
|
+ Afileid:=Topic^.FileId;
|
|
|
+ ALinkId:=TopicLinks^.AddItem(HRef);
|
|
|
+end;
|
|
|
+
|
|
|
procedure THTMLTopicRenderer.DocParagraph(Entered: boolean);
|
|
|
var Align: string;
|
|
|
begin
|
|
@@ -1302,10 +1318,10 @@ begin
|
|
|
for I:=0 to Min(Topic^.LinkCount-1,High(LinkIndexes)-1) do
|
|
|
begin
|
|
|
{$IFDEF WDEBUG}
|
|
|
- DebugMessageS({$i %file%},' Indexing links ('+inttostr(i)+')'+topiclinks^.at(linkindexes[i])^,{$i %line%},'1',0,0);
|
|
|
+ DebugMessageS({$i %file%},' Indexing links ('+inttostr(i)+')'+topiclinks^.at(linkindexes[i])^+' '+inttostr(i)+' '+inttostr(linkindexes[i]),{$i %line%},'1',0,0);
|
|
|
{$endif WDEBUG}
|
|
|
- Topic^.Links^[I].FileID:=Topic^.FileID;
|
|
|
- Topic^.Links^[I].Context:=EncodeHTMLCtx(Topic^.FileID,LinkIndexes[I]+1);
|
|
|
+ Topic^.Links^[I].FileID:=FileIDLinkIndexes[i];
|
|
|
+ Topic^.Links^[I].Context:=EncodeHTMLCtx(FileIDLinkIndexes[i],LinkIndexes[I]+1);
|
|
|
end;
|
|
|
{$IFDEF WDEBUG}
|
|
|
if Topic^.Linkcount>High(linkindexes) then
|
|
@@ -1336,6 +1352,28 @@ begin
|
|
|
CanonicalizeUrl:=relative;
|
|
|
end;
|
|
|
|
|
|
+procedure TCHMTopicRenderer.Resolve( href: ansistring; var AFileId,ALinkId : sw_integer);
|
|
|
+var resolved:boolean;
|
|
|
+begin
|
|
|
+{$IFDEF WDEBUG}
|
|
|
+ DebugMessageS({$i %file%},' chmresolve "'+HRef+'"',{$i %line%},'1',0,0);
|
|
|
+{$ENDIF WDEBUG}
|
|
|
+
|
|
|
+ resolved:=false;
|
|
|
+ if copy(href,1,7)='ms-its:' then
|
|
|
+ resolved:=CHMResolve(Href,AFileId,ALinkID);
|
|
|
+ if not resolved then
|
|
|
+ begin
|
|
|
+ {$IFDEF WDEBUG}
|
|
|
+ DebugMessageS({$i %file%},' chmresolve not resolved "'+HRef+'"',{$i %line%},'1',0,0);
|
|
|
+ {$ENDIF WDEBUG}
|
|
|
+
|
|
|
+ Afileid:=Topic^.FileId;
|
|
|
+ ALinkId:=TopicLinks^.AddItem(HRef);
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
+
|
|
|
constructor TCustomHTMLHelpFile.Init(AID: word);
|
|
|
begin
|
|
|
inherited Init(AID);
|
|
@@ -1601,7 +1639,7 @@ begin
|
|
|
Fail;
|
|
|
end
|
|
|
else
|
|
|
- chmw:=TCHMWrapper.Create(DefaultFileName);
|
|
|
+ chmw:=TCHMWrapper.Create(DefaultFileName,AID,TopicLinks);
|
|
|
end;
|
|
|
|
|
|
function TChmHelpFile.LoadIndex: boolean;
|