Bug 114552 - Improve image anchoring in Calc
Summary: Improve image anchoring in Calc
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Samuel Mehrbrodt (allotropia)
URL:
Whiteboard: target:6.1.0
Keywords:
Depends on:
Blocks: Calc-Images
  Show dependency treegraph
 
Reported: 2017-12-19 09:35 UTC by Samuel Mehrbrodt (allotropia)
Modified: 2024-03-25 12:33 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Samuel Mehrbrodt (allotropia) 2017-12-19 09:35:39 UTC
When inserting an image in Calc, and changing its anchor to "Cell", the image is resized when the column/row is resized.

However, the aspect ratio is not kept and the image gets distorted.

When resizing a cell, the image inside should be resized keeping the aspect ratio.
Comment 1 Buovjaga 2017-12-25 19:41:25 UTC
Samuel: what do you think of bug 46868 vs. bug 54769?
Comment 2 Samuel Mehrbrodt (allotropia) 2018-01-23 14:07:02 UTC
(In reply to Buovjaga from comment #1)
> Samuel: what do you think of bug 46868 vs. bug 54769?

Hm both bugs sound valid.
I like that images get scaled automatically with the cell, but would suggest the following improvements:

* Always keep the aspect ratio of the image (as described in comment 0)
* Only resize the image if it fits into the cell. If it's already larger than the cell, ignore it
* Add an option to *not* resize with the cell (as suggested in bug 46868). Maybe a third anchor type is the way to go, like "Anchor to cell, no automatic resize"
Comment 3 Samuel Mehrbrodt (allotropia) 2018-02-08 12:13:46 UTC
(In reply to Samuel Mehrbrodt (CIB) from comment #2)
> * Add an option to *not* resize with the cell (as suggested in bug 46868).
> Maybe a third anchor type is the way to go, like "Anchor to cell, no
> automatic resize"

For comparison, Excel also has three modes, namely:
* Dependent on cell position and size (matching our current cell anchoring)
* Dependent on cell position (default, no match in LO)
* Independent on cell position and size (matching our page anchoring)
Comment 4 Regina Henschel 2018-02-09 19:44:32 UTC
Hi Samuel, I have read in https://gerrit.libreoffice.org/#/c/49490/, that you are going to introduce a new attribute, "This adds a new loext:resize-with-cell attribute for ODF to the draw:frame element."

Please describe, how this new attribute will interact with already existing attributes
19.627 table:end-cell-address
19.632 table:end-x
19.633 table:end-y

The UI in Excel and Gnumeric have these settings:
A
Don't move or size with cells (Excel), Absolute size and position (Gnumeric).
That is "anchor to page" in LibreOffice.
B
Move and size with cells (Excel), Move and resize with cells (Gnumeric).
C
Move but don't size with cells(Excel), Move with cells (Gnumeric).

Gnumeric sets the attribute "table:end-cell-address" in case of B in ODF. So Gnumeric solves the size problem without introducing a new attribute.

From my understanding, you get the case C, if no additional attribute is used on the frame. Then the size is determined by svg:width and svg:height. Only LibreOffice does currently not respect the fixed size.
Comment 5 Samuel Mehrbrodt (allotropia) 2018-02-12 15:58:01 UTC
(In reply to Regina Henschel from comment #4)
> Hi Samuel, I have read in https://gerrit.libreoffice.org/#/c/49490/, that
> you are going to introduce a new attribute, "This adds a new
> loext:resize-with-cell attribute for ODF to the draw:frame element."
> 
> Please describe, how this new attribute will interact with already existing
> attributes
> 19.627 table:end-cell-address
> 19.632 table:end-x
> 19.633 table:end-y
> 
> The UI in Excel and Gnumeric have these settings:
> A
> Don't move or size with cells (Excel), Absolute size and position (Gnumeric).
> That is "anchor to page" in LibreOffice.
> B
> Move and size with cells (Excel), Move and resize with cells (Gnumeric).
> C
> Move but don't size with cells(Excel), Move with cells (Gnumeric).
> 
> Gnumeric sets the attribute "table:end-cell-address" in case of B in ODF. So
> Gnumeric solves the size problem without introducing a new attribute.
> 
> From my understanding, you get the case C, if no additional attribute is
> used on the frame. Then the size is determined by svg:width and svg:height.
> Only LibreOffice does currently not respect the fixed size.

Hi Regina, saw your comment just now.
Will read the docs and see if I can implement it the same way as gnumeric does.
Is there any definition in ODF when the table:end-cell-address is to be used?
Comment 6 Thomas Lendo 2018-02-12 19:44:18 UTC
I support the ideas in comment 2 with the addition of 3 possible options like Excel, described in comment 3. I set the bug to NEW despite that I think it duplicated the other 2 bugs. If this issue is fixed, the other 2 will be also fixed. :)
Comment 7 Samuel Mehrbrodt (allotropia) 2018-02-27 07:37:53 UTC
(In reply to Samuel Mehrbrodt (CIB) from comment #5)
> Hi Regina, saw your comment just now.
> Will read the docs and see if I can implement it the same way as gnumeric
> does.
> Is there any definition in ODF when the table:end-cell-address is to be used?

So I found out that table:end-cell-address etc was always written before. I now changed the patch to write it only when "resize with cell" is selected. So it's now the same as in Gnumeric (Tested that Gnumeric recognizes our three options correctly).
Comment 8 Commit Notification 2018-03-06 14:46:09 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=acf0bad4e2b8c3c43aaaee8312c8a61d3552fcc2

tdf#114552 Add a third anchor type for calc graphics

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Commit Notification 2018-03-06 14:49:36 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=782d504649ccb2dbe1a55d7abdf5c532b62f5c39

tdf#114552 Add unit test for ODF Import of anchor types

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2018-03-12 23:24:10 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=4f29ce6a67b81e7f28e1c86d60ff15ec1d180661

tdf#114552 Improve image scaling in Calc

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2018-03-13 07:10:55 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=1a7444ed69a68696b05feb3f3618b6704a140ba6

tdf#114552 Convert anchor toggle to anchor menu

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 12 Samuel Mehrbrodt (allotropia) 2018-03-13 07:11:39 UTC
I consider this fixed now.
Please test the changes and report back.
Comment 13 Commit Notification 2018-03-13 13:17:24 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=6ae7b9d40ca24c9c9fbad6346a4dd9112894dc49

tdf#114552 Also reduce the anchor offset when shrinking images

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.