This commit is contained in:
Georgy Litvinov 2019-10-16 23:13:24 +03:00
parent d7008bc972
commit aceaef82fd
5 changed files with 82 additions and 0 deletions

View file

@ -12,10 +12,92 @@
doNotTrack doNotTrack
statusIndicator.Start("Чистка документа начата, подождите",30) statusIndicator.Start("Чистка документа начата, подождите",30)
cleanFormatting cleanFormatting
disposePageBreaks
disposeAllLinks
disposeAllBookmarks
statusIndicator.end() statusIndicator.end()
saveAndreload() saveAndreload()
End Sub 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() Private Sub saveAndreload()
dim document as object dim document as object

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.