Insert custom rectangle to current slide

From The Document Foundation Wiki
Jump to: navigation, search
This page contains changes which are not marked for translation.

Other languages:


This macro will insert a[1] to the currently selected slide in an Impress document, with various custom presets as specified in the code.


In LibreOffice Basic:

Option Explicit

Sub InsertRectangleShape()
    '''Insert a RectangleShape to the currently selected slide'''

    Dim oDoc As Object '
    Dim oSlide As Object '
    Dim oRectangle As Object '
    Dim oSize As New
    Dim oPosition As New

    oDoc = ThisComponent
    oSlide = oDoc.CurrentController.CurrentPage
    oRectangle = oDoc.createInstance("")

    With oSlide
        oPosition.X = .7*(.Width - oSize.Width)
        oPosition.Y = .7*(.Height - oSize.Height)
    End With ' oSlide

    oSize.Width = 5000
    oSize.Height = 3000
    With oRectangle
        .FillColor = RGB(0,0,255)
        .FillStyle = ' or .NONE
        .FillTransparence = 30

        .LineStyle = ' or .NONE
        .LineWidth = 100
        .LineColor = RGB(0,0,0)

        .charFontName = "Liberation Sans"
        .charColor = RGB(255,255,255)
        .ZOrder = 1
    End With ' oRectangle

End Sub ' InsertRectangleShape

ODP file to test macro