Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/pdfwriter.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
#ifndef INCLUDED_VCL_PDFWRITER_HXX
20
#define INCLUDED_VCL_PDFWRITER_HXX
21
22
#include <sal/types.h>
23
24
#include <tools/gen.hxx>
25
#include <tools/color.hxx>
26
27
#include <vcl/dllapi.h>
28
#include <vcl/font.hxx>
29
#include <vcl/kernarray.hxx>
30
#include <vcl/rendercontext/DrawTextFlags.hxx>
31
#include <vcl/rendercontext/State.hxx>
32
#include <vcl/vclptr.hxx>
33
34
#include <com/sun/star/lang/Locale.hpp>
35
#include <com/sun/star/util/DateTime.hpp>
36
#include <com/sun/star/uno/Sequence.hxx>
37
38
#include <memory>
39
#include <vector>
40
#include <set>
41
#include <span>
42
43
namespace com::sun::star::beans { class XMaterialHolder; }
44
namespace com::sun::star::io { class XOutputStream; }
45
namespace com::sun::star::security { class XCertificate; }
46
47
class AlphaMask;
48
class GDIMetaFile;
49
class Graphic;
50
class MapMode;
51
class LineInfo;
52
namespace tools {
53
    class Polygon;
54
    class PolyPolygon;
55
}
56
namespace svl::crypto
57
{
58
class SigningContext;
59
}
60
class Bitmap;
61
class Gradient;
62
class Hatch;
63
class Wallpaper;
64
65
namespace vcl
66
{
67
68
class PDFExtOutDevData;
69
class PDFWriterImpl;
70
71
namespace pdf { struct PDFNote; }
72
73
class VCL_DLLPUBLIC PDFOutputStream
74
{
75
    public:
76
    virtual ~PDFOutputStream();
77
    virtual void write( const css::uno::Reference< css::io::XOutputStream >& xStream ) = 0;
78
};
79
80
/** Parameters that are needed when encrypting */
81
struct EncryptionParams
82
{
83
    bool mbCanEncrypt = false;
84
    std::vector<sal_uInt8> maKey;
85
};
86
87
/* The following structure describes the permissions used in PDF security */
88
struct PDFEncryptionProperties
89
{
90
    //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.
91
    bool CanPrintTheDocument = false;
92
    bool CanModifyTheContent = false;
93
    bool CanCopyOrExtract = false;
94
    bool CanAddOrModify = false;
95
96
    //for revision 3 (bit 128 security) only
97
    bool CanFillInteractive = false;
98
    bool CanExtractForAccessibility = true;
99
    bool CanAssemble = false;
100
    bool CanPrintFull = false;
101
102
    // encryption will only happen if EncryptionKey is not empty
103
    // EncryptionKey is actually a construct out of OValue, UValue and DocumentIdentifier
104
    // if these do not match, behavior is undefined, most likely an invalid PDF will be produced
105
    // OValue, UValue, EncryptionKey and DocumentIdentifier can be computed from
106
    // PDFDocInfo, Owner password and User password used the InitEncryption method which
107
    // implements the algorithms described in the PDF reference chapter 3.5: Encryption
108
    std::vector<sal_uInt8> OValue;
109
    std::vector<sal_uInt8> OE; // needed by R6 algorithm
110
111
    std::vector<sal_uInt8> UValue;
112
    std::vector<sal_uInt8> UE; // needed by R6 algorithm
113
114
    std::vector<sal_uInt8> EncryptionKey;
115
    std::vector<sal_uInt8> DocumentIdentifier;
116
117
    std::optional<EncryptionParams> moParameters;
118
119
    bool canEncrypt() const
120
91.2k
    {
121
91.2k
        return !OValue.empty() && !UValue.empty() && !DocumentIdentifier.empty();
122
91.2k
    }
123
124
    void clear()
125
0
    {
126
0
        OValue.clear();
127
0
        OE.clear();
128
0
        UValue.clear();
129
0
        UE.clear();
130
0
        EncryptionKey.clear();
131
0
    }
132
133
    sal_Int32 getAccessPermissions() const
134
0
    {
135
0
        sal_Int32 nAccessPermissions = 0xfffff0c0;
136
137
0
        nAccessPermissions |= CanPrintTheDocument ? 1 << 2 : 0;
138
0
        nAccessPermissions |= CanModifyTheContent ? 1 << 3 : 0;
139
0
        nAccessPermissions |= CanCopyOrExtract ? 1 << 4 : 0;
140
0
        nAccessPermissions |= CanAddOrModify ? 1 << 5 : 0;
141
0
        nAccessPermissions |= CanFillInteractive ? 1 << 8 : 0;
142
0
        nAccessPermissions |= CanExtractForAccessibility ? 1 << 9 : 0;
143
0
        nAccessPermissions |= CanAssemble ? 1 << 10 : 0;
144
0
        nAccessPermissions |= CanPrintFull ? 1 << 11 : 0;
145
146
0
        return nAccessPermissions;
147
0
    }
148
149
    EncryptionParams const& getParams()
150
11.4k
    {
151
11.4k
        if (!moParameters)
152
4.14k
        {
153
4.14k
            moParameters = EncryptionParams{ canEncrypt(), EncryptionKey };
154
4.14k
        }
155
11.4k
        return *moParameters;
156
11.4k
    }
157
};
158
159
namespace pdf
160
{
161
// For a definition of structural element types please refer to
162
// PDF Reference, 3rd ed. section 9.7.4.
163
//
164
// In PDF 2.0 specification (ISO 32000-2) refer to section 14.8.4
165
enum class StructElement
166
{
167
    // Special element to place outside the structure hierarchy
168
    NonStructElement,
169
170
    // Grouping elements
171
    Document, Part, Article, Section, Division, BlockQuote,
172
    Caption, TOC, TOCI, Index,
173
174
    // Block level elements
175
    Paragraph, Heading, H1, H2, H3, H4, H5, H6,
176
    List, ListItem, LILabel, LIBody,
177
    Table, TableRow, TableHeader, TableData,
178
    Title, // PDF 2.0
179
180
    // Inline level elements
181
    Span, Quote, Note, Reference, BibEntry, Code, Link, Annot,
182
    Ruby, RB, RT, RP, Warichu, WT, WP,
183
    Emphasis, Strong, // PDF 2.0
184
185
    // Illustration elements
186
    Figure, Formula, Form
187
};
188
189
class PDFWriter
190
{
191
    ScopedVclPtr<PDFWriterImpl> xImplementation;
192
193
    PDFWriter(const PDFWriter&) = delete;
194
    PDFWriter& operator=(const PDFWriter&) = delete;
195
196
public:
197
    // extended line info
198
    enum CapType { capButt, capRound, capSquare };
199
    enum JoinType { joinMiter, joinRound, joinBevel };
200
    struct ExtLineInfo
201
    {
202
        double                      m_fLineWidth;
203
        double                      m_fTransparency;
204
        CapType                     m_eCap;
205
        JoinType                    m_eJoin;
206
        double                      m_fMiterLimit;
207
        std::vector< double >       m_aDashArray;
208
209
11.7k
        ExtLineInfo() : m_fLineWidth( 0.0 ),
210
11.7k
                        m_fTransparency( 0.0 ),
211
11.7k
                        m_eCap( capButt ),
212
11.7k
                        m_eJoin( joinMiter ),
213
11.7k
                        m_fMiterLimit( 10.0 )
214
11.7k
        {}
215
    };
216
217
    enum class Orientation { Portrait, Inherit };
218
219
220
    enum class PDFVersion
221
    {
222
        PDF_1_4,
223
        PDF_1_5,
224
        PDF_1_6,
225
        PDF_1_7,
226
        PDF_2_0,
227
        PDF_A_1, // PDF/A-1b - Based on PDF 1.4. PDF/A-1a is not implemented.
228
        PDF_A_2, // Based on PDF 1.7
229
        PDF_A_3, // Based on PDF 1.7 + allows embedded
230
        PDF_A_4, // Based on PDF 2.0
231
        Default = PDF_1_7
232
    };
233
234
    // for the meaning of DestAreaType please look at PDF Reference Manual
235
    // version 1.4 section 8.2.1, page 475
236
    enum class DestAreaType { XYZ, FitRectangle };
237
238
    enum StructAttribute
239
    {
240
        // Artifacts
241
        Type, Subtype,
242
243
        Placement, WritingMode, SpaceBefore, SpaceAfter, StartIndent, EndIndent,
244
        TextIndent, TextAlign, Width, Height, BlockAlign, InlineAlign,
245
        LineHeight, BaselineShift, TextDecorationType, ListNumbering,
246
        RowSpan, ColSpan, Scope, Role,
247
        RubyAlign, RubyPosition,
248
249
        // link destination is an artificial attribute that sets
250
        // the link annotation ID of a Link element
251
        // further note: since structure attributes can only be
252
        // set during content creation, but links can be
253
        // created after the fact, it is possible to set
254
        // an arbitrary id as structure attribute here. In this
255
        // case the arbitrary id has to be passed again when the
256
        // actual link annotation is created via SetLinkPropertyID
257
        LinkAnnotation,
258
        // note destination is an artificial attribute that sets
259
        // the note annotation ID of a Note element
260
        NoteAnnotation,
261
        // Language currently sets a LanguageType (see i18nlangtag/lang.h)
262
        // which will be internally changed to a corresponding locale
263
        Language
264
    };
265
266
    enum StructAttributeValue
267
    {
268
        Invalid,
269
        NONE,
270
        // Artifacts
271
        Pagination, Layout, Page, Background,
272
        Header, Footer, Watermark,
273
        // Placement
274
        Block, Inline, Before, After, Start, End,
275
        // WritingMode
276
        LrTb, RlTb, TbRl,
277
        // TextAlign
278
        Center, Justify,
279
        // Width, Height,
280
        Auto,
281
        // BlockAlign
282
        Middle,
283
        // LineHeight
284
        Normal,
285
        // TextDecorationType
286
        Underline, Overline, LineThrough,
287
        // Scope
288
        Row, Column, Both,
289
        // Role
290
        Rb, Cb, Pb, Tv,
291
        // RubyAlign
292
        RStart, RCenter, REnd, RJustify, RDistribute,
293
        // RubyPosition
294
        RBefore, RAfter, RWarichu, RInline,
295
        // ListNumbering
296
        Disc, Circle, Square, Decimal, UpperRoman, LowerRoman, UpperAlpha, LowerAlpha
297
    };
298
299
    enum class PageTransition
300
    {
301
        Regular,
302
        SplitHorizontalInward, SplitHorizontalOutward,
303
        SplitVerticalInward, SplitVerticalOutward,
304
        BlindsHorizontal, BlindsVertical,
305
        BoxInward, BoxOutward,
306
        WipeLeftToRight, WipeBottomToTop, WipeRightToLeft, WipeTopToBottom,
307
        Dissolve
308
    };
309
310
    enum WidgetType
311
    {
312
        PushButton, RadioButton, CheckBox, Edit, ListBox, ComboBox, Hierarchy,
313
        Signature
314
    };
315
316
    enum FormatType
317
    {
318
        Text, Number, Time, Date
319
    };
320
321
    enum ErrorCode
322
    {
323
        // transparent object occurred and was draw opaque because
324
        // PDF/A does not allow transparency
325
        Warning_Transparency_Omitted_PDFA,
326
327
        // transparent object occurred but is only supported since
328
        // PDF 1.4
329
        Warning_Transparency_Omitted_PDF13,
330
331
        // a form action was exported that is not suitable for PDF/A
332
        // the action was skipped
333
        Warning_FormAction_Omitted_PDFA,
334
335
        // transparent objects were converted to a bitmap in order
336
        // to removetransparencies from the output
337
        Warning_Transparency_Converted,
338
339
        // signature generation failed
340
        Error_Signature_Failed,
341
    };
342
343
    struct VCL_DLLPUBLIC AnyWidget
344
    {
345
        WidgetType          Type;       // primitive RTTI
346
    public:
347
        OUString            Name;       // a distinct name to identify the control
348
        OUString            Description;// descriptive text for the control (e.g. for tool tip)
349
        OUString            Text;       // user text to appear on the control
350
        DrawTextFlags       TextStyle;  // style flags
351
        bool                ReadOnly;
352
        tools::Rectangle           Location;   // describes the area filled by the control
353
        bool                Border;     // true: widget should have a border, false: no border
354
        Color               BorderColor;// COL_TRANSPARENT and Border=true means get color from application settings
355
        bool                Background; // true: widget shall draw its background, false: no background
356
        Color               BackgroundColor; // COL_TRANSPARENT and Background=true means get color from application settings
357
        vcl::Font           TextFont;   // an empty font will be replaced by the
358
                                        // appropriate font from the user settings
359
        Color               TextColor;  // COL_TRANSPARENT will be replaced by the appropriate color from application settings
360
        sal_Int32           TabOrder; // lowest number is first in tab order
361
362
        /* style flags for text are those for OutputDevice::DrawText
363
           allowed values are:
364
           DrawTextFlags::Left, DrawTextFlags::Center, DrawTextFlags::Right, DrawTextFlags::Top,
365
           DrawTextFlags::VCenter, DrawTextFlags::Bottom,
366
           DrawTextFlags::MultiLine, DrawTextFlags::WordBreak
367
368
           if TextStyle is 0, then each control will fill in default values
369
         */
370
371
         // note: the Name member comprises the field name of the resulting
372
         // PDF field names need to be globally unique. Therefore if any
373
         // Widget with an already used name is created, the name will be
374
         // made unique by adding an underscore ('_') and an ascending number
375
         // to the name.
376
377
        AnyWidget( WidgetType eType ) :
378
0
                Type( eType ),
379
0
                TextStyle( DrawTextFlags::NONE ),
380
0
                ReadOnly( false ),
381
0
                Border( false ),
382
0
                BorderColor( COL_TRANSPARENT ),
383
0
                Background( false ),
384
0
                BackgroundColor( COL_TRANSPARENT ),
385
0
                TextColor( COL_TRANSPARENT ),
386
0
                TabOrder( -1 )
387
0
        {}
388
        virtual ~AnyWidget();
389
390
0
        WidgetType getType() const { return Type; }
391
392
        virtual std::shared_ptr<AnyWidget> Clone() const = 0;
393
394
    protected:
395
        // note that this equals the default compiler-generated copy-ctor, but we want to have it
396
        // protected, to only allow sub classes to access it
397
        AnyWidget( const AnyWidget& rSource )
398
0
            :Type( rSource.Type )
399
0
            ,Name( rSource.Name )
400
0
            ,Description( rSource.Description )
401
0
            ,Text( rSource.Text )
402
0
            ,TextStyle( rSource.TextStyle )
403
0
            ,ReadOnly( rSource.ReadOnly )
404
0
            ,Location( rSource.Location )
405
0
            ,Border( rSource.Border )
406
0
            ,BorderColor( rSource.BorderColor )
407
0
            ,Background( rSource.Background )
408
0
            ,BackgroundColor( rSource.BackgroundColor )
409
0
            ,TextFont( rSource.TextFont )
410
0
            ,TextColor( rSource.TextColor )
411
0
            ,TabOrder( rSource.TabOrder )
412
0
        {
413
0
        }
414
        AnyWidget& operator=( const AnyWidget& ) = delete;  // never implemented
415
    };
416
417
    struct PushButtonWidget final : public AnyWidget
418
    {
419
        /* If Dest is set to a valid link destination,
420
           Then pressing the button will act as a goto
421
           action within the document.
422
423
           Else:
424
           An empty URL means this button will reset the form.
425
426
           If URL is not empty and Submit is set, then the URL
427
           contained will be set as the URL to submit the
428
           form to. In this case the submit method will be
429
           either GET if SubmitGet is true or POST if
430
           SubmitGet is false.
431
432
           If URL is not empty and Submit is clear, then
433
           the URL contained will be interpreted as a
434
           hyperlink to be executed on pushing the button.
435
436
           There will be no error checking or any kind of
437
           conversion done to the URL parameter except this:
438
           it will be output as 7bit Ascii. The URL
439
           will appear literally in the PDF file produced
440
        */
441
        sal_Int32           Dest;
442
        OUString       URL;
443
        bool                Submit;
444
        bool                SubmitGet;
445
446
        PushButtonWidget()
447
                : AnyWidget( PDFWriter::PushButton ),
448
                  Dest( -1 ), Submit( false ), SubmitGet( false )
449
0
        {}
450
451
        virtual std::shared_ptr<AnyWidget> Clone() const override
452
0
        {
453
0
            return std::make_shared<PushButtonWidget>( *this );
454
0
        }
455
    };
456
457
    struct VCL_DLLPUBLIC CheckBoxWidget final : public AnyWidget
458
    {
459
        bool                Checked;
460
        OUString            OnValue; // the value of the checkbox if it is selected
461
        OUString            OffValue; // the value of the checkbox if it is not selected
462
463
        CheckBoxWidget()
464
                : AnyWidget( PDFWriter::CheckBox ),
465
                  Checked( false )
466
0
        {}
467
468
        virtual std::shared_ptr<AnyWidget> Clone() const override
469
0
        {
470
0
            return std::make_shared<CheckBoxWidget>( *this );
471
0
        }
472
    };
473
474
    struct RadioButtonWidget final : public AnyWidget
475
    {
476
        bool                Selected;
477
        sal_Int32           RadioGroup;
478
        OUString       OnValue; // the value of the radio button if it is selected
479
        OUString       OffValue; // the value of the radio button if it is not selected
480
481
        RadioButtonWidget()
482
                : AnyWidget( PDFWriter::RadioButton ),
483
                  Selected( false ),
484
                  RadioGroup( 0 )
485
0
        {}
486
487
        virtual std::shared_ptr<AnyWidget> Clone() const override
488
0
        {
489
0
            return std::make_shared<RadioButtonWidget>( *this );
490
0
        }
491
        // radio buttons having the same RadioGroup id comprise one
492
        // logical radio button group, that is at most one of the RadioButtons
493
        // in a group can be checked at any time
494
        //
495
        // note: a PDF radio button field consists of a named field
496
        // containing unnamed checkbox child fields. The name of the
497
        // radio button field is taken from the first RadioButtonWidget created
498
        // in the group
499
    };
500
501
    struct VCL_DLLPUBLIC EditWidget final : public AnyWidget
502
    {
503
        bool                MultiLine;  // whether multiple lines are allowed
504
        bool                Password;   // visible echo off
505
        bool                FileSelect; // field is a file selector
506
        sal_Int32           MaxLen;     // maximum field length in characters, 0 means unlimited
507
        FormatType          Format;
508
        OUString            CurrencySymbol;
509
        sal_Int32           DecimalAccuracy;
510
        bool                PrependCurrencySymbol;
511
        OUString            TimeFormat;
512
        OUString            DateFormat;
513
514
        EditWidget()
515
                : AnyWidget( PDFWriter::Edit ),
516
                  MultiLine( false ),
517
                  Password( false ),
518
                  FileSelect( false ),
519
                  MaxLen( 0 ),
520
                  Format( FormatType::Text ),
521
                  DecimalAccuracy ( 0 ),
522
                  PrependCurrencySymbol( false )
523
0
        {}
524
525
        virtual std::shared_ptr<AnyWidget> Clone() const override
526
0
        {
527
0
            return std::make_shared<EditWidget>( *this );
528
0
        }
529
    };
530
531
    struct VCL_DLLPUBLIC ListBoxWidget final : public AnyWidget
532
    {
533
        bool                            DropDown;
534
        bool                            MultiSelect;
535
        std::vector<OUString>      Entries;
536
        std::vector<sal_Int32>          SelectedEntries;
537
         // if MultiSelect is false only the first entry of SelectedEntries
538
         // will be taken into account. the same is implicit for PDF < 1.4
539
         // since multiselect is a 1.4+ feature
540
541
        ListBoxWidget()
542
0
                : AnyWidget( PDFWriter::ListBox ),
543
0
                  DropDown( false ),
544
0
                  MultiSelect( false )
545
0
        {}
546
547
        virtual std::shared_ptr<AnyWidget> Clone() const override
548
0
        {
549
0
            return std::make_shared<ListBoxWidget>( *this );
550
0
        }
551
    };
552
553
    // note: PDF only supports dropdown comboboxes
554
    struct ComboBoxWidget final : public AnyWidget
555
    {
556
        std::vector<OUString>      Entries;
557
        // set the current value in AnyWidget::Text
558
559
        ComboBoxWidget()
560
                : AnyWidget( PDFWriter::ComboBox )
561
0
        {}
562
563
        virtual std::shared_ptr<AnyWidget> Clone() const override
564
0
        {
565
0
            return std::make_shared<ComboBoxWidget>( *this );
566
0
        }
567
    };
568
569
    struct SignatureWidget final : public AnyWidget
570
    {
571
        SignatureWidget()
572
                : AnyWidget( PDFWriter::Signature )
573
0
        {}
574
575
        virtual std::shared_ptr<AnyWidget> Clone() const override
576
0
        {
577
0
            return std::make_shared<SignatureWidget>( *this );
578
0
        }
579
    };
580
581
    enum ExportDataFormat { HTML, XML, FDF, PDF };
582
// see 3.6.1 of PDF 1.4 ref for details, used for 8.1 PDF v 1.4 ref also
583
// These emuns are treated as integer while reading/writing to configuration
584
    enum PDFViewerPageMode
585
    {
586
        ModeDefault,
587
        UseOutlines,
588
        UseThumbs
589
    };
590
// These emuns are treated as integer while reading/writing to configuration
591
    enum PDFViewerAction
592
    {
593
        ActionDefault,
594
        FitInWindow,
595
        FitWidth,
596
        FitVisible,
597
        ActionZoom
598
    };
599
// These enums are treated as integer while reading/writing to configuration
600
    enum PDFPageLayout
601
    {
602
        DefaultLayout,
603
        SinglePage,
604
        Continuous,
605
        ContinuousFacing
606
    };
607
608
    // These emuns are treated as integer while reading/writing to configuration
609
    //what default action to generate in a PDF hyperlink to external document/site
610
    enum PDFLinkDefaultAction
611
    {
612
        URIAction,
613
        URIActionDestination,
614
        LaunchAction,
615
        RemoveExternalLinks
616
    };
617
618
    struct PDFDocInfo
619
    {
620
        OUString          Title;          // document title
621
        OUString          Author;         // document author
622
        OUString          Subject;        // subject
623
        OUString          Keywords;       // keywords
624
        css::util::DateTime ModificationDate;
625
        css::uno::Sequence<OUString> Contributor; // http://purl.org/dc/elements/1.1/contributor
626
        OUString          Coverage;       // http://purl.org/dc/elements/1.1/coverage
627
        OUString          Identifier;     // http://purl.org/dc/elements/1.1/identifier
628
        css::uno::Sequence<OUString> Publisher; // http://purl.org/dc/elements/1.1/publisher
629
        css::uno::Sequence<OUString> Relation; // http://purl.org/dc/elements/1.1/relation
630
        OUString          Rights;         // http://purl.org/dc/elements/1.1/rights
631
        OUString          Source;         // http://purl.org/dc/elements/1.1/source
632
        OUString          Type;           // http://purl.org/dc/elements/1.1/type
633
        OUString          Creator;        // application that created the original document
634
        OUString          Producer;       // OpenOffice
635
    };
636
637
    enum ColorMode
638
    {
639
        DrawColor, DrawGreyscale
640
    };
641
642
    struct PDFWriterContext
643
    {
644
        /* must be a valid file: URL usable by osl */
645
        OUString                   URL;
646
        /* the URL of the document being exported, used for relative links*/
647
        OUString                   BaseURL;
648
        /*if relative to file system should be formed*/
649
        bool                            RelFsys;//i56629, i49415?, i64585?
650
        /*the action to set the PDF hyperlink to*/
651
        PDFWriter::PDFLinkDefaultAction DefaultLinkAction;
652
        //convert the .od? target file type in a link to a .pdf type
653
        //this is examined before doing anything else
654
        bool                            ConvertOOoTargetToPDFTarget;
655
        //when the file type is .pdf, force the GoToR action
656
        bool                            ForcePDFAction;
657
658
        /* decides the PDF language level to be produced */
659
        PDFVersion                      Version;
660
661
        /* PDF/UA compliance */
662
        bool UniversalAccessibilityCompliance;
663
664
        /* valid for PDF >= 1.4
665
           causes the MarkInfo entry in the document catalog to be set
666
        */
667
        bool                            Tagged;
668
        /*  determines in which format a form
669
            will be submitted.
670
         */
671
        PDFWriter::ExportDataFormat     SubmitFormat;
672
        bool                            AllowDuplicateFieldNames;
673
        /* the following data members are used to customize the PDF viewer
674
           preferences
675
         */
676
        /* see 3.6.1 PDF v 1.4 ref*/
677
        PDFWriter::PDFViewerPageMode    PDFDocumentMode;
678
        PDFWriter::PDFViewerAction      PDFDocumentAction;
679
        // in percent, valid only if PDFDocumentAction == ActionZoom
680
        sal_Int32                       Zoom;
681
682
        /* see 8.6 PDF v 1.4 ref
683
           specifies whether to hide the viewer tool
684
          bars when the document is active.
685
        */
686
        bool                            HideViewerToolbar;
687
        bool                            HideViewerMenubar;
688
        bool                            HideViewerWindowControls;
689
        bool                            FitWindow;
690
        bool                            OpenInFullScreenMode;
691
        bool                            CenterWindow;
692
        bool                            DisplayPDFDocumentTitle;
693
        PDFPageLayout                   PageLayout;
694
        bool                            FirstPageLeft;
695
        // initially visible page in viewer (starting with 0 for first page)
696
        sal_Int32                       InitialPage;
697
        sal_Int32                       OpenBookmarkLevels; // -1 means all levels
698
699
        PDFEncryptionProperties  Encryption;
700
        PDFWriter::PDFDocInfo           DocumentInfo;
701
702
        bool                            SignPDF;
703
        OUString                        SignLocation;
704
        OUString                        SignPassword;
705
        OUString                        SignReason;
706
        OUString                        SignContact;
707
        css::lang::Locale               DocumentLocale; // defines the document default language
708
        sal_uInt32                      DPIx, DPIy;     // how to handle MapMode( MapUnit::MapPixel )
709
                                                        // 0 here specifies a default handling
710
        PDFWriter::ColorMode            ColorMode;
711
        css::uno::Reference< css::security::XCertificate> SignCertificate;
712
        OUString                        SignTSA;
713
        /// Use reference XObject markup for PDF images.
714
        bool                            UseReferenceXObject;
715
716
        PDFWriterContext() :
717
4.14k
                RelFsys( false ), //i56629, i49415?, i64585?
718
4.14k
                DefaultLinkAction( PDFWriter::URIAction ),
719
4.14k
                ConvertOOoTargetToPDFTarget( false ),
720
4.14k
                ForcePDFAction( false ),
721
4.14k
                Version(PDFWriter::PDFVersion::Default),
722
4.14k
                UniversalAccessibilityCompliance( false ),
723
4.14k
                Tagged( false ),
724
4.14k
                SubmitFormat( PDFWriter::FDF ),
725
4.14k
                AllowDuplicateFieldNames( false ),
726
4.14k
                PDFDocumentMode( PDFWriter::ModeDefault ),
727
4.14k
                PDFDocumentAction( PDFWriter::ActionDefault ),
728
4.14k
                Zoom( 100 ),
729
4.14k
                HideViewerToolbar( false ),
730
4.14k
                HideViewerMenubar( false ),
731
4.14k
                HideViewerWindowControls( false ),
732
4.14k
                FitWindow( false ),
733
4.14k
                OpenInFullScreenMode( false ),
734
4.14k
                CenterWindow( false ),
735
4.14k
                DisplayPDFDocumentTitle( true ),
736
4.14k
                PageLayout( PDFWriter::DefaultLayout ),
737
4.14k
                FirstPageLeft( false ),
738
4.14k
                InitialPage( 1 ),
739
4.14k
                OpenBookmarkLevels( -1 ),
740
4.14k
                SignPDF( false ),
741
4.14k
                DPIx( 0 ),
742
4.14k
                DPIy( 0 ),
743
4.14k
                ColorMode( PDFWriter::DrawColor ),
744
4.14k
                UseReferenceXObject( false )
745
4.14k
        {}
746
    };
747
748
    VCL_DLLPUBLIC PDFWriter( const PDFWriterContext& rContext, const css::uno::Reference< css::beans::XMaterialHolder >& );
749
    VCL_DLLPUBLIC ~PDFWriter();
750
751
    /** Returns an OutputDevice for formatting
752
        This Output device is guaranteed to use the same
753
        font metrics as the resulting PDF file.
754
755
        @returns
756
        the reference output device
757
    */
758
    VCL_DLLPUBLIC OutputDevice* GetReferenceDevice();
759
760
    /** Creates a new page to fill
761
        If width and height are not set the page size
762
        is inherited from the page tree
763
        other effects:
764
        resets the graphics state: MapMode, Font
765
        Colors and other state information MUST
766
        be set again or are undefined.
767
    */
768
    VCL_DLLPUBLIC void NewPage( double nPageWidth, double nPageHeight, Orientation eOrientation = Orientation::Inherit );
769
    /** Play a metafile like an outputdevice would do
770
    */
771
    struct PlayMetafileContext
772
    {
773
        int     m_nMaxImageResolution;
774
        bool    m_bOnlyLosslessCompression;
775
        int     m_nJPEGQuality;
776
        bool    m_bTransparenciesWereRemoved;
777
778
        PlayMetafileContext()
779
62.5k
        : m_nMaxImageResolution( 0 )
780
62.5k
        , m_bOnlyLosslessCompression( false )
781
62.5k
        , m_nJPEGQuality( 90 )
782
62.5k
        , m_bTransparenciesWereRemoved( false )
783
62.5k
        {}
784
785
    };
786
    VCL_DLLPUBLIC void PlayMetafile( const GDIMetaFile&, const PlayMetafileContext&, vcl::PDFExtOutDevData* pDevDat = nullptr );
787
788
    /* sets the document locale originally passed with the context to a new value
789
     * only affects the output if used before calling Emit.
790
     */
791
    VCL_DLLPUBLIC void SetDocumentLocale( const css::lang::Locale& rDocLocale );
792
793
    /* finishes the file */
794
    VCL_DLLPUBLIC bool Emit();
795
796
    /*
797
     * Get a list of errors that occurred during processing
798
     * this should enable the producer to give feedback about
799
     * any anomalies that might have occurred
800
     */
801
    VCL_DLLPUBLIC std::set< ErrorCode > const & GetErrors() const;
802
803
    /* functions for graphics state */
804
    /* flag values: see vcl/outdev.hxx */
805
    VCL_DLLPUBLIC void Push( PushFlags nFlags = PushFlags::ALL );
806
    VCL_DLLPUBLIC void Pop();
807
808
    VCL_DLLPUBLIC void SetClipRegion();
809
    VCL_DLLPUBLIC void SetClipRegion( const basegfx::B2DPolyPolygon& rRegion );
810
    void               MoveClipRegion( tools::Long nHorzMove, tools::Long nVertMove );
811
    void               IntersectClipRegion( const tools::Rectangle& rRect );
812
    void               IntersectClipRegion( const basegfx::B2DPolyPolygon& rRegion );
813
814
    void               SetLayoutMode( vcl::text::ComplexTextLayoutFlags nMode );
815
    void               SetDigitLanguage( LanguageType eLang );
816
817
    void               SetLineColor( const Color& rColor );
818
256k
    void               SetLineColor() { SetLineColor( COL_TRANSPARENT ); }
819
820
    void               SetFillColor( const Color& rColor );
821
141k
    void               SetFillColor() { SetFillColor( COL_TRANSPARENT ); }
822
823
    VCL_DLLPUBLIC void SetFont( const vcl::Font& rNewFont );
824
    VCL_DLLPUBLIC void SetTextColor( const Color& rColor );
825
    void               SetTextFillColor();
826
    void               SetTextFillColor( const Color& rColor );
827
828
    void               SetTextLineColor();
829
    void               SetTextLineColor( const Color& rColor );
830
    void               SetOverlineColor();
831
    void               SetOverlineColor( const Color& rColor );
832
    void               SetTextAlign( ::TextAlign eAlign );
833
834
    VCL_DLLPUBLIC void SetMapMode( const MapMode& rNewMapMode );
835
836
837
    /* actual drawing functions */
838
    VCL_DLLPUBLIC void  DrawText( const Point& rPos, const OUString& rText );
839
840
    void                DrawTextLine( const Point& rPos, tools::Long nWidth,
841
                                      FontStrikeout eStrikeout,
842
                                      FontLineStyle eUnderline,
843
                                      FontLineStyle eOverline );
844
    void DrawTextArray(const Point& rStartPt, const OUString& rStr, KernArraySpan aKernArray,
845
                       std::span<const sal_Bool> pKashidaAry, sal_Int32 nIndex, sal_Int32 nLen,
846
                       sal_Int32 nLayoutContextIndex, sal_Int32 nLayoutContextLen);
847
    void                DrawStretchText( const Point& rStartPt, sal_Int32 nWidth,
848
                                         const OUString& rStr,
849
                                         sal_Int32 nIndex, sal_Int32 nLen );
850
    VCL_DLLPUBLIC void  DrawText( const tools::Rectangle& rRect,
851
                                  const OUString& rStr, DrawTextFlags nStyle );
852
853
    void                DrawPixel( const Point& rPt, const Color& rColor );
854
    void                DrawPixel( const Point& rPt )
855
0
    { DrawPixel( rPt, COL_TRANSPARENT ); }
856
857
    void                DrawLine( const Point& rStartPt, const Point& rEndPt );
858
    void                DrawLine( const Point& rStartPt, const Point& rEndPt,
859
                                  const LineInfo& rLineInfo );
860
    VCL_DLLPUBLIC void  DrawPolyLine( const tools::Polygon& rPoly );
861
    void                DrawPolyLine( const tools::Polygon& rPoly,
862
                                      const LineInfo& rLineInfo );
863
    void                DrawPolyLine( const tools::Polygon& rPoly, const ExtLineInfo& rInfo );
864
    void                DrawPolygon( const tools::Polygon& rPoly );
865
    void                DrawPolyPolygon( const tools::PolyPolygon& rPolyPoly );
866
    void                DrawRect( const tools::Rectangle& rRect );
867
    void                DrawRect( const tools::Rectangle& rRect,
868
                                  sal_uInt32 nHorzRound, sal_uInt32 nVertRound );
869
    void                DrawEllipse( const tools::Rectangle& rRect );
870
    void                DrawArc( const tools::Rectangle& rRect,
871
                                 const Point& rStartPt, const Point& rEndPt );
872
    void                DrawPie( const tools::Rectangle& rRect,
873
                                 const Point& rStartPt, const Point& rEndPt );
874
    void                DrawChord( const tools::Rectangle& rRect,
875
                                   const Point& rStartPt, const Point& rEndPt );
876
877
    void                DrawBitmap( const Point& rDestPt, const Size& rDestSize,
878
                                    const Bitmap& rBitmap, const Graphic& rGraphic );
879
880
    void                DrawGradient( const tools::Rectangle& rRect, const Gradient& rGradient );
881
    void                DrawGradient( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient );
882
883
    void                DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch );
884
885
    void                DrawWallpaper( const tools::Rectangle& rRect, const Wallpaper& rWallpaper );
886
    void                DrawTransparent( const tools::PolyPolygon& rPolyPoly,
887
                                         sal_uInt16 nTransparencePercent );
888
889
    /** Start a transparency group
890
891
    Drawing operations can be grouped together to acquire a common transparency
892
    behaviour; after calling BeginTransparencyGroup all drawing
893
    operations will be grouped together into a transparent object.
894
895
    The transparency behaviour is set with one of the EndTransparencyGroup
896
    calls and can be either a constant transparency factor or a transparent
897
    soft mask in form of an 8 bit gray scale bitmap.
898
899
    It is permissible to nest transparency group.
900
901
    Transparency groups MUST NOT span multiple pages
902
903
    Transparency is a feature introduced in PDF1.4, so transparency group
904
    will be ignored if the produced PDF has a lower version. The drawing
905
    operations will be emitted normally.
906
    */
907
    VCL_DLLPUBLIC void BeginTransparencyGroup();
908
909
    /** End a transparency group with constant transparency factor
910
911
    This ends a transparency group and inserts it on the current page. The
912
    coordinates of the group result out of the grouped drawing operations.
913
914
    @param rBoundRect
915
    The bounding rectangle of the group
916
917
    @param nTransparencePercent
918
    The transparency factor
919
    */
920
    VCL_DLLPUBLIC void EndTransparencyGroup( const tools::Rectangle& rBoundRect, sal_uInt16 nTransparencePercent );
921
922
    /** Insert a JPG encoded image (optionally with mask)
923
924
    @param rJPGData
925
    a Stream containing the encoded image
926
927
    @param bIsTrueColor
928
    true: jpeg is 24 bit true color, false: jpeg is 8 bit greyscale
929
930
    @param rSrcSizePixel
931
    size in pixel of the image
932
933
    @param rTargetArea
934
    where to put the image
935
936
    @param rMask
937
    optional mask; if not empty it must have
938
    the same pixel size as the image and
939
    be either 1 bit black&white or 8 bit grey
940
    */
941
    void                DrawJPGBitmap( SvStream& rJPGData, bool bIsTrueColor, const Size& rSrcSizePixel, const tools::Rectangle& rTargetArea, const AlphaMask& rAlphaMask, const Graphic& rGraphic );
942
943
    /** Create a new named destination to be used in a link from another PDF document
944
945
    @param sDestName
946
    the name (label) of the bookmark, to be used to jump to
947
948
    @param rRect
949
    target rectangle on page to be displayed if dest is jumped to
950
951
    @param nPageNr
952
    number of page the dest is on (as returned by NewPage)
953
    or -1 in which case the current page is used
954
955
    @param eType
956
    what dest type to use
957
958
    @returns
959
    the destination id (to be used in SetLinkDest) or
960
    -1 if page id does not exist
961
    */
962
    sal_Int32           CreateNamedDest( const OUString& sDestName, const tools::Rectangle& rRect, sal_Int32 nPageNr, DestAreaType eType );
963
    /** Create a new destination to be used in a link
964
965
    @param rRect
966
    target rectangle on page to be displayed if dest is jumped to
967
968
    @param nPageNr
969
    number of page the dest is on (as returned by NewPage)
970
    or -1 in which case the current page is used
971
972
    @param eType
973
    what dest type to use
974
975
    @returns
976
    the destination id (to be used in SetLinkDest) or
977
    -1 if page id does not exist
978
    */
979
    sal_Int32           CreateDest( const tools::Rectangle& rRect, sal_Int32 nPageNr, DestAreaType eType );
980
    /** Create a new link on a page
981
982
    @param rRect
983
    active rectangle of the link (that is the area that has to be
984
    hit to activate the link)
985
986
    @param nPageNr
987
    number of page the link is on (as returned by NewPage)
988
    or -1 in which case the current page is used
989
990
    @returns
991
    the link id (to be used in SetLinkDest, SetLinkURL) or
992
    -1 if page id does not exist
993
    */
994
    sal_Int32 CreateLink(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText);
995
996
    /// Creates a screen annotation.
997
    sal_Int32 CreateScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr, OUString const& rAltText, OUString const& rMimeType);
998
999
    /** creates a destination which is not intended to be referred to by a link, but by a public destination Id.
1000
1001
        Form widgets, for instance, might refer to a destination, without ever actually creating a source link to
1002
        point to this destination. In such cases, a public destination Id will be assigned to the form widget,
1003
        and later on, the concrete destination data for this public Id will be registered using RegisterDestReference.
1004
1005
        @param nDestId
1006
            destination ID
1007
1008
        @param rRect
1009
            target rectangle on page to be displayed if dest is jumped to
1010
1011
        @param nPageNr
1012
            number of page the dest is on (as returned by NewPage)
1013
            or -1 in which case the current page is used
1014
1015
        @param eType
1016
            what dest type to use
1017
1018
        @returns
1019
            the internal destination Id.
1020
    */
1021
    sal_Int32           RegisterDestReference( sal_Int32 nDestId, const tools::Rectangle& rRect, sal_Int32 nPageNr, DestAreaType eType );
1022
1023
1024
    /** Set the destination for a link
1025
        will change a URL type link to a dest link if necessary
1026
1027
        @param nLinkId
1028
        the link to be changed
1029
1030
        @param nDestId
1031
        the dest the link shall point to
1032
    */
1033
    void           SetLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId );
1034
    /** Set the URL for a link
1035
        will change a dest type link to a URL type link if necessary
1036
        @param nLinkId
1037
        the link to be changed
1038
1039
        @param rURL
1040
        the URL the link shall point to.
1041
        The URL will be parsed (and corrected) by the com.sun.star.util.URLTransformer
1042
        service; the result will then appear literally in the PDF file produced
1043
    */
1044
    void           SetLinkURL( sal_Int32 nLinkId, const OUString& rURL );
1045
1046
    /// Sets the URL of a linked screen annotation.
1047
    void SetScreenURL(sal_Int32 nScreenId, const OUString& rURL);
1048
    /// Sets the URL of an embedded screen annotation.
1049
    void SetScreenStream(sal_Int32 nScreenId, const OUString& rURL);
1050
1051
    /** Resolve link in logical structure
1052
1053
        If a link is created after the corresponding visual appearance was drawn
1054
        it is not possible to set the link id as a property attribute to the
1055
        link structure item that should be created in tagged PDF around the
1056
        visual appearance of a link.
1057
1058
        For this reason an arbitrary id can be given to
1059
        SetStructureAttributeNumerical at the time the text for
1060
        the link is drawn. To resolve this arbitrary id again when the actual
1061
        link annotation is created use SetLinkPropertyID. When Emit
1062
        finally gets called all LinkAnnotation type structure attributes
1063
        will be replaced with the correct link id.
1064
1065
        CAUTION: this technique must be used either for all or none of the links
1066
        in a document since the link id space and arbitrary property id space
1067
        could overlap and it would be impossible to resolve whether a Link
1068
        structure attribute value was arbitrary or already a real id.
1069
1070
        @param nLinkId
1071
        the link to be mapped
1072
1073
        @param nPropertyID
1074
        the arbitrary id set in a Link structure element to address
1075
        the link with real id nLinkId
1076
     */
1077
    void                SetLinkPropertyID( sal_Int32 nLinkId, sal_Int32 nPropertyID );
1078
    /** Create a new outline item
1079
1080
        @param nParent
1081
        declares the parent of the new item in the outline hierarchy.
1082
        An invalid value will result in a new toplevel item.
1083
1084
        @param rText
1085
        sets the title text of the item
1086
1087
        @param nDestID
1088
        declares which Dest (created with CreateDest) the outline item
1089
        will point to
1090
1091
        @returns
1092
        the outline item id of the new item
1093
    */
1094
    sal_Int32 CreateOutlineItem( sal_Int32 nParent, std::u16string_view rText, sal_Int32 nDestID );
1095
1096
    /** Create a new note on a page
1097
1098
    @param rRect
1099
    active rectangle of the note (that is the area that has to be
1100
    hit to popup the annotation)
1101
1102
    @param rPopupRect
1103
    specifies the rectangle of the popup window for the note
1104
1105
    @param rNote
1106
    specifies the contents of the note
1107
1108
    @param nPageNr
1109
    number of page the note is on (as returned by NewPage)
1110
    or -1 in which case the current page is used
1111
    */
1112
    sal_Int32 CreateNote( const tools::Rectangle& rRect, const tools::Rectangle& rPopupRect, const vcl::pdf::PDFNote& rNote, sal_Int32 nPageNr );
1113
1114
    /** begin a new logical structure element
1115
1116
    BeginStructureElement/EndStructureElement calls build the logical structure
1117
    of the PDF - the basis for tagged PDF. Structural elements are implemented
1118
    using marked content tags. Each structural element can contain sub elements
1119
    (e.g. a section can contain a heading and a paragraph). The structure hierarchy
1120
    is built automatically from the Begin/EndStructureElement calls.
1121
1122
    The easy way is to call WrapBeginStructureElement, but it's also possible
1123
    to call EnsureStructureElement/InitStructureElement/BeginStructureElement
1124
    (its 3 parts) manually for more control; this way a placeholder SE can be
1125
    inserted and initialised later.
1126
1127
    A structural element need not be contained on one page; e.g. paragraphs often
1128
    run from one page to the next. In this case the corresponding EndStructureElement
1129
    must be called while drawing the next page.
1130
1131
    BeginStructureElement and EndStructureElement must be called only after
1132
    PDFWriter::NewPage has been called and before PDFWriter::Emit gets called. The
1133
    current page number is an implicit context parameter for Begin/EndStructureElement.
1134
1135
    For pagination artifacts that are not part of the logical structure
1136
    of the document (like header, footer or page number) the special
1137
    StructElement NonStructElement exists. To place content
1138
    outside of the structure tree simply call
1139
    BeginStructureElement( NonStructElement ) then draw your
1140
    content and then call EndStructureElement(). All children
1141
    of a NonStructElement will not be part of the structure.
1142
    Nonetheless if you add a child structural element to a
1143
    NonStructElement you will still have to call
1144
    EndStructureElement for it. Best think of the structure
1145
    tree as a stack.
1146
1147
    Note: there is always one structural element in existence without having
1148
    called BeginStructureElement; this is the root of the structure
1149
    tree (called StructTreeRoot). The StructTreeRoot has always the id 0.
1150
1151
    @param eType
1152
    denotes what kind of element to begin (e.g. a heading or paragraph)
1153
1154
    @param rAlias
1155
    the specified alias will be used as structure tag. Also an entry in the PDF's
1156
    role map will be created mapping alias to regular structure type.
1157
1158
    @returns
1159
    the new structure element's id for use in SetCurrentStructureElement
1160
     */
1161
    VCL_DLLPUBLIC void BeginStructureElement(sal_Int32 id);
1162
    VCL_DLLPUBLIC sal_Int32 EnsureStructureElement();
1163
    VCL_DLLPUBLIC void InitStructureElement(sal_Int32 id, vcl::pdf::StructElement eType, std::u16string_view rAlias);
1164
1165
    /** end the current logical structure element
1166
1167
    Close the current structure element. The current element's
1168
    parent becomes the current structure element again.
1169
1170
    @see BeginStructureElement
1171
     */
1172
    VCL_DLLPUBLIC void EndStructureElement();
1173
    /** set the current structure element
1174
1175
    For different purposes it may be useful to paint a structure element's
1176
    content discontinuously. In that case an already existing structure element
1177
    can be appended to by using SetCurrentStructureElement. The
1178
    referenced structure element becomes the current structure element with
1179
    all consequences: all following structure elements are appended as children
1180
    of the current element.
1181
1182
    @param nElement
1183
    the id of the new current structure element
1184
     */
1185
    void SetCurrentStructureElement( sal_Int32 nElement );
1186
1187
    /** set a structure attribute on the current structural element
1188
1189
    SetStructureAttribute sets an attribute of the current structural element to a
1190
    new value. A consistency check is performed before actually setting the value;
1191
    if the check fails, the function returns False and the attribute remains
1192
    unchanged.
1193
1194
    @param eAttr
1195
    denotes what attribute to change
1196
1197
    @param eVal
1198
    the value to set the attribute to
1199
     */
1200
    VCL_DLLPUBLIC void SetStructureAttribute( enum StructAttribute eAttr, enum StructAttributeValue eVal );
1201
    /** set a structure attribute on the current structural element
1202
1203
    SetStructureAttributeNumerical sets an attribute of the current structural element
1204
    to a new numerical value. A consistency check is performed before actually setting
1205
    the value; if the check fails, the function returns False and the attribute
1206
    remains unchanged.
1207
1208
    @param eAttr
1209
    denotes what attribute to change
1210
1211
    @param nValue
1212
    the value to set the attribute to
1213
     */
1214
    void SetStructureAttributeNumerical( enum StructAttribute eAttr, sal_Int32 nValue );
1215
    /** set the bounding box of a structural element
1216
1217
    SetStructureBoundingBox sets the BBox attribute to a new value. Since the BBox
1218
    attribute can only be applied to Table, Figure,
1219
    Form and Formula elements, a call of this function
1220
    for other element types will be ignored and the BBox attribute not be set.
1221
1222
    @param rRect
1223
    the new bounding box for the structural element
1224
     */
1225
    void SetStructureBoundingBox( const tools::Rectangle& rRect );
1226
1227
    /** set the annotations that should be referenced as children of the
1228
        current structural element.
1229
     */
1230
    void SetStructureAnnotIds(::std::vector<sal_Int32> const& rAnnotIds);
1231
1232
    /** set the ActualText attribute of a structural element
1233
1234
    ActualText contains the Unicode text without layout artifacts that is shown by
1235
    a structural element. For example if a line is ended prematurely with a break in
1236
    a word and continued on the next line (e.g. "happen-<newline>stance") the
1237
    corresponding ActualText would contain the unbroken line (e.g. "happenstance").
1238
1239
    @param rText
1240
    contains the complete logical text the structural element displays.
1241
     */
1242
    void SetActualText( const OUString& rText );
1243
1244
    /** set the Alt attribute of a structural element
1245
1246
    Alt is s replacement text describing the contents of a structural element. This
1247
    is mainly used by accessibility applications; e.g. a screen reader would read
1248
    the Alt replacement text for an image to a visually impaired user.
1249
1250
    @param rText
1251
    contains the replacement text for the structural element
1252
    */
1253
    void SetAlternateText( const OUString& rText );
1254
1255
    /** Sets the transitional effect to be applied when the current page gets shown.
1256
1257
    @param eType
1258
    the kind of effect to be used; use Regular to disable transitional effects
1259
    for this page
1260
1261
    @param nMilliSec
1262
    the duration of the transitional effect in milliseconds;
1263
    set 0 to disable transitional effects
1264
1265
    @param nPageNr
1266
    the page number to apply the effect to; -1 denotes the current page
1267
    */
1268
    void SetPageTransition( PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr );
1269
1270
    /** create a new form control
1271
1272
    This function creates a new form control in the PDF and sets its various
1273
    properties. Do not pass an actual AnyWidget as rControlType
1274
    will be cast to the type described by the type member.
1275
1276
    @param rControlType
1277
    a descendant of AnyWidget determining the control's properties
1278
1279
    @returns
1280
    the new control's id for reference purposes
1281
     */
1282
    sal_Int32 CreateControl( const AnyWidget& rControlType );
1283
1284
    /** Attaches an additional file to the PDF file
1285
1286
    This function adds an arbitrary stream that represents an attached file
1287
    in the PDF file.
1288
1289
    This also adds an additional stream array entry (with the mimetype) in
1290
    the trailer dictionary for backwards compatibility.
1291
1292
    @param rFileName
1293
    the filename of the additional file as presented in the stream
1294
1295
    @param rMimeType
1296
    the mimetype of the stream
1297
1298
    @param pStream
1299
    the interface to the additional stream
1300
    */
1301
    VCL_DLLPUBLIC void AddAttachedFile(OUString const& rFileName, OUString const& rMimeType, OUString const& rDescription, std::unique_ptr<PDFOutputStream> pStream);
1302
1303
    /// Get current date/time in PDF D:YYYYMMDDHHMMSS form.
1304
    static OString GetDateTime(svl::crypto::SigningContext* pSigningContext = nullptr);
1305
};
1306
1307
} // end namespace vcl::pdf
1308
1309
} // end namespace vcl
1310
1311
#endif // INCLUDED_VCL_PDFWRITER_HXX
1312
1313
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */