123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773 |
- {
- $Id$
- This file is part of the Free Pascal Integrated Development Environment
- Copyright (c) 1999-2000 by Berczi Gabor
- See the file COPYING.FPC, included in this distribution,
- for details about the copyright.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- **********************************************************************}
- unit WHTMLHlp;
- interface
- uses Objects,WHTML,WHelp;
- const
- ListIndent = 2;
- DefIndent = 4;
- MaxTopicLinks = 5000; { maximum number of links on a single HTML page }
- type
- THTMLSection = (hsNone,hsHeading1,hsHeading2,hsHeading3,hsHeading4,hsHeading5,hsHeading6);
- PTopicLinkCollection = ^TTopicLinkCollection;
- TTopicLinkCollection = object(TStringCollection)
- procedure Insert(Item: Pointer); virtual;
- function At(Index: sw_Integer): PString;
- function AddItem(Item: string): integer;
- end;
- TParagraphAlign = (paLeft,paCenter,paRight);
- PHTMLTopicRenderer = ^THTMLTopicRenderer;
- THTMLTopicRenderer = object(THTMLParser)
- function BuildTopic(P: PTopic; AURL: string; HTMLFile: PTextFile; ATopicLinks: PTopicLinkCollection): boolean;
- public
- function DocAddTextChar(C: char): boolean; virtual;
- procedure DocSoftBreak; virtual;
- procedure DocTYPE; virtual;
- procedure DocHTML(Entered: boolean); virtual;
- procedure DocHEAD(Entered: boolean); virtual;
- procedure DocMETA; virtual;
- procedure DocTITLE(Entered: boolean); virtual;
- procedure DocBODY(Entered: boolean); virtual;
- procedure DocAnchor(Entered: boolean); virtual;
- procedure DocHeading(Level: integer; Entered: boolean); virtual;
- procedure DocParagraph(Entered: boolean); virtual;
- procedure DocBreak; virtual;
- procedure DocImage; virtual;
- procedure DocBold(Entered: boolean); virtual;
- procedure DocCite(Entered: boolean); virtual;
- procedure DocCode(Entered: boolean); virtual;
- procedure DocEmphasized(Entered: boolean); virtual;
- procedure DocItalic(Entered: boolean); virtual;
- procedure DocKbd(Entered: boolean); virtual;
- procedure DocPreformatted(Entered: boolean); virtual;
- procedure DocSample(Entered: boolean); virtual;
- procedure DocStrong(Entered: boolean); virtual;
- procedure DocTeleType(Entered: boolean); virtual;
- procedure DocVariable(Entered: boolean); virtual;
- procedure DocList(Entered: boolean); virtual;
- procedure DocOrderedList(Entered: boolean); virtual;
- procedure DocListItem; virtual;
- procedure DocDefList(Entered: boolean); virtual;
- procedure DocDefTerm; virtual;
- procedure DocDefExp; virtual;
- procedure DocTable(Entered: boolean); virtual;
- procedure DocTableRow(Entered: boolean); virtual;
- procedure DocTableItem(Entered: boolean); virtual;
- procedure DocHorizontalRuler; virtual;
- public
- function GetSectionColor(Section: THTMLSection; var Color: byte): boolean; virtual;
- private
- URL: string;
- Topic: PTopic;
- TopicLinks: PTopicLinkCollection;
- TextPtr: sw_word;
- InTitle: boolean;
- InBody: boolean;
- InAnchor: boolean;
- InParagraph: boolean;
- InPreformatted: boolean;
- TopicTitle: string;
- Indent: integer;
- AnyCharsInLine: boolean;
- CurHeadLevel: integer;
- PAlign: TParagraphAlign;
- LinkIndexes: array[0..MaxTopicLinks] of sw_integer;
- LinkPtr: sw_integer;
- LastTextChar: char;
- { Anchor: TAnchor;}
- procedure AddText(S: string);
- procedure AddChar(C: char);
- end;
- PCustomHTMLHelpFile = ^TCustomHTMLHelpFile;
- TCustomHTMLHelpFile = object(THelpFile)
- constructor Init(AID: word);
- destructor Done; virtual;
- public
- function SearchTopic(HelpCtx: THelpCtx): PTopic; virtual;
- function ReadTopic(T: PTopic): boolean; virtual;
- private
- Renderer: PHTMLTopicRenderer;
- DefaultFileName: string;
- CurFileName: string;
- TopicLinks: PTopicLinkCollection;
- end;
- PHTMLHelpFile = ^THTMLHelpFile;
- THTMLHelpFile = object(TCustomHTMLHelpFile)
- constructor Init(AFileName: string; AID: word; ATOCEntry: string);
- public
- function LoadIndex: boolean; virtual;
- private
- TOCEntry: string;
- end;
- PHTMLIndexHelpFile = ^THTMLIndexHelpFile;
- THTMLIndexHelpFile = object(TCustomHTMLHelpFile)
- constructor Init(AFileName: string; AID: word);
- function LoadIndex: boolean; virtual;
- private
- IndexFileName: string;
- end;
- THTMLGetSectionColorProc = function(Section: THTMLSection; var Color: byte): boolean;
- function DefHTMLGetSectionColor(Section: THTMLSection; var Color: byte): boolean;
- const HTMLGetSectionColor : THTMLGetSectionColorProc = DefHTMLGetSectionColor;
- implementation
- uses WConsts,WUtils,WViews,WHTMLScn;
- function DefHTMLGetSectionColor(Section: THTMLSection; var Color: byte): boolean;
- begin
- Color:=0;
- DefHTMLGetSectionColor:=false;
- end;
- function EncodeHTMLCtx(FileID: integer; LinkNo: word): longint;
- var Ctx: longint;
- begin
- Ctx:=(longint(FileID) shl 16)+LinkNo;
- EncodeHTMLCtx:=Ctx;
- end;
- procedure DecodeHTMLCtx(Ctx: longint; var FileID: word; var LinkNo: word);
- begin
- if (Ctx shr 16)=0 then
- begin
- FileID:=$ffff; LinkNo:=0;
- end
- else
- begin
- FileID:=Ctx shr 16; LinkNo:=Ctx and $ffff;
- end;
- end;
- function CharStr(C: char; Count: byte): string;
- var S: string;
- begin
- S[0]:=chr(Count);
- if Count>0 then FillChar(S[1],Count,C);
- CharStr:=S;
- end;
- procedure TTopicLinkCollection.Insert(Item: Pointer);
- begin
- AtInsert(Count,Item);
- end;
- function TTopicLinkCollection.At(Index: sw_Integer): PString;
- begin
- At:=inherited At(Index);
- end;
- function TTopicLinkCollection.AddItem(Item: string): integer;
- var Idx: sw_integer;
- begin
- if Item='' then Idx:=-1 else
- if Search(@Item,Idx)=false then
- begin
- AtInsert(Count,NewStr(Item));
- Idx:=Count-1;
- end;
- AddItem:=Idx;
- end;
- function THTMLTopicRenderer.DocAddTextChar(C: char): boolean;
- var Added: boolean;
- begin
- Added:=false;
- if InTitle then
- begin
- TopicTitle:=TopicTitle+C;
- Added:=true;
- end
- else
- if InBody then
- begin
- if (InPreFormatted) or (C<>#32) or (LastTextChar<>C) then
- if (C<>#32) or (AnyCharsInLine=true) or (InPreFormatted=true) then
- begin
- AddChar(C);
- LastTextChar:=C;
- Added:=true;
- end;
- end;
- DocAddTextChar:=Added;
- end;
- procedure THTMLTopicRenderer.DocSoftBreak;
- begin
- if InPreformatted then DocBreak else
- if AnyCharsInLine then
- begin
- AddChar(' ');
- LastTextChar:=' ';
- end;
- end;
- procedure THTMLTopicRenderer.DocTYPE;
- begin
- end;
- procedure THTMLTopicRenderer.DocHTML(Entered: boolean);
- begin
- end;
- procedure THTMLTopicRenderer.DocHEAD(Entered: boolean);
- begin
- end;
- procedure THTMLTopicRenderer.DocMETA;
- begin
- end;
- procedure THTMLTopicRenderer.DocTITLE(Entered: boolean);
- begin
- if Entered then
- begin
- TopicTitle:='';
- end
- else
- begin
- { render topic title here }
- if TopicTitle<>'' then
- begin
- AddText(' '+TopicTitle+' Ü'); DocBreak;
- AddText(' '+CharStr('ß',length(TopicTitle)+3)); DocBreak;
- end;
- end;
- InTitle:=Entered;
- end;
- procedure THTMLTopicRenderer.DocBODY(Entered: boolean);
- begin
- InBody:=Entered;
- end;
- procedure THTMLTopicRenderer.DocAnchor(Entered: boolean);
- var HRef,Name: string;
- begin
- if Entered and InAnchor then DocAnchor(false);
- if Entered then
- begin
- if DocGetTagParam('HREF',HRef)=false then HRef:='';
- if DocGetTagParam('NAME',Name)=false then Name:='';
- if Name<>'' then
- begin
- Topic^.NamedMarks^.InsertStr(Name);
- AddChar(hscNamedMark);
- end;
- if (HRef<>'') then
- begin
- InAnchor:=true;
- AddChar(hscLink);
- if LinkPtr<MaxTopicLinks then
- begin
- HRef:=CompleteURL(URL,HRef);
- LinkIndexes[LinkPtr]:=TopicLinks^.AddItem(HRef);
- Inc(LinkPtr);
- end;
- end;
- end
- else
- begin
- if InAnchor=true then AddChar(hscLink);
- InAnchor:=false;
- end;
- end;
- procedure DecodeAlign(Align: string; var PAlign: TParagraphAlign);
- begin
- Align:=UpcaseStr(Align);
- if Align='LEFT' then PAlign:=paLeft else
- if Align='CENTER' then PAlign:=paCenter else
- if Align='RIGHT' then PAlign:=paRight;
- end;
- procedure THTMLTopicRenderer.DocHeading(Level: integer; Entered: boolean);
- var Align: string;
- C: byte;
- SC: THTMLSection;
- begin
- if Entered then
- begin
- DocBreak;
- CurHeadLevel:=Level;
- PAlign:=paLeft;
- if DocGetTagParam('ALIGN',Align) then
- DecodeAlign(Align,PAlign);
- SC:=hsNone;
- case Level of
- 1: SC:=hsHeading1;
- 2: SC:=hsHeading2;
- 3: SC:=hsHeading3;
- 4: SC:=hsHeading4;
- 5: SC:=hsHeading5;
- 6: SC:=hsHeading6;
- end;
- if GetSectionColor(SC,C) then
- AddText(hscTextAttr+chr(C));
- end
- else
- begin
- AddChar(hscNormText);
- CurHeadLevel:=0;
- DocBreak;
- end;
- end;
- procedure THTMLTopicRenderer.DocParagraph(Entered: boolean);
- var Align: string;
- begin
- if Entered and InParagraph then DocParagraph(false);
- if Entered then
- begin
- if AnyCharsInLine then DocBreak;
- if DocGetTagParam('ALIGN',Align) then
- DecodeAlign(Align,PAlign);
- end
- else
- begin
- { if AnyCharsInLine then }DocBreak;
- PAlign:=paLeft;
- end;
- InParagraph:=Entered;
- end;
- procedure THTMLTopicRenderer.DocBreak;
- begin
- if (CurHeadLevel=1) or (PAlign=paCenter) then
- AddChar(hscCenter);
- if (PAlign=paRight) then
- AddChar(hscRight);
- AddChar(hscLineBreak);
- if Indent>0 then
- AddText(CharStr(#255,Indent)+hscLineStart);
- AnyCharsInLine:=false;
- end;
- procedure THTMLTopicRenderer.DocImage;
- var Alt: string;
- begin
- if DocGetTagParam('ALT',Alt)=false then Alt:='IMG';
- if Alt<>'' then
- begin
- AddText('['+Alt+']');
- end;
- end;
- procedure THTMLTopicRenderer.DocBold(Entered: boolean);
- begin
- end;
- procedure THTMLTopicRenderer.DocCite(Entered: boolean);
- begin
- end;
- procedure THTMLTopicRenderer.DocCode(Entered: boolean);
- begin
- if AnyCharsInLine then DocBreak;
- AddText(hscCode);
- DocBreak;
- end;
- procedure THTMLTopicRenderer.DocEmphasized(Entered: boolean);
- begin
- end;
- procedure THTMLTopicRenderer.DocItalic(Entered: boolean);
- begin
- end;
- procedure THTMLTopicRenderer.DocKbd(Entered: boolean);
- begin
- end;
- procedure THTMLTopicRenderer.DocPreformatted(Entered: boolean);
- begin
- if AnyCharsInLine then DocBreak;
- AddText(hscCode);
- DocBreak;
- InPreformatted:=Entered;
- end;
- procedure THTMLTopicRenderer.DocSample(Entered: boolean);
- begin
- end;
- procedure THTMLTopicRenderer.DocStrong(Entered: boolean);
- begin
- end;
- procedure THTMLTopicRenderer.DocTeleType(Entered: boolean);
- begin
- end;
- procedure THTMLTopicRenderer.DocVariable(Entered: boolean);
- begin
- end;
- procedure THTMLTopicRenderer.DocList(Entered: boolean);
- begin
- if Entered then
- begin
- Inc(Indent,ListIndent);
- DocBreak;
- end
- else
- begin
- Dec(Indent,ListIndent);
- if AnyCharsInLine then DocBreak;
- end;
- end;
- procedure THTMLTopicRenderer.DocOrderedList(Entered: boolean);
- begin
- DocList(Entered);
- end;
- procedure THTMLTopicRenderer.DocListItem;
- begin
- if AnyCharsInLine then
- DocBreak;
- AddText('þ'+hscLineStart);
- end;
- procedure THTMLTopicRenderer.DocDefList(Entered: boolean);
- begin
- if Entered then
- begin
- { if LastChar<>hscLineBreak then DocBreak;}
- end
- else
- begin
- if AnyCharsInLine then DocBreak;
- end;
- end;
- procedure THTMLTopicRenderer.DocDefTerm;
- begin
- DocBreak;
- end;
- procedure THTMLTopicRenderer.DocDefExp;
- begin
- Inc(Indent,DefIndent);
- DocBreak;
- Dec(Indent,DefIndent);
- end;
- procedure THTMLTopicRenderer.DocTable(Entered: boolean);
- begin
- if AnyCharsInLine then
- DocBreak;
- if Entered then
- DocBreak;
- end;
- procedure THTMLTopicRenderer.DocTableRow(Entered: boolean);
- begin
- if AnyCharsInLine then
- DocBreak;
- end;
- procedure THTMLTopicRenderer.DocTableItem(Entered: boolean);
- begin
- if Entered then
- AddText(' - ');
- end;
- procedure THTMLTopicRenderer.DocHorizontalRuler;
- var OAlign: TParagraphAlign;
- begin
- OAlign:=PAlign;
- if AnyCharsInLine then DocBreak;
- PAlign:=paCenter;
- DocAddText(' '+CharStr('Ä',60)+' ');
- DocBreak;
- PAlign:=OAlign;
- end;
- procedure THTMLTopicRenderer.AddChar(C: char);
- begin
- if (Topic=nil) or (TextPtr=MaxBytes) then Exit;
- Topic^.Text^[TextPtr]:=ord(C);
- Inc(TextPtr);
- if (C>#15) and ((C<>' ') or (InPreFormatted=true)) then
- AnyCharsInLine:=true;
- end;
- procedure THTMLTopicRenderer.AddText(S: string);
- var I: sw_integer;
- begin
- for I:=1 to length(S) do
- AddChar(S[I]);
- end;
- function THTMLTopicRenderer.GetSectionColor(Section: THTMLSection; var Color: byte): boolean;
- begin
- GetSectionColor:=HTMLGetSectionColor(Section,Color);
- end;
- function THTMLTopicRenderer.BuildTopic(P: PTopic; AURL: string; HTMLFile: PTextFile;
- ATopicLinks: PTopicLinkCollection): boolean;
- var OK: boolean;
- TP: pointer;
- I: sw_integer;
- begin
- URL:=AURL;
- Topic:=P; TopicLinks:=ATopicLinks;
- OK:=Assigned(Topic) and Assigned(HTMLFile) and Assigned(TopicLinks);
- if OK then
- begin
- if (Topic^.TextSize<>0) and Assigned(Topic^.Text) then
- begin
- FreeMem(Topic^.Text,Topic^.TextSize);
- Topic^.TextSize:=0; Topic^.Text:=nil;
- end;
- Topic^.TextSize:=MaxHelpTopicSize;
- GetMem(Topic^.Text,Topic^.TextSize);
- TopicTitle:='';
- InTitle:=false; InBody:={false}true; InAnchor:=false;
- InParagraph:=false; InPreformatted:=false;
- Indent:=0; CurHeadLevel:=0;
- PAlign:=paLeft;
- TextPtr:=0; LinkPtr:=0;
- AnyCharsInLine:=false;
- LastTextChar:=#0;
- OK:=Process(HTMLFile);
- if OK then
- begin
- { --- topic links --- }
- if (Topic^.Links<>nil) and (Topic^.LinkSize>0) then
- begin
- FreeMem(Topic^.Links,Topic^.LinkSize);
- Topic^.Links:=nil; Topic^.LinkCount:=0;
- end;
- Topic^.LinkCount:=LinkPtr{TopicLinks^.Count}; { <- eeeeeek! }
- GetMem(Topic^.Links,Topic^.LinkSize);
- if Topic^.LinkCount>0 then { FP causes numeric RTE 215 without this }
- for I:=0 to Min(Topic^.LinkCount-1,High(LinkIndexes)-1) do
- begin
- Topic^.Links^[I].FileID:=Topic^.FileID;
- Topic^.Links^[I].Context:=EncodeHTMLCtx(Topic^.FileID,LinkIndexes[I]+1);
- end;
- { --- topic text --- }
- GetMem(TP,TextPtr);
- Move(Topic^.Text^,TP^,TextPtr);
- FreeMem(Topic^.Text,Topic^.TextSize);
- Topic^.Text:=TP; Topic^.TextSize:=TextPtr;
- end
- else
- begin
- DisposeTopic(Topic);
- Topic:=nil;
- end;
- end;
- BuildTopic:=OK;
- end;
- constructor TCustomHTMLHelpFile.Init(AID: word);
- begin
- inherited Init(AID);
- New(Renderer, Init);
- New(TopicLinks, Init(50,500));
- end;
- function TCustomHTMLHelpFile.SearchTopic(HelpCtx: THelpCtx): PTopic;
- function MatchCtx(P: PTopic): boolean; {$ifndef FPC}far;{$endif}
- begin
- MatchCtx:=P^.HelpCtx=HelpCtx;
- end;
- var FileID,LinkNo: word;
- P: PTopic;
- FName: string;
- begin
- DecodeHTMLCtx(HelpCtx,FileID,LinkNo);
- if (HelpCtx<>0) and (FileID<>ID) then P:=nil else
- if (FileID=ID) and (LinkNo>TopicLinks^.Count) then P:=nil else
- begin
- P:=Topics^.FirstThat(@MatchCtx);
- if P=nil then
- begin
- if LinkNo=0 then
- FName:=DefaultFileName
- else
- FName:=TopicLinks^.At(LinkNo-1)^;
- P:=NewTopic(ID,HelpCtx,0,FName,nil,0);
- Topics^.Insert(P);
- end;
- end;
- SearchTopic:=P;
- end;
- function TCustomHTMLHelpFile.ReadTopic(T: PTopic): boolean;
- var OK: boolean;
- HTMLFile: PMemoryTextFile;
- Name: string;
- Link,Bookmark: string;
- P: sw_integer;
- begin
- Bookmark:='';
- OK:=T<>nil;
- if OK then
- begin
- if T^.HelpCtx=0 then Name:=DefaultFileName else
- begin
- Link:=TopicLinks^.At((T^.HelpCtx and $ffff)-1)^;
- Link:=FormatPath(Link);
- P:=Pos('#',Link);
- if P>0 then
- begin
- Bookmark:=copy(Link,P+1,length(Link));
- Link:=copy(Link,1,P-1);
- end;
- { if CurFileName='' then Name:=Link else
- Name:=CompletePath(CurFileName,Link);}
- Name:=Link;
- end;
- HTMLFile:=New(PDOSTextFile, Init(Name));
- if HTMLFile=nil then
- begin
- New(HTMLFile, Init);
- HTMLFile^.AddLine('<HEAD><TITLE>'+msg_pagenotavailable+'</TITLE></HEAD>');
- HTMLFile^.AddLine(
- '<BODY>'+
- FormatStrStr(msg_cantaccessurl,Name)+'<br><br>'+
- '</BODY>');
- end;
- OK:=Renderer^.BuildTopic(T,Name,HTMLFile,TopicLinks);
- if OK then CurFileName:=Name;
- if HTMLFile<>nil then Dispose(HTMLFile, Done);
- if BookMark='' then
- T^.StartNamedMark:=0
- else
- T^.StartNamedMark:=T^.GetNamedMarkIndex(BookMark)+1;
- end;
- ReadTopic:=OK;
- end;
- destructor TCustomHTMLHelpFile.Done;
- begin
- inherited Done;
- if Renderer<>nil then Dispose(Renderer, Done);
- if TopicLinks<>nil then Dispose(TopicLinks, Done);
- end;
- constructor THTMLHelpFile.Init(AFileName: string; AID: word; ATOCEntry: string);
- begin
- if inherited Init(AID)=false then Fail;
- DefaultFileName:=AFileName; TOCEntry:=ATOCEntry;
- if DefaultFileName='' then
- begin
- Done;
- Fail;
- end;
- end;
- function THTMLHelpFile.LoadIndex: boolean;
- begin
- IndexEntries^.Insert(NewIndexEntry(TOCEntry,ID,0));
- LoadIndex:=true;
- end;
- constructor THTMLIndexHelpFile.Init(AFileName: string; AID: word);
- begin
- inherited Init(AID);
- IndexFileName:=AFileName;
- end;
- function THTMLIndexHelpFile.LoadIndex: boolean;
- function FormatAlias(Alias: string): string;
- begin
- if Assigned(HelpFacility) then
- if length(Alias)>HelpFacility^.IndexTabSize-4 then
- Alias:=Trim(copy(Alias,1,HelpFacility^.IndexTabSize-4-2))+'..';
- FormatAlias:=Alias;
- end;
- (*procedure AddDoc(P: PHTMLLinkScanDocument); {$ifndef FPC}far;{$endif}
- var I: sw_integer;
- TLI: THelpCtx;
- begin
- for I:=1 to P^.GetAliasCount do
- begin
- TLI:=TopicLinks^.AddItem(P^.GetName);
- TLI:=EncodeHTMLCtx(ID,TLI+1);
- IndexEntries^.Insert(NewIndexEntry(FormatAlias(P^.GetAlias(I-1)),ID,TLI));
- end;
- end;*)
- var S: PBufStream;
- LS: PHTMLLinkScanner;
- OK: boolean;
- TLI: THelpCtx;
- I,J: sw_integer;
- begin
- New(S, Init(IndexFileName,stOpenRead,4096));
- OK:=Assigned(S);
- if OK then
- begin
- New(LS, LoadDocuments(S^));
- OK:=Assigned(LS);
- if OK then
- begin
- LS^.SetBaseDir(DirOf(IndexFileName));
- for I:=0 to LS^.GetDocumentCount-1 do
- for J:=0 to LS^.GetDocumentAliasCount(I)-1 do
- begin
- TLI:=TopicLinks^.AddItem(LS^.GetDocumentURL(I));
- TLI:=EncodeHTMLCtx(ID,TLI+1);
- IndexEntries^.Insert(NewIndexEntry(FormatAlias(LS^.GetDocumentAlias(I,J)),ID,TLI));
- end;
- Dispose(LS, Done);
- end;
- Dispose(S, Done);
- end;
- LoadIndex:=OK;
- end;
- END.
- {
- $Log$
- Revision 1.2 2000-10-31 22:35:56 pierre
- * New big merge from fixes branch
- Revision 1.1.2.2 2000/10/18 21:53:27 pierre
- * several Gabor fixes
- Revision 1.1.2.1 2000/09/18 13:20:56 pierre
- New bunch of Gabor changes
- Revision 1.1 2000/07/13 09:48:37 michael
- + Initial import
- Revision 1.15 2000/06/22 09:07:15 pierre
- * Gabor changes: see fixes.txt
- Revision 1.14 2000/06/16 08:50:45 pierre
- + new bunch of Gabor's changes
- }
|