diff --git a/Addons.xcu b/Addons.xcu index d9f7e03..c10a28a 100644 --- a/Addons.xcu +++ b/Addons.xcu @@ -18,7 +18,7 @@ - ePublishing.journals.makeUpIssue + macro:///ePublishing.journals.makeUpIssue _self @@ -31,7 +31,7 @@ - com.example.addon1:Command1 + macro:///ePublishing.journals.setPageNumbers diff --git a/ePublishing/journals.xba b/ePublishing/journals.xba index 5ed129a..f7bb089 100644 --- a/ePublishing/journals.xba +++ b/ePublishing/journals.xba @@ -1,7 +1,7 @@ -' Globalscope.BasicLibraries.LoadLibrary( "MRILib" ) -' Mri curStyle +Private sub journalsMark1 +End sub Dim templateName As String Dim EIFN As String @@ -12,7 +12,7 @@ Dim allImagesRelativePath As String Dim path As String Dim sectionName As String -Sub makeUpIssue +Private Sub makeUpIssue turnOffTracking Dim description As String description = "Вы уверены, что хотите запустить сборку выпуска ?" @@ -141,12 +141,12 @@ Sub makeUpIssue statusIndicator.end() End Sub -Sub setPageNumbers() +Private Sub setPageNumbers() updateLastPageFields() End Sub -Sub setPageNumbersDeprecated() +Private Sub setPageNumbersDeprecated() Dim oVeiwCursor As Object Dim pageNum as Integer Dim firstPage as String @@ -165,14 +165,14 @@ Sub setPageNumbersDeprecated() End Sub -Sub setAtricleVars(i) +Private Sub setAtricleVars(i) 'updateUserField("article" + i + "LastPage", CStr(getArticleLastPage()) ) updateUserField("article" + i + "UDK", getUDK()) updateUserField("author" + i + "Copyright", getCopyright() ) 'updateUserField("rightHeader" + i , getTitleHeader() ) End Sub -Function lastPageNum(i) +Private Function lastPageNum(i) Dim docLastPage As Integer Dim curPageNum As Integer Dim oViewCursor As Object @@ -210,7 +210,7 @@ Function lastPageNum(i) lastPageNum = curPageNum End Function -Function getUDK() +Private Function getUDK() 'Globalscope.BasicLibraries.LoadLibrary( "MRILib" ) Dim oViewCursor As Object Dim oSavePosition As Object @@ -231,7 +231,7 @@ Function getUDK() oViewCursor.goToRange(oSavePosition, false) End Function -Function getCopyright() +Private Function getCopyright() Dim oViewCursor As Object Dim oSavePosition As Object Dim authors As String @@ -268,7 +268,7 @@ Function getCopyright() oViewCursor.goToRange(oSavePosition, false) End Function -Function getAuthor() +Private Function getAuthor() Dim oViewCursor As Object Dim oSavePosition As Object Dim authors As String @@ -284,7 +284,7 @@ Function getAuthor() oViewCursor.goToRange(oSavePosition, false) End Function -Function getArticleHeader() +Private Function getArticleHeader() Dim oViewCursor As Object Dim oSavePosition As Object Dim authors As String @@ -300,7 +300,7 @@ Function getArticleHeader() oViewCursor.goToRange(oSavePosition, false) End Function -Function getSectionX(section) +Private Function getSectionX(section) Dim oViewCursor As Object Dim oSavePosition As Object Dim startPage As String @@ -323,7 +323,7 @@ Function getSectionX(section) oViewCursor.goToRange(oSavePosition, false) End Function -Function getTitleHeader() +Private Function getTitleHeader() Dim oViewCursor As Object Dim oSavePosition As Object Dim title As String @@ -340,7 +340,7 @@ End Function -Sub setArticlePageStyles(i) +Private Sub setArticlePageStyles(i) Dim oViewCursor As Object Dim oTextCursor As Object Dim oText As Object @@ -386,7 +386,7 @@ Sub setArticlePageStyles(i) End Sub -Sub setFirstPageMetadata(curStyle,i) +Private Sub setFirstPageMetadata(curStyle,i) Dim oViewCursor As Object Dim oSavePosition As Object Dim savePageName As String @@ -413,7 +413,7 @@ Sub setFirstPageMetadata(curStyle,i) sendRM() End Sub -Sub setDefaultFirstPageMetadata(curStyle,i) +Private Sub setDefaultFirstPageMetadata(curStyle,i) Dim oViewCursor As Object Dim oHeaderTable As Object Dim oFooterTable As Object @@ -452,7 +452,7 @@ Sub setDefaultFirstPageMetadata(curStyle,i) End Sub -Sub setPHAFirstPageMetadata(curStyle,i) +Private Sub setPHAFirstPageMetadata(curStyle,i) Dim oViewCursor As Object Dim oHeader As Object Dim oFooterTable As Object @@ -483,7 +483,7 @@ Sub setPHAFirstPageMetadata(curStyle,i) End Sub -Sub setEIFNFirstPageMetadata(curStyle,i) +Private Sub setEIFNFirstPageMetadata(curStyle,i) Dim oViewCursor As Object Dim oHeaderTable As Object Dim oFooterTable As Object @@ -530,7 +530,7 @@ Sub setEIFNFirstPageMetadata(curStyle,i) End Sub -Sub setAritclePageHeaders(i) +Private Sub setAritclePageHeaders(i) Dim oViewCursor As Object Dim oSavePosition As Object Dim rightHeaderTable As Object @@ -612,7 +612,7 @@ Sub setAritclePageHeaders(i) End Sub -Sub setArticleUniqPageStyles(i) +Private Sub setArticleUniqPageStyles(i) Dim firstPageName As String Dim pageName As String Dim curPageNum As Integer @@ -667,7 +667,7 @@ Sub setArticleUniqPageStyles(i) End Sub -Sub takeWidowLinesIn +Private Sub takeWidowLinesIn Dim oViewCursor As Object oViewCursor = ThisComponent.CurrentController.getViewCursor() curPageStyleName = getNextPageStyleName() @@ -678,7 +678,7 @@ Sub takeWidowLinesIn Loop End Sub -Sub takeDownOrpahns +Private Sub takeDownOrpahns Dim oViewCursor As Object oViewCursor = ThisComponent.CurrentController.getViewCursor() curPageStyleName = getNextPageStyleName() @@ -689,7 +689,7 @@ Sub takeDownOrpahns Loop End Sub -Sub takeLineIn +Private Sub takeLineIn Globalscope.BasicLibraries.LoadLibrary( "Publishing" ) Dim oViewCursor As Object Dim oTextCursor As Object @@ -751,7 +751,7 @@ Sub takeLineIn End If End Sub -Function getNextPageStyleName() +Private Function getNextPageStyleName() dim curPageStyleName as String dim startPageStyleName as String dim startPageStyle as Object @@ -778,33 +778,33 @@ Function getNextPageStyleName() backspace() End Function -Function findArticleFile(path,i) -Dim NextFile As String -Dim TestName As String -Dim endChars(2) As String -endChars(0) = "_" -endChars(1) = "." -endChars(2) = " " -Dim FoundPosition As Long -Dim EndChar As String -NextFile = Dir(path+"/", 0) - While NextFile <> "" - For j = LBound(endChars) To UBound(endChars) - TestName = CStr(i)+endChars(j) - FoundPosition = InStr(NextFile, TestName) - If FoundPosition = 1 Then - findArticleFile = path+"/"+NextFile - Exit Function - End If - Next - NextFile = Dir - Wend - - -findArticleFile = "" +Private Function findArticleFile(path,i) + Dim NextFile As String + Dim TestName As String + Dim endChars(2) As String + endChars(0) = "_" + endChars(1) = "." + endChars(2) = " " + Dim FoundPosition As Long + Dim EndChar As String + NextFile = Dir(path+"/", 0) + While NextFile <> "" + For j = LBound(endChars) To UBound(endChars) + TestName = CStr(i)+endChars(j) + FoundPosition = InStr(NextFile, TestName) + If FoundPosition = 1 Then + findArticleFile = path+"/"+NextFile + Exit Function + End If + Next + NextFile = Dir + Wend + + + findArticleFile = "" End Function -Function InsertArticle(oFileName) +Private Function InsertArticle(oFileName) Dim document as Object Dim dispatcher as object Dim fileType as String @@ -827,13 +827,13 @@ End Function -Sub getChapter +Private Sub getChapter Dim testText As String testText = getFirstTextInStyle("Заголовок 1") End Sub -Function getFirstTextInStyle(styleName) +Private Function getFirstTextInStyle(styleName) Dim oViewCursor As Object Dim curPage As Long Dim foundPage As Long @@ -848,7 +848,7 @@ Function getFirstTextInStyle(styleName) getFirstTextInStyle = "" End Function -Sub setHeadingsOutlineLevels +Private Sub setHeadingsOutlineLevels setHeadingOutlineLevel(1,"Заголовок 1") setHeadingOutlineLevel(2,"Заголовок 2") @@ -874,7 +874,7 @@ Sub setHeadingOutlineLevel(num,targetStyleName) Wend End Sub -sub getFirstTextInStyleDispatch(styleName) +Private sub getFirstTextInStyleDispatch(styleName) dim document as object dim dispatcher as object document = ThisComponent.CurrentController.Frame @@ -927,38 +927,36 @@ sub getFirstTextInStyleDispatch(styleName) dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args1()) end Sub -sub insertLinkedImage(articleNum,styleName) -rem ---------------------------------------------------------------------- -rem define variables -dim document as object -dim dispatcher as object - -document = ThisComponent.CurrentController.Frame -dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") - -dim args2(3) as new com.sun.star.beans.PropertyValue -args2(0).Name = "FileName" -args2(0).Value = path + imagesRelativePath + articleNum + ".jpg" -args2(1).Name = "FilterName" -args2(1).Value = "<Все форматы>" -args2(2).Name = "AsLink" -args2(2).Value = true -args2(3).Name = "Style" -args2(3).Value = styleName - -dispatcher.executeDispatch(document, ".uno:InsertGraphic", "", 0, args2()) - - +Private sub insertLinkedImage(articleNum,styleName) + rem ---------------------------------------------------------------------- + rem define variables + dim document as object + dim dispatcher as object + + document = ThisComponent.CurrentController.Frame + dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") + + dim args2(3) as new com.sun.star.beans.PropertyValue + args2(0).Name = "FileName" + args2(0).Value = path + imagesRelativePath + articleNum + ".jpg" + args2(1).Name = "FilterName" + args2(1).Value = "<Все форматы>" + args2(2).Name = "AsLink" + args2(2).Value = true + args2(3).Name = "Style" + args2(3).Value = styleName + + dispatcher.executeDispatch(document, ".uno:InsertGraphic", "", 0, args2()) end sub -Sub copySectionIcon(articleNum) +Private Sub copySectionIcon(articleNum) FileCopy( path + allImagesRelativePath + getImageFileName(), path + imagesRelativePath + articleNum + ".jpg") End Sub -Function getImageFileName() +Private Function getImageFileName() Select Case UCase(sectionName) Case "АРХИВ" @@ -984,7 +982,7 @@ Function getImageFileName() End Select End Function -sub noNumbering +Private sub noNumbering rem ---------------------------------------------------------------------- rem define variables dim document as object @@ -1001,7 +999,80 @@ sub noNumbering Wait 500 end sub - +Private Sub updateLastPageFields + Dim enum1Element As Object + Dim enum1 As Object + Dim enum2 As Object + Dim thisPortion As Object + Dim footnoteText As Object + Dim label As String + Dim labelNum As Integer + Dim i As Integer + Dim cell As Object + Dim cellEnum As Object + Dim cellEnum2 As Object + Dim pageStyleName As String + Dim articleName As String + Dim articleNamePrefix As String + Dim articleNamePostfix As String + Dim strPos As Integer + Dim articleNum As Integer + Dim curNum As Integer + Dim pageNum As Integer + Dim textCursor As Object + Dim lastPages%( 100 ) + For i = 0 to 100 + lastPages%(i) = 0 + next i + articleNum = 0 + articleName = "0" + articleNamePrefix = "Статья " + articleNamePostfix = " " + Dim statusIndicator as Object + statusIndicator = ThisComponent.getCurrentController.statusIndicator + statusIndicator.Start("Производится обновление полей последних номеров страниц, подождите",30) + enum1 = ThisComponent.Text.createEnumeration + While enum1.hasMoreElements + enum1Element = enum1.nextElement + If enum1Element.supportsService("com.sun.star.text.Paragraph") Then + pageStyleName = getPageStyleNameFromEnum(enum1Element) + If Len(pageStyleName) > 0 Then + strPos = InStr(pageStyleName, articleNamePrefix) + If strPos <> 0 Then + articleName = Right(pageStyleName, Len(pageStyleName)-Len(articleNamePrefix)) + strPos = InStr(articleName, articleNamePostfix) + If strPos > 0 Then + articleName = Left(articleName,strPos) + EndIf + 'If first article reached + If articleNum = 0 Then + articleNum = CInt(Trim(articleName)) + EndIf + Else + articleName = "0" + EndIf + + If articleNum > 0 Then + curNum = CInt(Trim(articleName)) + If articleNum <> curNum Then + pageNum = getPageNumber(enum1Element.Start) + lastPages(articleNum) = CInt(pageNum) - 1 + articleNum = curNum + EndIf + EndIf + EndIf + + EndIf + 'TODO: + 'OR enum1Element.supportsService("com.sun.star.text.TextTable") + Wend + For i = LBound(lastPages) to UBound(lastPages) + If lastPages%(i) <> 0 Then + updateUserField("article" + i + "LastPage",lastPages%(i)) + EndIf + next i + statusIndicator.end() +End Sub