Changeset 298 for branches/2.19_branch/NewView/MainForm.pas
- Timestamp:
- May 18, 2008, 9:03:03 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.19_branch/NewView/MainForm.pas
r293 r298 2685 2685 end; 2686 2686 2687 Procedure TMainForm.WMFollowExternalLink( Var Msg: TMessage ); 2688 var 2689 FilePath: string; 2690 AlternativeFilePath: string; 2691 FileIndex: longint; 2692 HelpFile: THelpFile; 2693 Topic: TTopic; 2694 IsFileAlreadyOpened: boolean; 2695 begin 2687 Procedure TMainForm.WMFollowExternalLink(Var Msg: TMessage); 2688 var 2689 tmpFilePath: string; 2690 tmpAltFilePath: string; 2691 tmpIsFileAlreadyOpened: boolean; 2692 tmpHelpFile: THelpFile; 2693 tmpTopic: TTopic; 2694 i: longint; 2695 begin 2696 LogEvent(LogDebug, 'tmpFilePath ' + tmpFilePath); 2697 2696 2698 // try in same dir as source file 2697 FilePath := AddDirectorySeparator( ExtractFilePath( g_ExternalLinkSourceFilename ) )2698 + g_ExternalLinkFilename;2699 2700 AlternativeFilePath := FilePath;2701 2699 tmpFilePath := AddDirectorySeparator(ExtractFilePath(g_ExternalLinkSourceFilename)) + g_ExternalLinkFilename; 2700 tmpAltFilePath := tmpFilePath; 2701 2702 // we use paths with extension, because the internal list of helpfiles 2703 // always has extensions inside 2702 2704 if ExtractFileExt(g_ExternalLinkFilename) = '' then 2703 2705 begin 2704 FilePath := ChangeFileExt(FilePath, INF_FILE_EXTENSION);2705 AlternativeFilePath := ChangeFileExt(FilePath, HELP_FILE_EXTENSION);2706 tmpFilePath := ChangeFileExt(tmpFilePath, INF_FILE_EXTENSION); 2707 tmpAltFilePath := ChangeFileExt(tmpFilePath, HELP_FILE_EXTENSION); 2706 2708 end; 2707 2709 2708 2710 // figure out, if the file is already open 2709 IsFileAlreadyOpened := false;2710 for FileIndex:= 0 to CurrentOpenFiles.Count - 1 do2711 begin 2712 HelpFile := CurrentOpenFiles[FileIndex];2713 if StrEndsWithIgnoringCase( HelpFile.Filename,FilePath)2714 or StrEndsWithIgnoringCase( HelpFile.Filename, g_ExternalLinkFilename + HELP_FILE_EXTENSION) then2711 tmpIsFileAlreadyOpened := false; 2712 for i := 0 to CurrentOpenFiles.Count - 1 do 2713 begin 2714 tmpHelpFile := CurrentOpenFiles[i]; 2715 if StrEndsWithIgnoringCase(tmpHelpFile.Filename, tmpFilePath) 2716 or StrEndsWithIgnoringCase(tmpHelpFile.Filename, tmpAltFilePath) then 2715 2717 begin 2716 IsFileAlreadyOpened := true;2718 tmpIsFileAlreadyOpened := true; 2717 2719 end; 2718 2720 end; 2719 2721 2720 if not IsFileAlreadyOpened then2722 if not tmpIsFileAlreadyOpened then 2721 2723 begin 2722 2724 // different file - try and open it 2723 if not FileExists( FilePath ) then 2725 if not FileExists(tmpFilePath) then 2726 begin 2724 2727 // not in same directory, find in help paths 2725 FilePath := FindHelpFile( g_ExternalLinkFilename ); 2726 2727 if not FileExists( FilePath ) then 2728 tmpFilePath := FindHelpFile(g_ExternalLinkFilename); 2729 end; 2730 2731 if not FileExists(tmpFilePath) then 2728 2732 begin 2729 2733 DoErrorDlg('Link Error', 'Cannot find linked file ''' + g_ExternalLinkFilename +''''); … … 2733 2737 if g_ExternalLinkKeepCurrent then 2734 2738 begin 2735 if not OpenAdditionalFile( FilePath, false) then2739 if not OpenAdditionalFile(tmpFilePath, false) then 2736 2740 exit; 2737 2741 end 2738 2742 else 2739 2743 begin 2740 if not OpenFile( FilePath, '', false) then2744 if not OpenFile(tmpFilePath, '', false) then 2741 2745 exit; 2742 2746 end; … … 2752 2756 // don't call this search here; 2753 2757 // because we know the file to search in 2758 // otherwise the first occurence of the topic will be 2759 // found 2754 2760 // Topic := FindTopicByGlobalName( g_ExternalLinkTopic ); 2755 Topic := nil; 2756 for FileIndex := 0 to CurrentOpenFiles.Count - 1 do 2757 begin 2758 HelpFile := CurrentOpenFiles[FileIndex]; 2759 if StrEndsWithIgnoringCase(HelpFile.Filename, g_ExternalLinkFilename + INF_FILE_EXTENSION) 2760 or StrEndsWithIgnoringCase(HelpFile.Filename, g_ExternalLinkFilename + HELP_FILE_EXTENSION) then 2761 tmpTopic := nil; 2762 for i := 0 to CurrentOpenFiles.Count - 1 do 2763 begin 2764 tmpHelpFile := CurrentOpenFiles[i]; 2765 if StrEndsWithIgnoringCase(tmpHelpFile.Filename, g_ExternalLinkFilename) 2766 or StrEndsWithIgnoringCase(tmpHelpFile.Filename, g_ExternalLinkFilename + INF_FILE_EXTENSION) 2767 or StrEndsWithIgnoringCase(tmpHelpFile.Filename, g_ExternalLinkFilename + HELP_FILE_EXTENSION) then 2761 2768 begin 2762 Topic :=HelpFile.FindTopicByGlobalName(g_ExternalLinkTopic);2769 tmpTopic := tmpHelpFile.FindTopicByGlobalName(g_ExternalLinkTopic); 2763 2770 end; 2764 2771 end; 2765 2772 2766 if Topic = nil then2773 if tmpTopic = nil then 2767 2774 begin 2768 2775 DoErrorDlg('Link Error', 'Unable to find topic with global name ''' + g_ExternalLinkTopic + ''''); … … 2770 2777 end; 2771 2778 2772 DisplayTopic( Topic);2779 DisplayTopic(tmpTopic); 2773 2780 end; 2774 2781
Note:
See TracChangeset
for help on using the changeset viewer.