8

I would like to add a progress bar to my traineeship presentation with LibreOffice Impress, but I have only find this type of progress bar, using macro

enter image description here

As you can see, it can be hard to know how many slide there are in this part, how many there are before finishing the presentation, even if I can add the percentage of the progress. This macro can be find at this link :

https://github.com/dasaki/Impress-Progress-Bar

Now, I want something that look like bellow (sorry, GIMP isn't the best picture editer to draw line or square) :

enter image description here

If anyone have a solution or a link to a macro that do something like that, I don't want to do that square/circle progression manually, would be dirty and really some time to work on it. Thanks

2
+50

Well, may be not so sophisticated. I had looked to start by forking that repository but end up, writing from scratch.

Current state, it is working (LibreOffice v6.0.2.1). However, Setting are not presented in GUI.

Setup

  1. Tools > Macros > Organize Macros > LibreOffice Basic...
  2. My Macros > Standard: New module name it "ProgressLine" or whatever.
  3. Select it then Edit, Copy below code into it

    REM  *****  BASIC  *****
    
    Dim iFileNumber As Integer
    Dim iSectionCount As Integer
    Dim iSectionPage As Integer
    Dim iSectionIndex As Integer
    Dim iSectionIndexCurrent As Integer
    
    Dim oDocument As Object
    Dim oPage As Object
    Dim iPageCount As Integer
    Dim oPositionPageMark As New com.sun.star.awt.Point
    Dim oSizePageMark As New com.sun.star.awt.Size
    Dim oSizeSectionTitle As New com.sun.star.awt.Size
    
    
    Sub ProgressLine
    
        'Default values
        'sBulletShape = "com.sun.star.drawing.RectangleShape"
        sBulletShape = "com.sun.star.drawing.EllipseShape"
        'Values are fracture of page width
        oSizePageMark_Width = 0.02
        oSizePageMark_Height = 0.02
        oSizeSectionTitle_Width = 0.20
        oSizeSectionTitle_Height = 0.03
        dSeparationRatioSection = 3.0
        dMargin_Start = 0.05
        dMargin_End = 0.10
        dMargin_Side = 0.03
    
        oFillColorPageMarkActive = RGB(255,0,0)
        oFillColorPageMarkInactive = RGB(240, 200, 200)
        oCharColorSectionTitleActive = RGB(255, 0, 0)
        oCharColorSectionTitleInactive = RGB(150, 150, 150)
    
    
        ProgressLineRemove()
    
        oDocument = ThisComponent
        If oDocument.supportsService("com.sun.star.drawing.GenericDrawingDocument") Then
            'Load index
            sIndexPath = oDocument.URL
            sIndexPath = Mid( Left(sIndexPath, InStr(sIndexPath, ".odp")-1) & ".index",1,Len(sIndexPath)+2)
            iFileNumber = Freefile
            Open sIndexPath For Input As #iFileNumber
            'First line is section total count
            If Not eof(#iFileNumber) Then
                Line Input #iFileNumber, sLine
                If sLine<>"" Then
                    iSectionCount = Int(sLine)
                End If
            End If
            'Remaining lines for sections: page, title
            iPageCount = oDocument.DrawPages.Count
            Dim sSectionTitle(iPageCount) As String
            While Not eof(#iFileNumber)
                Line Input #iFileNumber, sLine
                If sLine<>"" Then
                    iSectionPage = Int(Left(sLine, InStr(sLine, ",")-1))
                    sSectionTitle(iSectionPage-1) = Right(sLine, Len(sLine)-InStr(sLine, ","))
                End If
            Wend
    
            'loop over pages
            iSectionIndex=-1
            For iPageIndex=0 To iPageCount-1
                If sSectionTitle(iPageIndex)<>"" Then
                    iSectionIndex = iSectionIndex+1
                End If
                oPage = oDocument.DrawPages(iPageIndex)
                oSizePageMark.Width = oPage.Width*oSizePageMark_Width
                oSizePageMark.Height = oPage.Width*oSizePageMark_Height
                dSeparation = (oPage.Width*(1-dMargin_Start-dMargin_End)-oSizePageMark.Width*iPageCount)/((iPageCount-iSectionCount)+(iSectionCount-1)*dSeparationRatioSection)
    
    
                'Place new shapes, loop over page for progress
                iSectionIndexCurrent=-1
                For iPageIndexCurrent=0 To iPageCount-1
                    If sSectionTitle(iPageIndexCurrent)<>"" Then
                        iSectionIndexCurrent = iSectionIndexCurrent+1
                    End If
                    oShape = oDocument.createInstance(sBulletShape)
                    oPositionPageMark.x = (iPageIndexCurrent+iSectionIndexCurrent*(dSeparationRatioSection-1))*dSeparation+iPageIndexCurrent*oSizePageMark.Width+oPage.Width*dMargin_Start
                    oPositionPageMark.y = oPage.Height-oPage.Width*dMargin_Side-oSizePageMark.Height
                    oShape.Size = oSizePageMark
                    oShape.Position = oPositionPageMark
                    oShape.LineStyle = none
                    If (iPageIndexCurrent=iPageIndex) Then
                        oShape.FillColor = oFillColorPageMarkActive
                    Else
                        oShape.FillColor = oFillColorPageMarkInactive
                    End If
                    oShape.Name = "Progress Line RS_" + (iPageIndex+1)+"_"+(iPageIndexCurrent+1)
                    oPage.add(oShape)
    
                    'Section titles, skip dummy title: "_"
                    If sSectionTitle(iPageIndexCurrent)<>"" And sSectionTitle(iPageIndexCurrent)<>"_" Then        
                        oShape = oDocument.createInstance("com.sun.star.drawing.RectangleShape")    
                        oShape.TextVerticalAdjust = com.sun.star.drawing.TextVerticalAdjust.TOP
                        oShape.TextHorizontalAdjust = com.sun.star.drawing.TextHorizontalAdjust.LEFT
                        oShape.TextLeftDistance = 0
                        oSizeSectionTitle.Width = oPage.Width*oSizeSectionTitle_Width
                        oSizeSectionTitle.Height = oPage.Width*oSizeSectionTitle_Height
                        oShape.Size = oSizeSectionTitle
                        oPositionPageMark.y = oPositionPageMark.y-oSizeSectionTitle.Height
                        oShape.Position = oPositionPageMark
                        oShape.LineStyle = none
                        oShape.FillStyle = none
                        oShape.Name = "Progress Line TS_" + (iPageIndex+1)+"_"+(iPageIndexCurrent+1)
                        oPage.add(oShape)
                        oShape.String = sSectionTitle(iPageIndexCurrent)
                        oShape.CharWeight = com.sun.star.awt.FontWeight.BOLD  
                        oShape.CharFontName = "Arial" 'todo: doesn't work
    
                        If iSectionIndexCurrent=iSectionIndex Then
                            oShape.CharColor = oCharColorSectionTitleActive
                        Else
                            oShape.CharColor = oCharColorSectionTitleInactive
                        End If 
    
                    End If
                Next iPageIndexCurrent
            Next iPageIndex
            Close #iFileNumber
        End If
    End Sub
    
    Sub ProgressLineRemove
        oDocument = ThisComponent
        If oDocument.supportsService("com.sun.star.drawing.GenericDrawingDocument") Then
            'loop over pages
            iSectionIndexCurrent=0
            For iPageIndex=0 To oDocument.DrawPages.Count-1
                oPage = oDocument.DrawPages(iPageIndex)
                'Cleanup old shapes
                iShapeIndex = oPage.getCount-1
                Do While (iShapeIndex>=0)
                    oShape = oPage.getByIndex(iShapeIndex)
                    If (InStr(oShape.Name, "Progress Line") <> 0) Then
                        oPage.remove(oShape)
                    End If
                    iShapeIndex = iShapeIndex-1
                Loop
            Next iPageIndex
        End If
    End Sub
    
  4. Save it

Workflow

Add ProgressLine

  1. Create index, a text file, in same folder with same name but with .index extension

    5
    1,_
    2,H2_a
    4,H2_b
    7,H2_c
    10,_
    
    • First line is total number of section
    • Remaining lines in this format: page, section title
    • _ special for section without title
  2. Open your presentation

  3. Tools > Macros > Organize Macros > LibreOffice Basic...: Run ProgressLine

Remove ProgressLine

  • Tools > Macros > Organize Macros > LibreOffice Basic...: Run ProgressLineRemove

Notes

  • Most settings are grouped at the top of the script, so it should be somehow easy to tweak it.

LibreOffice-OpenOffice Impress-Presentation Progress Bar with Sections Top Outline

6
  • where is located your .index file? – damadam Oct 31 '19 at 8:20
  • @damadam, In same folder – user.dz Oct 31 '19 at 8:38
  • @damadam, Could I ask how easy/difficult you find it for installation & for use? If it is worth for many users, I may put more time in it at lease make it easy to install (2~3h), probably get index from included note/outline (10~12h, need reading & testing) & publish it a repository so interested users may add or fork for better turnings (1.5h). – user.dz Oct 31 '19 at 11:51
  • 1
    I find it pretty easy to configure, and also not so hard to use, I just wait a little to deliver the bounty. I don't know how you could increase installation, but it could be worth :) – damadam Oct 31 '19 at 12:50
  • 1
    I had a problem with this macro: only the section titles were visible in the progress bar; the page markers were there, but were invisible. I fixed it by adding a line oShape.FillStyle = com.sun.star.drawing.FillStyle.SOLID next to oShape.Name = "Progress Line RS_" + (iPageIndex+1)+"_"+(iPageIndexCurrent+1). My LibreOffice version is 6.2.8.2, just in case. P.S. Thanks a lot for writing it! – Lapis Feb 3 '20 at 12:54
0

Great Idea. I down loaded the Progress bar too. It does give a Percentage figure "x %", but nothing as elaborate as what is in your drawing. I am not a developer, and just getting into LibreOffice Macros.

My Guess is solution is by using LibreOffice Writer Table of Contents(TOC), transformed for Presenter.

If it is possible to tag TOC entries as being 'mile stones', and once reached, sends an Abbreviated reduced font text box, and toggled Icon to place holder.

I would imagine multi sets of Placeholder templates would have to be made. Eg 10, 20, 30, 40, 50, 60, 70, 80, 90, 100. And Template called up automatically on slide increment, or decrement.

The colour of text and toggle filler Icons would be the tricky part to overcome. If this was set on a Master slide from the beginning, it would help.

I look forward(ie "Progress"!) to somebody who knows more about macro programming, than I do, giving this a go.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.