Page 1 of 1

[Solved] How I can sent picture in Calc to background?

PostPosted: Thu Nov 03, 2011 9:54 am
by vick
So i found two ways insert picture to calc document. But I don`t know how I can set attribute "to background"

first way:

Code: Select all   Expand viewCollapse view
Sub Main
   oDoc = ThisComponent
   oSheet = oDoc.getSheets().getByIndex( 1 )
   oDrawPage = oSheet.getDrawPage()
   
    cFile = "\\kamsslab-ir\R\source\st_ku_pet.jpg"
    cUrl = ConvertToUrl( cFile )
     
   oShape = MakeGraphicObjectShape( oDoc, MakePoint( 500, 27500 ), MakeSize( 13333, 5000 ) )
    oDrawPage.add( oShape )
     oShape.GraphicURL = cUrl
End Sub

second way
Code: Select all   Expand viewCollapse view
sub __Main
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "FileName"
args1(0).Value = "file://kamsslab-ir/R/source/st_ku_pet.jpg"
args1(1).Name = "FilterName"
args1(1).Value = "<All formats>"
args1(2).Name = "AsLink"
args1(2).Value = false

dispatcher.executeDispatch(document, ".uno:InsertGraphic", "", 0, args1())

end sub

but in second i don`t how resize and move picture.

dispatcher.executeDispatch(document, ".uno:SetObjectToBackground", "", 0, Array())
- don`t worked !!!!!

Re: how I can sent picture in Calc to background?

PostPosted: Thu Nov 03, 2011 11:37 am
by Villeroy
Recorded macros are not the way to go. You can not really program like this.
http://www.mediafire.com/?x20gqzjwyqm

Re: how I can sent picture in Calc to background?

PostPosted: Thu Nov 03, 2011 12:42 pm
by B Marcelly
Hi,
With your first method

Code: Select all   Expand viewCollapse view
' push graphic to background
oShape.LayerId = 1

' push graphic to usual layer
oShape.LayerId = 0

Re: How I can sent picture in Calc to background?

PostPosted: Thu Nov 03, 2011 4:02 pm
by vick
So thanks!!!

B Marcelly you solution is that what I found. Thanks!!!!