|
@@ -15,13 +15,13 @@
|
|
**********************************************************************}
|
|
**********************************************************************}
|
|
unit wchmhwrap;
|
|
unit wchmhwrap;
|
|
|
|
|
|
-interface
|
|
|
|
|
|
+interface
|
|
{$Mode Delphi}
|
|
{$Mode Delphi}
|
|
|
|
|
|
Uses wutils,whelp,whtml,SysUtils,ChmReader,ChmSiteMap,Classes;
|
|
Uses wutils,whelp,whtml,SysUtils,ChmReader,ChmSiteMap,Classes;
|
|
|
|
|
|
Type
|
|
Type
|
|
-// TopicLinks: PTopicLinkCollection;IndexEntries : PUnsortedIndexEntryCollection;
|
|
|
|
|
|
+// TopicLinks: PTopicLinkCollection;IndexEntries : PUnsortedIndexEntryCollection;
|
|
|
|
|
|
TChmWrapper = Class
|
|
TChmWrapper = Class
|
|
private
|
|
private
|
|
@@ -30,7 +30,7 @@ Type
|
|
findex: TChmSiteMap;
|
|
findex: TChmSiteMap;
|
|
ftopic: TChmSiteMap;
|
|
ftopic: TChmSiteMap;
|
|
floaded : boolean;
|
|
floaded : boolean;
|
|
- public
|
|
|
|
|
|
+ public
|
|
constructor Create(name:String);
|
|
constructor Create(name:String);
|
|
function LoadIndex(id:integer;TopicLinks: PTopicLinkCollection;IndexEntries : PUnsortedIndexEntryCollection;helpfacility:PHelpFacility):boolean;
|
|
function LoadIndex(id:integer;TopicLinks: PTopicLinkCollection;IndexEntries : PUnsortedIndexEntryCollection;helpfacility:PHelpFacility):boolean;
|
|
function GetTopic(name:string):PMemoryTextFile;
|
|
function GetTopic(name:string):PMemoryTextFile;
|
|
@@ -56,11 +56,19 @@ begin
|
|
basepath:=extractfiledir(basepath);
|
|
basepath:=extractfiledir(basepath);
|
|
delete(relpath,1,3);
|
|
delete(relpath,1,3);
|
|
end;
|
|
end;
|
|
-
|
|
|
|
- {$ifdef combinedebug}
|
|
|
|
|
|
+
|
|
|
|
+ {$ifdef combinedebug}
|
|
debugmessageS({$i %file%},'combine out "'+relpath+'" and "'+basepath+'"',{$i %line%},'1',0,0);
|
|
debugmessageS({$i %file%},'combine out "'+relpath+'" and "'+basepath+'"',{$i %line%},'1',0,0);
|
|
{$endif}
|
|
{$endif}
|
|
-
|
|
|
|
|
|
+ if (length(basepath)>0) and (length(relpath)>0) then
|
|
|
|
+ begin
|
|
|
|
+ if (relpath[1]<>'/') and (basepath[length(basepath)]<>'/') then
|
|
|
|
+ basepath:=basepath+'/';
|
|
|
|
+ {$ifdef combinedebug}
|
|
|
|
+ debugmessageS({$i %file%},'combine out2 "'+relpath+'" and "'+basepath+'"',{$i %line%},'1',0,0);
|
|
|
|
+ {$endif}
|
|
|
|
+ end;
|
|
|
|
+
|
|
result:=basepath+relpath;
|
|
result:=basepath+relpath;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -75,8 +83,8 @@ begin
|
|
begin
|
|
begin
|
|
freeandnil(fchmr);
|
|
freeandnil(fchmr);
|
|
freeandnil(ffs);
|
|
freeandnil(ffs);
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
{$ifdef wdebug}
|
|
{$ifdef wdebug}
|
|
debugmessageS({$i %file%},'TCHMWrapper: before sitemap creation ',{$i %line%},'1',0,0);
|
|
debugmessageS({$i %file%},'TCHMWrapper: before sitemap creation ',{$i %line%},'1',0,0);
|
|
{$endif}
|
|
{$endif}
|
|
@@ -97,7 +105,7 @@ begin
|
|
// if (length(alias)>0) and (alias[1]<>'/') then Alias:='/'+alias;
|
|
// if (length(alias)>0) and (alias[1]<>'/') then Alias:='/'+alias;
|
|
FormatAlias:=Alias;
|
|
FormatAlias:=Alias;
|
|
end;
|
|
end;
|
|
-
|
|
|
|
|
|
+
|
|
var
|
|
var
|
|
m : Classes.TMemoryStream;
|
|
m : Classes.TMemoryStream;
|
|
i,j : integer;
|
|
i,j : integer;
|
|
@@ -108,15 +116,15 @@ begin
|
|
if not assigned (fchmr) then exit;
|
|
if not assigned (fchmr) then exit;
|
|
if floaded then exit;
|
|
if floaded then exit;
|
|
{$ifdef wdebug}
|
|
{$ifdef wdebug}
|
|
- debugmessageS({$i %file%},'TCHMWrapper: indexfilename:'+fchmr.indexfile,{$i %line%},'1',0,0);
|
|
|
|
|
|
+ debugmessageS({$i %file%},'TCHMWrapper: indexfilename:'+fchmr.indexfile,{$i %line%},'1',0,0);
|
|
{$endif}
|
|
{$endif}
|
|
-
|
|
|
|
|
|
+
|
|
m:=fchmr.getobject(fchmr.indexfile);
|
|
m:=fchmr.getobject(fchmr.indexfile);
|
|
try
|
|
try
|
|
if assigned(m) then
|
|
if assigned(m) then
|
|
begin
|
|
begin
|
|
{$ifdef wdebug}
|
|
{$ifdef wdebug}
|
|
- debugmessageS({$i %file%},'TCHMWrapper: stream size loaded :'+inttostr(m.size),{$i %line%},'1',0,0);
|
|
|
|
|
|
+ debugmessageS({$i %file%},'TCHMWrapper: stream size loaded :'+inttostr(m.size),{$i %line%},'1',0,0);
|
|
{$endif}
|
|
{$endif}
|
|
findex.loadfromStream(m);
|
|
findex.loadfromStream(m);
|
|
end;
|
|
end;
|
|
@@ -124,21 +132,21 @@ begin
|
|
freeandnil(m);
|
|
freeandnil(m);
|
|
end;
|
|
end;
|
|
{$ifdef wdebug}
|
|
{$ifdef wdebug}
|
|
- debugmessageS({$i %file%},'TCHMWrapper: loadindex after final ',{$i %line%},'1',0,0);
|
|
|
|
|
|
+ debugmessageS({$i %file%},'TCHMWrapper: loadindex after final ',{$i %line%},'1',0,0);
|
|
{$endif}
|
|
{$endif}
|
|
-
|
|
|
|
- tli:=TopicLinks^.AddItem(fchmr.defaultpage);
|
|
|
|
|
|
+
|
|
|
|
+ tli:=TopicLinks^.AddItem(fchmr.defaultpage);
|
|
TLI:=EncodeHTMLCtx(ID,TLI+1);
|
|
TLI:=EncodeHTMLCtx(ID,TLI+1);
|
|
IndexEntries^.Insert(NewIndexEntry( FormatAlias('Table of contents'),ID,TLI));
|
|
IndexEntries^.Insert(NewIndexEntry( FormatAlias('Table of contents'),ID,TLI));
|
|
for i:=0 to findex.items.count-1 do
|
|
for i:=0 to findex.items.count-1 do
|
|
begin
|
|
begin
|
|
item:=findex.items.item[i];
|
|
item:=findex.items.item[i];
|
|
- tli:=TopicLinks^.AddItem('/'+item.local);
|
|
|
|
|
|
+ tli:=TopicLinks^.AddItem('/'+item.local);
|
|
TLI:=EncodeHTMLCtx(ID,TLI+1);
|
|
TLI:=EncodeHTMLCtx(ID,TLI+1);
|
|
IndexEntries^.Insert(NewIndexEntry( FormatAlias(item.text),ID,TLI));
|
|
IndexEntries^.Insert(NewIndexEntry( FormatAlias(item.text),ID,TLI));
|
|
end;
|
|
end;
|
|
{$ifdef wdebug}
|
|
{$ifdef wdebug}
|
|
- debugmessageS({$i %file%},'TCHMWrapper: endloadindex ',{$i %line%},'1',0,0);
|
|
|
|
|
|
+ debugmessageS({$i %file%},'TCHMWrapper: endloadindex ',{$i %line%},'1',0,0);
|
|
{$endif}
|
|
{$endif}
|
|
floaded:=true;
|
|
floaded:=true;
|
|
result:=true;
|
|
result:=true;
|
|
@@ -161,7 +169,7 @@ begin
|
|
if (s[i]=' ') and not inquote then lastpoint:=i;
|
|
if (s[i]=' ') and not inquote then lastpoint:=i;
|
|
if (s[i]='"') then inquote:=not inquote;
|
|
if (s[i]='"') then inquote:=not inquote;
|
|
inc(i);
|
|
inc(i);
|
|
- end;
|
|
|
|
|
|
+ end;
|
|
scanvalue:=lastpoint;
|
|
scanvalue:=lastpoint;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -191,19 +199,19 @@ var
|
|
begin
|
|
begin
|
|
result:=nil;
|
|
result:=nil;
|
|
if not assigned(fchmr) or (name='') then exit;
|
|
if not assigned(fchmr) or (name='') then exit;
|
|
-
|
|
|
|
|
|
+
|
|
If (name[1]<>'/') and (copy(name,1,7)<>'ms-its:') Then
|
|
If (name[1]<>'/') and (copy(name,1,7)<>'ms-its:') Then
|
|
name:='/'+name;
|
|
name:='/'+name;
|
|
linedata:=Classes.TStringList.create;
|
|
linedata:=Classes.TStringList.create;
|
|
try
|
|
try
|
|
{$ifdef wdebug}
|
|
{$ifdef wdebug}
|
|
- debugmessageS({$i %file%},'TCHMWrapper: Getting file '+name,{$i %line%},'1',0,0);
|
|
|
|
|
|
+ debugmessageS({$i %file%},'TCHMWrapper: Getting file '+name,{$i %line%},'1',0,0);
|
|
{$endif}
|
|
{$endif}
|
|
// if uppercase(name)='TABLE OF CONTENTS' Then
|
|
// if uppercase(name)='TABLE OF CONTENTS' Then
|
|
// m:=fchmr.getobject(fchmr.tocfile)
|
|
// m:=fchmr.getobject(fchmr.tocfile)
|
|
// else
|
|
// else
|
|
m:=fchmr.getobject(name);
|
|
m:=fchmr.getobject(name);
|
|
-
|
|
|
|
|
|
+
|
|
if not assigned(m) then exit;
|
|
if not assigned(m) then exit;
|
|
linedata.loadfromstream(m);
|
|
linedata.loadfromstream(m);
|
|
result:=new(PMemoryTextFile,Init);
|
|
result:=new(PMemoryTextFile,Init);
|
|
@@ -231,4 +239,4 @@ end;
|
|
// m:=r.getobject(r.indexfile);
|
|
// m:=r.getobject(r.indexfile);
|
|
// siteindex.loadfromStream(m);
|
|
// siteindex.loadfromStream(m);
|
|
|
|
|
|
-end.
|
|
|
|
|
|
+end.
|