Hi Mauricio,

Mauricio Baeza schrieb am 11.02.2021 um 19:26:
On Thu, 2021-02-11 at 19:08 +0100, Regina Henschel wrote:
Hi all,

does someone has a basic macro snippet for to insert a custom shape
(e.g. a smiley) into a page?

Background: For a unit test I need to insert a custom shape via code
similar to as it is done via mouse. But I have no idea how to code
it. A
macro might give me an initial stage for a solution.

Kind regards
Regina



For Calc, for example:


Sub Main
Dim size As New com.sun.star.awt.Size
Dim args(0) As New com.sun.star.beans.PropertyValue

     doc = ThisComponent
     sheet = doc.getCurrentController.getActiveSheet()
     dp = sheet.getDrawPage()
        
     shape =
doc.createInstance("com.sun.star.drawing.CustomShape")        
     dp.add(shape)

     size.Width = 5000
     size.Height = 5000
     shape.setSize(size)
        
     args(0).Name = "Type"
     args(0).Value = "smiley"
     shape.setPropertyValue("CustomShapeGeometry", args)
        
End Sub

Aha! That means, that Size and Type are set after the object is added to the draw page.

Unfortunately using this macro, does not show the error, which I'm going to fix. Nevertheless I will test in code, whether creating with a ctor with new ... (which corresponds to createInstance) and then applying the properties will work. But I will need some time for that.

Kind regards
Regina




--
To unsubscribe e-mail to: [email protected]
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

Reply via email to