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