Date: prev next · Thread: first prev next last
2019 Archives by date, by thread · List index


For example I want to do it for 2 rectangles as from menu Shape ->
Merge/Subtract/Intersect

Macro twoRectangles put 2 rectangles to the Draw page and select them.


Sub twoRectangles 'put 2 rectangles to the Draw page and select them
        dim oDrawDoc,oPage,oRect1,oRect2,oShapes,oSelect
        oDrawDoc=thisComponent
        oPage=oDrawDoc.getDrawPages().getByIndex(0)

        rem put rectangle 1
        oRect1=oDrawDoc.createInstance("com.sun.star.drawing.RectangleShape")
        oRect1.setPosition(createPoint(1000, 1000))
        oRect1.setSize(createSize(4000, 3000))
        oPage.add(oRect1)

        rem put rectangle2
        oRect2=oDrawDoc.createInstance("com.sun.star.drawing.RectangleShape")
        oRect2.setPosition(createPoint(2000, 1500))
        oRect2.setSize(createSize(5000, 2000))
        oRect2.fillColor=RGB(123,34,78) 'other color
        oPage.add(oRect2)

        rem shapes to collection
        oShapes=createUnoService("com.sun.star.drawing.ShapeCollection")
        oShapes.add(oRect1)
        oShapes.add(oRect2)

        rem shapes to selection
        oDrawDoc.CurrentController.Select(oShapes)
        oSelect=oDrawDoc.getCurrentController().getSelection()

        rem now I can do manually: menu Shape -> Merge/Subtract/Intersect, but how
via macro???
End Sub


Function CreatePoint(ByVal x As Long,ByVal y As Long) As
com.sun.star.awt.Point
        Dim oPoint
        oPoint=createUnoStruct( "com.sun.star.awt.Point" )
        oPoint.X=x : oPoint.Y=y
        CreatePoint=oPoint
End Function

Function CreateSize(ByVal x As Long,ByVal y As Long) As
com.sun.star.awt.Size
        Dim oSize
        oSize=createUnoStruct( "com.sun.star.awt.Size" )
        oSize.Width=x : oSize.Height=y
        CreateSize=oSize
End Function



--
Sent from: http://document-foundation-mail-archive.969070.n3.nabble.com/Users-f1639498.html

-- 
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
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

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.