tdf#67544 Embed transition sound when Link is unchecked

The Link checkbox in the sound file dialog was being ignored.
When the user selects a sound file with Link unchecked, we now
call avmedia::EmbedMedia() to copy the sound into the document
package, matching the behavior of Insert -> Audio or Video.

Change-Id: Id1c441ecd47c5fbc5bd285912fbf13a6c8346f1d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200083
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@collabora.com>
This commit is contained in:
Zeki Bildirici
2026-02-26 09:38:17 +01:00
committed by Samuel Mehrbrodt
parent 78dfcd5f5d
commit 507e1aeadf
@@ -54,6 +54,9 @@
#include <algorithm>
#include <avmedia/mediaitem.hxx>
#include <sfx2/objsh.hxx>
using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
@@ -692,6 +695,24 @@ void SlideTransitionPane::openSoundFileDialog()
aFileDialog.Execute() == ERRCODE_NONE )
{
OUString aFile = aFileDialog.GetPath();
bool bEmbedded = false;
// tdf#67544: Embed the sound file if "Link" is not checked
if (!aFileDialog.IsInsertAsLinkSelected())
{
SfxObjectShell* pShell = SfxObjectShell::Current();
if (pShell)
{
OUString aEmbeddedURL;
bool bSuccess = ::avmedia::EmbedMedia(pShell->GetModel(), aFile, aEmbeddedURL);
if (bSuccess && !aEmbeddedURL.isEmpty())
{
aFile = aEmbeddedURL;
bEmbedded = true;
}
}
}
std::vector<OUString>::size_type nPos = 0;
bValidSoundFile = lcl_findSoundInList( maSoundList, aFile, nPos );
@@ -699,6 +720,15 @@ void SlideTransitionPane::openSoundFileDialog()
{
bQuitLoop = true;
}
else if( bEmbedded )
{
// Embedded URL: add directly to sound list, skip gallery
maSoundList.push_back( aFile );
lcl_FillSoundListBox( maSoundList, *mxLB_SOUND );
nPos = maSoundList.size() - 1;
bValidSoundFile = true;
bQuitLoop = true;
}
else // not in sound list
{
// try to insert into gallery