Added button to replace paragraph style
This commit is contained in:
parent
03789e78c7
commit
1535e54017
5 changed files with 208 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
|
||||
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Archive" script:language="StarBasic" script:moduleType="normal">Sub archMark2
|
||||
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Archive" script:language="StarBasic" script:moduleType="normal">Sub archMark7
|
||||
|
||||
End Sub
|
||||
|
||||
|
@ -123,7 +123,11 @@ End Function
|
|||
|
||||
|
||||
sub convertIndesignPageBreaks
|
||||
|
||||
Dim description As String
|
||||
description = "Запустить восстановление разрывов страниц?"
|
||||
If NOT confirm(description) Then
|
||||
Exit Sub
|
||||
EndIf
|
||||
document = ThisComponent.CurrentController.Frame
|
||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||
oViewCursor = thisComponent.getCurrentController.getViewCursor
|
||||
|
@ -183,7 +187,7 @@ sub convertIndesignPageBreaks
|
|||
End If
|
||||
oFound = ThisComponent.findNext(oFound.End, oSearch)
|
||||
Loop
|
||||
|
||||
MsgBox "Восстановление разрывов страниц завершено."
|
||||
end Sub
|
||||
|
||||
Sub adjustLastLine(oTextCursor)
|
||||
|
@ -297,6 +301,12 @@ End Sub
|
|||
|
||||
|
||||
Sub convertBookmarksToFootnotes()
|
||||
Dim description As String
|
||||
description = "Запустить восстановление сносок из текста?"
|
||||
If NOT confirm(description) Then
|
||||
Exit Sub
|
||||
EndIf
|
||||
|
||||
Dim bookmarks as Object
|
||||
Dim bookmarkName as String
|
||||
Dim strStart As Integer
|
||||
|
@ -331,7 +341,7 @@ Sub convertBookmarksToFootnotes()
|
|||
Next i
|
||||
|
||||
resetNotesStyle
|
||||
|
||||
MsgBox "Восстановление сносок завершено."
|
||||
End Sub
|
||||
|
||||
Sub convertLinkToFootnote(forwardLink,backwardLink)
|
||||
|
@ -398,4 +408,124 @@ sub createFootnote
|
|||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||
dispatcher.executeDispatch(document, ".uno:InsertFootnote", "", 0, Array())
|
||||
end Sub
|
||||
|
||||
|
||||
Dim oDialog
|
||||
|
||||
Sub onSelectMenuItem(oEvent)
|
||||
oDialog.endExecute()
|
||||
oDialog.model.Tag = oEvent.ActionCommand
|
||||
End Sub
|
||||
|
||||
Sub replaceParaStyle
|
||||
|
||||
dim oldStyleName As String
|
||||
dim oldStyle As Object
|
||||
dim newStyleName As String
|
||||
dim paragraphStyles As Object
|
||||
dim userInput As Integer
|
||||
Dim listBox As Object
|
||||
Dim paraStyle As Object
|
||||
Dim oViewCursor As Object
|
||||
Dim enum1 As Object
|
||||
Dim oTextCursor As Object
|
||||
|
||||
oStyles = ThisComponent.StyleFamilies
|
||||
paraStyles = oStyles.getByName(oStyles.elementNames(1))
|
||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||
oldStyleName = oViewCursor.ParaStyleName
|
||||
|
||||
paraStyleNames = paraStyles.ElementNames
|
||||
Dim displayParaStyleNames(Ubound(paraStyleNames))
|
||||
Dim sortedDPSN(Ubound(paraStyleNames))
|
||||
displayParaStyleNames = paraStyleNames
|
||||
Redim Preserve displayParaStyleNames(Ubound(paraStyleNames))
|
||||
For i = LBound(displayParaStyleNames) To Ubound(displayParaStyleNames)
|
||||
paraStyle = paraStyles.getByName(displayParaStyleNames(i))
|
||||
displayParaStyleNames(i) = paraStyle.displayName
|
||||
Next i
|
||||
sortedDPSN = displayParaStyleNames
|
||||
Redim Preserve sortedDPSN(Ubound(paraStyleNames))
|
||||
subShellSort(sortedDPSN)
|
||||
DialogLibraries.LoadLibrary("ePublishing")
|
||||
oDialog = CreateUnoDialog( DialogLibraries.ePublishing.replaceParaStyle )
|
||||
listBox = oDialog.getControl("ListBox1")
|
||||
listBox.addItems(sortedDPSN , 0)
|
||||
oDialog.Execute()
|
||||
newStyleName = oDialog.model.Tag
|
||||
If newStyleName="0" or newStyleName="" Then
|
||||
Exit sub
|
||||
EndIf
|
||||
foundIndex = getIndex(displayParaStyleNames, newStyleName)
|
||||
'set style system name instead of display name
|
||||
newStyleName = paraStyleNames(foundIndex)
|
||||
|
||||
If newStyleName = oldStyleName Then
|
||||
MsgBox "Стили не различаются"
|
||||
Exit sub
|
||||
EndIf
|
||||
If oldStyleName <> "" Then
|
||||
oldStyle = paraStyles.getByName(oldStyleName)
|
||||
oldStyle.ParentStyle = newStyleName
|
||||
paraStyles.removeByName(oldStyleName)
|
||||
EndIf
|
||||
oTextCursor = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||
enum1 = oTextCursor.createEnumeration()
|
||||
While enum1.hasMoreElements
|
||||
enum1Element = enum1.nextElement
|
||||
If enum1Element.supportsService("com.sun.star.text.Paragraph") Then
|
||||
If enum1Element.ParaStyleName <> newStyleName Then
|
||||
oldStyle = paraStyles.getByName(enum1Element.ParaStyleName)
|
||||
oldStyle.ParentStyle = newStyleName
|
||||
paraStyles.removeByName(enum1Element.ParaStyleName)
|
||||
EndIf
|
||||
EndIf
|
||||
Wend
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
function getIndex(a, v)
|
||||
id = 0
|
||||
nRight = uBound(a)
|
||||
nLen = len(v)
|
||||
while id <= nRight
|
||||
if a(id) = v then
|
||||
getIndex = id
|
||||
exit Function
|
||||
Else
|
||||
id = id + 1
|
||||
end if
|
||||
wend
|
||||
getIndex = -1
|
||||
end function
|
||||
|
||||
sub subShellSort(mArray)
|
||||
|
||||
dim n as integer, h as integer, i as integer, j as integer, t as string, Ub as integer, LB as Integer
|
||||
Lb = lBound(mArray)
|
||||
Ub = uBound(mArray)
|
||||
|
||||
' compute largest increment
|
||||
n = Ub - Lb + 1
|
||||
h = 1
|
||||
if n > 14 then
|
||||
do while h < n
|
||||
h = 3 * h + 1
|
||||
loop
|
||||
h = h \ 3
|
||||
h = h \ 3
|
||||
end if
|
||||
do while h > 0
|
||||
for i = Lb + h to Ub
|
||||
t = mArray(i)
|
||||
for j = i - h to Lb step -h
|
||||
if strComp(mArray(j), t, 0) < 1 then exit for
|
||||
mArray(j + h) = mArray(j)
|
||||
next j
|
||||
mArray(j + h) = t
|
||||
next i
|
||||
h = h \ 3
|
||||
loop
|
||||
end sub
|
||||
</script:module>
|
Loading…
Add table
Add a link
Reference in a new issue