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