Bug 90494 - Option to change gradient angle diagonally (Left to Right / Right to Left)
Summary: Option to change gradient angle diagonally (Left to Right / Right to Left)
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
(earliest affected)
Hardware: All All
: medium enhancement
Assignee: Not Assigned
Depends on:
Blocks: Area-Fill-Tab ODF-spec
  Show dependency treegraph
Reported: 2015-04-07 05:52 UTC by Heena Gupta
Modified: 2018-05-30 21:31 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:

Screenshot for the new option (87.67 KB, image/png)
2015-04-07 05:52 UTC, Heena Gupta
Discussing the behavior of the gradient in PowerPoint, SVG and Draw (448.17 KB, application/vnd.sun.xml.impress)
2015-05-07 18:24 UTC, Regina Henschel

Note You need to log in before you can comment on or make changes to this bug.
Description Heena Gupta 2015-04-07 05:52:25 UTC
Created attachment 114665 [details]
Screenshot for the new option
Comment 1 Heena Gupta 2015-04-07 06:22:52 UTC
Link to the patch - https://gerrit.libreoffice.org/#/c/15180/
It changes the gradient angle on choosing an option "Diagonal" and by Selecting  Left To Right / Right To Left.

Working on Export and Import of the diagonal option.
Comment 2 A (Andy) 2015-04-07 07:50:59 UTC
Is my understanding correct that this would be an easy and fast alternative for the selection of the corresponding angle?
Comment 3 Matthew Francis 2015-04-07 09:07:17 UTC
New feature / improvement -> Severity: enhancement
Comment 4 Heena Gupta 2015-04-07 09:13:59 UTC
@Andy:- Yes. By choosing the diagonal option and selecting left to right / right to left, angle is calculated accordingly.
No need to calculate it manually.
Comment 5 A (Andy) 2015-04-07 10:35:04 UTC
(In reply to Heena Gupta from comment #4)
> @Andy:- Yes. By choosing the diagonal option and selecting left to right /
> right to left, angle is calculated accordingly.
> No need to calculate it manually.

Thanks for your very fast reply.  This is a good enhancement proposal.
Comment 6 Heena Gupta 2015-04-15 11:40:34 UTC
For Exporting gradient angle diagonally, I have added new attribute and the patch for this is:- https://gerrit.libreoffice.org/#/c/15323/
Comment 7 Regina Henschel 2015-04-15 13:27:29 UTC
You cannot add an attribute XML_GRADIENT_DIAGONAL with the XML_NAMESPACE_DRAW, because such attribute is not defined in ODF1.2.

I personally doubt, that the ODF TC will agree to such an attribute, because the attribute "draw:angle" exists.

Why do you think, that such attribute is needed?
Comment 8 Muthu Subramanian 2015-04-23 15:27:07 UTC
Right, so the question: How do we handle this, please?

What we need is a way to track diagonal gradients. Of course, we can save as 'angles', but then, when the user reopens the file and modifies the length or width of the object the fill would no longer be diagonal.

As a temporary solution, we could store 'angles' in the files and have the diagonal properties stored in the settings - but seems like those are dependent on the odf formats as well?
Comment 9 Regina Henschel 2015-04-23 23:48:55 UTC
The problem is very complex, so I do not have a final solution. Here are some details, which need to be considered:

New attributes can be handled in the namespace loext. But in addition a suggestion for ODF is needed to get such attribute into the next version of ODF.

ODF does not specify how a draw:transform attribute influence the filling. Alternatives are: (1) First transform the shape and then apply the filling, or (2) first fill the shape and then apply the transformation to shape including filling. A suggestion for ODF is needed.

PowerPoint has the option “Rotate with shape” which is not only available for background images, but for gradients too. LO does not have such options and ODF does not have an attribute for it. A suggestion for ODF is needed.

How does such attribute interact with the gradient-tool in the "Effects"-toolbox?

PowerPoint implements a gradient filling in the way, that it applies the filling to a unit shape and shows that angle in the UI. All scaling to the target size is then done on the gradient filling too. That results in the effect, that the angle shown in the dialog does not correspond to the angle which the user sees in the presentation. Is that the desired behavior for LO?
LO implements it the way, that the shape is first scaled from a unit shape to the target size and then the filling is applied. That way the filling is independent from the actual shape, so that all shapes which the same gradient applied, will show the gradient with the same angle.

ODF 1.2 allows svg:LinearGradient and that has a property svg:gradientUnits. Currently only value "objectBoundingBox" is allowed, but exact this value gives the effect, that the gradient is scaled together with the shape. Perhaps implementing this feature is the way to go? Having this feature would address multiple color stops too, which are needed for PowerPoint import.
Comment 10 Regina Henschel 2015-05-07 18:24:34 UTC
Created attachment 115433 [details]
Discussing the behavior of the gradient in PowerPoint, SVG and Draw

The attachment and this comment are an addition to my comments in https://gerrit.libreoffice.org/#/c/15180/

When you set an angle in the UI, you can calculate it in the way, that it corresponds to the "diagonal" of the current selected shape (actual its bounding rectangle). But if the shape gets a new height or width, the gradient is no longer diagonal. The same problem arose, if you apply such gradient to another shape via format paint brush. So such options in the dialog would not help to get a similar behavior of the gradient as in PowerPoint. See the attached file for screenshots of the behavior in PowerPoint.

If the goal is only a calculation help in the UI, then what is the desired behavior if nothing is selected and you only want to define a gradient, or if you want to make a style? The current suggestion in the patch generates a division by zero.

Will the user be surprised, when he notice, that "diagonal" refers to the diagonal of the bounding rectangle?

If it is really only about a calculation help for the current selected shape, then there is no need for a new attribute.

If you want, that a new kind of gradient is implemented, which is able to adapt itself to the shape, then doing changes in the UI is not sufficient, because you need the implementation of storing and rendering. But I would vote against a new king of gradient, because the svg:linearGradient which is already possible in ODF, can do such things.

Has there been any discussions about the UI, e.g several buttons vs drop-down-list (like in PowerPoint), or  corner/edge cross with options, or angle wheel with snapping? Why in that dialog and not in the Interactive Gradient tool?
Comment 11 Muthu Subramanian 2015-05-21 14:41:26 UTC
@Regina: Thank you! that is really good analysis/comparisons.

a) Does ODF specify what the "angle" is? Similar to ms-office or....?
b) What we need is a way to put in diagonal fills - we could do it like a UI-property and not touch the odf formats. But, like previously mentioned, it seems like the same properties are used to store UI preferences (?)
c) Yes, I think some way to differentiate if the angle is related to object (if i can call that) and behave like ms-office does, i think it would be more preferred. (Rather than just 'diagonals')
d) The current patch did handle it for diagonals when the objects are resized...but then...
Comment 12 Muthu 2015-09-07 13:13:34 UTC
@Regina: Its seems like MS Office does this behaviour only when you pick from "Direction" drop down and not if you plainly use the angle entry (?)
Comment 13 Regina Henschel 2015-09-07 20:58:29 UTC
OOXML has the attribute 'scaled' for the element 'a:lin'. If it is set to 0, then the angle is used. If it is set to 1, then the square unit gradient is fit to the fill area of the shape. I don't know which UI tool you have to use to set or unset this switch; but anyway not the UI of PowerPoint is essential, but the file format.

LibreOffice could solve a lot of the import problems easier, if the ODF1.2. filling 'svg:LinearGradient' would be implemented.
Comment 14 Xisco Faulí 2017-07-13 12:38:36 UTC
Setting Assignee back to default. Please assign it back to yourself if you're
still working on this issue