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 /vcl/inc | |
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 'vcl/inc')
-rw-r--r-- | vcl/inc/pdf/pdfwriter_impl.hxx | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx index ea7c3d3462ab..5f6abd7bca82 100644 --- a/vcl/inc/pdf/pdfwriter_impl.hxx +++ b/vcl/inc/pdf/pdfwriter_impl.hxx @@ -440,8 +440,10 @@ struct PDFEmbeddedFile { /// ID of the file. sal_Int32 m_nObject; + OUString m_aSubType; /// Contents of the file. BinaryDataContainer m_aDataContainer; + std::unique_ptr<PDFOutputStream> m_pStream; PDFEmbeddedFile() : m_nObject(0) @@ -673,7 +675,15 @@ struct GraphicsState enum class Mode { DEFAULT, NOWRITE }; -} +struct PDFDocumentAttachedFile +{ + OUString maFilename; + OUString maMimeType; + sal_Int32 mnEmbeddedFileObjectId; + sal_Int32 mnObjectId; +}; + +} // end pdf namespace class PDFWriterImpl final : public VirtualDevice, public PDFObjectContainer { @@ -728,6 +738,9 @@ private: std::vector<PDFScreen> m_aScreens; /// Contains embedded files. std::vector<PDFEmbeddedFile> m_aEmbeddedFiles; + + std::vector<PDFDocumentAttachedFile> m_aDocumentAttachedFiles; + /* makes correctly encoded for export to PDF URLS */ css::uno::Reference< css::util::XURLTransformer > m_xTrans; @@ -810,11 +823,20 @@ private: std::unique_ptr<ZCodec> m_pCodec; std::unique_ptr<SvMemoryStream> m_pMemStream; - std::vector< PDFAddStream > m_aAdditionalStreams; std::set< PDFWriter::ErrorCode > m_aErrors; ::comphelper::Hash m_DocDigest; + sal_uInt64 getCurrentFilePosition() + { + sal_uInt64 nPosition{}; + if (osl::File::E_None != m_aFile.getPos(nPosition)) + { + m_aFile.close(); + m_bOpen = false; + } + return nPosition; + } /* variables for PDF security i12626 @@ -1317,8 +1339,11 @@ public: // controls sal_Int32 createControl( const PDFWriter::AnyWidget& rControl, sal_Int32 nPageNr = -1 ); - // additional streams - void addStream( const OUString& rMimeType, PDFOutputStream* pStream ); + // attached file + void addDocumentAttachedFile(OUString const& rFileName, OUString const& rMimeType, std::unique_ptr<PDFOutputStream> rStream); + + sal_Int32 addEmbeddedFile(BinaryDataContainer const & rDataContainer); + sal_Int32 addEmbeddedFile(std::unique_ptr<PDFOutputStream> rStream, OUString const& rMimeType); // helper: eventually begin marked content sequence and // emit a comment in debug case |