Apache OpenOffice (AOO) Bugzilla – Issue 18037
using setposition to move a graphic image
Last modified: 2003-12-04 18:09:46 UTC
I could not get the setPosition function to work. For a starting point I used code in section 5.27 of Andrew;s book on macros. I include the code which is mostly like what is in Andrew's book on macros. The object was placed in the spreadsheet at coordinate 0,0. the setsize function also worked. I added the following to the code: dim aPosition as new com.sun.star.awt.Point dim py as long dim px as long before the call to setposition. It does not appear that anything else needs to be added for this function to work. I found the definition of com.sun.star.awt.Point on the scripting web site. It showed a structure of X as long and Y as long. the setposition does not give an error but it does not work either. David sub main Dim vSheet vSheet = ThisComponent.Sheets(0) Dim oDesktop As Object, oDocument As Object Dim mNoArgs() Dim sGraphicURL As String Dim sGraphicService As String, sUrl As String Dim oDrawPages As Object, oDrawPage As Object Dim oGraphic As Object sGraphicURL = "file:///usr/local/openoffice1.1RC/share/gallery/bullets/blkpearl.gif" sGraphicService = "com.sun.star.drawing.GraphicObjectShape" oDrawPage = vSheet.getDrawPage() ' RunSimpleObjectBrowser(oDrawPage) oGraphic = ThisComponent.createInstance(sGraphicService) oGraphic.GraphicURL = sGraphicURL ' RunSimpleObjectBrowser(oGraphic) oDrawPage.add(oGraphic) dim TheSize as new com.sun.star.awt.Size dim TheBitmapSize as new com.sun.star.awt.Size dim TheBitmap as object dim xmult as double, ymult as double TheBitmap=oGraphic.GraphicObjectFillBitmap TheBitmapSize=TheBitmap.GetSize xmult=TwipsPerPixelX/567*10*100 '567 twips = 1 cm *1*100 for 1/100th mm ymult=TwipsPerPixelY/567*10*100 'TheSize.width=TheBitmapSize.width*xmult 'TheSize.height=TheBitmapSize.height*ymult TheSize.width=400 TheSize.height=400 oGraphic.setsize(TheSize) dim aPosition as new com.sun.star.awt.Point dim py as long dim px as long py= 6 px = 2 aPosition.X = px aPosition.Y = py oGraphic.setposition(aPosition) end sub
Hi Stephan, please have a look
SW: the values used for setposition are pretty small, I used 6000 for x and 2000 for y and the picture was painted at the desired position.
SW: seems to be ok
You are correct. The larger values do indeed move the graphic to a different location. My error was in the conversion factor I needed to use and did not. It now works as desired. Thanks, David
SW: closing