xref: /aoo41x/main/vcl/inc/impprn.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #if 0
29*cdf0e10cSrcweir #define _SV_IMPPRN_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <vcl/print.hxx>
32*cdf0e10cSrcweir #include <vcl/timer.hxx>
33*cdf0e10cSrcweir #ifndef _VCL_IMPDEL_HXX
34*cdf0e10cSrcweir #include <vcl/impdel.hxx>
35*cdf0e10cSrcweir #endif
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <vector>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir struct QueuePage;
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir // ----------------
42*cdf0e10cSrcweir // - ImplQPrinter -
43*cdf0e10cSrcweir // ----------------
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir /*
46*cdf0e10cSrcweir     ImplQPrinter is on most systems a simple buffer that allows a potential
47*cdf0e10cSrcweir     lengthy print job to be printed in the background. For this it saves all
48*cdf0e10cSrcweir     normal drawing operations for each printed page to a metafile, then spooling
49*cdf0e10cSrcweir     the metafiles timer based to a normal printer. The application can act in the meantime
50*cdf0e10cSrcweir     including changing the original document without influencing the print job.
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir     On some systems (currently Mac/Aqua Cocoa) ImplQPrinter has the additional
53*cdf0e10cSrcweir     purpose of adapting to the print system: here theprint systems starts a
54*cdf0e10cSrcweir     job and will not return from that function until it has ended; to do so
55*cdf0e10cSrcweir     it queries for each consecutive page to be printed. Also the Cocoa print system
56*cdf0e10cSrcweir     needs to know the number of pages BEFORE starting a print job. Since our Printer
57*cdf0e10cSrcweir     does not know that, we need to do the completing spooling to ImplQPrinter before
58*cdf0e10cSrcweir     we can actually print to the real print system. Let's call this the pull model
59*cdf0e10cSrcweir     instead of the push model (because the systems pulls the pages).
60*cdf0e10cSrcweir */
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir class ImplQPrinter : public Printer, public vcl::DeletionNotifier
63*cdf0e10cSrcweir {
64*cdf0e10cSrcweir private:
65*cdf0e10cSrcweir 	Printer*                        mpParent;
66*cdf0e10cSrcweir 	std::vector< QueuePage* >       maQueue;
67*cdf0e10cSrcweir 	AutoTimer                       maTimer;
68*cdf0e10cSrcweir 	bool                            mbAborted;
69*cdf0e10cSrcweir 	bool                            mbUserCopy;
70*cdf0e10cSrcweir 	bool                            mbDestroyAllowed;
71*cdf0e10cSrcweir 	bool                            mbDestroyed;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir     GDIMetaFile                     maCurPageMetaFile;
74*cdf0e10cSrcweir     long                            mnMaxBmpDPIX;
75*cdf0e10cSrcweir     long                            mnMaxBmpDPIY;
76*cdf0e10cSrcweir     sal_uLong                           mnRestoreDrawMode;
77*cdf0e10cSrcweir     int                             mnCurCopyCount;
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 				DECL_LINK( ImplPrintHdl, Timer* );
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 				~ImplQPrinter();
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 	void		ImplPrintMtf( GDIMetaFile& rMtf, long nMaxBmpDPIX, long nMaxBmpDPIY );
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir                 ImplQPrinter( const ImplQPrinter& rPrinter );
86*cdf0e10cSrcweir     Printer&    operator =( const ImplQPrinter& rPrinter );
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     void        PrePrintPage( QueuePage* );
89*cdf0e10cSrcweir     void        PostPrintPage();
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir public:
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 				ImplQPrinter( Printer* pParent );
94*cdf0e10cSrcweir 	void		Destroy();
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 	void		StartQueuePrint();
97*cdf0e10cSrcweir 	void		EndQueuePrint();
98*cdf0e10cSrcweir 	void		AbortQueuePrint();
99*cdf0e10cSrcweir 	void		AddQueuePage( GDIMetaFile* pPage, sal_uInt16 nPage, sal_Bool bNewJobSetup );
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 	bool		IsUserCopy() const { return mbUserCopy; }
102*cdf0e10cSrcweir 	void		SetUserCopy( bool bSet ) { mbUserCopy = bSet; }
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     /**
105*cdf0e10cSrcweir     used by pull implementation to emit the next page
106*cdf0e10cSrcweir     */
107*cdf0e10cSrcweir     void        PrintPage( unsigned int nPage );
108*cdf0e10cSrcweir     /**
109*cdf0e10cSrcweir     used by pull implementation to get the number of physical pages
110*cdf0e10cSrcweir     (that is how often PrintNextPage should be called)
111*cdf0e10cSrcweir     */
112*cdf0e10cSrcweir     sal_uLong       GetPrintPageCount() const;
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     /**
115*cdf0e10cSrcweir     used by pull implementation to get ranges of physical pages that
116*cdf0e10cSrcweir     are to be printed on the same paper. If bIncludeOrientationChanges is true
117*cdf0e10cSrcweir     then orientation changes will not break a page run; the implementation has
118*cdf0e10cSrcweir     to rotate the page contents accordingly in that case.
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     The returned vector contains all pages indices beginning a new medium and additionally
121*cdf0e10cSrcweir     the index that of the last page+1 (for convenience, so the length of a range
122*cdf0e10cSrcweir     is always v[i+1] - v[i])
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     Example: 5 pages, all A4
125*cdf0e10cSrcweir     return: [0 5]
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     Example: 6 pages, beginning A4, switching tol A5 on fourth page, back to A4 on fifth page
128*cdf0e10cSrcweir     return [0 3 4 6]
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir     returns an false in push model (error condition)
131*cdf0e10cSrcweir     */
132*cdf0e10cSrcweir     bool GetPaperRanges( std::vector< sal_uLong >& o_rRanges, bool i_bIncludeOrientationChanges ) const;
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     /**
135*cdf0e10cSrcweir     get the jobsetup for a page
136*cdf0e10cSrcweir     */
137*cdf0e10cSrcweir     ImplJobSetup* GetPageSetup( unsigned int nPage ) const;
138*cdf0e10cSrcweir };
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir #endif	// _SV_IMPPRN_HXX
141