Advertisement
Guest User

Untitled

a guest
May 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' Va alla num-esima intestazione
  2. ' Macro personali\Standard\Module1\GoHeading
  3. 'macro:///Standard.Module1.GoHeading($heading)
  4. Sub GoHeading(num as integer)
  5.   REM Author: Andrew Pitonyak
  6.   REM Modified: Daniele Primon
  7.   Dim oParEnum     'Enumerator used to enumerate the paragraphs
  8.  Dim oPar         'The enumerated paragraph
  9.  Dim s$
  10.   Dim i as Integer
  11.  
  12.   IF IsNull(num) or num=0 then
  13.   ' exit sub
  14.     num = 1
  15.   endif
  16. '  print "Cappello"
  17.  Dim oFrame
  18.   Dim oDisp
  19.   oFrame = ThisComponent.CurrentController.Frame
  20.   oDisp = createUnoService("com.sun.star.frame.DispatchHelper")
  21.  
  22.  
  23.   REM Enumerate the paragraphs.
  24.   REM Tables are enumerated along with paragraphs
  25.   oParEnum = ThisComponent.getText().createEnumeration()
  26.   i=1
  27.   Do While oParEnum.hasMoreElements()
  28.     oPar = oParEnum.nextElement()
  29.  
  30.     REM This avoids the tables. Add an else statement if you want to
  31.     REM process the tables.
  32.     If oPar.supportsService("com.sun.star.text.Paragraph") Then
  33. '      MsgBox oPar.getString(), 0, "I found a paragraph"
  34. '      If Len(oPar.NumberingStyleName) > 0 Then
  35.        If InStr(oPar.ParaStyleName, "Heading ") = 1 Then
  36. '           print oPar.NumberingStyleName+" "+oPar.ParaStyleName
  37. '          If RefreshStyle(oPar.NumberingStyleName) Then
  38.            if i=num or Not oParEnum.hasMoreElements() then
  39. '              print "carrramba! "+i
  40.              ThisComponent.getCurrentController().select(oPar)
  41.               xViewCursor=ThisComponent.getCurrentController().getViewCursor()
  42.               xViewCursor.gotoStartOfLine(false)
  43.               exit do
  44.             end if
  45. '            msgbox "selezione?"
  46.            i=i+1
  47.  '         EndIf
  48.        End If
  49. '      End If
  50. '    ElseIf oPar.supportsService("com.sun.staar.text.TextTable") Then
  51.      'Print "I found a TextTable"
  52. '    Else
  53.      'Print "What did I find?"
  54.    End If
  55.   Loop
  56. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement