Books lib added
This commit is contained in:
parent
acad3ba493
commit
62fafde775
1 changed files with 126 additions and 0 deletions
126
ePublishing/Books.xba
Normal file
126
ePublishing/Books.xba
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
<?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="Books" script:language="StarBasic" script:moduleType="normal">Sub markBooks3
|
||||||
|
End Sub
|
||||||
|
Sub setUniqPageStyles
|
||||||
|
Dim prevPageName As String
|
||||||
|
Dim firstPageName As String
|
||||||
|
Dim pageName As String
|
||||||
|
Dim curPageNum As Integer
|
||||||
|
Dim prevPageNum As String
|
||||||
|
Dim leftPageNum As Long
|
||||||
|
Dim docPages As Long
|
||||||
|
Dim articlePages As Long
|
||||||
|
Dim previousPageStyle As Object
|
||||||
|
Dim pageStyles As Object
|
||||||
|
Dim curPageStyle As Object
|
||||||
|
Dim curPageStyleName As String
|
||||||
|
Dim nextStyle As Object
|
||||||
|
Dim clonedStyle As Object
|
||||||
|
Dim clonedStyleName As String
|
||||||
|
Dim oViewCursor As Object
|
||||||
|
Dim pageNum As Integer
|
||||||
|
Dim page As Integer
|
||||||
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
|
pageStyles = ThisComponent.StyleFamilies.getByName("PageStyles")
|
||||||
|
pageNum = 1
|
||||||
|
pageName = "Страница издания"
|
||||||
|
|
||||||
|
If NOT hasPageStyleWith(pageName) Then
|
||||||
|
MsgBox "Ошибка. Стиль страниц <" & pageName & "> не найден."
|
||||||
|
Exit Sub
|
||||||
|
EndIf
|
||||||
|
page = findFirstPageNumberWithStyle(pageName)
|
||||||
|
firstPage = page
|
||||||
|
oViewCursor.jumpToPage(page)
|
||||||
|
curPageStyleName = oViewCursor.PageStyleName
|
||||||
|
Do While StrComp(curPageStyleName,pageName,1) = 0
|
||||||
|
If pageNum = 1 Then
|
||||||
|
oViewCursor.jumpToPreviousPage()
|
||||||
|
prevPageName = oViewCursor.PageStyleName
|
||||||
|
previousPageStyle = pageStyles.getByName(prevPageName)
|
||||||
|
tmpName = pageName + " "
|
||||||
|
If InStr(prevPageName, tmpName) = 1 Then
|
||||||
|
startNum = Right(prevPageName,Len(prevPageName) - Len(tmpName))
|
||||||
|
pageNum = CInt(startNum) + 1
|
||||||
|
EndIf
|
||||||
|
oViewCursor.jumpToNextPage()
|
||||||
|
EndIf
|
||||||
|
newPageName = pageName + " " + pageNum
|
||||||
|
|
||||||
|
createPageStyleByExample(newPageName)
|
||||||
|
If pageNum = 1 Then
|
||||||
|
oTextCursor = oViewCursor.Text.CreateTextCursorByRange(oViewCursor)
|
||||||
|
oViewCursor.PageDescName = newPageName
|
||||||
|
|
||||||
|
Else
|
||||||
|
previousPageStyle.FollowStyle = newPageName
|
||||||
|
EndIf
|
||||||
|
|
||||||
|
curPageStyle = pageStyles.getByName(newPageName)
|
||||||
|
'Установим стиль следующей страницы в стандартное значение
|
||||||
|
curPageStyle.FollowStyle = pageName
|
||||||
|
previousPageStyle = curPageStyle
|
||||||
|
oViewCursor.jumpToNextPage()
|
||||||
|
curPageStyleName = getNextPageStyleName()
|
||||||
|
pageNum = pageNum + 1
|
||||||
|
Loop
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Function hasPageStyleWith(pageStyleName)
|
||||||
|
Dim enum1 As Object
|
||||||
|
Dim enum1Element As Object
|
||||||
|
Dim curPage As String
|
||||||
|
Dim curStyleName As String
|
||||||
|
Dim pageName As String
|
||||||
|
Dim oViewCursor As Object
|
||||||
|
Dim anchor As Object
|
||||||
|
enum1 = ThisComponent.Text.createEnumeration()
|
||||||
|
While enum1.hasMoreElements
|
||||||
|
enum1Element = enum1.nextElement
|
||||||
|
If enum1Element.supportsService("com.sun.star.text.Paragraph") OR enum1Element.supportsService("com.sun.star.text.TextTable") Then
|
||||||
|
If NOT IsMissing(enum1Element.PageDescName) AND NOT IsNull(enum1Element.PageDescName) Then
|
||||||
|
pageName = CStr(enum1Element.PageDescName)
|
||||||
|
If pageStyleName = pageName Then
|
||||||
|
hasPageStyleWith = true
|
||||||
|
Exit Function
|
||||||
|
EndIf
|
||||||
|
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
Wend
|
||||||
|
hasPageStyleWith = false
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Function findFirstPageNumberWithStyle(pageStyleName)
|
||||||
|
Dim enum1 As Object
|
||||||
|
Dim enum1Element As Object
|
||||||
|
Dim curPage As String
|
||||||
|
Dim curStyleName As String
|
||||||
|
Dim pageName As String
|
||||||
|
Dim oViewCursor As Object
|
||||||
|
Dim anchor As Object
|
||||||
|
Dim oSavePosition As Object
|
||||||
|
oViewCursor = ThisComponent.CurrentController.getViewCursor()
|
||||||
|
oSavePosition = oViewCursor.Text.createTextCursorByRange(oViewCursor)
|
||||||
|
enum1 = ThisComponent.Text.createEnumeration()
|
||||||
|
While enum1.hasMoreElements
|
||||||
|
enum1Element = enum1.nextElement
|
||||||
|
If enum1Element.supportsService("com.sun.star.text.Paragraph") OR enum1Element.supportsService("com.sun.star.text.TextTable") Then
|
||||||
|
If NOT IsMissing(enum1Element.PageDescName) AND NOT IsNull(enum1Element.PageDescName) Then
|
||||||
|
pageName = CStr(enum1Element.PageDescName)
|
||||||
|
If pageStyleName = pageName Then
|
||||||
|
anchor = enum1Element.getAnchor()
|
||||||
|
oViewCursor.gotoRange(anchor,false)
|
||||||
|
findFirstPageNumberWithStyle = oViewCursor.getPage()
|
||||||
|
oViewCursor.goToRange(oSavePosition, false)
|
||||||
|
Exit Function
|
||||||
|
EndIf
|
||||||
|
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
Wend
|
||||||
|
findFirstPageNumberWithStyle = -1
|
||||||
|
End Function
|
||||||
|
</script:module>
|
Loading…
Add table
Reference in a new issue