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("HelpAuthoring") oDialog = LoadDialog("HelpAuthoring", "dlgIND") ocbAddTag = oDialog.GetControl("cbAddTag") ' Check if bookmarks are allowed here If IsInList Then msgbox "No Bookmarks allowed inside a list.", 48, "D'oh!" Exit Sub End If nBookmarkType = IsInBookmark If nBookmarkType = 1 Then ' inside INDEX bookmark ocbAddTag.State = 0 End If oDialogModel = oDialog.Model If oDialog.Execute() = 1 Then ' Insert the bookmark construction olbIND = oDialog.GetControl("lbIND") If nBookmarkType = 0 Then' not in a bookmark, always add parent tags bmid = CreateID ' now check if we are in a para with text (this wouldn't be valid) If Not(ParaIsEmpty) Then CR End If InsertTag("BOOKMARK_","<BOOKMARK branch=""index"" id=""bm_id" + bmid + """>","hlp_aux_bookmark") For i=0 to ubound(olbIND.Items) LF InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>") InsertField("BOOKMARKVALUE",olbIND.Items(i)) InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>") Next i LF InsertTagCR("_BOOKMARK","</BOOKMARK>","hlp_aux_bookmark") ElseIf nBookmarkType = 1 Then ' in a correct bookmark type If ocbAddTag.State = 1 Then If Not(ParaIsEmpty) Then CR End If InsertTag("BOOKMARK_","<BOOKMARK branch=""index"" id=""bm_id" + bmid + """>","hlp_aux_bookmark") For i=0 to ubound(olbIND.Items) LF InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>") InsertField("BOOKMARKVALUE",olbIND.Items(i)) InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>") Next i If ocbAddTag.State = 1 Then LF InsertTagCR("_BOOKMARK","</BOOKMARK>","hlp_aux_bookmark") End If Else For i=0 to ubound(olbIND.Items) LF InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>") InsertField("BOOKMARKVALUE",olbIND.Items(i)) InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>") Next i End If Else ' in a wrong bookmark type If Not(ParaIsEmpty) Then CR End If InsertTag("BOOKMARK_","<BOOKMARK branch=""index"" id=""bm_id" + bmid + """>","hlp_aux_bookmark") For i=0 to ubound(olbIND.Items) LF InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>") InsertField("BOOKMARKVALUE",olbIND.Items(i)) InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>") Next i LF InsertTagCR("_BOOKMARK","</BOOKMARK>","hlp_aux_bookmark") 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("txtLevel1") oTxtLevel2 = oDialog.GetControl("txtLevel2") If oTxtLevel2.Text <> "" Then IndexEntry = oTxtLevel1.Text + ";" + oTxtLevel2.Text Else IndexEntry = oTxtLevel1.Text End If If ((oTxtLevel1.Text = "") OR (IndexEntry = "<Level 1>;<Level 2>")) Then msgbox "Enter an index entry first." Else ' Insert the index entry into the list olbIND = oDialog.GetControl("lbIND") 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("lbIND") 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