Merged removal of hyperlinks

This commit is contained in:
George Litvinov 2019-11-21 14:11:59 +03:00
parent 1554b9e8f7
commit c1e8e93b01
2 changed files with 54 additions and 15 deletions

View file

@ -20,7 +20,7 @@ Sub cleanButton
saveAndreload()
cleanFormatting
saveAndreload()
disposeAllLinks
removeHyperlinks
disposeAllBookmarks
fixTableWidth
fixDrawingAnchors
@ -273,20 +273,59 @@ End Function
Private Sub disposeAllLinks()
Dim SrchAttributes(0) as new com.sun.star.beans.PropertyValue
SrchAttributes(0).Name = "CharStyleName"
SrchAttributes(0).Value = "Internet link"
Dim ReplAttributes(2) as new com.sun.star.beans.PropertyValue
ReplAttributes(0).Name = "HyperlinkTarget"
ReplAttributes(0).Value = ""
ReplAttributes(1).Name = "HyperLinkURL"
ReplAttributes(1).Value = ""
ReplAttributes(2).Name = "CharStyleName"
ReplAttributes(2).Value = ThisComponent.getStyleFamilies().getByIndex(0).ElementNames(0)
setAttributesBySearchPattern("",ReplAttributes,SrchAttributes)
Private Sub removeHyperlinks()
Dim statusIndicator as Object
Dim aNote As Object
statusIndicator = ThisComponent.getCurrentController.StatusIndicator
statusIndicator.Start("Удаление гиперссылок, подождите",10)
removeHLInText(ThisComponent.Text)
For x = 0 to ThisComponent.FootNotes.Count -1
aNote = ThisComponent.FootNotes.getByIndex(x)
removeHLInText(aNote.Text)
Next
For x = 0 to ThisComponent.EndNotes.Count -1
aNote = ThisComponent.EndNotes.getByIndex(x)
removeHLInText(aNote.Text)
Next
statusIndicator.end()
End Sub
Private Sub removeHLInText(textElement)
Dim enum1Element As Object
Dim enum1 As Object
Dim i As Integer
Dim cell As Object
enum1 = textElement.createEnumeration()
While enum1.hasMoreElements
enum1Element = enum1.nextElement
If enum1Element.supportsService("com.sun.star.text.Paragraph") Then
removeHLInPara(enum1Element)
ElseIf enum1Element.supportsService("com.sun.star.text.TextTable") Then
cellNames = enum1Element.cellNames
For i = LBound(cellNames) To Ubound(cellNames)
cell = enum1Element.getCellByName(cellNames(i))
cellText = cell.getText()
removeHLInText(cellText)
Next i
Else
EndIf
Wend
End Sub
Private Sub removeHLInPara(para)
Dim enum1Element As Object
Dim enum1 As Object
Dim elPropertySetInfo As Object
Dim i As Integer
enum1 = para.createEnumeration()
While enum1.hasMoreElements
enum1Element = enum1.nextElement
elPropertySetInfo = enum1Element.getPropertySetInfo()
If elPropertySetInfo.hasPropertyByName("HyperLinkURL") Then
enum1Element.HyperLinkURL=""
EndIf
Wend
End Sub
Private Sub disposeAllBookmarks()
Dim bookmarks As Object
Dim elementName As String
@ -890,4 +929,4 @@ Private Function getStyleNames(oFamily,bLocalized as Boolean, _
Endif
xArray(iUB) = vNextElement
End Sub
</script:module>
</script:module>

View file

@ -3,7 +3,7 @@
xmlns:dep="http://openoffice.org/extensions/description/2006"
xmlns:xlink="http://www.w3.org/1999/xlink">
<identifier value="pro.litvinovg.Redaction" />
<version value="0.2.9" />
<version value="0.3.0" />
<platform value="all" />
<display-name>
<name lang="en">Redaction for publishing in Institute of philosophy</name>