Bug 139083 - Cell anchored shape is always resized if copy&paste to a different sized range
Summary: Cell anchored shape is always resized if copy&paste to a different sized range
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Regina Henschel
URL:
Whiteboard: target:7.6.0
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-19 23:58 UTC by Regina Henschel
Modified: 2023-12-08 10:51 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
sheet with different row heights to test copy&paste of shape (9.02 KB, application/vnd.oasis.opendocument.spreadsheet)
2020-12-19 23:58 UTC, Regina Henschel
Details
document for testing (14.46 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-04-12 15:54 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Regina Henschel 2020-12-19 23:58:50 UTC
Created attachment 168348 [details]
sheet with different row heights to test copy&paste of shape

Open attached document.
Make sure the shape in B2:B3 is anchored "To Cell" and not "To Cell (resize with cell)".
Copy range B2:B3 including the shape.
Paste to B5.
Notice, that shape is resized to the smaller height of B5:B6.

Expected: Shape is anchored to B5 and keeps its size.

The error seems to be in ScDrawLayer::CopyFromClip. It assumes, that every cell anchored object has to resize. That was true in OpenOffice (and the logic in the method has not changed since that time), but is no longer true in LibreOffice. OpenOffice had only two anchor types: "page" and "cell", where "cell" included "resize". But LibreOffice has three anchor types "page", "cell without resize" and "cell with resize" and therefor needs a new logic for "resize" in copy&paste.
Comment 1 m_a_riosv 2020-12-20 16:17:45 UTC
Confirmed
Version: 7.2.0.0.alpha0+ (x64)
Build ID: e97a81e94511b52987a50b7bdb72c922899da588
CPU threads: 4; OS: Windows 10.0 Build 20180; UI render: Skia/Vulkan; VCL: win
Locale: es-ES (es_ES); UI: es-ES Calc: CL
Comment 2 QA Administrators 2023-04-08 03:25:13 UTC Comment hidden (obsolete)
Comment 3 Regina Henschel 2023-04-08 12:55:57 UTC
The problem still exists in Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 23bd3bd10e74b0c23c2654d02d7d830e7693adac
CPU threads: 8; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: de-DE (en_US); UI: en-US
Calc: CL threaded
Comment 4 Regina Henschel 2023-04-08 16:57:33 UTC
Started, see https://gerrit.libreoffice.org/c/core/+/150161
Comment 5 Regina Henschel 2023-04-12 15:54:56 UTC
Created attachment 186623 [details]
document for testing

Unfortunately it is more complicate than I have thought. Open attached document. The left red shape is anchored "To page", the center blue shape is anchored "To cell" and the right green shape is anchored "To cell (resize with cell).

Copy the yellow cells to clipboard and then go to the other sheets and paste it somewhere there. You can see, that the red and green shape do not keep size. And that the green and blue shape are at wrong position.

It is questionable whether a shape anchored to page should be copied at all, but shapes anchored to cell should be positioned to the target cell similar as they were positioned in the source cell and only a shape anchored "To cell (resize with cell)" may resize at all.
Comment 6 Commit Notification 2023-05-07 08:57:09 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/dfb0d118f6b23730bc632885eb4703a37eeaec16

tdf#139083 Only resize if 'resize with cell' is set

It will be available in 7.6.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 7 Regina Henschel 2023-05-07 09:00:36 UTC
Further unit tests will be in follow up commits
Comment 8 BogdanB 2023-05-07 18:29:07 UTC
Verified with 7.6
Good in
Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 4f93995f2262cde0b16bacc83f4ba3c6161ada7f
CPU threads: 16; OS: Linux 5.19; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded

Bad in
Version: 7.5.3.2 (X86_64) / LibreOffice Community
Build ID: 9f56dff12ba03b9acd7730a5a481eea045e468f3
CPU threads: 16; OS: Linux 5.19; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 9 Commit Notification 2023-05-08 20:21:06 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/43f72183ce12835f6a3a5185e708a00e968d27da

tdf#139083 Further unit tests for commit dfb0d118

It will be available in 7.6.0.

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

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