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