tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / vcl / inc / pdf / pdfwriter_impl.hxx
blob6781d0f935fd3d8f5da09e8c33821983260a0f4e
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 .
20 #pragma once
22 #include <sal/config.h>
24 #include <map>
25 #include <list>
26 #include <unordered_map>
27 #include <unordered_set>
28 #include <memory>
29 #include <string_view>
30 #include <vector>
31 #include <stack>
32 #include <variant>
34 #include <pdf/ResourceDict.hxx>
35 #include <pdf/BitmapID.hxx>
36 #include <pdf/Matrix3.hxx>
38 #include <com/sun/star/lang/Locale.hpp>
39 #include <com/sun/star/util/XURLTransformer.hpp>
40 #include <osl/file.hxx>
41 #include <rtl/strbuf.hxx>
42 #include <rtl/ustring.hxx>
43 #include <tools/gen.hxx>
44 #include <vcl/bitmapex.hxx>
45 #include <vcl/gradient.hxx>
46 #include <vcl/graphictools.hxx>
47 #include <vcl/hatch.hxx>
48 #include <vcl/virdev.hxx>
49 #include <vcl/pdfwriter.hxx>
50 #include <vcl/wall.hxx>
51 #include <o3tl/safeint.hxx>
52 #include <o3tl/typed_flags_set.hxx>
53 #include <o3tl/lru_map.hxx>
54 #include <comphelper/hash.hxx>
55 #include <tools/stream.hxx>
56 #include <vcl/BinaryDataContainer.hxx>
57 #include <vcl/pdf/PDFNote.hxx>
59 #include <vcl/filter/pdfobjectcontainer.hxx>
60 #include <vcl/settings.hxx>
61 #include <pdf/ExternalPDFStreams.hxx>
62 #include <pdf/pdfbuildin_fonts.hxx>
63 #include <salgdi.hxx>
65 class FontSubsetInfo;
66 class ZCodec;
67 struct BitStreamState;
68 namespace vcl::font { class PhysicalFontFace; }
69 class SvStream;
70 class SvMemoryStream;
72 namespace vcl::pdf
75 enum class GraphicsStateUpdateFlags {
76 Font = 0x0001,
77 MapMode = 0x0002,
78 LineColor = 0x0004,
79 FillColor = 0x0008,
80 ClipRegion = 0x0040,
81 LayoutMode = 0x0100,
82 TransparentPercent = 0x0200,
83 DigitLanguage = 0x0400,
84 All = 0x077f
87 } // end vcl::pdf
89 namespace o3tl {
90 template<> struct typed_flags<vcl::pdf::GraphicsStateUpdateFlags> : is_typed_flags<vcl::pdf::GraphicsStateUpdateFlags, 0x077f> {};
93 namespace vcl
96 using namespace vcl::pdf;
98 class PDFStreamIf;
100 namespace filter
102 class PDFObjectElement;
105 namespace pdf
107 struct PDFPage
109 VclPtr<PDFWriterImpl> m_pWriter;
110 double m_nPageWidth; // in inch/72
111 double m_nPageHeight; // in inch/72
113 * A positive number that gives the size of default user space units, in multiples of points.
114 * Typically 1, larger if page size is > 508 cm.
116 sal_Int32 m_nUserUnit;
117 PDFWriter::Orientation m_eOrientation;
118 sal_Int32 m_nPageObject;
119 std::vector<sal_Int32> m_aStreamObjects;
120 sal_Int32 m_nStreamLengthObject;
121 sal_uInt64 m_nBeginStreamPos;
122 std::vector<sal_Int32> m_aAnnotations;
123 std::vector<sal_Int32> m_aMCIDParents;
124 PDFWriter::PageTransition m_eTransition;
125 sal_uInt32 m_nTransTime;
127 PDFPage( PDFWriterImpl* pWriter, double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation );
129 void beginStream();
130 void endStream();
131 bool emit( sal_Int32 nParentPage );
133 // converts point from ref device coordinates to
134 // page coordinates and appends the point to the buffer
135 // if pOutPoint is set it will be updated to the emitted point
136 // (in PDF map mode, that is 10th of point)
137 void appendPoint( const Point& rPoint, OStringBuffer& rBuffer ) const;
138 // appends a B2DPoint without further transformation
139 void appendPixelPoint( const basegfx::B2DPoint& rPoint, OStringBuffer& rBuffer ) const;
140 // appends a rectangle
141 void appendRect( const tools::Rectangle& rRect, OStringBuffer& rBuffer ) const;
142 // converts a rectangle to 10th points page space
143 void convertRect( tools::Rectangle& rRect ) const;
144 // appends a polygon optionally closing it
145 void appendPolygon( const tools::Polygon& rPoly, OStringBuffer& rBuffer, bool bClose = true ) const;
146 // appends a polygon optionally closing it
147 void appendPolygon( const basegfx::B2DPolygon& rPoly, OStringBuffer& rBuffer ) const;
148 // appends a polypolygon optionally closing the subpaths
149 void appendPolyPolygon( const tools::PolyPolygon& rPolyPoly, OStringBuffer& rBuffer ) const;
150 // appends a polypolygon optionally closing the subpaths
151 void appendPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPoly, OStringBuffer& rBuffer ) const;
152 // converts a length (either vertical or horizontal; this
153 // can be important if the source MapMode is not
154 // symmetrical) to page length and appends it to the buffer
155 // if pOutLength is set it will be updated to the emitted length
156 // (in PDF map mode, that is 10th of point)
157 void appendMappedLength( sal_Int32 nLength, OStringBuffer& rBuffer, bool bVertical = true, sal_Int32* pOutLength = nullptr ) const;
158 // the same for double values
159 void appendMappedLength( double fLength, OStringBuffer& rBuffer, bool bVertical = true, sal_Int32 nPrecision = 5 ) const;
160 // appends LineInfo
161 // returns false if too many dash array entry were created for
162 // the implementation limits of some PDF readers
163 bool appendLineInfo( const LineInfo& rInfo, OStringBuffer& rBuffer ) const;
164 // appends a horizontal waveline with vertical offset (helper for drawWaveLine)
165 void appendWaveLine( sal_Int32 nLength, sal_Int32 nYOffset, sal_Int32 nDelta, OStringBuffer& rBuffer ) const;
167 void appendMatrix3(Matrix3 const & rMatrix, OStringBuffer& rBuffer);
169 double getHeight() const;
172 /// Contains information to emit a reference XObject.
173 struct ReferenceXObjectEmit
175 /// ID of the Form XObject, if any.
176 sal_Int32 m_nFormObject;
177 /// ID of the vector/embedded object, if m_nFormObject is used.
178 sal_Int32 m_nEmbeddedObject;
179 /// ID of the bitmap object, if m_nFormObject is used.
180 sal_Int32 m_nBitmapObject;
181 /// Size of the bitmap replacement, in pixels.
182 Size m_aPixelSize;
183 /// PDF data from the graphic object, if not writing a reference XObject.
184 sal_Int32 m_nExternalPDFDataIndex;
185 sal_Int32 m_nExternalPDFPageIndex;
187 ReferenceXObjectEmit()
188 : m_nFormObject(0)
189 , m_nEmbeddedObject(0)
190 , m_nBitmapObject(0)
191 , m_nExternalPDFDataIndex(-1)
192 , m_nExternalPDFPageIndex(-1)
196 /// Returns the ID one should use when referring to this bitmap.
197 sal_Int32 getObject() const;
199 bool hasExternalPDFData() const
201 return m_nExternalPDFDataIndex >= 0;
205 struct BitmapEmit
207 BitmapID m_aID;
208 BitmapEx m_aBitmap;
209 sal_Int32 m_nObject;
210 ReferenceXObjectEmit m_aReferenceXObject;
212 BitmapEmit()
213 : m_nObject(0)
218 struct JPGEmit
220 BitmapID m_aID;
221 std::unique_ptr<SvMemoryStream>
222 m_pStream;
223 AlphaMask m_aAlphaMask;
224 sal_Int32 m_nObject;
225 bool m_bTrueColor;
226 ReferenceXObjectEmit m_aReferenceXObject;
228 JPGEmit()
229 : m_nObject(0)
230 , m_bTrueColor(false)
235 struct GradientEmit
237 Gradient m_aGradient;
238 Size m_aSize;
239 sal_Int32 m_nObject;
242 // for tilings (drawWallpaper, begin/endPattern)
243 struct TilingEmit
245 sal_Int32 m_nObject;
246 tools::Rectangle m_aRectangle;
247 Size m_aCellSize;
248 SvtGraphicFill::Transform m_aTransform;
249 ResourceDict m_aResources;
250 std::unique_ptr<SvMemoryStream> m_pTilingStream;
252 TilingEmit()
253 : m_nObject( 0 )
257 // for transparency group XObjects
258 struct TransparencyEmit
260 sal_Int32 m_nObject;
261 sal_Int32 m_nExtGStateObject;
262 double m_fAlpha;
263 tools::Rectangle m_aBoundRect;
264 std::unique_ptr<SvMemoryStream> m_pContentStream;
266 TransparencyEmit()
267 : m_nObject( 0 ),
268 m_nExtGStateObject( -1 ),
269 m_fAlpha( 0.0 )
273 // font subsets
275 struct ColorLayer
277 sal_Int32 m_nFontID;
278 sal_uInt8 m_nSubsetGlyphID;
279 uint32_t m_nColorIndex;
282 class GlyphEmit
284 // performance: actually this should probably a vector;
285 std::vector<sal_Ucs> m_CodeUnits;
286 sal_uInt8 m_nSubsetGlyphID;
287 sal_Int32 m_nGlyphWidth;
288 std::vector<ColorLayer> m_aColorLayers;
289 font::RawFontData m_aColorBitmap;
290 tools::Rectangle m_aRect;
291 basegfx::B2DPolyPolygon m_aOutline;
293 public:
294 GlyphEmit() : m_nSubsetGlyphID(0), m_nGlyphWidth(0)
298 void setGlyphId( sal_uInt8 i_nId ) { m_nSubsetGlyphID = i_nId; }
299 sal_uInt8 getGlyphId() const { return m_nSubsetGlyphID; }
301 void setGlyphWidth( sal_Int32 nWidth ) { m_nGlyphWidth = nWidth; }
302 sal_Int32 getGlyphWidth() const { return m_nGlyphWidth; }
304 void addColorLayer(ColorLayer aLayer) { m_aColorLayers.push_back(aLayer); }
305 const std::vector<ColorLayer>& getColorLayers() const { return m_aColorLayers; }
307 void setColorBitmap(font::RawFontData aData, tools::Rectangle aRect)
309 m_aColorBitmap = aData;
310 m_aRect = aRect;
312 const font::RawFontData& getColorBitmap(tools::Rectangle& rRect) const
314 rRect = m_aRect;
315 return m_aColorBitmap;
318 void setOutline(const basegfx::B2DPolyPolygon& rOutline) { m_aOutline = rOutline; }
319 const basegfx::B2DPolyPolygon& getOutline() const { return m_aOutline; }
321 void addCode( sal_Ucs i_cCode )
323 m_CodeUnits.push_back(i_cCode);
325 sal_Int32 countCodes() const { return m_CodeUnits.size(); }
326 const std::vector<sal_Ucs>& codes() const { return m_CodeUnits; }
327 sal_Ucs getCode( sal_Int32 i_nIndex ) const
329 sal_Ucs nRet = 0;
330 if (o3tl::make_unsigned(i_nIndex) < m_CodeUnits.size())
331 nRet = m_CodeUnits[i_nIndex];
332 return nRet;
336 struct FontEmit
338 sal_Int32 m_nFontID;
339 std::map<sal_GlyphId, GlyphEmit> m_aMapping;
341 explicit FontEmit( sal_Int32 nID ) : m_nFontID( nID ) {}
344 struct Glyph
346 sal_Int32 m_nFontID;
347 sal_uInt8 m_nSubsetGlyphID;
350 struct FontSubset
352 std::vector< FontEmit > m_aSubsets;
353 std::map<sal_GlyphId, Glyph> m_aMapping;
356 struct EmbedFont
358 sal_Int32 m_nNormalFontID;
359 LogicalFontInstance* m_pFontInstance;
361 EmbedFont()
362 : m_nNormalFontID(0)
363 , m_pFontInstance(nullptr) {}
366 struct PDFDest
368 sal_Int32 m_nPage;
369 PDFWriter::DestAreaType m_eType;
370 tools::Rectangle m_aRect;
373 //--->i56629
374 struct PDFNamedDest
376 OUString m_aDestName;
377 sal_Int32 m_nPage;
378 PDFWriter::DestAreaType m_eType;
379 tools::Rectangle m_aRect;
382 struct PDFOutlineEntry
384 sal_Int32 m_nObject;
385 sal_Int32 m_nParentObject;
386 sal_Int32 m_nNextObject;
387 sal_Int32 m_nPrevObject;
388 std::vector< sal_Int32 > m_aChildren;
389 OUString m_aTitle;
390 sal_Int32 m_nDestID;
392 PDFOutlineEntry()
393 : m_nObject( 0 ),
394 m_nParentObject( 0 ),
395 m_nNextObject( 0 ),
396 m_nPrevObject( 0 ),
397 m_nDestID( -1 )
401 struct PDFAnnotation
403 sal_Int32 m_nObject;
404 tools::Rectangle m_aRect;
405 sal_Int32 m_nPage;
407 PDFAnnotation()
408 : m_nObject( -1 ),
409 m_nPage( -1 )
413 struct PDFLink : public PDFAnnotation
415 sal_Int32 m_nDest; // set to -1 for URL, to a dest else
416 OUString m_aURL;
417 sal_Int32 m_nStructParent; // struct parent entry
418 OUString m_AltText;
420 PDFLink(OUString const& rAltText)
421 : m_nDest( -1 ),
422 m_nStructParent( -1 )
423 , m_AltText(rAltText)
427 /// A PDF embedded file.
428 struct PDFEmbeddedFile
430 /// ID of the file.
431 sal_Int32 m_nObject;
432 OUString m_aSubType;
433 /// Contents of the file.
434 BinaryDataContainer m_aDataContainer;
435 std::unique_ptr<PDFOutputStream> m_pStream;
437 PDFEmbeddedFile()
438 : m_nObject(0)
443 struct PDFPopupAnnotation : public PDFAnnotation
445 /// ID of the parent object.
446 sal_Int32 m_nParentObject;
449 struct PDFNoteEntry : public PDFAnnotation
451 vcl::pdf::PDFNote m_aContents;
453 PDFPopupAnnotation m_aPopUpAnnotation;
455 sal_Int32 m_nStructParent;
457 PDFNoteEntry()
458 : m_nStructParent(-1)
462 /// A PDF Screen annotation.
463 struct PDFScreen : public PDFAnnotation
465 /// Linked video.
466 OUString m_aURL;
467 /// Embedded video.
468 OUString m_aTempFileURL;
469 /// ID of the EmbeddedFile object.
470 sal_Int32 m_nTempFileObject;
471 /// alternative text description
472 OUString m_AltText;
473 sal_Int32 m_nStructParent;
474 OUString m_MimeType;
476 PDFScreen(OUString const& rAltText, OUString const& rMimeType)
477 : m_nTempFileObject(0)
478 , m_AltText(rAltText)
479 , m_nStructParent(-1)
480 , m_MimeType(rMimeType)
485 struct PDFWidgetCopy
487 sal_Int32 m_nObject = -1;
490 struct PDFWidget : public PDFAnnotation
492 PDFWriter::WidgetType m_eType;
493 OString m_aName;
494 OUString m_aDescription;
495 OUString m_aText;
496 DrawTextFlags m_nTextStyle;
497 OUString m_aValue;
498 OString m_aDAString;
499 OString m_aDRDict;
500 OString m_aMKDict;
501 OString m_aMKDictCAString; // i12626, added to be able to encrypt the /CA text string
502 // since the object number is not known at the moment
503 // of filling m_aMKDict, the string will be encrypted when emitted.
504 // the /CA string MUST BE the last added to m_aMKDict
505 // see code for details
506 sal_Int32 m_nFlags;
507 sal_Int32 m_nParent; // if not 0, parent's object number
508 std::vector<sal_Int32> m_aKids; // widget children, contains object numbers
509 std::vector<sal_Int32> m_aKidsIndex; // widget children, contains index to m_aWidgets
510 OUString m_aOnValue;
511 OUString m_aOffValue;
512 sal_Int32 m_nTabOrder; // lowest number gets first in tab order
513 sal_Int32 m_nRadioGroup;
514 sal_Int32 m_nMaxLen;
515 PDFWriter::FormatType m_nFormat;
516 OUString m_aCurrencySymbol;
517 sal_Int32 m_nDecimalAccuracy;
518 bool m_bPrependCurrencySymbol;
519 OUString m_aTimeFormat;
520 OUString m_aDateFormat;
521 bool m_bSubmit;
522 bool m_bSubmitGet;
523 sal_Int32 m_nDest;
524 std::vector<OUString> m_aListEntries;
525 std::vector<sal_Int32> m_aSelectedEntries;
526 typedef std::unordered_map<OString, SvMemoryStream*> PDFAppearanceStreams;
527 std::unordered_map<OString, PDFAppearanceStreams> m_aAppearances;
528 sal_Int32 m_nStructParent = -1;
530 PDFWidget()
531 : m_eType( PDFWriter::PushButton ),
532 m_nTextStyle( DrawTextFlags::NONE ),
533 m_nFlags( 0 ),
534 m_nParent( 0 ),
535 m_nTabOrder( 0 ),
536 m_nRadioGroup( -1 ),
537 m_nMaxLen( 0 ),
538 m_nFormat( PDFWriter::FormatType::Text ),
539 m_nDecimalAccuracy ( 0 ),
540 m_bPrependCurrencySymbol( false ),
541 m_bSubmit( false ),
542 m_bSubmitGet( false ),
543 m_nDest( -1 )
547 struct PDFStructureAttribute
549 PDFWriter::StructAttributeValue eValue;
550 sal_Int32 nValue;
552 PDFStructureAttribute()
553 : eValue( PDFWriter::Invalid ),
554 nValue( 0 )
557 explicit PDFStructureAttribute( PDFWriter::StructAttributeValue eVal )
558 : eValue( eVal ),
559 nValue( 0 )
562 explicit PDFStructureAttribute( sal_Int32 nVal )
563 : eValue( PDFWriter::Invalid ),
564 nValue( nVal )
568 struct ObjReference { sal_Int32 const nObject; };
569 struct ObjReferenceObj { sal_Int32 const nObject; };
570 struct MCIDReference { sal_Int32 const nPageObj; sal_Int32 const nMCID; };
571 typedef ::std::variant<ObjReference, ObjReferenceObj, MCIDReference> PDFStructureElementKid;
573 struct PDFStructureElement
575 sal_Int32 m_nObject;
576 ::std::optional<PDFWriter::StructElement> m_oType;
577 OString m_aAlias;
578 sal_Int32 m_nOwnElement; // index into structure vector
579 sal_Int32 m_nParentElement; // index into structure vector
580 sal_Int32 m_nFirstPageObject;
581 bool m_bOpenMCSeq;
582 std::vector< sal_Int32 > m_aChildren; // indexes into structure vector
583 std::list< PDFStructureElementKid > m_aKids;
584 std::map<PDFWriter::StructAttribute, PDFStructureAttribute >
585 m_aAttributes;
586 ::std::vector<sal_Int32> m_AnnotIds;
587 tools::Rectangle m_aBBox;
588 OUString m_aActualText;
589 OUString m_aAltText;
590 css::lang::Locale m_aLocale;
592 // m_aContents contains the element's marked content sequence
593 // as pairs of (page nr, MCID)
595 PDFStructureElement()
596 : m_nObject( 0 ),
597 m_nOwnElement( -1 ),
598 m_nParentElement( -1 ),
599 m_nFirstPageObject( 0 ),
600 m_bOpenMCSeq( false )
604 PDFStructureElement(sal_Int32 nOwnElement, sal_Int32 nParentElement, sal_Int32 nFirstPageObject)
605 : m_nObject(0)
606 , m_nOwnElement(nOwnElement)
607 , m_nParentElement(nParentElement)
608 , m_nFirstPageObject(nFirstPageObject)
609 , m_bOpenMCSeq(false )
614 // helper structure for drawLayout and friends
615 struct PDFGlyph
617 basegfx::B2DPoint const m_aPos;
618 const GlyphItem* m_pGlyph;
619 const LogicalFontInstance* m_pFont;
620 sal_Int32 const m_nNativeWidth;
621 sal_Int32 const m_nMappedFontId;
622 sal_uInt8 const m_nMappedGlyphId;
623 int const m_nCharPos;
625 PDFGlyph( const basegfx::B2DPoint& rPos,
626 const GlyphItem* pGlyph,
627 const LogicalFontInstance* pFont,
628 sal_Int32 nNativeWidth,
629 sal_Int32 nFontId,
630 sal_uInt8 nMappedGlyphId,
631 int nCharPos )
632 : m_aPos( rPos ), m_pGlyph(pGlyph), m_pFont(pFont), m_nNativeWidth( nNativeWidth ),
633 m_nMappedFontId( nFontId ), m_nMappedGlyphId( nMappedGlyphId ),
634 m_nCharPos(nCharPos)
638 struct StreamRedirect
640 SvStream* m_pStream;
641 MapMode m_aMapMode;
642 tools::Rectangle m_aTargetRect;
643 ResourceDict m_aResourceDict;
646 // graphics state
647 struct GraphicsState
649 vcl::Font m_aFont;
650 MapMode m_aMapMode;
651 Color m_aLineColor;
652 Color m_aFillColor;
653 Color m_aTextLineColor;
654 Color m_aOverlineColor;
655 basegfx::B2DPolyPolygon m_aClipRegion;
656 bool m_bClipRegion;
657 vcl::text::ComplexTextLayoutFlags m_nLayoutMode;
658 LanguageType m_aDigitLanguage;
659 PushFlags m_nFlags;
660 GraphicsStateUpdateFlags m_nUpdateFlags;
662 GraphicsState() :
663 m_aLineColor( COL_TRANSPARENT ),
664 m_aFillColor( COL_TRANSPARENT ),
665 m_aTextLineColor( COL_TRANSPARENT ),
666 m_aOverlineColor( COL_TRANSPARENT ),
667 m_bClipRegion( false ),
668 m_nLayoutMode( vcl::text::ComplexTextLayoutFlags::Default ),
669 m_aDigitLanguage( 0 ),
670 m_nFlags( PushFlags::ALL ),
671 m_nUpdateFlags( GraphicsStateUpdateFlags::All )
675 enum class Mode { DEFAULT, NOWRITE };
677 struct PDFDocumentAttachedFile
679 OUString maFilename;
680 OUString maMimeType;
681 OUString maDescription;
682 sal_Int32 mnEmbeddedFileObjectId;
683 sal_Int32 mnObjectId;
686 class IPDFEncryptor;
688 } // end pdf namespace
690 class PDFWriterImpl final : public VirtualDevice, public PDFObjectContainer
692 friend class PDFStreamIf;
694 public:
695 friend struct vcl::pdf::PDFPage;
697 const char* getStructureTag( PDFWriter::StructElement );
698 static const char* getAttributeTag( PDFWriter::StructAttribute eAtr );
699 static const char* getAttributeValueTag( PDFWriter::StructAttributeValue eVal );
701 // returns true if compression was done
702 // else false
703 static bool compressStream( SvMemoryStream* );
705 static void convertLineInfoToExtLineInfo( const LineInfo& rIn, PDFWriter::ExtLineInfo& rOut );
707 private:
708 bool ImplNewFont() const override;
709 void ImplClearFontData(bool bNewFontLists) override;
710 void ImplRefreshFontData(bool bNewFontLists) override;
711 vcl::Region ClipToDeviceBounds(vcl::Region aRegion) const override;
712 void DrawHatchLine_DrawLine(const Point& rStartPoint, const Point& rEndPoint) override;
714 MapMode m_aMapMode; // PDFWriterImpl scaled units
715 StyleSettings m_aWidgetStyleSettings;
716 std::vector< PDFPage > m_aPages;
717 /* maps object numbers to file offsets (needed for xref) */
718 std::vector< sal_uInt64 > m_aObjects;
719 /* contains Bitmaps until they are written to the
720 * file stream as XObjects*/
721 std::list< BitmapEmit > m_aBitmaps;
722 /* contains JPG streams until written to file */
723 std::vector<JPGEmit> m_aJPGs;
724 /*--->i56629 contains all named destinations ever set during the PDF creation,
725 destination id is always the destination's position in this vector
727 std::vector<PDFNamedDest> m_aNamedDests;
728 /* contains all dests ever set during the PDF creation,
729 dest id is always the dest's position in this vector
731 std::vector<PDFDest> m_aDests;
732 /** contains destinations accessible via a public Id, instead of being linked to by an ordinary link
734 ::std::map< sal_Int32, sal_Int32 > m_aDestinationIdTranslation;
735 /* contains all links ever set during PDF creation,
736 link id is always the link's position in this vector
738 std::vector<PDFLink> m_aLinks;
739 /// Contains all screen annotations.
740 std::vector<PDFScreen> m_aScreens;
741 /// Contains embedded files.
742 std::vector<PDFEmbeddedFile> m_aEmbeddedFiles;
744 std::vector<PDFDocumentAttachedFile> m_aDocumentAttachedFiles;
746 /* makes correctly encoded for export to PDF URLS
748 css::uno::Reference< css::util::XURLTransformer > m_xTrans;
749 /* maps arbitrary link ids for structure attributes to real link ids
750 (for setLinkPropertyId)
752 std::map<sal_Int32, sal_Int32> m_aLinkPropertyMap;
753 /* contains all outline items,
754 object 0 is the outline root
756 std::vector<PDFOutlineEntry> m_aOutline;
757 /* contains all notes set during PDF creation
759 std::vector<PDFNoteEntry> m_aNotes;
760 /* the root of the structure tree
762 std::vector<PDFStructureElement> m_aStructure;
763 /* current object in the structure hierarchy
765 sal_Int32 m_nCurrentStructElement;
766 std::stack<sal_Int32> m_StructElementStack;
767 /* structure parent tree */
768 std::vector< OString > m_aStructParentTree;
769 /* emit structure marks currently (aka. NonStructElement or not)
771 bool m_bEmitStructure;
772 /* role map of struct tree root */
773 std::unordered_map< OString, OString >
774 m_aRoleMap;
775 /* structure elements (object ids) that should have ID */
776 std::unordered_set<sal_Int32> m_StructElemObjsWithID;
778 /* contains all widgets used in the PDF */
779 std::vector<PDFWidget> m_aWidgets;
780 std::vector<PDFWidgetCopy> m_aCopiedWidgets;
782 /* maps radio group id to index of radio group control in m_aWidgets */
783 std::map< sal_Int32, sal_Int32 > m_aRadioGroupWidgets;
784 /* unordered_map for field names, used to ensure unique field names */
785 std::unordered_map< OString, sal_Int32 > m_aFieldNameMap;
787 /* contains Bitmaps for gradient functions until they are written
788 * to the file stream */
789 std::list< GradientEmit > m_aGradients;
790 /* contains bitmap tiling patterns */
791 std::vector< TilingEmit > m_aTilings;
792 std::vector< TransparencyEmit > m_aTransparentObjects;
793 /* contains all font subsets in use */
794 std::map<const vcl::font::PhysicalFontFace*, FontSubset> m_aSubsets;
795 std::map<const vcl::font::PhysicalFontFace*, EmbedFont> m_aSystemFonts;
796 std::map<const vcl::font::PhysicalFontFace*, FontSubset> m_aType3Fonts;
797 sal_Int32 m_nNextFID;
799 /// Cache some most recent bitmaps we've exported, in case we encounter them again..
800 o3tl::lru_map<BitmapChecksum,
801 std::shared_ptr<SvMemoryStream>> m_aPDFBmpCache;
803 sal_Int32 m_nCurrentPage;
805 sal_Int32 m_nCatalogObject;
806 // object number of the main signature dictionary
807 sal_Int32 m_nSignatureObject;
808 sal_Int64 m_nSignatureContentOffset;
809 sal_Int64 m_nSignatureLastByteRangeNoOffset;
810 sal_Int32 m_nResourceDict;
811 ResourceDict m_aGlobalResourceDict;
812 sal_Int32 m_nFontDictObject;
813 std::map< sal_Int32, sal_Int32 > m_aBuildinFontToObjectMap;
815 PDFWriter::PDFWriterContext m_aContext;
816 osl::File m_aFile;
817 bool m_bOpen;
819 ExternalPDFStreams m_aExternalPDFStreams;
821 std::shared_ptr<IPDFEncryptor> m_pPDFEncryptor;
823 /* output redirection; e.g. to accumulate content streams for
824 XObjects
826 std::list< StreamRedirect > m_aOutputStreams;
828 std::list< GraphicsState > m_aGraphicsStack;
829 GraphicsState m_aCurrentPDFState;
831 std::unique_ptr<ZCodec> m_pCodec;
832 std::unique_ptr<SvMemoryStream> m_pMemStream;
834 std::set< PDFWriter::ErrorCode > m_aErrors;
836 ::comphelper::Hash m_DocDigest;
838 // reduce repeated allocations
839 OStringBuffer updateGraphicsStateLine{256};
840 OStringBuffer drawBitmapLine{80};
842 sal_uInt64 getCurrentFilePosition()
844 sal_uInt64 nPosition{};
845 if (osl::File::E_None != m_aFile.getPos(nPosition))
847 m_aFile.close();
848 m_bOpen = false;
850 return nPosition;
853 /* string to hold the PDF creation date */
854 OString m_aCreationDateString;
855 /* string to hold the PDF creation date, for PDF/A metadata */
856 OString m_aCreationMetaDateString;
857 /* the buffer where the data are encrypted, dynamically allocated */
858 std::vector<sal_uInt8> m_vEncryptionBuffer;
860 void addRoleMap(const OString& aAlias, PDFWriter::StructElement eType);
862 void checkAndEnableStreamEncryption( sal_Int32 nObject ) override;
864 void disableStreamEncryption() override;
866 /* */
867 void enableStringEncryption( sal_Int32 nObject );
869 private:
870 /* creates fonts and subsets that will be emitted later */
871 void registerGlyph(const sal_GlyphId, const vcl::font::PhysicalFontFace*, const LogicalFontInstance* pFont, const std::vector<sal_Ucs>&, sal_Int32, sal_uInt8&, sal_Int32&);
872 void registerSimpleGlyph(const sal_GlyphId, const vcl::font::PhysicalFontFace*, const std::vector<sal_Ucs>&, sal_Int32, sal_uInt8&, sal_Int32&);
874 /* emits a text object according to the passed layout */
875 /* TODO: remove rText as soon as SalLayout will change so that rText is not necessary anymore */
876 void drawVerticalGlyphs( const std::vector<PDFGlyph>& rGlyphs, OStringBuffer& rLine, const Point& rAlignOffset, const Matrix3& rRotScale, double fAngle, double fXScale, sal_Int32 nFontHeight );
877 void drawHorizontalGlyphs( const std::vector<PDFGlyph>& rGlyphs, OStringBuffer& rLine, const Point& rAlignOffset, bool bFirst, double fAngle, double fXScale, sal_Int32 nFontHeight, sal_Int32 nPixelFontHeight );
878 void drawLayout( SalLayout& rLayout, const OUString& rText, bool bTextLines );
879 void drawRelief( SalLayout& rLayout, const OUString& rText, bool bTextLines );
880 void drawShadow( SalLayout& rLayout, const OUString& rText, bool bTextLines );
882 /* writes differences between graphics stack and current real PDF
883 * state to the file
885 void updateGraphicsState(Mode mode = Mode::DEFAULT);
887 /* writes a transparency group object */
888 void writeTransparentObject( TransparencyEmit& rObject );
890 /* writes an XObject of type image, may create
891 a second for the mask
893 bool writeBitmapObject( const BitmapEmit& rObject, bool bMask = false );
895 void writeJPG( const JPGEmit& rEmit );
896 /// Writes the form XObject proxy for the image.
897 void writeReferenceXObject(const ReferenceXObjectEmit& rEmit);
899 void mergeAnnotationsFromExternalPage(filter::PDFObjectElement* pPage, std::map<sal_Int32, sal_Int32>& rCopiedResourcesMap);
901 /* tries to find the bitmap by its id and returns its emit data if exists,
902 else creates a new emit data block */
903 const BitmapEmit& createBitmapEmit( const BitmapEx& rBitmapEx, const Graphic& rGraphic, std::list<BitmapEmit>& rBitmaps, ResourceDict& rResourceDict, std::list<StreamRedirect>& rOutputStreams );
904 const BitmapEmit& createBitmapEmit( const BitmapEx& rBitmapEx, const Graphic& rGraphic );
906 /* writes the Do operation inside the content stream */
907 void drawBitmap( const Point& rDestPt, const Size& rDestSize, const BitmapEmit& rBitmap, const Color& rFillColor );
908 /* write the function object for a Gradient */
909 bool writeGradientFunction( GradientEmit const & rObject );
910 /* creates a GradientEmit and returns its object number */
911 sal_Int32 createGradient( const Gradient& rGradient, const Size& rSize );
913 /* writes all tilings */
914 bool emitTilings();
915 /* writes all gradient patterns */
916 bool emitGradients();
917 /* writes a builtin font object and returns its objectid (or 0 in case of failure ) */
918 sal_Int32 emitBuildinFont( const pdf::BuildinFontFace*, sal_Int32 nObject );
919 /* writes a type1 system font object and returns its mapping from font ids to object ids (or 0 in case of failure ) */
920 std::map< sal_Int32, sal_Int32 > emitSystemFont(const vcl::font::PhysicalFontFace*, EmbedFont const &);
921 /* writes a type3 font object and appends it to the font id mapping, or returns false in case of failure */
922 bool emitType3Font(const vcl::font::PhysicalFontFace*, const FontSubset&, std::map<sal_Int32, sal_Int32>&);
923 /* writes a font descriptor and returns its object id (or 0) */
924 sal_Int32 emitFontDescriptor(const vcl::font::PhysicalFontFace*, FontSubsetInfo const &, sal_Int32 nSubsetID, sal_Int32 nStream);
925 /* writes a ToUnicode cmap, returns the corresponding stream object */
926 sal_Int32 createToUnicodeCMap( sal_uInt8 const * pEncoding, const std::vector<sal_Ucs>& CodeUnits, const sal_Int32* pCodeUnitsPerGlyph,
927 const sal_Int32* pEncToUnicodeIndex, uint32_t nGlyphs );
929 /* get resource dict object number */
930 sal_Int32 getResourceDictObj()
932 if( m_nResourceDict <= 0 )
933 m_nResourceDict = createObject();
934 return m_nResourceDict;
936 /* get the font dict object */
937 sal_Int32 getFontDictObject()
939 if( m_nFontDictObject <= 0 )
940 m_nFontDictObject = createObject();
941 return m_nFontDictObject;
943 /* push resource into current (redirected) resource dict */
944 static void pushResource( ResourceKind eKind, const OString& rResource, sal_Int32 nObject, ResourceDict& rResourceDict, std::list<StreamRedirect>& rOutputStreams );
945 void pushResource( ResourceKind eKind, const OString& rResource, sal_Int32 nObject );
947 void appendBuildinFontsToDict( OStringBuffer& rDict ) const;
948 /* writes the font dictionary and emits all font objects
949 * returns object id of font directory (or 0 on error)
951 bool emitFonts();
952 /* writes the Resource dictionary;
953 * returns dict object id (or 0 on error)
955 sal_Int32 emitResources();
956 // appends a dest
957 bool appendDest( sal_Int32 nDestID, OStringBuffer& rBuffer );
958 // write all links
959 bool emitLinkAnnotations();
960 // Write all screen annotations.
961 bool emitScreenAnnotations();
963 void emitTextAnnotationLine(OStringBuffer & aLine, PDFNoteEntry const & rNote);
964 static void emitPopupAnnotationLine(OStringBuffer & aLine, PDFPopupAnnotation const & rPopUp);
965 // write all notes
966 bool emitNoteAnnotations();
968 // write the appearance streams of a widget
969 bool emitAppearances( PDFWidget& rWidget, OStringBuffer& rAnnotDict );
970 // clean up radio button "On" values
971 void ensureUniqueRadioOnValues();
972 // write all widgets
973 bool emitWidgetAnnotations();
974 // writes all annotation objects
975 bool emitAnnotations();
976 /// Writes embedded files.
977 bool emitEmbeddedFiles();
978 //write the named destination stuff
979 sal_Int32 emitNamedDestinations();//i56629
980 // writes outline dict and tree
981 sal_Int32 emitOutline();
982 template<typename T> void AppendAnnotKid(PDFStructureElement& i_rEle, T & rAnnot);
983 // puts the attribute objects of a structure element into the returned string,
984 // helper for emitStructure
985 OString emitStructureAttributes( PDFStructureElement& rEle );
986 //--->i94258
987 // the maximum array elements allowed for PDF array object
988 static const sal_uInt32 ncMaxPDFArraySize = 8191;
989 //check if internal dummy container are needed in the structure elements
990 void addInternalStructureContainer( PDFStructureElement& rEle );
991 //<---i94258
992 // writes document structure
993 sal_Int32 emitStructure( PDFStructureElement& rEle );
994 // writes structure parent tree
995 sal_Int32 emitStructParentTree( sal_Int32 nTreeObject );
996 // writes structure IDTree
997 sal_Int32 emitStructIDTree(sal_Int32 nTreeObject);
998 // writes page tree and catalog
999 bool emitCatalog();
1000 // writes signature dictionary object
1001 bool emitSignature();
1002 // creates a PKCS7 object using the ByteRange and overwrite /Contents
1003 // of the signature dictionary
1004 bool finalizeSignature();
1005 //writes encrypt
1006 sal_Int32 emitEncrypt();
1007 // writes xref and trailer
1008 bool emitTrailer();
1009 // emits info dict (if applicable)
1010 sal_Int32 emitInfoDict( );
1012 // acrobat reader 5 and 6 use the order of the annotations
1013 // as their tab order; since PDF1.5 one can make the
1014 // tab order explicit by using the structure tree
1015 void sortWidgets();
1017 // updates the count numbers of outline items
1018 sal_Int32 updateOutlineItemCount( std::vector< sal_Int32 >& rCounts,
1019 sal_Int32 nItemLevel,
1020 sal_Int32 nCurrentItemId );
1021 // default appearances for widgets
1022 sal_Int32 findRadioGroupWidget( const PDFWriter::RadioButtonWidget& rRadio );
1023 Font replaceFont( const Font& rControlFont, const Font& rAppSetFont );
1024 sal_Int32 getBestBuildinFont( const Font& rFont );
1025 sal_Int32 getSystemFont( const Font& i_rFont );
1027 // used for edit and listbox
1028 Font drawFieldBorder( PDFWidget&, const PDFWriter::AnyWidget&, const StyleSettings& );
1030 void createDefaultPushButtonAppearance( PDFWidget&, const PDFWriter::PushButtonWidget& rWidget );
1031 void createDefaultCheckBoxAppearance( PDFWidget&, const PDFWriter::CheckBoxWidget& rWidget );
1032 void createDefaultRadioButtonAppearance( PDFWidget&, const PDFWriter::RadioButtonWidget& rWidget );
1033 void createDefaultEditAppearance( PDFWidget&, const PDFWriter::EditWidget& rWidget );
1034 void createDefaultListBoxAppearance( PDFWidget&, const PDFWriter::ListBoxWidget& rWidget );
1036 /* ensure proper escapement and uniqueness of field names */
1037 void createWidgetFieldName( sal_Int32 i_nWidgetsIndex, const PDFWriter::AnyWidget& i_rInWidget );
1038 /// See vcl::PDFObjectContainer::createObject().
1039 sal_Int32 createObject() override;
1040 /// See vcl::PDFObjectContainer::updateObject().
1041 bool updateObject( sal_Int32 n ) override;
1043 /// See vcl::PDFObjectContainer::writeBuffer().
1044 bool writeBufferBytes( const void* pBuffer, sal_uInt64 nBytes ) override;
1045 void beginCompression();
1046 void endCompression();
1047 void beginRedirect( SvStream* pStream, const tools::Rectangle& );
1048 SvStream* endRedirect();
1050 void endPage();
1052 void beginStructureElementMCSeq();
1053 enum class EndMode { Default, OnlyStruct };
1054 void endStructureElementMCSeq(EndMode = EndMode::Default);
1055 /** checks whether a non struct element lies in the ancestor hierarchy
1056 of the current structure element
1058 @returns
1059 true if no NonStructElement was found in ancestor path and tagged
1060 PDF output is enabled
1061 false else
1063 bool checkEmitStructure();
1065 /* draws an emphasis mark */
1066 void drawEmphasisMark( tools::Long nX, tools::Long nY, const tools::PolyPolygon& rPolyPoly, bool bPolyLine, const tools::Rectangle& rRect1, const tools::Rectangle& rRect2 );
1068 /* true if PDF/A-1a or PDF/A-1b is output */
1069 bool m_bIsPDF_A1 = false;
1070 /* true if PDF/A-2a is output */
1071 bool m_bIsPDF_A2 = false;
1072 /* true if PDF/A-3 is output */
1073 bool m_bIsPDF_A3 = false;
1074 /* true if PDF/A-4 is output */
1075 bool m_bIsPDF_A4 = false;
1077 sal_Int32 m_nPDFA_Version = 0;
1079 /* PDF/UA support enabled */
1080 bool m_bIsPDF_UA = false;
1082 PDFWriter& m_rOuterFace;
1085 i12626
1086 methods for PDF security
1088 pad a password according algorithm 3.2, step 1 */
1089 void setupDocInfo();
1091 // helper for playMetafile
1092 void implWriteGradient( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient,
1093 VirtualDevice* pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& );
1094 void implWriteBitmapEx( const Point& rPoint, const Size& rSize, const BitmapEx& rBitmapEx, const Graphic& i_pGraphic,
1095 VirtualDevice const * pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& );
1097 // helpers for CCITT 1bit bitmap stream
1098 void putG4Bits( sal_uInt32 i_nLength, sal_uInt32 i_nCode, BitStreamState& io_rState );
1099 void putG4Span( tools::Long i_nSpan, bool i_bWhitePixel, BitStreamState& io_rState );
1100 void writeG4Stream( BitmapReadAccess const * i_pBitmap );
1102 // color helper functions
1103 void appendStrokingColor( const Color& rColor, OStringBuffer& rBuffer );
1104 void appendNonStrokingColor( const Color& rColor, OStringBuffer& rBuffer );
1105 public:
1106 PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext, const css::uno::Reference< css::beans::XMaterialHolder >&, PDFWriter& );
1107 ~PDFWriterImpl() override;
1108 void dispose() override;
1110 /* document structure */
1111 void newPage( double nPageWidth , double nPageHeight, PDFWriter::Orientation eOrientation );
1112 bool emit();
1113 const std::set< PDFWriter::ErrorCode > & getErrors() const { return m_aErrors;}
1114 void insertError( PDFWriter::ErrorCode eErr ) { m_aErrors.insert( eErr ); }
1115 void playMetafile( const GDIMetaFile&, vcl::PDFExtOutDevData*, const vcl::PDFWriter::PlayMetafileContext&, VirtualDevice* pDummyDev = nullptr );
1117 Size getCurPageSize() const
1119 Size aSize;
1120 if( m_nCurrentPage >= 0 && o3tl::make_unsigned(m_nCurrentPage) < m_aPages.size() )
1121 aSize = Size( m_aPages[ m_nCurrentPage ].m_nPageWidth, m_aPages[ m_nCurrentPage ].m_nPageHeight );
1122 return aSize;
1125 void setDocumentLocale( const css::lang::Locale& rLoc )
1126 { m_aContext.DocumentLocale = rLoc; }
1128 /* graphics state */
1129 void push( PushFlags nFlags );
1130 void pop();
1132 void setFont( const Font& rFont );
1134 void setMapMode( const MapMode& rMapMode );
1136 const MapMode& getMapMode() { return m_aGraphicsStack.front().m_aMapMode; }
1138 void setLineColor( const Color& rColor )
1140 m_aGraphicsStack.front().m_aLineColor = rColor.IsTransparent() ? COL_TRANSPARENT : rColor;
1141 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::LineColor;
1144 void setFillColor( const Color& rColor )
1146 m_aGraphicsStack.front().m_aFillColor = rColor.IsTransparent() ? COL_TRANSPARENT : rColor;
1147 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::FillColor;
1150 void setTextLineColor()
1152 m_aGraphicsStack.front().m_aTextLineColor = COL_TRANSPARENT;
1155 void setTextLineColor( const Color& rColor )
1157 m_aGraphicsStack.front().m_aTextLineColor = rColor;
1160 void setOverlineColor()
1162 m_aGraphicsStack.front().m_aOverlineColor = COL_TRANSPARENT;
1165 void setOverlineColor( const Color& rColor )
1167 m_aGraphicsStack.front().m_aOverlineColor = rColor;
1170 void setTextFillColor( const Color& rColor )
1172 m_aGraphicsStack.front().m_aFont.SetFillColor( rColor );
1173 m_aGraphicsStack.front().m_aFont.SetTransparent( rColor.IsTransparent() );
1174 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
1176 void setTextFillColor()
1178 m_aGraphicsStack.front().m_aFont.SetFillColor( COL_TRANSPARENT );
1179 m_aGraphicsStack.front().m_aFont.SetTransparent( true );
1180 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
1182 void setTextColor( const Color& rColor )
1184 m_aGraphicsStack.front().m_aFont.SetColor( rColor );
1185 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
1188 void clearClipRegion()
1190 m_aGraphicsStack.front().m_aClipRegion.clear();
1191 m_aGraphicsStack.front().m_bClipRegion = false;
1192 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::ClipRegion;
1195 void setClipRegion( const basegfx::B2DPolyPolygon& rRegion );
1197 void moveClipRegion( sal_Int32 nX, sal_Int32 nY );
1199 void intersectClipRegion( const tools::Rectangle& rRect );
1201 void intersectClipRegion( const basegfx::B2DPolyPolygon& rRegion );
1203 void setLayoutMode( vcl::text::ComplexTextLayoutFlags nLayoutMode )
1205 m_aGraphicsStack.front().m_nLayoutMode = nLayoutMode;
1206 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::LayoutMode;
1209 void setDigitLanguage( LanguageType eLang )
1211 m_aGraphicsStack.front().m_aDigitLanguage = eLang;
1212 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::DigitLanguage;
1215 void setTextAlign( TextAlign eAlign )
1217 m_aGraphicsStack.front().m_aFont.SetAlignment( eAlign );
1218 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::Font;
1221 /* actual drawing functions */
1222 void drawText( const Point& rPos, const OUString& rText, sal_Int32 nIndex, sal_Int32 nLen, bool bTextLines = true );
1223 void drawTextArray(const Point& rPos, const OUString& rText, KernArraySpan pDXArray,
1224 std::span<const sal_Bool> pKashidaArray, sal_Int32 nIndex, sal_Int32 nLen,
1225 sal_Int32 nLayoutContextIndex, sal_Int32 nLayoutContextLen);
1226 void drawStretchText( const Point& rPos, sal_Int32 nWidth, const OUString& rText,
1227 sal_Int32 nIndex, sal_Int32 nLen );
1228 void drawText( const tools::Rectangle& rRect, const OUString& rOrigStr, DrawTextFlags nStyle );
1229 void drawTextLine( const Point& rPos, tools::Long nWidth, FontStrikeout eStrikeout, FontLineStyle eUnderline, FontLineStyle eOverline, bool bUnderlineAbove );
1230 void drawWaveTextLine( OStringBuffer& aLine, tools::Long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove );
1231 void drawStraightTextLine( OStringBuffer& aLine, tools::Long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove );
1232 void drawStrikeoutLine( OStringBuffer& aLine, tools::Long nWidth, FontStrikeout eStrikeout, Color aColor );
1233 void drawStrikeoutChar( const Point& rPos, tools::Long nWidth, FontStrikeout eStrikeout );
1235 void drawLine( const Point& rStart, const Point& rStop );
1236 void drawLine( const Point& rStart, const Point& rStop, const LineInfo& rInfo );
1237 void drawPolygon( const tools::Polygon& rPoly );
1238 void drawPolyPolygon( const tools::PolyPolygon& rPolyPoly );
1239 void drawPolyLine( const tools::Polygon& rPoly );
1240 void drawPolyLine( const tools::Polygon& rPoly, const LineInfo& rInfo );
1241 void drawPolyLine( const tools::Polygon& rPoly, const PDFWriter::ExtLineInfo& rInfo );
1243 void drawPixel( const Point& rPt, const Color& rColor );
1245 void drawRectangle( const tools::Rectangle& rRect );
1246 void drawRectangle( const tools::Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt32 nVertRound );
1247 void drawEllipse( const tools::Rectangle& rRect );
1248 void drawArc( const tools::Rectangle& rRect, const Point& rStart, const Point& rStop, bool bWithPie, bool bWidthChord );
1250 void drawBitmap( const Point& rDestPoint, const Size& rDestSize, const Bitmap& rBitmap, const Graphic& rGraphic );
1251 void drawBitmap( const Point& rDestPoint, const Size& rDestSize, const BitmapEx& rBitmap );
1252 void drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const Size& rSizePixel, const tools::Rectangle& rTargetArea, const AlphaMask& rAlphaMask, const Graphic& rGraphic );
1253 /// Stores the original PDF data from rGraphic as an embedded file.
1254 void createEmbeddedFile(const Graphic& rGraphic, ReferenceXObjectEmit& rEmit, sal_Int32 nBitmapObject);
1256 void drawGradient( const tools::Rectangle& rRect, const Gradient& rGradient );
1257 void drawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch );
1258 void drawWallpaper( const tools::Rectangle& rRect, const Wallpaper& rWall );
1259 void drawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uInt32 nTransparentPercent );
1260 void beginTransparencyGroup();
1261 void endTransparencyGroup( const tools::Rectangle& rBoundingBox, sal_uInt32 nTransparentPercent );
1263 void emitComment( const char* pComment );
1265 //--->i56629 named destinations
1266 sal_Int32 createNamedDest( const OUString& sDestName, const tools::Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType );
1268 //--->i59651
1269 //emits output intent
1270 sal_Int32 emitOutputIntent();
1272 //emits the document metadata
1273 sal_Int32 emitDocumentMetadata();
1275 // links
1276 sal_Int32 createLink(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText);
1277 sal_Int32 createDest( const tools::Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType );
1278 sal_Int32 registerDestReference( sal_Int32 nDestId, const tools::Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType );
1279 void setLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId );
1280 void setLinkURL( sal_Int32 nLinkId, const OUString& rURL );
1281 void setLinkPropertyId( sal_Int32 nLinkId, sal_Int32 nPropertyId );
1283 // screens
1284 sal_Int32 createScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText, OUString const& rMimeType);
1285 void setScreenURL(sal_Int32 nScreenId, const OUString& rURL);
1286 void setScreenStream(sal_Int32 nScreenId, const OUString& rURL);
1288 // outline
1289 sal_Int32 createOutlineItem( sal_Int32 nParent, std::u16string_view rText, sal_Int32 nDestID );
1290 void setOutlineItemParent( sal_Int32 nItem, sal_Int32 nNewParent );
1291 void setOutlineItemText( sal_Int32 nItem, std::u16string_view rText );
1292 void setOutlineItemDest( sal_Int32 nItem, sal_Int32 nDestID );
1294 // notes
1295 sal_Int32 createNote(const tools::Rectangle& rRect, const tools::Rectangle& rPopupRect, const PDFNote& rNote, sal_Int32 nPageNr);
1296 // structure elements
1297 sal_Int32 ensureStructureElement();
1298 void initStructureElement(sal_Int32 id, PDFWriter::StructElement eType, std::u16string_view rAlias);
1299 void beginStructureElement(sal_Int32 id);
1300 void endStructureElement();
1301 bool setCurrentStructureElement( sal_Int32 nElement );
1302 bool setStructureAttribute( enum PDFWriter::StructAttribute eAttr, enum PDFWriter::StructAttributeValue eVal );
1303 bool setStructureAttributeNumerical( enum PDFWriter::StructAttribute eAttr, sal_Int32 nValue );
1304 void setStructureBoundingBox( const tools::Rectangle& rRect );
1305 void setStructureAnnotIds(::std::vector<sal_Int32> const& rAnnotIds);
1306 void setActualText( const OUString& rText );
1307 void setAlternateText( const OUString& rText );
1309 // transitional effects
1310 void setPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr );
1312 // controls
1313 sal_Int32 createControl( const PDFWriter::AnyWidget& rControl, sal_Int32 nPageNr = -1 );
1315 // attached file
1316 void addDocumentAttachedFile(OUString const& rFileName, OUString const& rMimeType, OUString const& rDescription, std::unique_ptr<PDFOutputStream> rStream);
1318 sal_Int32 addEmbeddedFile(BinaryDataContainer const & rDataContainer);
1319 sal_Int32 addEmbeddedFile(std::unique_ptr<PDFOutputStream> rStream, OUString const& rMimeType);
1321 // helper: eventually begin marked content sequence and
1322 // emit a comment in debug case
1323 void MARK( const char* pString );
1326 } // namespace vcl
1328 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */