1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Link" script:language="StarBasic">REM ***** BASIC ***** 4 5Dim oDialog AS Object 6Dim document AS Object 7 8 9 10Sub Main 11 12 If not IsHelpFile Then 13 msgbox(strErr_NoHelpFile) 14 Exit Sub 15 End If 16 17 BasicLibraries.LoadLibrary("HelpAuthoring") 18 GlobalScope.BasicLibraries.loadLibrary("Tools") 19 Dim ListAny(0) as Long 20 21 DocRoot = ReadConfig("HelpPrefix") 22 sLastLinkDir = ReadConfig("LastLinkDir") 23 sLastLinkFile = ReadConfig("LastLinkFile") 24 25 ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE 26 oFileDialog = CreateUnoService("com.sun.star.ui.dialogs.FilePicker") 27 oFileDialog.Initialize(ListAny()) 28 29 30 If IsSubDir(sLastLinkDir,DocRoot) Then 31 oFileDialog.setDisplayDirectory(sLastLinkDir) 32 If sLastLinkFile <> "" AND Dir(sLastLinkDir+sLastLinkFile) > "" Then 33 oFileDialog.setDefaultName(sLastLinkFile) 34 End If 35 Else 36 oFileDialog.setDisplayDirectory(DocRoot) 37 End If 38 39 oMasterKey = GetRegistryKeyContent("org.openoffice.TypeDetection.Types/") 40 oTypes() = oMasterKey.Types 41 oFileDialog.AppendFilter("Help", "*.xhp") 42 43 oFileDialog.SetTitle("Link to Help File") 44 iAccept = oFileDialog.Execute() 45 46 If iAccept = 1 Then 47 sPath = oFileDialog.Files(0) 48 sCurDir = oFileDialog.getDisplayDirectory +"/" 49 WriteConfig("LastLinkDir",sCurDir) 50 LastFile = Right(sPath, Len(sPath) - Len(sCurDir)) 51 WriteConfig("LastLinkFile",LastFile) 52 53 If IsSubDir(sCurDir,DocRoot) Then 54 RelPath = GetRelPath(sPath, DocRoot) 55 Else 56 RelPath = sPath 57 msgbox("File is outside of your Document Root",48,"Warning") 58 End If 59 60 oSel = thiscomponent.getcurrentcontroller.getselection 61 oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 62 63 oStart = oCur.getStart 64 oCurStart = oStart.getText.createTextCursorByRange(oStart) 65 66 oEnd = oCur.getEnd 67 oCurEnd = oEnd.getText.createTextCursorByRange(oEnd) 68 69 thiscomponent.getcurrentcontroller.select(oCurStart) 70 InsertTag("LINK_","<LINK href=""" + RelPath + """>","hlp_aux_tag") 71 72 thiscomponent.getcurrentcontroller.select(oCurEnd) 73 InsertTag("_LINK","</LINK>","hlp_aux_tag") 74 75 SetCharStyle("Default") 76 77 End If 78 79 80End Sub 81 82 83</script:module>