Bump version to 21.06.18.1
[LibreOffice.git] / include / vcl / pdfwriter.hxx
blobf7010910299a8fc0f0ea7a8bec7957608fec3a89
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_PDFWRITER_HXX
20 #define INCLUDED_VCL_PDFWRITER_HXX
22 #include <config_options.h>
23 #include <sal/types.h>
25 #include <tools/gen.hxx>
26 #include <tools/color.hxx>
27 #include <rtl/strbuf.hxx>
29 #include <vcl/dllapi.h>
30 #include <vcl/font.hxx>
31 #include <vcl/outdev.hxx>
32 #include <vcl/graph.hxx>
34 #include <com/sun/star/lang/Locale.hpp>
35 #include <com/sun/star/util/DateTime.hpp>
37 #include <memory>
38 #include <vector>
39 #include <set>
41 namespace com::sun::star::beans { class XMaterialHolder; }
42 namespace com::sun::star::io { class XOutputStream; }
43 namespace com::sun::star::security { class XCertificate; }
45 class GDIMetaFile;
46 class MapMode;
47 class LineInfo;
48 namespace tools {
49 class Polygon;
50 class PolyPolygon;
52 class Bitmap;
53 class BitmapEx;
54 class Gradient;
55 class Hatch;
56 class Wallpaper;
58 namespace vcl
61 class PDFExtOutDevData;
62 class PDFWriterImpl;
64 struct PDFNote
66 OUString Title; // optional title for the popup containing the note
67 OUString Contents; // contents of the note
68 css::util::DateTime maModificationDate;
71 class VCL_DLLPUBLIC PDFOutputStream
73 public:
74 virtual ~PDFOutputStream();
75 virtual void write( const css::uno::Reference< css::io::XOutputStream >& xStream ) = 0;
78 class VCL_DLLPUBLIC PDFWriter
80 ScopedVclPtr<PDFWriterImpl> xImplementation;
82 PDFWriter(const PDFWriter&) = delete;
83 PDFWriter& operator=(const PDFWriter&) = delete;
85 public:
86 // extended line info
87 enum CapType { capButt, capRound, capSquare };
88 enum JoinType { joinMiter, joinRound, joinBevel };
89 struct ExtLineInfo
91 double m_fLineWidth;
92 double m_fTransparency;
93 CapType m_eCap;
94 JoinType m_eJoin;
95 double m_fMiterLimit;
96 std::vector< double > m_aDashArray;
98 ExtLineInfo() : m_fLineWidth( 0.0 ),
99 m_fTransparency( 0.0 ),
100 m_eCap( capButt ),
101 m_eJoin( joinMiter ),
102 m_fMiterLimit( 10.0 )
106 enum class Orientation { Portrait, Inherit };
108 // in case the below enum is added PDF_1_6 PDF_1_7, please add them just after PDF_1_5
109 enum class PDFVersion { PDF_1_2, PDF_1_3, PDF_1_4, PDF_1_5, PDF_1_6, PDF_A_1, PDF_A_2, PDF_A_3 };//i59651, PDF/A-1b & -1a, only -1b implemented for now
110 // for the meaning of DestAreaType please look at PDF Reference Manual
111 // version 1.4 section 8.2.1, page 475
112 enum class DestAreaType { XYZ, FitRectangle };
114 // for a definition of structural element types please refer to
115 // PDF Reference, 3rd ed. section 9.7.4
116 enum StructElement
118 // special element to place outside the structure hierarchy
119 NonStructElement,
120 // Grouping elements
121 Document, Part, Article, Section, Division, BlockQuote,
122 Caption, TOC, TOCI, Index,
124 // block level elements
125 Paragraph, Heading, H1, H2, H3, H4, H5, H6,
126 List, ListItem, LILabel, LIBody,
127 Table, TableRow, TableHeader, TableData,
129 // inline level elements
130 Span, Quote, Note, Reference, BibEntry, Code, Link,
132 // illustration elements
133 Figure, Formula, Form
136 enum StructAttribute
138 Placement, WritingMode, SpaceBefore, SpaceAfter, StartIndent, EndIndent,
139 TextIndent, TextAlign, Width, Height, BlockAlign, InlineAlign,
140 LineHeight, BaselineShift, TextDecorationType, ListNumbering,
141 RowSpan, ColSpan,
143 // link destination is an artificial attribute that sets
144 // the link annotation ID of a Link element
145 // further note: since structure attributes can only be
146 // set during content creation, but links can be
147 // created after the fact, it is possible to set
148 // an arbitrary id as structure attribute here. In this
149 // case the arbitrary id has to be passed again when the
150 // actual link annotation is created via SetLinkPropertyID
151 LinkAnnotation,
152 // Language currently sets a LanguageType (see i18nlangtag/lang.h)
153 // which will be internally changed to a corresponding locale
154 Language
157 enum StructAttributeValue
159 Invalid,
160 NONE,
161 // Placement
162 Block, Inline, Before, After, Start, End,
163 // WritingMode
164 LrTb, RlTb, TbRl,
165 // TextAlign
166 Center, Justify,
167 // Width, Height,
168 Auto,
169 // BlockAlign
170 Middle,
171 // LineHeight
172 Normal,
173 // TextDecorationType
174 Underline, Overline, LineThrough,
175 // ListNumbering
176 Disc, Circle, Square, Decimal, UpperRoman, LowerRoman, UpperAlpha, LowerAlpha
179 enum class PageTransition
181 Regular,
182 SplitHorizontalInward, SplitHorizontalOutward,
183 SplitVerticalInward, SplitVerticalOutward,
184 BlindsHorizontal, BlindsVertical,
185 BoxInward, BoxOutward,
186 WipeLeftToRight, WipeBottomToTop, WipeRightToLeft, WipeTopToBottom,
187 Dissolve
190 enum WidgetType
192 PushButton, RadioButton, CheckBox, Edit, ListBox, ComboBox, Hierarchy,
193 Signature
196 enum ErrorCode
198 // transparent object occurred and was draw opaque because
199 // PDF/A does not allow transparency
200 Warning_Transparency_Omitted_PDFA,
202 // transparent object occurred but is only supported since
203 // PDF 1.4
204 Warning_Transparency_Omitted_PDF13,
206 // a form action was exported that is not suitable for PDF/A
207 // the action was skipped
208 Warning_FormAction_Omitted_PDFA,
210 // transparent objects were converted to a bitmap in order
211 // to removetransparencies from the output
212 Warning_Transparency_Converted,
214 // signature generation failed
215 Error_Signature_Failed,
218 struct UNLESS_MERGELIBS(VCL_DLLPUBLIC) AnyWidget
220 WidgetType Type; // primitive RTTI
221 public:
222 OUString Name; // a distinct name to identify the control
223 OUString Description;// descriptive text for the control (e.g. for tool tip)
224 OUString Text; // user text to appear on the control
225 DrawTextFlags TextStyle; // style flags
226 bool ReadOnly;
227 tools::Rectangle Location; // describes the area filled by the control
228 bool Border; // true: widget should have a border, false: no border
229 Color BorderColor;// COL_TRANSPARENT and Border=true means get color from application settings
230 bool Background; // true: widget shall draw its background, false: no background
231 Color BackgroundColor; // COL_TRANSPARENT and Background=true means get color from application settings
232 vcl::Font TextFont; // an empty font will be replaced by the
233 // appropriate font from the user settings
234 Color TextColor; // COL_TRANSPARENT will be replaced by the appropriate color from application settings
235 sal_Int32 TabOrder; // lowest number is first in tab order
237 /* style flags for text are those for OutputDevice::DrawText
238 allowed values are:
239 DrawTextFlags::Left, DrawTextFlags::Center, DrawTextFlags::Right, DrawTextFlags::Top,
240 DrawTextFlags::VCenter, DrawTextFlags::Bottom,
241 DrawTextFlags::MultiLine, DrawTextFlags::WordBreak
243 if TextStyle is 0, then each control will fill in default values
246 // note: the Name member comprises the field name of the resulting
247 // PDF field names need to be globally unique. Therefore if any
248 // Widget with an already used name is created, the name will be
249 // made unique by adding an underscore ('_') and an ascending number
250 // to the name.
252 AnyWidget( WidgetType eType ) :
253 Type( eType ),
254 TextStyle( DrawTextFlags::NONE ),
255 ReadOnly( false ),
256 Border( false ),
257 BorderColor( COL_TRANSPARENT ),
258 Background( false ),
259 BackgroundColor( COL_TRANSPARENT ),
260 TextColor( COL_TRANSPARENT ),
261 TabOrder( -1 )
263 virtual ~AnyWidget();
265 WidgetType getType() const { return Type; }
267 virtual std::shared_ptr<AnyWidget> Clone() const = 0;
269 protected:
270 // note that this equals the default compiler-generated copy-ctor, but we want to have it
271 // protected, to only allow sub classes to access it
272 AnyWidget( const AnyWidget& rSource )
273 :Type( rSource.Type )
274 ,Name( rSource.Name )
275 ,Description( rSource.Description )
276 ,Text( rSource.Text )
277 ,TextStyle( rSource.TextStyle )
278 ,ReadOnly( rSource.ReadOnly )
279 ,Location( rSource.Location )
280 ,Border( rSource.Border )
281 ,BorderColor( rSource.BorderColor )
282 ,Background( rSource.Background )
283 ,BackgroundColor( rSource.BackgroundColor )
284 ,TextFont( rSource.TextFont )
285 ,TextColor( rSource.TextColor )
286 ,TabOrder( rSource.TabOrder )
289 AnyWidget& operator=( const AnyWidget& ); // never implemented
292 struct PushButtonWidget final : public AnyWidget
294 /* If Dest is set to a valid link destination,
295 Then pressing the button will act as a goto
296 action within the document.
298 Else:
299 An empty URL means this button will reset the form.
301 If URL is not empty and Submit is set, then the URL
302 contained will be set as the URL to submit the
303 form to. In this case the submit method will be
304 either GET if SubmitGet is true or POST if
305 SubmitGet is false.
307 If URL is not empty and Submit is clear, then
308 the URL contained will be interpreted as a
309 hyperlink to be executed on pushing the button.
311 There will be no error checking or any kind of
312 conversion done to the URL parameter execept this:
313 it will be output as 7bit Ascii. The URL
314 will appear literally in the PDF file produced
316 sal_Int32 Dest;
317 OUString URL;
318 bool Submit;
319 bool SubmitGet;
321 PushButtonWidget()
322 : AnyWidget( vcl::PDFWriter::PushButton ),
323 Dest( -1 ), Submit( false ), SubmitGet( false )
326 virtual std::shared_ptr<AnyWidget> Clone() const override
328 return std::make_shared<PushButtonWidget>( *this );
332 struct CheckBoxWidget final : public AnyWidget
334 bool Checked;
336 CheckBoxWidget()
337 : AnyWidget( vcl::PDFWriter::CheckBox ),
338 Checked( false )
341 virtual std::shared_ptr<AnyWidget> Clone() const override
343 return std::make_shared<CheckBoxWidget>( *this );
347 struct RadioButtonWidget final : public AnyWidget
349 bool Selected;
350 sal_Int32 RadioGroup;
351 OUString OnValue; // the value of the radio button if it is selected
353 RadioButtonWidget()
354 : AnyWidget( vcl::PDFWriter::RadioButton ),
355 Selected( false ),
356 RadioGroup( 0 )
359 virtual std::shared_ptr<AnyWidget> Clone() const override
361 return std::make_shared<RadioButtonWidget>( *this );
363 // radio buttons having the same RadioGroup id comprise one
364 // logical radio button group, that is at most one of the RadioButtons
365 // in a group can be checked at any time
367 // note: a PDF radio button field consists of a named field
368 // containing unnamed checkbox child fields. The name of the
369 // radio button field is taken from the first RadioButtonWidget created
370 // in the group
373 struct EditWidget final : public AnyWidget
375 bool MultiLine; // whether multiple lines are allowed
376 bool Password; // visible echo off
377 bool FileSelect; // field is a file selector
378 sal_Int32 MaxLen; // maximum field length in characters, 0 means unlimited
380 EditWidget()
381 : AnyWidget( vcl::PDFWriter::Edit ),
382 MultiLine( false ),
383 Password( false ),
384 FileSelect( false ),
385 MaxLen( 0 )
388 virtual std::shared_ptr<AnyWidget> Clone() const override
390 return std::make_shared<EditWidget>( *this );
394 struct ListBoxWidget final : public AnyWidget
396 bool DropDown;
397 bool MultiSelect;
398 std::vector<OUString> Entries;
399 std::vector<sal_Int32> SelectedEntries;
400 // if MultiSelect is false only the first entry of SelectedEntries
401 // will be taken into account. the same is implicit for PDF < 1.4
402 // since multiselect is a 1.4+ feature
404 ListBoxWidget()
405 : AnyWidget( vcl::PDFWriter::ListBox ),
406 DropDown( false ),
407 MultiSelect( false )
410 virtual std::shared_ptr<AnyWidget> Clone() const override
412 return std::make_shared<ListBoxWidget>( *this );
416 // note: PDF only supports dropdown comboboxes
417 struct ComboBoxWidget final : public AnyWidget
419 std::vector<OUString> Entries;
420 // set the current value in AnyWidget::Text
422 ComboBoxWidget()
423 : AnyWidget( vcl::PDFWriter::ComboBox )
426 virtual std::shared_ptr<AnyWidget> Clone() const override
428 return std::make_shared<ComboBoxWidget>( *this );
432 struct SignatureWidget final : public AnyWidget
434 SignatureWidget()
435 : AnyWidget( vcl::PDFWriter::Signature )
438 virtual std::shared_ptr<AnyWidget> Clone() const override
440 return std::make_shared<SignatureWidget>( *this );
444 enum ExportDataFormat { HTML, XML, FDF, PDF };
445 // see 3.6.1 of PDF 1.4 ref for details, used for 8.1 PDF v 1.4 ref also
446 // These emuns are treated as integer while reading/writing to configuration
447 enum PDFViewerPageMode
449 ModeDefault,
450 UseOutlines,
451 UseThumbs
453 // These emuns are treated as integer while reading/writing to configuration
454 enum PDFViewerAction
456 ActionDefault,
457 FitInWindow,
458 FitWidth,
459 FitVisible,
460 ActionZoom
462 // These enums are treated as integer while reading/writing to configuration
463 enum PDFPageLayout
465 DefaultLayout,
466 SinglePage,
467 Continuous,
468 ContinuousFacing
471 // These emuns are treated as integer while reading/writing to configuration
472 //what default action to generate in a PDF hyperlink to external document/site
473 enum PDFLinkDefaultAction
475 URIAction,
476 URIActionDestination,
477 LaunchAction
481 The following structure describes the permissions used in PDF security
483 struct PDFEncryptionProperties
486 //for both 40 and 128 bit security, see 3.5.2 PDF v 1.4 table 3.15, v 1.5 and v 1.6 table 3.20.
487 bool CanPrintTheDocument;
488 bool CanModifyTheContent;
489 bool CanCopyOrExtract;
490 bool CanAddOrModify;
491 //for revision 3 (bit 128 security) only
492 bool CanFillInteractive;
493 bool CanExtractForAccessibility;
494 bool CanAssemble;
495 bool CanPrintFull;
497 // encryption will only happen if EncryptionKey is not empty
498 // EncryptionKey is actually a construct out of OValue, UValue and DocumentIdentifier
499 // if these do not match, behavior is undefined, most likely an invalid PDF will be produced
500 // OValue, UValue, EncryptionKey and DocumentIdentifier can be computed from
501 // PDFDocInfo, Owner password and User password used the InitEncryption method which
502 // implements the algorithms described in the PDF reference chapter 3.5: Encryption
503 std::vector<sal_uInt8> OValue;
504 std::vector<sal_uInt8> UValue;
505 std::vector<sal_uInt8> EncryptionKey;
506 std::vector<sal_uInt8> DocumentIdentifier;
508 //permission default set for 128 bit, accessibility only
509 PDFEncryptionProperties() :
510 CanPrintTheDocument ( false ),
511 CanModifyTheContent ( false ),
512 CanCopyOrExtract ( false ),
513 CanAddOrModify ( false ),
514 CanFillInteractive ( false ),
515 CanExtractForAccessibility ( true ),
516 CanAssemble ( false ),
517 CanPrintFull ( false )
521 bool Encrypt() const
522 { return ! OValue.empty() && ! UValue.empty() && ! DocumentIdentifier.empty(); }
525 struct PDFDocInfo
527 OUString Title; // document title
528 OUString Author; // document author
529 OUString Subject; // subject
530 OUString Keywords; // keywords
531 OUString Creator; // application that created the original document
532 OUString Producer; // OpenOffice
535 enum ColorMode
537 DrawColor, DrawGreyscale
540 struct PDFWriterContext
542 /* must be a valid file: URL usable by osl */
543 OUString URL;
544 /* the URL of the document being exported, used for relative links*/
545 OUString BaseURL;
546 /*if relative to file system should be formed*/
547 bool RelFsys;//i56629, i49415?, i64585?
548 /*the action to set the PDF hyperlink to*/
549 PDFWriter::PDFLinkDefaultAction DefaultLinkAction;
550 //convert the .od? target file type in a link to a .pdf type
551 //this is examined before doing anything else
552 bool ConvertOOoTargetToPDFTarget;
553 //when the file type is .pdf, force the GoToR action
554 bool ForcePDFAction;
556 /* decides the PDF language level to be produced */
557 PDFVersion Version;
559 /* PDF/UA compliance */
560 bool UniversalAccessibilityCompliance;
562 /* valid for PDF >= 1.4
563 causes the MarkInfo entry in the document catalog to be set
565 bool Tagged;
566 /* determines in which format a form
567 will be submitted.
569 PDFWriter::ExportDataFormat SubmitFormat;
570 bool AllowDuplicateFieldNames;
571 /* the following data members are used to customize the PDF viewer
572 preferences
574 /* see 3.6.1 PDF v 1.4 ref*/
575 PDFWriter::PDFViewerPageMode PDFDocumentMode;
576 PDFWriter::PDFViewerAction PDFDocumentAction;
577 // in percent, valid only if PDFDocumentAction == ActionZoom
578 sal_Int32 Zoom;
580 /* see 8.6 PDF v 1.4 ref
581 specifies whether to hide the viewer tool
582 bars when the document is active.
584 bool HideViewerToolbar;
585 bool HideViewerMenubar;
586 bool HideViewerWindowControls;
587 bool FitWindow;
588 bool OpenInFullScreenMode;
589 bool CenterWindow;
590 bool DisplayPDFDocumentTitle;
591 PDFPageLayout PageLayout;
592 bool FirstPageLeft;
593 // initially visible page in viewer (starting with 0 for first page)
594 sal_Int32 InitialPage;
595 sal_Int32 OpenBookmarkLevels; // -1 means all levels
597 PDFWriter::PDFEncryptionProperties Encryption;
598 PDFWriter::PDFDocInfo DocumentInfo;
600 bool SignPDF;
601 OUString SignLocation;
602 OUString SignPassword;
603 OUString SignReason;
604 OUString SignContact;
605 css::lang::Locale DocumentLocale; // defines the document default language
606 sal_uInt32 DPIx, DPIy; // how to handle MapMode( MapUnit::MapPixel )
607 // 0 here specifies a default handling
608 PDFWriter::ColorMode ColorMode;
609 css::uno::Reference< css::security::XCertificate> SignCertificate;
610 OUString SignTSA;
611 /// Use reference XObject markup for PDF images.
612 bool UseReferenceXObject;
614 PDFWriterContext() :
615 RelFsys( false ), //i56629, i49415?, i64585?
616 DefaultLinkAction( PDFWriter::URIAction ),
617 ConvertOOoTargetToPDFTarget( false ),
618 ForcePDFAction( false ),
619 Version( PDFWriter::PDFVersion::PDF_1_6 ),
620 UniversalAccessibilityCompliance( false ),
621 Tagged( false ),
622 SubmitFormat( PDFWriter::FDF ),
623 AllowDuplicateFieldNames( false ),
624 PDFDocumentMode( PDFWriter::ModeDefault ),
625 PDFDocumentAction( PDFWriter::ActionDefault ),
626 Zoom( 100 ),
627 HideViewerToolbar( false ),
628 HideViewerMenubar( false ),
629 HideViewerWindowControls( false ),
630 FitWindow( false ),
631 OpenInFullScreenMode( false ),
632 CenterWindow( false ),
633 DisplayPDFDocumentTitle( true ),
634 PageLayout( PDFWriter::DefaultLayout ),
635 FirstPageLeft( false ),
636 InitialPage( 1 ),
637 OpenBookmarkLevels( -1 ),
638 Encryption(),
639 SignPDF( false ),
640 DPIx( 0 ),
641 DPIy( 0 ),
642 ColorMode( PDFWriter::DrawColor ),
643 UseReferenceXObject( false )
647 PDFWriter( const PDFWriterContext& rContext, const css::uno::Reference< css::beans::XMaterialHolder >& );
648 ~PDFWriter();
650 /** Returns an OutputDevice for formatting
651 This Output device is guaranteed to use the same
652 font metrics as the resulting PDF file.
654 @returns
655 the reference output device
657 OutputDevice* GetReferenceDevice();
659 /** Creates a new page to fill
660 If width and height are not set the page size
661 is inherited from the page tree
662 other effects:
663 resets the graphics state: MapMode, Font
664 Colors and other state information MUST
665 be set again or are undefined.
667 void NewPage( double nPageWidth, double nPageHeight, Orientation eOrientation = Orientation::Inherit );
668 /** Play a metafile like an outputdevice would do
670 struct PlayMetafileContext
672 int m_nMaxImageResolution;
673 bool m_bOnlyLosslessCompression;
674 int m_nJPEGQuality;
675 bool m_bTransparenciesWereRemoved;
677 PlayMetafileContext()
678 : m_nMaxImageResolution( 0 )
679 , m_bOnlyLosslessCompression( false )
680 , m_nJPEGQuality( 90 )
681 , m_bTransparenciesWereRemoved( false )
685 void PlayMetafile( const GDIMetaFile&, const PlayMetafileContext&, vcl::PDFExtOutDevData* pDevDat = nullptr );
687 /* sets the document locale originally passed with the context to a new value
688 * only affects the output if used before calling Emit.
690 void SetDocumentLocale( const css::lang::Locale& rDocLocale );
692 /* finishes the file */
693 bool Emit();
696 * Get a list of errors that occurred during processing
697 * this should enable the producer to give feedback about
698 * any anomalies that might have occurred
700 std::set< ErrorCode > const & GetErrors() const;
702 // uses 128bit encryption
703 static css::uno::Reference< css::beans::XMaterialHolder >
704 InitEncryption( const OUString& i_rOwnerPassword,
705 const OUString& i_rUserPassword
708 /* functions for graphics state */
709 /* flag values: see vcl/outdev.hxx */
710 void Push( PushFlags nFlags = PushFlags::ALL );
711 void Pop();
713 void SetClipRegion();
714 void SetClipRegion( const basegfx::B2DPolyPolygon& rRegion );
715 void MoveClipRegion( tools::Long nHorzMove, tools::Long nVertMove );
716 void IntersectClipRegion( const tools::Rectangle& rRect );
717 void IntersectClipRegion( const basegfx::B2DPolyPolygon& rRegion );
719 void SetLayoutMode( ComplexTextLayoutFlags nMode );
720 void SetDigitLanguage( LanguageType eLang );
722 void SetLineColor( const Color& rColor );
723 void SetLineColor() { SetLineColor( COL_TRANSPARENT ); }
725 void SetFillColor( const Color& rColor );
726 void SetFillColor() { SetFillColor( COL_TRANSPARENT ); }
728 void SetFont( const vcl::Font& rNewFont );
729 void SetTextColor( const Color& rColor );
730 void SetTextFillColor();
731 void SetTextFillColor( const Color& rColor );
733 void SetTextLineColor();
734 void SetTextLineColor( const Color& rColor );
735 void SetOverlineColor();
736 void SetOverlineColor( const Color& rColor );
737 void SetTextAlign( ::TextAlign eAlign );
739 void SetMapMode( const MapMode& rNewMapMode );
742 /* actual drawing functions */
743 void DrawText( const Point& rPos, const OUString& rText );
745 void DrawTextLine( const Point& rPos, tools::Long nWidth,
746 FontStrikeout eStrikeout,
747 FontLineStyle eUnderline,
748 FontLineStyle eOverline );
749 void DrawTextArray( const Point& rStartPt, const OUString& rStr,
750 const tools::Long* pDXAry,
751 sal_Int32 nIndex,
752 sal_Int32 nLen );
753 void DrawStretchText( const Point& rStartPt, sal_uLong nWidth,
754 const OUString& rStr,
755 sal_Int32 nIndex, sal_Int32 nLen );
756 void DrawText( const tools::Rectangle& rRect,
757 const OUString& rStr, DrawTextFlags nStyle );
759 void DrawPixel( const Point& rPt, const Color& rColor );
760 void DrawPixel( const Point& rPt )
761 { DrawPixel( rPt, COL_TRANSPARENT ); }
763 void DrawLine( const Point& rStartPt, const Point& rEndPt );
764 void DrawLine( const Point& rStartPt, const Point& rEndPt,
765 const LineInfo& rLineInfo );
766 void DrawPolyLine( const tools::Polygon& rPoly );
767 void DrawPolyLine( const tools::Polygon& rPoly,
768 const LineInfo& rLineInfo );
769 void DrawPolyLine( const tools::Polygon& rPoly, const ExtLineInfo& rInfo );
770 void DrawPolygon( const tools::Polygon& rPoly );
771 void DrawPolyPolygon( const tools::PolyPolygon& rPolyPoly );
772 void DrawRect( const tools::Rectangle& rRect );
773 void DrawRect( const tools::Rectangle& rRect,
774 sal_uLong nHorzRount, sal_uLong nVertRound );
775 void DrawEllipse( const tools::Rectangle& rRect );
776 void DrawArc( const tools::Rectangle& rRect,
777 const Point& rStartPt, const Point& rEndPt );
778 void DrawPie( const tools::Rectangle& rRect,
779 const Point& rStartPt, const Point& rEndPt );
780 void DrawChord( const tools::Rectangle& rRect,
781 const Point& rStartPt, const Point& rEndPt );
783 void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
784 const Bitmap& rBitmap, const Graphic& rGraphic );
786 void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
787 const BitmapEx& rBitmapEx );
789 void DrawGradient( const tools::Rectangle& rRect, const Gradient& rGradient );
790 void DrawGradient( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient );
792 void DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch );
794 void DrawWallpaper( const tools::Rectangle& rRect, const Wallpaper& rWallpaper );
795 void DrawTransparent( const tools::PolyPolygon& rPolyPoly,
796 sal_uInt16 nTransparencePercent );
798 /** Start a transparency group
800 Drawing operations can be grouped together to acquire a common transparency
801 behaviour; after calling BeginTransparencyGroup all drawing
802 operations will be grouped together into a transparent object.
804 The transparency behaviour is set with one of the EndTransparencyGroup
805 calls and can be either a constant transparency factor or a transparent
806 soft mask in form of an 8 bit gray scale bitmap.
808 It is permissible to nest transparency group.
810 Transparency groups MUST NOT span multiple pages
812 Transparency is a feature introduced in PDF1.4, so transparency group
813 will be ignored if the produced PDF has a lower version. The drawing
814 operations will be emitted normally.
816 void BeginTransparencyGroup();
818 /** End a transparency group with constant transparency factor
820 This ends a transparency group and inserts it on the current page. The
821 coordinates of the group result out of the grouped drawing operations.
823 @param rBoundRect
824 The bounding rectangle of the group
826 @param nTransparencePercent
827 The transparency factor
829 void EndTransparencyGroup( const tools::Rectangle& rBoundRect, sal_uInt16 nTransparencePercent );
831 /** Insert a JPG encoded image (optionally with mask)
833 @param rJPGData
834 a Stream containing the encoded image
836 @param bIsTrueColor
837 true: jpeg is 24 bit true color, false: jpeg is 8 bit greyscale
839 @param rSrcSizePixel
840 size in pixel of the image
842 @param rTargetArea
843 where to put the image
845 @param rMask
846 optional mask; if not empty it must have
847 the same pixel size as the image and
848 be either 1 bit black&white or 8 bit grey
850 void DrawJPGBitmap( SvStream& rJPGData, bool bIsTrueColor, const Size& rSrcSizePixel, const tools::Rectangle& rTargetArea, const Bitmap& rMask, const Graphic& rGraphic );
852 /** Create a new named destination to be used in a link from another PDF document
854 @param sDestName
855 the name (label) of the bookmark, to be used to jump to
857 @param rRect
858 target rectangle on page to be displayed if dest is jumped to
860 @param nPageNr
861 number of page the dest is on (as returned by NewPage)
862 or -1 in which case the current page is used
864 @param eType
865 what dest type to use
867 @returns
868 the destination id (to be used in SetLinkDest) or
869 -1 if page id does not exist
871 sal_Int32 CreateNamedDest( const OUString& sDestName, const tools::Rectangle& rRect, sal_Int32 nPageNr, DestAreaType eType );
872 /** Create a new destination to be used in a link
874 @param rRect
875 target rectangle on page to be displayed if dest is jumped to
877 @param nPageNr
878 number of page the dest is on (as returned by NewPage)
879 or -1 in which case the current page is used
881 @param eType
882 what dest type to use
884 @returns
885 the destination id (to be used in SetLinkDest) or
886 -1 if page id does not exist
888 sal_Int32 CreateDest( const tools::Rectangle& rRect, sal_Int32 nPageNr, DestAreaType eType );
889 /** Create a new link on a page
891 @param rRect
892 active rectangle of the link (that is the area that has to be
893 hit to activate the link)
895 @param nPageNr
896 number of page the link is on (as returned by NewPage)
897 or -1 in which case the current page is used
899 @returns
900 the link id (to be used in SetLinkDest, SetLinkURL) or
901 -1 if page id does not exist
903 sal_Int32 CreateLink( const tools::Rectangle& rRect, sal_Int32 nPageNr );
905 /// Creates a screen annotation.
906 sal_Int32 CreateScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr);
908 /** creates a destination which is not intended to be referred to by a link, but by a public destination Id.
910 Form widgets, for instance, might refer to a destination, without ever actually creating a source link to
911 point to this destination. In such cases, a public destination Id will be assigned to the form widget,
912 and later on, the concrete destination data for this public Id will be registered using RegisterDestReference.
914 @param nDestId
915 destination ID
917 @param rRect
918 target rectangle on page to be displayed if dest is jumped to
920 @param nPageNr
921 number of page the dest is on (as returned by NewPage)
922 or -1 in which case the current page is used
924 @param eType
925 what dest type to use
927 @returns
928 the internal destination Id.
930 sal_Int32 RegisterDestReference( sal_Int32 nDestId, const tools::Rectangle& rRect, sal_Int32 nPageNr, DestAreaType eType );
933 /** Set the destination for a link
934 will change a URL type link to a dest link if necessary
936 @param nLinkId
937 the link to be changed
939 @param nDestId
940 the dest the link shall point to
942 void SetLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId );
943 /** Set the URL for a link
944 will change a dest type link to a URL type link if necessary
945 @param nLinkId
946 the link to be changed
948 @param rURL
949 the URL the link shall point to.
950 The URL will be parsed (and corrected) by the com.sun.star.util.URLTransformer
951 service; the result will then appear literally in the PDF file produced
953 void SetLinkURL( sal_Int32 nLinkId, const OUString& rURL );
955 /// Sets the URL of a linked screen annotation.
956 void SetScreenURL(sal_Int32 nScreenId, const OUString& rURL);
957 /// Sets the URL of an embedded screen annotation.
958 void SetScreenStream(sal_Int32 nScreenId, const OUString& rURL);
960 /** Resolve link in logical structure
962 If a link is created after the corresponding visual appearance was drawn
963 it is not possible to set the link id as a property attribute to the
964 link structure item that should be created in tagged PDF around the
965 visual appearance of a link.
967 For this reason an arbitrary id can be given to
968 SetStructureAttributeNumerical at the time the text for
969 the link is drawn. To resolve this arbitrary id again when the actual
970 link annotation is created use SetLinkPropertyID. When Emit
971 finally gets called all LinkAnnotation type structure attributes
972 will be replaced with the correct link id.
974 CAUTION: this technique must be used either for all or none of the links
975 in a document since the link id space and arbitrary property id space
976 could overlap and it would be impossible to resolve whether a Link
977 structure attribute value was arbitrary or already a real id.
979 @param nLinkId
980 the link to be mapped
982 @param nPropertyID
983 the arbitrary id set in a Link structure element to address
984 the link with real id nLinkId
986 void SetLinkPropertyID( sal_Int32 nLinkId, sal_Int32 nPropertyID );
987 /** Create a new outline item
989 @param nParent
990 declares the parent of the new item in the outline hierarchy.
991 An invalid value will result in a new toplevel item.
993 @param rText
994 sets the title text of the item
996 @param nDestID
997 declares which Dest (created with CreateDest) the outline item
998 will point to
1000 @returns
1001 the outline item id of the new item
1003 sal_Int32 CreateOutlineItem( sal_Int32 nParent, const OUString& rText, sal_Int32 nDestID );
1005 /** Create a new note on a page
1007 @param rRect
1008 active rectangle of the note (that is the area that has to be
1009 hit to popup the annotation)
1011 @param rNote
1012 specifies the contents of the note
1014 @param nPageNr
1015 number of page the note is on (as returned by NewPage)
1016 or -1 in which case the current page is used
1018 void CreateNote( const tools::Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr );
1020 /** begin a new logical structure element
1022 BeginStructureElement/EndStructureElement calls build the logical structure
1023 of the PDF - the basis for tagged PDF. Structural elements are implemented
1024 using marked content tags. Each structural element can contain sub elements
1025 (e.g. a section can contain a heading and a paragraph). The structure hierarchy
1026 is build automatically from the Begin/EndStructureElement calls.
1028 A structural element need not be contained on one page; e.g. paragraphs often
1029 run from one page to the next. In this case the corresponding EndStructureElement
1030 must be called while drawing the next page.
1032 BeginStructureElement and EndStructureElement must be called only after
1033 PDFWriter::NewPage has been called and before PDFWriter::Emit gets called. The
1034 current page number is an implicit context parameter for Begin/EndStructureElement.
1036 For pagination artifacts that are not part of the logical structure
1037 of the document (like header, footer or page number) the special
1038 StructElement NonStructElement exists. To place content
1039 outside of the structure tree simply call
1040 BeginStructureElement( NonStructElement ) then draw your
1041 content and then call EndStructureElement(). All children
1042 of a NonStructElement will not be part of the structure.
1043 Nonetheless if you add a child structural element to a
1044 NonStructElement you will still have to call
1045 EndStructureElement for it. Best think of the structure
1046 tree as a stack.
1048 Note: there is always one structural element in existence without having
1049 called BeginStructureElement; this is the root of the structure
1050 tree (called StructTreeRoot). The StructTreeRoot has always the id 0.
1052 @param eType
1053 denotes what kind of element to begin (e.g. a heading or paragraph)
1055 @param rAlias
1056 the specified alias will be used as structure tag. Also an entry in the PDF's
1057 role map will be created mapping alias to regular structure type.
1059 @returns
1060 the new structure element's id for use in SetCurrentStructureElement
1062 sal_Int32 BeginStructureElement( enum StructElement eType, const OUString& rAlias );
1063 /** end the current logical structure element
1065 Close the current structure element. The current element's
1066 parent becomes the current structure element again.
1068 @see BeginStructureElement
1070 void EndStructureElement();
1071 /** set the current structure element
1073 For different purposes it may be useful to paint a structure element's
1074 content discontinuously. In that case an already existing structure element
1075 can be appended to by using SetCurrentStructureElement. The
1076 referenced structure element becomes the current structure element with
1077 all consequences: all following structure elements are appended as children
1078 of the current element.
1080 @param nElement
1081 the id of the new current structure element
1083 void SetCurrentStructureElement( sal_Int32 nElement );
1085 /** set a structure attribute on the current structural element
1087 SetStructureAttribute sets an attribute of the current structural element to a
1088 new value. A consistency check is performed before actually setting the value;
1089 if the check fails, the function returns False and the attribute remains
1090 unchanged.
1092 @param eAttr
1093 denotes what attribute to change
1095 @param eVal
1096 the value to set the attribute to
1098 void SetStructureAttribute( enum StructAttribute eAttr, enum StructAttributeValue eVal );
1099 /** set a structure attribute on the current structural element
1101 SetStructureAttributeNumerical sets an attribute of the current structural element
1102 to a new numerical value. A consistency check is performed before actually setting
1103 the value; if the check fails, the function returns False and the attribute
1104 remains unchanged.
1106 @param eAttr
1107 denotes what attribute to change
1109 @param nValue
1110 the value to set the attribute to
1112 void SetStructureAttributeNumerical( enum StructAttribute eAttr, sal_Int32 nValue );
1113 /** set the bounding box of a structural element
1115 SetStructureBoundingBox sets the BBox attribute to a new value. Since the BBox
1116 attribute can only be applied to Table, Figure,
1117 Form and Formula elements, a call of this function
1118 for other element types will be ignored and the BBox attribute not be set.
1120 @param rRect
1121 the new bounding box for the structural element
1123 void SetStructureBoundingBox( const tools::Rectangle& rRect );
1125 /** set the ActualText attribute of a structural element
1127 ActualText contains the Unicode text without layout artifacts that is shown by
1128 a structural element. For example if a line is ended prematurely with a break in
1129 a word and continued on the next line (e.g. "happen-<newline>stance") the
1130 corresponding ActualText would contain the unbroken line (e.g. "happenstance").
1132 @param rText
1133 contains the complete logical text the structural element displays.
1135 void SetActualText( const OUString& rText );
1137 /** set the Alt attribute of a strutural element
1139 Alt is s replacement text describing the contents of a structural element. This
1140 is mainly used by accessibility applications; e.g. a screen reader would read
1141 the Alt replacement text for an image to a visually impaired user.
1143 @param rText
1144 contains the replacement text for the structural element
1146 void SetAlternateText( const OUString& rText );
1148 /** Sets the transitional effect to be applied when the current page gets shown.
1150 @param eType
1151 the kind of effect to be used; use Regular to disable transitional effects
1152 for this page
1154 @param nMilliSec
1155 the duration of the transitional effect in milliseconds;
1156 set 0 to disable transitional effects
1158 @param nPageNr
1159 the page number to apply the effect to; -1 denotes the current page
1161 void SetPageTransition( PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr );
1163 /** create a new form control
1165 This function creates a new form control in the PDF and sets its various
1166 properties. Do not pass an actual AnyWidget as rControlType
1167 will be cast to the type described by the type member.
1169 @param rControlType
1170 a descendant of AnyWidget determining the control's properties
1172 @returns
1173 the new control's id for reference purposes
1175 sal_Int32 CreateControl( const AnyWidget& rControlType );
1177 /** Inserts an additional stream to the PDF file
1179 This function adds an arbitrary stream to the produced PDF file. May be called
1180 any time before Emit(). The stream will be written during
1181 Emit by calling the PDFOutputStream Object's write
1182 method. After the call the PDFOutputStream will be deleted.
1184 All additional streams and their mimetypes will be entered into an array
1185 in the trailer dictionary.
1187 @param rMimeType
1188 the mimetype of the stream
1190 @param pStream
1191 the interface to the additional stream
1194 void AddStream( const OUString& rMimeType, PDFOutputStream* pStream );
1196 /// Write rString as a PDF hex string into rBuffer.
1197 static void AppendUnicodeTextString(const OUString& rString, OStringBuffer& rBuffer);
1199 /// Get current date/time in PDF D:YYYYMMDDHHMMSS form.
1200 static OString GetDateTime();
1205 #endif // INCLUDED_VCL_PDFWRITER_HXX
1207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */