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() saveAndreload()
cleanFormatting cleanFormatting
saveAndreload() saveAndreload()
disposeAllLinks removeHyperlinks
disposeAllBookmarks disposeAllBookmarks
fixTableWidth fixTableWidth
fixDrawingAnchors fixDrawingAnchors
@ -273,20 +273,59 @@ End Function
Private Sub disposeAllLinks() Private Sub removeHyperlinks()
Dim SrchAttributes(0) as new com.sun.star.beans.PropertyValue Dim statusIndicator as Object
SrchAttributes(0).Name = "CharStyleName" Dim aNote As Object
SrchAttributes(0).Value = "Internet link" statusIndicator = ThisComponent.getCurrentController.StatusIndicator
Dim ReplAttributes(2) as new com.sun.star.beans.PropertyValue statusIndicator.Start("Удаление гиперссылок, подождите",10)
ReplAttributes(0).Name = "HyperlinkTarget" removeHLInText(ThisComponent.Text)
ReplAttributes(0).Value = "" For x = 0 to ThisComponent.FootNotes.Count -1
ReplAttributes(1).Name = "HyperLinkURL" aNote = ThisComponent.FootNotes.getByIndex(x)
ReplAttributes(1).Value = "" removeHLInText(aNote.Text)
ReplAttributes(2).Name = "CharStyleName" Next
ReplAttributes(2).Value = ThisComponent.getStyleFamilies().getByIndex(0).ElementNames(0) For x = 0 to ThisComponent.EndNotes.Count -1
setAttributesBySearchPattern("",ReplAttributes,SrchAttributes) aNote = ThisComponent.EndNotes.getByIndex(x)
removeHLInText(aNote.Text)
Next
statusIndicator.end()
End Sub 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() Private Sub disposeAllBookmarks()
Dim bookmarks As Object Dim bookmarks As Object
Dim elementName As String Dim elementName As String

View file

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