Bug 149207 - FILESAVE background images change upon save and reload
Summary: FILESAVE background images change upon save and reload
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Draw (show other bugs)
Version:
(earliest affected)
6.3.0.4 release
Hardware: x86-64 (AMD64) All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard: target:25.8.0 target:25.2.5
Keywords: bibisected, bisected, regression
: 166688 (view as bug list)
Depends on:
Blocks: Draw-Images
  Show dependency treegraph
 
Reported: 2022-05-20 17:56 UTC by maximilian-schindler
Modified: 2025-06-09 14:18 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
sample (28.06 MB, application/vnd.oasis.opendocument.graphics)
2022-05-20 22:01 UTC, maximilian-schindler
Details
sample 2 (358.42 KB, application/vnd.oasis.opendocument.graphics)
2022-05-22 23:05 UTC, maximilian-schindler
Details
Image should not share to another (325.64 KB, image/png)
2022-06-07 10:38 UTC, Matheswaran.S
Details
The bug is still present in LibreOffice 25.2.3.2: Background images get swaped upon saving an odg file. (235.98 KB, application/vnd.oasis.opendocument.graphics)
2025-05-10 13:19 UTC, maximilian-schindler
Details

Note You need to log in before you can comment on or make changes to this bug.
Description maximilian-schindler 2022-05-20 17:56:36 UTC
Create a odg file with many pages and add a different background jpg image to each page (without borders). When you save the file and open it again, some background images are often (but not always) changed to other background images from other pages.
Comment 1 Rafael Lima 2022-05-20 18:59:46 UTC
Can you provide a sample file?

Also, what version of LibreOffice are you using? What OS?

Please, copy and paste the "Version Information" found under Help - About LibreOffice.
Comment 2 maximilian-schindler 2022-05-20 22:01:22 UTC
Created attachment 180270 [details]
sample
Comment 3 maximilian-schindler 2022-05-20 22:06:05 UTC
the background image of page one got overwriten by the image of page two in this file.

Version: 7.3.2.2 (x64) / LibreOffice Community
Build ID: 49f2b1bff42cfccbd8f788c8dc32c1c309559be0
CPU threads: 24; OS: Windows 10.0 Build 22000; UI render: Skia/Vulkan; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: threaded
Comment 4 QA Administrators 2022-05-21 03:40:08 UTC Comment hidden (obsolete)
Comment 5 maximilian-schindler 2022-05-22 23:05:28 UTC
Created attachment 180307 [details]
sample 2

Here is a more simple test file. The image of page one got overwritten by the image of page 9.
Comment 6 Matheswaran.S 2022-06-07 10:38:40 UTC
Created attachment 180616 [details]
Image should not share to another
Comment 7 Matheswaran.S 2022-06-08 07:27:25 UTC
(In reply to Matheswaran.S from comment #6)
> Created attachment 180616 [details]
> Image should not share to another

OS Linux mint 20.2
cinnamon 64-bit

OS version:5.4.0-113-generic

Steps to reproduce:

1) Open Libreoffice Draw.

2) select Drawing page.

3) create new page.

4) set different background image in separate page.

5) save the odg file

6) close proper Libreoffice Draw

7) then open the odg file 

Actual result:

jpej image displayed in  all pages.

Expected result:

All the images should be display in separate page.
Comment 8 Buovjaga 2023-01-17 10:05:51 UTC
I could reproduce this from scratch at least once, but it seems to be unreliable indeed. I even did a useless bisecting run.

Arch Linux 64-bit, X11
Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 959fbfc000d2e3167b2b57b6d11bea231993b4f0
CPU threads: 8; OS: Linux 6.1; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded Jumbo
Built on 17 January 2023
Comment 9 QA Administrators 2025-05-05 03:10:22 UTC Comment hidden (obsolete)
Comment 10 maximilian-schindler 2025-05-10 13:19:13 UTC
Created attachment 200728 [details]
The bug is still present in LibreOffice 25.2.3.2: Background images get swaped upon saving an odg file.
Comment 11 maximilian-schindler 2025-05-10 13:41:50 UTC
The bug is still present in Version 25.2.3.2.

Here is a VersionInfo:
Version: 25.2.3.2 (X86_64) / LibreOffice Community
Build ID: bbb074479178df812d175f709636b368952c2ce3
CPU threads: 16; OS: Windows 11 X86_64 (10.0 build 26100); UI render: Skia/Vulkan; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: CL threaded

I also installed LibreOffice 3.3.0 and it doesn't seem like there is even an option for custom background images. There is only an option for some predefined background images, which didn't change/swap upon saving the file. So I'm adding 'regression' as a keyword.
Comment 12 Saburo 2025-05-23 05:38:29 UTC
*** Bug 166688 has been marked as a duplicate of this bug. ***
Comment 13 Saburo 2025-05-23 05:50:02 UTC
bibisected with linux-64-6.3,
bibisected with win32-6.3
Version: 6.3.0.0.alpha0+
Build ID: ec7ba61a6164c805f5a71b077715b7e1521a2d62

author	Noel Grandin
commit ec7ba61a6164c805f5a71b077715b7e1521a2d62

simplify SfxPoolItemArray_Impl (tdf#81765 related)
Since we want to look up items by pointer, just store them in a
std::unordered_set, which allows fast find().
This dramatically simplifies most operations on this data structure.

Fix a dodgy sd test that was relying on items with the same whichid
being in the pool being in a certain order.

Change-Id: I4d79fc718f95e3083a20788be1050fbe9fca7263
Reviewed-on: https://gerrit.libreoffice.org/70881
Comment 14 Tomaz Vajngerl 2025-05-23 09:29:45 UTC
[1] is a workaround for this issue. 

The issue is that in the function XFillBitmapItem::checkForUniqueItem we call CheckNamedItem function (implemented in svx/source/xoutdev/xattr.cxx:137) and this function now doesn't make the name unique.

So if you add 2 page background images: the input to CheckNamedItem is "background" and it returns "background", for the second background it's the same: input "background" and it returns "background" even when this name was already used for the first image. I have added a test for this to [1], which checks exactly this. 

The issue with the same name is then that the ODP export filter uses that unique name to determine if the background image needs to be written to the document or has already been written by checking the name and yeah - if two images have the same name... boom. 

The workaround is that we don't enter "background" for the image name, so if the input string is empty, the CheckNamedItem will automatically produce a new unique name and voila - no more uniqueness violations - at least in this case.

[1] https://gerrit.libreoffice.org/c/core/+/185699
Comment 15 Commit Notification 2025-05-24 01:30:41 UTC
Tomaž Vajngerl committed a patch related to this issue.
It has been pushed to "master":

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

tdf#149207 fix image not getting a unique name

It will be available in 25.8.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 2025-05-24 03:52:56 UTC
Tomaž Vajngerl committed a patch related to this issue.
It has been pushed to "libreoffice-25-2":

https://git.libreoffice.org/core/commit/02ad260a8d0a32924b6cca1d4a7e1e8bac34dc7f

tdf#149207 fix image not getting a unique name

It will be available in 25.2.5.

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 Tomaz Vajngerl 2025-06-09 14:18:18 UTC
I guess this is fixed now...