Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/print.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
20
#ifndef INCLUDED_VCL_PRINT_HXX
21
#define INCLUDED_VCL_PRINT_HXX
22
23
#include <sal/config.h>
24
25
#include <sal/types.h>
26
#include <rtl/ustring.hxx>
27
#include <tools/gen.hxx>
28
#include <tools/long.hxx>
29
30
#include <vcl/dllapi.h>
31
#include <utility>
32
#include <comphelper/errcode.hxx>
33
#include <vcl/outdev.hxx>
34
#include <vcl/prntypes.hxx>
35
#include <vcl/jobset.hxx>
36
37
#include <com/sun/star/beans/PropertyValue.hpp>
38
#include <com/sun/star/uno/Sequence.hxx>
39
40
#include <memory>
41
#include <unordered_map>
42
43
class GDIMetaFile;
44
class SalInfoPrinter;
45
struct SalPrinterQueueInfo;
46
class PaperInfo;
47
class QueueInfo;
48
class SalPrinter;
49
class VirtualDevice;
50
enum class SalPrinterError;
51
enum class PrinterSupport;
52
enum Paper : unsigned int;
53
54
namespace vcl {
55
    class PrinterController;
56
57
    namespace printer {
58
        class Options;
59
    }
60
}
61
62
namespace weld { class Window; }
63
namespace com::sun::star::view { enum class PrintableState; }
64
65
class VCL_DLLPUBLIC Printer : public OutputDevice
66
{
67
    friend class                ::OutputDevice;
68
69
private:
70
    SalInfoPrinter*             mpInfoPrinter;
71
    std::unique_ptr<SalPrinter> mpPrinter;
72
    SalGraphics*                mpJobGraphics;
73
    VclPtr<Printer>             mpPrev;
74
    VclPtr<Printer>             mpNext;
75
    VclPtr<VirtualDevice>       mpDisplayDev;
76
    std::unique_ptr<vcl::printer::Options> mpPrinterOptions;
77
    OUString                    maPrinterName;
78
    OUString                    maDriver;
79
    OUString                    maPrintFile;
80
    JobSetup                    maJobSetup;
81
    Point                       maPageOffset;
82
    Size                        maPaperSize;
83
    Size                        maPrintPageSize;
84
    ErrCode                     mnError;
85
    sal_uInt16                  mnPageQueueSize;
86
    sal_uInt16                  mnCopyCount;
87
    bool                        mbDefPrinter;
88
    bool                        mbPrinting;
89
    bool                        mbJobActive;
90
    bool                        mbCollateCopy;
91
    bool                        mbPrintFile;
92
    bool                        mbInPrintPage;
93
    bool                        mbNewJobSetup;
94
    bool                        mbSinglePrintJobs;
95
    bool                        mbUsePrintSetting;
96
97
    SAL_DLLPRIVATE void         ImplInitData();
98
    SAL_DLLPRIVATE void ImplInit(SalPrinterQueueInfo& rInfo);
99
    SAL_DLLPRIVATE void         ImplInitDisplay();
100
    SAL_DLLPRIVATE static SalPrinterQueueInfo*
101
                                ImplGetQueueInfo( const OUString& rPrinterName, const OUString* pDriver );
102
    SAL_DLLPRIVATE void         ImplUpdatePageData();
103
    SAL_DLLPRIVATE void         ImplUpdateFontList();
104
    SAL_DLLPRIVATE void         ImplFindPaperFormatForUserSize( JobSetup& );
105
106
    SAL_DLLPRIVATE bool         StartJob( const OUString& rJobName, std::shared_ptr<vcl::PrinterController> const & );
107
108
    static SAL_DLLPRIVATE ErrCode
109
                                ImplSalPrinterErrorCodeToVCL( SalPrinterError nError );
110
111
    SAL_DLLPRIVATE void         ImplPrintTransparent (
112
                                    const Bitmap& rBmp,
113
                                    const Point& rDestPt, const Size& rDestSize,
114
                                    const Point& rSrcPtPixel, const Size& rSrcSizePixel );
115
116
private:
117
    SAL_DLLPRIVATE void         EndJob();
118
                                Printer( const Printer& rPrinter )    = delete;
119
    Printer&                    operator =( const Printer& rPrinter ) = delete;
120
121
public:
122
    SAL_DLLPRIVATE void         ImplStartPage();
123
    SAL_DLLPRIVATE void         ImplEndPage();
124
125
protected:
126
    virtual bool                AcquireGraphics() const override;
127
    virtual void                ReleaseGraphics( bool bRelease = true ) override;
128
    SAL_DLLPRIVATE void ImplReleaseGraphics(bool bRelease = true);
129
    virtual void                ImplReleaseFonts() override;
130
131
    virtual tools::Long                GetGradientStepCount( tools::Long nMinRect ) override;
132
    virtual bool                UsePolyPolygonForComplexGradient() override;
133
    virtual void                ClipAndDrawGradientMetafile ( const Gradient &rGradient,
134
                                    const tools::PolyPolygon &rPolyPoly ) override;
135
136
0
    bool                        CanSubsampleBitmap() const override { return false; }
137
    vcl::Region                 ClipToDeviceBounds(vcl::Region aRegion) const override;
138
139
public:
140
    void                        SetSystemTextColor(SystemTextColorFlags, bool) override;
141
    SAL_DLLPRIVATE void                        DrawGradientEx( OutputDevice* pOut, const tools::Rectangle& rRect,
142
                                    const Gradient& rGradient );
143
    virtual Bitmap              GetBitmap( const Point& rSrcPt, const Size& rSize ) const override;
144
    virtual Size                GetButtonBorderSize() override;
145
0
    virtual Color               GetMonochromeButtonColor() override { return COL_LIGHTGRAY; }
146
147
0
    bool                        IsScreenComp() const override { return false; }
148
149
0
    bool                        CanAnimate() const override { return false; }
150
151
    void DrawBorder(tools::Rectangle aBorderRect) override
152
0
    {
153
0
        SetLineColor(COL_BLACK);
154
0
        DrawRect(aBorderRect);
155
0
    }
156
157
    css::awt::DeviceInfo GetDeviceInfo() const override;
158
159
0
    virtual bool HasAlpha() const override { return false; }
160
161
protected:
162
    virtual void                DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor,
163
                                    const Point& rDestPt, const Size& rDestSize,
164
                                    const Point& rSrcPtPixel, const Size& rSrcSizePixel) override;
165
166
    bool                        DrawTransformedBitmap(const basegfx::B2DHomMatrix& aFullTransform,
167
                                    const Bitmap& rBitmap, double fAlpha = 1.0) override;
168
169
    bool                        TransformAndReduceBitmapExToTargetRange( const basegfx::B2DHomMatrix& aFullTransform,
170
                                    basegfx::B2DRange &aVisibleRange, double &fMaximumArea) override;
171
172
    void                        DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize,
173
                                    const Point& rSrcPtPixel, const Size& rSrcSizePixel,
174
                                    Bitmap& rBitmap ) override;
175
176
    virtual void                EmulateDrawTransparent( const tools::PolyPolygon& rPolyPoly,
177
                                    sal_uInt16 nTransparencePercent ) override;
178
179
    virtual void                SetFontOrientation( LogicalFontInstance* const pFontInstance ) const override;
180
181
0
    bool                        shouldDrawWavePixelAsRect(tools::Long) const override { return true; }
182
    void                        SetWaveLineColors(Color const& rColor, tools::Long) override;
183
    Size                        GetWaveLineSize(tools::Long nLineWidth) const override;
184
185
public:
186
                                Printer();
187
                                Printer( const JobSetup& rJobSetup );
188
                                Printer( const QueueInfo& rQueueInfo );
189
                                Printer( const OUString& rPrinterName );
190
    virtual                     ~Printer() override;
191
    virtual void                dispose() override;
192
193
0
    virtual void SetMetafileMapMode(const MapMode& rNewMapMode, bool) override { SetMapMode(rNewMapMode); }
194
195
    static const std::vector< OUString >&
196
                                GetPrinterQueues();
197
    static const QueueInfo*     GetQueueInfo( const OUString& rPrinterName, bool bStatusUpdate );
198
    static OUString             GetDefaultPrinterName();
199
200
4.71k
    const OUString&             GetName() const             { return maPrinterName; }
201
0
    const OUString&             GetDriverName() const       { return maDriver; }
202
0
    bool                        IsDefPrinter() const        { return mbDefPrinter; }
203
751k
    bool                        IsDisplayPrinter() const    { return mpDisplayDev != nullptr; }
204
745k
    bool                        IsValid() const             { return !IsDisplayPrinter(); }
205
206
    SAL_DLLPRIVATE sal_uInt32                  GetCapabilities( PrinterCapType nType ) const;
207
    bool                        HasSupport( PrinterSupport eFeature ) const;
208
209
    bool                        SetJobSetup( const JobSetup& rSetup );
210
75
    const JobSetup&             GetJobSetup() const { return maJobSetup; }
211
212
    bool                        Setup(weld::Window* pWindow,
213
                                      PrinterSetupMode eMode = PrinterSetupMode::DocumentGlobal);
214
    bool                        SetPrinterProps( const Printer* pPrinter );
215
216
0
    Color                       GetBackgroundColor() const override { return COL_WHITE; }
217
0
    Color                       GetReadableFontColor(const Color&, const Color&) const override { return COL_BLACK; }
218
219
    /** SetPrinterOptions is used internally only now
220
221
        in earlier times it was used only to set the options loaded directly from the configuration
222
        in SfxPrinter::InitJob, this is now handled internally
223
        should the need arise to set the printer options outside vcl, also a method would have to be devised
224
        to not override these again internally
225
    */
226
    SAL_DLLPRIVATE void         SetPrinterOptions( const vcl::printer::Options& rOptions );
227
0
    const vcl::printer::Options& GetPrinterOptions() const { return( *mpPrinterOptions ); }
228
229
0
    void                        SetUsePrintDialogSetting(bool bUsed) { mbUsePrintSetting = bUsed; }
230
0
    bool                        IsUsePrintDialogSetting() { return mbUsePrintSetting; }
231
0
    void                        SetPrintPageSize(Size aPrintPageSize) { maPrintPageSize = aPrintPageSize; }
232
0
    const Size &                GetPrintPageSize() { return maPrintPageSize; }
233
    bool                        SetOrientation( Orientation eOrient );
234
    Orientation                 GetOrientation() const;
235
    SAL_DLLPRIVATE void                        SetDuplexMode( DuplexMode );
236
    SAL_DLLPRIVATE DuplexMode                  GetDuplexMode() const;
237
238
    bool                        SetPaperBin( sal_uInt16 nPaperBin );
239
    sal_uInt16                  GetPaperBin() const;
240
    sal_uInt16                  GetPaperBinBySourceIndex(sal_uInt16 nPaperSource) const;
241
    sal_uInt16                  GetSourceIndexByPaperBin(sal_uInt16 nPaperBin) const;
242
    void                        SetPaper( Paper ePaper );
243
    bool                        SetPaperSizeUser( const Size& rSize );
244
    /** @return The paper format of the printer's current "jobsetup". Note that if PAPER_USER the actual size can be anything. */
245
    Paper                       GetPaper() const;
246
    /** @return Size of the paper of the printer's current "jobsetup". */
247
    SAL_DLLPRIVATE Size                        GetSizeOfPaper() const;
248
    static OUString             GetPaperName( Paper ePaper );
249
250
    /** @return Number of available paper formats */
251
    SAL_DLLPRIVATE int                         GetPaperInfoCount() const;
252
253
    /** @return Info about paper format nPaper */
254
    SAL_DLLPRIVATE const PaperInfo&            GetPaperInfo( int nPaper ) const;
255
    sal_uInt16                  GetPaperBinCount() const;
256
    OUString                    GetPaperBinName( sal_uInt16 nPaperBin ) const;
257
258
    bool                        GetPrinterSettingsPreferred() const;
259
    void                        SetPrinterSettingsPreferred( bool bPaperSizeFromSetup );
260
261
0
    const Size&                 GetPaperSizePixel() const { return maPaperSize; }
262
0
    Size                        GetPaperSize() const { return PixelToLogic( maPaperSize ); }
263
29.9k
    const Point&                GetPageOffsetPixel() const { return maPageOffset; }
264
0
    Point                       GetPageOffset() const { return PixelToLogic( maPageOffset ); }
265
266
    SAL_DLLPRIVATE void                        SetCopyCount( sal_uInt16 nCopy, bool bCollate );
267
0
    sal_uInt16                  GetCopyCount() const { return mnCopyCount; }
268
0
    bool                        IsCollateCopy() const { return mbCollateCopy; }
269
0
    void                        SetSinglePrintJobs(bool bSinglePrintJobs) { mbSinglePrintJobs = bSinglePrintJobs; }
270
0
    bool                        IsSinglePrintJobs() const { return mbSinglePrintJobs; }
271
272
2.75k
    bool                        IsPrinting() const { return mbPrinting; }
273
274
0
    bool                        IsJobActive() const { return mbJobActive; }
275
276
    /** Checks the printer list and updates it necessary
277
278
        sends a DataChanged event of type DataChangedEventType::PRINTER if the printer list changed
279
    */
280
    static void                 updatePrinters();
281
282
    /** Execute a print job
283
284
        starts a print job asynchronously that is will return
285
    */
286
    static void                 PrintJob( const std::shared_ptr<vcl::PrinterController>& i_pController,
287
                                    const JobSetup& i_rInitSetup );
288
289
    virtual bool                HasMirroredGraphics() const override;
290
291
    virtual void                DrawOutDev( const Point& rDestPt, const Size& rDestSize,
292
                                    const Point& rSrcPt,  const Size& rSrcSize ) override;
293
294
    virtual void                DrawOutDev( const Point& rDestPt, const Size& rDestSize,
295
                                    const Point& rSrcPt,  const Size& rSrcSize,
296
                                    const OutputDevice& rOutDev ) override;
297
298
    virtual void                CopyArea( const Point& rDestPt, const Point& rSrcPt,
299
                                    const Size& rSrcSize ) override;
300
301
    virtual tools::Rectangle    GetBackgroundComponentBounds() const override;
302
303
    // These 3 together are more modular PrintJob(), allowing printing more documents as one print job
304
    // by repeated calls to ExecutePrintJob(). Used by mailmerge.
305
    SAL_DLLPRIVATE static bool                 PreparePrintJob( std::shared_ptr<vcl::PrinterController> i_pController,
306
                                    const JobSetup& i_rInitSetup );
307
    SAL_DLLPRIVATE static bool ExecutePrintJob(const std::shared_ptr<vcl::PrinterController>& i_pController);
308
    static void                 FinishPrintJob( const std::shared_ptr<vcl::PrinterController>& i_pController );
309
310
    /** Implementation detail of PrintJob being asynchronous
311
312
        not exported, not usable outside vcl
313
    */
314
    static void SAL_DLLPRIVATE  ImplPrintJob( const std::shared_ptr<vcl::PrinterController>& i_pController,
315
                                    const JobSetup& i_rInitSetup );
316
};
317
318
namespace vcl
319
{
320
class ImplPrinterControllerData;
321
322
enum class NupOrderType
323
{
324
    LRTB, TBLR, TBRL, RLTB
325
};
326
327
class VCL_DLLPUBLIC PrinterController
328
{
329
    std::unique_ptr<ImplPrinterControllerData>
330
                                        mpImplData;
331
protected:
332
    PrinterController(const VclPtr<Printer>&, weld::Window* pDialogParent);
333
public:
334
    struct MultiPageSetup
335
    {
336
        // all metrics in 100th mm
337
        int                             nRows;
338
        int                             nColumns;
339
        Size                            aPaperSize;
340
        tools::Long                            nLeftMargin;
341
        tools::Long                            nTopMargin;
342
        tools::Long                            nRightMargin;
343
        tools::Long                            nBottomMargin;
344
        tools::Long                            nHorizontalSpacing;
345
        tools::Long                            nVerticalSpacing;
346
        bool                            bDrawBorder;
347
        NupOrderType                    nOrder;
348
349
        MultiPageSetup()
350
0
             : nRows( 1 ), nColumns( 1 ), aPaperSize( 21000, 29700 )
351
0
             , nLeftMargin( 0 ), nTopMargin( 0 )
352
0
             , nRightMargin( 0 ), nBottomMargin( 0 )
353
0
             , nHorizontalSpacing( 0 ), nVerticalSpacing( 0 )
354
0
             , bDrawBorder( false )
355
0
             , nOrder( NupOrderType::LRTB ) {}
356
    };
357
358
    struct PageSize
359
    {
360
        /// In 100th mm
361
        Size                            aSize;
362
363
        /// Full paper, not only imageable area is printed
364
        bool                            bFullPaper;
365
366
                                        PageSize( const Size& i_rSize = Size( 21000, 29700 ),
367
                                            bool i_bFullPaper = false)
368
0
                                            : aSize( i_rSize ), bFullPaper( i_bFullPaper ) {}
369
    };
370
371
    virtual ~PrinterController();
372
373
    const VclPtr<Printer>&              getPrinter() const;
374
    SAL_DLLPRIVATE weld::Window*        getWindow() const;
375
376
    /** For implementations: get current job properties as changed by e.g. print dialog
377
378
        this gets the current set of properties initially told to Printer::PrintJob
379
380
        For convenience a second sequence will be merged in to get a combined sequence.
381
        In case of duplicate property names, the value of i_MergeList wins.
382
    */
383
    css::uno::Sequence< css::beans::PropertyValue >
384
                                        getJobProperties(const css::uno::Sequence< css::beans::PropertyValue >& i_rMergeList ) const;
385
386
    /// Get the PropertyValue of a Property
387
    css::beans::PropertyValue*          getValue( const OUString& i_rPropertyName );
388
    const css::beans::PropertyValue*    getValue( const OUString& i_rPropertyName ) const;
389
390
    /** Get a bool property
391
392
        in case the property is unknown or not convertible to bool, i_bFallback is returned
393
    */
394
    SAL_DLLPRIVATE bool                 getBoolProperty( const OUString& i_rPropertyName, bool i_bFallback ) const;
395
396
    /** Get an int property
397
398
        in case the property is unknown or not convertible to bool, i_nFallback is returned
399
    */
400
    SAL_DLLPRIVATE sal_Int32            getIntProperty( const OUString& i_rPropertyName, sal_Int32 i_nFallback ) const;
401
402
    /// Set a property value - can also be used to add another UI property
403
    void                                setValue( const OUString& i_rPropertyName, const css::uno::Any& i_rValue );
404
    SAL_DLLPRIVATE void                 setValue( const css::beans::PropertyValue& i_rValue );
405
406
    /** @return The currently active UI options. These are the same that were passed to setUIOptions. */
407
    const css::uno::Sequence< css::beans::PropertyValue >&
408
                                        getUIOptions() const;
409
410
    /** Set possible UI options.
411
412
        should only be done once before passing the PrinterListener to Printer::PrintJob
413
    */
414
    void                                setUIOptions( const css::uno::Sequence< css::beans::PropertyValue >& );
415
416
    /// Enable/disable an option; this can be used to implement dialog logic.
417
    bool                                isUIOptionEnabled( const OUString& rPropName ) const;
418
    SAL_DLLPRIVATE bool                 isUIChoiceEnabled( const OUString& rPropName, sal_Int32 nChoice ) const;
419
420
    /// Defines which options in a UI element should be disabled or enabled.
421
    void                                setUIChoicesDisabled(const OUString& rPropName, css::uno::Sequence<sal_Bool>& rChoicesDisabled);
422
423
    /** MakeEnabled will change the property rPropName depends on to the value
424
425
        that makes rPropName enabled. If the dependency itself is also disabled,
426
        no action will be performed.
427
428
        @return The property name rPropName depends on or an empty string if no change was made.
429
    */
430
    SAL_DLLPRIVATE OUString             makeEnabled( const OUString& rPropName );
431
432
    /// App must override this
433
    virtual int                         getPageCount() const = 0;
434
435
    /** Get the page parameters
436
437
        namely the jobsetup that should be active for the page
438
        (describing among others the physical page size) and the "page size". In writer
439
        case this would probably be the same as the JobSetup since writer sets the page size
440
        draw/impress for example print their page on the paper set on the printer,
441
        possibly adjusting the page size to fit. That means the page size can be different from
442
        the paper size.
443
444
        App must override this
445
446
        @return Page size in 1/100th mm
447
    */
448
    virtual css::uno::Sequence< css::beans::PropertyValue >
449
                                        getPageParameters( int i_nPage ) const = 0;
450
    /// App must override this
451
    virtual void                        printPage(int i_nPage) const = 0;
452
453
    /// Will be called after a possible dialog has been shown and the real printjob starts
454
    SAL_DLLPRIVATE virtual void         jobStarted();
455
    SAL_DLLPRIVATE virtual void         jobFinished( css::view::PrintableState );
456
457
    SAL_DLLPRIVATE css::view::PrintableState getJobState() const;
458
459
    SAL_DLLPRIVATE void                 abortJob();
460
461
    bool                                isShowDialogs() const;
462
    bool                                isDirectPrint() const;
463
464
    void                                dialogsParentClosing();
465
466
    // implementation details, not usable outside vcl
467
    // don't use outside vcl. Some of these are exported for
468
    // the benefit of vcl's plugins.
469
    // Still: DO NOT USE OUTSIDE VCL
470
                      int               getFilteredPageCount() const;
471
    SAL_DLLPRIVATE    PageSize          getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf,
472
                                            bool i_bMayUseCache = false );
473
    PageSize                            getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf,
474
                                            bool i_bMayUseCache = false );
475
                      void              printFilteredPage( int i_nPage );
476
    SAL_DLLPRIVATE    void              setPrinter( const VclPtr<Printer>& );
477
    SAL_DLLPRIVATE    void              createProgressDialog();
478
    SAL_DLLPRIVATE    bool              isProgressCanceled() const;
479
    SAL_DLLPRIVATE    void              setMultipage( const MultiPageSetup& );
480
    SAL_DLLPRIVATE    const MultiPageSetup&
481
                                        getMultipage() const;
482
                      void              setLastPage( bool i_bLastPage );
483
    SAL_DLLPRIVATE    void              setReversePrint( bool i_bReverse );
484
    SAL_DLLPRIVATE    void              setPapersizeFromSetup( bool i_bPapersizeFromSetup );
485
    SAL_DLLPRIVATE    bool              getPapersizeFromSetup() const;
486
    SAL_DLLPRIVATE    void              setPaperSizeFromUser( Size i_aUserSize );
487
    SAL_DLLPRIVATE    void              setOrientationFromUser( Orientation eOrientation, bool set );
488
                      void              setPrinterModified( bool i_bPapersizeFromSetup );
489
    SAL_DLLPRIVATE    bool              getPrinterModified() const;
490
    SAL_DLLPRIVATE    void              pushPropertiesToPrinter();
491
    SAL_DLLPRIVATE    void              resetPaperToLastConfigured();
492
                      void              setJobState( css::view::PrintableState );
493
    SAL_DLLPRIVATE    void              setupPrinter( weld::Window* i_pDlgParent );
494
495
    SAL_DLLPRIVATE    int               getPageCountProtected() const;
496
    SAL_DLLPRIVATE    css::uno::Sequence< css::beans::PropertyValue >
497
                                        getPageParametersProtected( int i_nPage ) const;
498
499
    SAL_DLLPRIVATE    DrawModeFlags     removeTransparencies( GDIMetaFile const & i_rIn, GDIMetaFile& o_rOut );
500
    SAL_DLLPRIVATE    void              resetPrinterOptions( bool i_bFileOutput );
501
502
    SAL_DLLPRIVATE    void              invalidatePageCache();
503
};
504
505
class VCL_DLLPUBLIC PrinterOptionsHelper
506
{
507
protected:
508
    std::unordered_map< OUString, css::uno::Any >
509
                         m_aPropertyMap;
510
    std::vector< css::beans::PropertyValue >
511
                         m_aUIProperties;
512
513
public:
514
515
                         /// Create without ui properties
516
4.14k
                         PrinterOptionsHelper() {}
517
518
    /** Process a new set of properties
519
520
        merges changed properties and returns "true" if any occurred
521
    */
522
    bool                 processProperties( const css::uno::Sequence< css::beans::PropertyValue >& i_rNewProp );
523
524
    /** Append to a sequence of property values the ui property sequence passed at creation
525
526
        as the "ExtraPrintUIOptions" property. if that sequence was empty, no "ExtraPrintUIOptions" property
527
        will be appended.
528
    */
529
    void                 appendPrintUIOptions( css::uno::Sequence< css::beans::PropertyValue >& io_rProps ) const;
530
531
    /** @return An empty Any for not existing properties */
532
    css::uno::Any        getValue( const OUString& i_rPropertyName ) const;
533
534
    bool                 getBoolValue( const OUString& i_rPropertyName, bool i_bDefault ) const;
535
    // convenience for fixed strings
536
    bool                 getBoolValue( const char* i_pPropName, bool i_bDefault = false ) const
537
545k
                             { return getBoolValue( OUString::createFromAscii( i_pPropName ), i_bDefault ); }
538
539
    sal_Int64            getIntValue( const OUString& i_rPropertyName, sal_Int64 i_nDefault ) const;
540
    // convenience for fixed strings
541
    sal_Int64            getIntValue( const char* i_pPropName, sal_Int64 i_nDefault ) const
542
41.4k
                             { return getIntValue( OUString::createFromAscii( i_pPropName ), i_nDefault ); }
543
544
    OUString             getStringValue( const OUString& i_rPropertyName ) const;
545
    // convenience for fixed strings
546
    OUString             getStringValue( const char* i_pPropName ) const
547
62.5k
                             { return getStringValue( OUString::createFromAscii( i_pPropName ) ); }
548
549
    // helper functions for user to create a single control
550
    struct UIControlOptions
551
    {
552
        OUString         maDependsOnName;
553
        OUString         maGroupHint;
554
        std::vector< css::beans::PropertyValue >
555
                         maAddProps;
556
        sal_Int32        mnDependsOnEntry;
557
        bool             mbAttachToDependency;
558
        bool             mbInternalOnly;
559
        bool             mbEnabled;
560
561
                         UIControlOptions( OUString i_DependsOnName = OUString(),
562
                             sal_Int32 i_nDependsOnEntry = -1, bool i_bAttachToDependency = false)
563
0
                             : maDependsOnName(std::move( i_DependsOnName ))
564
0
                             , mnDependsOnEntry( i_nDependsOnEntry )
565
0
                             , mbAttachToDependency( i_bAttachToDependency )
566
0
                             , mbInternalOnly( false )
567
0
                             , mbEnabled( true ) {}
568
    };
569
570
    // note: in the following helper functions HelpIds are expected as an OUString
571
    // the normal HelpId form is OString (byte string instead of UTF16 string)
572
    // this is because the whole interface is base on UNO properties; in fact the structures
573
    // are passed over UNO interfaces. UNO does not know a byte string, hence the string is
574
    // transported via UTF16 strings.
575
576
    /// Show general control
577
    static css::uno::Any setUIControlOpt( const css::uno::Sequence< OUString >& i_rIDs, const OUString& i_rTitle,
578
                             const css::uno::Sequence< OUString >& i_rHelpId, const OUString& i_rType,
579
                             const css::beans::PropertyValue* i_pValue = nullptr,
580
                             const UIControlOptions& i_rControlOptions = UIControlOptions());
581
582
    /// Show and set the title of a TagPage of id i_rID
583
    static css::uno::Any setGroupControlOpt( const OUString& i_rID, const OUString& i_rTitle,
584
                             const OUString& i_rHelpId);
585
586
    /// Show and set the label of a VclFrame of id i_rID
587
    static css::uno::Any setSubgroupControlOpt( const OUString& i_rID, const OUString& i_rTitle, const OUString& i_rHelpId,
588
                             const UIControlOptions& i_rControlOptions = UIControlOptions());
589
590
    /// Show a bool option as a checkbox
591
    static css::uno::Any setBoolControlOpt( const OUString& i_rID, const OUString& i_rTitle, const OUString& i_rHelpId,
592
                             const OUString& i_rProperty, bool i_bValue,
593
                             const UIControlOptions& i_rControlOptions = UIControlOptions());
594
595
    /// Show a set of choices in a list box
596
    static css::uno::Any setChoiceListControlOpt( const OUString&  i_rID, const OUString& i_rTitle,
597
                             const css::uno::Sequence< OUString >& i_rHelpId, const OUString& i_rProperty,
598
                             const css::uno::Sequence< OUString >& i_rChoices, sal_Int32 i_nValue,
599
                             const css::uno::Sequence< sal_Bool >& i_rDisabledChoices = css::uno::Sequence< sal_Bool >(),
600
                             const UIControlOptions& i_rControlOptions = UIControlOptions());
601
602
    /// Show a set of choices as radio buttons
603
    static css::uno::Any setChoiceRadiosControlOpt( const css::uno::Sequence< OUString >& i_rIDs,
604
                             const OUString& i_rTitle,  const css::uno::Sequence< OUString >& i_rHelpId,
605
                             const OUString& i_rProperty, const css::uno::Sequence< OUString >& i_rChoices,
606
                             sal_Int32 i_nValue,
607
                             const css::uno::Sequence< sal_Bool >& i_rDisabledChoices = css::uno::Sequence< sal_Bool >(),
608
                             const UIControlOptions& i_rControlOptions  = UIControlOptions());
609
610
    /** Show an integer range (e.g. a spin field)
611
612
        note: max value < min value means do not apply min/max values
613
    */
614
    static css::uno::Any setRangeControlOpt( const OUString& i_rID, const OUString& i_rTitle, const OUString& i_rHelpId,
615
                             const OUString& i_rProperty, sal_Int32 i_nValue, sal_Int32 i_nMinValue,
616
                             sal_Int32 i_nMaxValue, const UIControlOptions& i_rControlOptions);
617
618
    /** Show a string field
619
620
        note: max value < min value means do not apply min/max values
621
    */
622
    static css::uno::Any setEditControlOpt( const OUString& i_rID, const OUString& i_rTitle, const OUString& i_rHelpId,
623
                             const OUString&  i_rProperty, const OUString& i_rValue,
624
                             const UIControlOptions& i_rControlOptions);
625
}; // class PrinterOptionsHelper
626
627
} // namespace vcl
628
629
630
#endif // INCLUDED_VCL_PRINT_HXX
631
632
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */