Advertisement
paul1149

LO Macro: Insert Index Mark

Feb 12th, 2016
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. Working macro to insert Index Mark, update Indexes:
  2.  
  3. Sub SetIndex
  4. ' see: https://wiki.openoffice.org/wiki/Documentation/DevGuide/Text/Indexes_and_Index_Marks
  5. oSelection = ThisComponent.CurrentController.Selection
  6. oIndex =ThisComponent.createInstance("com.sun.star.text.ContentIndexMark")
  7. oIndex.setPropertyValue ( "Level", 4)
  8. for Int1 = 0 to oSelection.Count -1
  9. oSel1 = oSelection (Int1)
  10. if HasUnoInterfaces(oSel1,"com.sun.star.text.XTextRange") Then
  11. ThisComponent.Text.InsertTextContent(oSel1, oIndex, True)
  12. end If
  13. Next Int1
  14. Update_Index 'Call Sub Update_Index
  15. End Sub
  16.  
  17. sub Update_Index
  18. dim document as object
  19. dim dispatcher as object
  20. document = ThisComponent.CurrentController.Frame
  21. dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
  22. dispatcher.executeDispatch(document, ".uno:UpdateAllIndexes", "", 0, Array())
  23. end sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement