blob: a9deeb4e6b05e0f46b699e02631c2bb67ef6b150 [file] [log] [blame]
<?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(&quot;HelpAuthoring&quot;)
GlobalScope.BasicLibraries.loadLibrary(&quot;Tools&quot;)
Dim ListAny(0) as Long
DocRoot = ReadConfig(&quot;HelpPrefix&quot;)
sLastLinkDir = ReadConfig(&quot;LastLinkDir&quot;)
sLastLinkFile = ReadConfig(&quot;LastLinkFile&quot;)
ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE
oFileDialog = CreateUnoService(&quot;com.sun.star.ui.dialogs.FilePicker&quot;)
oFileDialog.Initialize(ListAny())
If IsSubDir(sLastLinkDir,DocRoot) Then
oFileDialog.setDisplayDirectory(sLastLinkDir)
If sLastLinkFile &lt;&gt; &quot;&quot; AND Dir(sLastLinkDir+sLastLinkFile) &gt; &quot;&quot; Then
oFileDialog.setDefaultName(sLastLinkFile)
End If
Else
oFileDialog.setDisplayDirectory(DocRoot)
End If
oMasterKey = GetRegistryKeyContent(&quot;org.openoffice.TypeDetection.Types/&quot;)
oTypes() = oMasterKey.Types
oFileDialog.AppendFilter(&quot;Help&quot;, &quot;*.xhp&quot;)
oFileDialog.SetTitle(&quot;Link to Help File&quot;)
iAccept = oFileDialog.Execute()
If iAccept = 1 Then
sPath = oFileDialog.Files(0)
sCurDir = oFileDialog.getDisplayDirectory +&quot;/&quot;
WriteConfig(&quot;LastLinkDir&quot;,sCurDir)
LastFile = Right(sPath, Len(sPath) - Len(sCurDir))
WriteConfig(&quot;LastLinkFile&quot;,LastFile)
If IsSubDir(sCurDir,DocRoot) Then
RelPath = GetRelPath(sPath, DocRoot)
Else
RelPath = sPath
msgbox(&quot;File is outside of your Document Root&quot;,48,&quot;Warning&quot;)
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(&quot;LINK_&quot;,&quot;&lt;LINK href=&quot;&quot;&quot; + RelPath + &quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_tag&quot;)
thiscomponent.getcurrentcontroller.select(oCurEnd)
InsertTag(&quot;_LINK&quot;,&quot;&lt;/LINK&gt;&quot;,&quot;hlp_aux_tag&quot;)
SetCharStyle(&quot;Default&quot;)
End If
End Sub
</script:module>