]>
Commit | Line | Data |
---|---|---|
06d21470 | 1 | Index: psprint/inc/psprint/printergfx.hxx |
2 | =================================================================== | |
3 | RCS file: /cvs/gsl/psprint/inc/psprint/printergfx.hxx,v | |
4 | retrieving revision 1.10 | |
5 | diff -u -p -u -r1.10 printergfx.hxx | |
6 | --- psprint/inc/psprint/printergfx.hxx 26 Mar 2003 14:24:02 -0000 1.10 | |
7 | +++ psprint/inc/psprint/printergfx.hxx 29 May 2003 14:27:22 -0000 | |
8 | @@ -237,6 +237,8 @@ private: | |
9 | osl::File* mpPageHeader; | |
10 | osl::File* mpPageBody; | |
11 | ||
12 | + void InitForPrinter( const rtl::OUString &rPrinter ); | |
13 | + | |
14 | void TranslateCoordinates (sal_Int32 &rXOut, sal_Int32 &rYOut, | |
15 | sal_Int32 nXIn, sal_Int32 nYIn ) | |
16 | { rXOut = nXIn; rYOut = nYIn; } | |
17 | Index: psprint/source/printer/jobdata.cxx | |
18 | =================================================================== | |
19 | RCS file: /cvs/gsl/psprint/source/printer/jobdata.cxx,v | |
20 | retrieving revision 1.2 | |
21 | diff -u -p -u -r1.2 jobdata.cxx | |
22 | --- psprint/source/printer/jobdata.cxx 19 Jun 2002 10:53:34 -0000 1.2 | |
23 | +++ psprint/source/printer/jobdata.cxx 29 May 2003 14:27:54 -0000 | |
24 | @@ -205,9 +205,7 @@ bool JobData::constructFromStreamBuffer( | |
25 | { | |
26 | if( bPrinter ) | |
27 | { | |
28 | - PrinterInfoManager& rManager = PrinterInfoManager::get(); | |
29 | - const PrinterInfo& rInfo = rManager.getPrinterInfo( rJobData.m_aPrinterName ); | |
30 | - rJobData.m_pParser = PPDParser::getParser( rInfo.m_aDriverName ); | |
31 | + rJobData.m_pParser = PrinterInfoManager::get()->getParserForPrinter( rJobData.m_aPrinterName ); | |
32 | if( rJobData.m_pParser ) | |
33 | { | |
34 | rJobData.m_aContext.setParser( rJobData.m_pParser ); | |
35 | Index: psprint/source/printergfx/common_gfx.cxx | |
36 | =================================================================== | |
37 | RCS file: /cvs/gsl/psprint/source/printergfx/common_gfx.cxx,v | |
38 | retrieving revision 1.11 | |
39 | diff -u -p -u -r1.11 common_gfx.cxx | |
40 | --- psprint/source/printergfx/common_gfx.cxx 26 Mar 2003 14:24:07 -0000 1.11 | |
41 | +++ psprint/source/printergfx/common_gfx.cxx 29 May 2003 14:28:17 -0000 | |
42 | @@ -102,6 +102,17 @@ GraphicsStatus::GraphicsStatus() : | |
43 | * non graphics graphics routines | |
44 | */ | |
45 | ||
46 | +void | |
47 | +PrinterGfx::InitForPrinter( const ::rtl::OUString &rPrinter ) | |
48 | +{ | |
49 | + const PPDParser *pParser = PrinterInfoManager::get()->getParserForPrinter( rPrinter ); | |
50 | + | |
51 | + mpFontSubstitutes = PrinterInfoManager::get()->getFontSubstitutesForPrinter( rPrinter ); | |
52 | + | |
53 | + mbUploadPS42Fonts = pParser ? ( pParser->isType42Capable() ? sal_True : sal_False ) : sal_False; | |
54 | +} | |
55 | + | |
56 | + | |
57 | sal_Bool | |
58 | PrinterGfx::Init (PrinterJob &rPrinterJob) | |
59 | { | |
60 | @@ -113,14 +124,8 @@ PrinterGfx::Init (PrinterJob &rPrinterJo | |
61 | ||
62 | mnDpi = rPrinterJob.GetResolution(); | |
63 | rPrinterJob.GetScale (mfScaleX, mfScaleY); | |
64 | - const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( rPrinterJob.GetPrinterName() ) ); | |
65 | - if( mpFontSubstitutes ) | |
66 | - delete const_cast< ::std::hash_map<fontID,fontID>* >(mpFontSubstitutes); | |
67 | - if( rInfo.m_bPerformFontSubstitution ) | |
68 | - mpFontSubstitutes = new ::std::hash_map< fontID, fontID >( rInfo.m_aFontSubstitutions ); | |
69 | - else | |
70 | - mpFontSubstitutes = NULL; | |
71 | - mbUploadPS42Fonts = rInfo.m_pParser ? ( rInfo.m_pParser->isType42Capable() ? sal_True : sal_False ) : sal_False; | |
72 | + | |
73 | + InitForPrinter( rPrinterJob.GetPrinterName() ); | |
74 | ||
75 | return sal_True; | |
76 | } | |
77 | @@ -137,6 +142,7 @@ PrinterGfx::Init (const JobData& rData) | |
78 | mnDpi = nRes; | |
79 | mfScaleX = (double)72.0 / (double)mnDpi; | |
80 | mfScaleY = (double)72.0 / (double)mnDpi; | |
81 | +#if 0 | |
82 | const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( rData.m_aPrinterName ) ); | |
83 | if( mpFontSubstitutes ) | |
84 | delete const_cast< ::std::hash_map<fontID,fontID>* >(mpFontSubstitutes); | |
85 | @@ -145,6 +151,8 @@ PrinterGfx::Init (const JobData& rData) | |
86 | else | |
87 | mpFontSubstitutes = NULL; | |
88 | mbUploadPS42Fonts = rInfo.m_pParser ? ( rInfo.m_pParser->isType42Capable() ? sal_True : sal_False ) : sal_False; | |
89 | +#endif | |
90 | + InitForPrinter( rData.m_aPrinterName ); | |
91 | ||
92 | return sal_True; | |
93 | } | |
6c81318c AM |
94 | |
95 | --- psprint/source/printergfx/printerjob.cxx 2004-03-30 01:22:47.000000000 +0000 | |
96 | +++ psprint/source/printergfx/printerjob.cxx 2004-03-30 01:24:27.000000000 +0000 | |
97 | @@ -575,13 +575,7 @@ | |
06d21470 | 98 | } |
99 | else | |
100 | { | |
101 | - const PrinterInfoManager& rPrinterInfoManager = PrinterInfoManager::get (); | |
102 | - const rtl::OUString& rPrinter = m_aLastJobData.m_aPrinterName; | |
103 | - const PrinterInfo& rPrinterInfo = rPrinterInfoManager.getPrinterInfo (rPrinter); | |
104 | - const rtl::OUString& rCommand = rPrinterInfo.m_aCommand; | |
6c81318c | 105 | - |
06d21470 | 106 | - const rtl::OString aShellCommand = rtl::OUStringToOString (rCommand, |
107 | - RTL_TEXTENCODING_ISO_8859_1); | |
6c81318c AM |
108 | + pDestFILE = PrinterInfoManager::get ()->getPipeToPrinter( m_aLastJobData.m_aPrinterName ); |
109 | ||
110 | /* Mac OS X: open a pipe only if we are using (1) Darwin5 LPR printing. | |
111 | * All other OS X/Darwin cases use spool to file. | |
112 | @@ -595,7 +589,6 @@ | |
113 | #endif | |
114 | ) | |
115 | { | |
116 | - pDestFILE = popen (aShellCommand.getStr(), "w"); | |
117 | if (pDestFILE == NULL) | |
118 | return sal_False; | |
119 | } | |
06d21470 | 120 | Index: psprint/inc/psprint/printerinfomanager.hxx |
121 | =================================================================== | |
122 | RCS file: /cvs/gsl/psprint/inc/psprint/printerinfomanager.hxx,v | |
123 | retrieving revision 1.4 | |
124 | diff -u -p -u -r1.4 printerinfomanager.hxx | |
125 | --- psprint/inc/psprint/printerinfomanager.hxx 10 Jun 2003 14:34:28 -0000 1.4 | |
126 | +++ psprint/inc/psprint/printerinfomanager.hxx 20 Jun 2003 14:47:18 -0000 | |
127 | @@ -83,6 +83,20 @@ | |
128 | ||
129 | namespace psp | |
130 | { | |
131 | +class PrinterInfoManager | |
132 | +{ | |
133 | + static PrinterInfoManager *pGlobalManager; | |
134 | +protected: | |
135 | + static void set (PrinterInfoManager *pManager) { pGlobalManager = pManager; } | |
136 | +public: | |
137 | + static PrinterInfoManager *get (); | |
138 | + virtual const PPDParser *getParserForPrinter( ::rtl::OUString rPrinter ); | |
139 | + virtual ::std::hash_map< fontID, fontID > *getFontSubstitutesForPrinter( ::rtl::OUString rPrinter ); | |
140 | + virtual FILE *getPipeToPrinter( ::rtl::OUString rPrinter ); | |
141 | +}; | |
142 | + | |
143 | +namespace lpr | |
144 | +{ | |
145 | ||
146 | class SystemQueueInfo; | |
147 | ||
148 | @@ -115,7 +129,7 @@ struct PrinterInfo : JobData | |
149 | m_aFontSubstitutions; | |
150 | }; | |
151 | ||
152 | -class PrinterInfoManager | |
153 | +class PrinterInfoManagerLpr : ::psp::PrinterInfoManager | |
154 | { | |
155 | // needed for checkPrintersChanged: files (not necessarily existant) | |
156 | // and their last known modification time | |
157 | @@ -155,8 +169,8 @@ class PrinterInfoManager | |
158 | ||
159 | SystemQueueInfo* m_pQueueInfo; | |
160 | ||
161 | - PrinterInfoManager(); | |
162 | - ~PrinterInfoManager(); | |
163 | + PrinterInfoManagerLpr(); | |
164 | + ~PrinterInfoManagerLpr(); | |
165 | ||
166 | void initialize(); | |
167 | ||
168 | @@ -214,8 +228,14 @@ public: | |
169 | ||
170 | // similar but returnse whole commandlines | |
171 | void getSystemPrintCommands( ::std::list< ::rtl::OUString >& rCommands ); | |
172 | + | |
173 | + virtual const PPDParser *getParserForPrinter( ::rtl::OUString rPrinter ); | |
174 | + virtual ::std::hash_map< fontID, fontID > *getFontSubstitutesForPrinter( ::rtl::OUString rPrinter ); | |
175 | + virtual FILE *getPipeToPrinter( ::rtl::OUString rPrinter ); | |
176 | }; | |
177 | + | |
178 | +} // namespace lpr | |
179 | ||
180 | -} // namespace | |
181 | +} // namespace psp | |
182 | ||
183 | #endif // _PSPRINT_PRINTERINFOMANAGER_HXX_ | |
184 | Index: psprint/source/printer/printerinfomanager.cxx | |
185 | =================================================================== | |
186 | RCS file: /cvs/gsl/psprint/source/printer/printerinfomanager.cxx,v | |
187 | retrieving revision 1.19 | |
188 | diff -u -p -u -r1.19 printerinfomanager.cxx | |
189 | --- psprint/source/printer/printerinfomanager.cxx 12 Jun 2003 11:08:59 -0000 1.19 | |
190 | +++ psprint/source/printer/printerinfomanager.cxx 23 Jun 2003 13:28:10 -0000 | |
191 | @@ -62,6 +62,7 @@ | |
192 | #include <unistd.h> | |
193 | #include <sys/wait.h> | |
194 | #include <signal.h> | |
195 | +#include <stdio.h> | |
196 | ||
197 | #include <tools/urlobj.hxx> | |
198 | #include <tools/stream.hxx> | |
199 | @@ -81,10 +82,41 @@ | |
200 | using namespace psp; | |
201 | using namespace rtl; | |
202 | using namespace osl; | |
203 | +using namespace lpr; | |
204 | ||
205 | namespace psp | |
206 | { | |
207 | -class SystemQueueInfo : public Thread | |
208 | + | |
209 | +PrinterInfoManager *::psp::PrinterInfoManager::pGlobalManager = NULL; | |
210 | + | |
211 | +const ::psp::PPDParser * | |
212 | +PrinterInfoManager::getParserForPrinter( ::rtl::OUString rPrinter ) | |
213 | +{ | |
214 | + fprintf( stderr, "error, base PrinterInfoManager::getParserForPrinter\n" ); | |
215 | + return NULL; | |
216 | +} | |
217 | + | |
218 | +::std::hash_map< fontID, fontID > * | |
219 | +PrinterInfoManager::getFontSubstitutesForPrinter( ::rtl::OUString rPrinter ) | |
220 | +{ // font mapping tables are a terrible idea. | |
221 | + fprintf( stderr, "error, base PrinterInfoManager::getFontSubstitutesForPrinter\n" ); | |
222 | + return NULL; | |
223 | +} | |
224 | + | |
225 | +::psp::PrinterInfoManager * | |
226 | +PrinterInfoManager::get () | |
227 | +{ | |
228 | + return pGlobalManager; | |
229 | +} | |
230 | + | |
231 | +FILE * | |
232 | +PrinterInfoManager::getPipeToPrinter( ::rtl::OUString rPrinter ) | |
233 | +{ | |
234 | + fprintf( stderr, "error, base PrinterInfoManager::getPipeToPrinter\n" ); | |
235 | + return NULL; | |
236 | +} | |
237 | + | |
238 | +class psp::lpr::SystemQueueInfo : public Thread | |
239 | { | |
240 | mutable Mutex m_aMutex; | |
241 | bool m_bChanged; | |
242 | @@ -106,21 +138,21 @@ class SystemQueueInfo : public Thread | |
243 | } // namespace | |
244 | ||
245 | /* | |
246 | - * class PrinterInfoManager | |
247 | + * class PrinterInfoManagerLpr | |
248 | */ | |
249 | ||
250 | // ----------------------------------------------------------------- | |
251 | ||
252 | -PrinterInfoManager& PrinterInfoManager::get() | |
253 | +PrinterInfoManager& PrinterInfoManagerLpr::get() | |
254 | { | |
255 | - static PrinterInfoManager aManager; | |
256 | + static PrinterInfoManagerLpr aManager; | |
257 | ||
258 | return aManager; | |
259 | } | |
260 | ||
261 | // ----------------------------------------------------------------- | |
262 | ||
263 | -PrinterInfoManager::PrinterInfoManager() | |
264 | +PrinterInfoManagerLpr::PrinterInfoManagerLpr() | |
265 | { | |
266 | m_pQueueInfo = new SystemQueueInfo(); | |
267 | initialize(); | |
268 | @@ -128,14 +160,14 @@ PrinterInfoManager::PrinterInfoManager() | |
269 | ||
270 | // ----------------------------------------------------------------- | |
271 | ||
272 | -PrinterInfoManager::~PrinterInfoManager() | |
273 | +PrinterInfoManagerLpr::~PrinterInfoManagerLpr() | |
274 | { | |
275 | delete m_pQueueInfo; | |
276 | } | |
277 | ||
278 | // ----------------------------------------------------------------- | |
279 | ||
280 | -bool PrinterInfoManager::checkPrintersChanged() | |
281 | +bool PrinterInfoManagerLpr::checkPrintersChanged() | |
282 | { | |
283 | // check if files were created, deleted or modified since initialize() | |
284 | ||
285 | @@ -172,7 +204,7 @@ bool PrinterInfoManager::checkPrintersCh | |
286 | ||
287 | // ----------------------------------------------------------------- | |
288 | ||
289 | -void PrinterInfoManager::initialize() | |
290 | +void PrinterInfoManagerLpr::initialize() | |
291 | { | |
292 | rtl_TextEncoding aEncoding = gsl_getSystemTextEncoding(); | |
293 | m_aPrinters.clear(); | |
294 | @@ -542,7 +574,7 @@ void PrinterInfoManager::initialize() | |
295 | ||
296 | // ----------------------------------------------------------------- | |
297 | ||
298 | -void PrinterInfoManager::listPrinters( ::std::list< OUString >& rList ) const | |
299 | +void PrinterInfoManagerLpr::listPrinters( ::std::list< OUString >& rList ) const | |
300 | { | |
301 | ::std::hash_map< OUString, Printer, OUStringHash >::const_iterator it; | |
302 | rList.clear(); | |
303 | @@ -552,7 +584,7 @@ void PrinterInfoManager::listPrinters( : | |
304 | ||
305 | // ----------------------------------------------------------------- | |
306 | ||
307 | -const PrinterInfo& PrinterInfoManager::getPrinterInfo( const OUString& rPrinter ) const | |
308 | +const PrinterInfo& PrinterInfoManagerLpr::getPrinterInfo( const OUString& rPrinter ) const | |
309 | { | |
310 | static PrinterInfo aEmptyInfo; | |
311 | ::std::hash_map< OUString, Printer, OUStringHash >::const_iterator it = m_aPrinters.find( rPrinter ); | |
312 | @@ -564,7 +596,7 @@ const PrinterInfo& PrinterInfoManager::g | |
313 | ||
314 | // ----------------------------------------------------------------- | |
315 | ||
316 | -void PrinterInfoManager::changePrinterInfo( const OUString& rPrinter, const PrinterInfo& rNewInfo ) | |
317 | +void PrinterInfoManagerLpr::changePrinterInfo( const OUString& rPrinter, const PrinterInfo& rNewInfo ) | |
318 | { | |
319 | ::std::hash_map< OUString, Printer, OUStringHash >::iterator it = m_aPrinters.find( rPrinter ); | |
320 | ||
321 | @@ -593,7 +625,7 @@ static bool checkWriteability( const OUS | |
322 | return bRet; | |
323 | } | |
324 | ||
325 | -bool PrinterInfoManager::writePrinterConfig() | |
326 | +bool PrinterInfoManagerLpr::writePrinterConfig() | |
327 | { | |
328 | // find at least one writeable config | |
329 | ::std::hash_map< OUString, Config*, OUStringHash > files; | |
330 | @@ -724,7 +756,7 @@ bool PrinterInfoManager::writePrinterCon | |
331 | ||
332 | // ----------------------------------------------------------------- | |
333 | ||
334 | -bool PrinterInfoManager::addPrinter( const OUString& rPrinterName, const OUString& rDriverName ) | |
335 | +bool PrinterInfoManagerLpr::addPrinter( const OUString& rPrinterName, const OUString& rDriverName ) | |
336 | { | |
337 | bool bSuccess = false; | |
338 | ||
339 | @@ -769,7 +801,7 @@ bool PrinterInfoManager::addPrinter( con | |
340 | ||
341 | // ----------------------------------------------------------------- | |
342 | ||
343 | -bool PrinterInfoManager::removePrinter( const OUString& rPrinterName, bool bCheckOnly ) | |
344 | +bool PrinterInfoManagerLpr::removePrinter( const OUString& rPrinterName, bool bCheckOnly ) | |
345 | { | |
346 | bool bSuccess = true; | |
347 | ||
348 | @@ -823,7 +855,7 @@ bool PrinterInfoManager::removePrinter( | |
349 | ||
350 | // ----------------------------------------------------------------- | |
351 | ||
352 | -bool PrinterInfoManager::setDefaultPrinter( const OUString& rPrinterName ) | |
353 | +bool PrinterInfoManagerLpr::setDefaultPrinter( const OUString& rPrinterName ) | |
354 | { | |
355 | bool bSuccess = false; | |
356 | ||
357 | @@ -841,7 +873,7 @@ bool PrinterInfoManager::setDefaultPrint | |
358 | ||
359 | // ----------------------------------------------------------------- | |
360 | ||
361 | -void PrinterInfoManager::fillFontSubstitutions( PrinterInfo& rInfo ) const | |
362 | +void PrinterInfoManagerLpr::fillFontSubstitutions( PrinterInfo& rInfo ) const | |
363 | { | |
364 | PrintFontManager& rFontManager( PrintFontManager::get() ); | |
365 | rInfo.m_aFontSubstitutions.clear(); | |
366 | @@ -938,7 +970,7 @@ void PrinterInfoManager::fillFontSubstit | |
367 | ||
368 | // ----------------------------------------------------------------- | |
369 | ||
370 | -void PrinterInfoManager::getSystemPrintCommands( std::list< OUString >& rCommands ) | |
371 | +void PrinterInfoManagerLpr::getSystemPrintCommands( std::list< OUString >& rCommands ) | |
372 | { | |
373 | if( m_pQueueInfo->hasChanged() ) | |
374 | { | |
375 | @@ -957,7 +989,7 @@ void PrinterInfoManager::getSystemPrintC | |
376 | } | |
377 | } | |
378 | ||
379 | -const std::list< OUString >& PrinterInfoManager::getSystemPrintQueues() | |
380 | +const std::list< OUString >& PrinterInfoManagerLpr::getSystemPrintQueues() | |
381 | { | |
382 | if( m_pQueueInfo->hasChanged() ) | |
383 | { | |
384 | @@ -1097,4 +1129,36 @@ void SystemQueueInfo::run() | |
385 | m_aQueues = aSysPrintQueues; | |
386 | m_aCommand = aPrintCommand; | |
387 | } | |
388 | +} | |
389 | + | |
390 | +// --- untested, just to show willing --- | |
391 | + | |
392 | +const PPDParser * | |
393 | +PrinterInfoManagerLpr::getParserForPrinter( ::rtl::OUString rPrinter ) | |
394 | +{ | |
395 | + PrinterInfo rInfo( getPrinterInfo( rPrinter ) ); | |
396 | + return rInfo.m_pParser; | |
397 | +} | |
398 | + | |
399 | +::std::hash_map< fontID, fontID > * | |
400 | +PrinterInfoManagerLpr::getFontSubstitutesForPrinter( ::rtl::OUString rPrinter ) | |
401 | +{ | |
402 | + PrinterInfo rInfo( getPrinterInfo( rPrinter ) ); | |
403 | + | |
404 | + if( !rInfo.m_bPerformFontSubstitution ) | |
405 | + return NULL; | |
406 | + | |
407 | + return new ::std::hash_map< fontID, fontID >( rInfo.m_aFontSubstitutions ); | |
408 | +} | |
409 | + | |
410 | +FILE * | |
411 | +PrinterInfoManagerLpr::getPipeToPrinter( ::rtl::OUString rPrinter ) | |
412 | +{ | |
413 | + const PrinterInfo& rPrinterInfo = getPrinterInfo (rPrinter); | |
414 | + const rtl::OUString& rCommand = rPrinterInfo.m_aCommand; | |
415 | + | |
416 | + const rtl::OString aShellCommand = rtl::OUStringToOString | |
417 | + ( rCommand, RTL_TEXTENCODING_ISO_8859_1); | |
418 | + | |
419 | + return popen (aShellCommand.getStr(), "w"); | |
420 | } |