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