1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<!--***********************************************************
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements.  See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership.  The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License.  You may obtain a copy of the License at
12 *
13 *   http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied.  See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
22 ***********************************************************-->
23<script:module xmlns:script="http://openoffice.org/2000/script" script:name="HID" script:language="StarBasic">&apos; *** MODULE HID ***
24
25Dim oDialog AS Object
26Dim document AS Object
27
28Sub Main
29
30	If not IsHelpFile Then
31		msgbox(strErr_NoHelpFile)
32		Exit Sub
33	End If
34
35	document = StarDesktop.CurrentComponent
36
37	BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
38	oDialog = LoadDialog(&quot;HelpAuthoring&quot;, &quot;dlgHID&quot;)
39	oDialogModel = oDialog.Model
40
41&apos;	oPath = createUNOService(&quot;com.sun.star.util.PathSettings&quot;)
42&apos;	filename = oPath.UserConfig+&quot;/help_hid.lst&quot;
43&apos;	oButHIDList = oDialog.GetControl(&quot;butHIDList&quot;)
44&apos;	If FileExists(filename) Then
45&apos;		oButHIDList.Enable = true
46&apos;	Else
47&apos;		oLblWait = oDialog.GetControl(&quot;lblWait&quot;)
48&apos;		oLblWait.Text = &quot;No hid list found in your config folder&quot;
49&apos;		oButHIDList.Enable = false
50&apos;	End If
51	oTxtHID = oDialog.GetControl(&quot;txtHID&quot;)
52
53	&apos; Check if bookmarks are allowed here
54	If IsInList Then
55		msgbox &quot;No Bookmarks allowed inside a list.&quot;, 48, &quot;D&apos;oh!&quot;
56		Exit Sub
57	End If
58
59	&apos; Find out if we are in front of an existing HID
60	If oDialog.Execute() = 1 Then
61
62		If oTxtHID.Text = &quot;&quot; Then
63			msgbox &quot;Empty Help ID. No Help ID element added.&quot;
64		Else
65			If IsInBookmark &gt; 0 or Not(ParaIsEmpty) Then
66				CR
67			End If
68			If not(join(split(oTxtHID.Text,&quot; &quot;),&quot;&quot;) = oTxtHID.Text) Then
69&apos;				msgbox &quot;Help ID seems to contain forbidden characters (like spaces). You may need to verify this.&quot;
70&apos;               HID and uno command
71				arHID = split(oTxtHID.Text,&quot; &quot;)
72				sHID = arHID(0)
73				sUNO = arHID(1)
74			Else
75				sHID = oTxtHID.Text
76				sUNO = &quot;&quot;
77			End If
78
79			If sHID &lt;&gt; &quot;&quot; Then
80				bmid = CreateID
81				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;)
82			End If
83			If sUNO &lt;&gt; &quot;&quot; Then
84				bmid = CreateID
85				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;)
86			End If
87
88		End If
89	End If
90	oDialog.dispose
91
92End Sub
93
94Sub ConvertToSymbol
95	oPath = createUNOService(&quot;com.sun.star.util.PathSettings&quot;)
96	filename = oPath.UserConfig+&quot;/help_hid.lst&quot;
97	oTxtHID = oDialog.GetControl(&quot;txtHID&quot;)
98	oButHIDList = oDialog.GetControl(&quot;butHIDList&quot;)
99	sHID = oTxtHID.Text
100	sCt = 0
101	If FileExists(filename) AND sHID &lt;&gt; &quot;&quot; Then
102		oLblWait = oDialog.GetControl(&quot;lblWait&quot;)
103		oLblWait.Text = &quot;Searching help_hid.lst. Please wait...&quot;
104		iNumber = Freefile
105		bFound = false
106		Open filename For Input As iNumber
107		Do While (not eof(iNumber) AND not(bFound))
108			Line Input #iNumber, sLine
109			sCt = sCt+1
110			arHID = split(sLine,&quot;,&quot;)
111			If arHID(1) = sHID Then
112				If arHID(2) &lt;&gt; &quot;&quot; Then
113					symHID = arHID(0) + &quot; &quot; + arHID(2)
114				Else
115					symHID = arHID(0)
116				End If
117				bFound = true
118			End If
119		Loop
120		Close #iNumber
121		If not bFound Then
122			oLblWait.Text = &quot;Nothing found. Searched &quot;+sCt+&quot; Help IDs&quot;
123		Else
124			oTxtHID.Text = symHID
125			oLblWait.Text = &quot;HelpID found. Searched &quot;+sCt+&quot; Help IDs&quot;
126			oButHIDList.Enable = false
127		End If
128	Else
129		oLblWait.Text = &quot;No help_hid.lst found in your config folder&quot;
130	End If
131End Sub
132
133</script:module>
134