sd/qa/unit/export-tests.cxx     |    3 +--
 xmloff/source/draw/ximpshap.cxx |   16 ++++++++++++++--
 2 files changed, 15 insertions(+), 4 deletions(-)

New commits:
commit cde91f936d8b569278f63205e942ea3ded5907b3
Author:     Aron Budea <aron.bu...@collabora.com>
AuthorDate: Tue Feb 11 11:57:22 2025 +1030
Commit:     Aron Budea <aron.bu...@collabora.com>
CommitDate: Wed Feb 12 11:00:44 2025 +0100

    tdf#165181 Don't overwrite guessed media MIME type with default on load
    
    MIME types for media can be the default one,
    'application/vnd.sun.star.media'.
    In ODFs coming from old versions, for media unsupported
    at the time, this default MIME type was used, and is read
    when opening them in new versions.
    
    MIME type is also guessed more accurately from the URI
    (file name and extension), but was overwritten by the saved
    MIME type. When using the UI, it is again overwritten by
    the guessed MIME type, but not when using '--convert-to'.
    
    This can cause a problem when saving ODPs to PPTX, PP will
    consider these files corrupted.
    
    Started happening after bc72514f90d90e1ab3fed8167663e835edf03508.
    
    Change-Id: Icd95b06d54154f3b533840f8a5f381400f2e6108
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181399
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index a57dc111b0d2..9015eca50e09 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -354,8 +354,7 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testMediaEmbedding)
     CPPUNIT_ASSERT_MESSAGE("missing media object", pMediaObj != nullptr);
     CPPUNIT_ASSERT_EQUAL(u"vnd.sun.star.Package:Media/button-1.wav"_ustr,
                          pMediaObj->getMediaProperties().getURL());
-    CPPUNIT_ASSERT_EQUAL(u"application/vnd.sun.star.media"_ustr,
-                         pMediaObj->getMediaProperties().getMimeType());
+    CPPUNIT_ASSERT_EQUAL(u"audio/x-wav"_ustr, 
pMediaObj->getMediaProperties().getMimeType());
 }
 
 CPPUNIT_TEST_FIXTURE(SdExportTest, testFillBitmapUnused)
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index f6bec74799ab..6b742be164ae 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -3097,8 +3097,20 @@ void SdXMLPluginShapeContext::endFastElement(sal_Int32 
nElement)
         {
             // in case we have a media object
             xProps->setPropertyValue( u"MediaURL"_ustr, uno::Any(maHref));
-
-            xProps->setPropertyValue(u"MediaMimeType"_ustr, 
uno::Any(maMimeType) );
+            // could be from old times when a format was unsupported
+            // likely already guessed a possibly more accurate MIME type from 
MediaURL, don't override
+            bool bUpdateMimeType = false;
+            if (maMimeType != AVMEDIA_MIMETYPE_COMMON)
+                bUpdateMimeType = true;
+            else
+            {
+                OUString aExistingMimeType;
+                xProps->getPropertyValue(u"MediaMimeType"_ustr) >>= 
aExistingMimeType;
+                if (aExistingMimeType.isEmpty())
+                    bUpdateMimeType = true;
+            }
+            if (bUpdateMimeType)
+                xProps->setPropertyValue(u"MediaMimeType"_ustr, 
uno::Any(maMimeType) );
 
             for (const auto& rParam : maParams)
             {

Reply via email to