diff --git a/IPHRedaction/Clean.xba b/IPHRedaction/Clean.xba index 0bd0148..5e6088f 100644 --- a/IPHRedaction/Clean.xba +++ b/IPHRedaction/Clean.xba @@ -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 - + \ No newline at end of file diff --git a/description.xml b/description.xml index d87e04f..cf1ea30 100644 --- a/description.xml +++ b/description.xml @@ -3,7 +3,7 @@ xmlns:dep="http://openoffice.org/extensions/description/2006" xmlns:xlink="http://www.w3.org/1999/xlink"> - + Redaction for publishing in Institute of philosophy