[Solved] Change position image in document

Creating a macro - Writing a Script - Using the API

[Solved] Change position image in document

Postby Touf2638 » Thu Aug 29, 2019 10:21 am

Hi,
I try to change position of an image in a document. I have error message "position can't be changed with this method"
I have try oGraphics(0).SetPosition Opos, oGraphics(0).Position = oPos. I have try with oImg instead of oGraphics(0) etc... Same error
Size works fine. Just position don't work.
What's wrong ?
Thanks

Code: Select all   Expand viewCollapse view
   Dim oGraphics as Object, ImageName as string, oPos as object
   oGraphics = Doc.getGraphicObjects()   
   Dim oImg as Object 
   For Each oImg in oGraphics   
      ImageName = oImg.name
      if ImageName="Image1" then
         oImg.Width=2000
         oImg.Height=2000
         oPos = New com.sun.star.awt.Point
         oPos.X = 10
         oPos.Y = 10
         oImg.setPosition(oPos)
         exit for
      end if
   Next 
Last edited by Hagar Delest on Sun Sep 08, 2019 9:33 pm, edited 1 time in total.
Reason: tagged solved
OpenOffice 6.2 on Windows 10
Touf2638
 
Posts: 14
Joined: Tue Aug 20, 2019 4:21 pm

Re: Change position image in document

Postby JeJe » Thu Aug 29, 2019 1:10 pm

Use oImg.HoriOrientPosition and oImg.VertOrientPosition

If you don't have MRI...

https://extensions.openoffice.org/en/pr ... ction-tool

Exploring will get you this information and tell you that getposition and setposition won't work.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 584
Joined: Wed Mar 09, 2016 2:40 pm

Re: Change position image in document

Postby Touf2638 » Mon Sep 02, 2019 10:02 am

Thank's works fine. Sorry but I have search in documentation and I don't find reason get et set position don't works. Where do you see explanation ?
OpenOffice 6.2 on Windows 10
Touf2638
 
Posts: 14
Joined: Tue Aug 20, 2019 4:21 pm

Re: Change position image in document

Postby JeJe » Mon Sep 02, 2019 10:16 am

I just looked at MRI and saw that getposition and setposition don't work... and looked to find the correct thing to do what you wanted to do. Everything isn't fully documented in OO... you just have to do what I did there... and not worry about that.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 584
Joined: Wed Mar 09, 2016 2:40 pm

Re: Change position image in document

Postby Zizi64 » Mon Sep 02, 2019 10:17 am

Where do you see explanation ?

The object inspection tools - Like the XrayTool or the MRI - can show list the existing properties and methods of the objects.

Otherwise there are descriptions for the API on the AOO and LibreOffice related webpages.
API: Application Programming Interface
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.5; AOO4.1.6
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 8343
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Change position image in document

Postby JeJe » Mon Sep 02, 2019 10:34 am

There will probably be an explanation if you dig around in the documentation... looking at what are the supported services (again from MRI), perhaps you can get that understanding looking at these pages for starters:

https://www.openoffice.org/api/docs/com ... Shape.html

https://www.openoffice.org/api/docs/com ... Frame.html

This interface specifies the access to the shape data (position and size) of the text frame.

This interface is valid before the text frame is attached to a surrounding text, but when attached the values can change (e.g., due to a revised layout of the surrounding text).

The position is relative to the position of the anchor [see XTextFrame::getAnchor()]. Size and position are both measured in 100th mm. The size is not valid if the size is relative and no layout exists or if the layout is invalid.

This interface is only for the layout. In particular, the setting of values is only allowed for the layout component of the owner text of this text component.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 584
Joined: Wed Mar 09, 2016 2:40 pm

Re: Change position image in document

Postby Touf2638 » Mon Sep 02, 2019 10:43 am

Thanks a lot
OpenOffice 6.2 on Windows 10
Touf2638
 
Posts: 14
Joined: Tue Aug 20, 2019 4:21 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: JeJe and 12 guests