[Solved] PolyPolygonShape with bitmap fill

Creating a macro - Writing a Script - Using the API

[Solved] PolyPolygonShape with bitmap fill

Postby bartjeman » Fri Jun 30, 2017 4:17 pm

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   Expand viewCollapse view
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   Expand viewCollapse view
DrawPolygonBitmap (SectionPoints,oDP,BitmapPath)


And here is the Sub:
Code: Select all   Expand viewCollapse view
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.0.1 on Windows 7
User avatar
bartjeman
 
Posts: 132
Joined: Sun Jan 03, 2010 6:23 am
Location: Toronto

Re: PolyPolygonShape with bitmap fill

Postby Zizi64 » Fri Jun 30, 2017 4:36 pm

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; LO4.4.7, LO5.3.6 on Win7x64Prof.
And the portable versions: LO3.3.0-LO5.4.1 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5893
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: PolyPolygonShape with bitmap fill

Postby bartjeman » Fri Jun 30, 2017 6:36 pm

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.0.1 on Windows 7
User avatar
bartjeman
 
Posts: 132
Joined: Sun Jan 03, 2010 6:23 am
Location: Toronto

Re: PolyPolygonShape with bitmap fill

Postby musikai » Sat Jul 01, 2017 12:39 am

Give the Url in the correct format:

Code: Select all   Expand viewCollapse view
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/libreofficesongbookarchitect.html
musikai
Volunteer
 
Posts: 158
Joined: Wed Nov 11, 2015 12:19 am

Re: PolyPolygonShape with bitmap fill

Postby Zizi64 » Sat Jul 01, 2017 7:14 am

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; LO4.4.7, LO5.3.6 on Win7x64Prof.
And the portable versions: LO3.3.0-LO5.4.1 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5893
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: PolyPolygonShape with bitmap fill

Postby bartjeman » Thu Jul 06, 2017 5:24 pm

Thanks musikai, ConvertToUrl fixed the problem

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

Code: Select all   Expand viewCollapse view
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   Expand viewCollapse view
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.0.1 on Windows 7
User avatar
bartjeman
 
Posts: 132
Joined: Sun Jan 03, 2010 6:23 am
Location: Toronto

Re: [Solved] PolyPolygonShape with bitmap fill

Postby musikai » Thu Jul 06, 2017 10:36 pm

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/libreofficesongbookarchitect.html
musikai
Volunteer
 
Posts: 158
Joined: Wed Nov 11, 2015 12:19 am


Return to Macros and UNO API

Who is online

Users browsing this forum: Yahoo [Bot] and 7 guests