blob: 1e1d6b938389c5230b2935a3d03dc7c904ae1bbf [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="IND" 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
document = StarDesktop.CurrentComponent
BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
oDialog = LoadDialog(&quot;HelpAuthoring&quot;, &quot;dlgIND&quot;)
ocbAddTag = oDialog.GetControl(&quot;cbAddTag&quot;)
&apos; Check if bookmarks are allowed here
If IsInList Then
msgbox &quot;No Bookmarks allowed inside a list.&quot;, 48, &quot;D&apos;oh!&quot;
Exit Sub
End If
nBookmarkType = IsInBookmark
If nBookmarkType = 1 Then &apos; inside INDEX bookmark
ocbAddTag.State = 0
End If
oDialogModel = oDialog.Model
If oDialog.Execute() = 1 Then
&apos; Insert the bookmark construction
olbIND = oDialog.GetControl(&quot;lbIND&quot;)
If nBookmarkType = 0 Then&apos; not in a bookmark, always add parent tags
bmid = CreateID
&apos; now check if we are in a para with text (this wouldn&apos;t be valid)
If Not(ParaIsEmpty) Then
CR
End If
InsertTag(&quot;BOOKMARK_&quot;,&quot;&lt;BOOKMARK branch=&quot;&quot;index&quot;&quot; id=&quot;&quot;bm_id&quot; + bmid + &quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
For i=0 to ubound(olbIND.Items)
LF
InsertTag(&quot;BOOKMARKVALUE_&quot;,&quot;&lt;BOOKMARKVALUE&gt;&quot;)
InsertField(&quot;BOOKMARKVALUE&quot;,olbIND.Items(i))
InsertTag(&quot;_BOOKMARKVALUE&quot;,&quot;&lt;/BOOKMARKVALUE&gt;&quot;)
Next i
LF
InsertTagCR(&quot;_BOOKMARK&quot;,&quot;&lt;/BOOKMARK&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
ElseIf nBookmarkType = 1 Then &apos; in a correct bookmark type
If ocbAddTag.State = 1 Then
If Not(ParaIsEmpty) Then
CR
End If
InsertTag(&quot;BOOKMARK_&quot;,&quot;&lt;BOOKMARK branch=&quot;&quot;index&quot;&quot; id=&quot;&quot;bm_id&quot; + bmid + &quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
For i=0 to ubound(olbIND.Items)
LF
InsertTag(&quot;BOOKMARKVALUE_&quot;,&quot;&lt;BOOKMARKVALUE&gt;&quot;)
InsertField(&quot;BOOKMARKVALUE&quot;,olbIND.Items(i))
InsertTag(&quot;_BOOKMARKVALUE&quot;,&quot;&lt;/BOOKMARKVALUE&gt;&quot;)
Next i
If ocbAddTag.State = 1 Then
LF
InsertTagCR(&quot;_BOOKMARK&quot;,&quot;&lt;/BOOKMARK&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
End If
Else
For i=0 to ubound(olbIND.Items)
LF
InsertTag(&quot;BOOKMARKVALUE_&quot;,&quot;&lt;BOOKMARKVALUE&gt;&quot;)
InsertField(&quot;BOOKMARKVALUE&quot;,olbIND.Items(i))
InsertTag(&quot;_BOOKMARKVALUE&quot;,&quot;&lt;/BOOKMARKVALUE&gt;&quot;)
Next i
End If
Else &apos; in a wrong bookmark type
If Not(ParaIsEmpty) Then
CR
End If
InsertTag(&quot;BOOKMARK_&quot;,&quot;&lt;BOOKMARK branch=&quot;&quot;index&quot;&quot; id=&quot;&quot;bm_id&quot; + bmid + &quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
For i=0 to ubound(olbIND.Items)
LF
InsertTag(&quot;BOOKMARKVALUE_&quot;,&quot;&lt;BOOKMARKVALUE&gt;&quot;)
InsertField(&quot;BOOKMARKVALUE&quot;,olbIND.Items(i))
InsertTag(&quot;_BOOKMARKVALUE&quot;,&quot;&lt;/BOOKMARKVALUE&gt;&quot;)
Next i
LF
InsertTagCR(&quot;_BOOKMARK&quot;,&quot;&lt;/BOOKMARK&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
End If
End If
oDialog.dispose
End Sub
Sub AddKeyStroke(Event As Object)
Select Case Event.KeyCode
Case com.sun.star.awt.Key.RETURN
AddIndexEntry
Case com.sun.star.awt.Key.SPACE
AddIndexEntry
End Select
End Sub
Sub AddIndexEntry
oTxtLevel1 = oDialog.GetControl(&quot;txtLevel1&quot;)
oTxtLevel2 = oDialog.GetControl(&quot;txtLevel2&quot;)
If oTxtLevel2.Text &lt;&gt; &quot;&quot; Then
IndexEntry = oTxtLevel1.Text + &quot;;&quot; + oTxtLevel2.Text
Else
IndexEntry = oTxtLevel1.Text
End If
If ((oTxtLevel1.Text = &quot;&quot;) OR (IndexEntry = &quot;&lt;Level 1&gt;;&lt;Level 2&gt;&quot;)) Then
msgbox &quot;Enter an index entry first.&quot;
Else
&apos; Insert the index entry into the list
olbIND = oDialog.GetControl(&quot;lbIND&quot;)
olbIND.addItem(IndexEntry,0)
End If
End Sub
Sub RemoveKeyStroke(Event As Object)
Select Case Event.KeyCode
Case com.sun.star.awt.Key.RETURN
RemoveIndexEntry
Case com.sun.star.awt.Key.SPACE
RemoveIndexEntry
End Select
End Sub
Sub RemoveIndexEntry
olbIND = oDialog.GetControl(&quot;lbIND&quot;)
ItemsPos = olbIND.getSelectedItemsPos
For i=0 to ubound(ItemsPos)
olbIND.removeItems(ItemsPos(i)-i,1)
Next i
End Sub
Sub KeyPressedAdd(Event As Object)
Select Case Event.KeyCode
Case com.sun.star.awt.Key.INSERT
AddIndexEntry
End Select
End Sub
Sub KeyPressedRemove(Event As Object)
Select Case Event.KeyCode
Case com.sun.star.awt.Key.DELETE
RemoveIndexEntry
End Select
End Sub
</script:module>