include/vcl/pdfextoutdevdata.hxx | 2 +- include/vcl/pdfwriter.hxx | 2 +- sd/source/ui/unoidl/unomodel.cxx | 3 ++- sw/source/core/text/EnhancedPDFExportHelper.cxx | 3 ++- vcl/inc/pdf/pdfwriter_impl.hxx | 6 ++++-- vcl/qa/cppunit/pdfexport/data/vid.odt |binary vcl/qa/cppunit/pdfexport/pdfexport.cxx | 2 ++ vcl/source/gdi/pdfextoutdevdata.cxx | 12 +++++++++--- vcl/source/gdi/pdfwriter.cxx | 4 ++-- vcl/source/gdi/pdfwriter_impl.cxx | 8 ++++---- 10 files changed, 27 insertions(+), 15 deletions(-)
New commits: commit 5cc69594e4382c258f0e3e3b1ef210567fce1bd8 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Wed Apr 5 12:24:43 2023 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Apr 5 15:39:37 2023 +0200 vcl,sw,sd: PDF/UA export: produce better /CT for SdrMediaObj 7.18.6.2 Media clip data In the media clip data dictionary, the optional CT and Alt keys (ISO 32000-1:2008, 13.2.4.2, Table 274) are required. Presumably writing a potentially wrong hard-coded mime type here isn't intended. Change-Id: Ifa8ee199a4cf9ce83f410860d59b6c30475f80e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150050 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/include/vcl/pdfextoutdevdata.hxx b/include/vcl/pdfextoutdevdata.hxx index 2f0360d1fdd5..58088d235eff 100644 --- a/include/vcl/pdfextoutdevdata.hxx +++ b/include/vcl/pdfextoutdevdata.hxx @@ -270,7 +270,7 @@ public: sal_Int32 CreateLink(const tools::Rectangle& rRect, OUString const& rAltText, sal_Int32 nPageNr = -1); /// Create a Screen annotation. - sal_Int32 CreateScreen(const tools::Rectangle& rRect, OUString const& rAltText, sal_Int32 nPageNr, SdrObject const* pObj); + sal_Int32 CreateScreen(const tools::Rectangle& rRect, OUString const& rAltText, OUString const& rMimeType, sal_Int32 nPageNr, SdrObject const* pObj); /// Get back the annotations created for one SdrObject. ::std::vector<sal_Int32> const& GetScreenAnnotIds(SdrObject const* pObj) const; diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx index 0d959f9add34..156720fed840 100644 --- a/include/vcl/pdfwriter.hxx +++ b/include/vcl/pdfwriter.hxx @@ -930,7 +930,7 @@ The following structure describes the permissions used in PDF security sal_Int32 CreateLink(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText); /// Creates a screen annotation. - sal_Int32 CreateScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText); + sal_Int32 CreateScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText, OUString const& rMimeType); /** creates a destination which is not intended to be referred to by a link, but by a public destination Id. diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index bab827c6be5f..ca741e9bb53f 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -1659,7 +1659,8 @@ static void ImplPDFExportShapeInteraction( const uno::Reference< drawing::XShape if (!aMediaURL.isEmpty()) { SdrObject const*const pSdrObj(SdrObject::getSdrObjectFromXShape(xShape)); - sal_Int32 nScreenId = rPDFExtOutDevData.CreateScreen(aLinkRect, altText, rPDFExtOutDevData.GetCurrentPageNumber(), pSdrObj); + OUString const mimeType(xShapePropSet->getPropertyValue("MediaMimeType").get<OUString>()); + sal_Int32 nScreenId = rPDFExtOutDevData.CreateScreen(aLinkRect, altText, mimeType, rPDFExtOutDevData.GetCurrentPageNumber(), pSdrObj); if (aMediaURL.startsWith("vnd.sun.star.Package:")) { OUString aTempFileURL; diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index 26970499ca40..633dd4d2d3c8 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -2036,11 +2036,12 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() xShapePropSet->getPropertyValue("MediaURL") >>= aMediaURL; if (!aMediaURL.isEmpty()) { + OUString const mimeType(xShapePropSet->getPropertyValue("MediaMimeType").get<OUString>()); const SwPageFrame* pCurrPage = mrSh.GetLayout()->GetPageAtPos(aSnapRect.Center()); tools::Rectangle aPDFRect(SwRectToPDFRect(pCurrPage, aSnapRect.SVRect())); for (sal_Int32 nScreenPageNum : aScreenPageNums) { - sal_Int32 nScreenId = pPDFExtOutDevData->CreateScreen(aPDFRect, altText, nScreenPageNum, pObject); + sal_Int32 nScreenId = pPDFExtOutDevData->CreateScreen(aPDFRect, altText, mimeType, nScreenPageNum, pObject); if (aMediaURL.startsWith("vnd.sun.star.Package:")) { // Embedded media. diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx index e30c8968e59a..aadb6b204d22 100644 --- a/vcl/inc/pdf/pdfwriter_impl.hxx +++ b/vcl/inc/pdf/pdfwriter_impl.hxx @@ -480,11 +480,13 @@ struct PDFScreen : public PDFAnnotation /// alternative text description OUString m_AltText; sal_Int32 m_nStructParent; + OUString m_MimeType; - PDFScreen(OUString const& rAltText) + PDFScreen(OUString const& rAltText, OUString const& rMimeType) : m_nTempFileObject(0) , m_AltText(rAltText) , m_nStructParent(-1) + , m_MimeType(rMimeType) { } }; @@ -1316,7 +1318,7 @@ public: void setLinkPropertyId( sal_Int32 nLinkId, sal_Int32 nPropertyId ); // screens - sal_Int32 createScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText); + sal_Int32 createScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText, OUString const& rMimeType); void setScreenURL(sal_Int32 nScreenId, const OUString& rURL); void setScreenStream(sal_Int32 nScreenId, const OUString& rURL); diff --git a/vcl/qa/cppunit/pdfexport/data/vid.odt b/vcl/qa/cppunit/pdfexport/data/vid.odt index 730358e261fa..fc34ab8f198a 100644 Binary files a/vcl/qa/cppunit/pdfexport/data/vid.odt and b/vcl/qa/cppunit/pdfexport/data/vid.odt differ diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 4f24545a0829..beb1a1daf50c 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -3610,6 +3610,8 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testMediaShapeAnnot) CPPUNIT_ASSERT(pR); auto pC = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pR->LookupElement("C")); CPPUNIT_ASSERT(pC); + auto pCT = dynamic_cast<vcl::filter::PDFLiteralStringElement*>(pC->LookupElement("CT")); + CPPUNIT_ASSERT_EQUAL(OString("video/webm"), pCT->GetValue()); auto pD = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pC->LookupElement("D")); CPPUNIT_ASSERT(pD); auto pDesc = dynamic_cast<vcl::filter::PDFHexStringElement*>(pD->LookupElement("Desc")); diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx index 21f340fc2107..ff99fdbbcd90 100644 --- a/vcl/source/gdi/pdfextoutdevdata.cxx +++ b/vcl/source/gdi/pdfextoutdevdata.cxx @@ -200,12 +200,15 @@ void GlobalSyncData::PlayGlobalActions( PDFWriter& rWriter ) rWriter.Push(PushFlags::MAPMODE); rWriter.SetMapMode(mParaMapModes.front()); mParaMapModes.pop_front(); - mParaIds.push_back(rWriter.CreateScreen(mParaRects.front(), mParaInts.front(), mParaOUStrings.front())); + OUString const altText(mParaOUStrings.front()); + mParaOUStrings.pop_front(); + OUString const mimeType(mParaOUStrings.front()); + mParaOUStrings.pop_front(); + mParaIds.push_back(rWriter.CreateScreen(mParaRects.front(), mParaInts.front(), altText, mimeType)); // resolve AnnotIds structural attribute rWriter.SetLinkPropertyID(mParaIds.back(), sal_Int32(mParaIds.size()-1)); mParaRects.pop_front(); mParaInts.pop_front(); - mParaOUStrings.pop_front(); rWriter.Pop(); } break; @@ -704,13 +707,16 @@ sal_Int32 PDFExtOutDevData::CreateLink(const tools::Rectangle& rRect, OUString c return mpGlobalSyncData->mCurId++; } -sal_Int32 PDFExtOutDevData::CreateScreen(const tools::Rectangle& rRect, OUString const& rAltText, sal_Int32 nPageNr, SdrObject const*const pObj) +sal_Int32 PDFExtOutDevData::CreateScreen(const tools::Rectangle& rRect, + OUString const& rAltText, OUString const& rMimeType, + sal_Int32 nPageNr, SdrObject const*const pObj) { mpGlobalSyncData->mActions.push_back(PDFExtOutDevDataSync::CreateScreen); mpGlobalSyncData->mParaRects.push_back(rRect); mpGlobalSyncData->mParaMapModes.push_back(mrOutDev.GetMapMode()); mpGlobalSyncData->mParaInts.push_back(nPageNr); mpGlobalSyncData->mParaOUStrings.push_back(rAltText); + mpGlobalSyncData->mParaOUStrings.push_back(rMimeType); auto const ret(mpGlobalSyncData->mCurId++); m_ScreenAnnotations[pObj].push_back(ret); return ret; diff --git a/vcl/source/gdi/pdfwriter.cxx b/vcl/source/gdi/pdfwriter.cxx index f0314ce0fe82..dda44d2f4adb 100644 --- a/vcl/source/gdi/pdfwriter.cxx +++ b/vcl/source/gdi/pdfwriter.cxx @@ -335,9 +335,9 @@ sal_Int32 PDFWriter::CreateLink(const tools::Rectangle& rRect, sal_Int32 nPageNr return xImplementation->createLink(rRect, nPageNr, rAltText); } -sal_Int32 PDFWriter::CreateScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText) +sal_Int32 PDFWriter::CreateScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText, OUString const& rMimeType) { - return xImplementation->createScreen(rRect, nPageNr, rAltText); + return xImplementation->createScreen(rRect, nPageNr, rAltText, rMimeType); } sal_Int32 PDFWriter::RegisterDestReference( sal_Int32 nDestId, const tools::Rectangle& rRect, sal_Int32 nPageNr, DestAreaType eType ) diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 6415ac76e90e..83d5e6ea9a83 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -3616,8 +3616,8 @@ bool PDFWriterImpl::emitScreenAnnotations() // Allow playing the video via a tempfile. aLine.append("/P <</TF (TEMPACCESS)>>"); // ISO 14289-1:2014, Clause: 7.18.6.2 - // Until the real MIME type (instead of application/vnd.sun.star.media) is available here. - aLine.append("/CT (video/mp4)"); + aLine.append("/CT "); + appendLiteralStringEncrypt(rScreen.m_MimeType, rScreen.m_nObject, aLine); // ISO 14289-1:2014, Clause: 7.18.6.2 // Alt text is a "Multi-language Text Array" aLine.append(" /Alt [ () "); @@ -10383,7 +10383,7 @@ sal_Int32 PDFWriterImpl::createLink(const tools::Rectangle& rRect, sal_Int32 nPa return nRet; } -sal_Int32 PDFWriterImpl::createScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText) +sal_Int32 PDFWriterImpl::createScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText, OUString const& rMimeType) { if (nPageNr < 0) nPageNr = m_nCurrentPage; @@ -10393,7 +10393,7 @@ sal_Int32 PDFWriterImpl::createScreen(const tools::Rectangle& rRect, sal_Int32 n sal_Int32 nRet = m_aScreens.size(); - m_aScreens.emplace_back(rAltText); + m_aScreens.emplace_back(rAltText, rMimeType); m_aScreens.back().m_nObject = createObject(); m_aScreens.back().m_nPage = nPageNr; m_aScreens.back().m_aRect = rRect;