xref: /trunk/main/helpauthoring/HelpAuthoring/HID.xba (revision 66b843ff8f1eedd2e69941f1ea52fa080f01ec28)
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="HID" script:language="StarBasic">&apos; *** MODULE HID ***
241ecadb57SMathias Bauer
251ecadb57SMathias BauerDim oDialog AS Object
261ecadb57SMathias BauerDim document AS Object
271ecadb57SMathias Bauer
281ecadb57SMathias BauerSub Main
291ecadb57SMathias Bauer
301ecadb57SMathias Bauer    If not IsHelpFile Then
311ecadb57SMathias Bauer        msgbox(strErr_NoHelpFile)
321ecadb57SMathias Bauer        Exit Sub
331ecadb57SMathias Bauer    End If
341ecadb57SMathias Bauer
351ecadb57SMathias Bauer    document = StarDesktop.CurrentComponent
361ecadb57SMathias Bauer
371ecadb57SMathias Bauer    BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
381ecadb57SMathias Bauer    oDialog = LoadDialog(&quot;HelpAuthoring&quot;, &quot;dlgHID&quot;)
391ecadb57SMathias Bauer    oDialogModel = oDialog.Model
401ecadb57SMathias Bauer
411ecadb57SMathias Bauer&apos;  oPath = createUNOService(&quot;com.sun.star.util.PathSettings&quot;)
421ecadb57SMathias Bauer&apos;  filename = oPath.UserConfig+&quot;/help_hid.lst&quot;
431ecadb57SMathias Bauer&apos;  oButHIDList = oDialog.GetControl(&quot;butHIDList&quot;)
441ecadb57SMathias Bauer&apos;  If FileExists(filename) Then
451ecadb57SMathias Bauer&apos;      oButHIDList.Enable = true
461ecadb57SMathias Bauer&apos;  Else
471ecadb57SMathias Bauer&apos;      oLblWait = oDialog.GetControl(&quot;lblWait&quot;)
481ecadb57SMathias Bauer&apos;      oLblWait.Text = &quot;No hid list found in your config folder&quot;
491ecadb57SMathias Bauer&apos;      oButHIDList.Enable = false
501ecadb57SMathias Bauer&apos;  End If
511ecadb57SMathias Bauer    oTxtHID = oDialog.GetControl(&quot;txtHID&quot;)
521ecadb57SMathias Bauer
531ecadb57SMathias Bauer    &apos; Check if bookmarks are allowed here
541ecadb57SMathias Bauer    If IsInList Then
551ecadb57SMathias Bauer        msgbox &quot;No Bookmarks allowed inside a list.&quot;, 48, &quot;D&apos;oh!&quot;
561ecadb57SMathias Bauer        Exit Sub
571ecadb57SMathias Bauer    End If
581ecadb57SMathias Bauer
591ecadb57SMathias Bauer    &apos; Find out if we are in front of an existing HID
601ecadb57SMathias Bauer    If oDialog.Execute() = 1 Then
611ecadb57SMathias Bauer
621ecadb57SMathias Bauer        If oTxtHID.Text = &quot;&quot; Then
631ecadb57SMathias Bauer            msgbox &quot;Empty Help ID. No Help ID element added.&quot;
641ecadb57SMathias Bauer        Else
651ecadb57SMathias Bauer            If IsInBookmark &gt; 0 or Not(ParaIsEmpty) Then
661ecadb57SMathias Bauer                CR
671ecadb57SMathias Bauer            End If
681ecadb57SMathias Bauer            If not(join(split(oTxtHID.Text,&quot; &quot;),&quot;&quot;) = oTxtHID.Text) Then
691ecadb57SMathias Bauer&apos;              msgbox &quot;Help ID seems to contain forbidden characters (like spaces). You may need to verify this.&quot;
701ecadb57SMathias Bauer&apos;               HID and uno command
711ecadb57SMathias Bauer                arHID = split(oTxtHID.Text,&quot; &quot;)
721ecadb57SMathias Bauer                sHID = arHID(0)
731ecadb57SMathias Bauer                sUNO = arHID(1)
741ecadb57SMathias Bauer            Else
751ecadb57SMathias Bauer                sHID = oTxtHID.Text
761ecadb57SMathias Bauer                sUNO = &quot;&quot;
771ecadb57SMathias Bauer            End If
781ecadb57SMathias Bauer
791ecadb57SMathias Bauer            If sHID &lt;&gt; &quot;&quot; Then
801ecadb57SMathias Bauer                bmid = CreateID
811ecadb57SMathias Bauer                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;)
821ecadb57SMathias Bauer            End If
831ecadb57SMathias Bauer            If sUNO &lt;&gt; &quot;&quot; Then
841ecadb57SMathias Bauer                bmid = CreateID
851ecadb57SMathias Bauer                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;)
861ecadb57SMathias Bauer            End If
871ecadb57SMathias Bauer
881ecadb57SMathias Bauer        End If
891ecadb57SMathias Bauer    End If
901ecadb57SMathias Bauer    oDialog.dispose
911ecadb57SMathias Bauer
921ecadb57SMathias BauerEnd Sub
931ecadb57SMathias Bauer
941ecadb57SMathias BauerSub ConvertToSymbol
951ecadb57SMathias Bauer    oPath = createUNOService(&quot;com.sun.star.util.PathSettings&quot;)
961ecadb57SMathias Bauer    filename = oPath.UserConfig+&quot;/help_hid.lst&quot;
971ecadb57SMathias Bauer    oTxtHID = oDialog.GetControl(&quot;txtHID&quot;)
981ecadb57SMathias Bauer    oButHIDList = oDialog.GetControl(&quot;butHIDList&quot;)
991ecadb57SMathias Bauer    sHID = oTxtHID.Text
1001ecadb57SMathias Bauer    sCt = 0
1011ecadb57SMathias Bauer    If FileExists(filename) AND sHID &lt;&gt; &quot;&quot; Then
1021ecadb57SMathias Bauer        oLblWait = oDialog.GetControl(&quot;lblWait&quot;)
1031ecadb57SMathias Bauer        oLblWait.Text = &quot;Searching help_hid.lst. Please wait...&quot;
1041ecadb57SMathias Bauer        iNumber = Freefile
1051ecadb57SMathias Bauer        bFound = false
1061ecadb57SMathias Bauer        Open filename For Input As iNumber
1071ecadb57SMathias Bauer        Do While (not eof(iNumber) AND not(bFound))
1081ecadb57SMathias Bauer            Line Input #iNumber, sLine
1091ecadb57SMathias Bauer            sCt = sCt+1
1101ecadb57SMathias Bauer            arHID = split(sLine,&quot;,&quot;)
1111ecadb57SMathias Bauer            If arHID(1) = sHID Then
1121ecadb57SMathias Bauer                If arHID(2) &lt;&gt; &quot;&quot; Then
1131ecadb57SMathias Bauer                    symHID = arHID(0) + &quot; &quot; + arHID(2)
1141ecadb57SMathias Bauer                Else
1151ecadb57SMathias Bauer                    symHID = arHID(0)
1161ecadb57SMathias Bauer                End If
1171ecadb57SMathias Bauer                bFound = true
1181ecadb57SMathias Bauer            End If
1191ecadb57SMathias Bauer        Loop
1201ecadb57SMathias Bauer        Close #iNumber
1211ecadb57SMathias Bauer        If not bFound Then
1221ecadb57SMathias Bauer            oLblWait.Text = &quot;Nothing found. Searched &quot;+sCt+&quot; Help IDs&quot;
1231ecadb57SMathias Bauer        Else
1241ecadb57SMathias Bauer            oTxtHID.Text = symHID
1251ecadb57SMathias Bauer            oLblWait.Text = &quot;HelpID found. Searched &quot;+sCt+&quot; Help IDs&quot;
1261ecadb57SMathias Bauer            oButHIDList.Enable = false
1271ecadb57SMathias Bauer        End If
1281ecadb57SMathias Bauer    Else
1291ecadb57SMathias Bauer        oLblWait.Text = &quot;No help_hid.lst found in your config folder&quot;
1301ecadb57SMathias Bauer    End If
1311ecadb57SMathias BauerEnd Sub
1321ecadb57SMathias Bauer
1331ecadb57SMathias Bauer</script:module>
134