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 ClipAndDrawGradientMetafile ( const Gradient &rGradient, const PolyPolygon &rPolyPoly ) SAL_OVERRIDE;
278 : virtual bool UsePolyPolygonForComplexGradient() SAL_OVERRIDE;
279 :
280 0 : void ScaleBitmap ( Bitmap&, SalTwoRect& ) SAL_OVERRIDE { };
281 :
282 : public:
283 : void DrawGradientEx( OutputDevice* pOut, const Rectangle& rRect, const Gradient& rGradient );
284 :
285 : protected:
286 :
287 : void SetSelfAsQueuePrinter( bool bQueuePrinter ) { mbIsQueuePrinter = bQueuePrinter; }
288 : bool IsQueuePrinter() const { return mbIsQueuePrinter; }
289 : virtual void ImplPrintMask ( const Bitmap& rMask, const Color& rMaskColor,
290 : const Point& rDestPt, const Size& rDestSize,
291 : const Point& rSrcPtPixel, const Size& rSrcSizePixel ) SAL_OVERRIDE;
292 :
293 : bool DrawTransformBitmapExDirect(
294 : const basegfx::B2DHomMatrix& aFullTransform,
295 : const BitmapEx& rBitmapEx) SAL_OVERRIDE;
296 :
297 : bool TransformReduceBitmapExTargetRange(
298 : const basegfx::B2DHomMatrix& aFullTransform,
299 : basegfx::B2DRange &aVisibleRange,
300 : double &fMaximumArea) SAL_OVERRIDE;
301 :
302 : void DrawDeviceBitmap(
303 : const Point& rDestPt, const Size& rDestSize,
304 : const Point& rSrcPtPixel, const Size& rSrcSizePixel,
305 : BitmapEx& rBitmapEx ) SAL_OVERRIDE;
306 :
307 : virtual void EmulateDrawTransparent( const PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent ) SAL_OVERRIDE;
308 :
309 : public:
310 : Printer();
311 : Printer( const JobSetup& rJobSetup );
312 : Printer( const QueueInfo& rQueueInfo );
313 : Printer( const OUString& rPrinterName );
314 : virtual ~Printer();
315 :
316 : static const std::vector< OUString >& GetPrinterQueues();
317 : static const QueueInfo* GetQueueInfo( const OUString& rPrinterName, bool bStatusUpdate );
318 : static OUString GetDefaultPrinterName();
319 :
320 : virtual void Error();
321 :
322 0 : const OUString& GetName() const { return maPrinterName; }
323 0 : const OUString& GetDriverName() const { return maDriver; }
324 0 : bool IsDefPrinter() const { return mbDefPrinter; }
325 0 : bool IsDisplayPrinter() const { return mpDisplayDev != NULL; }
326 0 : bool IsValid() const { return !IsDisplayPrinter(); }
327 :
328 : sal_uLong GetCapabilities( sal_uInt16 nType ) const;
329 : bool HasSupport( PrinterSupport eFeature ) const;
330 :
331 : bool SetJobSetup( const JobSetup& rSetup );
332 0 : const JobSetup& GetJobSetup() const { return maJobSetup; }
333 :
334 : bool Setup( Window* pWindow = NULL );
335 : bool SetPrinterProps( const Printer* pPrinter );
336 :
337 : // SetPrinterOptions is used internally only now
338 : // in earlier times it was used only to set the options loaded directly from the configuration
339 : // in SfxPrinter::InitJob, this is now handled internally
340 : // should the need arise to set the printer options outside vcl, also a method would have to be devised
341 : // to not override these again internally
342 : SAL_DLLPRIVATE void SetPrinterOptions( const PrinterOptions& rOptions );
343 0 : const PrinterOptions& GetPrinterOptions() const { return( *mpPrinterOptions ); }
344 :
345 : bool SetOrientation( Orientation eOrient );
346 : Orientation GetOrientation() const;
347 : bool SetDuplexMode( DuplexMode );
348 : // returns the angle that a landscape page will be turned counterclockwise
349 : // wrt to portrait. The return value may be only valid for
350 : // the current paper
351 : int GetLandscapeAngle() const;
352 : bool SetPaperBin( sal_uInt16 nPaperBin );
353 : sal_uInt16 GetPaperBin() const;
354 : bool SetPaper( Paper ePaper );
355 : bool SetPaperSizeUser( const Size& rSize );
356 : bool SetPaperSizeUser( const Size& rSize, bool bMatchNearest );
357 : Paper GetPaper() const;
358 : static OUString GetPaperName( Paper ePaper );
359 : // return a UI string for the current paper; i_bPaperUser == false means an empty string for PAPER_USER
360 : OUString GetPaperName( bool i_bPaperUser = true ) const;
361 :
362 : // returns number of available paper formats
363 : int GetPaperInfoCount() const;
364 : // returns info about paper format nPaper
365 : const PaperInfo& GetPaperInfo( int nPaper ) const;
366 : sal_uInt16 GetPaperBinCount() const;
367 : OUString GetPaperBinName( sal_uInt16 nPaperBin ) const;
368 :
369 0 : const Size& GetPaperSizePixel() const { return maPaperSize; }
370 0 : Size GetPaperSize() const { return PixelToLogic( maPaperSize ); }
371 0 : const Point& GetPageOffsetPixel() const { return maPageOffset; }
372 0 : Point GetPageOffset() const { return PixelToLogic( maPageOffset ); }
373 :
374 : bool SetCopyCount( sal_uInt16 nCopy, bool bCollate = false );
375 0 : sal_uInt16 GetCopyCount() const { return mnCopyCount; }
376 0 : bool IsCollateCopy() const { return mbCollateCopy; }
377 :
378 0 : bool IsPrinting() const { return mbPrinting; }
379 :
380 : const OUString& GetCurJobName() const { return maJobName; }
381 : sal_uInt16 GetCurPage() const { return mnCurPage; }
382 0 : bool IsJobActive() const { return mbJobActive; }
383 :
384 : sal_uLong GetError() const { return ERRCODE_TOERROR(mnError); }
385 : sal_uLong GetErrorCode() const { return mnError; }
386 :
387 : void SetErrorHdl( const Link& rLink ) { maErrorHdl = rLink; }
388 : const Link& GetErrorHdl() const { return maErrorHdl; }
389 :
390 : /** checks the printer list and updates it necessary
391 : *
392 : * sends a DataChanged event of type DATACHANGED_PRINTER
393 : * if the printer list changed
394 : */
395 : static void updatePrinters();
396 :
397 : /** execute a print job
398 :
399 : starts a print job asynchronously (that is will return
400 :
401 : */
402 : static void PrintJob( const boost::shared_ptr<vcl::PrinterController>& i_pController,
403 : const JobSetup& i_rInitSetup );
404 :
405 : virtual bool HasMirroredGraphics() const SAL_OVERRIDE;
406 :
407 : virtual void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
408 : const Point& rSrcPt, const Size& rSrcSize ) SAL_OVERRIDE;
409 : virtual void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
410 : const Point& rSrcPt, const Size& rSrcSize,
411 : const OutputDevice& rOutDev ) SAL_OVERRIDE;
412 : virtual void CopyArea( const Point& rDestPt,
413 : const Point& rSrcPt, const Size& rSrcSize,
414 : sal_uInt16 nFlags = 0 ) SAL_OVERRIDE;
415 :
416 :
417 : // implementation detail of PrintJob being asynchronous
418 : // not exported, not usable outside vcl
419 : static void SAL_DLLPRIVATE ImplPrintJob( const boost::shared_ptr<vcl::PrinterController>& i_pController,
420 : const JobSetup& i_rInitSetup );
421 : };
422 :
423 : namespace vcl
424 : {
425 : class ImplPrinterControllerData;
426 :
427 : class VCL_DLLPUBLIC PrinterController
428 : {
429 : ImplPrinterControllerData* mpImplData;
430 : protected:
431 : PrinterController( const boost::shared_ptr<Printer>& );
432 : public:
433 : enum NupOrderType
434 : { LRTB, TBLR, TBRL, RLTB };
435 : struct MultiPageSetup
436 : {
437 : // all metrics in 100th mm
438 : int nRows;
439 : int nColumns;
440 : int nRepeat;
441 : Size aPaperSize;
442 : long nLeftMargin;
443 : long nTopMargin;
444 : long nRightMargin;
445 : long nBottomMargin;
446 : long nHorizontalSpacing;
447 : long nVerticalSpacing;
448 : bool bDrawBorder;
449 : PrinterController::NupOrderType nOrder;
450 :
451 0 : MultiPageSetup()
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 )
457 0 : , nOrder( LRTB )
458 : {
459 0 : }
460 : };
461 :
462 : struct PageSize
463 : {
464 : Size aSize; // in 100th mm
465 : bool bFullPaper; // full paper, not only imageable area is printed
466 :
467 0 : PageSize( const Size& i_rSize = Size( 21000, 29700 ),
468 : bool i_bFullPaper = false
469 0 : ) : aSize( i_rSize ), bFullPaper( i_bFullPaper ) {}
470 : };
471 :
472 : virtual ~PrinterController();
473 :
474 : const boost::shared_ptr<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
477 :
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.
480 : */
481 : css::uno::Sequence< css::beans::PropertyValue >
482 : getJobProperties( const css::uno::Sequence< css::beans::PropertyValue >& i_rMergeList ) const;
483 :
484 : /* get the PropertyValue of a Property
485 : */
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
490 : */
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
494 : */
495 : sal_Int32 getIntProperty( const OUString& i_rPropertyName, sal_Int32 i_nFallback ) const;
496 :
497 : /* set a property value - can also be used to add another UI property
498 : */
499 : void setValue( const OUString& i_rPropertyName, const css::uno::Any& i_rValue );
500 : void setValue( const css::beans::PropertyValue& i_rValue );
501 :
502 : /* return the currently active UI options. These are the same that were passed to setUIOptions.
503 : */
504 : const css::uno::Sequence< css::beans::PropertyValue >& getUIOptions() const;
505 : /* set possible UI options. should only be done once before passing the PrinterListener
506 : to Printer::PrintJob
507 : */
508 : void setUIOptions( const css::uno::Sequence< css::beans::PropertyValue >& );
509 : /* enable/disable an option; this can be used to implement dialog logic.
510 : */
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.
515 : */
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.
520 :
521 : returns the property name rPropName depends on or an empty string
522 : if no change was made.
523 : */
524 : OUString makeEnabled( const OUString& rPropName );
525 :
526 : virtual int getPageCount() const = 0; // must be overloaded by the app
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
532 : the paper size.
533 : */
534 : // must be overloaded by the app, 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; // must be overloaded by the app
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 );
539 :
540 : com::sun::star::view::PrintableState getJobState() const;
541 :
542 : void abortJob();
543 :
544 : bool isShowDialogs() const;
545 : bool isDirectPrint() const;
546 :
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 boost::shared_ptr<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 : SAL_DLLPRIVATE void pushPropertiesToPrinter();
567 : SAL_DLLPRIVATE void resetPaperToLastConfigured();
568 : VCL_PLUGIN_PUBLIC void setJobState( com::sun::star::view::PrintableState );
569 : SAL_DLLPRIVATE bool setupPrinter( Window* i_pDlgParent );
570 :
571 : SAL_DLLPRIVATE int getPageCountProtected() const;
572 : SAL_DLLPRIVATE css::uno::Sequence< css::beans::PropertyValue > getPageParametersProtected( int i_nPage ) const;
573 :
574 : SAL_DLLPRIVATE sal_uLong removeTransparencies( GDIMetaFile& i_rIn, GDIMetaFile& o_rOut );
575 : SAL_DLLPRIVATE void resetPrinterOptions( bool i_bFileOutput );
576 : };
577 :
578 : class VCL_DLLPUBLIC PrinterOptionsHelper
579 : {
580 : protected:
581 : boost::unordered_map< OUString, css::uno::Any, OUStringHash > m_aPropertyMap;
582 : css::uno::Sequence< css::beans::PropertyValue > m_aUIProperties;
583 :
584 : public:
585 0 : PrinterOptionsHelper() {} // create without ui properties
586 : PrinterOptionsHelper( const css::uno::Sequence< css::beans::PropertyValue >& i_rUIProperties )
587 : : m_aUIProperties( i_rUIProperties )
588 : {}
589 0 : ~PrinterOptionsHelper()
590 0 : {}
591 :
592 : /* process a new set of properties
593 : * merges changed properties and returns "true" if any occurred
594 : * if the optional output set is not NULL then the names of the changed properties are returned
595 : **/
596 : bool processProperties( const css::uno::Sequence< css::beans::PropertyValue >& i_rNewProp,
597 : std::set< OUString >* o_pChangeProp = NULL );
598 : /* append to a sequence of property values the ui property sequence passed at creation
599 : * as the "ExtraPrintUIOptions" property. if that sequence was empty, no "ExtraPrintUIOptions" property
600 : * will be appended.
601 : **/
602 : void appendPrintUIOptions( css::uno::Sequence< css::beans::PropertyValue >& io_rProps ) const;
603 :
604 : // returns an empty Any for not existing properties
605 : css::uno::Any getValue( const OUString& i_rPropertyName ) const;
606 :
607 : bool getBoolValue( const OUString& i_rPropertyName, bool i_bDefault = false ) const;
608 : // convenience for fixed strings
609 0 : bool getBoolValue( const char* i_pPropName, bool i_bDefault = false ) const
610 0 : { return getBoolValue( OUString::createFromAscii( i_pPropName ), i_bDefault ); }
611 :
612 : sal_Int64 getIntValue( const OUString& i_rPropertyName, sal_Int64 i_nDefault = 0 ) const;
613 : // convenience for fixed strings
614 0 : sal_Int64 getIntValue( const char* i_pPropName, sal_Int64 i_nDefault = 0 ) const
615 0 : { return getIntValue( OUString::createFromAscii( i_pPropName ), i_nDefault ); }
616 :
617 : OUString getStringValue( const OUString& i_rPropertyName, const OUString& i_rDefault = OUString() ) const;
618 : // convenience for fixed strings
619 0 : OUString getStringValue( const char* i_pPropName, const OUString& i_rDefault = OUString() ) const
620 0 : { return getStringValue( OUString::createFromAscii( i_pPropName ), i_rDefault ); }
621 :
622 : // helper functions for user to create a single control
623 0 : struct UIControlOptions
624 : {
625 : OUString maDependsOnName;
626 : sal_Int32 mnDependsOnEntry;
627 : bool mbAttachToDependency;
628 : OUString maGroupHint;
629 : bool mbInternalOnly;
630 : bool mbEnabled;
631 : css::uno::Sequence< css::beans::PropertyValue > maAddProps;
632 :
633 0 : UIControlOptions( const OUString& i_rDependsOnName = OUString(),
634 : sal_Int32 i_nDependsOnEntry = -1,
635 : bool i_bAttachToDependency = false,
636 : const OUString& i_rGroupHint = OUString(),
637 : bool i_bInternalOnly = false,
638 : bool i_bEnabled = true
639 : )
640 : : maDependsOnName( i_rDependsOnName )
641 : , mnDependsOnEntry( i_nDependsOnEntry )
642 : , mbAttachToDependency( i_bAttachToDependency )
643 : , maGroupHint( i_rGroupHint )
644 : , mbInternalOnly( i_bInternalOnly )
645 0 : , mbEnabled( i_bEnabled ) {}
646 : };
647 :
648 : // note: in the following helper functions HelpIds are expected as an OUString
649 : // the normal HelpId form is OString (byte string instead of UTF16 string)
650 : // this is because the whole interface is base on UNO properties; in fact the structures
651 : // are passed over UNO interfaces. UNO does not know a byte string, hence the string is
652 : // transported via UTF16 strings.
653 :
654 : // Show general control
655 : static css::uno::Any setUIControlOpt( const css::uno::Sequence< OUString >& i_rIDs,
656 : const OUString& i_rTitle,
657 : const css::uno::Sequence< OUString >& i_rHelpId,
658 : const OUString& i_rType,
659 : const css::beans::PropertyValue* i_pValue = NULL,
660 : const UIControlOptions& i_rControlOptions = UIControlOptions()
661 : );
662 :
663 : // Show and set the title of a TagPage of id i_rID
664 : static css::uno::Any setGroupControlOpt(const OUString& i_rID,
665 : const OUString& i_rTitle,
666 : const OUString& i_rHelpId);
667 :
668 : // Show and set the label of a VclFrame of id i_rID
669 : static css::uno::Any setSubgroupControlOpt(const OUString& i_rID,
670 : const OUString& i_rTitle,
671 : const OUString& i_rHelpId,
672 : const UIControlOptions& i_rControlOptions = UIControlOptions());
673 :
674 : // Show a bool option as a checkbox
675 : static css::uno::Any setBoolControlOpt(const OUString& i_rID,
676 : const OUString& i_rTitle,
677 : const OUString& i_rHelpId,
678 : const OUString& i_rProperty,
679 : bool i_bValue,
680 : const UIControlOptions& i_rControlOptions = UIControlOptions());
681 :
682 : // Show a set of choices in a list box
683 : static css::uno::Any setChoiceListControlOpt(const OUString& i_rID,
684 : const OUString& i_rTitle,
685 : const css::uno::Sequence< OUString >& i_rHelpId,
686 : const OUString& i_rProperty,
687 : const css::uno::Sequence< OUString >& i_rChoices,
688 : sal_Int32 i_nValue,
689 : const css::uno::Sequence< sal_Bool >& i_rDisabledChoices = css::uno::Sequence< sal_Bool >(),
690 : const UIControlOptions& i_rControlOptions = UIControlOptions());
691 :
692 : // show a set of choices as radio buttons
693 : static css::uno::Any setChoiceRadiosControlOpt(const css::uno::Sequence< OUString >& i_rIDs,
694 : const OUString& i_rTitle,
695 : const css::uno::Sequence< OUString >& i_rHelpId,
696 : const OUString& i_rProperty,
697 : const css::uno::Sequence< OUString >& i_rChoices,
698 : sal_Int32 i_nValue,
699 : const css::uno::Sequence< sal_Bool >& i_rDisabledChoices = css::uno::Sequence< sal_Bool >(),
700 : const UIControlOptions& i_rControlOptions = UIControlOptions());
701 :
702 :
703 : // show an integer range (e.g. a spin field)
704 : // note: max value < min value means do not apply min/max values
705 : static css::uno::Any setRangeControlOpt(const OUString& i_rID,
706 : const OUString& i_rTitle,
707 : const OUString& i_rHelpId,
708 : const OUString& i_rProperty,
709 : sal_Int32 i_nValue,
710 : sal_Int32 i_nMinValue = -1,
711 : sal_Int32 i_nMaxValue = -2,
712 : const UIControlOptions& i_rControlOptions = UIControlOptions());
713 :
714 : // show a string field
715 : // note: max value < min value means do not apply min/max values
716 : static css::uno::Any setEditControlOpt(const OUString& i_rID,
717 : const OUString& i_rTitle,
718 : const OUString& i_rHelpId,
719 : const OUString& i_rProperty,
720 : const OUString& i_rValue,
721 : const UIControlOptions& i_rControlOptions = UIControlOptions());
722 : };
723 :
724 : }
725 :
726 :
727 : #endif // INCLUDED_VCL_PRINT_HXX
728 :
729 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|