Basic macro in Impress to get current/active/selected slide?

classic Classic list List threaded Threaded
3 messages Options
Nathan Ullberg Nathan Ullberg
Reply | Threaded
Open this post in threaded view
|

Basic macro in Impress to get current/active/selected slide?

Hi there,

I was wondering:  I am trying to write a Basic macro which inserts a
rectangle in Impress in the current/active/selected slide.
But the closest I have gotten is to specify which slide# it will end up
on....
How do I get the current slide?  (No success after much googling.....)

This is what I have:
========================
sub InsertRectangle
dim shapeGeometry(0) as new com.sun.star.beans.PropertyValue
dim oSize as new com.sun.star.awt.Size
dim oPosition as new com.sun.star.awt.Point
oSize.width = 6000
oSize.height = 3000
oDoc = ThisComponent
oSlide = oDoc.DrawPages(2)  'how do i get current/active/selected
slide......?
oShape = oDoc.createInstance("com.sun.star.drawing.CustomShape")
shapeGeometry(0).Name = "Type"
shapeGeometry(0).Value = "flowchart-process"
oSlide.add(oShape)
oShape.CustomShapeGeometry = shapeGeometry
oShape.Size = oSize
oPosition.X = (oSlide.width - oSize.width) / 2
oPosition.Y = (oSlide.height - oSize.height) / 2
oShape.setPosition(oPosition)
oShape.FillStyle = com.sun.star.drawing.FillStyle.SOLID
oShape.LineStyle = com.sun.star.drawing.LineStyle.NONE
oShape.FillColor = 2943070
end sub
========================

Thanks,
/Nathan


--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Mauricio Baeza-4 Mauricio Baeza-4
Reply | Threaded
Open this post in threaded view
|

Re: Basic macro in Impress to get current/active/selected slide?

On Wed, 6 Mar 2019 01:52:25 +0100, Nathan Ullberg <[hidden email]> wrote:

> Hi there,
>
> I was wondering:  I am trying to write a Basic macro which inserts a
> rectangle in Impress in the current/active/selected slide.
> But the closest I have gotten is to specify which slide# it will end up
> on....
> How do I get the current slide?  (No success after much googling.....)
>
> This is what I have:
> ========================
> sub InsertRectangle
> dim shapeGeometry(0) as new com.sun.star.beans.PropertyValue
> dim oSize as new com.sun.star.awt.Size
> dim oPosition as new com.sun.star.awt.Point
> oSize.width = 6000
> oSize.height = 3000
> oDoc = ThisComponent
> oSlide = oDoc.DrawPages(2)  'how do i get current/active/selected


Hello...

Try...

Sub InsertRectangle()
Dim s As New com.sun.star.awt.Size

    doc = ThisComponent
    dp = doc.CurrentController.CurrentPage
    obj = doc.createInstance("com.sun.star.drawing.RectangleShape")

    s.Width = 2000
    s.Height = 1000
    obj.setSize(s)

    dp.add(obj)

End Sub
--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Andrew Douglas Pitonyak Andrew Douglas Pitonyak
Reply | Threaded
Open this post in threaded view
|

Re: Basic macro in Impress to get current/active/selected slide?

http://www.pitonyak.org/oo.php

Look for OOME (open office macros explained) and download the latest version. There is a section on draw and one on impress.

⁣Sent from BlueMail ​

On Mar 5, 2019, 11:30 PM, at 11:30 PM, Mauricio Baeza <[hidden email]> wrote:

>On Wed, 6 Mar 2019 01:52:25 +0100, Nathan Ullberg
><[hidden email]> wrote:
>
>> Hi there,
>>
>> I was wondering:  I am trying to write a Basic macro which inserts a
>> rectangle in Impress in the current/active/selected slide.
>> But the closest I have gotten is to specify which slide# it will end
>up
>> on....
>> How do I get the current slide?  (No success after much
>googling.....)
>>
>> This is what I have:
>> ========================
>> sub InsertRectangle
>> dim shapeGeometry(0) as new com.sun.star.beans.PropertyValue
>> dim oSize as new com.sun.star.awt.Size
>> dim oPosition as new com.sun.star.awt.Point
>> oSize.width = 6000
>> oSize.height = 3000
>> oDoc = ThisComponent
>> oSlide = oDoc.DrawPages(2)  'how do i get current/active/selected
>
>
>Hello...
>
>Try...
>
>Sub InsertRectangle()
>Dim s As New com.sun.star.awt.Size
>
>    doc = ThisComponent
>    dp = doc.CurrentController.CurrentPage
>    obj = doc.createInstance("com.sun.star.drawing.RectangleShape")
>
>    s.Width = 2000
>    s.Height = 1000
>    obj.setSize(s)
>
>    dp.add(obj)
>
>End Sub
>--
>To unsubscribe e-mail to: [hidden email]
>Problems?
>https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
>Posting guidelines + more:
>https://wiki.documentfoundation.org/Netiquette
>List archive: https://listarchives.libreoffice.org/global/users/
>Privacy Policy: https://www.documentfoundation.org/privacy

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy