Changeset 342


Ignore:
Timestamp:
Jun 1, 2009, 2:42:16 PM (16 years ago)
Author:
RBRi
Message:

index is a real object now
support for env variables to make glossary simulation work

Location:
trunk/NewView
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/NewView/CmdLineParameterUnit.pas

    r259 r342  
    8686  end;
    8787
     88
     89  // add all file name parts of aFileNameString to the result
     90  // check for containing environment vars
     91  // and include all help files if the environment var points
     92  // to a directory
     93  PROCEDURE ParseAndExpandFileNames(const aFileNameString: String; aResult: TStrings );
     94
     95
    8896  // returns a string containing the whole
    8997  // command line parametes
     
    680688
    681689
     690  PROCEDURE ParseAndExpandFileNames(const aFileNameString : String; aResult: TStrings);
     691  var
     692    i : longint;
     693    tmpFileNamesList: TStringList;
     694    tmpItem: String;
     695    tmpEnvironmentVarValue: string;
     696  begin
     697    LogEvent(LogDebug, 'ParseAndExpandFileNames "' + aFileNameString + '"');
     698
     699    tmpFileNamesList := TStringList.Create;
     700
     701    StrExtractStrings(tmpFileNamesList, aFileNameString, [HELP_FILE_DELIMITER, PATH_SEPARATOR], #0);
     702    for i := 0 to tmpFileNamesList.Count - 1 do
     703    begin
     704      tmpItem := tmpFileNamesList[i];
     705
     706      // is this a environment var
     707      tmpEnvironmentVarValue := GetEnv(tmpItem);
     708      if DosError = 0 then
     709      begin
     710        // environment var exists
     711        LogEvent(LogStartup, '    Environment var found; translated to: "' + tmpEnvironmentVarValue + '"');
     712        ParseAndExpandFileNames(tmpEnvironmentVarValue, aResult);
     713      end
     714      else if DirectoryExists(tmpItem) then
     715      begin
     716        ListFilesInDirectory(tmpItem, '*' + HELP_FILE_EXTENSION, true, aResult);
     717      end
     718      else
     719      begin
     720        aResult.Add(tmpItem);
     721      end;
     722    end;
     723
     724    tmpFileNamesList.Destroy;
     725  end;
     726
     727
    682728  FUNCTION nativeOS2GetCmdLineParameter : AnsiString;
    683729  VAR
  • trunk/NewView/HelpFile.pas

    r252 r342  
    2222
    2323type
     24
     25  TIndexEntry = class
     26  private
     27    name: String;
     28    topic: TTopic;
     29    flags: uint8;
     30  public
     31    CONSTRUCTOR Create(aName: String; aTopic: TTopic; aFlags: uint8);
     32    DESTRUCTOR Destroy; override;
     33
     34    PROPERTY getTopic: TTopic read topic;
     35    FUNCTION getLabel: String;
     36    FUNCTION isGlobal: boolean;
     37    FUNCTION getLevel: integer;
     38  end;
     39
     40
     41  TIndex = class
     42  private
     43    entries: TStringList;
     44    // labels: TStringList;
     45  public
     46    CONSTRUCTOR Create;
     47    DESTRUCTOR Destroy; override;
     48
     49    FUNCTION Count: longint;
     50    FUNCTION GetLabels: TStringList;
     51    FUNCTION GetTopic(aPos: longint): TTopic;
     52    PROCEDURE Add(anIndexEntry: TIndexEntry);
     53  end;
     54
     55
    2456  THelpFile = class
    2557  protected
     
    3769    _Dictionary: TList; // pointers to strings.
    3870
    39     _Index: TStringList;
     71    _Index: TIndex;
    4072
    4173    _SearchTable: TSearchTable;
     
    82114    function GetDictionaryWordPtr( Index: longint ): pstring;
    83115
    84     function GetIndexEntryPtr( Index: longint ): pstring;
    85116    function GetHighlightWords: UInt32ArrayPointer;
    86117
     
    94125
    95126  public
    96     constructor Create( const FileName: string );
     127    constructor Create( const aFileName: string );
    97128
    98129    destructor Destroy; override;
    99130
    100     function GetIndex: TStringList;
     131    function GetIndex: TIndex;
    101132
    102133    property Title: string read _Title;
     
    104135    property TopicList: TList read _Topics;
    105136    property TopicCount: longint read GetTopicCount;
    106     property Index: TStringList read GetIndex;
    107     property IndexEntryPtr[ index: longint ]: pstring read GetIndexEntryPtr;
     137    property Index: TIndex read GetIndex;
    108138    property Filename: string read _FileName;
    109139
     
    170200  FileErrorInUse: string;
    171201  FileErrorInvalidHeader: string;
     202
     203
     204  // -----------
     205  // TIndexEntry
     206  // -----------
     207
     208  CONSTRUCTOR TIndexEntry.Create(aName: String; aTopic: TTopic; aFlags: uint8);
     209  begin
     210    LogEvent(LogObjConstDest, 'TIndexEntry.Create');
     211    name := aName;
     212    topic := aTopic;
     213    flags := aFlags;
     214  end;
     215
     216
     217  DESTRUCTOR TIndexEntry.Destroy;
     218  begin
     219    LogEvent(LogObjConstDest, 'TIndexEntry.Destroy');
     220    topic := nil;
     221    // inherited Destroy;
     222  end;
     223
     224
     225  FUNCTION TIndexEntry.getLabel: String;
     226  begin
     227    result := name;
     228
     229    // index level check (level 1 or 2)
     230    if (getLevel) > 1 then
     231    begin
     232      result := '- ' + result;
     233    end;
     234
     235    if isGlobal then
     236    begin
     237      result := result + ' (g)';
     238    end;
     239  end;
     240
     241
     242  FUNCTION TIndexEntry.isGlobal: boolean;
     243  begin
     244    result := (flags and 64) > 0
     245  end;
     246
     247
     248  FUNCTION TIndexEntry.getLevel: integer;
     249  begin
     250    result := 1;
     251
     252    // index level check (level 1 or 2)
     253    if (flags and 2 ) > 0 then
     254    begin
     255      result := 2;
     256    end;
     257  end;
     258
     259
     260
     261
     262  // -----------
     263  // TIndex
     264  // -----------
     265  CONSTRUCTOR TIndex.Create;
     266  begin
     267    inherited Create;
     268
     269    entries := TStringList.Create;
     270    // labels := nil; // lazy
     271  end;
     272
     273
     274  DESTRUCTOR TIndex.Destroy;
     275  var
     276    i : longint;
     277    tmpEntry : TIndexEntry;
     278  begin
     279    LogEvent(LogObjConstDest, 'TIndex.Destroy (size:' + IntToStr(entries.Count) + ')');
     280
     281    for i := 0 to entries.Count - 1 do
     282    begin
     283      tmpEntry := TIndexEntry(entries.Objects[i]);
     284      if tmpEntry <> nil then
     285      begin
     286        tmpEntry.Destroy;
     287        entries.Objects[i] := nil;
     288      end;
     289    end;
     290    entries.Destroy;
     291
     292    inherited Destroy;
     293  end;
     294
     295
     296  FUNCTION TIndex.Count: longint;
     297  begin
     298    result := entries.Count;
     299  end;
     300
     301
     302  FUNCTION TIndex.GetLabels: TStringList;
     303  begin
     304    result := entries;
     305  end;
     306
     307
     308  FUNCTION TIndex.GetTopic(aPos: longint): TTopic;
     309  begin
     310    result := TTopic(entries.Objects[aPos]);
     311  end;
     312
     313
     314  PROCEDURE TIndex.add(anIndexEntry: TIndexEntry);
     315  begin
     316    // LogEvent(LogDebug, 'TIndex.add(' + aName + ', ' + anIndexEntry.ClassName);
     317    entries.AddObject(anIndexEntry.getLabel, anIndexEntry);
     318  end;
     319
     320
     321
    172322
    173323Procedure OnLanguageEvent( Language: TLanguageFile;
     
    221371end;
    222372
    223 constructor THelpFile.Create( const FileName: string );
    224 begin
    225   LogEvent(LogParse, 'Helpfile Load: ' + FileName);
    226 
    227   _FileName := FileName;
     373
     374constructor THelpFile.Create(const aFileName: string);
     375begin
     376  LogEvent(LogObjConstDest, 'THelpFile.Create (file:' + aFileName + ')');
     377  LogEvent(LogParse, 'Helpfile Load: ' + aFileName);
     378
     379  _FileName := aFileName;
    228380
    229381  InitMembers;
     
    248400end;
    249401
     402
    250403destructor THelpFile.Destroy;
    251404begin
     405  LogEvent(LogObjConstDest, 'THelpFile.Destroy');
    252406  DeallocateMemory( _pHeader );
    253407  DeallocateMemory( _pExtendedHeader );
     
    262416  DeallocateMemory( _pHighlightWords );
    263417
     418  // index entries are pointing to topics
     419  // so let us clean them first
     420  if Assigned( _Index ) then
     421  begin
     422    _Index.Destroy;
     423  end;
     424
    264425  if Assigned( _Topics ) then
     426  begin
    265427    DestroyListAndObjects( _Topics );
    266 
    267   if Assigned( _Index ) then
    268     _Index.Destroy;
     428  end;
    269429
    270430  _Dictionary.Free;
     
    453613end;
    454614
    455 function THelpFile.GetIndex: TStringList;
     615
     616function THelpFile.GetIndex: TIndex;
    456617begin
    457618  if _Index = nil then
     
    477638  pEnd: pointer;
    478639  pIndexData: pointer;
     640
     641  tmpIndexEntry: TIndexEntry;
    479642begin
    480643  LogEvent(LogParse, 'Read index');
    481644
    482   _Index := TStringList.Create;
     645  _Index := TIndex.Create;
    483646
    484647  if _pHeader^.nindex = 0 then
     
    504667
    505668    GetMemString( p, EntryText, IndexTitleLen );
    506     if ( pEntryHeader^.flags and 2 ) > 0 then
    507       EntryText := '- ' + EntryText;
     669
    508670    if pEntryHeader^.TOCIndex < _Topics.Count then
    509       _Index.AddObject( EntryText, _Topics[ pEntryHeader^.TOCIndex ] )
     671    begin
     672      tmpIndexEntry := TIndexEntry.Create(EntryText, _Topics[pEntryHeader^.TOCIndex], pEntryHeader^.flags);
     673      _Index.Add(tmpIndexEntry);
     674    end
    510675    else
    511676//      raise EHelpFileException.Create( 'Error reading help file index - out of range topic reference' );
     
    666831end;
    667832
     833
     834// TODO move to index class
    668835function THelpFile.FindTopicByIndexStartsWith( const SearchText: string ): TTopic;
    669836var
    670837  i: longint;
    671   tmpIndex: String;
     838  tmpLabel: String;
    672839begin
    673840  result := nil;
    674841  GetIndex; // make sure it's read
     842
    675843  for i := 0 to _Index.Count - 1 do
    676844  begin
    677     tmpIndex := _Index.ValuePtrs[i]^;
    678     if StrStartsWithIgnoringCase(tmpIndex, SearchText) then
     845    tmpLabel := _Index.GetLabels.ValuePtrs[i]^;
     846    if StrStartsWithIgnoringCase(tmpLabel, SearchText) then
    679847    begin
    680848      // found
    681       result := TTopic( Index.Objects[ i ] );
     849      result := Index.getTopic(i);
    682850      exit;
    683851    end;
     
    685853end;
    686854
    687 function THelpFile.FindTopicByIndexContains( const SearchText: string ): TTopic;
     855
     856function THelpFile.FindTopicByIndexContains(const SearchText: string): TTopic;
    688857var
    689858  i: longint;
     859  tmpLabel: String;
    690860begin
    691861  result := nil;
    692862  GetIndex; // make sure it's read
     863
    693864  for i := 0 to _Index.Count - 1 do
    694865  begin
    695     if CaseInsensitivePos( SearchText, _Index.ValuePtrs[ i ] ^ ) > 0 then
     866    tmpLabel := _Index.GetLabels.ValuePtrs[i]^;
     867    if CaseInsensitivePos(SearchText, tmpLabel) > 0 then
    696868    begin
    697869      // found
    698       result := TTopic( Index.Objects[ i ] );
     870      result := Index.getTopic(i);
    699871      exit;
    700872    end;
    701873  end;
    702874end;
     875
    703876
    704877function THelpFile.FindTopicByTitleStartsWith( const SearchText: string ): TTopic;
     
    9461119begin
    9471120  Result := pstring( _Dictionary[ Index ] );
    948 end;
    949 
    950 function THelpFile.GetIndexEntryPtr( Index: longint ): pstring;
    951 begin
    952   if _Index = nil then
    953     ReadIndex;
    954   Result := _Index.ValuePtrs[ Index ];
    9551121end;
    9561122
  • trunk/NewView/MainForm.pas

    r259 r342  
    383383    Procedure AddCurrentToMRUFiles;
    384384
    385     Function LoadFiles( const FileNames: TStrings;
    386                         HelpFiles: TList ): boolean;
     385    Function LoadFiles(const aFileNames: TStrings; aHelpFiles: TList) : boolean;
    387386    Procedure DisplayFiles( NewFiles: TList;
    388387                            Var FirstContentsNode: TNode );
     
    16121611    end;
    16131612  end;
    1614  
     1613
    16151614  CreateMRUMenuItems;
    16161615End;
     
    16721671  tmpFileNames := TStringList.Create;
    16731672
    1674   StrExtractStringsIgnoreEmpty(tmpFileNames, TextList, [HELP_FILE_DELIMITER], #0);
     1673  ParseAndExpandFileNames(TextList, tmpFileNames);
    16751674  if tmpFileNames.Count > 0 then
    16761675  begin
    1677     result := OpenFiles(tmpFileNames, '', DisplayFirstTopic );
     1676    result := OpenFiles(tmpFileNames, '', DisplayFirstTopic);
    16781677  end
    16791678  else
     
    22832282    CmdLineParameters.writeDetailsTo(Lines);
    22842283    writeSettingsDetailsTo(Lines);
     2284    writeDebugSetupDetailsTo(Lines);
    22852285  end;
    22862286
     
    40654065  if CmdLineParameters.getOwnerWindow <> NULLHANDLE then
    40664066  begin
    4067     LogEvent(LogStartup, 'Setting owner: '
    4068                   + IntToStr( CmdLineParameters.getOwnerWindow));
    4069     WinSetOwner( Frame.Handle,
    4070                  CmdLineParameters.getOwnerWindow );
    4071 
     4067    LogEvent(LogStartup, 'Setting owner: ' + IntToStr( CmdLineParameters.getOwnerWindow));
     4068    WinSetOwner( Frame.Handle, CmdLineParameters.getOwnerWindow );
    40724069  end;
    40734070
     
    40854082  CoolBar.SetMinConstButtonWidth;
    40864083
    4087   LogEvent(LogStartup, 'Post WM_OPENED');
    4088 
    40894084  ResetProgress;
    40904085
     
    40954090  AddShortcut( kbCtrlCLeft, kbCtrlCLeft ); // back
    40964091
     4092  LogEvent(LogStartup, 'Post WM_OPENED');
    40974093  PostMsg( Handle, WM_OPENED, 0, 0 );
    40984094End;
     
    41964192  LogEvent(LogStartup, 'Finish paint');
    41974193  Update;
     4194  LogEvent(LogStartup, 'BringToFront');
     4195  MainForm.BringToFront;
    41984196
    41994197  if not CmdLineParameters.getHelpManagerFlag then
     
    42224220    Filenames := TStringList.Create;
    42234221
    4224     StrExtractStringsIgnoreEmpty(Filenames, tmpFileNames, [HELP_FILE_DELIMITER], #0);
    4225 
     4222    ParseAndExpandFileNames(tmpFileNames, Filenames);
    42264223    LogEvent(LogStartup, 'Call OpenFiles');
    42274224
     
    57225719  Tag:= MenuItem.Tag;
    57235720  MRUItem := Settings.MRUList[ Tag ];
     5721// RBRi woher kommt die liste?
    57245722  if OpenFiles( MRUItem.FileNames, '', true ) then
    57255723  begin
     
    62286226procedure TMainForm.LoadIndex;
    62296227var
    6230   HelpFile: THelpFile;
    6231   TextCompareResult: integer;
     6228  tmpHelpFile: THelpFile;
     6229  tmpTextCompareResult: integer;
    62326230
    62336231  FileIndex: longint;
     
    62356233  Contents: TList;
    62366234  ContentsLists: TList; // of tlist
    6237   IndexLists: TList; // of tstringlist
     6235  tmpIndexLists: TList; // of tstringlist
    62386236  ContentsNextIndex: array[ 0..255 ] of longint;
    62396237  IndexNextIndex: array[ 0..255 ] of longint;
    62406238  Topic: TTopic;
    62416239
    6242   ListIndex: longint;
    6243 
    62446240  pListEntry: pstring;
    62456241  pLowestEntry: pstring;
    62466242  pLastEntry: pstring;
    62476243
    6248   LowestEntryListIndex: longint;
    6249   LowestEntryListType: TListType;
    6250   LowestEntryTopic: TTopic;
    6251 
    6252   Index: TStringList;
     6244  tmpLowestEntryListIndex: longint;
     6245  tmpLowestEntryListType: TListType;
     6246  tmpLowestEntryTopic: TTopic;
     6247
     6248  tmpIndex: TStringList;
    62536249
    62546250  i : longint;
     
    62646260
    62656261  ContentsLists := TList.Create;
    6266   IndexLists := TList.Create;
     6262  tmpIndexLists := TList.Create;
    62676263
    62686264  // collect the contents and index lists from the files
    62696265  for FileIndex := 0 to CurrentOpenFiles.Count - 1 do
    62706266  begin
    6271     HelpFile := CurrentOpenFiles[ FileIndex ];
     6267    tmpHelpFile := CurrentOpenFiles[ FileIndex ];
    62726268    ProgressBar.Position := 70 + 10 * FileIndex div CurrentOpenFiles.Count;
    62736269
     
    62756271    begin
    62766272      Contents := TList.Create;
    6277       Contents.Capacity := HelpFile.TopicCount;
     6273      Contents.Capacity := tmpHelpFile.TopicCount;
    62786274
    62796275      // copy [contents] topic list
    6280       for i := 0 to HelpFile.TopicCount - 1 do
     6276      for i := 0 to tmpHelpFile.TopicCount - 1 do
    62816277      begin
    6282         Topic := HelpFile.Topics[ i ];
     6278        Topic := tmpHelpFile.Topics[ i ];
    62836279        if Topic.ShowInContents then
    62846280          Contents.Add( Topic );
     
    62966292    if Settings.IndexStyle in [ isFileOnly, isFull ] then
    62976293    begin
    6298       IndexLists.Add( HelpFile.Index );
    6299       IndexNextIndex[ IndexLists.Count - 1 ] := 0;
     6294      tmpIndexLists.Add(tmpHelpFile.Index.GetLabels);
     6295      IndexNextIndex[ tmpIndexLists.Count - 1 ] := 0;
    63006296    end;
    63016297  end;
     
    63136309  begin
    63146310    pLowestEntry := NullStr;
    6315     LowestEntryListIndex := -1;
     6311    tmpLowestEntryListIndex := -1;
    63166312
    63176313    // Find alphabetically lowest (remaining) topic
    63186314
    63196315    // first, look in contents lists
    6320     for ListIndex := 0 to ContentsLists.Count - 1 do
     6316    LogEvent(LogDebug, '  Merge contents' );
     6317    for i := 0 to ContentsLists.Count - 1 do
    63216318    begin
    6322       Contents := ContentsLists[ ListIndex ];
    6323       if ContentsNextIndex[ ListIndex ] < Contents.Count then
     6319      Contents := ContentsLists[i];
     6320      if ContentsNextIndex[i] < Contents.Count then
    63246321      begin
    63256322        // list is not yet finished, get next entry
    6326         Topic := Contents[ ContentsNextIndex[ ListIndex ] ];
     6323        Topic := Contents[ ContentsNextIndex[i] ];
    63276324        pListEntry := Topic.TitlePtr;
    63286325
    63296326        if pLowestEntry^ <> '' then
    6330           TextCompareResult := CompareText( pListEntry^, pLowestEntry^ )
     6327          tmpTextCompareResult := CompareText( pListEntry^, pLowestEntry^ )
    63316328        else
    6332           TextCompareResult := -1;
    6333 
    6334         if TextCompareResult < 0 then
     6329          tmpTextCompareResult := -1;
     6330
     6331        if tmpTextCompareResult < 0 then
    63356332        begin
    63366333          // this index entry comes before the lowest one so far
    63376334          pLowestEntry := pListEntry;
    6338           LowestEntryListIndex := ListIndex;
    6339           LowestEntryListType := ltContents;
    6340           LowestEntryTopic := Topic;
     6335          tmpLowestEntryListIndex := i;
     6336          tmpLowestEntryListType := ltContents;
     6337          tmpLowestEntryTopic := Topic;
    63416338        end;
    63426339      end;
     
    63446341
    63456342    // look in indices
    6346     for ListIndex := 0 to IndexLists.Count - 1 do
     6343    LogEvent(LogDebug, '  Merge indices' );
     6344    for i := 0 to tmpIndexLists.Count - 1 do
    63476345    begin
    6348       Index := IndexLists[ ListIndex ];
    6349       if IndexNextIndex[ ListIndex ] < Index.Count then
     6346      LogEvent(LogDebug, '  Merge indices ' + IntToStr(i) );
     6347      tmpIndex := tmpIndexLists[i];
     6348      if IndexNextIndex[i] < tmpIndex.Count then
    63506349      begin
    63516350        // list is not yet finished, get next entry
    6352         pListEntry := Index.ValuePtrs[ IndexNextIndex[ ListIndex ] ];
     6351        pListEntry := tmpIndex.ValuePtrs[ IndexNextIndex[i] ];
    63536352
    63546353        if pLowestEntry^ <> '' then
    6355           TextCompareResult := CompareText( pListEntry^, pLowestEntry^ )
     6354          tmpTextCompareResult := CompareText( pListEntry^, pLowestEntry^ )
    63566355        else
    6357           TextCompareResult := -1;
    6358 
    6359         if TextCompareResult < 0 then
     6356          tmpTextCompareResult := -1;
     6357
     6358        if tmpTextCompareResult < 0 then
    63606359        begin
    63616360          // this index entry comes before the lowest one so far
    63626361          pLowestEntry := pListEntry;
    6363           LowestEntryListIndex := ListIndex;
    6364           LowestEntryListType := ltIndex;
    6365           LowestEntryTopic := TTopic( Index.Objects[ IndexNextIndex[ ListIndex ] ] );
     6362          tmpLowestEntryListIndex := i;
     6363          tmpLowestEntryListType := ltIndex;
     6364
     6365          LogEvent(LogDebug, '  Merge indices ' + tmpIndex.Objects[ IndexNextIndex[i] ].ClassName);
     6366          tmpLowestEntryTopic := TIndexEntry( tmpIndex.Objects[ IndexNextIndex[i] ] ).getTopic;
    63666367        end;
    63676368      end;
    63686369    end;
    63696370
    6370     if LowestEntryListIndex = -1 then
     6371    if tmpLowestEntryListIndex = -1 then
    63716372      // we're out
    63726373      break;
     
    63746375    if ( pLowestEntry^ ) <> ( pLastEntry^ ) then
    63756376      // add, if different from last
    6376       DisplayedIndex.AddObject( pLowestEntry^,
    6377                                 LowestEntryTopic );
     6377      DisplayedIndex.AddObject( pLowestEntry^, tmpLowestEntryTopic );
    63786378    pLastEntry := pLowestEntry;
    63796379
    6380     if LowestEntryListType = ltContents then
     6380    if tmpLowestEntryListType = ltContents then
    63816381    begin
    6382       inc( ContentsNextIndex[ LowestEntryListIndex ] );
     6382      inc( ContentsNextIndex[ tmpLowestEntryListIndex ] );
    63836383    end
    63846384    else
     
    63866386      // found in one of indices.
    63876387      // Check for subsequent indented strings
    6388       Index := IndexLists[ LowestEntryListIndex ];
    6389 
    6390       i := IndexNextIndex[ LowestEntryListIndex ] + 1;
    6391       while i < Index.Count do
     6388      tmpIndex := tmpIndexLists[ tmpLowestEntryListIndex ];
     6389
     6390      i := IndexNextIndex[ tmpLowestEntryListIndex ] + 1;
     6391      while i < tmpIndex.Count do
    63926392      begin
    6393         pListEntry := Index.ValuePtrs[ i ];
     6393        pListEntry := tmpIndex.ValuePtrs[ i ];
    63946394        if pListEntry^ = '' then
    63956395          break;
     
    64006400
    64016401        // found one,
    6402         Topic := Index.Objects[ i ] as TTopic;
     6402        Topic := TIndexEntry(tmpIndex.Objects[ i ]).getTopic;
    64036403        DisplayedIndex.AddObject( pListEntry^,
    64046404                                  Topic );
    64056405        inc( i );
    64066406      end;
    6407       IndexNextIndex[ LowestEntryListIndex ] := i;
     6407      IndexNextIndex[ tmpLowestEntryListIndex ] := i;
    64086408    end;
    64096409  end;
     
    64196419  LogEvent(LogStartup, '  Tidy up' );
    64206420
    6421   IndexLists.Destroy;
     6421  tmpIndexLists.Destroy;
    64226422
    64236423  DestroyListAndObjects( ContentsLists );
     
    64656465                             const SelectFirstContentsNode: boolean ): boolean;
    64666466var
    6467   FileNames: TStringList;
    6468 begin
    6469   FileNames := TStringList.Create;
    6470   FileNames.Add( FileName );
    6471   Result := OpenFiles( FileNames,
     6467  tmpFileNames: TStringList;
     6468begin
     6469  tmpFileNames := TStringList.Create;
     6470  ParseAndExpandFileNames(FileName, tmpFileNames);
     6471  Result := OpenFiles( tmpFileNames,
    64726472                       WindowTitle,
    64736473                       DisplayFirstTopic );
    6474   FileNames.Destroy;
     6474  tmpFileNames.Destroy;
    64756475end;
    64766476
     
    64786478                                       const DisplayFirstTopic: boolean ): boolean;
    64796479var
    6480   FileNames: TStringList;
    6481 begin
    6482   FileNames := TStringList.Create;
    6483   FileNames.Add( FileName );
    6484   Result := OpenAdditionalFiles( FileNames,
    6485                                  DisplayFirstTopic );
    6486   FileNames.Destroy;
     6480  tmpFileNames: TStringList;
     6481begin
     6482  tmpFileNames := TStringList.Create;
     6483  ParseAndExpandFileNames(FileName, tmpFileNames);
     6484  Result := OpenAdditionalFiles(tmpFileNames, DisplayFirstTopic );
     6485  tmpFileNames.Destroy;
    64876486end;
    64886487
     
    65286527
    65296528// Load the specified set of help files
    6530 Function TMainForm.LoadFiles( const FileNames: TStrings;
    6531                               HelpFiles: TList ): boolean;
     6529Function TMainForm.LoadFiles(const aFileNames: TStrings; aHelpFiles: TList) : boolean;
    65326530var
    65336531  HelpFile: THelpFile;
    6534   FileIndex: longint;
     6532  FileIndex, i: longint;
    65356533  FileName: string;
    65366534  FullFilePath: string;
     
    65446542  LoadingFilenameList := TStringList.Create;
    65456543
    6546   TranslateIPFEnvironmentVars( FileNames, LoadingFilenameList );
     6544// RBRi  TranslateIPFEnvironmentVars( FileNames, LoadingFilenameList );
     6545  for i := 0 to aFileNames.Count - 1 do
     6546  begin
     6547    LoadingFilenameList.Add(aFileNames[i]);
     6548  end;
    65476549
    65486550  LogEvent(LogStartup, 'Finding files' );
     
    66096611         HelpFile.SetupFontSubstitutes( Settings.FixedFontSubstitutes );
    66106612
    6611       HelpFiles.Add( HelpFile );
     6613      aHelpFiles.Add( HelpFile );
    66126614
    66136615    except
     
    66316633        Result := false;
    66326634
    6633         DestroyListObjects( HelpFiles );
     6635        DestroyListObjects( aHelpFiles );
    66346636
    66356637        LoadingFilenameList.Destroy;
     
    66506652Procedure TMainForm.AddCurrentToMRUFiles;
    66516653var
    6652   Filenames: TStringList;
     6654  tmpFilenames: TStringList;
    66536655  i: longint;
    6654   HelpFile: THelpFile;
    6655 begin
    6656   Filenames := TStringList.Create;
    6657 
    6658   for i := 0 to CurrentOpenFiles.Count - 1 do
    6659   begin
    6660     HelpFile := CurrentOpenFiles[ i ];
    6661     Filenames.Add( HelpFile.Filename );
    6662   end;
    6663 
    6664   // update most-recently-used file list
    6665   HelpFile := CurrentOpenFiles[ 0 ];
    6666   AddToMRUList( HelpFile.Title,
    6667                 Filenames );
     6656  tmpHelpFile: THelpFile;
     6657begin
     6658  tmpFilenames := TStringList.Create;
     6659
     6660  if CurrentOpenFiles.Count > 0 then
     6661  begin
     6662    for i := 0 to CurrentOpenFiles.Count - 1 do
     6663    begin
     6664      tmpHelpFile := CurrentOpenFiles[ i ];
     6665      tmpFilenames.Add(tmpHelpFile.Filename);
     6666    end;
     6667
     6668    // update most-recently-used file list
     6669    tmpHelpFile := CurrentOpenFiles[ 0 ];
     6670    AddToMRUList(tmpHelpFile.Title, tmpFilenames);
     6671  end;
    66686672
    66696673  // recreate menu
    66706674  CreateMRUMenuItems;
    66716675
    6672   Filenames.Destroy;
     6676  tmpFilenames.Destroy;
    66736677end;
    66746678
     
    67226726                              const DisplayFirstTopic: boolean ): boolean;
    67236727var
    6724   HelpFiles: TList;
     6728  tmpHelpFiles: TList;
    67256729  FirstContentsNode: TNode;
    67266730begin
     
    67326736  SetWaitCursor;
    67336737
    6734   HelpFiles := TList.Create;
    6735 
    6736   if not LoadFiles(FileNames, HelpFiles ) then
     6738  tmpHelpFiles := TList.Create;
     6739
     6740// RBRi Translate
     6741  if not LoadFiles(FileNames, tmpHelpFiles) then
    67376742  begin
    67386743    ClearWaitCursor;
    6739     HelpFiles.Destroy;
     6744    tmpHelpFiles.Destroy;
    67406745    exit;
    67416746  end;
     
    67516756  CloseFile;
    67526757
    6753   AssignList( HelpFiles, CurrentOpenFiles );
     6758  AssignList(tmpHelpFiles, CurrentOpenFiles );
    67546759
    67556760  ProgressBar.Position := 50;
     
    67706775  ContentsOutline.Clear;
    67716776
    6772   DisplayFiles( HelpFiles,
     6777  DisplayFiles( tmpHelpFiles,
    67736778                FirstContentsNode );
    67746779
     
    68916896      exit;
    68926897
     6898    // no ParseAndExpandFileNames call required here
     6899    // this is the result of a file dialog
     6900    // no environment vars here
    68936901    if KeepCurrentFiles then
    68946902      OpenedOK := OpenAdditionalFiles( FileNames, true )
  • trunk/NewView/SearchUnit.pas

    r252 r342  
    273273  for IndexIndex := 0 to HelpFile.Index.Count - 1 do
    274274  begin
    275     Topic := HelpFile.Index.Objects[ IndexIndex ] as TTopic;
    276     pIndexEntry := HelpFile.IndexEntryPtr[ IndexIndex ];
     275    Topic := HelpFile.Index.getTopic(IndexIndex);
     276    pIndexEntry := HelpFile.Index.GetLabels.ValuePtrs[IndexIndex];
    277277    IndexEntryWordIndex := 0;
    278278
  • trunk/NewView/StartupUnit.pas

    r259 r342  
    1919const
    2020  OWN_HELP_MARKER = '[NVHELP]';
    21   HELP_FILE_DELIMITER = '+';
    2221
    2322
     
    2625// Look for any items that are actually specifiying environment
    2726// variables, and expand them to the contents of the variables
    28 Procedure TranslateIPFEnvironmentVars(const Items: TStrings; ExpandedItems: TStrings );
    2927
    3028// Given a filename, which may or may not contain a path or extension,
     
    5149  FileUtilsUnit;
    5250
    53 // Look for any items that are actually specifiying environment
    54 // variables, and expand them to the contents of the variables
    55 Procedure TranslateIPFEnvironmentVars(const Items: TStrings; ExpandedItems: TStrings );
    56 var
    57   i : longint;
    58   tmpItem: string;
    59   tmpEnvironmentVarValue: string;
    60 begin
    61   LogEvent(LogStartup, 'Translating environment vars' );
    62   for i := 0 to Items.Count - 1 do
    63   begin
    64     tmpItem := Items[i];
    65 
    66     tmpItem := StrTrimChars(tmpItem, [StrSingleQuote]); // remove single quotes
    67     tmpItem := StrTrimChars(tmpItem, [StrDoubleQuote]); // remove double quotes
    68 
    69     LogEvent(LogStartup, '  Checking for environment var: ' + tmpItem );
    70     tmpEnvironmentVarValue := GetEnv( Uppercase( tmpItem ) );
    71     if DosError = 0 then
    72     begin
    73       // environment var exists - use it's value
    74       LogEvent(LogStartup, '    Environment var found; translated to: ' + tmpEnvironmentVarValue);
    75       StrExtractStrings(ExpandedItems, tmpEnvironmentVarValue, [HELP_FILE_DELIMITER], #0);
    76     end
    77     else
    78     begin
    79       // not an environment var
    80       ExpandedItems.Add(tmpItem);
    81     end;
    82   end;
    83 end;
    8451
    8552// Given a filename, which may or may not contain a path or extension,
Note: See TracChangeset for help on using the changeset viewer.