Browse Source

--- Merging r13947 into '.':
U packages/chm/src/chmsitemap.pas
--- Merging r13955 into '.':
U packages/chm/src/chmreader.pas
--- Merging r13956 into '.':
G packages/chm/src/chmreader.pas
--- Merging r14103 into '.':
U packages/chm/src/chmwriter.pas
--- Merging r14345 into '.':
U ide/wchmhwrap.pas
--- Merging r14346 into '.':
G ide/wchmhwrap.pas
--- Merging r14497 into '.':
U packages/chm/src/chmfilewriter.pas
--- Merging r14498 into '.':
G packages/chm/src/chmfilewriter.pas
--- Merging r14499 into '.':
G packages/chm/src/chmfilewriter.pas
G packages/chm/src/chmwriter.pas

# revisions: 13947,13955,13956,14102,14103,14345,14346,14497,14498,14499
------------------------------------------------------------------------
r13947 | andrew | 2009-10-24 21:06:12 +0200 (Sat, 24 Oct 2009) | 2 lines
Changed paths:
M /trunk/packages/chm/src/chmsitemap.pas

* Fixed bug #14858 where chmsitemap could not properly read a file

------------------------------------------------------------------------
------------------------------------------------------------------------
r13955 | andrew | 2009-10-26 01:50:15 +0100 (Mon, 26 Oct 2009) | 2 lines
Changed paths:
M /trunk/packages/chm/src/chmreader.pas

* Fixed a chm reader bug that Return value was not initialized if neither binary or text index existed

------------------------------------------------------------------------
------------------------------------------------------------------------
r13956 | andrew | 2009-10-26 02:12:11 +0100 (Mon, 26 Oct 2009) | 2 lines
Changed paths:
M /trunk/packages/chm/src/chmreader.pas

* reverted 13955 since a fix was already in place

------------------------------------------------------------------------
------------------------------------------------------------------------
r14102 | marco | 2009-11-07 17:24:06 +0100 (Sat, 07 Nov 2009) | 2 lines
Changed paths:
M /trunk/packages/fcl-base/src/gettext.pp

* Patch for gettext empty string problem, Mantis 14902

------------------------------------------------------------------------
------------------------------------------------------------------------
r14103 | andrew | 2009-11-07 20:36:08 +0100 (Sat, 07 Nov 2009) | 3 lines
Changed paths:
M /trunk/packages/chm/src/chmwriter.pas

* Split TChmWriter to TITSFWriter and TChmWriter
* Some endian fixes for chm binary index

------------------------------------------------------------------------
------------------------------------------------------------------------
r14345 | marco | 2009-12-06 22:03:35 +0100 (Sun, 06 Dec 2009) | 2 lines
Changed paths:
M /trunk/ide/wchmhwrap.pas

* minor fix for problem of // with bin index chm files.

------------------------------------------------------------------------
------------------------------------------------------------------------
r14346 | marco | 2009-12-06 22:05:51 +0100 (Sun, 06 Dec 2009) | 1 line
Changed paths:
M /trunk/ide/wchmhwrap.pas

* another minor incompatibility
------------------------------------------------------------------------
------------------------------------------------------------------------
r14497 | marco | 2009-12-29 21:29:37 +0100 (Tue, 29 Dec 2009) | 2 lines
Changed paths:
M /trunk/packages/chm/src/chmfilewriter.pas

* context support in the project.

------------------------------------------------------------------------
------------------------------------------------------------------------
r14498 | marco | 2009-12-29 22:04:23 +0100 (Tue, 29 Dec 2009) | 2 lines
Changed paths:
M /trunk/packages/chm/src/chmfilewriter.pas

* small fix for last commit that avoids trouble when project is created programmatically

------------------------------------------------------------------------
------------------------------------------------------------------------
r14499 | marco | 2009-12-30 00:33:34 +0100 (Wed, 30 Dec 2009) | 1 line
Changed paths:
M /trunk/packages/chm/src/chmfilewriter.pas
M /trunk/packages/chm/src/chmwriter.pas

* Am now able to generate helpfiles with contextids from xml via chmfilewriter. XML format needs some rethinking though.
------------------------------------------------------------------------

git-svn-id: branches/fixes_2_4@14656 -

marco 15 years ago
parent
commit
d8ee4d4cd9
4 changed files with 674 additions and 338 deletions
  1. 4 1
      ide/wchmhwrap.pas
  2. 69 11
      packages/chm/src/chmfilewriter.pas
  3. 14 3
      packages/chm/src/chmsitemap.pas
  4. 587 323
      packages/chm/src/chmwriter.pas

+ 4 - 1
ide/wchmhwrap.pas

@@ -160,7 +160,10 @@ begin
   for i:=0 to findex.items.count-1 do
     begin
       item:=findex.items.item[i];
-      tli:=TopicLinks^.AddItem('/'+item.local);
+      if (length(item.local)>0) and (item.local[1]<>'/') then
+        tli:=TopicLinks^.AddItem('/'+item.local)
+      else
+        tli:=TopicLinks^.AddItem(item.local);
       TLI:=EncodeHTMLCtx(ID,TLI+1);
       IndexEntries^.Insert(NewIndexEntry(  FormatAlias(item.text),ID,TLI));
     end;

+ 69 - 11
packages/chm/src/chmfilewriter.pas

@@ -59,6 +59,7 @@ type
     procedure SaveToFile(AFileName: String);
     procedure WriteChm(AOutStream: TStream);
     function ProjectDir: String;
+    procedure AddFileWithContext(contextid:integer;filename:ansistring;contextname:ansistring='');
     // though stored in the project file, it is only there for the program that uses the unit
     // since we actually write to a stream
     property OutputFileName: String read FOutputFileName write FOutputFileName;
@@ -77,6 +78,12 @@ type
     property OnProgress: TChmProgressCB read FOnProgress write FOnProgress;
   end;
 
+  TChmContextNode = Class
+                     URLName       : AnsiString;
+                     ContextNumber : Integer;
+                     ContextName   : AnsiString;
+                    End;
+
 implementation
 
 uses XmlCfg, chmsitemap;
@@ -122,7 +129,7 @@ begin
       IndexSitemap := TChmSiteMap.Create(stIndex);
       indexSitemap.LoadFromStream(IndexStream);
       Writer.AppendBinaryIndexFromSiteMap(IndexSitemap,False);
-      IndexSitemap.Free;	
+      IndexSitemap.Free;
     end;
     IndexStream.Free;
   end;
@@ -148,8 +155,11 @@ begin
 end;
 
 destructor TChmProject.Destroy;
+var i : integer;
 begin
-  FFIles.Free;
+  for i:=0 to ffiles.count -1 do
+    ffiles.objects[i].free;
+  FFiles.Free;
   inherited Destroy;
 end;
 
@@ -157,7 +167,8 @@ procedure TChmProject.LoadFromFile(AFileName: String);
 var
   Cfg: TXMLConfig;
   FileCount: Integer;
-  I: Integer;
+  I  : Integer;
+  nd : TChmContextNode;
 begin
   Cfg := TXMLConfig.Create(nil);
   Cfg.Filename := AFileName;
@@ -165,9 +176,14 @@ begin
 
   Files.Clear;
   FileCount := Cfg.GetValue('Files/Count/Value', 0);
-  for I := 0 to FileCount-1 do begin
-    Files.Add(Cfg.GetValue('Files/FileName'+IntToStr(I)+'/Value',''));
-  end;
+  for I := 0 to FileCount-1 do
+    begin
+      nd:=TChmContextNode.Create;
+      nd.urlname:=Cfg.GetValue('Files/FileName'+IntToStr(I)+'/Value','');
+      nd.contextnumber:=Cfg.GetValue('Files/FileName'+IntToStr(I)+'/ContextNumber',0);
+      nd.contextname:=Cfg.GetValue('Files/FileName'+IntToStr(I)+'/ContextName','');
+      Files.AddObject(nd.urlname,nd);
+    end;
   IndexFileName := Cfg.GetValue('Files/IndexFile/Value','');
   TableOfContentsFileName := Cfg.GetValue('Files/TOCFile/Value','');
   // For chm file merging, bintoc must be false and binindex true. Change defaults in time?
@@ -182,19 +198,53 @@ begin
   Cfg.Free;
 end;
 
+procedure TChmProject.AddFileWithContext(contextid:integer;filename:ansistring;contextname:ansistring='');
+var x : integer;
+    nd : TChmContextNode;
+begin
+  x:=files.indexof(filename);
+  if x=-1 then
+    begin
+      nd:=TChmContextNode.Create;
+      nd.urlname:=filename;
+      nd.contextnumber:=contextid;
+      nd.contextname:=contextname;
+      Files.AddObject(nd.urlname,nd);
+    end
+  else
+   begin
+     nd:=TChmContextNode(files.objects[x]);
+     if not assigned(nd) then
+       begin
+         nd:=TChmContextNode.Create;
+         nd.urlname:=filename;
+         files.objects[x]:=nd;
+       end;
+      nd.contextnumber:=contextid;
+      nd.contextname:=contextname;
+   end;
+end;
+
 procedure TChmProject.SaveToFile(AFileName: String);
 var
   Cfg: TXMLConfig;
-  I: Integer;
-
+  I  : Integer;
+  nd : TChmContextNode;
 begin
   Cfg := TXMLConfig.Create(nil);
   Cfg.StartEmpty := True;
   Cfg.Filename := FileName;
   Cfg.Clear;
   Cfg.SetValue('Files/Count/Value', Files.Count);
-  for I := 0 to Files.Count-1 do begin
+  for I := 0 to Files.Count-1 do
+  begin
+    nd:=TChmContextNode(files.objects[i]);
     Cfg.SetValue('Files/FileName'+IntToStr(I)+'/Value', Files.Strings[I]);
+    if assigned(nd) then
+      begin
+        Cfg.SetValue('Files/FileName'+IntToStr(I)+'/ContextNumber', nd.contextnumber);
+        Cfg.SetValue('Files/FileName'+IntToStr(I)+'/ContextName', nd.contextname);
+      end;
   end;
   Cfg.SetValue('Files/IndexFile/Value', IndexFileName);
   Cfg.SetValue('Files/TOCFile/Value', TableOfContentsFileName);
@@ -217,10 +267,11 @@ end;
 
 procedure TChmProject.WriteChm(AOutStream: TStream);
 var
-  Writer: TChmWriter;
+  Writer     : TChmWriter;
   TOCStream,
   IndexStream: TFileStream;
-
+  nd         : TChmContextNode;
+  I          : Integer;
 begin
   IndexStream := nil;
   TOCStream := nil;
@@ -242,6 +293,13 @@ begin
   Writer.HasBinaryTOC := MakeBinaryTOC;
   Writer.HasBinaryIndex := MakeBinaryIndex;
 
+  for i:=0 to files.count-1 do
+    begin
+      nd:=TChmContextNode(files.objects[i]);
+      if assigned(nd) and (nd.contextnumber<>0) then
+        Writer.AddContext(nd.ContextNumber,files[i]);
+    end;
+
   // and write!
   Writer.Execute;
 

+ 14 - 3
packages/chm/src/chmsitemap.pas

@@ -124,6 +124,7 @@ type
     FUseFolderImages: Boolean;
     FWindowName: String;
     FLevel: Integer;
+    FLevelForced: Boolean;
     FWindowStyles: LongInt;
     procedure SetItems(const AValue: TChmSiteMapItems);
   protected
@@ -202,7 +203,7 @@ begin
   else begin // looking for /HTML
     if TagName = '/HTML' then Exclude(FSiteMapTags, smtHTML);
   end;}
-  
+
   //if (smtHTML in FSiteMapTags) then begin
      if not (smtBODY in FSiteMapTags) then begin
        if TagName = 'BODY' then Include(FSiteMapTags, smtBODY);
@@ -210,7 +211,7 @@ begin
      else begin
        if TagName = '/BODY' then Exclude(FSiteMapTags, smtBODY);
      end;
-     
+
      if (smtBODY in FSiteMapTags) then begin
        //WriteLn('GOT TAG: ', AActualTag);
        if TagName = 'UL' then begin
@@ -221,16 +222,26 @@ begin
          //WriteLN('Dec Level');
          DecreaseULevel;
        end
+       else if (TagName = 'LI') and (FLevel = 0) then
+         FLevelForced := True
        else if TagName = 'OBJECT' then begin
          Include(FSiteMapBodyTags, smbtOBJECT);
+         if FLevelForced then
+           IncreaseULevel;
          If FLevel > 0 then // if it is zero it is the site properties
            NewSiteMapItem;
        end
        else if TagName = '/OBJECT' then begin
          Exclude(FSiteMapBodyTags, smbtOBJECT);
+         if FLevelForced then
+         begin
+           DecreaseULevel;
+           FLevelForced := False;
+         end;
        end
        else begin // we are the properties of the object tag
-         if (smbtOBJECT in FSiteMapBodyTags) then begin
+         if (FLevel > 0 ) and (smbtOBJECT in FSiteMapBodyTags) then begin
+
            if LowerCase(GetTagName(AActualTag)) = 'param' then begin
 
              TagAttributeName := GetVal(AActualTag, 'name');

File diff suppressed because it is too large
+ 587 - 323
packages/chm/src/chmwriter.pas


Some files were not shown because too many files changed in this diff