include/vcl/pdfextoutdevdata.hxx                |    2 -
 include/vcl/pdfwriter.hxx                       |    2 -
 sd/source/ui/unoidl/unomodel.cxx                |   25 ++++++++++++++++++++++--
 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, 55 insertions(+), 13 deletions(-)

New commits:
commit 1c92038e2e4fdc556ec4ca1e00eff3ae355b683f
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Wed Mar 15 12:39:55 2023 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sat Mar 25 19:41:54 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>
    (cherry picked from commit e7d5e346677efeb7d7d14537a9151ea7a1a32809)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149106
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

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 3e62aee7d1f4..8c9150f4dbca 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 67d93cf1bbdd..881908638efd 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -1642,11 +1642,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 9309d3ec7c58..977491a7f3ce 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -1967,6 +1967,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())
@@ -1975,7 +1985,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 ab0ff5b4f86e..ca1e7f7eda0e 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -475,9 +475,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)
     {
     }
 };
@@ -1294,7 +1297,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 8b206debfbc1..3f56bc8660e2 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 698e171963a8..452e0ff30386 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -3578,8 +3578,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.
@@ -10305,7 +10311,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;
@@ -10315,7 +10321,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;
commit b82de080efc883f688a6d9c7dcafc7672c3bffef
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri Mar 17 16:39:01 2023 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sat Mar 25 19:41:44 2023 +0000

    sd: PDF export: produce annotations for shapes before painting shapes
    
    This is the same order as sw SwEnhancedPDFExportHelper and required to
    connect media shape Annot to its StructElem.
    
    Change-Id: I1d421e5d353261e32b28a0429cd73f156c692260
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149060
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit fb93cf7e3f70cf711742c5b492d520d9d49c3c5e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149302
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index edcaa3a4fdfc..67d93cf1bbdd 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -1932,8 +1932,8 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 
nRenderer, const uno::Any& r
             // hint value if screen display. Only then the AutoColor 
mechanisms shall be applied
             rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor( pPV, 
bScreenDisplay ) );
         }
-        aView.SdrPaintView::CompleteRedraw( pOut, aRegion, 
&aImplRenderPaintProc );
 
+        // produce link annots for media shapes before painting them
         if ( pPDFExtOutDevData && pPage )
         {
             try
@@ -2080,7 +2080,18 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 
nRenderer, const uno::Any& r
                         }
                     }
                 }
+            }
+            catch (const uno::Exception&)
+            {
+            }
+        }
 
+        aView.SdrPaintView::CompleteRedraw(pOut, aRegion, 
&aImplRenderPaintProc);
+
+        if (pPDFExtOutDevData && pPage)
+        {
+            try
+            {
                 Size        aPageSize( mpDoc->GetSdPage( 0, PageKind::Standard 
)->GetSize() );
                 Point aPoint( 0, 0 );
                 ::tools::Rectangle   aPageRect( aPoint, aPageSize );

Reply via email to