REM ***** BASIC ***** Dim oDialog AS Object Dim document AS Object Sub Main If not IsHelpFile Then msgbox(strErr_NoHelpFile) Exit Sub End If BasicLibraries.LoadLibrary("HelpAuthoring") GlobalScope.BasicLibraries.loadLibrary("Tools") Dim ListAny(0) as Long DocRoot = ReadConfig("HelpPrefix") sLastLinkDir = ReadConfig("LastLinkDir") sLastLinkFile = ReadConfig("LastLinkFile") ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE oFileDialog = CreateUnoService("com.sun.star.ui.dialogs.FilePicker") oFileDialog.Initialize(ListAny()) If IsSubDir(sLastLinkDir,DocRoot) Then oFileDialog.setDisplayDirectory(sLastLinkDir) If sLastLinkFile <> "" AND Dir(sLastLinkDir+sLastLinkFile) > "" Then oFileDialog.setDefaultName(sLastLinkFile) End If Else oFileDialog.setDisplayDirectory(DocRoot) End If oMasterKey = GetRegistryKeyContent("org.openoffice.TypeDetection.Types/") oTypes() = oMasterKey.Types oFileDialog.AppendFilter("Help", "*.xhp") oFileDialog.SetTitle("Link to Help File") iAccept = oFileDialog.Execute() If iAccept = 1 Then sPath = oFileDialog.Files(0) sCurDir = oFileDialog.getDisplayDirectory +"/" WriteConfig("LastLinkDir",sCurDir) LastFile = Right(sPath, Len(sPath) - Len(sCurDir)) WriteConfig("LastLinkFile",LastFile) If IsSubDir(sCurDir,DocRoot) Then RelPath = GetRelPath(sPath, DocRoot) Else RelPath = sPath msgbox("File is outside of your Document Root",48,"Warning") End If oSel = thiscomponent.getcurrentcontroller.getselection oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) oStart = oCur.getStart oCurStart = oStart.getText.createTextCursorByRange(oStart) oEnd = oCur.getEnd oCurEnd = oEnd.getText.createTextCursorByRange(oEnd) thiscomponent.getcurrentcontroller.select(oCurStart) InsertTag("LINK_","<LINK href=""" + RelPath + """>","hlp_aux_tag") thiscomponent.getcurrentcontroller.select(oCurEnd) InsertTag("_LINK","</LINK>","hlp_aux_tag") SetCharStyle("Default") End If End Sub