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

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
vick
Posts: 2
Joined: Thu Nov 03, 2011 5:48 am

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

Post 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

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

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 !!!!!
Last edited by Hagar Delest on Fri Nov 04, 2011 1:25 pm, edited 3 times in total.
Reason: tagged [Solved].
libreoffice 3.3.2
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

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

Post by Villeroy »

Recorded macros are not the way to go. You can not really program like this.
http://www.mediafire.com/?x20gqzjwyqm
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

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

Post by B Marcelly »

Hi,
With your first method

Code: Select all

' push graphic to background
oShape.LayerId = 1

' push graphic to usual layer
oShape.LayerId = 0
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
vick
Posts: 2
Joined: Thu Nov 03, 2011 5:48 am

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

Post by vick »

So thanks!!!

B Marcelly you solution is that what I found. Thanks!!!!
libreoffice 3.3.2
Post Reply