Bug 67274 - Gallery: Do not link inserted images
Summary: Gallery: Do not link inserted images
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
4.2.0.0.alpha0+ Master
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: target:4.2.0 Confirmed:4.2.0.0.beta1:...
Keywords: difficultyInteresting, easyHack, skillCpp, topicCleanup
Depends on: 69079
Blocks: Gallery
  Show dependency treegraph
 
Reported: 2013-07-24 20:49 UTC by Samuel Mehrbrodt (allotropia)
Modified: 2024-01-26 07:42 UTC (History)
9 users (show)

See Also:
Crash report or crash signature:


Attachments
An ODT file with a custom background (209.27 KB, application/vnd.oasis.opendocument.text)
2022-07-15 21:52 UTC, Hossein
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Samuel Mehrbrodt (allotropia) 2013-07-24 20:49:47 UTC
Go to Gallery->Backgrounds
Right-click on a background and choose Insert->Background->Page or Paragraph

The page style has then a link like this:
<style:background-image xlink:href="../../../../opt/libreoffice4.0/program/../share/gallery/www-back/ice-blue.jpg" xlink:type="simple" xlink:actuate="onLoad"/>

and the paragraph style looks like this in the document structure:
<style:background-image xlink:href="../../../../opt/libreoffice4.0/program/../share/gallery/www-back/ice-light.jpg" xlink:type="simple" xlink:actuate="onLoad"/>

Instead of being linked, these images should be embedded in the document structure. Currently you only have to move the document to a different folder and the image won't load anymore.
Comment 1 Tomaz Vajngerl 2013-07-25 08:44:00 UTC
Confirmed.

Linking is always "dangerous" and I think any linking to gallery images should be removed. Additionally if a user tries to link to any external resource, he should be warned about the consequences of his action.
Comment 2 Samuel Mehrbrodt (allotropia) 2013-07-27 12:39:23 UTC
You are right, it should not be possible to link to gallery images. We discussed this also on the UX-Advise list: http://nabble.documentfoundation.org/Libreoffice-ux-advise-Remove-outdated-Gallery-images-tp4067129p4067444.html

I changed the title accordingly.
Comment 3 Commit Notification 2013-07-29 13:13:40 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "master":

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

fdo#67274 Always embed images from gallery



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 4 Samuel Mehrbrodt (allotropia) 2013-08-04 11:24:32 UTC
The mentioned commit fixes this problem only partly.
The Problem described in Comment 0 still exists.
Comment 5 Samuel Mehrbrodt (allotropia) 2013-09-22 09:23:53 UTC
Can someone else please have a look at it?
The Background URL is set here: http://opengrok.libreoffice.org/xref/core/svx/source/gallery2/galbrws2.cxx#372

Then the Image gets inserted here: http://opengrok.libreoffice.org/xref/core/sw/source/ui/shells/basesh.cxx#2662

Somewhere in between the SvxBrushItem (the background) is created as a linked graphic and that must be changed. But I don't know where that happens.

Can someone give a hint or take this over?

I mark this as MAB because it makes Documents depend on hard-coded image paths.
Comment 6 Samuel Mehrbrodt (allotropia) 2013-11-01 15:30:59 UTC
(Adding the Dev list to CC)
I'd need some help with the Fix for this bug. Can someone have a look at Comment 5 and help me with this?
Comment 7 Michael Meeks 2013-11-05 12:31:47 UTC
No idea but I assume code like this:

    706                 const Graphic aGrf( pGalleryItem->GetGraphic() );
    707 
    708                 if ( nSelType & nsSelectionType::SEL_GRF )
    709                     rSh.ReRead( aGrfName, aFltName, &aGrf );
    710                 else
    711                     rSh.Insert( aGrfName, aFltName, aGrf );

Creates that Graphic - and that (somehow) the GraphicObject that gets created from that gets tagged as linked somehow - perhaps chasing rSh.Insert() and re-read to see what parameters they take might be useful (?)
Comment 8 Robinson Tryon (qubit) 2013-11-24 05:43:59 UTC
CONFIRMED on LO 4.2.0.0.beta1 + Ubuntu 12.04.3

REPRO:
- Open LibreOffice
- Tools -> Gallery -> Backgrounds
- Right-click on aqua (first background in list) and choose: Insert as Background -> Page
- Right-click on the changed page background and select 'Page'
- Select 'Background' tab
- Under the 'File' section, the 'Link' checkbox is checked, and the filepath listed below the 'Browse' button is to a file in 'share/gallery' on disk.

EXPECTED:
- The background would be embedded in the file.
- The 'Link' checkbox would be unchecked

Adding repro information to whiteboard
Comment 9 Christian Lohmaier 2014-01-16 14:08:15 UTC
not a MAB in my opionion.. 
* has always been that way for decades, 
* graphic as page backgrounds are not a very common usecase
* easy workaround/manual fix (Goto Format|Page → Background and uncheck [ ] Link)

Not saying that this shouldn't be fixed, but that's not so important to have for 4.2.0 (4.2.x is enough IMHO)
Comment 10 Björn Michaelsen 2014-01-17 09:58:35 UTC Comment hidden (obsolete)
Comment 11 Stéphane Guillou (stragu) 2014-02-13 23:19:22 UTC
Moving to mab4.1 (Bug 60270) because:
- 4.0 reached EOL (End Of Life)
- bug confirmed in later version
Comment 12 tommy27 2014-05-04 08:41:56 UTC
if issue is still present in 4.2.x current releases please move it to the mab4.2 list (Bug 65675) since 4.1.x is END OF LIFE
Comment 13 Joel Madero 2014-05-23 02:35:10 UTC
Removing from MAB - this is an enhancement and does not belong on mab list. Marking as enhancement also. The product works as designed, the request is just to change the design which by definition is an enhancement.
Comment 14 Xisco Faulí 2016-09-15 11:28:29 UTC
@Jan: it sounds like an easyhack. isn't it?
Comment 15 jani 2016-09-15 11:33:34 UTC
(In reply to Xisco Faulí from comment #14)
> @Jan: it sounds like an easyhack. isn't it?
it sure is, and a good one.
Comment 16 Hossein 2022-07-15 21:52:52 UTC
Created attachment 181288 [details]
An ODT file with a custom background

I am using LibreOffice 7.3 Writer.

Version: 7.3.0.3 / LibreOffice Community
Build ID: 0f246aa12d0eee4a0f7adcefbf7c878fc2238db3
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

I no longer see "background" tab when opening "Gallery", which is now available from the sidebar. The menu option for "Gallery" is currently in:

    Insert > Media > Gallery

On the other hand, it is possible to set a custom background using this method:

https://ask.libreoffice.org/t/writer-custom-background-size-image-as-page-background-unwanted-images-are-not-deleted/44138/6

    Styles > Default Page Style > (Right click) > Modify > Area > Image

When I save the file as ODT, I see these in styles.xml:

...
<draw:fill-image draw:name="Maple_20_Leaves" draw:display-name="Maple Leaves" xlink:href="Pictures/1000000000000200000002009F9CDFF76A1A9DB9.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
...
<style:background-image xlink:href="Pictures/1000000000000200000002009F9CDFF76A1A9DB9.jpg" xlink:type="simple" xlink:actuate="onLoad"/>

The jpeg file is stored in the Pictures folder. It means that the files is now embedded in the document.

Thus, I consider this issue fixed.
Comment 17 Regina Henschel 2022-07-15 22:29:27 UTC
It is not really solved. Follow up bug report is bug 127322.
Test it in Writer with a Gallery theme, that has images.
Comment 18 Hossein 2022-07-19 11:20:15 UTC
(In reply to Regina Henschel from comment #17)
> It is not really solved. Follow up bug report is bug 127322.
> Test it in Writer with a Gallery theme, that has images.
You are right. I am reopening the issue.
For testing, "Gallery" > "Bullets" can be used.
Comment 19 Stéphane Guillou (stragu) 2023-10-01 23:40:37 UTC
Reproduced in libreoffice-4.3.7.1 but it has been fixed since at least libreoffice-4.4.0.0.beta1.
Tested back then with inserting a page background from the Background gallery, but can be tested in a recent trunk build with the Bullet gallery.
Files are included in the file's Picture directory instead of being linked.

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: e9a0c97de95688b2f86bbb4dd8c823af5442401c
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Couldn't find the fixing commit.