1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3<!--*********************************************************** 4 * 5 * Licensed to the Apache Software Foundation (ASF) under one 6 * or more contributor license agreements. See the NOTICE file 7 * distributed with this work for additional information 8 * regarding copyright ownership. The ASF licenses this file 9 * to you under the Apache License, Version 2.0 (the 10 * "License"); you may not use this file except in compliance 11 * with the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, 16 * software distributed under the License is distributed on an 17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 * KIND, either express or implied. See the License for the 19 * specific language governing permissions and limitations 20 * under the License. 21 * 22 ***********************************************************--> 23<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Link" script:language="StarBasic">REM ***** BASIC ***** 24 25Dim oDialog AS Object 26Dim document AS Object 27 28 29 30Sub Main 31 32 If not IsHelpFile Then 33 msgbox(strErr_NoHelpFile) 34 Exit Sub 35 End If 36 37 BasicLibraries.LoadLibrary("HelpAuthoring") 38 GlobalScope.BasicLibraries.loadLibrary("Tools") 39 Dim ListAny(0) as Long 40 41 DocRoot = ReadConfig("HelpPrefix") 42 sLastLinkDir = ReadConfig("LastLinkDir") 43 sLastLinkFile = ReadConfig("LastLinkFile") 44 45 ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE 46 oFileDialog = CreateUnoService("com.sun.star.ui.dialogs.FilePicker") 47 oFileDialog.Initialize(ListAny()) 48 49 50 If IsSubDir(sLastLinkDir,DocRoot) Then 51 oFileDialog.setDisplayDirectory(sLastLinkDir) 52 If sLastLinkFile <> "" AND Dir(sLastLinkDir+sLastLinkFile) > "" Then 53 oFileDialog.setDefaultName(sLastLinkFile) 54 End If 55 Else 56 oFileDialog.setDisplayDirectory(DocRoot) 57 End If 58 59 oMasterKey = GetRegistryKeyContent("org.openoffice.TypeDetection.Types/") 60 oTypes() = oMasterKey.Types 61 oFileDialog.AppendFilter("Help", "*.xhp") 62 63 oFileDialog.SetTitle("Link to Help File") 64 iAccept = oFileDialog.Execute() 65 66 If iAccept = 1 Then 67 sPath = oFileDialog.Files(0) 68 sCurDir = oFileDialog.getDisplayDirectory +"/" 69 WriteConfig("LastLinkDir",sCurDir) 70 LastFile = Right(sPath, Len(sPath) - Len(sCurDir)) 71 WriteConfig("LastLinkFile",LastFile) 72 73 If IsSubDir(sCurDir,DocRoot) Then 74 RelPath = GetRelPath(sPath, DocRoot) 75 Else 76 RelPath = sPath 77 msgbox("File is outside of your Document Root",48,"Warning") 78 End If 79 80 oSel = thiscomponent.getcurrentcontroller.getselection 81 oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 82 83 oStart = oCur.getStart 84 oCurStart = oStart.getText.createTextCursorByRange(oStart) 85 86 oEnd = oCur.getEnd 87 oCurEnd = oEnd.getText.createTextCursorByRange(oEnd) 88 89 thiscomponent.getcurrentcontroller.select(oCurStart) 90 InsertTag("LINK_","<LINK href=""" + RelPath + """>","hlp_aux_tag") 91 92 thiscomponent.getcurrentcontroller.select(oCurEnd) 93 InsertTag("_LINK","</LINK>","hlp_aux_tag") 94 95 SetCharStyle("Default") 96 97 End If 98 99 100End Sub 101 102 103</script:module> 104