Page 1 of 1

[Solved] Change position image in document

PostPosted: Thu Aug 29, 2019 10:21 am
by Touf2638
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 

Re: Change position image in document

PostPosted: Thu Aug 29, 2019 1:10 pm
by JeJe
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.

Re: Change position image in document

PostPosted: Mon Sep 02, 2019 10:02 am
by Touf2638
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 ?

Re: Change position image in document

PostPosted: Mon Sep 02, 2019 10:16 am
by JeJe
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.

Re: Change position image in document

PostPosted: Mon Sep 02, 2019 10:17 am
by Zizi64
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

Re: Change position image in document

PostPosted: Mon Sep 02, 2019 10:34 am
by JeJe
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.

Re: Change position image in document

PostPosted: Mon Sep 02, 2019 10:43 am
by Touf2638
Thanks a lot