LibreOffice Module vcl (master) 1
pdfwriter_impl.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <map>
25#include <list>
26#include <unordered_map>
27#include <memory>
28#include <string_view>
29#include <vector>
30
31#include <pdf/ResourceDict.hxx>
32#include <pdf/BitmapID.hxx>
33#include <pdf/Matrix3.hxx>
34
35#include <com/sun/star/lang/Locale.hpp>
36#include <com/sun/star/util/XURLTransformer.hpp>
37#include <com/sun/star/uno/Sequence.h>
38#include <osl/file.hxx>
39#include <rtl/cipher.h>
40#include <rtl/strbuf.hxx>
41#include <rtl/ustring.hxx>
42#include <tools/gen.hxx>
43#include <vcl/bitmapex.hxx>
44#include <vcl/gradient.hxx>
45#include <vcl/graphictools.hxx>
46#include <vcl/hatch.hxx>
47#include <vcl/virdev.hxx>
48#include <vcl/pdfwriter.hxx>
49#include <vcl/wall.hxx>
50#include <o3tl/safeint.hxx>
52#include <o3tl/lru_map.hxx>
53#include <comphelper/hash.hxx>
54#include <tools/stream.hxx>
56
60#include <pdf/pdffontcache.hxx>
61
62class StyleSettings;
63class FontSubsetInfo;
64class ZCodec;
66struct BitStreamState;
67namespace vcl::font { class PhysicalFontFace; }
68class SvStream;
69class SvMemoryStream;
70
71// the maximum password length
72constexpr sal_Int32 ENCRYPTED_PWD_SIZE = 32;
73constexpr sal_Int32 MD5_DIGEST_SIZE = 16;
74// security 128 bit
75constexpr sal_Int32 SECUR_128BIT_KEY = 16;
76// maximum length of MD5 digest input, in step 2 of algorithm 3.1
77// PDF spec ver. 1.4: see there for details
78constexpr sal_Int32 MAXIMUM_RC4_KEY_LENGTH = SECUR_128BIT_KEY + 3 + 2;
79
80namespace vcl::pdf
81{
82
84 Font = 0x0001,
85 MapMode = 0x0002,
86 LineColor = 0x0004,
87 FillColor = 0x0008,
88 ClipRegion = 0x0040,
89 LayoutMode = 0x0100,
90 TransparentPercent = 0x0200,
91 DigitLanguage = 0x0400,
92 All = 0x077f
93};
94
95} // end vcl::pdf
96
97namespace o3tl {
98 template<> struct typed_flags<vcl::pdf::GraphicsStateUpdateFlags> : is_typed_flags<vcl::pdf::GraphicsStateUpdateFlags, 0x077f> {};
99}
100
101namespace vcl
102{
103
104using namespace vcl::pdf;
105
106class PDFStreamIf;
107
108namespace filter
109{
110class PDFObjectElement;
111}
112
113namespace pdf
114{
115constexpr sal_Int32 g_nInheritedPageWidth = 595; // default A4 in inch/72
116constexpr sal_Int32 g_nInheritedPageHeight = 842; // default A4 in inch/72
117
119{
121 double m_nPageWidth; // in inch/72
122 double m_nPageHeight; // in inch/72
127 sal_Int32 m_nUserUnit;
129 sal_Int32 m_nPageObject;
130 std::vector<sal_Int32> m_aStreamObjects;
133 std::vector<sal_Int32> m_aAnnotations;
134 std::vector<sal_Int32> m_aMCIDParents;
136 sal_uInt32 m_nTransTime;
137
138 PDFPage( PDFWriterImpl* pWriter, double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation );
139
140 void beginStream();
141 void endStream();
142 bool emit( sal_Int32 nParentPage );
143
144 // converts point from ref device coordinates to
145 // page coordinates and appends the point to the buffer
146 // if pOutPoint is set it will be updated to the emitted point
147 // (in PDF map mode, that is 10th of point)
148 void appendPoint( const Point& rPoint, OStringBuffer& rBuffer ) const;
149 // appends a B2DPoint without further transformation
150 void appendPixelPoint( const basegfx::B2DPoint& rPoint, OStringBuffer& rBuffer ) const;
151 // appends a rectangle
152 void appendRect( const tools::Rectangle& rRect, OStringBuffer& rBuffer ) const;
153 // converts a rectangle to 10th points page space
154 void convertRect( tools::Rectangle& rRect ) const;
155 // appends a polygon optionally closing it
156 void appendPolygon( const tools::Polygon& rPoly, OStringBuffer& rBuffer, bool bClose = true ) const;
157 // appends a polygon optionally closing it
158 void appendPolygon( const basegfx::B2DPolygon& rPoly, OStringBuffer& rBuffer ) const;
159 // appends a polypolygon optionally closing the subpaths
160 void appendPolyPolygon( const tools::PolyPolygon& rPolyPoly, OStringBuffer& rBuffer ) const;
161 // appends a polypolygon optionally closing the subpaths
162 void appendPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPoly, OStringBuffer& rBuffer ) const;
163 // converts a length (either vertical or horizontal; this
164 // can be important if the source MapMode is not
165 // symmetrical) to page length and appends it to the buffer
166 // if pOutLength is set it will be updated to the emitted length
167 // (in PDF map mode, that is 10th of point)
168 void appendMappedLength( sal_Int32 nLength, OStringBuffer& rBuffer, bool bVertical = true, sal_Int32* pOutLength = nullptr ) const;
169 // the same for double values
170 void appendMappedLength( double fLength, OStringBuffer& rBuffer, bool bVertical = true, sal_Int32 nPrecision = 5 ) const;
171 // appends LineInfo
172 // returns false if too many dash array entry were created for
173 // the implementation limits of some PDF readers
174 bool appendLineInfo( const LineInfo& rInfo, OStringBuffer& rBuffer ) const;
175 // appends a horizontal waveline with vertical offset (helper for drawWaveLine)
176 void appendWaveLine( sal_Int32 nLength, sal_Int32 nYOffset, sal_Int32 nDelta, OStringBuffer& rBuffer ) const;
177
178 void appendMatrix3(Matrix3 const & rMatrix, OStringBuffer& rBuffer);
179
180 double getHeight() const;
181};
182
185{
187 sal_Int32 m_nFormObject;
197
199 : m_nFormObject(0)
201 , m_nBitmapObject(0)
204 {
205 }
206
208 sal_Int32 getObject() const;
209
211 {
212 return m_nExternalPDFDataIndex >= 0;
213 }
214};
215
217{
220 sal_Int32 m_nObject;
222
224 : m_nObject(0)
225 {
226 }
227};
228
230{
232 std::unique_ptr<SvMemoryStream>
235 sal_Int32 m_nObject;
238
240 : m_nObject(0)
241 , m_bTrueColor(false)
242 {
243 }
244};
245
247{
250 sal_Int32 m_nObject;
251};
252
253// for tilings (drawWallpaper, begin/endPattern)
255{
256 sal_Int32 m_nObject;
261 std::unique_ptr<SvMemoryStream> m_pTilingStream;
262
264 : m_nObject( 0 )
265 {}
266};
267
268// for transparency group XObjects
270{
271 sal_Int32 m_nObject;
273 double m_fAlpha;
275 std::unique_ptr<SvMemoryStream> m_pContentStream;
276
278 : m_nObject( 0 ),
279 m_nExtGStateObject( -1 ),
280 m_fAlpha( 0.0 )
281 {}
282};
283
284// font subsets
286{
287 // performance: actually this should probably a vector;
288 std::vector<sal_Ucs> m_CodeUnits;
290 sal_Int32 m_nGlyphWidth;
291
292public:
294 {
295 }
296
297 void setGlyphId( sal_uInt8 i_nId ) { m_nSubsetGlyphID = i_nId; }
299
300 void setGlyphWidth( sal_Int32 nWidth ) { m_nGlyphWidth = nWidth; }
301 sal_Int32 getGlyphWidth() const { return m_nGlyphWidth; }
302
303 void addCode( sal_Ucs i_cCode )
304 {
305 m_CodeUnits.push_back(i_cCode);
306 }
307 sal_Int32 countCodes() const { return m_CodeUnits.size(); }
308 const std::vector<sal_Ucs>& codes() const { return m_CodeUnits; }
309 sal_Ucs getCode( sal_Int32 i_nIndex ) const
310 {
311 sal_Ucs nRet = 0;
312 if (o3tl::make_unsigned(i_nIndex) < m_CodeUnits.size())
313 nRet = m_CodeUnits[i_nIndex];
314 return nRet;
315 }
316};
317
319{
320 sal_Int32 m_nFontID;
321 std::map<sal_GlyphId, GlyphEmit> m_aMapping;
322
323 explicit FontEmit( sal_Int32 nID ) : m_nFontID( nID ) {}
324};
325
326struct Glyph
327{
328 sal_Int32 m_nFontID;
330};
331
333{
334 std::vector< FontEmit > m_aSubsets;
335 std::map<sal_GlyphId, Glyph> m_aMapping;
336};
337
339{
341
343};
344
346{
347 sal_Int32 m_nPage;
350};
351
352//--->i56629
354{
355 OUString m_aDestName;
356 sal_Int32 m_nPage;
359};
360
362{
363 sal_Int32 m_nObject;
365 sal_Int32 m_nNextObject;
366 sal_Int32 m_nPrevObject;
367 std::vector< sal_Int32 > m_aChildren;
368 OUString m_aTitle;
369 sal_Int32 m_nDestID;
370
372 : m_nObject( 0 ),
373 m_nParentObject( 0 ),
374 m_nNextObject( 0 ),
375 m_nPrevObject( 0 ),
376 m_nDestID( -1 )
377 {}
378};
379
381{
382 sal_Int32 m_nObject;
384 sal_Int32 m_nPage;
385
387 : m_nObject( -1 ),
388 m_nPage( -1 )
389 {}
390};
391
392struct PDFLink : public PDFAnnotation
393{
394 sal_Int32 m_nDest; // set to -1 for URL, to a dest else
395 OUString m_aURL;
396 sal_Int32 m_nStructParent; // struct parent entry
397
399 : m_nDest( -1 ),
400 m_nStructParent( -1 )
401 {}
402};
403
406{
408 sal_Int32 m_nObject;
411
413 : m_nObject(0)
414 {
415 }
416};
417
419{
422};
423
425{
427
429
431 {}
432};
433
436{
438 OUString m_aURL;
443
446 {
447 }
448};
449
451{
453 OString m_aName;
455 OUString m_aText;
457 OUString m_aValue;
458 OString m_aDAString;
459 OString m_aDRDict;
460 OString m_aMKDict;
461 OString m_aMKDictCAString; // i12626, added to be able to encrypt the /CA text string
462 // since the object number is not known at the moment
463 // of filling m_aMKDict, the string will be encrypted when emitted.
464 // the /CA string MUST BE the last added to m_aMKDict
465 // see code for details
466 sal_Int32 m_nFlags;
467 sal_Int32 m_nParent; // if not 0, parent's object number
468 std::vector<sal_Int32> m_aKids; // widget children, contains object numbers
469 std::vector<sal_Int32> m_aKidsIndex; // widget children, contains index to m_aWidgets
470 OUString m_aOnValue;
471 OUString m_aOffValue;
472 sal_Int32 m_nTabOrder; // lowest number gets first in tab order
473 sal_Int32 m_nRadioGroup;
474 sal_Int32 m_nMaxLen;
483 sal_Int32 m_nDest;
484 std::vector<OUString> m_aListEntries;
485 std::vector<sal_Int32> m_aSelectedEntries;
486 typedef std::unordered_map<OString, SvMemoryStream*> PDFAppearanceStreams;
487 std::unordered_map<OString, PDFAppearanceStreams> m_aAppearances;
491 m_nFlags( 0 ),
492 m_nParent( 0 ),
493 m_nTabOrder( 0 ),
494 m_nRadioGroup( -1 ),
495 m_nMaxLen( 0 ),
497 m_nDecimalAccuracy ( 0 ),
499 m_bSubmit( false ),
500 m_bSubmitGet( false ),
501 m_nDest( -1 )
502 {}
503};
504
506{
508 sal_Int32 nValue;
509
512 nValue( 0 )
513 {}
514
516 : eValue( eVal ),
517 nValue( 0 )
518 {}
519
520 explicit PDFStructureAttribute( sal_Int32 nVal )
522 nValue( nVal )
523 {}
524};
525
526struct PDFStructureElementKid // for Kids entries
527{
528 sal_Int32 const nObject; // an object number if nMCID is -1,
529 // else the page object relevant to MCID
530 sal_Int32 const nMCID; // an MCID if >= 0
531
532 explicit PDFStructureElementKid( sal_Int32 nObj ) : nObject( nObj ), nMCID( -1 ) {}
533 PDFStructureElementKid( sal_Int32 MCID, sal_Int32 nPage ) : nObject( nPage ), nMCID( MCID ) {}
534};
535
537{
538 sal_Int32 m_nObject;
540 OString m_aAlias;
541 sal_Int32 m_nOwnElement; // index into structure vector
542 sal_Int32 m_nParentElement; // index into structure vector
545 std::list< sal_Int32 > m_aChildren; // indexes into structure vector
546 std::list< PDFStructureElementKid > m_aKids;
547 std::map<PDFWriter::StructAttribute, PDFStructureAttribute >
551 OUString m_aAltText;
552 css::lang::Locale m_aLocale;
553
554 // m_aContents contains the element's marked content sequence
555 // as pairs of (page nr, MCID)
556
558 : m_nObject( 0 ),
559 m_eType( PDFWriter::NonStructElement ),
560 m_nOwnElement( -1 ),
561 m_nParentElement( -1 ),
563 m_bOpenMCSeq( false )
564 {
565 }
566
567};
568
570{
571 OUString m_aMimeType;
575
576 PDFAddStream() : m_pStream( nullptr ), m_nStreamObject( 0 ), m_bCompress( true ) {}
577};
578
579// helper structure for drawLayout and friends
581{
584 sal_Int32 const m_nNativeWidth;
585 sal_Int32 const m_nMappedFontId;
587 int const m_nCharPos;
588
589 PDFGlyph( const Point& rPos,
590 const GlyphItem* pGlyph,
591 sal_Int32 nNativeWidth,
592 sal_Int32 nFontId,
593 sal_uInt8 nMappedGlyphId,
594 int nCharPos )
595 : m_aPos( rPos ), m_pGlyph(pGlyph), m_nNativeWidth( nNativeWidth ),
596 m_nMappedFontId( nFontId ), m_nMappedGlyphId( nMappedGlyphId ),
597 m_nCharPos(nCharPos)
598 {}
599};
600
602{
607};
608
609// graphics state
611{
624
630 m_bClipRegion( false ),
632 m_aDigitLanguage( 0 ),
635 {}
636};
637
638enum class Mode { DEFAULT, NOWRITE };
639
640}
641
643{
644 friend class PDFStreamIf;
645
646public:
647 friend struct vcl::pdf::PDFPage;
648
649 static const char* getStructureTag( PDFWriter::StructElement );
650 static const char* getAttributeTag( PDFWriter::StructAttribute eAtr );
651 static const char* getAttributeValueTag( PDFWriter::StructAttributeValue eVal );
652
653 // returns true if compression was done
654 // else false
655 static bool compressStream( SvMemoryStream* );
656
657 static void convertLineInfoToExtLineInfo( const LineInfo& rIn, PDFWriter::ExtLineInfo& rOut );
658
659private:
660 bool ImplNewFont() const override;
661 void ImplClearFontData(bool bNewFontLists) override;
662 void ImplRefreshFontData(bool bNewFontLists) override;
663 vcl::Region ClipToDeviceBounds(vcl::Region aRegion) const override;
664 void DrawHatchLine_DrawLine(const Point& rStartPoint, const Point& rEndPoint) override;
665
666 MapMode m_aMapMode; // PDFWriterImpl scaled units
667 std::vector< PDFPage > m_aPages;
668 /* maps object numbers to file offsets (needed for xref) */
669 std::vector< sal_uInt64 > m_aObjects;
670 /* contains Bitmaps until they are written to the
671 * file stream as XObjects*/
672 std::list< BitmapEmit > m_aBitmaps;
673 /* contains JPG streams until written to file */
674 std::vector<JPGEmit> m_aJPGs;
675 /*--->i56629 contains all named destinations ever set during the PDF creation,
676 destination id is always the destination's position in this vector
677 */
678 std::vector<PDFNamedDest> m_aNamedDests;
679 /* contains all dests ever set during the PDF creation,
680 dest id is always the dest's position in this vector
681 */
682 std::vector<PDFDest> m_aDests;
685 ::std::map< sal_Int32, sal_Int32 > m_aDestinationIdTranslation;
686 /* contains all links ever set during PDF creation,
687 link id is always the link's position in this vector
688 */
689 std::vector<PDFLink> m_aLinks;
691 std::vector<PDFScreen> m_aScreens;
693 std::vector<PDFEmbeddedFile> m_aEmbeddedFiles;
694 /* makes correctly encoded for export to PDF URLS
695 */
696 css::uno::Reference< css::util::XURLTransformer > m_xTrans;
697 /* maps arbitrary link ids for structure attributes to real link ids
698 (for setLinkPropertyId)
699 */
700 std::map<sal_Int32, sal_Int32> m_aLinkPropertyMap;
701 /* contains all outline items,
702 object 0 is the outline root
703 */
704 std::vector<PDFOutlineEntry> m_aOutline;
705 /* contains all notes set during PDF creation
706 */
707 std::vector<PDFNoteEntry> m_aNotes;
708 /* the root of the structure tree
709 */
710 std::vector<PDFStructureElement> m_aStructure;
711 /* current object in the structure hierarchy
712 */
714 /* structure parent tree */
715 std::vector< OString > m_aStructParentTree;
716 /* emit structure marks currently (aka. NonStructElement or not)
717 */
719 /* role map of struct tree root */
720 std::unordered_map< OString, OString >
722
723 /* contains all widgets used in the PDF
724 */
725 std::vector<PDFWidget> m_aWidgets;
726 /* maps radio group id to index of radio group control in m_aWidgets */
727 std::map< sal_Int32, sal_Int32 > m_aRadioGroupWidgets;
728 /* unordered_map for field names, used to ensure unique field names */
729 std::unordered_map< OString, sal_Int32 > m_aFieldNameMap;
730
731 /* contains Bitmaps for gradient functions until they are written
732 * to the file stream */
733 std::list< GradientEmit > m_aGradients;
734 /* contains bitmap tiling patterns */
735 std::vector< TilingEmit > m_aTilings;
736 std::vector< TransparencyEmit > m_aTransparentObjects;
737 /* contains all font subsets in use */
738 std::map<const vcl::font::PhysicalFontFace*, FontSubset> m_aSubsets;
739 std::map<const vcl::font::PhysicalFontFace*, EmbedFont> m_aSystemFonts;
740 sal_Int32 m_nNextFID;
742
745 std::shared_ptr<SvMemoryStream>> m_aPDFBmpCache;
746
747 sal_Int32 m_nCurrentPage;
748
750 // object number of the main signature dictionary
757 std::map< sal_Int32, sal_Int32 > m_aBuildinFontToObjectMap;
758
760 osl::File m_aFile;
762
764
765 /* output redirection; e.g. to accumulate content streams for
766 XObjects
767 */
768 std::list< StreamRedirect > m_aOutputStreams;
769
770 std::list< GraphicsState > m_aGraphicsStack;
772
773 std::unique_ptr<ZCodec> m_pCodec;
774 std::unique_ptr<SvMemoryStream> m_pMemStream;
775
776 std::vector< PDFAddStream > m_aAdditionalStreams;
777 std::set< PDFWriter::ErrorCode > m_aErrors;
778
780
781/*
782variables for PDF security
783i12626
784*/
785/* used to cipher the stream data and for password management */
786 rtlCipher m_aCipher;
787 /* pad string used for password in Standard security handler */
789
790 /* the encryption key, formed with the user password according to algorithm 3.2, maximum length is 16 bytes + 3 + 2
791 for 128 bit security */
792 sal_Int32 m_nKeyLength; // key length, 16 or 5
793 sal_Int32 m_nRC4KeyLength; // key length, 16 or 10, to be input to the algorithm 3.1
794
795 /* set to true if the following stream must be encrypted, used inside writeBuffer() */
797
798 /* the numerical value of the access permissions, according to PDF spec, must be signed */
800 /* string to hold the PDF creation date */
802 /* string to hold the PDF creation date, for PDF/A metadata */
804 /* the buffer where the data are encrypted, dynamically allocated */
805 std::vector<sal_uInt8> m_vEncryptionBuffer;
806
807 void addRoleMap(OString aAlias, PDFWriter::StructElement eType);
808
809 /* this function implements part of the PDF spec algorithm 3.1 in encryption, the rest (the actual encryption) is in PDFWriterImpl::writeBuffer */
810 void checkAndEnableStreamEncryption( sal_Int32 nObject ) override;
811
812 void disableStreamEncryption() override { m_bEncryptThisStream = false; };
813
814 /* */
815 void enableStringEncryption( sal_Int32 nObject );
816
817// test if the encryption is active, if yes than encrypt the unicode string and add to the OStringBuffer parameter
818 void appendUnicodeTextStringEncrypt( const OUString& rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer );
819
820 void appendLiteralStringEncrypt( std::u16string_view rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer, rtl_TextEncoding nEnc = RTL_TEXTENCODING_ASCII_US );
821 void appendLiteralStringEncrypt( std::string_view rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer );
822
823 /* creates fonts and subsets that will be emitted later */
824 void registerGlyph(const GlyphItem* pGlyph, const vcl::font::PhysicalFontFace* pFont, const std::vector<sal_Ucs>& rCodeUnits, sal_Int32 nGlyphWidth, sal_uInt8& nMappedGlyph, sal_Int32& nMappedFontObject);
825
826 /* emits a text object according to the passed layout */
827 /* TODO: remove rText as soon as SalLayout will change so that rText is not necessary anymore */
828 void drawVerticalGlyphs( const std::vector<PDFGlyph>& rGlyphs, OStringBuffer& rLine, const Point& rAlignOffset, const Matrix3& rRotScale, double fAngle, double fXScale, double fSkew, sal_Int32 nFontHeight );
829 void drawHorizontalGlyphs( const std::vector<PDFGlyph>& rGlyphs, OStringBuffer& rLine, const Point& rAlignOffset, bool bFirst, double fAngle, double fXScale, double fSkew, sal_Int32 nFontHeight, sal_Int32 nPixelFontHeight );
830 void drawLayout( SalLayout& rLayout, const OUString& rText, bool bTextLines );
831 void drawRelief( SalLayout& rLayout, const OUString& rText, bool bTextLines );
832 void drawShadow( SalLayout& rLayout, const OUString& rText, bool bTextLines );
833
834 /* writes differences between graphics stack and current real PDF
835 * state to the file
836 */
838
839 /* writes a transparency group object */
841
842 /* writes an XObject of type image, may create
843 a second for the mask
844 */
845 bool writeBitmapObject( const BitmapEmit& rObject, bool bMask = false );
846
847 void writeJPG( const JPGEmit& rEmit );
850
851 /* tries to find the bitmap by its id and returns its emit data if exists,
852 else creates a new emit data block */
853 const BitmapEmit& createBitmapEmit( const BitmapEx& rBitmapEx, const Graphic& rGraphic );
854
855 /* writes the Do operation inside the content stream */
856 void drawBitmap( const Point& rDestPt, const Size& rDestSize, const BitmapEmit& rBitmap, const Color& rFillColor );
857 /* write the function object for a Gradient */
858 bool writeGradientFunction( GradientEmit const & rObject );
859 /* creates a GradientEmit and returns its object number */
860 sal_Int32 createGradient( const Gradient& rGradient, const Size& rSize );
861
862 /* writes all tilings */
863 bool emitTilings();
864 /* writes all gradient patterns */
865 bool emitGradients();
866 /* writes a builtin font object and returns its objectid (or 0 in case of failure ) */
867 sal_Int32 emitBuildinFont( const pdf::BuildinFontFace*, sal_Int32 nObject );
868 /* writes a type1 system font object and returns its mapping from font ids to object ids (or 0 in case of failure ) */
869 std::map< sal_Int32, sal_Int32 > emitSystemFont(const vcl::font::PhysicalFontFace*, EmbedFont const &);
870 /* writes a font descriptor and returns its object id (or 0) */
871 sal_Int32 emitFontDescriptor(const vcl::font::PhysicalFontFace*, FontSubsetInfo const &, sal_Int32 nSubsetID, sal_Int32 nStream);
872 /* writes a ToUnicode cmap, returns the corresponding stream object */
873 sal_Int32 createToUnicodeCMap( sal_uInt8 const * pEncoding, const sal_Ucs* pCodeUnits, const sal_Int32* pCodeUnitsPerGlyph,
874 const sal_Int32* pEncToUnicodeIndex, int nGlyphs );
875
876 /* get resource dict object number */
878 {
879 if( m_nResourceDict <= 0 )
881 return m_nResourceDict;
882 }
883 /* get the font dict object */
885 {
886 if( m_nFontDictObject <= 0 )
888 return m_nFontDictObject;
889 }
890 /* push resource into current (redirected) resource dict */
891 void pushResource( ResourceKind eKind, const OString& rResource, sal_Int32 nObject );
892
893 void appendBuildinFontsToDict( OStringBuffer& rDict ) const;
894 /* writes the font dictionary and emits all font objects
895 * returns object id of font directory (or 0 on error)
896 */
897 bool emitFonts();
898 /* writes the Resource dictionary;
899 * returns dict object id (or 0 on error)
900 */
901 sal_Int32 emitResources();
902 // appends a dest
903 bool appendDest( sal_Int32 nDestID, OStringBuffer& rBuffer );
904 // write all links
905 bool emitLinkAnnotations();
906 // Write all screen annotations.
908
909 void emitTextAnnotationLine(OStringBuffer & aLine, PDFNoteEntry const & rNote);
910 static void emitPopupAnnotationLine(OStringBuffer & aLine, PDFPopupAnnotation const & rPopUp);
911 // write all notes
912 bool emitNoteAnnotations();
913
914 // write the appearance streams of a widget
915 bool emitAppearances( PDFWidget& rWidget, OStringBuffer& rAnnotDict );
916 // clean up radio button "On" values
918 // write all widgets
920 // writes all annotation objects
921 bool emitAnnotations();
923 bool emitEmbeddedFiles();
924 //write the named destination stuff
925 sal_Int32 emitNamedDestinations();//i56629
926 // writes outline dict and tree
927 sal_Int32 emitOutline();
928 // puts the attribute objects of a structure element into the returned string,
929 // helper for emitStructure
931 //--->i94258
932 // the maximum array elements allowed for PDF array object
933 static const sal_uInt32 ncMaxPDFArraySize = 8191;
934 //check if internal dummy container are needed in the structure elements
936 //<---i94258
937 // writes document structure
938 sal_Int32 emitStructure( PDFStructureElement& rEle );
939 // writes structure parent tree
940 sal_Int32 emitStructParentTree( sal_Int32 nTreeObject );
941 // writes page tree and catalog
942 bool emitCatalog();
943 // writes signature dictionary object
945 // creates a PKCS7 object using the ByteRange and overwrite /Contents
946 // of the signature dictionary
948 // writes xref and trailer
949 bool emitTrailer();
950 // emit additional streams collected; also create there object numbers
952 // emits info dict (if applicable)
953 sal_Int32 emitInfoDict( );
954
955 // acrobat reader 5 and 6 use the order of the annotations
956 // as their tab order; since PDF1.5 one can make the
957 // tab order explicit by using the structure tree
958 void sortWidgets();
959
960 // updates the count numbers of outline items
961 sal_Int32 updateOutlineItemCount( std::vector< sal_Int32 >& rCounts,
962 sal_Int32 nItemLevel,
963 sal_Int32 nCurrentItemId );
964 // default appearances for widgets
965 sal_Int32 findRadioGroupWidget( const PDFWriter::RadioButtonWidget& rRadio );
966 Font replaceFont( const Font& rControlFont, const Font& rAppSetFont );
967 sal_Int32 getBestBuildinFont( const Font& rFont );
968 sal_Int32 getSystemFont( const Font& i_rFont );
969
970 // used for edit and listbox
971 Font drawFieldBorder( PDFWidget&, const PDFWriter::AnyWidget&, const StyleSettings& );
972
978
979 /* ensure proper escapement and uniqueness of field names */
980 void createWidgetFieldName( sal_Int32 i_nWidgetsIndex, const PDFWriter::AnyWidget& i_rInWidget );
982 sal_Int32 createObject() override;
984 bool updateObject( sal_Int32 n ) override;
985
987 bool writeBuffer( const void* pBuffer, sal_uInt64 nBytes ) override;
988 void beginCompression();
989 void endCompression();
990 void beginRedirect( SvStream* pStream, const tools::Rectangle& );
992
993 void endPage();
994
1005 bool checkEmitStructure();
1006
1007 /* draws an emphasis mark */
1008 void drawEmphasisMark( tools::Long nX, tools::Long nY, const tools::PolyPolygon& rPolyPoly, bool bPolyLine, const tools::Rectangle& rRect1, const tools::Rectangle& rRect2 );
1009
1010 /* true if PDF/A-1a or PDF/A-1b is output */
1012 /* true if PDF/A-2a is output */
1014
1015 /* PDF/UA support enabled */
1017
1019
1021
1022 /*
1023 i12626
1024 methods for PDF security
1025
1026 pad a password according algorithm 3.2, step 1 */
1027 static void padPassword( std::u16string_view i_rPassword, sal_uInt8* o_pPaddedPW );
1028 /* algorithm 3.2: compute an encryption key */
1031 sal_Int32 i_nAccessPermissions
1032 );
1033 /* algorithm 3.3: computing the encryption dictionary'ss owner password value ( /O ) */
1034 static bool computeODictionaryValue( const sal_uInt8* i_pPaddedOwnerPassword, const sal_uInt8* i_pPaddedUserPassword,
1035 std::vector< sal_uInt8 >& io_rOValue,
1036 sal_Int32 i_nKeyLength
1037 );
1038 /* algorithm 3.4 or 3.5: computing the encryption dictionary's user password value ( /U ) revision 2 or 3 of the standard security handler */
1039 static bool computeUDictionaryValue( EncHashTransporter* i_pTransporter,
1041 sal_Int32 i_nKeyLength,
1042 sal_Int32 i_nAccessPermissions
1043 );
1044
1045 static void computeDocumentIdentifier( std::vector< sal_uInt8 >& o_rIdentifier,
1046 const vcl::PDFWriter::PDFDocInfo& i_rDocInfo,
1047 const OString& i_rCString1,
1048 OString& o_rCString2
1049 );
1050 static sal_Int32 computeAccessPermissions( const vcl::PDFWriter::PDFEncryptionProperties& i_rProperties,
1051 sal_Int32& o_rKeyLength, sal_Int32& o_rRC4KeyLength );
1052 void setupDocInfo();
1053 bool prepareEncryption( const css::uno::Reference< css::beans::XMaterialHolder >& );
1054
1055 // helper for playMetafile
1056 void implWriteGradient( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient,
1058 void implWriteBitmapEx( const Point& rPoint, const Size& rSize, const BitmapEx& rBitmapEx, const Graphic& i_pGraphic,
1059 VirtualDevice const * pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& );
1060
1061 // helpers for CCITT 1bit bitmap stream
1062 void putG4Bits( sal_uInt32 i_nLength, sal_uInt32 i_nCode, BitStreamState& io_rState );
1063 void putG4Span( tools::Long i_nSpan, bool i_bWhitePixel, BitStreamState& io_rState );
1064 void writeG4Stream( BitmapReadAccess const * i_pBitmap );
1065
1066 // color helper functions
1067 void appendStrokingColor( const Color& rColor, OStringBuffer& rBuffer );
1068 void appendNonStrokingColor( const Color& rColor, OStringBuffer& rBuffer );
1069public:
1070 PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext, const css::uno::Reference< css::beans::XMaterialHolder >&, PDFWriter& );
1071 ~PDFWriterImpl() override;
1072 void dispose() override;
1073
1074 static css::uno::Reference< css::beans::XMaterialHolder >
1075 initEncryption( const OUString& i_rOwnerPassword,
1076 const OUString& i_rUserPassword );
1077
1078 /* document structure */
1079 void newPage( double nPageWidth , double nPageHeight, PDFWriter::Orientation eOrientation );
1080 bool emit();
1081 const std::set< PDFWriter::ErrorCode > & getErrors() const { return m_aErrors;}
1082 void insertError( PDFWriter::ErrorCode eErr ) { m_aErrors.insert( eErr ); }
1084
1086 {
1087 Size aSize;
1090 return aSize;
1091 }
1092
1093 void setDocumentLocale( const css::lang::Locale& rLoc )
1094 { m_aContext.DocumentLocale = rLoc; }
1095
1096 /* graphics state */
1097 void push( PushFlags nFlags );
1098 void pop();
1099
1100 void setFont( const Font& rFont );
1101
1102 void setMapMode( const MapMode& rMapMode );
1103
1104 const MapMode& getMapMode() { return m_aGraphicsStack.front().m_aMapMode; }
1105
1106 void setLineColor( const Color& rColor )
1107 {
1108 m_aGraphicsStack.front().m_aLineColor = rColor.IsTransparent() ? COL_TRANSPARENT : rColor;
1109 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::LineColor;
1110 }
1111
1112 void setFillColor( const Color& rColor )
1113 {
1114 m_aGraphicsStack.front().m_aFillColor = rColor.IsTransparent() ? COL_TRANSPARENT : rColor;
1115 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::FillColor;
1116 }
1117
1119 {
1120 m_aGraphicsStack.front().m_aTextLineColor = COL_TRANSPARENT;
1121 }
1122
1123 void setTextLineColor( const Color& rColor )
1124 {
1125 m_aGraphicsStack.front().m_aTextLineColor = rColor;
1126 }
1127
1129 {
1130 m_aGraphicsStack.front().m_aOverlineColor = COL_TRANSPARENT;
1131 }
1132
1133 void setOverlineColor( const Color& rColor )
1134 {
1135 m_aGraphicsStack.front().m_aOverlineColor = rColor;
1136 }
1137
1138 void setTextFillColor( const Color& rColor )
1139 {
1140 m_aGraphicsStack.front().m_aFont.SetFillColor( rColor );
1141 m_aGraphicsStack.front().m_aFont.SetTransparent( rColor.IsTransparent() );
1142 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
1143 }
1145 {
1146 m_aGraphicsStack.front().m_aFont.SetFillColor( COL_TRANSPARENT );
1147 m_aGraphicsStack.front().m_aFont.SetTransparent( true );
1148 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
1149 }
1150 void setTextColor( const Color& rColor )
1151 {
1152 m_aGraphicsStack.front().m_aFont.SetColor( rColor );
1153 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
1154 }
1155
1157 {
1158 m_aGraphicsStack.front().m_aClipRegion.clear();
1159 m_aGraphicsStack.front().m_bClipRegion = false;
1161 }
1162
1163 void setClipRegion( const basegfx::B2DPolyPolygon& rRegion );
1164
1165 void moveClipRegion( sal_Int32 nX, sal_Int32 nY );
1166
1167 void intersectClipRegion( const tools::Rectangle& rRect );
1168
1169 void intersectClipRegion( const basegfx::B2DPolyPolygon& rRegion );
1170
1172 {
1173 m_aGraphicsStack.front().m_nLayoutMode = nLayoutMode;
1175 }
1176
1178 {
1179 m_aGraphicsStack.front().m_aDigitLanguage = eLang;
1181 }
1182
1184 {
1185 m_aGraphicsStack.front().m_aFont.SetAlignment( eAlign );
1186 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
1187 }
1188
1189 /* actual drawing functions */
1190 void drawText( const Point& rPos, const OUString& rText, sal_Int32 nIndex, sal_Int32 nLen, bool bTextLines = true );
1191 void drawTextArray( const Point& rPos, const OUString& rText, o3tl::span<const sal_Int32> pDXArray, sal_Int32 nIndex, sal_Int32 nLen );
1192 void drawStretchText( const Point& rPos, sal_uLong nWidth, const OUString& rText,
1193 sal_Int32 nIndex, sal_Int32 nLen );
1194 void drawText( const tools::Rectangle& rRect, const OUString& rOrigStr, DrawTextFlags nStyle );
1195 void drawTextLine( const Point& rPos, tools::Long nWidth, FontStrikeout eStrikeout, FontLineStyle eUnderline, FontLineStyle eOverline, bool bUnderlineAbove );
1196 void drawWaveTextLine( OStringBuffer& aLine, tools::Long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove );
1197 void drawStraightTextLine( OStringBuffer& aLine, tools::Long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove );
1198 void drawStrikeoutLine( OStringBuffer& aLine, tools::Long nWidth, FontStrikeout eStrikeout, Color aColor );
1199 void drawStrikeoutChar( const Point& rPos, tools::Long nWidth, FontStrikeout eStrikeout );
1200
1201 void drawLine( const Point& rStart, const Point& rStop );
1202 void drawLine( const Point& rStart, const Point& rStop, const LineInfo& rInfo );
1203 void drawPolygon( const tools::Polygon& rPoly );
1204 void drawPolyPolygon( const tools::PolyPolygon& rPolyPoly );
1205 void drawPolyLine( const tools::Polygon& rPoly );
1206 void drawPolyLine( const tools::Polygon& rPoly, const LineInfo& rInfo );
1207 void drawPolyLine( const tools::Polygon& rPoly, const PDFWriter::ExtLineInfo& rInfo );
1208
1209 void drawPixel( const Point& rPt, const Color& rColor );
1210
1211 void drawRectangle( const tools::Rectangle& rRect );
1212 void drawRectangle( const tools::Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt32 nVertRound );
1213 void drawEllipse( const tools::Rectangle& rRect );
1214 void drawArc( const tools::Rectangle& rRect, const Point& rStart, const Point& rStop, bool bWithPie, bool bWidthChord );
1215
1216 void drawBitmap( const Point& rDestPoint, const Size& rDestSize, const Bitmap& rBitmap, const Graphic& rGraphic );
1217 void drawBitmap( const Point& rDestPoint, const Size& rDestSize, const BitmapEx& rBitmap );
1218 void drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const Size& rSizePixel, const tools::Rectangle& rTargetArea, const AlphaMask& rAlphaMask, const Graphic& rGraphic );
1220 void createEmbeddedFile(const Graphic& rGraphic, ReferenceXObjectEmit& rEmit, sal_Int32 nBitmapObject);
1221
1222 void drawGradient( const tools::Rectangle& rRect, const Gradient& rGradient );
1223 void drawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch );
1224 void drawWallpaper( const tools::Rectangle& rRect, const Wallpaper& rWall );
1225 void drawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uInt32 nTransparentPercent );
1227 void endTransparencyGroup( const tools::Rectangle& rBoundingBox, sal_uInt32 nTransparentPercent );
1228
1229 void emitComment( const char* pComment );
1230
1231 //--->i56629 named destinations
1232 sal_Int32 createNamedDest( const OUString& sDestName, const tools::Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType );
1233
1234 //--->i59651
1235 //emits output intent
1236 sal_Int32 emitOutputIntent();
1237
1238 //emits the document metadata
1239 sal_Int32 emitDocumentMetadata();
1240
1241 // links
1242 sal_Int32 createLink( const tools::Rectangle& rRect, sal_Int32 nPageNr );
1243 sal_Int32 createDest( const tools::Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType );
1244 sal_Int32 registerDestReference( sal_Int32 nDestId, const tools::Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType );
1245 void setLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId );
1246 void setLinkURL( sal_Int32 nLinkId, const OUString& rURL );
1247 void setLinkPropertyId( sal_Int32 nLinkId, sal_Int32 nPropertyId );
1248
1249 // screens
1250 sal_Int32 createScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr);
1251 void setScreenURL(sal_Int32 nScreenId, const OUString& rURL);
1252 void setScreenStream(sal_Int32 nScreenId, const OUString& rURL);
1253
1254 // outline
1255 sal_Int32 createOutlineItem( sal_Int32 nParent, std::u16string_view rText, sal_Int32 nDestID );
1256 void setOutlineItemParent( sal_Int32 nItem, sal_Int32 nNewParent );
1257 void setOutlineItemText( sal_Int32 nItem, std::u16string_view rText );
1258 void setOutlineItemDest( sal_Int32 nItem, sal_Int32 nDestID );
1259
1260 // notes
1261 void createNote( const tools::Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr );
1262 // structure elements
1263 sal_Int32 beginStructureElement( PDFWriter::StructElement eType, const OUString& rAlias );
1264 void endStructureElement();
1265 bool setCurrentStructureElement( sal_Int32 nElement );
1267 bool setStructureAttributeNumerical( enum PDFWriter::StructAttribute eAttr, sal_Int32 nValue );
1268 void setStructureBoundingBox( const tools::Rectangle& rRect );
1269 void setActualText( const OUString& rText );
1270 void setAlternateText( const OUString& rText );
1271
1272 // transitional effects
1273 void setPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr );
1274
1275 // controls
1276 sal_Int32 createControl( const PDFWriter::AnyWidget& rControl, sal_Int32 nPageNr = -1 );
1277
1278 // additional streams
1279 void addStream( const OUString& rMimeType, PDFOutputStream* pStream );
1280
1281 // helper: eventually begin marked content sequence and
1282 // emit a comment in debug case
1283 void MARK( const char* pString );
1284};
1285
1286} // namespace vcl
1287
1288/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DrawTextFlags
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
Container for the binary data, whose responsibility is to manage the make it as simple as possible to...
bool IsTransparent() const
Definition: hatch.hxx:47
A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for refer...
Definition: vclptr.hxx:58
Allows creating, updating and writing PDF objects in a container.
static void computeDocumentIdentifier(std::vector< sal_uInt8 > &o_rIdentifier, const vcl::PDFWriter::PDFDocInfo &i_rDocInfo, const OString &i_rCString1, OString &o_rCString2)
void registerGlyph(const GlyphItem *pGlyph, const vcl::font::PhysicalFontFace *pFont, const std::vector< sal_Ucs > &rCodeUnits, sal_Int32 nGlyphWidth, sal_uInt8 &nMappedGlyph, sal_Int32 &nMappedFontObject)
std::list< GradientEmit > m_aGradients
void setDocumentLocale(const css::lang::Locale &rLoc)
sal_Int64 m_nSignatureContentOffset
void drawWallpaper(const tools::Rectangle &rRect, const Wallpaper &rWall)
void setTextAlign(TextAlign eAlign)
std::map< sal_Int32, sal_Int32 > m_aLinkPropertyMap
void moveClipRegion(sal_Int32 nX, sal_Int32 nY)
void setLayoutMode(vcl::text::ComplexTextLayoutFlags nLayoutMode)
sal_Int64 m_nSignatureLastByteRangeNoOffset
bool updateObject(sal_Int32 n) override
See vcl::PDFObjectContainer::updateObject().
sal_Int32 createLink(const tools::Rectangle &rRect, sal_Int32 nPageNr)
void drawEllipse(const tools::Rectangle &rRect)
static bool computeODictionaryValue(const sal_uInt8 *i_pPaddedOwnerPassword, const sal_uInt8 *i_pPaddedUserPassword, std::vector< sal_uInt8 > &io_rOValue, sal_Int32 i_nKeyLength)
void addInternalStructureContainer(PDFStructureElement &rEle)
void putG4Bits(sal_uInt32 i_nLength, sal_uInt32 i_nCode, BitStreamState &io_rState)
void enableStringEncryption(sal_Int32 nObject)
void setFont(const Font &rFont)
sal_Int32 findRadioGroupWidget(const PDFWriter::RadioButtonWidget &rRadio)
void setAlternateText(const OUString &rText)
sal_Int32 emitBuildinFont(const pdf::BuildinFontFace *, sal_Int32 nObject)
void addStream(const OUString &rMimeType, PDFOutputStream *pStream)
sal_Int32 emitStructParentTree(sal_Int32 nTreeObject)
sal_Int32 emitFontDescriptor(const vcl::font::PhysicalFontFace *, FontSubsetInfo const &, sal_Int32 nSubsetID, sal_Int32 nStream)
static void convertLineInfoToExtLineInfo(const LineInfo &rIn, PDFWriter::ExtLineInfo &rOut)
std::set< PDFWriter::ErrorCode > m_aErrors
void ImplRefreshFontData(bool bNewFontLists) override
void createNote(const tools::Rectangle &rRect, const PDFNote &rNote, sal_Int32 nPageNr)
std::map< const vcl::font::PhysicalFontFace *, FontSubset > m_aSubsets
void setActualText(const OUString &rText)
static css::uno::Reference< css::beans::XMaterialHolder > initEncryption(const OUString &i_rOwnerPassword, const OUString &i_rUserPassword)
std::map< const vcl::font::PhysicalFontFace *, EmbedFont > m_aSystemFonts
static void emitPopupAnnotationLine(OStringBuffer &aLine, PDFPopupAnnotation const &rPopUp)
static void padPassword(std::u16string_view i_rPassword, sal_uInt8 *o_pPaddedPW)
void drawPolyLine(const tools::Polygon &rPoly)
std::list< GraphicsState > m_aGraphicsStack
GraphicsState m_aCurrentPDFState
std::unordered_map< OString, OString > m_aRoleMap
void pushResource(ResourceKind eKind, const OString &rResource, sal_Int32 nObject)
void createWidgetFieldName(sal_Int32 i_nWidgetsIndex, const PDFWriter::AnyWidget &i_rInWidget)
sal_Int32 createControl(const PDFWriter::AnyWidget &rControl, sal_Int32 nPageNr=-1)
sal_Int32 createToUnicodeCMap(sal_uInt8 const *pEncoding, const sal_Ucs *pCodeUnits, const sal_Int32 *pCodeUnitsPerGlyph, const sal_Int32 *pEncToUnicodeIndex, int nGlyphs)
void writeTransparentObject(TransparencyEmit &rObject)
sal_Int32 m_nCurrentStructElement
static const char * getStructureTag(PDFWriter::StructElement)
void drawPolyPolygon(const tools::PolyPolygon &rPolyPoly)
void addRoleMap(OString aAlias, PDFWriter::StructElement eType)
OString emitStructureAttributes(PDFStructureElement &rEle)
std::vector< PDFLink > m_aLinks
std::vector< PDFEmbeddedFile > m_aEmbeddedFiles
Contains embedded files.
static sal_Int32 computeAccessPermissions(const vcl::PDFWriter::PDFEncryptionProperties &i_rProperties, sal_Int32 &o_rKeyLength, sal_Int32 &o_rRC4KeyLength)
void appendLiteralStringEncrypt(std::u16string_view rInString, const sal_Int32 nInObjectNumber, OStringBuffer &rOutBuffer, rtl_TextEncoding nEnc=RTL_TEXTENCODING_ASCII_US)
void setTextLineColor(const Color &rColor)
std::map< sal_Int32, sal_Int32 > m_aRadioGroupWidgets
std::list< StreamRedirect > m_aOutputStreams
void drawGradient(const tools::Rectangle &rRect, const Gradient &rGradient)
void drawTextLine(const Point &rPos, tools::Long nWidth, FontStrikeout eStrikeout, FontLineStyle eUnderline, FontLineStyle eOverline, bool bUnderlineAbove)
OString m_aCreationMetaDateString
void newPage(double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation)
void drawVerticalGlyphs(const std::vector< PDFGlyph > &rGlyphs, OStringBuffer &rLine, const Point &rAlignOffset, const Matrix3 &rRotScale, double fAngle, double fXScale, double fSkew, sal_Int32 nFontHeight)
static bool computeEncryptionKey(EncHashTransporter *, vcl::PDFWriter::PDFEncryptionProperties &io_rProperties, sal_Int32 i_nAccessPermissions)
void drawStraightTextLine(OStringBuffer &aLine, tools::Long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove)
void dispose() override
void setOutlineItemDest(sal_Int32 nItem, sal_Int32 nDestID)
bool writeGradientFunction(GradientEmit const &rObject)
void drawText(const Point &rPos, const OUString &rText, sal_Int32 nIndex, sal_Int32 nLen, bool bTextLines=true)
std::map< sal_Int32, sal_Int32 > emitSystemFont(const vcl::font::PhysicalFontFace *, EmbedFont const &)
void createDefaultRadioButtonAppearance(PDFWidget &, const PDFWriter::RadioButtonWidget &rWidget)
void DrawHatchLine_DrawLine(const Point &rStartPoint, const Point &rEndPoint) override
void writeG4Stream(BitmapReadAccess const *i_pBitmap)
PDFWriter::PDFWriterContext m_aContext
void createDefaultPushButtonAppearance(PDFWidget &, const PDFWriter::PushButtonWidget &rWidget)
void drawStrikeoutLine(OStringBuffer &aLine, tools::Long nWidth, FontStrikeout eStrikeout, Color aColor)
void setOutlineItemText(sal_Int32 nItem, std::u16string_view rText)
std::list< BitmapEmit > m_aBitmaps
void setTextFillColor(const Color &rColor)
PDFWriterImpl(const PDFWriter::PDFWriterContext &rContext, const css::uno::Reference< css::beans::XMaterialHolder > &, PDFWriter &)
std::vector< PDFAddStream > m_aAdditionalStreams
std::vector< PDFNamedDest > m_aNamedDests
bool checkEmitStructure()
checks whether a non struct element lies in the ancestor hierarchy of the current structure element
void setMapMode(const MapMode &rMapMode)
sal_Int32 emitDocumentMetadata()
void setOutlineItemParent(sal_Int32 nItem, sal_Int32 nNewParent)
void checkAndEnableStreamEncryption(sal_Int32 nObject) override
bool emitEmbeddedFiles()
Writes embedded files.
sal_Int32 updateOutlineItemCount(std::vector< sal_Int32 > &rCounts, sal_Int32 nItemLevel, sal_Int32 nCurrentItemId)
void setLinkURL(sal_Int32 nLinkId, const OUString &rURL)
Size getCurPageSize() const
void endTransparencyGroup(const tools::Rectangle &rBoundingBox, sal_uInt32 nTransparentPercent)
std::unique_ptr< SvMemoryStream > m_pMemStream
const BitmapEmit & createBitmapEmit(const BitmapEx &rBitmapEx, const Graphic &rGraphic)
void disableStreamEncryption() override
::comphelper::Hash m_DocDigest
void setScreenStream(sal_Int32 nScreenId, const OUString &rURL)
void drawArc(const tools::Rectangle &rRect, const Point &rStart, const Point &rStop, bool bWithPie, bool bWidthChord)
void drawStrikeoutChar(const Point &rPos, tools::Long nWidth, FontStrikeout eStrikeout)
void ImplClearFontData(bool bNewFontLists) override
std::vector< PDFPage > m_aPages
void appendBuildinFontsToDict(OStringBuffer &rDict) const
std::vector< sal_uInt8 > m_vEncryptionBuffer
void createDefaultEditAppearance(PDFWidget &, const PDFWriter::EditWidget &rWidget)
void insertError(PDFWriter::ErrorCode eErr)
const MapMode & getMapMode()
sal_Int32 getFontDictObject()
void writeReferenceXObject(const ReferenceXObjectEmit &rEmit)
Writes the form XObject proxy for the image.
void setStructureBoundingBox(const tools::Rectangle &rRect)
void createDefaultListBoxAppearance(PDFWidget &, const PDFWriter::ListBoxWidget &rWidget)
std::unordered_map< OString, sal_Int32 > m_aFieldNameMap
std::vector< TransparencyEmit > m_aTransparentObjects
void drawEmphasisMark(tools::Long nX, tools::Long nY, const tools::PolyPolygon &rPolyPoly, bool bPolyLine, const tools::Rectangle &rRect1, const tools::Rectangle &rRect2)
void createEmbeddedFile(const Graphic &rGraphic, ReferenceXObjectEmit &rEmit, sal_Int32 nBitmapObject)
Stores the original PDF data from rGraphic as an embedded file.
static const sal_uInt32 ncMaxPDFArraySize
void setDigitLanguage(LanguageType eLang)
bool setStructureAttribute(enum PDFWriter::StructAttribute eAttr, enum PDFWriter::StructAttributeValue eVal)
std::vector< OString > m_aStructParentTree
o3tl::lru_map< BitmapChecksum, std::shared_ptr< SvMemoryStream > > m_aPDFBmpCache
Cache some most recent bitmaps we've exported, in case we encounter them again..
void drawRelief(SalLayout &rLayout, const OUString &rText, bool bTextLines)
void appendStrokingColor(const Color &rColor, OStringBuffer &rBuffer)
void setLinkPropertyId(sal_Int32 nLinkId, sal_Int32 nPropertyId)
void playMetafile(const GDIMetaFile &, vcl::PDFExtOutDevData *, const vcl::PDFWriter::PlayMetafileContext &, VirtualDevice *pDummyDev=nullptr)
static const char * getAttributeTag(PDFWriter::StructAttribute eAtr)
sal_Int32 getBestBuildinFont(const Font &rFont)
void drawJPGBitmap(SvStream &rDCTData, bool bIsTrueColor, const Size &rSizePixel, const tools::Rectangle &rTargetArea, const AlphaMask &rAlphaMask, const Graphic &rGraphic)
sal_Int32 createNamedDest(const OUString &sDestName, const tools::Rectangle &rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType)
void drawHatch(const tools::PolyPolygon &rPolyPoly, const Hatch &rHatch)
void drawTransparent(const tools::PolyPolygon &rPolyPoly, sal_uInt32 nTransparentPercent)
sal_Int32 emitStructure(PDFStructureElement &rEle)
void push(PushFlags nFlags)
void setScreenURL(sal_Int32 nScreenId, const OUString &rURL)
std::vector< sal_uInt64 > m_aObjects
Font drawFieldBorder(PDFWidget &, const PDFWriter::AnyWidget &, const StyleSettings &)
void drawStretchText(const Point &rPos, sal_uLong nWidth, const OUString &rText, sal_Int32 nIndex, sal_Int32 nLen)
void implWriteGradient(const tools::PolyPolygon &rPolyPoly, const Gradient &rGradient, VirtualDevice *pDummyVDev, const vcl::PDFWriter::PlayMetafileContext &)
std::vector< TilingEmit > m_aTilings
std::map< sal_Int32, sal_Int32 > m_aBuildinFontToObjectMap
bool ImplNewFont() const override
sal_Int32 createScreen(const tools::Rectangle &rRect, sal_Int32 nPageNr)
sal_Int32 beginStructureElement(PDFWriter::StructElement eType, const OUString &rAlias)
sal_Int32 m_nAccessPermissions
void beginRedirect(SvStream *pStream, const tools::Rectangle &)
sal_Int32 emitOutputIntent()
void setOverlineColor(const Color &rColor)
sal_Int32 createGradient(const Gradient &rGradient, const Size &rSize)
sal_Int32 createObject() override
See vcl::PDFObjectContainer::createObject().
bool setCurrentStructureElement(sal_Int32 nElement)
void appendNonStrokingColor(const Color &rColor, OStringBuffer &rBuffer)
void createDefaultCheckBoxAppearance(PDFWidget &, const PDFWriter::CheckBoxWidget &rWidget)
void drawLine(const Point &rStart, const Point &rStop)
std::vector< PDFDest > m_aDests
void setFillColor(const Color &rColor)
void drawRectangle(const tools::Rectangle &rRect)
void drawLayout(SalLayout &rLayout, const OUString &rText, bool bTextLines)
void setTextColor(const Color &rColor)
void drawHorizontalGlyphs(const std::vector< PDFGlyph > &rGlyphs, OStringBuffer &rLine, const Point &rAlignOffset, bool bFirst, double fAngle, double fXScale, double fSkew, sal_Int32 nFontHeight, sal_Int32 nPixelFontHeight)
void drawTextArray(const Point &rPos, const OUString &rText, o3tl::span< const sal_Int32 > pDXArray, sal_Int32 nIndex, sal_Int32 nLen)
std::vector< PDFStructureElement > m_aStructure
void appendUnicodeTextStringEncrypt(const OUString &rInString, const sal_Int32 nInObjectNumber, OStringBuffer &rOutBuffer)
std::vector< JPGEmit > m_aJPGs
sal_Int32 m_nSignatureObject
bool setStructureAttributeNumerical(enum PDFWriter::StructAttribute eAttr, sal_Int32 nValue)
void drawBitmap(const Point &rDestPt, const Size &rDestSize, const BitmapEmit &rBitmap, const Color &rFillColor)
sal_Int32 getSystemFont(const Font &i_rFont)
std::vector< PDFScreen > m_aScreens
Contains all screen annotations.
static const char * getAttributeValueTag(PDFWriter::StructAttributeValue eVal)
void drawShadow(SalLayout &rLayout, const OUString &rText, bool bTextLines)
void writeJPG(const JPGEmit &rEmit)
void putG4Span(tools::Long i_nSpan, bool i_bWhitePixel, BitStreamState &io_rState)
bool prepareEncryption(const css::uno::Reference< css::beans::XMaterialHolder > &)
bool appendDest(sal_Int32 nDestID, OStringBuffer &rBuffer)
std::vector< PDFNoteEntry > m_aNotes
void setPageTransition(PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr)
void MARK(const char *pString)
void emitComment(const char *pComment)
ExternalPDFStreams m_aExternalPDFStreams
sal_Int32 registerDestReference(sal_Int32 nDestId, const tools::Rectangle &rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType)
sal_Int32 createOutlineItem(sal_Int32 nParent, std::u16string_view rText, sal_Int32 nDestID)
void emitTextAnnotationLine(OStringBuffer &aLine, PDFNoteEntry const &rNote)
sal_Int32 getResourceDictObj()
ResourceDict m_aGlobalResourceDict
bool writeBuffer(const void *pBuffer, sal_uInt64 nBytes) override
See vcl::PDFObjectContainer::writeBuffer().
sal_Int32 createDest(const tools::Rectangle &rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType)
bool emitAppearances(PDFWidget &rWidget, OStringBuffer &rAnnotDict)
void intersectClipRegion(const tools::Rectangle &rRect)
vcl::Region ClipToDeviceBounds(vcl::Region aRegion) const override
Perform actual rect clip against outdev dimensions, to generate empty clips whenever one of the value...
void implWriteBitmapEx(const Point &rPoint, const Size &rSize, const BitmapEx &rBitmapEx, const Graphic &i_pGraphic, VirtualDevice const *pDummyVDev, const vcl::PDFWriter::PlayMetafileContext &)
void setLineColor(const Color &rColor)
void setLinkDest(sal_Int32 nLinkId, sal_Int32 nDestId)
void updateGraphicsState(Mode mode=Mode::DEFAULT)
css::uno::Reference< css::util::XURLTransformer > m_xTrans
void drawWaveTextLine(OStringBuffer &aLine, tools::Long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove)
std::vector< PDFWidget > m_aWidgets
static bool compressStream(SvMemoryStream *)
void setClipRegion(const basegfx::B2DPolyPolygon &rRegion)
sal_Int32 emitNamedDestinations()
bool writeBitmapObject(const BitmapEmit &rObject, bool bMask=false)
static bool computeUDictionaryValue(EncHashTransporter *i_pTransporter, vcl::PDFWriter::PDFEncryptionProperties &io_rProperties, sal_Int32 i_nKeyLength, sal_Int32 i_nAccessPermissions)
static const sal_uInt8 s_nPadString[ENCRYPTED_PWD_SIZE]
PDFFontCache m_aFontCache
::std::map< sal_Int32, sal_Int32 > m_aDestinationIdTranslation
contains destinations accessible via a public Id, instead of being linked to by an ordinary link
Font replaceFont(const Font &rControlFont, const Font &rAppSetFont)
SvStream * endRedirect()
void drawPolygon(const tools::Polygon &rPoly)
const std::set< PDFWriter::ErrorCode > & getErrors() const
std::vector< PDFOutlineEntry > m_aOutline
std::unique_ptr< ZCodec > m_pCodec
void drawPixel(const Point &rPt, const Color &rColor)
abstract base class for physical font faces
void addCode(sal_Ucs i_cCode)
std::vector< sal_Ucs > m_CodeUnits
const std::vector< sal_Ucs > & codes() const
void setGlyphWidth(sal_Int32 nWidth)
void setGlyphId(sal_uInt8 i_nId)
sal_Ucs getCode(sal_Int32 i_nIndex) const
sal_Int32 countCodes() const
sal_Int32 getGlyphWidth() const
sal_uInt8 getGlyphId() const
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
FontLineStyle
FontStrikeout
def text(shape, orig_st)
NONE
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
FormatType
TextAlign
long Long
A PhysicalFontFaceCollection is created by a PhysicalFontCollection and becomes invalid when original...
constexpr sal_Int32 g_nInheritedPageWidth
constexpr sal_Int32 g_nInheritedPageHeight
ComplexTextLayoutFlags
Definition: State.hxx:76
PushFlags
Definition: State.hxx:40
constexpr sal_Int32 MAXIMUM_RC4_KEY_LENGTH
constexpr sal_Int32 MD5_DIGEST_SIZE
constexpr sal_Int32 ENCRYPTED_PWD_SIZE
constexpr sal_Int32 SECUR_128BIT_KEY
sal_Unicode sal_Ucs
Definition: salgdi.hxx:65
sal_uIntPtr sal_uLong
Homogeneous 2D transformation matrix.
css::lang::Locale DocumentLocale
Definition: pdfwriter.hxx:622
Play a metafile like an outputdevice would do.
Definition: pdfwriter.hxx:687
ReferenceXObjectEmit m_aReferenceXObject
std::map< sal_GlyphId, GlyphEmit > m_aMapping
FontEmit(sal_Int32 nID)
std::vector< FontEmit > m_aSubsets
std::map< sal_GlyphId, Glyph > m_aMapping
sal_uInt8 m_nSubsetGlyphID
vcl::text::ComplexTextLayoutFlags m_nLayoutMode
basegfx::B2DPolyPolygon m_aClipRegion
GraphicsStateUpdateFlags m_nUpdateFlags
std::unique_ptr< SvMemoryStream > m_pStream
ReferenceXObjectEmit m_aReferenceXObject
PDFOutputStream * m_pStream
tools::Rectangle m_aRect
PDFWriter::DestAreaType m_eType
tools::Rectangle m_aRect
A PDF embedded file.
BinaryDataContainer m_aDataContainer
Contents of the file.
sal_Int32 m_nObject
ID of the file.
sal_uInt8 const m_nMappedGlyphId
sal_Int32 const m_nMappedFontId
PDFGlyph(const Point &rPos, const GlyphItem *pGlyph, sal_Int32 nNativeWidth, sal_Int32 nFontId, sal_uInt8 nMappedGlyphId, int nCharPos)
sal_Int32 const m_nNativeWidth
const GlyphItem * m_pGlyph
PDFWriter::DestAreaType m_eType
tools::Rectangle m_aRect
PDFPopupAnnotation m_aPopUpAnnotation
std::vector< sal_Int32 > m_aChildren
PDFPage(PDFWriterImpl *pWriter, double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation)
void appendWaveLine(sal_Int32 nLength, sal_Int32 nYOffset, sal_Int32 nDelta, OStringBuffer &rBuffer) const
sal_uInt64 m_nBeginStreamPos
void appendPoint(const Point &rPoint, OStringBuffer &rBuffer) const
void appendPixelPoint(const basegfx::B2DPoint &rPoint, OStringBuffer &rBuffer) const
void convertRect(tools::Rectangle &rRect) const
VclPtr< PDFWriterImpl > m_pWriter
void appendMatrix3(Matrix3 const &rMatrix, OStringBuffer &rBuffer)
std::vector< sal_Int32 > m_aAnnotations
void appendRect(const tools::Rectangle &rRect, OStringBuffer &rBuffer) const
sal_Int32 m_nUserUnit
A positive number that gives the size of default user space units, in multiples of points.
bool appendLineInfo(const LineInfo &rInfo, OStringBuffer &rBuffer) const
std::vector< sal_Int32 > m_aMCIDParents
double getHeight() const
void appendMappedLength(sal_Int32 nLength, OStringBuffer &rBuffer, bool bVertical=true, sal_Int32 *pOutLength=nullptr) const
sal_Int32 m_nStreamLengthObject
bool emit(sal_Int32 nParentPage)
void appendPolygon(const tools::Polygon &rPoly, OStringBuffer &rBuffer, bool bClose=true) const
PDFWriter::Orientation m_eOrientation
std::vector< sal_Int32 > m_aStreamObjects
void appendPolyPolygon(const tools::PolyPolygon &rPolyPoly, OStringBuffer &rBuffer) const
PDFWriter::PageTransition m_eTransition
sal_Int32 m_nParentObject
ID of the parent object.
A PDF Screen annotation.
OUString m_aTempFileURL
Embedded video.
sal_Int32 m_nTempFileObject
ID of the EmbeddedFile object.
OUString m_aURL
Linked video.
PDFWriter::StructAttributeValue eValue
PDFStructureAttribute(PDFWriter::StructAttributeValue eVal)
PDFStructureElementKid(sal_Int32 MCID, sal_Int32 nPage)
std::list< sal_Int32 > m_aChildren
std::map< PDFWriter::StructAttribute, PDFStructureAttribute > m_aAttributes
std::list< PDFStructureElementKid > m_aKids
PDFWriter::StructElement m_eType
DrawTextFlags m_nTextStyle
std::unordered_map< OString, PDFAppearanceStreams > m_aAppearances
PDFWriter::WidgetType m_eType
std::vector< sal_Int32 > m_aKidsIndex
std::vector< sal_Int32 > m_aKids
std::unordered_map< OString, SvMemoryStream * > PDFAppearanceStreams
PDFWriter::FormatType m_nFormat
std::vector< OUString > m_aListEntries
std::vector< sal_Int32 > m_aSelectedEntries
Contains information to emit a reference XObject.
sal_Int32 m_nEmbeddedObject
ID of the vector/embedded object, if m_nFormObject is used.
sal_Int32 m_nFormObject
ID of the Form XObject, if any.
sal_Int32 getObject() const
Returns the ID one should use when referring to this bitmap.
sal_Int32 m_nBitmapObject
ID of the bitmap object, if m_nFormObject is used.
sal_Int32 m_nExternalPDFDataIndex
PDF data from the graphic object, if not writing a reference XObject.
Size m_aPixelSize
Size of the bitmap replacement, in pixels.
tools::Rectangle m_aTargetRect
tools::Rectangle m_aRectangle
std::unique_ptr< SvMemoryStream > m_pTilingStream
SvtGraphicFill::Transform m_aTransform
std::unique_ptr< SvMemoryStream > m_pContentStream
unsigned char sal_uInt8