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