include/vcl/pdfextoutdevdata.hxx | 2 +- include/vcl/pdfwriter.hxx | 2 +- sd/source/ui/unoidl/unomodel.cxx | 12 +++++++++++- sw/source/core/text/EnhancedPDFExportHelper.cxx | 12 +++++++++++- vcl/inc/pdf/pdfwriter_impl.hxx | 7 +++++-- vcl/source/gdi/pdfextoutdevdata.cxx | 6 ++++-- vcl/source/gdi/pdfwriter.cxx | 4 ++-- vcl/source/gdi/pdfwriter_impl.cxx | 10 ++++++++-- 8 files changed, 43 insertions(+), 12 deletions(-)
New commits: commit e7d5e346677efeb7d7d14537a9151ea7a1a32809 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Wed Mar 15 12:39:55 2023 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Mon Mar 20 17:14:49 2023 +0000 vcl,sd,sw: PDF/UA export: add Alt text to SdrMediaObj media shapes 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. Change-Id: I147f1677f1bd0788c2269735688d329db15c0ead Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149007 Tested-by: Michael Stahl <michael.st...@allotropia.de> Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/include/vcl/pdfextoutdevdata.hxx b/include/vcl/pdfextoutdevdata.hxx index 89696ef757b6..81ea37b86d9b 100644 --- a/include/vcl/pdfextoutdevdata.hxx +++ b/include/vcl/pdfextoutdevdata.hxx @@ -266,7 +266,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, sal_Int32 nPageNr); + sal_Int32 CreateScreen(const tools::Rectangle& rRect, OUString const& rAltText, sal_Int32 nPageNr); /** Set the destination for a link <p>will change a URL type link to a dest link if necessary</p> diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx index f415fa59699f..1319909961a9 100644 --- a/include/vcl/pdfwriter.hxx +++ b/include/vcl/pdfwriter.hxx @@ -928,7 +928,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); + sal_Int32 CreateScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText); /** 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 a955e02e3da6..61189ca9deaa 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -1644,11 +1644,21 @@ static void ImplPDFExportShapeInteraction( const uno::Reference< drawing::XShape // Handle linked videos. if (xShape->getShapeType() == "com.sun.star.drawing.MediaShape" || xShape->getShapeType() == "com.sun.star.presentation.MediaShape") { + OUString title; + xShapePropSet->getPropertyValue("Title") >>= title; + OUString description; + xShapePropSet->getPropertyValue("Description") >>= description; + OUString const altText(title.isEmpty() + ? description + : description.isEmpty() + ? title + : OUString::Concat(title) + OUString::Concat("\n") + OUString::Concat(description)); + OUString aMediaURL; xShapePropSet->getPropertyValue("MediaURL") >>= aMediaURL; if (!aMediaURL.isEmpty()) { - sal_Int32 nScreenId = rPDFExtOutDevData.CreateScreen(aLinkRect, rPDFExtOutDevData.GetCurrentPageNumber()); + sal_Int32 nScreenId = rPDFExtOutDevData.CreateScreen(aLinkRect, altText, rPDFExtOutDevData.GetCurrentPageNumber()); 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 4db59dcd1be5..7c518f8b4594 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -2022,6 +2022,16 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() if (xShape->getShapeType() == "com.sun.star.drawing.MediaShape") { uno::Reference<beans::XPropertySet> xShapePropSet(xShape, uno::UNO_QUERY); + OUString title; + xShapePropSet->getPropertyValue("Title") >>= title; + OUString description; + xShapePropSet->getPropertyValue("Description") >>= description; + OUString const altText(title.isEmpty() + ? description + : description.isEmpty() + ? title + : OUString::Concat(title) + OUString::Concat("\n") + OUString::Concat(description)); + OUString aMediaURL; xShapePropSet->getPropertyValue("MediaURL") >>= aMediaURL; if (!aMediaURL.isEmpty()) @@ -2030,7 +2040,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() tools::Rectangle aPDFRect(SwRectToPDFRect(pCurrPage, aSnapRect.SVRect())); for (sal_Int32 nScreenPageNum : aScreenPageNums) { - sal_Int32 nScreenId = pPDFExtOutDevData->CreateScreen(aPDFRect, nScreenPageNum); + sal_Int32 nScreenId = pPDFExtOutDevData->CreateScreen(aPDFRect, altText, nScreenPageNum); 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 4157aeda446a..cc1c23a974a2 100644 --- a/vcl/inc/pdf/pdfwriter_impl.hxx +++ b/vcl/inc/pdf/pdfwriter_impl.hxx @@ -477,9 +477,12 @@ struct PDFScreen : public PDFAnnotation OUString m_aTempFileURL; /// ID of the EmbeddedFile object. sal_Int32 m_nTempFileObject; + /// alternative text description + OUString m_AltText; - PDFScreen() + PDFScreen(OUString const& rAltText) : m_nTempFileObject(0) + , m_AltText(rAltText) { } }; @@ -1307,7 +1310,7 @@ public: void setLinkPropertyId( sal_Int32 nLinkId, sal_Int32 nPropertyId ); // screens - sal_Int32 createScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr); + sal_Int32 createScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText); void setScreenURL(sal_Int32 nScreenId, const OUString& rURL); void setScreenStream(sal_Int32 nScreenId, const OUString& rURL); diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx index 200f36e3dd9b..c40e9a73fba3 100644 --- a/vcl/source/gdi/pdfextoutdevdata.cxx +++ b/vcl/source/gdi/pdfextoutdevdata.cxx @@ -195,9 +195,10 @@ 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())); + mParaIds.push_back(rWriter.CreateScreen(mParaRects.front(), mParaInts.front(), mParaOUStrings.front())); mParaRects.pop_front(); mParaInts.pop_front(); + mParaOUStrings.pop_front(); rWriter.Pop(); } break; @@ -675,12 +676,13 @@ sal_Int32 PDFExtOutDevData::CreateLink(const tools::Rectangle& rRect, OUString c return mpGlobalSyncData->mCurId++; } -sal_Int32 PDFExtOutDevData::CreateScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr) +sal_Int32 PDFExtOutDevData::CreateScreen(const tools::Rectangle& rRect, OUString const& rAltText, sal_Int32 nPageNr) { 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); return mpGlobalSyncData->mCurId++; } diff --git a/vcl/source/gdi/pdfwriter.cxx b/vcl/source/gdi/pdfwriter.cxx index 23d986313c5b..d1399ee0912b 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) +sal_Int32 PDFWriter::CreateScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText) { - return xImplementation->createScreen(rRect, nPageNr); + return xImplementation->createScreen(rRect, nPageNr, rAltText); } 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 9e0f370dbc8a..4ff97a5c0988 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -3604,8 +3604,14 @@ 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)"); + // ISO 14289-1:2014, Clause: 7.18.6.2 + // Alt text is a "Multi-language Text Array" + aLine.append(" /Alt [ () "); + appendLiteralStringEncrypt(rScreen.m_AltText, rScreen.m_nObject, aLine, osl_getThreadTextEncoding()); + aLine.append(" ] "); aLine.append(">>"); // End Rendition dictionary by requesting play/pause/stop controls. @@ -10344,7 +10350,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) +sal_Int32 PDFWriterImpl::createScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText) { if (nPageNr < 0) nPageNr = m_nCurrentPage; @@ -10354,7 +10360,7 @@ sal_Int32 PDFWriterImpl::createScreen(const tools::Rectangle& rRect, sal_Int32 n sal_Int32 nRet = m_aScreens.size(); - m_aScreens.emplace_back(); + m_aScreens.emplace_back(rAltText); m_aScreens.back().m_nObject = createObject(); m_aScreens.back().m_nPage = nPageNr; m_aScreens.back().m_aRect = rRect;