Changeset 342 for trunk/NewView/MainForm.pas
- Timestamp:
- Jun 1, 2009, 2:42:16 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NewView/MainForm.pas
r259 r342 383 383 Procedure AddCurrentToMRUFiles; 384 384 385 Function LoadFiles( const FileNames: TStrings; 386 HelpFiles: TList ): boolean; 385 Function LoadFiles(const aFileNames: TStrings; aHelpFiles: TList) : boolean; 387 386 Procedure DisplayFiles( NewFiles: TList; 388 387 Var FirstContentsNode: TNode ); … … 1612 1611 end; 1613 1612 end; 1614 1613 1615 1614 CreateMRUMenuItems; 1616 1615 End; … … 1672 1671 tmpFileNames := TStringList.Create; 1673 1672 1674 StrExtractStringsIgnoreEmpty(tmpFileNames, TextList, [HELP_FILE_DELIMITER], #0);1673 ParseAndExpandFileNames(TextList, tmpFileNames); 1675 1674 if tmpFileNames.Count > 0 then 1676 1675 begin 1677 result := OpenFiles(tmpFileNames, '', DisplayFirstTopic 1676 result := OpenFiles(tmpFileNames, '', DisplayFirstTopic); 1678 1677 end 1679 1678 else … … 2283 2282 CmdLineParameters.writeDetailsTo(Lines); 2284 2283 writeSettingsDetailsTo(Lines); 2284 writeDebugSetupDetailsTo(Lines); 2285 2285 end; 2286 2286 … … 4065 4065 if CmdLineParameters.getOwnerWindow <> NULLHANDLE then 4066 4066 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 ); 4072 4069 end; 4073 4070 … … 4085 4082 CoolBar.SetMinConstButtonWidth; 4086 4083 4087 LogEvent(LogStartup, 'Post WM_OPENED');4088 4089 4084 ResetProgress; 4090 4085 … … 4095 4090 AddShortcut( kbCtrlCLeft, kbCtrlCLeft ); // back 4096 4091 4092 LogEvent(LogStartup, 'Post WM_OPENED'); 4097 4093 PostMsg( Handle, WM_OPENED, 0, 0 ); 4098 4094 End; … … 4196 4192 LogEvent(LogStartup, 'Finish paint'); 4197 4193 Update; 4194 LogEvent(LogStartup, 'BringToFront'); 4195 MainForm.BringToFront; 4198 4196 4199 4197 if not CmdLineParameters.getHelpManagerFlag then … … 4222 4220 Filenames := TStringList.Create; 4223 4221 4224 StrExtractStringsIgnoreEmpty(Filenames, tmpFileNames, [HELP_FILE_DELIMITER], #0); 4225 4222 ParseAndExpandFileNames(tmpFileNames, Filenames); 4226 4223 LogEvent(LogStartup, 'Call OpenFiles'); 4227 4224 … … 5722 5719 Tag:= MenuItem.Tag; 5723 5720 MRUItem := Settings.MRUList[ Tag ]; 5721 // RBRi woher kommt die liste? 5724 5722 if OpenFiles( MRUItem.FileNames, '', true ) then 5725 5723 begin … … 6228 6226 procedure TMainForm.LoadIndex; 6229 6227 var 6230 HelpFile: THelpFile;6231 TextCompareResult: integer;6228 tmpHelpFile: THelpFile; 6229 tmpTextCompareResult: integer; 6232 6230 6233 6231 FileIndex: longint; … … 6235 6233 Contents: TList; 6236 6234 ContentsLists: TList; // of tlist 6237 IndexLists: TList; // of tstringlist6235 tmpIndexLists: TList; // of tstringlist 6238 6236 ContentsNextIndex: array[ 0..255 ] of longint; 6239 6237 IndexNextIndex: array[ 0..255 ] of longint; 6240 6238 Topic: TTopic; 6241 6239 6242 ListIndex: longint;6243 6244 6240 pListEntry: pstring; 6245 6241 pLowestEntry: pstring; 6246 6242 pLastEntry: pstring; 6247 6243 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; 6253 6249 6254 6250 i : longint; … … 6264 6260 6265 6261 ContentsLists := TList.Create; 6266 IndexLists := TList.Create;6262 tmpIndexLists := TList.Create; 6267 6263 6268 6264 // collect the contents and index lists from the files 6269 6265 for FileIndex := 0 to CurrentOpenFiles.Count - 1 do 6270 6266 begin 6271 HelpFile := CurrentOpenFiles[ FileIndex ];6267 tmpHelpFile := CurrentOpenFiles[ FileIndex ]; 6272 6268 ProgressBar.Position := 70 + 10 * FileIndex div CurrentOpenFiles.Count; 6273 6269 … … 6275 6271 begin 6276 6272 Contents := TList.Create; 6277 Contents.Capacity := HelpFile.TopicCount;6273 Contents.Capacity := tmpHelpFile.TopicCount; 6278 6274 6279 6275 // copy [contents] topic list 6280 for i := 0 to HelpFile.TopicCount - 1 do6276 for i := 0 to tmpHelpFile.TopicCount - 1 do 6281 6277 begin 6282 Topic := HelpFile.Topics[ i ];6278 Topic := tmpHelpFile.Topics[ i ]; 6283 6279 if Topic.ShowInContents then 6284 6280 Contents.Add( Topic ); … … 6296 6292 if Settings.IndexStyle in [ isFileOnly, isFull ] then 6297 6293 begin 6298 IndexLists.Add( HelpFile.Index);6299 IndexNextIndex[ IndexLists.Count - 1 ] := 0;6294 tmpIndexLists.Add(tmpHelpFile.Index.GetLabels); 6295 IndexNextIndex[ tmpIndexLists.Count - 1 ] := 0; 6300 6296 end; 6301 6297 end; … … 6313 6309 begin 6314 6310 pLowestEntry := NullStr; 6315 LowestEntryListIndex := -1;6311 tmpLowestEntryListIndex := -1; 6316 6312 6317 6313 // Find alphabetically lowest (remaining) topic 6318 6314 6319 6315 // 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 6321 6318 begin 6322 Contents := ContentsLists[ ListIndex];6323 if ContentsNextIndex[ ListIndex] < Contents.Count then6319 Contents := ContentsLists[i]; 6320 if ContentsNextIndex[i] < Contents.Count then 6324 6321 begin 6325 6322 // list is not yet finished, get next entry 6326 Topic := Contents[ ContentsNextIndex[ ListIndex] ];6323 Topic := Contents[ ContentsNextIndex[i] ]; 6327 6324 pListEntry := Topic.TitlePtr; 6328 6325 6329 6326 if pLowestEntry^ <> '' then 6330 TextCompareResult := CompareText( pListEntry^, pLowestEntry^ )6327 tmpTextCompareResult := CompareText( pListEntry^, pLowestEntry^ ) 6331 6328 else 6332 TextCompareResult := -1;6333 6334 if TextCompareResult < 0 then6329 tmpTextCompareResult := -1; 6330 6331 if tmpTextCompareResult < 0 then 6335 6332 begin 6336 6333 // this index entry comes before the lowest one so far 6337 6334 pLowestEntry := pListEntry; 6338 LowestEntryListIndex := ListIndex;6339 LowestEntryListType := ltContents;6340 LowestEntryTopic := Topic;6335 tmpLowestEntryListIndex := i; 6336 tmpLowestEntryListType := ltContents; 6337 tmpLowestEntryTopic := Topic; 6341 6338 end; 6342 6339 end; … … 6344 6341 6345 6342 // 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 6347 6345 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 6350 6349 begin 6351 6350 // list is not yet finished, get next entry 6352 pListEntry := Index.ValuePtrs[ IndexNextIndex[ ListIndex] ];6351 pListEntry := tmpIndex.ValuePtrs[ IndexNextIndex[i] ]; 6353 6352 6354 6353 if pLowestEntry^ <> '' then 6355 TextCompareResult := CompareText( pListEntry^, pLowestEntry^ )6354 tmpTextCompareResult := CompareText( pListEntry^, pLowestEntry^ ) 6356 6355 else 6357 TextCompareResult := -1;6358 6359 if TextCompareResult < 0 then6356 tmpTextCompareResult := -1; 6357 6358 if tmpTextCompareResult < 0 then 6360 6359 begin 6361 6360 // this index entry comes before the lowest one so far 6362 6361 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; 6366 6367 end; 6367 6368 end; 6368 6369 end; 6369 6370 6370 if LowestEntryListIndex = -1 then6371 if tmpLowestEntryListIndex = -1 then 6371 6372 // we're out 6372 6373 break; … … 6374 6375 if ( pLowestEntry^ ) <> ( pLastEntry^ ) then 6375 6376 // add, if different from last 6376 DisplayedIndex.AddObject( pLowestEntry^, 6377 LowestEntryTopic ); 6377 DisplayedIndex.AddObject( pLowestEntry^, tmpLowestEntryTopic ); 6378 6378 pLastEntry := pLowestEntry; 6379 6379 6380 if LowestEntryListType = ltContents then6380 if tmpLowestEntryListType = ltContents then 6381 6381 begin 6382 inc( ContentsNextIndex[ LowestEntryListIndex ] );6382 inc( ContentsNextIndex[ tmpLowestEntryListIndex ] ); 6383 6383 end 6384 6384 else … … 6386 6386 // found in one of indices. 6387 6387 // Check for subsequent indented strings 6388 Index := IndexLists[LowestEntryListIndex ];6389 6390 i := IndexNextIndex[ LowestEntryListIndex ] + 1;6391 while i < Index.Count do6388 tmpIndex := tmpIndexLists[ tmpLowestEntryListIndex ]; 6389 6390 i := IndexNextIndex[ tmpLowestEntryListIndex ] + 1; 6391 while i < tmpIndex.Count do 6392 6392 begin 6393 pListEntry := Index.ValuePtrs[ i ];6393 pListEntry := tmpIndex.ValuePtrs[ i ]; 6394 6394 if pListEntry^ = '' then 6395 6395 break; … … 6400 6400 6401 6401 // found one, 6402 Topic := Index.Objects[ i ] as TTopic;6402 Topic := TIndexEntry(tmpIndex.Objects[ i ]).getTopic; 6403 6403 DisplayedIndex.AddObject( pListEntry^, 6404 6404 Topic ); 6405 6405 inc( i ); 6406 6406 end; 6407 IndexNextIndex[ LowestEntryListIndex ] := i;6407 IndexNextIndex[ tmpLowestEntryListIndex ] := i; 6408 6408 end; 6409 6409 end; … … 6419 6419 LogEvent(LogStartup, ' Tidy up' ); 6420 6420 6421 IndexLists.Destroy;6421 tmpIndexLists.Destroy; 6422 6422 6423 6423 DestroyListAndObjects( ContentsLists ); … … 6465 6465 const SelectFirstContentsNode: boolean ): boolean; 6466 6466 var 6467 FileNames: TStringList;6468 begin 6469 FileNames := TStringList.Create;6470 FileNames.Add( FileName);6471 Result := OpenFiles( FileNames,6467 tmpFileNames: TStringList; 6468 begin 6469 tmpFileNames := TStringList.Create; 6470 ParseAndExpandFileNames(FileName, tmpFileNames); 6471 Result := OpenFiles( tmpFileNames, 6472 6472 WindowTitle, 6473 6473 DisplayFirstTopic ); 6474 FileNames.Destroy;6474 tmpFileNames.Destroy; 6475 6475 end; 6476 6476 … … 6478 6478 const DisplayFirstTopic: boolean ): boolean; 6479 6479 var 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; 6481 begin 6482 tmpFileNames := TStringList.Create; 6483 ParseAndExpandFileNames(FileName, tmpFileNames); 6484 Result := OpenAdditionalFiles(tmpFileNames, DisplayFirstTopic ); 6485 tmpFileNames.Destroy; 6487 6486 end; 6488 6487 … … 6528 6527 6529 6528 // Load the specified set of help files 6530 Function TMainForm.LoadFiles( const FileNames: TStrings; 6531 HelpFiles: TList ): boolean; 6529 Function TMainForm.LoadFiles(const aFileNames: TStrings; aHelpFiles: TList) : boolean; 6532 6530 var 6533 6531 HelpFile: THelpFile; 6534 FileIndex : longint;6532 FileIndex, i: longint; 6535 6533 FileName: string; 6536 6534 FullFilePath: string; … … 6544 6542 LoadingFilenameList := TStringList.Create; 6545 6543 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; 6547 6549 6548 6550 LogEvent(LogStartup, 'Finding files' ); … … 6609 6611 HelpFile.SetupFontSubstitutes( Settings.FixedFontSubstitutes ); 6610 6612 6611 HelpFiles.Add( HelpFile );6613 aHelpFiles.Add( HelpFile ); 6612 6614 6613 6615 except … … 6631 6633 Result := false; 6632 6634 6633 DestroyListObjects( HelpFiles );6635 DestroyListObjects( aHelpFiles ); 6634 6636 6635 6637 LoadingFilenameList.Destroy; … … 6650 6652 Procedure TMainForm.AddCurrentToMRUFiles; 6651 6653 var 6652 Filenames: TStringList;6654 tmpFilenames: TStringList; 6653 6655 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; 6657 begin 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; 6668 6672 6669 6673 // recreate menu 6670 6674 CreateMRUMenuItems; 6671 6675 6672 Filenames.Destroy;6676 tmpFilenames.Destroy; 6673 6677 end; 6674 6678 … … 6722 6726 const DisplayFirstTopic: boolean ): boolean; 6723 6727 var 6724 HelpFiles: TList;6728 tmpHelpFiles: TList; 6725 6729 FirstContentsNode: TNode; 6726 6730 begin … … 6732 6736 SetWaitCursor; 6733 6737 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 6737 6742 begin 6738 6743 ClearWaitCursor; 6739 HelpFiles.Destroy;6744 tmpHelpFiles.Destroy; 6740 6745 exit; 6741 6746 end; … … 6751 6756 CloseFile; 6752 6757 6753 AssignList( 6758 AssignList(tmpHelpFiles, CurrentOpenFiles ); 6754 6759 6755 6760 ProgressBar.Position := 50; … … 6770 6775 ContentsOutline.Clear; 6771 6776 6772 DisplayFiles( HelpFiles,6777 DisplayFiles( tmpHelpFiles, 6773 6778 FirstContentsNode ); 6774 6779 … … 6891 6896 exit; 6892 6897 6898 // no ParseAndExpandFileNames call required here 6899 // this is the result of a file dialog 6900 // no environment vars here 6893 6901 if KeepCurrentFiles then 6894 6902 OpenedOK := OpenAdditionalFiles( FileNames, true )
Note:
See TracChangeset
for help on using the changeset viewer.