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