Code cleaning
This commit is contained in:
parent
2d4407b269
commit
52a5b70bbf
3 changed files with 44 additions and 21 deletions
|
@ -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.2.4" />
|
<version value="0.2.5" />
|
||||||
<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="Album" script:language="StarBasic" script:moduleType="normal">Sub albumMark2
|
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Album" script:language="StarBasic" script:moduleType="normal">Sub albumMark3
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub rotatePageButton
|
Sub rotatePageButton
|
||||||
|
@ -27,11 +27,9 @@ Sub makePageAlbum
|
||||||
Exit Sub
|
Exit Sub
|
||||||
EndIf
|
EndIf
|
||||||
rotatePageClockwise(curPageStyleName)
|
rotatePageClockwise(curPageStyleName)
|
||||||
'saveAndreload()
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub findBestAnchor()
|
Sub findBestAnchor()
|
||||||
'Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
|
|
||||||
Dim curPageStyleName As String
|
Dim curPageStyleName As String
|
||||||
Dim oViewCursor As Object
|
Dim oViewCursor As Object
|
||||||
Dim oTextCursor As Object
|
Dim oTextCursor As Object
|
||||||
|
@ -55,12 +53,11 @@ Sub undoPageAlbum
|
||||||
applyPortraitPageStyle(curPageStyleName)
|
applyPortraitPageStyle(curPageStyleName)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
sub applyPortraitPageStyle(pageStyleName)
|
sub applyPortraitPageStyle(pageStyleName As String)
|
||||||
Dim pageStyles As Object
|
Dim pageStyles As Object
|
||||||
Dim pageStyle As Object
|
Dim pageStyle As Object
|
||||||
Dim oViewCursor As Object
|
Dim oViewCursor As Object
|
||||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
breakType = oViewCursor.getPropertyValue("BreakType")
|
|
||||||
pageStyles = ThisComponent.StyleFamilies.getByName("PageStyles")
|
pageStyles = ThisComponent.StyleFamilies.getByName("PageStyles")
|
||||||
pageStyle = pageStyles.getByName(pageStyleName)
|
pageStyle = pageStyles.getByName(pageStyleName)
|
||||||
If NOT pageStyle.IsLandScape Then
|
If NOT pageStyle.IsLandScape Then
|
||||||
|
@ -68,20 +65,20 @@ sub applyPortraitPageStyle(pageStyleName)
|
||||||
Exit sub
|
Exit sub
|
||||||
EndIf
|
EndIf
|
||||||
If pageStyles.hasByName("portrait_" & pageStyleName) Then
|
If pageStyles.hasByName("portrait_" & pageStyleName) Then
|
||||||
|
|
||||||
replacePageStyleByPortrait(pageStyleName)
|
replacePageStyleByPortrait(pageStyleName)
|
||||||
removeAlbumFrames(pageStyleName)
|
removeAlbumFrames(pageStyleName)
|
||||||
' Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
|
|
||||||
Else
|
Else
|
||||||
MsgBox "Стиль страницы с портретной ориентацией portrait_" & pageStyleName & " не был найден. "
|
MsgBox "Стиль страницы с портретной ориентацией portrait_" & pageStyleName & " не был найден. "
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub replacePageStyleByPortrait(pageStyleName)
|
Sub replacePageStyleByPortrait(pageStyleName As String)
|
||||||
Dim pageStyles As Object
|
Dim pageStyles As Object
|
||||||
Dim pageStyle As Object
|
Dim pageStyle As Object
|
||||||
Dim oldPageStyle As Object
|
Dim oldPageStyle As Object
|
||||||
|
Dim textEnumeration As Object
|
||||||
|
Dim enumerationElement As Object
|
||||||
pageStyles = ThisComponent.StyleFamilies.getByName("PageStyles")
|
pageStyles = ThisComponent.StyleFamilies.getByName("PageStyles")
|
||||||
oldPageStyle = pageStyles.getByName(pageStyleName)
|
oldPageStyle = pageStyles.getByName(pageStyleName)
|
||||||
For i = 0 To pageStyles.getCount() - 1
|
For i = 0 To pageStyles.getCount() - 1
|
||||||
|
@ -115,7 +112,7 @@ Sub replacePageStyleByPortrait(pageStyleName)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
Sub removeAlbumFrames(pageStyleName)
|
Sub removeAlbumFrames(pageStyleName As String)
|
||||||
Dim drawPagesEnum As Object
|
Dim drawPagesEnum As Object
|
||||||
Dim drawPage As Object
|
Dim drawPage As Object
|
||||||
drawPagesEnum = ThisComponent.DrawPage.CreateEnumeration()
|
drawPagesEnum = ThisComponent.DrawPage.CreateEnumeration()
|
||||||
|
@ -127,7 +124,7 @@ Sub removeAlbumFrames(pageStyleName)
|
||||||
Wend
|
Wend
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
sub savePortraitPageStyle(pageStyleName)
|
sub savePortraitPageStyle(pageStyleName As String)
|
||||||
createPageStyleByExample("portrait_" & pageStyleName)
|
createPageStyleByExample("portrait_" & pageStyleName)
|
||||||
hidePageStyle("portrait_" & pageStyleName)
|
hidePageStyle("portrait_" & pageStyleName)
|
||||||
End Sub
|
End Sub
|
||||||
|
@ -141,12 +138,23 @@ Sub hidePageStyle(pageStyleName As String)
|
||||||
pageStyle.Hidden = true
|
pageStyle.Hidden = true
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub rotatePageClockwise(pageStyleName)
|
Sub rotatePageClockwise(pageStyleName As String)
|
||||||
Dim pageStyles As Object
|
Dim pageStyles As Object
|
||||||
Dim pageStyle As Object
|
Dim pageStyle As Object
|
||||||
Dim tmpDimension As Long
|
Dim tmpDimension As Long
|
||||||
Dim frame As Object
|
Dim frame As Object
|
||||||
Dim frameName As String
|
Dim frameName As String
|
||||||
|
Dim oViewCursor As Object
|
||||||
|
Dim pageNumber As Long
|
||||||
|
Dim headerFrameW As Long
|
||||||
|
Dim headerFrameH As Long
|
||||||
|
Dim headerFrameYOffset As Long
|
||||||
|
Dim headerFrameXOffset As Long
|
||||||
|
Dim footerFrameW As Long
|
||||||
|
Dim footerFrameH As Long
|
||||||
|
Dim footerFrameYOffset As Long
|
||||||
|
Dim footerFrameXOffset As Long
|
||||||
|
Dim textElement As Object
|
||||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
pageNumber = oViewCursor.getPage()
|
pageNumber = oViewCursor.getPage()
|
||||||
pageStyles = ThisComponent.StyleFamilies.getByName("PageStyles")
|
pageStyles = ThisComponent.StyleFamilies.getByName("PageStyles")
|
||||||
|
@ -241,8 +249,11 @@ Sub rotatePageOrientation(pageStyle)
|
||||||
pageStyle.IsLandscape = Not pageStyle.IsLandscape
|
pageStyle.IsLandscape = Not pageStyle.IsLandscape
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Function checkPageSettings(pageStyleName)
|
Function checkPageSettings(pageStyleName As String) As Boolean
|
||||||
|
Dim pageStyles As Object
|
||||||
|
Dim pageStyle As Object
|
||||||
checkPageSettings = false
|
checkPageSettings = false
|
||||||
|
|
||||||
pageStyles = ThisComponent.StyleFamilies.getByName("PageStyles")
|
pageStyles = ThisComponent.StyleFamilies.getByName("PageStyles")
|
||||||
pageStyle = pageStyles.getByName(pageStyleName)
|
pageStyle = pageStyles.getByName(pageStyleName)
|
||||||
If pageStyle.HeaderIsOn Then
|
If pageStyle.HeaderIsOn Then
|
||||||
|
@ -278,7 +289,17 @@ Function checkPageSettings(pageStyleName)
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
|
||||||
Sub copyTextToFrame(textElement,frameXOffset,frameYOffset,frameW,frameH,frameName)
|
Sub copyTextToFrame(textElement As Object,frameXOffset As Long,frameYOffset As Long,frameW As Long,frameH As Long,frameName As String)
|
||||||
|
Dim oViewCursor As Object
|
||||||
|
Dim initialCursorPosition As Object
|
||||||
|
Dim frame As Object
|
||||||
|
Dim enumeration As Object
|
||||||
|
Dim firstElement As Boolean
|
||||||
|
Dim element As Object
|
||||||
|
Dim cellNames() As String
|
||||||
|
Dim firstCellAnchor As Object
|
||||||
|
Dim lastCellAnchor As Object
|
||||||
|
|
||||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
initialCursorPosition = oViewCursor.Text.createTextCursorByRange(oViewCursor.End)
|
initialCursorPosition = oViewCursor.Text.createTextCursorByRange(oViewCursor.End)
|
||||||
frame = createFrame(frameXOffset,frameYOffset,frameW,frameH,frameName)
|
frame = createFrame(frameXOffset,frameYOffset,frameW,frameH,frameName)
|
||||||
|
@ -310,20 +331,19 @@ Sub copyTextToFrame(textElement,frameXOffset,frameYOffset,frameW,frameH,frameNam
|
||||||
oViewCursor.goToRange(initialCursorPosition,false)
|
oViewCursor.goToRange(initialCursorPosition,false)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub removePageHeader(pageStyle)
|
Sub removePageHeader(pageStyle As Object)
|
||||||
pageStyle.headerIsOn = false
|
pageStyle.headerIsOn = false
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub removePageFooter(pageStyle)
|
Sub removePageFooter(pageStyle As Object)
|
||||||
pageStyle.FooterIsOn = false
|
pageStyle.FooterIsOn = false
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Function getCurPageStyleName()
|
Function getCurPageStyleName() As String
|
||||||
dim curPageStyleName as String
|
dim curPageStyleName as String
|
||||||
dim oViewCursor as Object
|
dim oViewCursor as Object
|
||||||
dim oTextCursor as Object
|
dim oTextCursor as Object
|
||||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
'Mri oViewCursor
|
|
||||||
If Not oViewCursor.isAtEndOfLine() And Not oViewCursor.isAtStartOfLine() Then
|
If Not oViewCursor.isAtEndOfLine() And Not oViewCursor.isAtStartOfLine() Then
|
||||||
oViewCursor.goToStartOfLine(false)
|
oViewCursor.goToStartOfLine(false)
|
||||||
EndIf
|
EndIf
|
||||||
|
@ -363,10 +383,12 @@ sub unoPaste
|
||||||
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
|
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
|
||||||
end sub
|
end sub
|
||||||
|
|
||||||
Function createFrame(posX,posY,width,height,frameName)
|
Function createFrame(posX As Long,posY As Long,width As Long,height As Long,frameName As String) As Object
|
||||||
Dim oViewCursor as Object
|
Dim oViewCursor as Object
|
||||||
Dim oTextCursor as Object
|
Dim oTextCursor as Object
|
||||||
Dim oText As Object
|
Dim oText As Object
|
||||||
|
Dim frame As Object
|
||||||
|
Dim border As Object
|
||||||
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
oText = oViewCursor.Text
|
oText = oViewCursor.Text
|
||||||
oTextCursor = oText.createTextCursorByRange(oViewCursor.End)
|
oTextCursor = oText.createTextCursorByRange(oViewCursor.End)
|
||||||
|
|
|
@ -45,7 +45,7 @@ Private sub disableAutoHyph()
|
||||||
Next
|
Next
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub convertHyphInText(textElement)
|
Private Sub convertHyphInText(textElement As Object)
|
||||||
Dim enum1Element As Object
|
Dim enum1Element As Object
|
||||||
Dim enum1 As Object
|
Dim enum1 As Object
|
||||||
Dim i As Integer
|
Dim i As Integer
|
||||||
|
@ -422,4 +422,5 @@ End Function
|
||||||
|
|
||||||
Sub Macro1
|
Sub Macro1
|
||||||
|
|
||||||
End Sub</script:module>
|
End Sub
|
||||||
|
</script:module>
|
Loading…
Add table
Reference in a new issue