Where is a Shape’s alignment stored?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
_savage
Posts: 187
Joined: Sun Apr 21, 2013 12:55 am

Where is a Shape’s alignment stored?

Post by _savage »

Hello,

Suppose I have a document and iterate over its DrawPage objects like so:

Code: Select all

shapeobjenum = document.DrawPage.createEnumeration()
while shapeobjenum.hasMoreElements():
    shapeobj = shapeobjenum.nextElement()
    # shapeobj.Size, shapeobj.ActualSize give me the object’s size on the page in 100th/mm
Some of these XShape objects are implemented by SwXTextGraphicObject (a simple jpg image dropped into the document) and others by SwXShape or SvxShapeCollection (a hand-drawn shape, for example). Can there be other implementations for shapes?

As I iterate over these shape objects, I can get their size but I am at a loss as for their alignment. The XShapeAligner is deprecated (and I did not see it used in MRI) but the drawing module has an Alignment enum whose values I can not find when I browse the shape objects in MRI.

Can somebody please point me into the right direction? How can I find the alignment of a shape?
Mac 10.14 using LO 7.2.0.2, Gentoo Linux using LO 7.2.3.2 headless.
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Where is a Shape’s alignment stored?

Post by Zizi64 »

Please upload your ODF type sample file here with the embedded macro code.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
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
Lupp
Volunteer
Posts: 3549
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Where is a Shape’s alignment stored?

Post by Lupp »

To get it clear:
The (deprecated) XShapeAligner isn't a property like .Size (which you mention). Were you aware of this?
It should allow to handle the relative alignment of a selection of shapes.

The alignment of a shape is controlled by the properties
HoriOrient, if HoriOrient=0 then HoriOrientPosition in 1E-2 mm,
VertOrient, if VertOrient=0 then VertOrientPosition in 1E-2 mm.
(Also see https://api.libreoffice.org/docs/idl/re ... _8idl.html)

Shapes:
https://api.libreoffice.org/docs/idl/re ... Shape.html
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply