11ecadb57SMathias Bauer<?xml version="1.0" encoding="UTF-8"?> 21ecadb57SMathias Bauer<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3*3e02b54dSAndrew Rist<!--*********************************************************** 4*3e02b54dSAndrew Rist * 5*3e02b54dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 6*3e02b54dSAndrew Rist * or more contributor license agreements. See the NOTICE file 7*3e02b54dSAndrew Rist * distributed with this work for additional information 8*3e02b54dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 9*3e02b54dSAndrew Rist * to you under the Apache License, Version 2.0 (the 10*3e02b54dSAndrew Rist * "License"); you may not use this file except in compliance 11*3e02b54dSAndrew Rist * with the License. You may obtain a copy of the License at 12*3e02b54dSAndrew Rist * 13*3e02b54dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 14*3e02b54dSAndrew Rist * 15*3e02b54dSAndrew Rist * Unless required by applicable law or agreed to in writing, 16*3e02b54dSAndrew Rist * software distributed under the License is distributed on an 17*3e02b54dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18*3e02b54dSAndrew Rist * KIND, either express or implied. See the License for the 19*3e02b54dSAndrew Rist * specific language governing permissions and limitations 20*3e02b54dSAndrew Rist * under the License. 21*3e02b54dSAndrew Rist * 22*3e02b54dSAndrew Rist ***********************************************************--> 231ecadb57SMathias Bauer<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Link" script:language="StarBasic">REM ***** BASIC ***** 241ecadb57SMathias Bauer 251ecadb57SMathias BauerDim oDialog AS Object 261ecadb57SMathias BauerDim document AS Object 271ecadb57SMathias Bauer 281ecadb57SMathias Bauer 291ecadb57SMathias Bauer 301ecadb57SMathias BauerSub Main 311ecadb57SMathias Bauer 321ecadb57SMathias Bauer If not IsHelpFile Then 331ecadb57SMathias Bauer msgbox(strErr_NoHelpFile) 341ecadb57SMathias Bauer Exit Sub 351ecadb57SMathias Bauer End If 361ecadb57SMathias Bauer 371ecadb57SMathias Bauer BasicLibraries.LoadLibrary("HelpAuthoring") 381ecadb57SMathias Bauer GlobalScope.BasicLibraries.loadLibrary("Tools") 391ecadb57SMathias Bauer Dim ListAny(0) as Long 401ecadb57SMathias Bauer 411ecadb57SMathias Bauer DocRoot = ReadConfig("HelpPrefix") 421ecadb57SMathias Bauer sLastLinkDir = ReadConfig("LastLinkDir") 431ecadb57SMathias Bauer sLastLinkFile = ReadConfig("LastLinkFile") 441ecadb57SMathias Bauer 451ecadb57SMathias Bauer ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE 461ecadb57SMathias Bauer oFileDialog = CreateUnoService("com.sun.star.ui.dialogs.FilePicker") 471ecadb57SMathias Bauer oFileDialog.Initialize(ListAny()) 481ecadb57SMathias Bauer 491ecadb57SMathias Bauer 501ecadb57SMathias Bauer If IsSubDir(sLastLinkDir,DocRoot) Then 511ecadb57SMathias Bauer oFileDialog.setDisplayDirectory(sLastLinkDir) 521ecadb57SMathias Bauer If sLastLinkFile <> "" AND Dir(sLastLinkDir+sLastLinkFile) > "" Then 531ecadb57SMathias Bauer oFileDialog.setDefaultName(sLastLinkFile) 541ecadb57SMathias Bauer End If 551ecadb57SMathias Bauer Else 561ecadb57SMathias Bauer oFileDialog.setDisplayDirectory(DocRoot) 571ecadb57SMathias Bauer End If 581ecadb57SMathias Bauer 591ecadb57SMathias Bauer oMasterKey = GetRegistryKeyContent("org.openoffice.TypeDetection.Types/") 601ecadb57SMathias Bauer oTypes() = oMasterKey.Types 611ecadb57SMathias Bauer oFileDialog.AppendFilter("Help", "*.xhp") 621ecadb57SMathias Bauer 631ecadb57SMathias Bauer oFileDialog.SetTitle("Link to Help File") 641ecadb57SMathias Bauer iAccept = oFileDialog.Execute() 651ecadb57SMathias Bauer 661ecadb57SMathias Bauer If iAccept = 1 Then 671ecadb57SMathias Bauer sPath = oFileDialog.Files(0) 681ecadb57SMathias Bauer sCurDir = oFileDialog.getDisplayDirectory +"/" 691ecadb57SMathias Bauer WriteConfig("LastLinkDir",sCurDir) 701ecadb57SMathias Bauer LastFile = Right(sPath, Len(sPath) - Len(sCurDir)) 711ecadb57SMathias Bauer WriteConfig("LastLinkFile",LastFile) 721ecadb57SMathias Bauer 731ecadb57SMathias Bauer If IsSubDir(sCurDir,DocRoot) Then 741ecadb57SMathias Bauer RelPath = GetRelPath(sPath, DocRoot) 751ecadb57SMathias Bauer Else 761ecadb57SMathias Bauer RelPath = sPath 771ecadb57SMathias Bauer msgbox("File is outside of your Document Root",48,"Warning") 781ecadb57SMathias Bauer End If 791ecadb57SMathias Bauer 801ecadb57SMathias Bauer oSel = thiscomponent.getcurrentcontroller.getselection 811ecadb57SMathias Bauer oCur = oSel(0).getText.createTextCursorByRange(oSel(0)) 821ecadb57SMathias Bauer 831ecadb57SMathias Bauer oStart = oCur.getStart 841ecadb57SMathias Bauer oCurStart = oStart.getText.createTextCursorByRange(oStart) 851ecadb57SMathias Bauer 861ecadb57SMathias Bauer oEnd = oCur.getEnd 871ecadb57SMathias Bauer oCurEnd = oEnd.getText.createTextCursorByRange(oEnd) 881ecadb57SMathias Bauer 891ecadb57SMathias Bauer thiscomponent.getcurrentcontroller.select(oCurStart) 901ecadb57SMathias Bauer InsertTag("LINK_","<LINK href=""" + RelPath + """>","hlp_aux_tag") 911ecadb57SMathias Bauer 921ecadb57SMathias Bauer thiscomponent.getcurrentcontroller.select(oCurEnd) 931ecadb57SMathias Bauer InsertTag("_LINK","</LINK>","hlp_aux_tag") 941ecadb57SMathias Bauer 951ecadb57SMathias Bauer SetCharStyle("Default") 961ecadb57SMathias Bauer 971ecadb57SMathias Bauer End If 981ecadb57SMathias Bauer 991ecadb57SMathias Bauer 1001ecadb57SMathias BauerEnd Sub 1011ecadb57SMathias Bauer 1021ecadb57SMathias Bauer 103*3e02b54dSAndrew Rist</script:module> 104