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
58#include <vcl/settings.hxx>
61#include <salgdi.hxx>
62
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
285
287{
288 sal_Int32 m_nFontID;
291};
292
294{
295 // performance: actually this should probably a vector;
296 std::vector<sal_Ucs> m_CodeUnits;
298 sal_Int32 m_nGlyphWidth;
299 std::vector<ColorLayer> m_aColorLayers;
303
304public:
306 {
307 }
308
309 void setGlyphId( sal_uInt8 i_nId ) { m_nSubsetGlyphID = i_nId; }
311
312 void setGlyphWidth( sal_Int32 nWidth ) { m_nGlyphWidth = nWidth; }
313 sal_Int32 getGlyphWidth() const { return m_nGlyphWidth; }
314
315 void addColorLayer(ColorLayer aLayer) { m_aColorLayers.push_back(aLayer); }
316 const std::vector<ColorLayer>& getColorLayers() const { return m_aColorLayers; }
317
319 {
321 m_aRect = aRect;
322 }
324 {
325 rRect = m_aRect;
326 return m_aColorBitmap;
327 }
328
329 void setOutline(basegfx::B2DPolyPolygon aOutline) { m_aOutline = aOutline; }
331
332 void addCode( sal_Ucs i_cCode )
333 {
334 m_CodeUnits.push_back(i_cCode);
335 }
336 sal_Int32 countCodes() const { return m_CodeUnits.size(); }
337 const std::vector<sal_Ucs>& codes() const { return m_CodeUnits; }
338 sal_Ucs getCode( sal_Int32 i_nIndex ) const
339 {
340 sal_Ucs nRet = 0;
341 if (o3tl::make_unsigned(i_nIndex) < m_CodeUnits.size())
342 nRet = m_CodeUnits[i_nIndex];
343 return nRet;
344 }
345};
346
348{
349 sal_Int32 m_nFontID;
350 std::map<sal_GlyphId, GlyphEmit> m_aMapping;
351
352 explicit FontEmit( sal_Int32 nID ) : m_nFontID( nID ) {}
353};
354
355struct Glyph
356{
357 sal_Int32 m_nFontID;
359};
360
362{
363 std::vector< FontEmit > m_aSubsets;
364 std::map<sal_GlyphId, Glyph> m_aMapping;
365};
366
368{
371
373 : m_nNormalFontID(0)
374 , m_pFontInstance(nullptr) {}
375};
376
378{
379 sal_Int32 m_nPage;
382};
383
384//--->i56629
386{
387 OUString m_aDestName;
388 sal_Int32 m_nPage;
391};
392
394{
395 sal_Int32 m_nObject;
397 sal_Int32 m_nNextObject;
398 sal_Int32 m_nPrevObject;
399 std::vector< sal_Int32 > m_aChildren;
400 OUString m_aTitle;
401 sal_Int32 m_nDestID;
402
404 : m_nObject( 0 ),
405 m_nParentObject( 0 ),
406 m_nNextObject( 0 ),
407 m_nPrevObject( 0 ),
408 m_nDestID( -1 )
409 {}
410};
411
413{
414 sal_Int32 m_nObject;
416 sal_Int32 m_nPage;
417
419 : m_nObject( -1 ),
420 m_nPage( -1 )
421 {}
422};
423
424struct PDFLink : public PDFAnnotation
425{
426 sal_Int32 m_nDest; // set to -1 for URL, to a dest else
427 OUString m_aURL;
428 sal_Int32 m_nStructParent; // struct parent entry
429 OUString m_AltText;
430
431 PDFLink(OUString const& rAltText)
432 : m_nDest( -1 ),
433 m_nStructParent( -1 )
434 , m_AltText(rAltText)
435 {}
436};
437
440{
442 sal_Int32 m_nObject;
445
447 : m_nObject(0)
448 {
449 }
450};
451
453{
456};
457
459{
461
463
465 {}
466};
467
470{
472 OUString m_aURL;
477
480 {
481 }
482};
483
485{
487 OString m_aName;
489 OUString m_aText;
491 OUString m_aValue;
492 OString m_aDAString;
493 OString m_aDRDict;
494 OString m_aMKDict;
495 OString m_aMKDictCAString; // i12626, added to be able to encrypt the /CA text string
496 // since the object number is not known at the moment
497 // of filling m_aMKDict, the string will be encrypted when emitted.
498 // the /CA string MUST BE the last added to m_aMKDict
499 // see code for details
500 sal_Int32 m_nFlags;
501 sal_Int32 m_nParent; // if not 0, parent's object number
502 std::vector<sal_Int32> m_aKids; // widget children, contains object numbers
503 std::vector<sal_Int32> m_aKidsIndex; // widget children, contains index to m_aWidgets
504 OUString m_aOnValue;
505 OUString m_aOffValue;
506 sal_Int32 m_nTabOrder; // lowest number gets first in tab order
507 sal_Int32 m_nRadioGroup;
508 sal_Int32 m_nMaxLen;
517 sal_Int32 m_nDest;
518 std::vector<OUString> m_aListEntries;
519 std::vector<sal_Int32> m_aSelectedEntries;
520 typedef std::unordered_map<OString, SvMemoryStream*> PDFAppearanceStreams;
521 std::unordered_map<OString, PDFAppearanceStreams> m_aAppearances;
525 m_nFlags( 0 ),
526 m_nParent( 0 ),
527 m_nTabOrder( 0 ),
528 m_nRadioGroup( -1 ),
529 m_nMaxLen( 0 ),
531 m_nDecimalAccuracy ( 0 ),
533 m_bSubmit( false ),
534 m_bSubmitGet( false ),
535 m_nDest( -1 )
536 {}
537};
538
540{
542 sal_Int32 nValue;
543
546 nValue( 0 )
547 {}
548
550 : eValue( eVal ),
551 nValue( 0 )
552 {}
553
554 explicit PDFStructureAttribute( sal_Int32 nVal )
556 nValue( nVal )
557 {}
558};
559
560struct PDFStructureElementKid // for Kids entries
561{
562 sal_Int32 const nObject; // an object number if nMCID is -1,
563 // else the page object relevant to MCID
564 sal_Int32 const nMCID; // an MCID if >= 0
565
566 explicit PDFStructureElementKid( sal_Int32 nObj ) : nObject( nObj ), nMCID( -1 ) {}
567 PDFStructureElementKid( sal_Int32 MCID, sal_Int32 nPage ) : nObject( nPage ), nMCID( MCID ) {}
568};
569
571{
572 sal_Int32 m_nObject;
574 OString m_aAlias;
575 sal_Int32 m_nOwnElement; // index into structure vector
576 sal_Int32 m_nParentElement; // index into structure vector
579 std::list< sal_Int32 > m_aChildren; // indexes into structure vector
580 std::list< PDFStructureElementKid > m_aKids;
581 std::map<PDFWriter::StructAttribute, PDFStructureAttribute >
585 OUString m_aAltText;
586 css::lang::Locale m_aLocale;
587
588 // m_aContents contains the element's marked content sequence
589 // as pairs of (page nr, MCID)
590
592 : m_nObject( 0 ),
593 m_eType( PDFWriter::NonStructElement ),
594 m_nOwnElement( -1 ),
595 m_nParentElement( -1 ),
597 m_bOpenMCSeq( false )
598 {
599 }
600
601};
602
604{
605 OUString m_aMimeType;
609
610 PDFAddStream() : m_pStream( nullptr ), m_nStreamObject( 0 ), m_bCompress( true ) {}
611};
612
613// helper structure for drawLayout and friends
615{
618 sal_Int32 const m_nNativeWidth;
619 sal_Int32 const m_nMappedFontId;
621 int const m_nCharPos;
622
623 PDFGlyph( const DevicePoint& rPos,
624 const GlyphItem* pGlyph,
625 sal_Int32 nNativeWidth,
626 sal_Int32 nFontId,
627 sal_uInt8 nMappedGlyphId,
628 int nCharPos )
629 : m_aPos( rPos ), m_pGlyph(pGlyph), m_nNativeWidth( nNativeWidth ),
630 m_nMappedFontId( nFontId ), m_nMappedGlyphId( nMappedGlyphId ),
631 m_nCharPos(nCharPos)
632 {}
633};
634
636{
641};
642
643// graphics state
645{
658
664 m_bClipRegion( false ),
666 m_aDigitLanguage( 0 ),
669 {}
670};
671
672enum class Mode { DEFAULT, NOWRITE };
673
674}
675
677{
678 friend class PDFStreamIf;
679
680public:
681 friend struct vcl::pdf::PDFPage;
682
683 static const char* getStructureTag( PDFWriter::StructElement );
684 static const char* getAttributeTag( PDFWriter::StructAttribute eAtr );
685 static const char* getAttributeValueTag( PDFWriter::StructAttributeValue eVal );
686
687 // returns true if compression was done
688 // else false
689 static bool compressStream( SvMemoryStream* );
690
691 static void convertLineInfoToExtLineInfo( const LineInfo& rIn, PDFWriter::ExtLineInfo& rOut );
692
693private:
694 bool ImplNewFont() const override;
695 void ImplClearFontData(bool bNewFontLists) override;
696 void ImplRefreshFontData(bool bNewFontLists) override;
697 vcl::Region ClipToDeviceBounds(vcl::Region aRegion) const override;
698 void DrawHatchLine_DrawLine(const Point& rStartPoint, const Point& rEndPoint) override;
699
700 MapMode m_aMapMode; // PDFWriterImpl scaled units
702 std::vector< PDFPage > m_aPages;
703 /* maps object numbers to file offsets (needed for xref) */
704 std::vector< sal_uInt64 > m_aObjects;
705 /* contains Bitmaps until they are written to the
706 * file stream as XObjects*/
707 std::list< BitmapEmit > m_aBitmaps;
708 /* contains JPG streams until written to file */
709 std::vector<JPGEmit> m_aJPGs;
710 /*--->i56629 contains all named destinations ever set during the PDF creation,
711 destination id is always the destination's position in this vector
712 */
713 std::vector<PDFNamedDest> m_aNamedDests;
714 /* contains all dests ever set during the PDF creation,
715 dest id is always the dest's position in this vector
716 */
717 std::vector<PDFDest> m_aDests;
720 ::std::map< sal_Int32, sal_Int32 > m_aDestinationIdTranslation;
721 /* contains all links ever set during PDF creation,
722 link id is always the link's position in this vector
723 */
724 std::vector<PDFLink> m_aLinks;
726 std::vector<PDFScreen> m_aScreens;
728 std::vector<PDFEmbeddedFile> m_aEmbeddedFiles;
729 /* makes correctly encoded for export to PDF URLS
730 */
731 css::uno::Reference< css::util::XURLTransformer > m_xTrans;
732 /* maps arbitrary link ids for structure attributes to real link ids
733 (for setLinkPropertyId)
734 */
735 std::map<sal_Int32, sal_Int32> m_aLinkPropertyMap;
736 /* contains all outline items,
737 object 0 is the outline root
738 */
739 std::vector<PDFOutlineEntry> m_aOutline;
740 /* contains all notes set during PDF creation
741 */
742 std::vector<PDFNoteEntry> m_aNotes;
743 /* the root of the structure tree
744 */
745 std::vector<PDFStructureElement> m_aStructure;
746 /* current object in the structure hierarchy
747 */
749 /* structure parent tree */
750 std::vector< OString > m_aStructParentTree;
751 /* emit structure marks currently (aka. NonStructElement or not)
752 */
754 /* role map of struct tree root */
755 std::unordered_map< OString, OString >
757
758 /* contains all widgets used in the PDF
759 */
760 std::vector<PDFWidget> m_aWidgets;
761 /* maps radio group id to index of radio group control in m_aWidgets */
762 std::map< sal_Int32, sal_Int32 > m_aRadioGroupWidgets;
763 /* unordered_map for field names, used to ensure unique field names */
764 std::unordered_map< OString, sal_Int32 > m_aFieldNameMap;
765
766 /* contains Bitmaps for gradient functions until they are written
767 * to the file stream */
768 std::list< GradientEmit > m_aGradients;
769 /* contains bitmap tiling patterns */
770 std::vector< TilingEmit > m_aTilings;
771 std::vector< TransparencyEmit > m_aTransparentObjects;
772 /* contains all font subsets in use */
773 std::map<const vcl::font::PhysicalFontFace*, FontSubset> m_aSubsets;
774 std::map<const vcl::font::PhysicalFontFace*, EmbedFont> m_aSystemFonts;
775 std::map<const vcl::font::PhysicalFontFace*, FontSubset> m_aType3Fonts;
776 sal_Int32 m_nNextFID;
777
780 std::shared_ptr<SvMemoryStream>> m_aPDFBmpCache;
781
782 sal_Int32 m_nCurrentPage;
783
785 // object number of the main signature dictionary
792 std::map< sal_Int32, sal_Int32 > m_aBuildinFontToObjectMap;
793
795 osl::File m_aFile;
797
799
800 /* output redirection; e.g. to accumulate content streams for
801 XObjects
802 */
803 std::list< StreamRedirect > m_aOutputStreams;
804
805 std::list< GraphicsState > m_aGraphicsStack;
807
808 std::unique_ptr<ZCodec> m_pCodec;
809 std::unique_ptr<SvMemoryStream> m_pMemStream;
810
811 std::vector< PDFAddStream > m_aAdditionalStreams;
812 std::set< PDFWriter::ErrorCode > m_aErrors;
813
815
816/*
817variables for PDF security
818i12626
819*/
820/* used to cipher the stream data and for password management */
821 rtlCipher m_aCipher;
822 /* pad string used for password in Standard security handler */
824
825 /* the encryption key, formed with the user password according to algorithm 3.2, maximum length is 16 bytes + 3 + 2
826 for 128 bit security */
827 sal_Int32 m_nKeyLength; // key length, 16 or 5
828 sal_Int32 m_nRC4KeyLength; // key length, 16 or 10, to be input to the algorithm 3.1
829
830 /* set to true if the following stream must be encrypted, used inside writeBuffer() */
832
833 /* the numerical value of the access permissions, according to PDF spec, must be signed */
835 /* string to hold the PDF creation date */
837 /* string to hold the PDF creation date, for PDF/A metadata */
839 /* the buffer where the data are encrypted, dynamically allocated */
840 std::vector<sal_uInt8> m_vEncryptionBuffer;
841
842 void addRoleMap(OString aAlias, PDFWriter::StructElement eType);
843
844 /* this function implements part of the PDF spec algorithm 3.1 in encryption, the rest (the actual encryption) is in PDFWriterImpl::writeBuffer */
845 void checkAndEnableStreamEncryption( sal_Int32 nObject ) override;
846
847 void disableStreamEncryption() override { m_bEncryptThisStream = false; };
848
849 /* */
850 void enableStringEncryption( sal_Int32 nObject );
851
852// test if the encryption is active, if yes than encrypt the unicode string and add to the OStringBuffer parameter
853 void appendUnicodeTextStringEncrypt( const OUString& rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer );
854
855 void appendLiteralStringEncrypt( std::u16string_view rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer, rtl_TextEncoding nEnc = RTL_TEXTENCODING_ASCII_US );
856 void appendLiteralStringEncrypt( std::string_view rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer );
857
858 /* creates fonts and subsets that will be emitted later */
859 void registerGlyph(const sal_GlyphId, const vcl::font::PhysicalFontFace*, const LogicalFontInstance* pFont, const std::vector<sal_Ucs>&, sal_Int32, sal_uInt8&, sal_Int32&);
860 void registerSimpleGlyph(const sal_GlyphId, const vcl::font::PhysicalFontFace*, const std::vector<sal_Ucs>&, sal_Int32, sal_uInt8&, sal_Int32&);
861
862 /* emits a text object according to the passed layout */
863 /* TODO: remove rText as soon as SalLayout will change so that rText is not necessary anymore */
864 void drawVerticalGlyphs( const std::vector<PDFGlyph>& rGlyphs, OStringBuffer& rLine, const Point& rAlignOffset, const Matrix3& rRotScale, double fAngle, double fXScale, double fSkew, sal_Int32 nFontHeight );
865 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 );
866 void drawLayout( SalLayout& rLayout, const OUString& rText, bool bTextLines );
867 void drawRelief( SalLayout& rLayout, const OUString& rText, bool bTextLines );
868 void drawShadow( SalLayout& rLayout, const OUString& rText, bool bTextLines );
869
870 /* writes differences between graphics stack and current real PDF
871 * state to the file
872 */
874
875 /* writes a transparency group object */
877
878 /* writes an XObject of type image, may create
879 a second for the mask
880 */
881 bool writeBitmapObject( const BitmapEmit& rObject, bool bMask = false );
882
883 void writeJPG( const JPGEmit& rEmit );
886
887 /* tries to find the bitmap by its id and returns its emit data if exists,
888 else creates a new emit data block */
889 const BitmapEmit& createBitmapEmit( const BitmapEx& rBitmapEx, const Graphic& rGraphic, std::list<BitmapEmit>& rBitmaps, ResourceDict& rResourceDict, std::list<StreamRedirect>& rOutputStreams );
890 const BitmapEmit& createBitmapEmit( const BitmapEx& rBitmapEx, const Graphic& rGraphic );
891
892 /* writes the Do operation inside the content stream */
893 void drawBitmap( const Point& rDestPt, const Size& rDestSize, const BitmapEmit& rBitmap, const Color& rFillColor );
894 /* write the function object for a Gradient */
895 bool writeGradientFunction( GradientEmit const & rObject );
896 /* creates a GradientEmit and returns its object number */
897 sal_Int32 createGradient( const Gradient& rGradient, const Size& rSize );
898
899 /* writes all tilings */
900 bool emitTilings();
901 /* writes all gradient patterns */
902 bool emitGradients();
903 /* writes a builtin font object and returns its objectid (or 0 in case of failure ) */
904 sal_Int32 emitBuildinFont( const pdf::BuildinFontFace*, sal_Int32 nObject );
905 /* writes a type1 system font object and returns its mapping from font ids to object ids (or 0 in case of failure ) */
906 std::map< sal_Int32, sal_Int32 > emitSystemFont(const vcl::font::PhysicalFontFace*, EmbedFont const &);
907 /* writes a type3 font object and appends it to the font id mapping, or returns false in case of failure */
908 bool emitType3Font(const vcl::font::PhysicalFontFace*, const FontSubset&, std::map<sal_Int32, sal_Int32>&);
909 /* writes a font descriptor and returns its object id (or 0) */
910 sal_Int32 emitFontDescriptor(const vcl::font::PhysicalFontFace*, FontSubsetInfo const &, sal_Int32 nSubsetID, sal_Int32 nStream);
911 /* writes a ToUnicode cmap, returns the corresponding stream object */
912 sal_Int32 createToUnicodeCMap( sal_uInt8 const * pEncoding, const sal_Ucs* pCodeUnits, const sal_Int32* pCodeUnitsPerGlyph,
913 const sal_Int32* pEncToUnicodeIndex, uint32_t nGlyphs );
914
915 /* get resource dict object number */
917 {
918 if( m_nResourceDict <= 0 )
920 return m_nResourceDict;
921 }
922 /* get the font dict object */
924 {
925 if( m_nFontDictObject <= 0 )
927 return m_nFontDictObject;
928 }
929 /* push resource into current (redirected) resource dict */
930 static void pushResource( ResourceKind eKind, const OString& rResource, sal_Int32 nObject, ResourceDict& rResourceDict, std::list<StreamRedirect>& rOutputStreams );
931 void pushResource( ResourceKind eKind, const OString& rResource, sal_Int32 nObject );
932
933 void appendBuildinFontsToDict( OStringBuffer& rDict ) const;
934 /* writes the font dictionary and emits all font objects
935 * returns object id of font directory (or 0 on error)
936 */
937 bool emitFonts();
938 /* writes the Resource dictionary;
939 * returns dict object id (or 0 on error)
940 */
941 sal_Int32 emitResources();
942 // appends a dest
943 bool appendDest( sal_Int32 nDestID, OStringBuffer& rBuffer );
944 // write all links
945 bool emitLinkAnnotations();
946 // Write all screen annotations.
948
949 void emitTextAnnotationLine(OStringBuffer & aLine, PDFNoteEntry const & rNote);
950 static void emitPopupAnnotationLine(OStringBuffer & aLine, PDFPopupAnnotation const & rPopUp);
951 // write all notes
952 bool emitNoteAnnotations();
953
954 // write the appearance streams of a widget
955 bool emitAppearances( PDFWidget& rWidget, OStringBuffer& rAnnotDict );
956 // clean up radio button "On" values
958 // write all widgets
960 // writes all annotation objects
961 bool emitAnnotations();
963 bool emitEmbeddedFiles();
964 //write the named destination stuff
965 sal_Int32 emitNamedDestinations();//i56629
966 // writes outline dict and tree
967 sal_Int32 emitOutline();
968 // puts the attribute objects of a structure element into the returned string,
969 // helper for emitStructure
971 //--->i94258
972 // the maximum array elements allowed for PDF array object
973 static const sal_uInt32 ncMaxPDFArraySize = 8191;
974 //check if internal dummy container are needed in the structure elements
976 //<---i94258
977 // writes document structure
978 sal_Int32 emitStructure( PDFStructureElement& rEle );
979 // writes structure parent tree
980 sal_Int32 emitStructParentTree( sal_Int32 nTreeObject );
981 // writes page tree and catalog
982 bool emitCatalog();
983 // writes signature dictionary object
985 // creates a PKCS7 object using the ByteRange and overwrite /Contents
986 // of the signature dictionary
988 // writes xref and trailer
989 bool emitTrailer();
990 // emit additional streams collected; also create there object numbers
992 // emits info dict (if applicable)
993 sal_Int32 emitInfoDict( );
994
995 // acrobat reader 5 and 6 use the order of the annotations
996 // as their tab order; since PDF1.5 one can make the
997 // tab order explicit by using the structure tree
998 void sortWidgets();
999
1000 // updates the count numbers of outline items
1001 sal_Int32 updateOutlineItemCount( std::vector< sal_Int32 >& rCounts,
1002 sal_Int32 nItemLevel,
1003 sal_Int32 nCurrentItemId );
1004 // default appearances for widgets
1005 sal_Int32 findRadioGroupWidget( const PDFWriter::RadioButtonWidget& rRadio );
1006 Font replaceFont( const Font& rControlFont, const Font& rAppSetFont );
1007 sal_Int32 getBestBuildinFont( const Font& rFont );
1008 sal_Int32 getSystemFont( const Font& i_rFont );
1009
1010 // used for edit and listbox
1012
1018
1019 /* ensure proper escapement and uniqueness of field names */
1020 void createWidgetFieldName( sal_Int32 i_nWidgetsIndex, const PDFWriter::AnyWidget& i_rInWidget );
1022 sal_Int32 createObject() override;
1024 bool updateObject( sal_Int32 n ) override;
1025
1027 bool writeBuffer( const void* pBuffer, sal_uInt64 nBytes ) override;
1028 void beginCompression();
1029 void endCompression();
1030 void beginRedirect( SvStream* pStream, const tools::Rectangle& );
1032
1033 void endPage();
1034
1045 bool checkEmitStructure();
1046
1047 /* draws an emphasis mark */
1048 void drawEmphasisMark( tools::Long nX, tools::Long nY, const tools::PolyPolygon& rPolyPoly, bool bPolyLine, const tools::Rectangle& rRect1, const tools::Rectangle& rRect2 );
1049
1050 /* true if PDF/A-1a or PDF/A-1b is output */
1052 /* true if PDF/A-2a is output */
1054
1055 /* PDF/UA support enabled */
1057
1059
1061
1062 /*
1063 i12626
1064 methods for PDF security
1065
1066 pad a password according algorithm 3.2, step 1 */
1067 static void padPassword( std::u16string_view i_rPassword, sal_uInt8* o_pPaddedPW );
1068 /* algorithm 3.2: compute an encryption key */
1071 sal_Int32 i_nAccessPermissions
1072 );
1073 /* algorithm 3.3: computing the encryption dictionary'ss owner password value ( /O ) */
1074 static bool computeODictionaryValue( const sal_uInt8* i_pPaddedOwnerPassword, const sal_uInt8* i_pPaddedUserPassword,
1075 std::vector< sal_uInt8 >& io_rOValue,
1076 sal_Int32 i_nKeyLength
1077 );
1078 /* algorithm 3.4 or 3.5: computing the encryption dictionary's user password value ( /U ) revision 2 or 3 of the standard security handler */
1079 static bool computeUDictionaryValue( EncHashTransporter* i_pTransporter,
1081 sal_Int32 i_nKeyLength,
1082 sal_Int32 i_nAccessPermissions
1083 );
1084
1085 static void computeDocumentIdentifier( std::vector< sal_uInt8 >& o_rIdentifier,
1086 const vcl::PDFWriter::PDFDocInfo& i_rDocInfo,
1087 const OString& i_rCString1,
1088 OString& o_rCString2
1089 );
1090 static sal_Int32 computeAccessPermissions( const vcl::PDFWriter::PDFEncryptionProperties& i_rProperties,
1091 sal_Int32& o_rKeyLength, sal_Int32& o_rRC4KeyLength );
1092 void setupDocInfo();
1093 bool prepareEncryption( const css::uno::Reference< css::beans::XMaterialHolder >& );
1094
1095 // helper for playMetafile
1096 void implWriteGradient( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient,
1098 void implWriteBitmapEx( const Point& rPoint, const Size& rSize, const BitmapEx& rBitmapEx, const Graphic& i_pGraphic,
1099 VirtualDevice const * pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& );
1100
1101 // helpers for CCITT 1bit bitmap stream
1102 void putG4Bits( sal_uInt32 i_nLength, sal_uInt32 i_nCode, BitStreamState& io_rState );
1103 void putG4Span( tools::Long i_nSpan, bool i_bWhitePixel, BitStreamState& io_rState );
1104 void writeG4Stream( BitmapReadAccess const * i_pBitmap );
1105
1106 // color helper functions
1107 void appendStrokingColor( const Color& rColor, OStringBuffer& rBuffer );
1108 void appendNonStrokingColor( const Color& rColor, OStringBuffer& rBuffer );
1109public:
1110 PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext, const css::uno::Reference< css::beans::XMaterialHolder >&, PDFWriter& );
1111 ~PDFWriterImpl() override;
1112 void dispose() override;
1113
1114 static css::uno::Reference< css::beans::XMaterialHolder >
1115 initEncryption( const OUString& i_rOwnerPassword,
1116 const OUString& i_rUserPassword );
1117
1118 /* document structure */
1119 void newPage( double nPageWidth , double nPageHeight, PDFWriter::Orientation eOrientation );
1120 bool emit();
1121 const std::set< PDFWriter::ErrorCode > & getErrors() const { return m_aErrors;}
1122 void insertError( PDFWriter::ErrorCode eErr ) { m_aErrors.insert( eErr ); }
1124
1126 {
1127 Size aSize;
1130 return aSize;
1131 }
1132
1133 void setDocumentLocale( const css::lang::Locale& rLoc )
1134 { m_aContext.DocumentLocale = rLoc; }
1135
1136 /* graphics state */
1137 void push( PushFlags nFlags );
1138 void pop();
1139
1140 void setFont( const Font& rFont );
1141
1142 void setMapMode( const MapMode& rMapMode );
1143
1144 const MapMode& getMapMode() { return m_aGraphicsStack.front().m_aMapMode; }
1145
1146 void setLineColor( const Color& rColor )
1147 {
1148 m_aGraphicsStack.front().m_aLineColor = rColor.IsTransparent() ? COL_TRANSPARENT : rColor;
1149 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::LineColor;
1150 }
1151
1152 void setFillColor( const Color& rColor )
1153 {
1154 m_aGraphicsStack.front().m_aFillColor = rColor.IsTransparent() ? COL_TRANSPARENT : rColor;
1155 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::FillColor;
1156 }
1157
1159 {
1160 m_aGraphicsStack.front().m_aTextLineColor = COL_TRANSPARENT;
1161 }
1162
1163 void setTextLineColor( const Color& rColor )
1164 {
1165 m_aGraphicsStack.front().m_aTextLineColor = rColor;
1166 }
1167
1169 {
1170 m_aGraphicsStack.front().m_aOverlineColor = COL_TRANSPARENT;
1171 }
1172
1173 void setOverlineColor( const Color& rColor )
1174 {
1175 m_aGraphicsStack.front().m_aOverlineColor = rColor;
1176 }
1177
1178 void setTextFillColor( const Color& rColor )
1179 {
1180 m_aGraphicsStack.front().m_aFont.SetFillColor( rColor );
1181 m_aGraphicsStack.front().m_aFont.SetTransparent( rColor.IsTransparent() );
1182 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
1183 }
1185 {
1186 m_aGraphicsStack.front().m_aFont.SetFillColor( COL_TRANSPARENT );
1187 m_aGraphicsStack.front().m_aFont.SetTransparent( true );
1188 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
1189 }
1190 void setTextColor( const Color& rColor )
1191 {
1192 m_aGraphicsStack.front().m_aFont.SetColor( rColor );
1193 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
1194 }
1195
1197 {
1198 m_aGraphicsStack.front().m_aClipRegion.clear();
1199 m_aGraphicsStack.front().m_bClipRegion = false;
1201 }
1202
1203 void setClipRegion( const basegfx::B2DPolyPolygon& rRegion );
1204
1205 void moveClipRegion( sal_Int32 nX, sal_Int32 nY );
1206
1207 void intersectClipRegion( const tools::Rectangle& rRect );
1208
1209 void intersectClipRegion( const basegfx::B2DPolyPolygon& rRegion );
1210
1212 {
1213 m_aGraphicsStack.front().m_nLayoutMode = nLayoutMode;
1215 }
1216
1218 {
1219 m_aGraphicsStack.front().m_aDigitLanguage = eLang;
1221 }
1222
1224 {
1225 m_aGraphicsStack.front().m_aFont.SetAlignment( eAlign );
1226 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
1227 }
1228
1229 /* actual drawing functions */
1230 void drawText( const Point& rPos, const OUString& rText, sal_Int32 nIndex, sal_Int32 nLen, bool bTextLines = true );
1231 void drawTextArray( const Point& rPos, const OUString& rText, o3tl::span<const sal_Int32> pDXArray, o3tl::span<const sal_Bool> pKashidaArray, sal_Int32 nIndex, sal_Int32 nLen );
1232 void drawStretchText( const Point& rPos, sal_uLong nWidth, const OUString& rText,
1233 sal_Int32 nIndex, sal_Int32 nLen );
1234 void drawText( const tools::Rectangle& rRect, const OUString& rOrigStr, DrawTextFlags nStyle );
1235 void drawTextLine( const Point& rPos, tools::Long nWidth, FontStrikeout eStrikeout, FontLineStyle eUnderline, FontLineStyle eOverline, bool bUnderlineAbove );
1236 void drawWaveTextLine( OStringBuffer& aLine, tools::Long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove );
1237 void drawStraightTextLine( OStringBuffer& aLine, tools::Long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove );
1238 void drawStrikeoutLine( OStringBuffer& aLine, tools::Long nWidth, FontStrikeout eStrikeout, Color aColor );
1239 void drawStrikeoutChar( const Point& rPos, tools::Long nWidth, FontStrikeout eStrikeout );
1240
1241 void drawLine( const Point& rStart, const Point& rStop );
1242 void drawLine( const Point& rStart, const Point& rStop, const LineInfo& rInfo );
1243 void drawPolygon( const tools::Polygon& rPoly );
1244 void drawPolyPolygon( const tools::PolyPolygon& rPolyPoly );
1245 void drawPolyLine( const tools::Polygon& rPoly );
1246 void drawPolyLine( const tools::Polygon& rPoly, const LineInfo& rInfo );
1247 void drawPolyLine( const tools::Polygon& rPoly, const PDFWriter::ExtLineInfo& rInfo );
1248
1249 void drawPixel( const Point& rPt, const Color& rColor );
1250
1251 void drawRectangle( const tools::Rectangle& rRect );
1252 void drawRectangle( const tools::Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt32 nVertRound );
1253 void drawEllipse( const tools::Rectangle& rRect );
1254 void drawArc( const tools::Rectangle& rRect, const Point& rStart, const Point& rStop, bool bWithPie, bool bWidthChord );
1255
1256 void drawBitmap( const Point& rDestPoint, const Size& rDestSize, const Bitmap& rBitmap, const Graphic& rGraphic );
1257 void drawBitmap( const Point& rDestPoint, const Size& rDestSize, const BitmapEx& rBitmap );
1258 void drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const Size& rSizePixel, const tools::Rectangle& rTargetArea, const AlphaMask& rAlphaMask, const Graphic& rGraphic );
1260 void createEmbeddedFile(const Graphic& rGraphic, ReferenceXObjectEmit& rEmit, sal_Int32 nBitmapObject);
1261
1262 void drawGradient( const tools::Rectangle& rRect, const Gradient& rGradient );
1263 void drawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch );
1264 void drawWallpaper( const tools::Rectangle& rRect, const Wallpaper& rWall );
1265 void drawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uInt32 nTransparentPercent );
1267 void endTransparencyGroup( const tools::Rectangle& rBoundingBox, sal_uInt32 nTransparentPercent );
1268
1269 void emitComment( const char* pComment );
1270
1271 //--->i56629 named destinations
1272 sal_Int32 createNamedDest( const OUString& sDestName, const tools::Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType );
1273
1274 //--->i59651
1275 //emits output intent
1276 sal_Int32 emitOutputIntent();
1277
1278 //emits the document metadata
1279 sal_Int32 emitDocumentMetadata();
1280
1281 // links
1282 sal_Int32 createLink(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText);
1283 sal_Int32 createDest( const tools::Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType );
1284 sal_Int32 registerDestReference( sal_Int32 nDestId, const tools::Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType );
1285 void setLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId );
1286 void setLinkURL( sal_Int32 nLinkId, const OUString& rURL );
1287 void setLinkPropertyId( sal_Int32 nLinkId, sal_Int32 nPropertyId );
1288
1289 // screens
1290 sal_Int32 createScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr);
1291 void setScreenURL(sal_Int32 nScreenId, const OUString& rURL);
1292 void setScreenStream(sal_Int32 nScreenId, const OUString& rURL);
1293
1294 // outline
1295 sal_Int32 createOutlineItem( sal_Int32 nParent, std::u16string_view rText, sal_Int32 nDestID );
1296 void setOutlineItemParent( sal_Int32 nItem, sal_Int32 nNewParent );
1297 void setOutlineItemText( sal_Int32 nItem, std::u16string_view rText );
1298 void setOutlineItemDest( sal_Int32 nItem, sal_Int32 nDestID );
1299
1300 // notes
1301 void createNote( const tools::Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr );
1302 // structure elements
1303 sal_Int32 beginStructureElement( PDFWriter::StructElement eType, std::u16string_view rAlias );
1304 void endStructureElement();
1305 bool setCurrentStructureElement( sal_Int32 nElement );
1307 bool setStructureAttributeNumerical( enum PDFWriter::StructAttribute eAttr, sal_Int32 nValue );
1308 void setStructureBoundingBox( const tools::Rectangle& rRect );
1309 void setActualText( const OUString& rText );
1310 void setAlternateText( const OUString& rText );
1311
1312 // transitional effects
1313 void setPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr );
1314
1315 // controls
1316 sal_Int32 createControl( const PDFWriter::AnyWidget& rControl, sal_Int32 nPageNr = -1 );
1317
1318 // additional streams
1319 void addStream( const OUString& rMimeType, PDFOutputStream* pStream );
1320
1321 // helper: eventually begin marked content sequence and
1322 // emit a comment in debug case
1323 void MARK( const char* pString );
1324};
1325
1326} // namespace vcl
1327
1328/* 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)
sal_Int32 beginStructureElement(PDFWriter::StructElement eType, std::u16string_view rAlias)
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().
void drawTextArray(const Point &rPos, const OUString &rText, o3tl::span< const sal_Int32 > pDXArray, o3tl::span< const sal_Bool > pKashidaArray, sal_Int32 nIndex, sal_Int32 nLen)
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::map< const vcl::font::PhysicalFontFace *, FontSubset > m_aType3Fonts
std::unordered_map< OString, OString > m_aRoleMap
void createWidgetFieldName(sal_Int32 i_nWidgetsIndex, const PDFWriter::AnyWidget &i_rInWidget)
sal_Int32 createControl(const PDFWriter::AnyWidget &rControl, sal_Int32 nPageNr=-1)
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)
sal_Int32 createLink(const tools::Rectangle &rRect, sal_Int32 nPageNr, OUString const &rAltText)
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
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)
StyleSettings m_aWidgetStyleSettings
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)
const BitmapEmit & createBitmapEmit(const BitmapEx &rBitmapEx, const Graphic &rGraphic, std::list< BitmapEmit > &rBitmaps, ResourceDict &rResourceDict, std::list< StreamRedirect > &rOutputStreams)
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 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)
sal_Int32 createToUnicodeCMap(sal_uInt8 const *pEncoding, const sal_Ucs *pCodeUnits, const sal_Int32 *pCodeUnitsPerGlyph, const sal_Int32 *pEncToUnicodeIndex, uint32_t nGlyphs)
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)
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)
static void pushResource(ResourceKind eKind, const OString &rResource, sal_Int32 nObject, ResourceDict &rResourceDict, std::list< StreamRedirect > &rOutputStreams)
void updateGraphicsState(Mode mode=Mode::DEFAULT)
css::uno::Reference< css::util::XURLTransformer > m_xTrans
void registerGlyph(const sal_GlyphId, const vcl::font::PhysicalFontFace *, const LogicalFontInstance *pFont, const std::vector< sal_Ucs > &, sal_Int32, sal_uInt8 &, sal_Int32 &)
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]
bool emitType3Font(const vcl::font::PhysicalFontFace *, const FontSubset &, std::map< sal_Int32, sal_Int32 > &)
::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 registerSimpleGlyph(const sal_GlyphId, const vcl::font::PhysicalFontFace *, const std::vector< sal_Ucs > &, sal_Int32, sal_uInt8 &, sal_Int32 &)
void drawPixel(const Point &rPt, const Color &rColor)
abstract base class for physical font faces
const std::vector< ColorLayer > & getColorLayers() const
font::RawFontData m_aColorBitmap
void setOutline(basegfx::B2DPolyPolygon aOutline)
void addCode(sal_Ucs i_cCode)
tools::Rectangle m_aRect
const basegfx::B2DPolyPolygon & getOutline() const
const font::RawFontData & getColorBitmap(tools::Rectangle &rRect) const
void setColorBitmap(font::RawFontData aData, tools::Rectangle aRect)
std::vector< sal_Ucs > m_CodeUnits
const std::vector< sal_Ucs > & codes() const
void addColorLayer(ColorLayer aLayer)
void setGlyphWidth(sal_Int32 nWidth)
basegfx::B2DPolyPolygon m_aOutline
void setGlyphId(sal_uInt8 i_nId)
sal_Ucs getCode(sal_Int32 i_nIndex) const
sal_Int32 countCodes() const
std::vector< ColorLayer > m_aColorLayers
sal_Int32 getGlyphWidth() const
sal_uInt8 getGlyphId() const
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
FontLineStyle
FontStrikeout
uint32_t sal_GlyphId
Definition: glyphid.hxx:24
def text(shape, orig_st)
constexpr OUStringLiteral aData
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:64
sal_uIntPtr sal_uLong
Homogeneous 2D transformation matrix.
css::lang::Locale DocumentLocale
Definition: pdfwriter.hxx:624
Play a metafile like an outputdevice would do.
Definition: pdfwriter.hxx:689
ReferenceXObjectEmit m_aReferenceXObject
LogicalFontInstance * m_pFontInstance
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
sal_Int32 const m_nNativeWidth
DevicePoint const m_aPos
PDFGlyph(const DevicePoint &rPos, const GlyphItem *pGlyph, sal_Int32 nNativeWidth, sal_Int32 nFontId, sal_uInt8 nMappedGlyphId, int nCharPos)
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