Line data Source code
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 <rtl/ustring.hxx>
24 :
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>
34 :
35 : #include <com/sun/star/beans/PropertyValue.hpp>
36 : #include <com/sun/star/view/PrintableState.hpp>
37 :
38 : #include <memory>
39 : #include <set>
40 : #include <unordered_map>
41 :
42 : class SalInfoPrinter;
43 : struct SalPrinterQueueInfo;
44 : class SalPrinter;
45 : class VirtualDevice;
46 : namespace vcl { class Window; }
47 :
48 : namespace vcl {
49 : class PrinterController;
50 : class PrintDialog;
51 : }
52 :
53 :
54 :
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 };
59 :
60 :
61 : class VCL_DLLPUBLIC PrinterPage
62 : {
63 : GDIMetaFile* mpMtf;
64 : JobSetup maJobSetup;
65 : bool mbNewJobSetup;
66 :
67 : public:
68 :
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; }
73 :
74 : GDIMetaFile* GetGDIMetaFile() const { return mpMtf; }
75 : const JobSetup& GetJobSetup() const { return maJobSetup; }
76 : bool IsNewJobSetup() const { return mbNewJobSetup; }
77 : };
78 :
79 :
80 :
81 0 : class VCL_DLLPUBLIC QueueInfo
82 : {
83 : friend class Printer;
84 :
85 : private:
86 : OUString maPrinterName;
87 : OUString maDriver;
88 : OUString maLocation;
89 : OUString maComment;
90 : PrintQueueFlags mnStatus;
91 : sal_uInt32 mnJobs;
92 :
93 : public:
94 : QueueInfo();
95 : QueueInfo( const QueueInfo& rInfo );
96 : ~QueueInfo();
97 :
98 0 : const OUString& GetPrinterName() const { return maPrinterName; }
99 0 : const OUString& GetDriver() const { return maDriver; }
100 0 : const OUString& GetLocation() const { return maLocation; }
101 0 : const OUString& GetComment() const { return maComment; }
102 0 : PrintQueueFlags GetStatus() const { return mnStatus; }
103 0 : sal_uInt32 GetJobs() const { return mnJobs; }
104 :
105 : bool operator==( const QueueInfo& rInfo ) const;
106 :
107 : friend VCL_DLLPUBLIC SvStream& ReadQueueInfo( SvStream& rIStream, QueueInfo& rInfo );
108 : friend VCL_DLLPUBLIC SvStream& WriteQueueInfo( SvStream& rOStream, const QueueInfo& rInfo );
109 : };
110 :
111 :
112 : enum PrinterTransparencyMode
113 : {
114 : PRINTER_TRANSPARENCY_AUTO = 0,
115 : PRINTER_TRANSPARENCY_NONE = 1
116 : };
117 :
118 :
119 :
120 : enum PrinterGradientMode
121 : {
122 : PRINTER_GRADIENT_STRIPES = 0,
123 : PRINTER_GRADIENT_COLOR = 1
124 : };
125 :
126 :
127 :
128 : enum PrinterBitmapMode
129 : {
130 : PRINTER_BITMAP_OPTIMAL = 0,
131 : PRINTER_BITMAP_NORMAL = 1,
132 : PRINTER_BITMAP_RESOLUTION = 2
133 : };
134 :
135 :
136 :
137 : class VCL_DLLPUBLIC PrinterOptions
138 : {
139 : private:
140 :
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;
152 :
153 : public:
154 :
155 : PrinterOptions();
156 : ~PrinterOptions();
157 :
158 0 : bool IsReduceTransparency() const { return mbReduceTransparency; }
159 0 : void SetReduceTransparency( bool bSet ) { mbReduceTransparency = bSet; }
160 :
161 0 : PrinterTransparencyMode GetReducedTransparencyMode() const { return meReducedTransparencyMode; }
162 0 : void SetReducedTransparencyMode( PrinterTransparencyMode eMode ) { meReducedTransparencyMode = eMode; }
163 :
164 0 : bool IsReduceGradients() const { return mbReduceGradients; }
165 0 : void SetReduceGradients( bool bSet ) { mbReduceGradients = bSet; }
166 :
167 0 : PrinterGradientMode GetReducedGradientMode() const { return meReducedGradientsMode; }
168 0 : void SetReducedGradientMode( PrinterGradientMode eMode ) { meReducedGradientsMode = eMode; }
169 :
170 0 : sal_uInt16 GetReducedGradientStepCount() const { return mnReducedGradientStepCount; }
171 0 : void SetReducedGradientStepCount( sal_uInt16 nStepCount ) { mnReducedGradientStepCount = nStepCount; }
172 :
173 0 : bool IsReduceBitmaps() const { return mbReduceBitmaps; }
174 0 : void SetReduceBitmaps( bool bSet ) { mbReduceBitmaps = bSet; }
175 :
176 0 : PrinterBitmapMode GetReducedBitmapMode() const { return meReducedBitmapMode; }
177 0 : void SetReducedBitmapMode( PrinterBitmapMode eMode ) { meReducedBitmapMode = eMode; }
178 :
179 0 : sal_uInt16 GetReducedBitmapResolution() const { return mnReducedBitmapResolution; }
180 0 : void SetReducedBitmapResolution( sal_uInt16 nResolution ) { mnReducedBitmapResolution = nResolution; }
181 :
182 0 : bool IsReducedBitmapIncludesTransparency() const { return mbReducedBitmapsIncludeTransparency; }
183 0 : void SetReducedBitmapIncludesTransparency( bool bSet ) { mbReducedBitmapsIncludeTransparency = bSet; }
184 :
185 0 : bool IsConvertToGreyscales() const { return mbConvertToGreyscales; }
186 0 : void SetConvertToGreyscales( bool bSet ) { mbConvertToGreyscales = bSet; }
187 :
188 0 : bool IsPDFAsStandardPrintJobFormat() const { return mbPDFAsStandardPrintJobFormat; }
189 0 : void SetPDFAsStandardPrintJobFormat( bool bSet ) { mbPDFAsStandardPrintJobFormat = bSet; }
190 :
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 );
195 : };
196 :
197 :
198 : class VCL_DLLPUBLIC Printer : public OutputDevice
199 : {
200 : friend class ::OutputDevice;
201 :
202 : private:
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;
211 : OUString maDriver;
212 : OUString maPrintFile;
213 : OUString maJobName;
214 : JobSetup maJobSetup;
215 : Point maPageOffset;
216 : Size maPaperSize;
217 : sal_uLong mnError;
218 : sal_uInt16 mnCurPage;
219 : sal_uInt16 mnCurPrintPage;
220 : sal_uInt16 mnPageQueueSize;
221 : sal_uInt16 mnCopyCount;
222 : bool mbDefPrinter;
223 : bool mbPrinting;
224 : bool mbJobActive;
225 : bool mbCollateCopy;
226 : bool mbPrintFile;
227 : bool mbInPrintPage;
228 : bool mbNewJobSetup;
229 : bool mbIsQueuePrinter;
230 : Link<> maErrorHdl;
231 :
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 );
240 :
241 : SAL_DLLPRIVATE bool StartJob( const OUString& rJobName, std::shared_ptr<vcl::PrinterController>& );
242 :
243 : static SAL_DLLPRIVATE sal_uLong ImplSalPrinterErrorCodeToVCL( sal_uLong nError );
244 :
245 : private:
246 : SAL_DLLPRIVATE bool EndJob();
247 : Printer( const Printer& rPrinter ) SAL_DELETED_FUNCTION;
248 : Printer& operator =( const Printer& rPrinter ) SAL_DELETED_FUNCTION;
249 :
250 : public:
251 : SAL_DLLPRIVATE void ImplStartPage();
252 : SAL_DLLPRIVATE void ImplEndPage();
253 :
254 : protected:
255 : virtual bool AcquireGraphics() const SAL_OVERRIDE;
256 : virtual void ReleaseGraphics( bool bRelease = true ) SAL_OVERRIDE;
257 : virtual void ImplReleaseFonts() SAL_OVERRIDE;
258 :
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;
262 :
263 0 : void ScaleBitmap ( Bitmap&, SalTwoRect& ) SAL_OVERRIDE { };
264 :
265 : public:
266 : void DrawGradientEx( OutputDevice* pOut, const Rectangle& rRect, const Gradient& rGradient );
267 : virtual Bitmap GetBitmap( const Point& rSrcPt, const Size& rSize ) const SAL_OVERRIDE;
268 :
269 : protected:
270 :
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;
276 :
277 : bool DrawTransformBitmapExDirect(
278 : const basegfx::B2DHomMatrix& aFullTransform,
279 : const BitmapEx& rBitmapEx) SAL_OVERRIDE;
280 :
281 : bool TransformAndReduceBitmapExToTargetRange(
282 : const basegfx::B2DHomMatrix& aFullTransform,
283 : basegfx::B2DRange &aVisibleRange,
284 : double &fMaximumArea) SAL_OVERRIDE;
285 :
286 : void DrawDeviceBitmap(
287 : const Point& rDestPt, const Size& rDestSize,
288 : const Point& rSrcPtPixel, const Size& rSrcSizePixel,
289 : BitmapEx& rBitmapEx ) SAL_OVERRIDE;
290 :
291 : virtual void EmulateDrawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent ) SAL_OVERRIDE;
292 :
293 : virtual void InitFont() const SAL_OVERRIDE;
294 : virtual void SetFontOrientation( ImplFontEntry* const pFontEntry ) const SAL_OVERRIDE;
295 :
296 : public:
297 : Printer();
298 : Printer( const JobSetup& rJobSetup );
299 : Printer( const QueueInfo& rQueueInfo );
300 : Printer( const OUString& rPrinterName );
301 : virtual ~Printer();
302 : virtual void dispose() SAL_OVERRIDE;
303 :
304 : static const std::vector< OUString >& GetPrinterQueues();
305 : static const QueueInfo* GetQueueInfo( const OUString& rPrinterName, bool bStatusUpdate );
306 : static OUString GetDefaultPrinterName();
307 :
308 : void Error();
309 :
310 439 : const OUString& GetName() const { return maPrinterName; }
311 0 : const OUString& GetDriverName() const { return maDriver; }
312 0 : bool IsDefPrinter() const { return mbDefPrinter; }
313 14803 : bool IsDisplayPrinter() const { return mpDisplayDev != nullptr; }
314 14460 : bool IsValid() const { return !IsDisplayPrinter(); }
315 :
316 : sal_uLong GetCapabilities( PrinterCapType nType ) const;
317 : bool HasSupport( PrinterSupport eFeature ) const;
318 :
319 : bool SetJobSetup( const JobSetup& rSetup );
320 30 : const JobSetup& GetJobSetup() const { return maJobSetup; }
321 :
322 : bool Setup( vcl::Window* pWindow = NULL );
323 : bool SetPrinterProps( const Printer* pPrinter );
324 :
325 : // SetPrinterOptions is used internally only now
326 : // in earlier times it was used only to set the options loaded directly from the configuration
327 : // in SfxPrinter::InitJob, this is now handled internally
328 : // should the need arise to set the printer options outside vcl, also a method would have to be devised
329 : // to not override these again internally
330 : SAL_DLLPRIVATE void SetPrinterOptions( const PrinterOptions& rOptions );
331 0 : const PrinterOptions& GetPrinterOptions() const { return( *mpPrinterOptions ); }
332 :
333 : bool SetOrientation( Orientation eOrient );
334 : Orientation GetOrientation() const;
335 : bool SetDuplexMode( DuplexMode );
336 : // returns the angle that a landscape page will be turned counterclockwise
337 : // wrt to portrait. The return value may be only valid for
338 : // the current paper
339 : int GetLandscapeAngle() const;
340 : bool SetPaperBin( sal_uInt16 nPaperBin );
341 : sal_uInt16 GetPaperBin() const;
342 : bool SetPaper( Paper ePaper );
343 : bool SetPaperSizeUser( const Size& rSize );
344 : bool SetPaperSizeUser( const Size& rSize, bool bMatchNearest );
345 : Paper GetPaper() const;
346 : static OUString GetPaperName( Paper ePaper );
347 : // return a UI string for the current paper; i_bPaperUser == false means an empty string for PAPER_USER
348 : OUString GetPaperName( bool i_bPaperUser = true ) const;
349 :
350 : // returns number of available paper formats
351 : int GetPaperInfoCount() const;
352 : // returns info about paper format nPaper
353 : const PaperInfo& GetPaperInfo( int nPaper ) const;
354 : sal_uInt16 GetPaperBinCount() const;
355 : OUString GetPaperBinName( sal_uInt16 nPaperBin ) const;
356 :
357 0 : const Size& GetPaperSizePixel() const { return maPaperSize; }
358 27 : Size GetPaperSize() const { return PixelToLogic( maPaperSize ); }
359 348 : const Point& GetPageOffsetPixel() const { return maPageOffset; }
360 0 : Point GetPageOffset() const { return PixelToLogic( maPageOffset ); }
361 :
362 : bool SetCopyCount( sal_uInt16 nCopy, bool bCollate = false );
363 0 : sal_uInt16 GetCopyCount() const { return mnCopyCount; }
364 0 : bool IsCollateCopy() const { return mbCollateCopy; }
365 :
366 340 : bool IsPrinting() const { return mbPrinting; }
367 :
368 : const OUString& GetCurJobName() const { return maJobName; }
369 : sal_uInt16 GetCurPage() const { return mnCurPage; }
370 0 : bool IsJobActive() const { return mbJobActive; }
371 :
372 : sal_uLong GetError() const { return ERRCODE_TOERROR(mnError); }
373 : sal_uLong GetErrorCode() const { return mnError; }
374 :
375 : void SetErrorHdl( const Link<>& rLink ) { maErrorHdl = rLink; }
376 : const Link<>& GetErrorHdl() const { return maErrorHdl; }
377 :
378 : /** checks the printer list and updates it necessary
379 : *
380 : * sends a DataChanged event of type DataChangedEventType::PRINTER
381 : * if the printer list changed
382 : */
383 : static void updatePrinters();
384 :
385 : /** execute a print job
386 :
387 : starts a print job asynchronously (that is will return
388 :
389 : */
390 : static void PrintJob( const std::shared_ptr<vcl::PrinterController>& i_pController,
391 : const JobSetup& i_rInitSetup );
392 :
393 : virtual bool HasMirroredGraphics() const SAL_OVERRIDE;
394 :
395 : virtual void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
396 : const Point& rSrcPt, const Size& rSrcSize ) SAL_OVERRIDE;
397 : virtual void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
398 : const Point& rSrcPt, const Size& rSrcSize,
399 : const OutputDevice& rOutDev ) SAL_OVERRIDE;
400 : virtual void CopyArea( const Point& rDestPt,
401 : const Point& rSrcPt, const Size& rSrcSize,
402 : bool bWindowInvalidate = false ) SAL_OVERRIDE;
403 :
404 : virtual void DrawImage( const Point&, const Image&, DrawImageFlags ) SAL_OVERRIDE;
405 : virtual void DrawImage( const Point&, const Size&,
406 : const Image&, DrawImageFlags ) SAL_OVERRIDE;
407 :
408 :
409 : // These 3 together are more modular PrintJob(), allowing printing more documents as one print job
410 : // by repeated calls to ExecutePrintJob(). Used by mailmerge.
411 : static bool PreparePrintJob( std::shared_ptr<vcl::PrinterController> i_pController,
412 : const JobSetup& i_rInitSetup );
413 : static bool ExecutePrintJob( std::shared_ptr<vcl::PrinterController> i_pController );
414 : static void FinishPrintJob( std::shared_ptr<vcl::PrinterController> i_pController );
415 :
416 : // implementation detail of PrintJob being asynchronous
417 : // not exported, not usable outside vcl
418 : static void SAL_DLLPRIVATE ImplPrintJob( std::shared_ptr<vcl::PrinterController> i_pController,
419 : const JobSetup& i_rInitSetup );
420 : };
421 :
422 : namespace vcl
423 : {
424 : class ImplPrinterControllerData;
425 :
426 : class VCL_DLLPUBLIC PrinterController
427 : {
428 : ImplPrinterControllerData* mpImplData;
429 : protected:
430 : PrinterController( const VclPtr<Printer>& );
431 : public:
432 : enum NupOrderType
433 : { LRTB, TBLR, TBRL, RLTB };
434 : struct MultiPageSetup
435 : {
436 : // all metrics in 100th mm
437 : int nRows;
438 : int nColumns;
439 : int nRepeat;
440 : Size aPaperSize;
441 : long nLeftMargin;
442 : long nTopMargin;
443 : long nRightMargin;
444 : long nBottomMargin;
445 : long nHorizontalSpacing;
446 : long nVerticalSpacing;
447 : bool bDrawBorder;
448 : PrinterController::NupOrderType nOrder;
449 :
450 0 : MultiPageSetup()
451 : : nRows( 1 ), nColumns( 1 ), nRepeat( 1 ), aPaperSize( 21000, 29700 )
452 : , nLeftMargin( 0 ), nTopMargin( 0 )
453 : , nRightMargin( 0 ), nBottomMargin( 0 )
454 : , nHorizontalSpacing( 0 ), nVerticalSpacing( 0 )
455 : , bDrawBorder( false )
456 0 : , nOrder( LRTB )
457 : {
458 0 : }
459 : };
460 :
461 : struct PageSize
462 : {
463 : Size aSize; // in 100th mm
464 : bool bFullPaper; // full paper, not only imageable area is printed
465 :
466 0 : PageSize( const Size& i_rSize = Size( 21000, 29700 ),
467 : bool i_bFullPaper = false
468 0 : ) : aSize( i_rSize ), bFullPaper( i_bFullPaper ) {}
469 : };
470 :
471 : virtual ~PrinterController();
472 :
473 : const VclPtr<Printer>& getPrinter() const;
474 : /* for implementations: get current job properties as changed by e.g. print dialog
475 : this gets the current set of properties initially told to Printer::PrintJob
476 :
477 : For convenience a second sequence will be merged in to get a combined sequence.
478 : In case of duplicate property names, the value of i_MergeList wins.
479 : */
480 : css::uno::Sequence< css::beans::PropertyValue >
481 : getJobProperties( const css::uno::Sequence< css::beans::PropertyValue >& i_rMergeList ) const;
482 :
483 : /* get the PropertyValue of a Property
484 : */
485 : css::beans::PropertyValue* getValue( const OUString& i_rPropertyName );
486 : const css::beans::PropertyValue* getValue( const OUString& i_rPropertyName ) const;
487 : /* get a bool property
488 : in case the property is unknown or not convertible to bool, i_bFallback is returned
489 : */
490 : bool getBoolProperty( const OUString& i_rPropertyName, bool i_bFallback ) const;
491 : /* get an int property
492 : in case the property is unknown or not convertible to bool, i_nFallback is returned
493 : */
494 : sal_Int32 getIntProperty( const OUString& i_rPropertyName, sal_Int32 i_nFallback ) const;
495 :
496 : /* set a property value - can also be used to add another UI property
497 : */
498 : void setValue( const OUString& i_rPropertyName, const css::uno::Any& i_rValue );
499 : void setValue( const css::beans::PropertyValue& i_rValue );
500 :
501 : /* return the currently active UI options. These are the same that were passed to setUIOptions.
502 : */
503 : const css::uno::Sequence< css::beans::PropertyValue >& getUIOptions() const;
504 : /* set possible UI options. should only be done once before passing the PrinterListener
505 : to Printer::PrintJob
506 : */
507 : void setUIOptions( const css::uno::Sequence< css::beans::PropertyValue >& );
508 : /* enable/disable an option; this can be used to implement dialog logic.
509 : */
510 : bool isUIOptionEnabled( const OUString& rPropName ) const;
511 : bool isUIChoiceEnabled( const OUString& rPropName, sal_Int32 nChoice ) const;
512 : /* returns the property name rPropName depends on or an empty string
513 : if no dependency exists.
514 : */
515 : OUString getDependency( const OUString& rPropName ) const;
516 : /* makeEnabled will chage the property rPropName depends on to the value
517 : that makes rPropName enabled. If the dependency itself is also disabled,
518 : no action will be performed.
519 :
520 : returns the property name rPropName depends on or an empty string
521 : if no change was made.
522 : */
523 : OUString makeEnabled( const OUString& rPropName );
524 :
525 : virtual int getPageCount() const = 0; /// App must override this
526 : /* get the page parameters, namely the jobsetup that should be active for the page
527 : (describing among others the physical page size) and the "page size". In writer
528 : case this would probably be the same as the JobSetup since writer sets the page size
529 : draw/impress for example print their page on the paper set on the printer,
530 : possibly adjusting the page size to fit. That means the page size can be different from
531 : the paper size.
532 : App must override this, return page size in 1/100th mm
533 : */
534 : virtual css::uno::Sequence< css::beans::PropertyValue > getPageParameters( int i_nPage ) const = 0;
535 : virtual void printPage(int i_nPage) const = 0; /// App must override this
536 : virtual void jobStarted(); // will be called after a possible dialog has been shown and the real printjob starts
537 : virtual void jobFinished( com::sun::star::view::PrintableState );
538 :
539 : com::sun::star::view::PrintableState getJobState() const;
540 :
541 : void abortJob();
542 :
543 : bool isShowDialogs() const;
544 : bool isDirectPrint() const;
545 :
546 : // implementation details, not usable outside vcl
547 : // don't use outside vcl. Some of these are exported for
548 : // the benefit of vcl's plugins.
549 : // Still: DO NOT USE OUTSIDE VCL
550 : VCL_PLUGIN_PUBLIC int getFilteredPageCount();
551 : SAL_DLLPRIVATE PageSize getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf, bool i_bMayUseCache = false );
552 : VCL_PLUGIN_PUBLIC PageSize getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache = false );
553 : VCL_PLUGIN_PUBLIC void printFilteredPage( int i_nPage );
554 : SAL_DLLPRIVATE void setPrinter( const VclPtr<Printer>& );
555 : SAL_DLLPRIVATE void setOptionChangeHdl( const Link<>& );
556 : VCL_PLUGIN_PUBLIC void createProgressDialog();
557 : VCL_PLUGIN_PUBLIC bool isProgressCanceled() const;
558 : SAL_DLLPRIVATE void setMultipage( const MultiPageSetup& );
559 : SAL_DLLPRIVATE const MultiPageSetup& getMultipage() const;
560 : VCL_PLUGIN_PUBLIC void setLastPage( bool i_bLastPage );
561 : SAL_DLLPRIVATE void setReversePrint( bool i_bReverse );
562 : SAL_DLLPRIVATE bool getReversePrint() const;
563 : SAL_DLLPRIVATE void setPapersizeFromSetup( bool i_bPapersizeFromSetup );
564 : SAL_DLLPRIVATE bool getPapersizeFromSetup() const;
565 : SAL_DLLPRIVATE void pushPropertiesToPrinter();
566 : SAL_DLLPRIVATE void resetPaperToLastConfigured();
567 : VCL_PLUGIN_PUBLIC void setJobState( com::sun::star::view::PrintableState );
568 : SAL_DLLPRIVATE bool setupPrinter( vcl::Window* i_pDlgParent );
569 :
570 : SAL_DLLPRIVATE int getPageCountProtected() const;
571 : SAL_DLLPRIVATE css::uno::Sequence< css::beans::PropertyValue > getPageParametersProtected( int i_nPage ) const;
572 :
573 : SAL_DLLPRIVATE DrawModeFlags removeTransparencies( GDIMetaFile& i_rIn, GDIMetaFile& o_rOut );
574 : SAL_DLLPRIVATE void resetPrinterOptions( bool i_bFileOutput );
575 : };
576 :
577 : class VCL_DLLPUBLIC PrinterOptionsHelper
578 : {
579 : protected:
580 : std::unordered_map< OUString, css::uno::Any, OUStringHash > m_aPropertyMap;
581 : css::uno::Sequence< css::beans::PropertyValue > m_aUIProperties;
582 :
583 : public:
584 1 : PrinterOptionsHelper() {} // create without ui properties
585 : PrinterOptionsHelper( const css::uno::Sequence< css::beans::PropertyValue >& i_rUIProperties )
586 : : m_aUIProperties( i_rUIProperties )
587 : {}
588 1 : ~PrinterOptionsHelper()
589 1 : {}
590 :
591 : /* process a new set of properties
592 : * merges changed properties and returns "true" if any occurred
593 : * if the optional output set is not NULL then the names of the changed properties are returned
594 : **/
595 : bool processProperties( const css::uno::Sequence< css::beans::PropertyValue >& i_rNewProp,
596 : std::set< OUString >* o_pChangeProp = NULL );
597 : /* append to a sequence of property values the ui property sequence passed at creation
598 : * as the "ExtraPrintUIOptions" property. if that sequence was empty, no "ExtraPrintUIOptions" property
599 : * will be appended.
600 : **/
601 : void appendPrintUIOptions( css::uno::Sequence< css::beans::PropertyValue >& io_rProps ) const;
602 :
603 : // returns an empty Any for not existing properties
604 : css::uno::Any getValue( const OUString& i_rPropertyName ) const;
605 :
606 : bool getBoolValue( const OUString& i_rPropertyName, bool i_bDefault = false ) const;
607 : // convenience for fixed strings
608 39 : bool getBoolValue( const char* i_pPropName, bool i_bDefault = false ) const
609 39 : { return getBoolValue( OUString::createFromAscii( i_pPropName ), i_bDefault ); }
610 :
611 : sal_Int64 getIntValue( const OUString& i_rPropertyName, sal_Int64 i_nDefault = 0 ) const;
612 : // convenience for fixed strings
613 12 : sal_Int64 getIntValue( const char* i_pPropName, sal_Int64 i_nDefault = 0 ) const
614 12 : { return getIntValue( OUString::createFromAscii( i_pPropName ), i_nDefault ); }
615 :
616 : OUString getStringValue( const OUString& i_rPropertyName, const OUString& i_rDefault = OUString() ) const;
617 : // convenience for fixed strings
618 1 : OUString getStringValue( const char* i_pPropName, const OUString& i_rDefault = OUString() ) const
619 1 : { return getStringValue( OUString::createFromAscii( i_pPropName ), i_rDefault ); }
620 :
621 : // helper functions for user to create a single control
622 28 : struct UIControlOptions
623 : {
624 : OUString maDependsOnName;
625 : sal_Int32 mnDependsOnEntry;
626 : bool mbAttachToDependency;
627 : OUString maGroupHint;
628 : bool mbInternalOnly;
629 : bool mbEnabled;
630 : css::uno::Sequence< css::beans::PropertyValue > maAddProps;
631 :
632 20 : UIControlOptions( const OUString& i_rDependsOnName = OUString(),
633 : sal_Int32 i_nDependsOnEntry = -1,
634 : bool i_bAttachToDependency = false,
635 : const OUString& i_rGroupHint = OUString(),
636 : bool i_bInternalOnly = false,
637 : bool i_bEnabled = true
638 : )
639 : : maDependsOnName( i_rDependsOnName )
640 : , mnDependsOnEntry( i_nDependsOnEntry )
641 : , mbAttachToDependency( i_bAttachToDependency )
642 : , maGroupHint( i_rGroupHint )
643 : , mbInternalOnly( i_bInternalOnly )
644 20 : , mbEnabled( i_bEnabled ) {}
645 : };
646 :
647 : // note: in the following helper functions HelpIds are expected as an OUString
648 : // the normal HelpId form is OString (byte string instead of UTF16 string)
649 : // this is because the whole interface is base on UNO properties; in fact the structures
650 : // are passed over UNO interfaces. UNO does not know a byte string, hence the string is
651 : // transported via UTF16 strings.
652 :
653 : // Show general control
654 : static css::uno::Any setUIControlOpt( const css::uno::Sequence< OUString >& i_rIDs,
655 : const OUString& i_rTitle,
656 : const css::uno::Sequence< OUString >& i_rHelpId,
657 : const OUString& i_rType,
658 : const css::beans::PropertyValue* i_pValue = NULL,
659 : const UIControlOptions& i_rControlOptions = UIControlOptions()
660 : );
661 :
662 : // Show and set the title of a TagPage of id i_rID
663 : static css::uno::Any setGroupControlOpt(const OUString& i_rID,
664 : const OUString& i_rTitle,
665 : const OUString& i_rHelpId);
666 :
667 : // Show and set the label of a VclFrame of id i_rID
668 : static css::uno::Any setSubgroupControlOpt(const OUString& i_rID,
669 : const OUString& i_rTitle,
670 : const OUString& i_rHelpId,
671 : const UIControlOptions& i_rControlOptions = UIControlOptions());
672 :
673 : // Show a bool option as a checkbox
674 : static css::uno::Any setBoolControlOpt(const OUString& i_rID,
675 : const OUString& i_rTitle,
676 : const OUString& i_rHelpId,
677 : const OUString& i_rProperty,
678 : bool i_bValue,
679 : const UIControlOptions& i_rControlOptions = UIControlOptions());
680 :
681 : // Show a set of choices in a list box
682 : static css::uno::Any setChoiceListControlOpt(const OUString& i_rID,
683 : const OUString& i_rTitle,
684 : const css::uno::Sequence< OUString >& i_rHelpId,
685 : const OUString& i_rProperty,
686 : const css::uno::Sequence< OUString >& i_rChoices,
687 : sal_Int32 i_nValue,
688 : const css::uno::Sequence< sal_Bool >& i_rDisabledChoices = css::uno::Sequence< sal_Bool >(),
689 : const UIControlOptions& i_rControlOptions = UIControlOptions());
690 :
691 : // show a set of choices as radio buttons
692 : static css::uno::Any setChoiceRadiosControlOpt(const css::uno::Sequence< OUString >& i_rIDs,
693 : const OUString& i_rTitle,
694 : const css::uno::Sequence< OUString >& i_rHelpId,
695 : const OUString& i_rProperty,
696 : const css::uno::Sequence< OUString >& i_rChoices,
697 : sal_Int32 i_nValue,
698 : const css::uno::Sequence< sal_Bool >& i_rDisabledChoices = css::uno::Sequence< sal_Bool >(),
699 : const UIControlOptions& i_rControlOptions = UIControlOptions());
700 :
701 :
702 : // show an integer range (e.g. a spin field)
703 : // note: max value < min value means do not apply min/max values
704 : static css::uno::Any setRangeControlOpt(const OUString& i_rID,
705 : const OUString& i_rTitle,
706 : const OUString& i_rHelpId,
707 : const OUString& i_rProperty,
708 : sal_Int32 i_nValue,
709 : sal_Int32 i_nMinValue = -1,
710 : sal_Int32 i_nMaxValue = -2,
711 : const UIControlOptions& i_rControlOptions = UIControlOptions());
712 :
713 : // show a string field
714 : // note: max value < min value means do not apply min/max values
715 : static css::uno::Any setEditControlOpt(const OUString& i_rID,
716 : const OUString& i_rTitle,
717 : const OUString& i_rHelpId,
718 : const OUString& i_rProperty,
719 : const OUString& i_rValue,
720 : const UIControlOptions& i_rControlOptions = UIControlOptions());
721 : };
722 :
723 : }
724 :
725 :
726 : #endif // INCLUDED_VCL_PRINT_HXX
727 :
728 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|