From e72ccdda16e92141448655893430c7e10f782211 Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Fri, 8 May 2020 16:35:26 +0200 Subject: [PATCH] Fixes --- ePublishing/Album.xba | 2 +- ePublishing/Archive.xba | 12 ++++-- ePublishing/Books.xba | 84 ++++++++++++++++++++++++++++++++++++ ePublishing/Hyphenations.xba | 24 ++++++++--- 4 files changed, 110 insertions(+), 12 deletions(-) diff --git a/ePublishing/Album.xba b/ePublishing/Album.xba index 364a6e5..b79c022 100644 --- a/ePublishing/Album.xba +++ b/ePublishing/Album.xba @@ -1,6 +1,6 @@ -Sub albumMark3 +Sub albumMark4 End Sub Sub rotatePageButton diff --git a/ePublishing/Archive.xba b/ePublishing/Archive.xba index 641e2c7..55e4b61 100644 --- a/ePublishing/Archive.xba +++ b/ePublishing/Archive.xba @@ -128,8 +128,11 @@ sub convertIndesignPageBreaks If NOT confirm(description) Then Exit Sub EndIf + Dim document As Object document = ThisComponent.CurrentController.Frame + Dim dispatcher As Object dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") + Dim oViewCursor As Object oViewCursor = thisComponent.getCurrentController.getViewCursor oViewCursor.jumpToFirstPage Dim args(0) as new com.sun.star.beans.PropertyValue @@ -139,12 +142,12 @@ sub convertIndesignPageBreaks args(0).Value = false dispatcher.executeDispatch(document, ".uno:TrackChanges", "", 0, args()) - Dim oSearch - Dim oTextCursor - Dim lineIndent + Dim oSearch As Object + Dim oTextCursor As Object Dim firstLowercase As Boolean Dim charNum As Long Dim character As String + Dim oFound As Object firstLowercase = false oSearch = ThisComponent.createSearchDescriptor() @@ -202,7 +205,8 @@ Sub adjustFirstLine(oTextCursor) End Sub -Function isLowerCase(character) +Function isLowerCase(character) As Boolean + Dim charNum As Integer If (character = "") Then charNum = ASC(""+0) Else diff --git a/ePublishing/Books.xba b/ePublishing/Books.xba index 8925e2c..587fbf2 100644 --- a/ePublishing/Books.xba +++ b/ePublishing/Books.xba @@ -2,6 +2,67 @@ Sub markBooks3 End Sub + +Sub makeUniquePages + Dim pageStyleBreaks As Variant + pageStyleBreaks = getPageStyleBreaks() + Dim pageCount As Integer + Dim i As Integer + 'Globalscope.BasicLibraries.LoadLibrary( "MRILib" ) + pageCount = thiscomponent.currentController.pageCount + Dim styleNames(pageCount - 1) As String + For i = 0 To pageCount - 1 + If i = 0 Then + + EndIf + Next i + +End Sub + + +Function getPageStyleBreaks() + + Dim enum1 As Object + Dim enum1Element As Object + Dim pageStyleName As String + Dim pageNumber As Integer + Dim pageName As String + Dim oViewCursor As Object + Dim anchor As Object + Dim oSavePosition As Object + Dim pageStyleBreaks(1) As Variant + Dim pageStyleNames() As String + Dim pageNumbers() As Integer + oViewCursor = ThisComponent.CurrentController.getViewCursor() + + enum1 = ThisComponent.Text.createEnumeration() + Dim i As Integer + i = 0 + Dim first As Boolean + first = true + While enum1.hasMoreElements + enum1Element = enum1.nextElement + If enum1Element.supportsService("com.sun.star.text.Paragraph") OR enum1Element.supportsService("com.sun.star.text.TextTable") Then + If enum1Element.BreakType = com.sun.star.style.BreakType.PAGE_BEFORE AND NOT IsMissing(enum1Element.PageDescName) AND NOT IsNull(enum1Element.PageDescName) AND NOT IsEmpty(enum1Element.PageDescName) Then + pageStyleName = enum1Element.PageStyleName + addToArray(pageStyleNames(),pageStyleName) + oViewCursor.goToRange(enum1Element.Anchor,false) + addToArray(pageNumbers(),CInt(oViewCursor.Page)) + first = false + ElseIf first Then + addToArray(pageStyleNames(), enum1Element.PageStyleName) + addToArray(pageNumbers(),1) + first = false + EndIf + + EndIf + i = i + 1 + Wend + pageStyleBreaks(0) = pageStyleNames + pageStyleBreaks(1) = pageNumbers + getPageStyleBreaks = pageStyleBreaks +End Function + Sub setUniqPageStyles Dim prevPageName As String Dim firstPageName As String @@ -123,4 +184,27 @@ Function findFirstPageNumberWithStyle(pageStyleName) Wend findFirstPageNumberWithStyle = -1 End Function + + +sub testStyleCopy +rem ---------------------------------------------------------------------- +rem define variables +dim document as object +dim dispatcher as object +rem ---------------------------------------------------------------------- +rem get access to the document +document = ThisComponent.CurrentController.Frame +dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") + +rem ---------------------------------------------------------------------- +dim args1(1) as new com.sun.star.beans.PropertyValue +args1(0).Name = "Param" +args1(0).Value = "alb2" +args1(1).Name = "Family" +args1(1).Value = 8 + +dispatcher.executeDispatch(document, ".uno:StyleNewByExample", "", 0, args1()) + + +end sub \ No newline at end of file diff --git a/ePublishing/Hyphenations.xba b/ePublishing/Hyphenations.xba index ff3f3a4..0a82614 100644 --- a/ePublishing/Hyphenations.xba +++ b/ePublishing/Hyphenations.xba @@ -33,6 +33,11 @@ End Sub Private sub disableAutoHyph() Dim propertySetInfo As Object Dim oPositionOfMatch As Long + Dim oFamilies As Object + Dim sElements() As String + Dim oFamily As Object + Dim oStyle As Object + Dim j As Integer oFamilies = ThisComponent.StyleFamilies sElements() = oFamilies.getElementNames() oFamily = oFamilies.getByName(sElements(1)) @@ -50,6 +55,8 @@ Private Sub convertHyphInText(textElement As Object) Dim enum1 As Object Dim i As Integer Dim cell As Object + Dim cellNames() As Object + Dim cellText As Object enum1 = textElement.createEnumeration() While enum1.hasMoreElements enum1Element = enum1.nextElement @@ -67,7 +74,7 @@ Private Sub convertHyphInText(textElement As Object) Wend End Sub -Private Sub convertParaHyphens(para) +Private Sub convertParaHyphens(para As Object) Dim lineEnds() As Object Dim autoHyphens() As Object Dim autoBreaks() As Object @@ -75,10 +82,13 @@ Private Sub convertParaHyphens(para) ' Dim lineShifts() As Integer Dim charNum as Integer Dim lineLength As Integer + Dim lineCursor As Object Dim i As Integer Dim vCurs As Object Dim tCurs As Object Dim lineCurs As Object + Dim lastChar As String + Dim nextChar As String 'No hyphenation needed If para.ParaIsHyphenation = false Then Exit Sub @@ -170,13 +180,13 @@ Private Sub insertBreak(tCursor As Object) tCursor.String = "​" End Sub -Private Function getPrevChar(tCurs As Object) +Private Function getPrevChar(tCurs As Object) As String tCurs.goLeft(1,true) getPrevChar = tCurs.getString() tCurs.goRight(1,false) End Function -Private Function getNextChar(tCurs As Object) +Private Function getNextChar(tCurs As Object) As String tCurs.goRight(1,true) getNextChar = tCurs.getString() tCurs.goLeft(1,false) @@ -291,7 +301,7 @@ Private Sub stretchLine(tCurs As Object) End Sub -Private Function getParaLineNumber(vCursor As Object) +Private Function getParaLineNumber(vCursor As Object) As Integer Dim lineNumber As Integer Dim oSavePosition As Object Dim tCursor As Object @@ -325,9 +335,9 @@ End Sub -Private Function needHyphen(before As String, after As String,lineLength As Integer) -Dim charNumBefore as Integer -Dim charNumAfter as Integer +Private Function needHyphen(before As String, after As String,lineLength As Integer) As boolean + Dim charNumBefore as Integer + Dim charNumAfter as Integer needHyphen = true If lineLength < 2 Then needHyphen = false