1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_PRINT_HXX
21 #define INCLUDED_VCL_PRINT_HXX
23 #include <rtl/ustring.hxx>
25 #include <tools/errcode.hxx>
26 #include <tools/solar.h>
27 #include <vcl/dllapi.h>
28 #include <vcl/outdev.hxx>
29 #include <vcl/prntypes.hxx>
30 #include <vcl/jobset.hxx>
31 #include <vcl/gdimtf.hxx>
32 #include <tools/stream.hxx>
33 #include <tools/multisel.hxx>
35 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <com/sun/star/view/PrintableState.hpp>
40 #include <unordered_map>
43 struct SalPrinterQueueInfo
;
46 namespace vcl
{ class Window
; }
49 class PrinterController
;
55 enum PrinterSupport
{ SUPPORT_SET_ORIENTATION
, SUPPORT_SET_PAPERBIN
,
56 SUPPORT_SET_PAPERSIZE
, SUPPORT_SET_PAPER
,
57 SUPPORT_COPY
, SUPPORT_COLLATECOPY
,
58 SUPPORT_SETUPDIALOG
, SUPPORT_FAX
, SUPPORT_PDF
};
61 class VCL_DLLPUBLIC PrinterPage
69 PrinterPage() : mpMtf( new GDIMetaFile() ) {}
70 PrinterPage( GDIMetaFile
* pMtf
, bool bNewJobSetup
, const JobSetup
& rSetup
) :
71 mpMtf( pMtf
), maJobSetup( rSetup
), mbNewJobSetup( bNewJobSetup
) {}
72 ~PrinterPage() { delete mpMtf
; }
74 GDIMetaFile
* GetGDIMetaFile() const { return mpMtf
; }
75 const JobSetup
& GetJobSetup() const { return maJobSetup
; }
76 bool IsNewJobSetup() const { return mbNewJobSetup
; }
81 class VCL_DLLPUBLIC QueueInfo
86 OUString maPrinterName
;
90 PrintQueueFlags mnStatus
;
95 QueueInfo( const QueueInfo
& rInfo
);
98 const OUString
& GetPrinterName() const { return maPrinterName
; }
99 const OUString
& GetDriver() const { return maDriver
; }
100 const OUString
& GetLocation() const { return maLocation
; }
101 const OUString
& GetComment() const { return maComment
; }
102 PrintQueueFlags
GetStatus() const { return mnStatus
; }
103 sal_uInt32
GetJobs() const { return mnJobs
; }
105 bool operator==( const QueueInfo
& rInfo
) const;
107 friend VCL_DLLPUBLIC SvStream
& ReadQueueInfo( SvStream
& rIStream
, QueueInfo
& rInfo
);
108 friend VCL_DLLPUBLIC SvStream
& WriteQueueInfo( SvStream
& rOStream
, const QueueInfo
& rInfo
);
112 enum PrinterTransparencyMode
114 PRINTER_TRANSPARENCY_AUTO
= 0,
115 PRINTER_TRANSPARENCY_NONE
= 1
120 enum PrinterGradientMode
122 PRINTER_GRADIENT_STRIPES
= 0,
123 PRINTER_GRADIENT_COLOR
= 1
128 enum PrinterBitmapMode
130 PRINTER_BITMAP_OPTIMAL
= 0,
131 PRINTER_BITMAP_NORMAL
= 1,
132 PRINTER_BITMAP_RESOLUTION
= 2
137 class VCL_DLLPUBLIC PrinterOptions
141 bool mbReduceTransparency
;
142 PrinterTransparencyMode meReducedTransparencyMode
;
143 bool mbReduceGradients
;
144 PrinterGradientMode meReducedGradientsMode
;
145 sal_uInt16 mnReducedGradientStepCount
;
146 bool mbReduceBitmaps
;
147 PrinterBitmapMode meReducedBitmapMode
;
148 sal_uInt16 mnReducedBitmapResolution
;
149 bool mbReducedBitmapsIncludeTransparency
;
150 bool mbConvertToGreyscales
;
151 bool mbPDFAsStandardPrintJobFormat
;
158 bool IsReduceTransparency() const { return mbReduceTransparency
; }
159 void SetReduceTransparency( bool bSet
) { mbReduceTransparency
= bSet
; }
161 PrinterTransparencyMode
GetReducedTransparencyMode() const { return meReducedTransparencyMode
; }
162 void SetReducedTransparencyMode( PrinterTransparencyMode eMode
) { meReducedTransparencyMode
= eMode
; }
164 bool IsReduceGradients() const { return mbReduceGradients
; }
165 void SetReduceGradients( bool bSet
) { mbReduceGradients
= bSet
; }
167 PrinterGradientMode
GetReducedGradientMode() const { return meReducedGradientsMode
; }
168 void SetReducedGradientMode( PrinterGradientMode eMode
) { meReducedGradientsMode
= eMode
; }
170 sal_uInt16
GetReducedGradientStepCount() const { return mnReducedGradientStepCount
; }
171 void SetReducedGradientStepCount( sal_uInt16 nStepCount
) { mnReducedGradientStepCount
= nStepCount
; }
173 bool IsReduceBitmaps() const { return mbReduceBitmaps
; }
174 void SetReduceBitmaps( bool bSet
) { mbReduceBitmaps
= bSet
; }
176 PrinterBitmapMode
GetReducedBitmapMode() const { return meReducedBitmapMode
; }
177 void SetReducedBitmapMode( PrinterBitmapMode eMode
) { meReducedBitmapMode
= eMode
; }
179 sal_uInt16
GetReducedBitmapResolution() const { return mnReducedBitmapResolution
; }
180 void SetReducedBitmapResolution( sal_uInt16 nResolution
) { mnReducedBitmapResolution
= nResolution
; }
182 bool IsReducedBitmapIncludesTransparency() const { return mbReducedBitmapsIncludeTransparency
; }
183 void SetReducedBitmapIncludesTransparency( bool bSet
) { mbReducedBitmapsIncludeTransparency
= bSet
; }
185 bool IsConvertToGreyscales() const { return mbConvertToGreyscales
; }
186 void SetConvertToGreyscales( bool bSet
) { mbConvertToGreyscales
= bSet
; }
188 bool IsPDFAsStandardPrintJobFormat() const { return mbPDFAsStandardPrintJobFormat
; }
189 void SetPDFAsStandardPrintJobFormat( bool bSet
) { mbPDFAsStandardPrintJobFormat
= bSet
; }
191 // read printer options from configuration, parameter decides whether the set for
192 // print "to printer" or "to file" should be read.
193 // returns true if config was read, false if an error occurred
194 bool ReadFromConfig( bool bFile
);
198 class VCL_DLLPUBLIC Printer
: public OutputDevice
200 friend class ::OutputDevice
;
203 SalInfoPrinter
* mpInfoPrinter
;
204 SalPrinter
* mpPrinter
;
205 SalGraphics
* mpJobGraphics
;
206 VclPtr
<Printer
> mpPrev
;
207 VclPtr
<Printer
> mpNext
;
208 VclPtr
<VirtualDevice
> mpDisplayDev
;
209 PrinterOptions
* mpPrinterOptions
;
210 OUString maPrinterName
;
212 OUString maPrintFile
;
218 sal_uInt16 mnCurPage
;
219 sal_uInt16 mnCurPrintPage
;
220 sal_uInt16 mnPageQueueSize
;
221 sal_uInt16 mnCopyCount
;
229 bool mbIsQueuePrinter
;
232 SAL_DLLPRIVATE
void ImplInitData();
233 SAL_DLLPRIVATE
void ImplInit( SalPrinterQueueInfo
* pInfo
);
234 SAL_DLLPRIVATE
void ImplInitDisplay( const vcl::Window
* pWindow
);
235 SAL_DLLPRIVATE
static SalPrinterQueueInfo
* ImplGetQueueInfo( const OUString
& rPrinterName
,
236 const OUString
* pDriver
);
237 SAL_DLLPRIVATE
void ImplUpdatePageData();
238 SAL_DLLPRIVATE
void ImplUpdateFontList();
239 SAL_DLLPRIVATE
void ImplFindPaperFormatForUserSize( JobSetup
&, bool bMatchNearest
);
241 SAL_DLLPRIVATE
bool StartJob( const OUString
& rJobName
, std::shared_ptr
<vcl::PrinterController
>& );
243 static SAL_DLLPRIVATE sal_uLong
ImplSalPrinterErrorCodeToVCL( sal_uLong nError
);
246 SAL_DLLPRIVATE
bool EndJob();
247 Printer( const Printer
& rPrinter
) SAL_DELETED_FUNCTION
;
248 Printer
& operator =( const Printer
& rPrinter
) SAL_DELETED_FUNCTION
;
251 SAL_DLLPRIVATE
void ImplStartPage();
252 SAL_DLLPRIVATE
void ImplEndPage();
255 virtual bool AcquireGraphics() const SAL_OVERRIDE
;
256 virtual void ReleaseGraphics( bool bRelease
= true ) SAL_OVERRIDE
;
257 virtual void ImplReleaseFonts() SAL_OVERRIDE
;
259 virtual long GetGradientStepCount( long nMinRect
) SAL_OVERRIDE
;
260 virtual bool UsePolyPolygonForComplexGradient() SAL_OVERRIDE
;
261 virtual void ClipAndDrawGradientMetafile ( const Gradient
&rGradient
, const tools::PolyPolygon
&rPolyPoly
) SAL_OVERRIDE
;
263 void ScaleBitmap ( Bitmap
&, SalTwoRect
& ) SAL_OVERRIDE
{ };
266 void DrawGradientEx( OutputDevice
* pOut
, const Rectangle
& rRect
, const Gradient
& rGradient
);
267 virtual Bitmap
GetBitmap( const Point
& rSrcPt
, const Size
& rSize
) const SAL_OVERRIDE
;
271 void SetSelfAsQueuePrinter( bool bQueuePrinter
) { mbIsQueuePrinter
= bQueuePrinter
; }
272 bool IsQueuePrinter() const { return mbIsQueuePrinter
; }
273 virtual void DrawDeviceMask ( const Bitmap
& rMask
, const Color
& rMaskColor
,
274 const Point
& rDestPt
, const Size
& rDestSize
,
275 const Point
& rSrcPtPixel
, const Size
& rSrcSizePixel
) SAL_OVERRIDE
;
277 bool DrawTransformBitmapExDirect(
278 const basegfx::B2DHomMatrix
& aFullTransform
,
279 const BitmapEx
& rBitmapEx
) SAL_OVERRIDE
;
281 bool TransformAndReduceBitmapExToTargetRange(
282 const basegfx::B2DHomMatrix
& aFullTransform
,
283 basegfx::B2DRange
&aVisibleRange
,
284 double &fMaximumArea
) SAL_OVERRIDE
;
286 void DrawDeviceBitmap(
287 const Point
& rDestPt
, const Size
& rDestSize
,
288 const Point
& rSrcPtPixel
, const Size
& rSrcSizePixel
,
289 BitmapEx
& rBitmapEx
) SAL_OVERRIDE
;
291 virtual void EmulateDrawTransparent( const tools::PolyPolygon
& rPolyPoly
, sal_uInt16 nTransparencePercent
) SAL_OVERRIDE
;
293 virtual void InitFont() const SAL_OVERRIDE
;
294 virtual void SetFontOrientation( ImplFontEntry
* const pFontEntry
) const SAL_OVERRIDE
;
298 Printer( const JobSetup
& rJobSetup
);
299 Printer( const QueueInfo
& rQueueInfo
);
300 Printer( const OUString
& rPrinterName
);
302 virtual void dispose() SAL_OVERRIDE
;
304 static const std::vector
< OUString
>& GetPrinterQueues();
305 static const QueueInfo
* GetQueueInfo( const OUString
& rPrinterName
, bool bStatusUpdate
);
306 static OUString
GetDefaultPrinterName();
310 const OUString
& GetName() const { return maPrinterName
; }
311 const OUString
& GetDriverName() const { return maDriver
; }
312 bool IsDefPrinter() const { return mbDefPrinter
; }
313 void SetDefPrinter(bool bDef
) { mbDefPrinter
= bDef
; }
314 bool IsDisplayPrinter() const { return mpDisplayDev
!= nullptr; }
315 bool IsValid() const { return !IsDisplayPrinter(); }
317 sal_uLong
GetCapabilities( sal_uInt16 nType
) const;
318 bool HasSupport( PrinterSupport eFeature
) const;
320 bool SetJobSetup( const JobSetup
& rSetup
);
321 const JobSetup
& GetJobSetup() const { return maJobSetup
; }
323 bool Setup( vcl::Window
* pWindow
= NULL
, bool bPapersizeFromSetup
= false );
324 bool SetPrinterProps( const Printer
* pPrinter
);
326 // SetPrinterOptions is used internally only now
327 // in earlier times it was used only to set the options loaded directly from the configuration
328 // in SfxPrinter::InitJob, this is now handled internally
329 // should the need arise to set the printer options outside vcl, also a method would have to be devised
330 // to not override these again internally
331 SAL_DLLPRIVATE
void SetPrinterOptions( const PrinterOptions
& rOptions
);
332 const PrinterOptions
& GetPrinterOptions() const { return( *mpPrinterOptions
); }
334 bool SetOrientation( Orientation eOrient
);
335 Orientation
GetOrientation() const;
336 bool SetDuplexMode( DuplexMode
);
337 // returns the angle that a landscape page will be turned counterclockwise
338 // wrt to portrait. The return value may be only valid for
340 int GetLandscapeAngle() const;
341 bool SetPaperBin( sal_uInt16 nPaperBin
);
342 sal_uInt16
GetPaperBin() const;
343 bool SetPaper( Paper ePaper
);
344 bool SetPaperSizeUser( const Size
& rSize
);
345 bool SetPaperSizeUser( const Size
& rSize
, bool bMatchNearest
);
346 Paper
GetPaper() const;
347 static OUString
GetPaperName( Paper ePaper
);
348 // return a UI string for the current paper; i_bPaperUser == false means an empty string for PAPER_USER
349 OUString
GetPaperName( bool i_bPaperUser
= true ) const;
351 // returns number of available paper formats
352 int GetPaperInfoCount() const;
353 // returns info about paper format nPaper
354 const PaperInfo
& GetPaperInfo( int nPaper
) const;
355 sal_uInt16
GetPaperBinCount() const;
356 OUString
GetPaperBinName( sal_uInt16 nPaperBin
) const;
358 const Size
& GetPaperSizePixel() const { return maPaperSize
; }
359 Size
GetPaperSize() const { return PixelToLogic( maPaperSize
); }
360 const Point
& GetPageOffsetPixel() const { return maPageOffset
; }
361 Point
GetPageOffset() const { return PixelToLogic( maPageOffset
); }
363 bool SetCopyCount( sal_uInt16 nCopy
, bool bCollate
= false );
364 sal_uInt16
GetCopyCount() const { return mnCopyCount
; }
365 bool IsCollateCopy() const { return mbCollateCopy
; }
367 bool IsPrinting() const { return mbPrinting
; }
369 const OUString
& GetCurJobName() const { return maJobName
; }
370 sal_uInt16
GetCurPage() const { return mnCurPage
; }
371 bool IsJobActive() const { return mbJobActive
; }
373 sal_uLong
GetError() const { return ERRCODE_TOERROR(mnError
); }
374 sal_uLong
GetErrorCode() const { return mnError
; }
376 void SetErrorHdl( const Link
<>& rLink
) { maErrorHdl
= rLink
; }
377 const Link
<>& GetErrorHdl() const { return maErrorHdl
; }
379 /** checks the printer list and updates it necessary
381 * sends a DataChanged event of type DataChangedEventType::PRINTER
382 * if the printer list changed
384 static void updatePrinters();
386 /** execute a print job
388 starts a print job asynchronously (that is will return
391 static void PrintJob( const std::shared_ptr
<vcl::PrinterController
>& i_pController
,
392 const JobSetup
& i_rInitSetup
);
394 virtual bool HasMirroredGraphics() const SAL_OVERRIDE
;
396 virtual void DrawOutDev( const Point
& rDestPt
, const Size
& rDestSize
,
397 const Point
& rSrcPt
, const Size
& rSrcSize
) SAL_OVERRIDE
;
398 virtual void DrawOutDev( const Point
& rDestPt
, const Size
& rDestSize
,
399 const Point
& rSrcPt
, const Size
& rSrcSize
,
400 const OutputDevice
& rOutDev
) SAL_OVERRIDE
;
401 virtual void CopyArea( const Point
& rDestPt
,
402 const Point
& rSrcPt
, const Size
& rSrcSize
,
403 bool bWindowInvalidate
= false ) SAL_OVERRIDE
;
405 virtual void DrawImage( const Point
&, const Image
&, DrawImageFlags
) SAL_OVERRIDE
;
406 virtual void DrawImage( const Point
&, const Size
&,
407 const Image
&, DrawImageFlags
) SAL_OVERRIDE
;
410 // These 3 together are more modular PrintJob(), allowing printing more documents as one print job
411 // by repeated calls to ExecutePrintJob(). Used by mailmerge.
412 static bool PreparePrintJob( std::shared_ptr
<vcl::PrinterController
> i_pController
,
413 const JobSetup
& i_rInitSetup
);
414 static bool ExecutePrintJob( std::shared_ptr
<vcl::PrinterController
> i_pController
);
415 static void FinishPrintJob( std::shared_ptr
<vcl::PrinterController
> i_pController
);
417 // implementation detail of PrintJob being asynchronous
418 // not exported, not usable outside vcl
419 static void SAL_DLLPRIVATE
ImplPrintJob( std::shared_ptr
<vcl::PrinterController
> i_pController
,
420 const JobSetup
& i_rInitSetup
);
425 class ImplPrinterControllerData
;
427 class VCL_DLLPUBLIC PrinterController
429 ImplPrinterControllerData
* mpImplData
;
431 PrinterController( const VclPtr
<Printer
>& );
434 { LRTB
, TBLR
, TBRL
, RLTB
};
435 struct MultiPageSetup
437 // all metrics in 100th mm
446 long nHorizontalSpacing
;
447 long nVerticalSpacing
;
449 PrinterController::NupOrderType nOrder
;
452 : nRows( 1 ), nColumns( 1 ), nRepeat( 1 ), aPaperSize( 21000, 29700 )
453 , nLeftMargin( 0 ), nTopMargin( 0 )
454 , nRightMargin( 0 ), nBottomMargin( 0 )
455 , nHorizontalSpacing( 0 ), nVerticalSpacing( 0 )
456 , bDrawBorder( false )
464 Size aSize
; // in 100th mm
465 bool bFullPaper
; // full paper, not only imageable area is printed
467 PageSize( const Size
& i_rSize
= Size( 21000, 29700 ),
468 bool i_bFullPaper
= false
469 ) : aSize( i_rSize
), bFullPaper( i_bFullPaper
) {}
472 virtual ~PrinterController();
474 const VclPtr
<Printer
>& getPrinter() const;
475 /* for implementations: get current job properties as changed by e.g. print dialog
476 this gets the current set of properties initially told to Printer::PrintJob
478 For convenience a second sequence will be merged in to get a combined sequence.
479 In case of duplicate property names, the value of i_MergeList wins.
481 css::uno::Sequence
< css::beans::PropertyValue
>
482 getJobProperties( const css::uno::Sequence
< css::beans::PropertyValue
>& i_rMergeList
) const;
484 /* get the PropertyValue of a Property
486 css::beans::PropertyValue
* getValue( const OUString
& i_rPropertyName
);
487 const css::beans::PropertyValue
* getValue( const OUString
& i_rPropertyName
) const;
488 /* get a bool property
489 in case the property is unknown or not convertible to bool, i_bFallback is returned
491 bool getBoolProperty( const OUString
& i_rPropertyName
, bool i_bFallback
) const;
492 /* get an int property
493 in case the property is unknown or not convertible to bool, i_nFallback is returned
495 sal_Int32
getIntProperty( const OUString
& i_rPropertyName
, sal_Int32 i_nFallback
) const;
497 /* set a property value - can also be used to add another UI property
499 void setValue( const OUString
& i_rPropertyName
, const css::uno::Any
& i_rValue
);
500 void setValue( const css::beans::PropertyValue
& i_rValue
);
502 /* return the currently active UI options. These are the same that were passed to setUIOptions.
504 const css::uno::Sequence
< css::beans::PropertyValue
>& getUIOptions() const;
505 /* set possible UI options. should only be done once before passing the PrinterListener
508 void setUIOptions( const css::uno::Sequence
< css::beans::PropertyValue
>& );
509 /* enable/disable an option; this can be used to implement dialog logic.
511 bool isUIOptionEnabled( const OUString
& rPropName
) const;
512 bool isUIChoiceEnabled( const OUString
& rPropName
, sal_Int32 nChoice
) const;
513 /* returns the property name rPropName depends on or an empty string
514 if no dependency exists.
516 OUString
getDependency( const OUString
& rPropName
) const;
517 /* makeEnabled will chage the property rPropName depends on to the value
518 that makes rPropName enabled. If the dependency itself is also disabled,
519 no action will be performed.
521 returns the property name rPropName depends on or an empty string
522 if no change was made.
524 OUString
makeEnabled( const OUString
& rPropName
);
526 virtual int getPageCount() const = 0; /// App must override this
527 /* get the page parameters, namely the jobsetup that should be active for the page
528 (describing among others the physical page size) and the "page size". In writer
529 case this would probably be the same as the JobSetup since writer sets the page size
530 draw/impress for example print their page on the paper set on the printer,
531 possibly adjusting the page size to fit. That means the page size can be different from
533 App must override this, return page size in 1/100th mm
535 virtual css::uno::Sequence
< css::beans::PropertyValue
> getPageParameters( int i_nPage
) const = 0;
536 virtual void printPage(int i_nPage
) const = 0; /// App must override this
537 virtual void jobStarted(); // will be called after a possible dialog has been shown and the real printjob starts
538 virtual void jobFinished( com::sun::star::view::PrintableState
);
540 com::sun::star::view::PrintableState
getJobState() const;
544 bool isShowDialogs() const;
545 bool isDirectPrint() const;
547 // implementation details, not usable outside vcl
548 // don't use outside vcl. Some of these are exported for
549 // the benefit of vcl's plugins.
550 // Still: DO NOT USE OUTSIDE VCL
551 VCL_PLUGIN_PUBLIC
int getFilteredPageCount();
552 SAL_DLLPRIVATE PageSize
getPageFile( int i_inUnfilteredPage
, GDIMetaFile
& rMtf
, bool i_bMayUseCache
= false );
553 VCL_PLUGIN_PUBLIC PageSize
getFilteredPageFile( int i_nFilteredPage
, GDIMetaFile
& o_rMtf
, bool i_bMayUseCache
= false );
554 VCL_PLUGIN_PUBLIC
void printFilteredPage( int i_nPage
);
555 SAL_DLLPRIVATE
void setPrinter( const VclPtr
<Printer
>& );
556 SAL_DLLPRIVATE
void setOptionChangeHdl( const Link
<>& );
557 VCL_PLUGIN_PUBLIC
void createProgressDialog();
558 VCL_PLUGIN_PUBLIC
bool isProgressCanceled() const;
559 SAL_DLLPRIVATE
void setMultipage( const MultiPageSetup
& );
560 SAL_DLLPRIVATE
const MultiPageSetup
& getMultipage() const;
561 VCL_PLUGIN_PUBLIC
void setLastPage( bool i_bLastPage
);
562 SAL_DLLPRIVATE
void setReversePrint( bool i_bReverse
);
563 SAL_DLLPRIVATE
bool getReversePrint() const;
564 SAL_DLLPRIVATE
void setPapersizeFromSetup( bool i_bPapersizeFromSetup
);
565 SAL_DLLPRIVATE
bool getPapersizeFromSetup() const;
566 VCL_PLUGIN_PUBLIC
void setPrinterModified( bool i_bPapersizeFromSetup
);
567 VCL_PLUGIN_PUBLIC
bool getPrinterModified() const;
568 SAL_DLLPRIVATE
void pushPropertiesToPrinter();
569 SAL_DLLPRIVATE
void resetPaperToLastConfigured();
570 VCL_PLUGIN_PUBLIC
void setJobState( com::sun::star::view::PrintableState
);
571 SAL_DLLPRIVATE
bool setupPrinter( vcl::Window
* i_pDlgParent
);
573 SAL_DLLPRIVATE
int getPageCountProtected() const;
574 SAL_DLLPRIVATE
css::uno::Sequence
< css::beans::PropertyValue
> getPageParametersProtected( int i_nPage
) const;
576 SAL_DLLPRIVATE DrawModeFlags
removeTransparencies( GDIMetaFile
& i_rIn
, GDIMetaFile
& o_rOut
);
577 SAL_DLLPRIVATE
void resetPrinterOptions( bool i_bFileOutput
);
580 class VCL_DLLPUBLIC PrinterOptionsHelper
583 std::unordered_map
< OUString
, css::uno::Any
, OUStringHash
> m_aPropertyMap
;
584 css::uno::Sequence
< css::beans::PropertyValue
> m_aUIProperties
;
587 PrinterOptionsHelper() {} // create without ui properties
588 PrinterOptionsHelper( const css::uno::Sequence
< css::beans::PropertyValue
>& i_rUIProperties
)
589 : m_aUIProperties( i_rUIProperties
)
591 ~PrinterOptionsHelper()
594 /* process a new set of properties
595 * merges changed properties and returns "true" if any occurred
596 * if the optional output set is not NULL then the names of the changed properties are returned
598 bool processProperties( const css::uno::Sequence
< css::beans::PropertyValue
>& i_rNewProp
,
599 std::set
< OUString
>* o_pChangeProp
= NULL
);
600 /* append to a sequence of property values the ui property sequence passed at creation
601 * as the "ExtraPrintUIOptions" property. if that sequence was empty, no "ExtraPrintUIOptions" property
604 void appendPrintUIOptions( css::uno::Sequence
< css::beans::PropertyValue
>& io_rProps
) const;
606 // returns an empty Any for not existing properties
607 css::uno::Any
getValue( const OUString
& i_rPropertyName
) const;
609 bool getBoolValue( const OUString
& i_rPropertyName
, bool i_bDefault
= false ) const;
610 // convenience for fixed strings
611 bool getBoolValue( const char* i_pPropName
, bool i_bDefault
= false ) const
612 { return getBoolValue( OUString::createFromAscii( i_pPropName
), i_bDefault
); }
614 sal_Int64
getIntValue( const OUString
& i_rPropertyName
, sal_Int64 i_nDefault
= 0 ) const;
615 // convenience for fixed strings
616 sal_Int64
getIntValue( const char* i_pPropName
, sal_Int64 i_nDefault
= 0 ) const
617 { return getIntValue( OUString::createFromAscii( i_pPropName
), i_nDefault
); }
619 OUString
getStringValue( const OUString
& i_rPropertyName
, const OUString
& i_rDefault
= OUString() ) const;
620 // convenience for fixed strings
621 OUString
getStringValue( const char* i_pPropName
, const OUString
& i_rDefault
= OUString() ) const
622 { return getStringValue( OUString::createFromAscii( i_pPropName
), i_rDefault
); }
624 // helper functions for user to create a single control
625 struct UIControlOptions
627 OUString maDependsOnName
;
628 sal_Int32 mnDependsOnEntry
;
629 bool mbAttachToDependency
;
630 OUString maGroupHint
;
633 css::uno::Sequence
< css::beans::PropertyValue
> maAddProps
;
635 UIControlOptions( const OUString
& i_rDependsOnName
= OUString(),
636 sal_Int32 i_nDependsOnEntry
= -1,
637 bool i_bAttachToDependency
= false,
638 const OUString
& i_rGroupHint
= OUString(),
639 bool i_bInternalOnly
= false,
640 bool i_bEnabled
= true
642 : maDependsOnName( i_rDependsOnName
)
643 , mnDependsOnEntry( i_nDependsOnEntry
)
644 , mbAttachToDependency( i_bAttachToDependency
)
645 , maGroupHint( i_rGroupHint
)
646 , mbInternalOnly( i_bInternalOnly
)
647 , mbEnabled( i_bEnabled
) {}
650 // note: in the following helper functions HelpIds are expected as an OUString
651 // the normal HelpId form is OString (byte string instead of UTF16 string)
652 // this is because the whole interface is base on UNO properties; in fact the structures
653 // are passed over UNO interfaces. UNO does not know a byte string, hence the string is
654 // transported via UTF16 strings.
656 // Show general control
657 static css::uno::Any
setUIControlOpt( const css::uno::Sequence
< OUString
>& i_rIDs
,
658 const OUString
& i_rTitle
,
659 const css::uno::Sequence
< OUString
>& i_rHelpId
,
660 const OUString
& i_rType
,
661 const css::beans::PropertyValue
* i_pValue
= NULL
,
662 const UIControlOptions
& i_rControlOptions
= UIControlOptions()
665 // Show and set the title of a TagPage of id i_rID
666 static css::uno::Any
setGroupControlOpt(const OUString
& i_rID
,
667 const OUString
& i_rTitle
,
668 const OUString
& i_rHelpId
);
670 // Show and set the label of a VclFrame of id i_rID
671 static css::uno::Any
setSubgroupControlOpt(const OUString
& i_rID
,
672 const OUString
& i_rTitle
,
673 const OUString
& i_rHelpId
,
674 const UIControlOptions
& i_rControlOptions
= UIControlOptions());
676 // Show a bool option as a checkbox
677 static css::uno::Any
setBoolControlOpt(const OUString
& i_rID
,
678 const OUString
& i_rTitle
,
679 const OUString
& i_rHelpId
,
680 const OUString
& i_rProperty
,
682 const UIControlOptions
& i_rControlOptions
= UIControlOptions());
684 // Show a set of choices in a list box
685 static css::uno::Any
setChoiceListControlOpt(const OUString
& i_rID
,
686 const OUString
& i_rTitle
,
687 const css::uno::Sequence
< OUString
>& i_rHelpId
,
688 const OUString
& i_rProperty
,
689 const css::uno::Sequence
< OUString
>& i_rChoices
,
691 const css::uno::Sequence
< sal_Bool
>& i_rDisabledChoices
= css::uno::Sequence
< sal_Bool
>(),
692 const UIControlOptions
& i_rControlOptions
= UIControlOptions());
694 // show a set of choices as radio buttons
695 static css::uno::Any
setChoiceRadiosControlOpt(const css::uno::Sequence
< OUString
>& i_rIDs
,
696 const OUString
& i_rTitle
,
697 const css::uno::Sequence
< OUString
>& i_rHelpId
,
698 const OUString
& i_rProperty
,
699 const css::uno::Sequence
< OUString
>& i_rChoices
,
701 const css::uno::Sequence
< sal_Bool
>& i_rDisabledChoices
= css::uno::Sequence
< sal_Bool
>(),
702 const UIControlOptions
& i_rControlOptions
= UIControlOptions());
705 // show an integer range (e.g. a spin field)
706 // note: max value < min value means do not apply min/max values
707 static css::uno::Any
setRangeControlOpt(const OUString
& i_rID
,
708 const OUString
& i_rTitle
,
709 const OUString
& i_rHelpId
,
710 const OUString
& i_rProperty
,
712 sal_Int32 i_nMinValue
= -1,
713 sal_Int32 i_nMaxValue
= -2,
714 const UIControlOptions
& i_rControlOptions
= UIControlOptions());
716 // show a string field
717 // note: max value < min value means do not apply min/max values
718 static css::uno::Any
setEditControlOpt(const OUString
& i_rID
,
719 const OUString
& i_rTitle
,
720 const OUString
& i_rHelpId
,
721 const OUString
& i_rProperty
,
722 const OUString
& i_rValue
,
723 const UIControlOptions
& i_rControlOptions
= UIControlOptions());
729 #endif // INCLUDED_VCL_PRINT_HXX
731 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */