diff --git a/IPHRedaction/Clean.xba b/IPHRedaction/Clean.xba index 2846e3f..f5b0520 100644 --- a/IPHRedaction/Clean.xba +++ b/IPHRedaction/Clean.xba @@ -12,10 +12,92 @@ doNotTrack statusIndicator.Start("Чистка документа начата, подождите",30) cleanFormatting + disposePageBreaks + disposeAllLinks + disposeAllBookmarks statusIndicator.end() saveAndreload() End Sub +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(searchPattern,SrchAttributes,ReplAttributes) +End Sub + +Private Sub disposeAllBookmarks() + Dim bookmarks As Object + Dim elementName As String + elementName = ThisComponent.Links.ElementNames(6) + bookmarks = ThisComponent.Links.getByName(elementName) + While bookmarks.hasElements() + bookmark = bookmarks.getByName(bookmarks.ElementNames(0)) + bookmark.dispose() + Wend +End Sub + + +Private Sub disposePageBreaks + oTextCursor = ThisComponent.Text.CreateTextCursor() + enum1 = ThisComponent.Text.createEnumeration + While enum1.hasMoreElements + enum1Element = enum1.nextElement + If enum1Element.supportsService("com.sun.star.text.Paragraph") Then + If enum1Element.BreakType <> com.sun.star.style.BreakType.NONE Then + oTextCursor.goToRange(enum1Element.getAnchor(), false) + If NOT IsEmpty(oTextCursor.PageDescName) Then + oTextCursor.PageDescName = "" + End If + oTextCursor.BreakType = com.sun.star.style.BreakType.NONE + End If + ElseIf enum1Element.supportsService("com.sun.star.text.TextTable") Then + If NOT IsEmpty(enum1Element.PageDescName) Then + enum1Element.PageDescName = "" + End If + enum1Element.BreakType = com.sun.star.style.BreakType.NONE + EndIf + Wend +End Sub + +Private Sub setAttributesBySearchPattern(searchPattern As String, SrchAttributes, ReplAttributes) + + Dim oSearch + Dim oTextCursor As Object + Dim oViewCursor As Object + Dim lineIndent + Dim foundPatterns() As Object + document = ThisComponent.CurrentController.Frame + dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") + oSearch = ThisComponent.createSearchDescriptor() + oSearch.SearchString = searchPattern + oSearch.SearchRegularExpression=True + oSearch.SearchAll = True + oSearch.searchStyles = true + If Not IsEmpty(SrchAttributes(0).Value) Then + oSearch.SetSearchAttributes(SrchAttributes()) + End If + oFound = ThisComponent.findFirst(oSearch) + Do While Not IsNull(oFound) + For i = LBound(ReplAttributes) To Ubound(ReplAttributes) + ' Globalscope.BasicLibraries.LoadLibrary( "MRILib" ) + ' Mri oFound + If oFound.getPropertySetInfo.hasPropertyByName(ReplAttributes(i).Name) Then + oFound.SetPropertyValue(ReplAttributes(i).Name,ReplAttributes(i).Value) + EndIf + Next i + oFound = ThisComponent.findNext(oFound.End, oSearch) + Loop + +End Sub + Private Sub saveAndreload() dim document as object diff --git a/icons/addon_icon.png b/icons/addon_icon.png index ab29643..2291918 100644 Binary files a/icons/addon_icon.png and b/icons/addon_icon.png differ diff --git a/icons/clean.png b/icons/clean.png index d3646ab..5e6acd3 100644 Binary files a/icons/clean.png and b/icons/clean.png differ diff --git a/icons/validate.png b/icons/validate.png index 4a554a3..fdf7c33 100644 Binary files a/icons/validate.png and b/icons/validate.png differ diff --git a/redaction.oxt b/redaction.oxt index 3430ddf..46124f6 100644 Binary files a/redaction.oxt and b/redaction.oxt differ