Change Impress Layout at Runtime Using Basic Macro

1 min


This tutorial will show how to change the Impress Slide Layouts at Run-time.

Prerequisite

This tutorial assumes that you know how to create a basic Impress macro in LibreOffice. You can go through the basic guide using below link.

Impress Macro – Getting Started

In a presentation document, there are various styles of Layout present – Title only, Title with single box, double text box etc. For any automation tasks where it is required to generate the Impress presentation files dynamically with a desired layout, we need to program for the layout changes.

Layout Options

LibreOffice Impress 5.1+ comes with below layouts:

  • Blank Slide
  • Title Slide
  • Title, Content
  • Title and 2 Content
  • Title Only
  • Centered Text
  • Title, 2 Content and Content
  • Title, Content and 2 Content
  • Title, 2 Content over content
  • Title, Content over content
  • Title, 4 Content
  • Title, 6 Content

impress-macro-layouts

 

Macro

To change the Layout at run-time, use the Layout property of a Slide. Layout property takes a number which refers to any above of the layouts.

For example, to change a slide layout to “Title, Content”, follow below code:

oDoc = ThisComponent
' Get a List of all Slides
oSlideList = oDoc.getDrawPages()
' Get the First Slide
oSlide = oSlideList.getByIndex(0)
oSlide.Layout =1 ' Title, Content

Refer below table to get desired Layout numbers for various Layouts.

Layout ValueLayout Type
0Title Slide; one title and a text box
1Title, Content
3Title , two content
12Title content, 2 content
14Title, content over content
15Title, 2 content and content
18Title , 4 content
19Title Only
34Title, 6 content

Reference

DrawPage-Layout


We bring the latest tech, software news and stuff that matters. Stay in touch via Telegram, Twitter, YouTube, and Facebook and never miss an update!

Join our Telegram channel and stay informed on the move.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.


Arindam

Creator of debugpoint.com. All time Linux user and open-source supporter. Connect with me via Telegram, Twitter, LinkedIn, or send us an email.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x