Added button to replace paragraph style
This commit is contained in:
parent
03789e78c7
commit
1535e54017
5 changed files with 208 additions and 6 deletions
62
Addons.xcu
62
Addons.xcu
|
@ -1,6 +1,68 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addons" oor:package="org.openoffice.Office">
|
<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addons" oor:package="org.openoffice.Office">
|
||||||
<node oor:name="AddonUI">
|
<node oor:name="AddonUI">
|
||||||
|
<node oor:name="OfficeToolBar">
|
||||||
|
<node oor:name="pro.litvinovg.ePublishing.panel" oor:op="replace">
|
||||||
|
<prop oor:name="Title" oor:type="xs:string">
|
||||||
|
<value xml:lang="en-US">ePublishing panel</value>
|
||||||
|
<value xml:lang="ru">Панель ePublishing</value>
|
||||||
|
</prop>
|
||||||
|
<prop oor:name="Docked" oor:op="fuse">
|
||||||
|
<value>true</value>
|
||||||
|
</prop>
|
||||||
|
<prop oor:name="HideFromToolbarMenu" oor:op="fuse"><value>false</value></prop>
|
||||||
|
<prop oor:name="Locked" oor:op="fuse"><value>false</value></prop>
|
||||||
|
<node oor:name="ToolBarItems">
|
||||||
|
<node oor:name="buttonReplaceParaStyle" oor:op="replace">
|
||||||
|
<prop oor:name="Context" oor:type="xs:string">
|
||||||
|
<value>com.sun.star.text.TextDocument,com.sun.star.text.WebDocument</value>
|
||||||
|
</prop>
|
||||||
|
<prop oor:name="Title" oor:type="xs:string">
|
||||||
|
<value xml:lang="en-US">ePublishing panel</value>
|
||||||
|
<value xml:lang="ru">Панель ePublishing</value>
|
||||||
|
</prop>
|
||||||
|
<prop oor:name="URL" oor:type="xs:string">
|
||||||
|
<value>macro:///ePublishing.Archive.replaceParaStyle</value>
|
||||||
|
</prop>
|
||||||
|
<prop oor:name="Target" oor:type="xs:string">
|
||||||
|
<value>_self</value>
|
||||||
|
</prop>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
<node oor:name="buttonReplaceParaStyle" oor:op="replace">
|
||||||
|
<prop oor:name="Context" oor:type="xs:string">
|
||||||
|
<value>com.sun.star.text.TextDocument,com.sun.star.text.WebDocument</value>
|
||||||
|
</prop>
|
||||||
|
<prop oor:name="Title" oor:type="xs:string">
|
||||||
|
<value xml:lang="ru">ЗаменитьСтильПараграфа</value>
|
||||||
|
<value xml:lang="en">ReplaceParaStyle</value>
|
||||||
|
</prop>
|
||||||
|
<prop oor:name="URL" oor:type="xs:string">
|
||||||
|
<value>macro:///ePublishing.Archive.replaceParaStyle</value>
|
||||||
|
</prop>
|
||||||
|
<prop oor:name="Target" oor:type="xs:string">
|
||||||
|
<value>_self</value>
|
||||||
|
</prop>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
<node oor:name="Images">
|
||||||
|
<node oor:name="image-verify-button" oor:op="replace">
|
||||||
|
<prop oor:name="URL" oor:type="xs:string">
|
||||||
|
<value>macro:///ePublishing.Archive.replaceParaStyle</value>
|
||||||
|
</prop>
|
||||||
|
<node oor:name="UserDefinedImages">
|
||||||
|
<prop oor:name="ImageBigURL">
|
||||||
|
<value>%origin%/icons/validate.png</value>
|
||||||
|
</prop>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<node oor:name="OfficeMenuBar">
|
<node oor:name="OfficeMenuBar">
|
||||||
<node oor:name="pro.litvinovg.epublishing.menu" oor:op="replace">
|
<node oor:name="pro.litvinovg.epublishing.menu" oor:op="replace">
|
||||||
<prop oor:name="Context" oor:type="xs:string">
|
<prop oor:name="Context" oor:type="xs:string">
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
xmlns:dep="http://openoffice.org/extensions/description/2006"
|
xmlns:dep="http://openoffice.org/extensions/description/2006"
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
<identifier value="pro.litvinovg.epublishing" />
|
<identifier value="pro.litvinovg.epublishing" />
|
||||||
<version value="0.1.6" />
|
<version value="0.1.7" />
|
||||||
<platform value="all" />
|
<platform value="all" />
|
||||||
<display-name>
|
<display-name>
|
||||||
<name lang="ru">Инструменты для создания электронных изданий</name>
|
<name lang="ru">Инструменты для создания электронных изданий</name>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
|
<!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
|
End Sub
|
||||||
|
|
||||||
|
@ -123,7 +123,11 @@ End Function
|
||||||
|
|
||||||
|
|
||||||
sub convertIndesignPageBreaks
|
sub convertIndesignPageBreaks
|
||||||
|
Dim description As String
|
||||||
|
description = "Запустить восстановление разрывов страниц?"
|
||||||
|
If NOT confirm(description) Then
|
||||||
|
Exit Sub
|
||||||
|
EndIf
|
||||||
document = ThisComponent.CurrentController.Frame
|
document = ThisComponent.CurrentController.Frame
|
||||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||||
oViewCursor = thisComponent.getCurrentController.getViewCursor
|
oViewCursor = thisComponent.getCurrentController.getViewCursor
|
||||||
|
@ -183,7 +187,7 @@ sub convertIndesignPageBreaks
|
||||||
End If
|
End If
|
||||||
oFound = ThisComponent.findNext(oFound.End, oSearch)
|
oFound = ThisComponent.findNext(oFound.End, oSearch)
|
||||||
Loop
|
Loop
|
||||||
|
MsgBox "Восстановление разрывов страниц завершено."
|
||||||
end Sub
|
end Sub
|
||||||
|
|
||||||
Sub adjustLastLine(oTextCursor)
|
Sub adjustLastLine(oTextCursor)
|
||||||
|
@ -297,6 +301,12 @@ End Sub
|
||||||
|
|
||||||
|
|
||||||
Sub convertBookmarksToFootnotes()
|
Sub convertBookmarksToFootnotes()
|
||||||
|
Dim description As String
|
||||||
|
description = "Запустить восстановление сносок из текста?"
|
||||||
|
If NOT confirm(description) Then
|
||||||
|
Exit Sub
|
||||||
|
EndIf
|
||||||
|
|
||||||
Dim bookmarks as Object
|
Dim bookmarks as Object
|
||||||
Dim bookmarkName as String
|
Dim bookmarkName as String
|
||||||
Dim strStart As Integer
|
Dim strStart As Integer
|
||||||
|
@ -331,7 +341,7 @@ Sub convertBookmarksToFootnotes()
|
||||||
Next i
|
Next i
|
||||||
|
|
||||||
resetNotesStyle
|
resetNotesStyle
|
||||||
|
MsgBox "Восстановление сносок завершено."
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub convertLinkToFootnote(forwardLink,backwardLink)
|
Sub convertLinkToFootnote(forwardLink,backwardLink)
|
||||||
|
@ -398,4 +408,124 @@ sub createFootnote
|
||||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||||
dispatcher.executeDispatch(document, ".uno:InsertFootnote", "", 0, Array())
|
dispatcher.executeDispatch(document, ".uno:InsertFootnote", "", 0, Array())
|
||||||
end Sub
|
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>
|
</script:module>
|
|
@ -2,4 +2,5 @@
|
||||||
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
|
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
|
||||||
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="ePublishing" library:readonly="false" library:passwordprotected="false">
|
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="ePublishing" library:readonly="false" library:passwordprotected="false">
|
||||||
<library:element library:name="FootnotesConfig"/>
|
<library:element library:name="FootnotesConfig"/>
|
||||||
|
<library:element library:name="replaceParaStyle"/>
|
||||||
</library:library>
|
</library:library>
|
9
ePublishing/replaceParaStyle.xdl
Normal file
9
ePublishing/replaceParaStyle.xdl
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
|
||||||
|
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="selectMenu" dlg:left="14" dlg:top="7" dlg:width="182" dlg:height="308" dlg:closeable="true" dlg:moveable="true" dlg:title="Дваждый кликните на выбранный элемент">
|
||||||
|
<dlg:bulletinboard>
|
||||||
|
<dlg:menulist dlg:id="ListBox1" dlg:tab-index="0" dlg:left="0" dlg:top="3" dlg:width="181" dlg:height="306">
|
||||||
|
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:ePublishing.Archive.onSelectMenuItem?language=Basic&location=application" script:language="Script"/>
|
||||||
|
</dlg:menulist>
|
||||||
|
</dlg:bulletinboard>
|
||||||
|
</dlg:window>
|
Loading…
Add table
Reference in a new issue