Find coordinates of path points

I have a “path” object defined by this, as shown with the image,

<draw:path draw:style-name=“gr19” draw:text-style-name=“P11” draw:layer=“layout” svg:width=“1.806cm” svg:height=“5.999cm” svg:x=“71.193cm” svg:y=“21cm” svg:viewBox=“0 0 1807 6000” svg:d=“M1800 6000c-100-1600-1800-800-1800-2400 0-1100 1707-500 1807-1600-100-1100-1107-500-1007-2000”>
<text:p text:style-name=“P9”><text:span text:style-name=“T4”>Path</text:span></text:p>
</draw:path>

How can I work out what the coordinates of the endpoints of the line are?

I am using the drawing as a control system configuration and want to know which objects are linked by path connectors.

In case you need the coordinates in the internal coordinate system, you have to calculate it yourself (see below) or write a macro to do it for you. In case you need the coordinates in the page coordinate system, you can look at the status bar or the position dialog or you put a snap point at the same position and read its coordinates.

The path is defined as svg:d which means, it is the definition as can be read in http://www.w3.org/TR/SVG/expanded-toc.html.

M1800 6000 is an absolute move to (1800|6000) and the start anchor point of the following Bézier segment.

A c means a Bézier curve. Such has for each segment two control points and the end anchor point, which is the start point of the next segment. The c is not repeated for the next segment. As the c is lower case, the coordinates are relative to the start anchor point.

c-100-1600-1800-800-1800-2400 means: control points (1700|4400) (0|5200) next anchor point (0|3600)

0-1100 1707-500 1807-1600 means: control points (0|2500) (1707|3100) next anchor point (1807|2000)

-100-1100-1107-500-1007-2000 means: control points (1707|900) (900|1500) last anchor point (800|0).

For to know the connected objects do not use the path. A connector has the attributes draw:start-shape and draw:start-glue-point and draw:end-shape and draw:end-glue-point. These gives you the information directly. If you save the document in flat ODF (= file name extension fodt) and open it in an editor, then you will find these attributes easily. You can get these information using a macro.

Thanks. I am reading the XML from Java. Did you mean a glue point? I tried to add one to the line but it doesn’t move with the line.

“c-100-1600-1800-800-1800-2400 means: control points” I’m not quite with you. Are these numbers x and y distances from the bottom left corner?

The coordinates inside the shape are based on svg:viewbox=“0 0 1807 6000”, which is left,top,width,height. That rectangle is mapped to svg:width=“1.806cm” svg:height=“5.999cm” svg:x=“71.193cm” svg:y=“21cm”, which is relative to the page coordinate system.

The shape has an xml:id and this number is in draw:start-shape if the connector is docked to that shape. To which glue-point of that shape the connector is docked is in draw:start-glue-point. Each shape has four default glue points with the numbers 0, 1, 2, 3. The other glue points are defined inside the shape. They can be an attribute draw:glue-points of the element draw:enhanced-geometry or they can be user defined in an draw:glue-point element as child of element draw:custom-shape.

Do you work on the file source or do you have a running LibreOffice so that you can get current information via API?

I am using the Java odg toolkit API to read in an ODG document, from which I get the XML code for an object. And I want to determine the coordinates of the line end points within the page coordinate system. So if “c-100-1600-1800-800-1800-2400” are relative to the top left corner how do I know if these values are in the x or y directions?

You need to read the SVG specification, its link I have given in my answer. In case of the c command, it is first number x, second number y (=>first control point), third number x, forth number y (=>second control point), fifth number x, sixth number y (=> anchor point) and so on. From the information svg:width, svg;height, svg:x, svg:y, svg:viewbox you generate a transformation matrix. Apply this matrix to the internal path coordinates to get the position on the page.

Because you only need the last point, you can skip the control points.