sub footMark8 End Sub Sub openFootNotesDialog Dim dialog As Object DialogLibraries.LoadLibrary("ePublishing") dialog = CreateUnoDialog(DialogLibraries.ePublishing.FootnotesConfig) dialog.getControl("buttonOK").Label = getTranslation("buttonOk") dialog.getControl("buttonCancel").Label = getTranslation("buttonCancel") dialog.getControl("configText1").setText(getTranslation("configText1")) dialog.getControl("configText2").setText(getTranslation("configText2")) dialog.getControl("configText3").setText(getTranslation("configText3")) dialog.getControl("configText4").setText(getTranslation("configText4")) dialog.getControl("configText5").setText(getTranslation("configText5")) dialog.getControl("notesTypeLabel").setText(getTranslation("FootnotesConfigDialogNotesTypeLabel")) dialog.getControl("PerPageRangeLabel").setText(getTranslation("FootnotesConfigDialogNotesPerPageRangeLabel")) dialog.getControl("groupByPages").Model.Label = getTranslation("FootnotesConfigDialogNotesPerPage") dialog.getControl("groupByHeadings").Model.Label = getTranslation("FootnotesConfigDialogNotesByHeadingsLabel") dialog.Title = getTranslation("footnotesConfigDialogTitle") Dim nCount As Integer nCount = dialog.getControl("lb_notes_types").getItemCount() dialog.getControl("lb_notes_types").addItem( getTranslation("FootnotesConfigDialogFootnotesName"), nCount ) dialog.getControl("lb_notes_types").addItem( getTranslation("FootnotesConfigDialogEndnotesName"), nCount + 1 ) dialog.getControl("lb_notes_types").selectItemPos( 0, True ) dialog.setVisible(true) Select Case dialog.Execute() Case 1 setFootnotesNumberingFrom(dialog) Case 0 End Select dialog.dispose() End Sub Sub setFootnotesNumberingFrom(dialog As Object) Dim statusIndicator as Object Dim targetLevel As Integer Dim stringLevelInput As String Dim stringPageRangeInput As String Dim noteType As Integer statusIndicator = ThisComponent.getCurrentController.statusIndicator dialog.setVisible(false) doNotTrack stringLevelInput = dialog.getControl("level").getText stringPageRangeInput = dialog.getControl("pageRange").getText noteType = dialog.getControl("lb_notes_types").getSelectedItemPos() If (stringLevelInput <> "") Then targetLevel = CInt(stringLevelInput) If targetLevel > -1 AND targetLevel < 11 Then statusIndicator.Start(getTranslation("statusNumberingInProcess"),100) setFootnotesNumberingLevel(targetLevel,noteType) Else MsgBox getTranslation("numberingInputOutOfRange") EndIf EndIf If (stringPageRangeInput <> "") Then Dim pageNums() As Integer getPageNumsFrom(stringPageRangeInput, pageNums()) statusIndicator.Start(getTranslation("statusNumberingInProcess"),100) setNotesPaginatedNumbering(noteType, pageNums()) EndIf statusIndicator.end() MsgBox getTranslation("statusNumberingFinished") End Sub Sub setNotesPaginatedNumbering(noteType As Integer, pageNums() As Integer) Dim allNotes As Object Dim statusIndicator as Object Dim i As Integer Dim curNote As Object Dim curPage As String Dim prevPage As String Dim curNum As Integer Dim notesToValidate() As Object statusIndicator = ThisComponent.getCurrentController.statusIndicator statusIndicator.Start(getTranslation("statusNumberingInProcess"),30) curNum = 1 prevPage = "" If noteType = 0 Then allNotes = thisComponent.FootNotes Else allNotes = thisComponent.EndNotes EndIf For i = 0 to allNotes.Count -1 curNote = allNotes.getByIndex(i) curPage = getPageNumberVCurs(curNote.Anchor) If ( IsInArray(pageNums, CInt(curPage) ) ) Then If (curPage <> prevPage) Then curNum = 1 prevPage = curPage EndIf label = curNote.getLabel If label = "" Or IsNumeric(label) Then curNote.setLabel(CStr(curNum)) addToArray(notesToValidate,curnote) curNum = curNum + 1 EndIf EndIf Next i 'Second pass in case layout has changed For i = 0 To Ubound(notesToValidate) curNote = notesToValidate(i) curPage = getPageNumberVCurs(curNote.Anchor) If (curPage <> prevPage) Then curNum = 1 prevPage = curPage EndIf curNote.setLabel(CStr(curNum)) curNum = curNum + 1 Next i statusIndicator.end() End Sub Sub setFootnotesNumberingLevel(level As Integer,noteType As Integer) Dim enum1Element As Object Dim enum1 As Object Dim enum2 As Object Dim curNum As Integer Dim i As Integer Dim cell As Object Dim cellEnum As Object Dim statusIndicator as Object statusIndicator = ThisComponent.getCurrentController.statusIndicator statusIndicator.Start(getTranslation("statusNumberingInProcess"),30) curNum = 1 enum1 = ThisComponent.Text.createEnumeration While enum1.hasMoreElements enum1Element = enum1.nextElement If enum1Element.supportsService("com.sun.star.text.Paragraph") Then traverseNoteParagraphs(curNum, enum1Element ,noteType, level) ElseIf enum1Element.supportsService("com.sun.star.text.TextTable") Then cellNames = enum1Element.cellNames For i = LBound(cellNames) To Ubound(cellNames) cell = enum1Element.getCellByName(cellNames(i)) cellEnum = cell.getText().createEnumeration() While cellEnum.hasMoreElements cellEnumElement = cellEnum.nextElement If cellEnumElement.supportsService("com.sun.star.text.Paragraph") Then traverseNoteParagraphs(curNum, cellEnumElement ,noteType, level) EndIf Wend Next i EndIf Wend statusIndicator.end() End Sub Sub traverseNoteParagraphs(curNum As Integer, enum1Element As Object, noteType As Integer, level As Integer) Dim textPortions As Object Dim thisPortion As Object Dim footnoteText As Object Dim label As String Dim labelNum As Long If enum1Element.OutlineLevel = level Then curNum = 1 EndIf textPortions = enum1Element.createEnumeration While textPortions.hasMoreElements thisPortion = textPortions.nextElement If isTargetNote(thisPortion, noteType) Then footnoteText = thisPortion.Footnote label = footnoteText.getLabel If label = "" Then If level > 0 Then footnoteText.setLabel(CStr(curNum)) curNum = curNum + 1 EndIf Else If IsNumeric(label) Then If level < 1 Then footnoteText.setLabel("") Else footnoteText.setLabel(CStr(curNum)) curNum = curNum + 1 EndIf EndIf EndIf EndIf Wend End Sub Function isTargetNote(portion As Object, noteType As Integer) As Boolean If ( portion.TextPortionType <> "Footnote" ) Then isTargetNote = false Exit Function EndIf If ( isEndNote(portion) = CBool(noteType) ) Then isTargetNote = true Exit Function EndIf isTargetNote = false End Function 'Sub testRange ' Dim pageNums() As Integer ' getPageNumsFrom("9-10,8-12,-111-099,99,102,105,187,187",pageNums()) 'End Sub Sub getPageNumsFrom(inputString As String, pageNums() As Integer) Dim ranges() As String ranges = split(inputString,",") For i = Lbound(ranges) To (Ubound(ranges)) processNumRange(ranges(i),pageNums()) Next i End Sub Function IsInArray(array As Variant, content As Variant) As Boolean IsInArray = false For i = LBound(array) To UBound(array) inArr = array(i) If inArr = content Then IsInArray = true Exit Function EndIf Next i End Function Sub processNumRange(range As String, pageNums() As Integer) Dim rangeParts() As String Dim firstValue As String Dim secondValue As String Dim firstNum As Integer Dim secondNum As Integer rangeParts = split( range, "-") If UBound(rangeParts) = 1 Then firstValue = trim(rangeParts(0)) secondValue = trim(rangeParts(1)) If ( IsNumeric(firstValue) And IsNumeric(secondValue)) Then firstNum = CInt(firstValue) secondNum = CInt(secondValue) If firstNum <= secondNum Then For i = firstNum To secondNum If (NOT IsInArray(pageNums, i)) Then addToArray(pageNums, i) EndIf Next i EndIf EndIf EndIf If UBound(rangeParts) = 0 Then firstValue = trim(rangeParts(0)) If IsNumeric(firstValue) Then firstNum = CInt(firstValue) If (NOT IsInArray(pageNums, firstNum)) Then addToArray(pageNums, firstNum) EndIf EndIf EndIf End Sub Function isEndNote(portion As Object) As Boolean If (IsEmpty(portion.Start.EndNote)) Then isEndNote = false Else isEndNote = true EndIf End Function Private Sub doNotTrack Dim dispatcher As Object Dim document As Object dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") document = ThisComponent.CurrentController.Frame dim trackProperties(0) as new com.sun.star.beans.PropertyValue trackProperties(0).Name = "TrackChanges" trackProperties(0).Value = false dispatcher.executeDispatch(document, ".uno:TrackChanges", "", 0, trackProperties()) dim args1(0) as new com.sun.star.beans.PropertyValue args1(0).Name = "ShowTrackedChanges" args1(0).Value = true dispatcher.executeDispatch(document, ".uno:ShowTrackedChanges", "", 0, args1()) End Sub Sub FixFootnotes() Dim description As String Dim allNotes As Object Dim aNote As Object Dim oViewCursor As Object turnOffTracking AcceptAllTrackedChanges oViewCursor = ThisComponent.currentController.getViewCursor() 'Globalscope.BasicLibraries.LoadLibrary( "MRILib" ) allNotes = ThisComponent.FootNotes For x = 0 to allNotes.Count -1 aNote = allNotes.getByIndex(x) anchor = aNote.anchor oViewCursor.goToRange(anchor,false) oViewCursor.collapseToStart() oViewCursor.goToRange(anchor,true) unoCut() oViewCursor.goLeft(1,false) unoPaste() Next End Sub