Apache OpenOffice (AOO) Bugzilla – Issue 95421
ODT: Media type for png thumbnail not set.
Last modified: 2022-10-28 12:54:28 UTC
1. Create a text document 2. Create some content (d t F3) 3. Store as ODT 4. Rename the ODT to ODT.zip 5. take a look into the META-INF/manifest.xml The media type of "Thumbnains/thumbnail.png" is empty ("") shouldn't it be 'image/png'?
*** Issue 30870 has been marked as a duplicate of this issue. ***
The media type is missing in .ods, .odp, and .odg too. I've tested with OOo3.4 and a AOO4.0 buildbot version.
The mime type is never set in SfxObjectShell::GenerateAndStoreThumbnail http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/doc/objstor.cxx?revision=1413471&view=markup#l3695 The fix is rather trivial: sal_Bool SfxObjectShell::GenerateAndStoreThumbnail( sal_Bool bEncrypted, sal_Bool bSigned, sal_Bool bIsTemplate, const uno::Reference< embed::XStorage >& xStor ) { RTL_LOGFILE_CONTEXT( aLog, "sfx2 (mv76033) SfxObjectShell::GenerateAndStoreThumbnail" ); bIsInGenerateThumbnail = sal_True;//optimize thumbnail generate and store procedure to improve odt saving performance, i120030 sal_Bool bResult = sal_False; try { uno::Reference< embed::XStorage > xThumbnailStor = xStor->openStorageElement( ::rtl::OUString::createFromAscii( "Thumbnails" ), embed::ElementModes::READWRITE ); if ( xThumbnailStor.is() ) { uno::Reference< io::XStream > xStream = xThumbnailStor->openStreamElement( ::rtl::OUString::createFromAscii( "thumbnail.png" ), embed::ElementModes::READWRITE ); if ( xStream.is() && WriteThumbnail( bEncrypted, bSigned, bIsTemplate, xStream ) ) { uno::Reference< beans::XPropertySet > xPropSet( xStream, uno::UNO_QUERY ); if ( xPropSet.is() ) xPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), uno::makeAny( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "image/png" ) ) ) ); uno::Reference< embed::XTransactedObject > xTransact( xThumbnailStor, uno::UNO_QUERY_THROW ); xTransact->commit(); bResult = sal_True; } } } catch( uno::Exception& ) { } bIsInGenerateThumbnail = sal_False;//optimize thumbnail generate and store procedure to improve odt saving performance, i120030 return bResult; }
(In reply to comment #2) > The media type is missing in .ods, .odp, and .odg too. This affects all document types based in the old sfx2 module (Writer, Draw/Impress, Calc, Math).
"arielch" committed SVN revision 1462756 into trunk: i95421 - Set MediaType when storing thumbnail.png
Fixed on trunk
Although the provision of a media-type is a "should," the <manifest:file-entry> manifest:media-type attribute is required by the schema for ODF 1.2 META-INF/manifest.xml. This is apparently the justification for manifest:media-type="", a common practice despite the absence of any such media type. Note that the media type of optional package part "Thumbnails/thumbnail.png" is always known. It is required to be a PNG by the ODF 1.2 specification. I also assume that software (other than an ODF consumer) that makes the thumbnail available probably does not bother with processing META-INF/manifest.xml in order to use it. I heartily agree that "image/png" is preferable to "" but I wonder who will check this on input. It seems that a practical verification of ODF package conformance would need to accept either media-type value when the preview image is present and also require that the thumbnail be a valid PNG as well.