Issue 95421 - ODT: Media type for png thumbnail not set.
Summary: ODT: Media type for png thumbnail not set.
Alias: None
Product: Writer
Classification: Application
Component: save-export (show other issues)
Version: DEV300m30
Hardware: All All
: P3 Trivial (vote)
Target Milestone: 4.0.0
Assignee: Ariel Constenla-Haile
QA Contact:
Keywords: odf_validation
: 30870 (view as issue list)
Depends on:
Reported: 2008-10-24 14:37 UTC by lars.langhans
Modified: 2013-03-30 15:48 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Note You need to log in before you can comment on or make changes to this issue.
Description lars.langhans 2008-10-24 14:37:59 UTC
1. Create a text document
2. Create some content (d t F3)
3. Store as ODT
4. Rename the ODT to
5. take a look into the META-INF/manifest.xml 

The media type of "Thumbnains/thumbnail.png" is empty ("") shouldn't it be
Comment 1 Regina Henschel 2013-03-29 17:32:39 UTC
*** Issue 30870 has been marked as a duplicate of this issue. ***
Comment 2 Regina Henschel 2013-03-29 20:53:48 UTC
The media type is missing in .ods, .odp, and .odg too. I've tested with OOo3.4 and a AOO4.0 buildbot version.
Comment 3 Ariel Constenla-Haile 2013-03-30 13:30:16 UTC
The mime type is never set in SfxObjectShell::GenerateAndStoreThumbnail

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 ( )
            uno::Reference< io::XStream > xStream = xThumbnailStor->openStreamElement(
                                                        ::rtl::OUString::createFromAscii( "thumbnail.png" ),
                                                        embed::ElementModes::READWRITE );

            if ( && WriteThumbnail( bEncrypted, bSigned, bIsTemplate, xStream ) )
                uno::Reference< beans::XPropertySet > xPropSet( xStream, uno::UNO_QUERY );
                if ( )
                    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 );
                bResult = sal_True;
    catch( uno::Exception& )
    bIsInGenerateThumbnail = sal_False;//optimize thumbnail generate and store procedure to improve odt saving performance, i120030

    return bResult;
Comment 4 Ariel Constenla-Haile 2013-03-30 13:32:21 UTC
(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).
Comment 5 SVN Robot 2013-03-30 13:50:17 UTC
"arielch" committed SVN revision 1462756 into trunk:
i95421 - Set MediaType when storing thumbnail.png
Comment 6 Ariel Constenla-Haile 2013-03-30 13:50:53 UTC
Fixed on trunk
Comment 7 orcmid 2013-03-30 15:48:56 UTC
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.