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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 )
Note: See TracChangeset for help on using the changeset viewer.