Bug 133299 - Option to set the default anchor mode for images in Calc
Summary: Option to set the default anchor mode for images in Calc
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.4.1.2 release
Hardware: All All
: medium enhancement
Assignee: Thierry E
URL:
Whiteboard: target:7.5.0 target:7.4.1
Keywords:
Depends on:
Blocks: Anchor-and-Text-Wrap
  Show dependency treegraph
 
Reported: 2020-05-23 06:43 UTC by zzz
Modified: 2022-10-15 18:47 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments
patch to anchor to cell pasted image in Calc (985 bytes, patch)
2021-12-10 13:51 UTC, Thierry E
Details

Note You need to log in before you can comment on or make changes to this bug.
Description zzz 2020-05-23 06:43:42 UTC
In current version, the anchor of a newly pasted image is fixed to "To Page". I want to change that default behaviour to "anchor To Cell" in the Options menu, with a new entry like: "default anchor mode when insert/paste/create image". For other types of objects(graphics,textboxes,videos etc.), I'm not sure yet of whether to share the same settings is better or not, so suggest to make each of them independently configurable (to avoid unexpected behaviour).
Also, when several images are "grouped" (object group, not the table group), the anchor mode of this new object should also honor this default setting.

Reason: For me, I always and only need "anchor To Cell". I often paste a lot of images. Forgetting to change even just one image from "To Page" to "To Cell" results in a disaster because whenever I resize or insert or delete some rows/columns or cells, the image will become orphaned on a totally different place from where I originally pasted it. This often happens somewhere far away from the visible window, found only a long time after, impossible to find when it had happened, which backup file is correct. So it is not solvable with the usual undo feature. And worse is that even if I found such an out-of-place image, I don't know where that image belonged to, so my whole work is instantly trashed. I personally never needed "anchor To Page", but some other people might, so the best solution is to make the default settings configurable. Another annoying bug/feature of current version is that even if I had anchored all images to cells, if I group some of them, the new object goes back to "anchor To Page", which is very easily forgotten to re-correct.
Excel already has the ability for user to set default paste anchor mode to "To Cell".
Comment 1 zzz 2020-06-16 03:56:58 UTC
To make it clear, this request is strictly only for Calc. I'm not sure what I want in other apps such as Writer or, um, the slides? app, but I'm quite certain that I would need them to be independently configurable. Please don't try to "integrate" them. (Although an "integration" in a different sense, to collect all settings into a single 2-dimensional matrix, would be very useful. Columns:apps; Rows:optiontrees)
Comment 2 Heiko Tietze 2020-09-09 10:18:21 UTC
Image handling was improved a lot recently and default anchoring is now To Cell. Nevertheless I can imagine some users might want to change the default. And since we have a similar request for Writer in bug 99646 it should be possible in Calc too.
Comment 3 Samuel Mehrbrodt (allotropia) 2020-09-09 10:26:28 UTC
Agree, when selecting a different value in the insert image dialog for anchoring, this should be remembered.

But I don't understand this bug, as the default is already "to cell" (as Heiko pointed out).
Comment 4 zzz 2020-09-09 12:32:14 UTC
Sorry that the reproducing condition was't clear enough.
The "To Page" mode happens when I PASTE an image from clipboard into the spreadsheet by either
* ctrl+V
* right-click|(context menu)|Paste

Re-confirmed that the symptom persists in Calc version 7.0.1.2 (x64) too.
(for Menu|Insert|Image|Anchor, it does already default to "To Cell")
Comment 5 zzz 2020-09-09 12:50:09 UTC
Did a little more experiments (Windows 10; Calc version 7.0.1.2 (x64)).
(A)Image copied from external apps (Firefox screenshot; IrfanView's Edit|Copy)
  Paste to Calc by
  * ctrl+V
  * right-click|(context menu)|Paste
  * Main menu|Edit|Paste
  All set the image to "To Page".
  Reproducibility 100%.

(B)Image copied from Calc
  Paste to Calc by
  * ctrl+V
  * right-click|(context menu)|Paste
  * Main menu|Edit|Paste
  All preserved the source image's anchor mode.
Comment 6 Samuel Mehrbrodt (allotropia) 2020-09-09 13:11:11 UTC
Ah so then we should set the default to be "To cell" when pasting images too.
Missed that when I changed the default for the insert image dialog.
Comment 7 Zoom 2021-11-02 08:40:16 UTC
Still relevant for pasting and drag-and-dropped images in the latest release. Currently it defaults to "to Page".

+ Would be nice to have as a configurable option.
+ A hotkey for changing anchoring mode could be useful.
Comment 8 Thierry E 2021-12-10 13:51:44 UTC
Created attachment 176843 [details]
patch to anchor to cell pasted image in Calc

The attached proposed patch for LibreOffice Calc 7.4 (dev version) anchors pasted image to Cell instead of default to Page.
Tested on xubuntu 20.04 including saving and reopening the .ods file, and also tested on xubuntu 20.04 that this saved file can be opened in LibreOffice Calc 7.2.3.2 and the image is correctly shown as anchored to Cell in that version too.
Comment 9 Samuel Mehrbrodt (allotropia) 2022-08-08 20:13:11 UTC
(In reply to Thierry E from comment #8)
> Created attachment 176843 [details]
> patch to anchor to cell pasted image in Calc
> 
> The attached proposed patch for LibreOffice Calc 7.4 (dev version) anchors
> pasted image to Cell instead of default to Page.
> Tested on xubuntu 20.04 including saving and reopening the .ods file, and
> also tested on xubuntu 20.04 that this saved file can be opened in
> LibreOffice Calc 7.2.3.2 and the image is correctly shown as anchored to
> Cell in that version too.

Hi Thierry,
thanks a lot for your patch! And sorry it took so long.

I uploaded your patch to Gerrit and made sure it works (it does): https://gerrit.libreoffice.org/c/core/+/138005

Before merging, we need your license statement as described here: https://wiki.documentfoundation.org/Development/Developers#License_Statements

Can you please send that statement? Thanks!
Comment 10 Thierry E 2022-08-09 09:27:35 UTC
All of my past & future contributions to LibreOffice may be licensed under the MPLv2/LGPLv3+ dual license.
Comment 11 Thierry E 2022-08-09 09:28:27 UTC
Thank you Samuel!
Comment 12 Samuel Mehrbrodt (allotropia) 2022-08-11 05:18:42 UTC
(In reply to Thierry E from comment #10)
> All of my past & future contributions to LibreOffice may be licensed under
> the MPLv2/LGPLv3+ dual license.

Thanks!
Can you please quickly verify that I spelled your name correctly in the commit message? I guessed that from the email address. 

https://gerrit.libreoffice.org/c/core/+/138005/1//COMMIT_MSG
Comment 13 Thierry E 2022-08-11 12:07:39 UTC
Can you please remove "al" (these were initials which are now obsolete) from my name? Thanks!
Comment 14 Commit Notification 2022-08-15 11:18:00 UTC
Thierry Emery committed a patch related to this issue.
It has been pushed to "master":

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

tdf#133299 Anchor pasted images 'to cell' by default

It will be available in 7.5.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 15 Commit Notification 2022-08-17 06:29:31 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/45076f7f3a661ba18c4821147c0d6b3956603d86

tdf#133299: sw: Add UItest

It will be available in 7.5.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 16 Commit Notification 2022-08-18 06:15:35 UTC
Thierry Emery committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

https://git.libreoffice.org/core/commit/77a0a504540c36159271622fda1be47d4f6cb180

tdf#133299 Anchor pasted images 'to cell' by default

It will be available in 7.4.1.

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 17 zzz 2022-10-15 18:47:45 UTC
Tested on
Version: 7.4.1.2 (x64) / LibreOffice Community
Build ID: 3c58a8f3a960df8bc8fd77b461821e42c061c5f0
CPU threads: 4; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: ja-JP (ja_JP); UI: en-US
Calc: CL

Results:
1. Image copied from external apps (Firefox screenshot; IrfanView's Edit|Copy)
  Paste to Calc by
  * ctrl+V
  * right-click|(context menu)|Paste
  * Main menu|Edit|Paste
  will now all set the image to "To Cell", as expected.
  So my problem has been cured, thank you for the remedy.
2. However, three issues remain:
  2-(1) If you paste the image to Calc by
    * right-click|(context menu)|Paste Special|Paste Special|
    * ctrl+shift+V
    and choose either
    * Bitmap Image (BMP)
    * Portable Network Graphics (PNG)
    then the image's anchor mode is again "To Page".
    Not a big problem for me, but the inconsistency is confusing.
  2-(2) I found another related problem:
    If you drag&drop an image file from the Windows File Manager onto
    Calc's window (sheet), then again the image's anchor mode is "To Page".
    The same symptom happens also when you drag&drop an image object
    from Microsoft Excel 2000 onto Calc's window (sheet).
    I apologize that I, a mere user, failed to notice thus could not report
    this case, but why didn't any developer ask what to do with such case?
    Honestly, I am very frustrated that dear developers, experts of this
    product, do not imagine or revisit other combinations of
    "paste image" and "paste object", once they receive a bug report.
    Users can only report an illustrative example, not meant to enumerate
    all possible situations.
  2-(3) The subject of this topic: "Option to set the default anchor mode"
    seems to be not implemented yet (at least nothing mentioned in the
    Release Note). I can withdraw that part of request, but as predicted,
    there are other user(s) who like to configure/switch the anchoring mode,
    so technically the topic is still unresolved.