| <?xml version="1.0" encoding="UTF-8"?> |
| <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> |
| <!--*********************************************************** |
| * |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| * |
| ***********************************************************--> |
| <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Link" script:language="StarBasic">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 |
| |
| |
| </script:module> |