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="IND" script:language="StarBasic">REM ***** BASIC ***** 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("HelpAuthoring") 38 oDialog = LoadDialog("HelpAuthoring", "dlgIND") 39 ocbAddTag = oDialog.GetControl("cbAddTag") 40 41 ' Check if bookmarks are allowed here 42 If IsInList Then 43 msgbox "No Bookmarks allowed inside a list.", 48, "D'oh!" 44 Exit Sub 45 End If 46 47 48 nBookmarkType = IsInBookmark 49 If nBookmarkType = 1 Then ' inside INDEX bookmark 50 ocbAddTag.State = 0 51 End If 52 53 oDialogModel = oDialog.Model 54 55 If oDialog.Execute() = 1 Then 56 ' Insert the bookmark construction 57 olbIND = oDialog.GetControl("lbIND") 58 59 If nBookmarkType = 0 Then' not in a bookmark, always add parent tags 60 bmid = CreateID 61 ' now check if we are in a para with text (this wouldn't be valid) 62 If Not(ParaIsEmpty) Then 63 CR 64 End If 65 InsertTag("BOOKMARK_","<BOOKMARK branch=""index"" id=""bm_id" + bmid + """>","hlp_aux_bookmark") 66 67 For i=0 to ubound(olbIND.Items) 68 LF 69 InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>") 70 InsertField("BOOKMARKVALUE",olbIND.Items(i)) 71 InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>") 72 Next i 73 LF 74 InsertTagCR("_BOOKMARK","</BOOKMARK>","hlp_aux_bookmark") 75 76 ElseIf nBookmarkType = 1 Then ' in a correct bookmark type 77 If ocbAddTag.State = 1 Then 78 If Not(ParaIsEmpty) Then 79 CR 80 End If 81 InsertTag("BOOKMARK_","<BOOKMARK branch=""index"" id=""bm_id" + bmid + """>","hlp_aux_bookmark") 82 For i=0 to ubound(olbIND.Items) 83 LF 84 InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>") 85 InsertField("BOOKMARKVALUE",olbIND.Items(i)) 86 InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>") 87 Next i 88 If ocbAddTag.State = 1 Then 89 LF 90 InsertTagCR("_BOOKMARK","</BOOKMARK>","hlp_aux_bookmark") 91 End If 92 Else 93 For i=0 to ubound(olbIND.Items) 94 LF 95 InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>") 96 InsertField("BOOKMARKVALUE",olbIND.Items(i)) 97 InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>") 98 Next i 99 End If 100 Else ' in a wrong bookmark type 101 If Not(ParaIsEmpty) Then 102 CR 103 End If 104 InsertTag("BOOKMARK_","<BOOKMARK branch=""index"" id=""bm_id" + bmid + """>","hlp_aux_bookmark") 105 For i=0 to ubound(olbIND.Items) 106 LF 107 InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>") 108 InsertField("BOOKMARKVALUE",olbIND.Items(i)) 109 InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>") 110 Next i 111 LF 112 InsertTagCR("_BOOKMARK","</BOOKMARK>","hlp_aux_bookmark") 113 End If 114 End If 115 116 oDialog.dispose 117 118End Sub 119 120Sub AddKeyStroke(Event As Object) 121 Select Case Event.KeyCode 122 Case com.sun.star.awt.Key.RETURN 123 AddIndexEntry 124 Case com.sun.star.awt.Key.SPACE 125 AddIndexEntry 126 End Select 127End Sub 128 129Sub AddIndexEntry 130 131 oTxtLevel1 = oDialog.GetControl("txtLevel1") 132 oTxtLevel2 = oDialog.GetControl("txtLevel2") 133 134 If oTxtLevel2.Text <> "" Then 135 IndexEntry = oTxtLevel1.Text + ";" + oTxtLevel2.Text 136 Else 137 IndexEntry = oTxtLevel1.Text 138 End If 139 140 If ((oTxtLevel1.Text = "") OR (IndexEntry = "<Level 1>;<Level 2>")) Then 141 msgbox "Enter an index entry first." 142 Else 143 ' Insert the index entry into the list 144 olbIND = oDialog.GetControl("lbIND") 145 olbIND.addItem(IndexEntry,0) 146 End If 147 148End Sub 149 150Sub RemoveKeyStroke(Event As Object) 151 Select Case Event.KeyCode 152 Case com.sun.star.awt.Key.RETURN 153 RemoveIndexEntry 154 Case com.sun.star.awt.Key.SPACE 155 RemoveIndexEntry 156 End Select 157End Sub 158 159 160Sub RemoveIndexEntry 161 olbIND = oDialog.GetControl("lbIND") 162 ItemsPos = olbIND.getSelectedItemsPos 163 For i=0 to ubound(ItemsPos) 164 olbIND.removeItems(ItemsPos(i)-i,1) 165 Next i 166End Sub 167 168Sub KeyPressedAdd(Event As Object) 169 Select Case Event.KeyCode 170 Case com.sun.star.awt.Key.INSERT 171 AddIndexEntry 172 End Select 173End Sub 174 175Sub KeyPressedRemove(Event As Object) 176 Select Case Event.KeyCode 177 Case com.sun.star.awt.Key.DELETE 178 RemoveIndexEntry 179 End Select 180End Sub 181</script:module> 182