[Solved] PolyPolygonShape with bitmap fill

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
bartjeman
Posts: 177
Joined: Sun Jan 03, 2010 6:23 am
Location: Toronto

[Solved] PolyPolygonShape with bitmap fill

Post by bartjeman »

My polygons are drawing without error, but I am getting the default light blue fill, not my bitmap fill

My code contains

Code: Select all

BitmapPath = "Z:\Products-Internal\Vista\Pricing_&_Quoting\bronze_thumbnail_for_stacking_window_draw_macro.jpg"
I confirmed that the path is valid

Later in the code I call the Sub like so:

Code: Select all

DrawPolygonBitmap (SectionPoints,oDP,BitmapPath)
And here is the Sub:

Code: Select all

Sub DrawPolygonBitmap(SectionPoints as Object, oDP as Object, BitmapPath as String) 'took out bitmap size
   oShape = ThisComponent.createInstance( "com.sun.star.drawing.PolyPolygonShape" )
   oDP.add(oShape) 
   oShape.PolyPolygon = Array(SectionPoints)
   oShape.LineStyle = com.sun.star.drawing.LineStyle.SOLID
   oShape.FillStyle = com.sun.star.drawing.FillStyle.BITMAP
   oShape.FillBitmapURL = BitmapPath
   oShape.FillBitmapMode = com.sun.star.drawing.BitmapMode.REPEAT
   oShape.LineWidth = 20
   oShape.LineColor = RGB(0,0,0)
End Sub
Last edited by Hagar Delest on Thu Jul 06, 2017 10:30 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 4.1.7 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: PolyPolygonShape with bitmap fill

Post by Zizi64 »

It is a Draw application related question (or other)?

Please uplaod your ODF type example file with the embedded macro code here.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
bartjeman
Posts: 177
Joined: Sun Jan 03, 2010 6:23 am
Location: Toronto

Re: PolyPolygonShape with bitmap fill

Post by bartjeman »

Hi Zizi64

This is a Calc macro

I was hoping I supplied enough information. I am guessing that my BitmapPath variable is not the right syntax or that I have done something wrong in the Sub

The polygon is being drawn, there are no errors, but the polygon fill is the default light blue

I would rather not put the whole macro here, I could PM it to you
OpenOffice 4.1.7 on Windows 10
musikai
Volunteer
Posts: 294
Joined: Wed Nov 11, 2015 12:19 am

Re: PolyPolygonShape with bitmap fill

Post by musikai »

Give the Url in the correct format:

Code: Select all

oShape.FillBitmapURL = ConvertToUrl(BitmapPath)
Interested: How does the points array look like?
Win7 Pro, Lubuntu 15.10, LO 4.4.7, OO 4.1.3
Free Project: LibreOffice Songbook Architect (LOSA)
http://struckkai.blogspot.de/2015/04/li ... itect.html
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: PolyPolygonShape with bitmap fill

Post by Zizi64 »

This is a Calc macro

I was hoping I supplied enough information.

Without your public sample file we can not examine YOUR mistakes.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
bartjeman
Posts: 177
Joined: Sun Jan 03, 2010 6:23 am
Location: Toronto

Re: PolyPolygonShape with bitmap fill

Post by bartjeman »

Thanks musikai, ConvertToUrl fixed the problem

You mentioned how the points were defined, here you go:

Code: Select all

SectionPoints(0).x = Position.x + 100
         SectionPoints(0).y = Position.y - (Height - Transheight) * Scale
         SectionPoints(1).x = Position.x + Width * Scale - 100
         SectionPoints(1).y = SectionPoints(0).y
         SectionPoints(2).x = SectionPoints(1).x
         SectionPoints(2).y = Position.y - (oCurrentSheet.getCellByPosition(c,6).value - 3) * Scale
         SectionPoints(3).x = SectionPoints(0).x
         SectionPoints(3).y = Position.y - (oCurrentSheet.getCellByPosition(c,7).value - 3) * Scale
         DrawPolygonBitmap (SectionPoints,oDP,BitmapPath)

Code: Select all

Sub DrawPolygonBitmap(SectionPoints as Object, oDP as Object, BitmapPath as String) 'took out bitmap size
   oShape = ThisComponent.createInstance( "com.sun.star.drawing.PolyPolygonShape" )
   oDP.add(oShape)           'must be before the bitmap lines
   oShape.PolyPolygon = Array(SectionPoints)
   oShape.LineStyle = com.sun.star.drawing.LineStyle.SOLID   'or NONE
   oShape.FillStyle = com.sun.star.drawing.FillStyle.BITMAP
   oShape.FillBitmapURL = ConvertToUrl(BitmapPath)
   oShape.FillBitmapMode = com.sun.star.drawing.BitmapMode.REPEAT
   oShape.LineWidth = 20
   oShape.LineColor = RGB(0,0,0)
End Sub
OpenOffice 4.1.7 on Windows 10
musikai
Volunteer
Posts: 294
Joined: Wed Nov 11, 2015 12:19 am

Re: [Solved] PolyPolygonShape with bitmap fill

Post by musikai »

Thank you for the info!!
Win7 Pro, Lubuntu 15.10, LO 4.4.7, OO 4.1.3
Free Project: LibreOffice Songbook Architect (LOSA)
http://struckkai.blogspot.de/2015/04/li ... itect.html
Post Reply