More fixes. Clean is ready

This commit is contained in:
Georgy Litvinov 2019-10-17 00:11:21 +03:00
parent 1ee9bf594e
commit 0843de1752
3 changed files with 71 additions and 476 deletions

View file

@ -15,12 +15,60 @@
disposePageBreaks
disposeAllLinks
disposeAllBookmarks
fixTableAnchors
fixTableWidth
fixDrawingAnchors
loadArticleStyles
statusIndicator.end()
saveAndreload()
End Sub
Private Sub loadArticleStyles
Dim dispatcher as object
Dim fileePath As String
Dim fileTest As Object
Dim fileName As String
Dim aArgs(0) As New com.sun.star.beans.PropertyValue
fileName = "Статья.ott"
filePath = getTemplatePath() & "/" & fileName
fileTest = CreateUnoService("com.sun.star.ucb.SimpleFileAccess")
If NOT fileTest.exists(filePath) Then
MsgBox "Файл стилей " & fileName & " не добавлен в Мои шаблоны. Не могу загрузить стили в текущий файл."
Exit Sub
EndIf
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
aArgs(0).Name = "OverwriteStyles"
aArgs(0).Value = True
ThisComponent.StyleFamilies.loadStylesFromURL( filePath, aArgs() )
End Sub
Private Sub AskAndReplace(SearchString, oReplaceString)
Dim SrchAttributes(0) as new com.sun.star.beans.PropertyValue
Dim ReplAttributes(0) as new com.sun.star.beans.PropertyValue
ReplaceFormatting(SearchString,oReplaceString,SrchAttributes,ReplAttributes, true)
End Sub
Private Function getTemplatePath() as String
Dim ath as String
Dim settings As Object
Dim configProvider As Object
Dim params(0) As new com.sun.star.beans.PropertyValue
Dim convService As Object
configProvider = createUnoService( "com.sun.star.configuration.ConfigurationProvider" )
params(0).Name = "nodepath"
params(0).Value = "/org.openoffice.Office.Paths/Paths"
settings = configProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", params() )
path = settings.Template.WritePath
convService = CreateUnoService("com.sun.star.util.PathSubstitution")
path = convService.substituteVariables(path, true)
path = ConvertToUrl(path)
getTemplatePath = path
End Function
Private Sub disposeAllLinks()
Dim SrchAttributes(0) as new com.sun.star.beans.PropertyValue
SrchAttributes(0).Name = "CharStyleName"
@ -148,7 +196,7 @@ Private Sub cleanFormatting
End Sub
Private Sub fixTableAnchors()
Private Sub fixTableWidth()
Dim table As Object
Dim tables As Object
tables = ThisComponent.TextTables
@ -165,6 +213,20 @@ Private Sub fixTableAnchors()
Next
End Sub
Private Sub fixDrawingAnchors()
Dim drawing As Object
Dim drawings As Object
drawings = ThisComponent.DrawPage
Dim count As Long
count = drawings.getCount()
For i = 0 To count - 1
drawing = drawings.getByIndex(i)
If drawing.AnchorType= com.sun.star.text.TextContentAnchorType.AT_PAGE Then
drawing.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH
EndIf
Next
End Sub
Sub manualFontsToCharStyle
Dim oDoc
oDoc = Thiscomponent
@ -262,8 +324,6 @@ Private Sub doNotTrack
dispatcher.executeDispatch(document, ".uno:ShowTrackedChanges", "", 0, args1())
End Sub
Private Sub removeDirectFormatting
Dim oDescriptor 'The search descriptor
dim dispatcher as Object
@ -272,6 +332,9 @@ Private Sub removeDirectFormatting
document = ThisComponent.CurrentController.Frame
Dim oViewCursor As Object 'View cursor
oViewCursor = ThisComponent.CurrentController.getViewCursor()
' Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
' Mri oViewCursor
oViewCursor.jumpToFirstPage()
oViewCursor.gotoStart(false)
oViewCursor.gotoEnd(true)
dispatcher.executeDispatch(document, ".uno:ResetAttributes", "", 0, Array())