Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I think you will need user code for the purpose.
If your big document does not contain tables and there are no TextFrames or only TextFrames not containing hyperlinked text, it is rather simple to search for all the hyperlinks, and to change them as you think to need ("_blank" target frame).
If TextTables occur, it's significantly more complicated.
The code:

Sub clearFormattingAndDirectHyperlinksToBlank()
REM This roughly sketched macro CAN NOT HANDLE text inside TextFrames.
REM It will fail and throw an error if the body text is containing TextTables.

theDoc       = ThisComponent
currCtrl     = theDoc.CurrentController
oldSel       = theDoc.CurrentSelection
dispProvider = currCtrl.Frame
dispHelper   = createUnoService("com.sun.star.frame.DispatchHelper")
dispHelper.executeDispatch(dispProvider, ".uno:SelectAll", "", 0, Array())
dispHelper.executeDispatch(dispProvider, ".uno:ResetAttributes", "", 0, Array())
bText        = theDoc.Text
For Each para in bText
  para.ParaStyleName = "Default Style"
  For Each piece in para
    url = urlIf(piece)
    If url<>"" Then
      piece.HyperLinkTarget = "_blank"
    End If
  Next piece
Next para
currCtrl.select(oldSel)
End Sub

Function urlIf(pPiece As Object) As String
On Local Error Goto errorExit

 urlIf = "" urlIf = pPiece.HyperLinkURL errorExit: End Function

And a demo.

I think you will need user code for the purpose.
If your big document does not contain tables and there are no TextFrames or only TextFrames not containing hyperlinked text, it is rather simple to search for all the hyperlinks, and to change them as you think to need ("_blank" target frame).
If TextTables occur, it's significantly more complicated.
The code:

Sub clearFormattingAndDirectHyperlinksToBlank()
REM This roughly sketched macro CAN NOT HANDLE text inside TextFrames.
REM It will fail and throw an error if the body text is containing TextTables.

theDoc       = ThisComponent
currCtrl     = theDoc.CurrentController
oldSel       = theDoc.CurrentSelection
dispProvider = currCtrl.Frame
dispHelper   = createUnoService("com.sun.star.frame.DispatchHelper")
dispHelper.executeDispatch(dispProvider, ".uno:SelectAll", "", 0, Array())
dispHelper.executeDispatch(dispProvider, ".uno:ResetAttributes", "", 0, Array())
bText        = theDoc.Text
For Each para in bText
  para.ParaStyleName = "Default Style"
  For Each piece in para
    url = urlIf(piece)
    If url<>"" Then
      piece.HyperLinkTarget = "_blank"
    End If
  Next piece
Next para
currCtrl.select(oldSel)
End Sub

 Function urlIf(pPiece As Object) As String
 On Local Error Goto errorExit
errorExit  
 urlIf = "" 
 urlIf = pPiece.HyperLinkURL 
 errorExit: 
 End Function

 urlIf = "" urlIf = pPiece.HyperLinkURL errorExit: End Function

And a demo.