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