diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-01-23 12:33:39 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-01-24 10:50:49 +0000 |
commit | e052f6e1d49a5289411b31561d6e310bf414d896 (patch) | |
tree | 8aa7d8683589077346abe32b4a6c8e6d0d777ae8 /filter/source/pdf | |
parent | 217ef2ed9b8a757b7b02feac799621d20d0f312e (diff) |
tdf#66580 write ODF document as an attachment in hybrid mode
This changes the hybrid mode so that the ODF document is written
as an PDF compatible file attachment into the PDF document. It also
keeps writing the /AdditionalStreams element into the trailer to
keep backwards compatibility for now.
Change-Id: Ica31159cfbd591c6741e3da62c42d1fefd085696
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146053
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'filter/source/pdf')
-rw-r--r-- | filter/source/pdf/pdfexport.cxx | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index 338463f184f8..7e710dabd928 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -27,6 +27,7 @@ #include <vcl/canvastools.hxx> #include <vcl/mapmod.hxx> #include <vcl/gdimtf.hxx> +#include <rtl/ustring.hxx> #include <comphelper/propertyvalue.hxx> #include <comphelper/sequence.hxx> #include <comphelper/string.hxx> @@ -312,19 +313,16 @@ void PDFExportStreamDoc::write( const Reference< XOutputStream >& xStream ) if( !xStore.is() ) return; - Sequence< beans::PropertyValue > aArgs( 2 + (m_aPreparedPassword.hasElements() ? 1 : 0) ); - aArgs.getArray()[0].Name = "FilterName"; - aArgs.getArray()[1].Name = "OutputStream"; - aArgs.getArray()[1].Value <<= xStream; - if( m_aPreparedPassword.hasElements() ) - { - aArgs.getArray()[2].Name = "EncryptionData"; - aArgs.getArray()[2].Value <<= m_aPreparedPassword; - } + std::vector<beans::PropertyValue> aArgs { + comphelper::makePropertyValue("FilterName", OUString()), + comphelper::makePropertyValue("OutputStream", xStream), + }; + if (m_aPreparedPassword.hasElements()) + aArgs.push_back(comphelper::makePropertyValue("EncryptionData", m_aPreparedPassword)); try { - xStore->storeToURL( "private:stream", aArgs ); + xStore->storeToURL("private:stream", comphelper::containerToSequence(aArgs)); } catch( const IOException& ) { @@ -927,9 +925,17 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& // export stream // get mimetype OUString aSrcMimetype = getMimetypeForDocument( mxContext, mxSrcDoc ); - aPDFWriter.AddStream( aSrcMimetype, - new PDFExportStreamDoc( mxSrcDoc, aPreparedPermissionPassword ) - ); + OUString aExt; + if (aSrcMimetype == "application/vnd.oasis.opendocument.text") + aExt = ".odt"; + else if (aSrcMimetype == "application/vnd.oasis.opendocument.presentation") + aExt = ".odp"; + else if (aSrcMimetype == "application/vnd.oasis.opendocument.spreadsheet") + aExt = ".ods"; + else if (aSrcMimetype == "application/vnd.oasis.opendocument.graphics") + aExt = ".odg"; + std::unique_ptr<vcl::PDFOutputStream> pStream(new PDFExportStreamDoc(mxSrcDoc, aPreparedPermissionPassword)); + aPDFWriter.AddAttachedFile("Original" + aExt, aSrcMimetype, std::move(pStream)); } if ( pOut ) |