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