[Solved] Insert Image, Position and Resize via Macro in Calc

Creating a macro - Writing a Script - Using the API

[Solved] Insert Image, Position and Resize via Macro in Calc

Postby masc145 » Wed Jan 27, 2016 1:17 am

We need to extract certain info create a new spreadsheet format, insert an image and save as pdf
but we can haven´t found how to resize and position the image
we insert it with:
Code: Select all   Expand viewCollapse view
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 = "logosLMF.png"
args1(1).Name = "FilterName"
args1(1).Value = "PNG - Portable Network Graphic"
args1(2).Name = "AsLink"
args1(2).Value = false

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

and then how do we place it and position: x=0.53cm and y=0.41cm and size: width=15.59cm and heigh=2.83 cm
Any One?
Thanks
Last edited by Hagar Delest on Fri Feb 26, 2016 11:19 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 4.0.1 with MacOs 10.11.2
masc145
 
Posts: 2
Joined: Wed Jan 27, 2016 1:09 am

Re: Inserting Image, Positioning and Resizing via Macro in C

Postby FJCC » Wed Jan 27, 2016 3:41 am

I would insert an image in the first sheet of the document like this
Code: Select all   Expand viewCollapse view
Folder = "C:\Users\fjcc\Desktop\"

imagen = "W21_0.TIF"
ImagenURL = convertToURL(Folder & imagen)
oImagen_obj = ThisComponent.createInstance("com.sun.star.drawing.GraphicObjectShape")

oImagen_obj.GraphicURL = ImagenURL
oSize = oImagen_obj.Size
oSize.Height = 3000
oSize.Width = 3000
oImagen_obj.Size = oSize
oPos = oImagen_obj.Position
oPos.X = 2000
oPos.Y = 3000
oImagen_obj.Position = oPos

oDP = ThisComponent.DrawPages.getByIndex(0)
oDP.add(oImagen_obj)
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7493
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Inserting Image, Positioning and Resizing via Macro in C

Postby masc145 » Wed Jan 27, 2016 3:56 am

it worked, thanks
OpenOffice 4.0.1 with MacOs 10.11.2
masc145
 
Posts: 2
Joined: Wed Jan 27, 2016 1:09 am

Re: Inserting Image, Positioning and Resizing via Macro in C

Postby mauriciobaeza » Wed Jan 27, 2016 5:47 pm

You can try EasyDev, too: http://easydev.readthedocs.org/en/lates ... sert-image

Best regards
______________________________________________
Everything not given is lost
AOO 4.1 / LibO 4.3 on ArchLinux with Gnome3
Please, I do not answer private questions, you use the forum
mauriciobaeza
 
Posts: 56
Joined: Thu Apr 22, 2010 5:03 am

Re: Inserting Image, Positioning and Resizing via Macro in C

Postby musikai » Wed Jan 27, 2016 8:13 pm

@mauriciobaeza
Macros created using EasyDev, do they need EasyDev installed when executing?
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: 267
Joined: Wed Nov 11, 2015 12:19 am

Re: Inserting Image, Positioning and Resizing via Macro in C

Postby mauriciobaeza » Thu Jan 28, 2016 4:31 am

musikai wrote:@mauriciobaeza
Macros created using EasyDev, do they need EasyDev installed when executing?


Yes, It need...
______________________________________________
Everything not given is lost
AOO 4.1 / LibO 4.3 on ArchLinux with Gnome3
Please, I do not answer private questions, you use the forum
mauriciobaeza
 
Posts: 56
Joined: Thu Apr 22, 2010 5:03 am

Re: Inserting Image, Positioning and Resizing via Macro in C

Postby musikai » Thu Jan 28, 2016 10:16 pm

Thank you!
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: 267
Joined: Wed Nov 11, 2015 12:19 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 5 guests