https://bugs.documentfoundation.org/show_bug.cgi?id=174258

            Bug ID: 174258
           Summary: Document negative Width and Height behavior of
                    com.sun.star.drawing.LineShape
           Product: LibreOffice
           Version: 26.8.1.1 release
          Hardware: x86-64 (AMD64)
                OS: Windows (All)
            Status: UNCONFIRMED
          Severity: minor
          Priority: medium
         Component: Documentation
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Description:
The API documentation for com.sun.star.drawing.LineShape and its inherited
XShape interface does not explain how negative Width and Height values affect
line geometry and positioning.

Negative dimensions are useful for defining the direction of a line.

For example:

Dim aPos As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size

Dim w As Long, h As Long

w = x2 - x1
h = y2 - y1

aPos.X = x1
aPos.Y = y1

If w < 0 Then aPos.X = aPos.X + w
If h < 0 Then aPos.Y = aPos.Y + h

aSize.Width = w
aSize.Height = h

Important observations:

Negative Width and Height values must retain their signs. Using Abs() changes
the line direction.

When Width is negative, the X position must be adjusted by adding Width.

When Height is negative, the Y position must be adjusted by adding Height.

The signs of Width and Height determine the diagonal direction of the line.

Requested improvement:

Please document the behavior of negative Width and Height values in the API
documentation, particularly for com.sun.star.drawing.LineShape and
XShape.setSize().

A short example covering all four diagonal directions would be very helpful for
developers using UNO and LibreOffice Basic.

Steps to Reproduce:
Sub CreateLine(x1 As Double, y1 As Double, x2 As Double, y2 As Double)
    w = CLng(x2 - x1)
    h = CLng(y2 - y1)

    aPos.X = CLng(x1)
    aPos.Y = CLng(y1)

    aSize.Width = w
    aSize.Height = h

    oLine = oDoc.createInstance("com.sun.star.drawing.LineShape")
    oLine.setPosition(aPos)
    oLine.setSize(aSize)

Actual Results:
line appears not starting in x1,y1 but in the min(x1,y1),min(x2,y2) of the
bounding box, which is wrong if width or height is negative.
Negative width and/or height is necessary for the orientation of the line!

Expected Results:
line should appear correctly starting at x1,y1, ending at x2,y2.


Reproducible: Always


User Profile Reset: No

Additional Info:
For getting the correct line in case of negative height or width the position
need to be corrected by either height or width.
    If w < 0 Then
        aPos.X = aPos.X + w
    End If

    If h < 0 Then
        aPos.Y = aPos.Y + h
    End If

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to