Bug 149077 - Change how Rounded Rectangle Callout is drawn in LibreOffice
Summary: Change how Rounded Rectangle Callout is drawn in LibreOffice
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Impress (show other bugs)
Version:
(earliest affected)
7.3.2.2 release
Hardware: All All
: low normal
Assignee: Mohamed Zaghloul
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Shapes
  Show dependency treegraph
 
Reported: 2022-05-13 17:49 UTC by Rafael Lima
Modified: 2025-03-29 15:00 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Comparison of callouts between LO Impress and MS PowerPoint (44.55 KB, application/vnd.oasis.opendocument.graphics)
2022-05-13 17:49 UTC, Rafael Lima
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Lima 2022-05-13 17:49:07 UTC
Created attachment 180099 [details]
Comparison of callouts between LO Impress and MS PowerPoint

In presentations it is very common to use Rounded Rectangle Callouts, specially when the user is trying to highlight something.

LibreOffice provides the "Rounded Rectangle Callout" tool to draw such shape, however it calculates the rounded corners in a weird manner. Because of this, every time one draws a very wide callout the rounded corners end up looking weird because the start/end points of where the curve is drawn seem out of place.

See attached ODG for comparison between LO Impress and MS PowerPoint. Notice that in PowerPoint the points where the curve is drawn are fixed regardless of the proportion of the callout rectangle. This ends up looking smoother.

Hence, my suggestion is to use the same approach to draw Rounded Rectangle Callouts in LibreOffice.

System info:
Version: 7.3.3.2 / LibreOffice Community
Build ID: 30(Build:2)
CPU threads: 16; OS: Linux 5.13; UI render: default; VCL: kf5 (cairo+xcb)
Locale: pt-BR (pt_BR.UTF-8); UI: en-US
Ubuntu package version: 1:7.3.3~rc2-0ubuntu0.21.10.1~lo1
Calc: threaded
Comment 1 Buovjaga 2022-05-23 11:35:38 UTC
Sounds good -> NEW
Comment 2 Regina Henschel 2022-05-23 12:44:01 UTC
If you do not intend to save to the binary ppt format, then you can use the ooxml-callout. That is in the Gallery theme "Shapes".
Comment 3 Rafael Lima 2022-05-26 19:37:59 UTC
(In reply to Regina Henschel from comment #2)
> If you do not intend to save to the binary ppt format, then you can use the
> ooxml-callout. That is in the Gallery theme "Shapes".

Regina, do you have a code pointer to where the rectangle callout is defined in LO?

I was looking for .uno:CalloutShapes and SID_DRAWTBX_CS_CALLOUT to try to figure out where LO pulls the coordinates for the callout, but I could not find it.
Comment 4 Regina Henschel 2022-05-26 22:13:20 UTC
(In reply to Rafael Lima from comment #3)
> (In reply to Regina Henschel from comment #2)
> > If you do not intend to save to the binary ppt format, then you can use the
> > ooxml-callout. That is in the Gallery theme "Shapes".
> 
> Regina, do you have a code pointer to where the rectangle callout is defined
> in LO?

The shape belongs to those, which have a corresponding shape in binary MS Office. By import in filter/source/msfilter/msdffimp.cxx it gets a type from enum MSO_SPT, in this case mso_sptWedgeRRectCallout = 62.
Coming from ODF we have the map from the value of draw:type="rounded-rectangular-callout" in ODF to MSO_SPT in /svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx.

The MSO_SPT enum value is then mapped to a mso_CustomShape* in method GetCustomShapeContent() at the end of svx/source/customshapes/EnhancedCustomShapeGeometry.cxx, here msoWedgeRRectCallout. The details for this shape are then around #5800 above in this file.

> 
> I was looking for .uno:CalloutShapes and SID_DRAWTBX_CS_CALLOUT to try to
> figure out where LO pulls the coordinates for the callout, but I could not
> find it.

Depending on what you want to do, you likely need some more info. No problem with that, but I need to know what you want to do, to help you further.
Comment 5 Regina Henschel 2022-05-27 19:53:13 UTC
The shape "Alternate Process" from category "Flowchart" has the same problem, that the corners do not remain circular.
Comment 6 Rafael Lima 2022-05-27 20:29:10 UTC
(In reply to Regina Henschel from comment #5)
> The shape "Alternate Process" from category "Flowchart" has the same
> problem, that the corners do not remain circular.

Indeed, the "Alternate Process" shape has the same problem. OTOH "Rectangle, Rounded" (Basic Shapes) is a very similar shape and it does not have the same problem.

Note that "Rectangle, Rounded" has a handle and it prevents the corners from being distorted.

I was trying to figure out the code in [1] to see if we could change the way these corner vertices are calculated. However, I still could not figure out what the calculation data means in the mso_CustomShape struct.

[1] https://opengrok.libreoffice.org/xref/core/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx?r=4cfe4699#5820
Comment 7 Regina Henschel 2022-05-27 21:26:26 UTC
What do you already know about custom shapes? Do you know, how the ODF markup in file is written? Do you know how the information is hold in property CustomShapeGeometry (Development Tools)? Do you now how shapes were defined in VML? Do you know "limo stretch" or "stretchpoint"? Then I would know where to start to explain the mso_CustomShape struct. Should we discuss it in direct mails? Or we start a Wiki-page about this topic? I think it is a little bit off-topic for Bugzilla.
Comment 8 Eyal Rozenberg 2023-10-21 18:45:05 UTC
This is a major annoyance for presentation authors. The weird elliptic quadrants make this shape incredibly ugly. I wish someone would work on it, since it's not some systemic bug so it should not be that much work beyond realizing how the shape is specified.
Comment 9 Khushi Gautam 2023-10-23 21:14:10 UTC
(In reply to Regina Henschel from comment #7)
> What do you already know about custom shapes? Do you know, how the ODF
> markup in file is written? Do you know how the information is hold in
> property CustomShapeGeometry (Development Tools)? Do you now how shapes were
> defined in VML? Do you know "limo stretch" or "stretchpoint"? Then I would
> know where to start to explain the mso_CustomShape struct. Should we discuss
> it in direct mails? Or we start a Wiki-page about this topic? I think it is
> a little bit off-topic for Bugzilla.

I want to know about how the shapes are defined in VML, Also if I am making any changes in the EnhancedCustomShapeGeometry.cxx , will the changed reflect in impress document or draw document. Also whenever I am editing "msoWedgeRRectCallout" I am unable to see any differences. Just wants to know from where this shape is coded
Comment 10 Buovjaga 2025-03-27 11:30:14 UTC
(In reply to Regina Henschel from comment #7)
> What do you already know about custom shapes? Do you know, how the ODF
> markup in file is written? Do you know how the information is hold in
> property CustomShapeGeometry (Development Tools)? Do you now how shapes were
> defined in VML? Do you know "limo stretch" or "stretchpoint"? Then I would
> know where to start to explain the mso_CustomShape struct. Should we discuss
> it in direct mails? Or we start a Wiki-page about this topic? I think it is
> a little bit off-topic for Bugzilla.

Regina gave a presentation in 2022 'Introduction to the feature "limo-stretch" of shapes':
https://www.youtube.com/watch?v=t5-zCzfTrmE
Comment 11 Mohamed Zaghloul 2025-03-27 14:57:41 UTC
I've been analyzing the msoWedgeRRectCallout shape definition, and I see that several arrays define its properties:

mso_sptWedgeRRectCalloutVert → Defines points in the shape.

mso_sptWedgeRRectCalloutSegm → Defines how these points are connected.

mso_sptWedgeRectCalloutCalc → Defines dynamic properties (adjustments, constraints, etc.).

Looking deeper into the mso_sptWedgeRectCalloutCalc array, I see that each entry consists of a hexadecimal flag and an array of parameters. For example:


{ 0x2000, { DFF_Prop_adjust2Value, 0, 10800 } },
{ 0x6006, { 0x412, DFF_Prop_adjustValue, 0 } },  // 0x402
{ 0x6006, { 0x412, DFF_Prop_adjust2Value, 6280 } },
I have two questions regarding this:

1. What does the hex value (e.g., 0x2000, 0x6006, etc.) represent?
- How is it interpreted in calculations?
- How are these formulas evaluated in the shape generation process?

2. Since this is named mso_sptWedgeRectCalloutCalc (without "R" for rounded), should a separate array be created for the rounded variant?
- For example, should there be a mso_sptWedgeRRectCalloutCalc specifically for rounded calculations?
- Or would modifications to the existing array be enough to support the rounded version?
Comment 12 Mohamed Zaghloul 2025-03-29 12:28:48 UTC
(In reply to Regina Henschel from comment #7)
> What do you already know about custom shapes? Do you know, how the ODF
> markup in file is written? Do you know how the information is hold in
> property CustomShapeGeometry (Development Tools)? Do you now how shapes were
> defined in VML? Do you know "limo stretch" or "stretchpoint"? Then I would
> know where to start to explain the mso_CustomShape struct. Should we discuss
> it in direct mails? Or we start a Wiki-page about this topic? I think it is
> a little bit off-topic for Bugzilla.

more about ODF document structure 
https://web.archive.org/web/20220819080817/https://fivedots.coe.psu.ac.th/~ad/jlop/chaps/51.%20Simple%20ODF.pdf
Comment 13 Buovjaga 2025-03-29 15:00:11 UTC
(In reply to Mohamed Zaghloul from comment #12)
> (In reply to Regina Henschel from comment #7)
> > What do you already know about custom shapes? Do you know, how the ODF
> > markup in file is written? Do you know how the information is hold in
> > property CustomShapeGeometry (Development Tools)? Do you now how shapes were
> > defined in VML? Do you know "limo stretch" or "stretchpoint"? Then I would
> > know where to start to explain the mso_CustomShape struct. Should we discuss
> > it in direct mails? Or we start a Wiki-page about this topic? I think it is
> > a little bit off-topic for Bugzilla.
> 
> more about ODF document structure 
> https://web.archive.org/web/20220819080817/https://fivedots.coe.psu.ac.th/
> ~ad/jlop/chaps/51.%20Simple%20ODF.pdf

No need to use archive.org: https://wiki.documentfoundation.org/Documentation/SDKGuide#Part_9:_The_ODF_Format

See also the ODF category in the wiki: https://wiki.documentfoundation.org/Category:ODF