1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="HID" script:language="StarBasic">&apos; *** MODULE HID ***
4
5Dim oDialog AS Object
6Dim document AS Object
7
8Sub Main
9
10	If not IsHelpFile Then
11		msgbox(strErr_NoHelpFile)
12		Exit Sub
13	End If
14
15	document = StarDesktop.CurrentComponent
16
17	BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
18	oDialog = LoadDialog(&quot;HelpAuthoring&quot;, &quot;dlgHID&quot;)
19	oDialogModel = oDialog.Model
20
21&apos;	oPath = createUNOService(&quot;com.sun.star.util.PathSettings&quot;)
22&apos;	filename = oPath.UserConfig+&quot;/help_hid.lst&quot;
23&apos;	oButHIDList = oDialog.GetControl(&quot;butHIDList&quot;)
24&apos;	If FileExists(filename) Then
25&apos;		oButHIDList.Enable = true
26&apos;	Else
27&apos;		oLblWait = oDialog.GetControl(&quot;lblWait&quot;)
28&apos;		oLblWait.Text = &quot;No hid list found in your config folder&quot;
29&apos;		oButHIDList.Enable = false
30&apos;	End If
31	oTxtHID = oDialog.GetControl(&quot;txtHID&quot;)
32
33	&apos; Check if bookmarks are allowed here
34	If IsInList Then
35		msgbox &quot;No Bookmarks allowed inside a list.&quot;, 48, &quot;D&apos;oh!&quot;
36		Exit Sub
37	End If
38
39	&apos; Find out if we are in front of an existing HID
40	If oDialog.Execute() = 1 Then
41
42		If oTxtHID.Text = &quot;&quot; Then
43			msgbox &quot;Empty Help ID. No Help ID element added.&quot;
44		Else
45			If IsInBookmark &gt; 0 or Not(ParaIsEmpty) Then
46				CR
47			End If
48			If not(join(split(oTxtHID.Text,&quot; &quot;),&quot;&quot;) = oTxtHID.Text) Then
49&apos;				msgbox &quot;Help ID seems to contain forbidden characters (like spaces). You may need to verify this.&quot;
50&apos;               HID and uno command
51				arHID = split(oTxtHID.Text,&quot; &quot;)
52				sHID = arHID(0)
53				sUNO = arHID(1)
54			Else
55				sHID = oTxtHID.Text
56				sUNO = &quot;&quot;
57			End If
58
59			If sHID &lt;&gt; &quot;&quot; Then
60				bmid = CreateID
61				InsertTagCR(&quot;BOOKMARK&quot;,&quot;&lt;BOOKMARK branch=&quot;&quot;hid/&quot; + sHID + &quot;&quot;&quot; id=&quot;&quot;bm_id&quot; + bmid + &quot;&quot;&quot; localize=&quot;&quot;false&quot;&quot;/&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
62			End If
63			If sUNO &lt;&gt; &quot;&quot; Then
64				bmid = CreateID
65				InsertTagCR(&quot;BOOKMARK&quot;,&quot;&lt;BOOKMARK branch=&quot;&quot;hid/&quot; + sUNO + &quot;&quot;&quot; id=&quot;&quot;bm_id&quot; + bmid + &quot;&quot;&quot; localize=&quot;&quot;false&quot;&quot;/&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
66			End If
67
68		End If
69	End If
70	oDialog.dispose
71
72End Sub
73
74Sub ConvertToSymbol
75	oPath = createUNOService(&quot;com.sun.star.util.PathSettings&quot;)
76	filename = oPath.UserConfig+&quot;/help_hid.lst&quot;
77	oTxtHID = oDialog.GetControl(&quot;txtHID&quot;)
78	oButHIDList = oDialog.GetControl(&quot;butHIDList&quot;)
79	sHID = oTxtHID.Text
80	sCt = 0
81	If FileExists(filename) AND sHID &lt;&gt; &quot;&quot; Then
82		oLblWait = oDialog.GetControl(&quot;lblWait&quot;)
83		oLblWait.Text = &quot;Searching help_hid.lst. Please wait...&quot;
84		iNumber = Freefile
85		bFound = false
86		Open filename For Input As iNumber
87		Do While (not eof(iNumber) AND not(bFound))
88			Line Input #iNumber, sLine
89			sCt = sCt+1
90			arHID = split(sLine,&quot;,&quot;)
91			If arHID(1) = sHID Then
92				If arHID(2) &lt;&gt; &quot;&quot; Then
93					symHID = arHID(0) + &quot; &quot; + arHID(2)
94				Else
95					symHID = arHID(0)
96				End If
97				bFound = true
98			End If
99		Loop
100		Close #iNumber
101		If not bFound Then
102			oLblWait.Text = &quot;Nothing found. Searched &quot;+sCt+&quot; Help IDs&quot;
103		Else
104			oTxtHID.Text = symHID
105			oLblWait.Text = &quot;HelpID found. Searched &quot;+sCt+&quot; Help IDs&quot;
106			oButHIDList.Enable = false
107		End If
108	Else
109		oLblWait.Text = &quot;No help_hid.lst found in your config folder&quot;
110	End If
111End Sub
112
113</script:module>