xref: /aoo42x/main/vcl/inc/impprn.hxx (revision ebfcd9af)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #if 0
25 #define _SV_IMPPRN_HXX
26 
27 #include <vcl/print.hxx>
28 #include <vcl/timer.hxx>
29 #ifndef _VCL_IMPDEL_HXX
30 #include <vcl/impdel.hxx>
31 #endif
32 
33 #include <vector>
34 
35 struct QueuePage;
36 
37 // ----------------
38 // - ImplQPrinter -
39 // ----------------
40 
41 /*
42     ImplQPrinter is on most systems a simple buffer that allows a potential
43     lengthy print job to be printed in the background. For this it saves all
44     normal drawing operations for each printed page to a metafile, then spooling
45     the metafiles timer based to a normal printer. The application can act in the meantime
46     including changing the original document without influencing the print job.
47 
48     On some systems (currently Mac/Aqua Cocoa) ImplQPrinter has the additional
49     purpose of adapting to the print system: here theprint systems starts a
50     job and will not return from that function until it has ended; to do so
51     it queries for each consecutive page to be printed. Also the Cocoa print system
52     needs to know the number of pages BEFORE starting a print job. Since our Printer
53     does not know that, we need to do the completing spooling to ImplQPrinter before
54     we can actually print to the real print system. Let's call this the pull model
55     instead of the push model (because the systems pulls the pages).
56 */
57 
58 class ImplQPrinter : public Printer, public vcl::DeletionNotifier
59 {
60 private:
61 	Printer*                        mpParent;
62 	std::vector< QueuePage* >       maQueue;
63 	AutoTimer                       maTimer;
64 	bool                            mbAborted;
65 	bool                            mbUserCopy;
66 	bool                            mbDestroyAllowed;
67 	bool                            mbDestroyed;
68 
69     GDIMetaFile                     maCurPageMetaFile;
70     long                            mnMaxBmpDPIX;
71     long                            mnMaxBmpDPIY;
72     sal_uLong                           mnRestoreDrawMode;
73     int                             mnCurCopyCount;
74 
75 				DECL_LINK( ImplPrintHdl, Timer* );
76 
77 				~ImplQPrinter();
78 
79 	void		ImplPrintMtf( GDIMetaFile& rMtf, long nMaxBmpDPIX, long nMaxBmpDPIY );
80 
81                 ImplQPrinter( const ImplQPrinter& rPrinter );
82     Printer&    operator =( const ImplQPrinter& rPrinter );
83 
84     void        PrePrintPage( QueuePage* );
85     void        PostPrintPage();
86 
87 public:
88 
89 				ImplQPrinter( Printer* pParent );
90 	void		Destroy();
91 
92 	void		StartQueuePrint();
93 	void		EndQueuePrint();
94 	void		AbortQueuePrint();
95 	void		AddQueuePage( GDIMetaFile* pPage, sal_uInt16 nPage, sal_Bool bNewJobSetup );
96 
97 	bool		IsUserCopy() const { return mbUserCopy; }
98 	void		SetUserCopy( bool bSet ) { mbUserCopy = bSet; }
99 
100     /**
101     used by pull implementation to emit the next page
102     */
103     void        PrintPage( unsigned int nPage );
104     /**
105     used by pull implementation to get the number of physical pages
106     (that is how often PrintNextPage should be called)
107     */
108     sal_uLong       GetPrintPageCount() const;
109 
110     /**
111     used by pull implementation to get ranges of physical pages that
112     are to be printed on the same paper. If bIncludeOrientationChanges is true
113     then orientation changes will not break a page run; the implementation has
114     to rotate the page contents accordingly in that case.
115 
116     The returned vector contains all pages indices beginning a new medium and additionally
117     the index that of the last page+1 (for convenience, so the length of a range
118     is always v[i+1] - v[i])
119 
120     Example: 5 pages, all A4
121     return: [0 5]
122 
123     Example: 6 pages, beginning A4, switching tol A5 on fourth page, back to A4 on fifth page
124     return [0 3 4 6]
125 
126     returns an false in push model (error condition)
127     */
128     bool GetPaperRanges( std::vector< sal_uLong >& o_rRanges, bool i_bIncludeOrientationChanges ) const;
129 
130     /**
131     get the jobsetup for a page
132     */
133     ImplJobSetup* GetPageSetup( unsigned int nPage ) const;
134 };
135 
136 #endif	// _SV_IMPPRN_HXX
137