Issue 18037 - using setposition to move a graphic image
Summary: using setposition to move a graphic image
Status: CLOSED IRREPRODUCIBLE
Alias: None
Product: Calc
Classification: Application
Component: code (show other issues)
Version: OOo 1.1 RC2
Hardware: Other Linux, all
: P3 Trivial (vote)
Target Milestone: ---
Assignee: Unknown
QA Contact: issues@sc
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-08-08 16:12 UTC by Unknown
Modified: 2003-12-04 18:09 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Unknown 2003-08-08 16:12:59 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
Comment 1 oc 2003-08-11 09:44:34 UTC
Hi Stephan, please have a look
Comment 2 stephan.wunderlich 2003-08-11 13:29:02 UTC
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.
Comment 3 stephan.wunderlich 2003-08-11 13:29:39 UTC
SW: seems to be ok 
Comment 4 Unknown 2003-08-11 14:22:31 UTC
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 
Comment 5 stephan.wunderlich 2003-12-04 18:09:46 UTC
SW: closing