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;
12 + void InitForPrinter( const rtl::OUString &rPrinter );
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(
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 )
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
47 +PrinterGfx::InitForPrinter( const ::rtl::OUString &rPrinter )
49 + const PPDParser *pParser = PrinterInfoManager::get()->getParserForPrinter( rPrinter );
51 + mpFontSubstitutes = PrinterInfoManager::get()->getFontSubstitutesForPrinter( rPrinter );
53 + mbUploadPS42Fonts = pParser ? ( pParser->isType42Capable() ? sal_True : sal_False ) : sal_False;
58 PrinterGfx::Init (PrinterJob &rPrinterJob)
60 @@ -113,14 +124,8 @@ PrinterGfx::Init (PrinterJob &rPrinterJo
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 );
70 - mpFontSubstitutes = NULL;
71 - mbUploadPS42Fonts = rInfo.m_pParser ? ( rInfo.m_pParser->isType42Capable() ? sal_True : sal_False ) : sal_False;
73 + InitForPrinter( rPrinterJob.GetPrinterName() );
77 @@ -137,6 +142,7 @@ PrinterGfx::Init (const JobData& rData)
79 mfScaleX = (double)72.0 / (double)mnDpi;
80 mfScaleY = (double)72.0 / (double)mnDpi;
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)
87 mpFontSubstitutes = NULL;
88 mbUploadPS42Fonts = rInfo.m_pParser ? ( rInfo.m_pParser->isType42Capable() ? sal_True : sal_False ) : sal_False;
90 + InitForPrinter( rData.m_aPrinterName );
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
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;
106 - const rtl::OString aShellCommand = rtl::OUStringToOString (rCommand,
107 - RTL_TEXTENCODING_ISO_8859_1);
108 + pDestFILE = PrinterInfoManager::get ()->getPipeToPrinter( m_aLastJobData.m_aPrinterName );
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.
116 - pDestFILE = popen (aShellCommand.getStr(), "w");
117 if (pDestFILE == NULL)
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
131 +class PrinterInfoManager
133 + static PrinterInfoManager *pGlobalManager;
135 + static void set (PrinterInfoManager *pManager) { pGlobalManager = pManager; }
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 );
146 class SystemQueueInfo;
148 @@ -115,7 +129,7 @@ struct PrinterInfo : JobData
149 m_aFontSubstitutions;
152 -class PrinterInfoManager
153 +class PrinterInfoManagerLpr : ::psp::PrinterInfoManager
155 // needed for checkPrintersChanged: files (not necessarily existant)
156 // and their last known modification time
157 @@ -155,8 +169,8 @@ class PrinterInfoManager
159 SystemQueueInfo* m_pQueueInfo;
161 - PrinterInfoManager();
162 - ~PrinterInfoManager();
163 + PrinterInfoManagerLpr();
164 + ~PrinterInfoManagerLpr();
168 @@ -214,8 +228,14 @@ public:
170 // similar but returnse whole commandlines
171 void getSystemPrintCommands( ::std::list< ::rtl::OUString >& rCommands );
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 );
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
193 #include <sys/wait.h>
197 #include <tools/urlobj.hxx>
198 #include <tools/stream.hxx>
203 +using namespace lpr;
207 -class SystemQueueInfo : public Thread
209 +PrinterInfoManager *::psp::PrinterInfoManager::pGlobalManager = NULL;
211 +const ::psp::PPDParser *
212 +PrinterInfoManager::getParserForPrinter( ::rtl::OUString rPrinter )
214 + fprintf( stderr, "error, base PrinterInfoManager::getParserForPrinter\n" );
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" );
225 +::psp::PrinterInfoManager *
226 +PrinterInfoManager::get ()
228 + return pGlobalManager;
232 +PrinterInfoManager::getPipeToPrinter( ::rtl::OUString rPrinter )
234 + fprintf( stderr, "error, base PrinterInfoManager::getPipeToPrinter\n" );
238 +class psp::lpr::SystemQueueInfo : public Thread
240 mutable Mutex m_aMutex;
242 @@ -106,21 +138,21 @@ class SystemQueueInfo : public Thread
246 - * class PrinterInfoManager
247 + * class PrinterInfoManagerLpr
250 // -----------------------------------------------------------------
252 -PrinterInfoManager& PrinterInfoManager::get()
253 +PrinterInfoManager& PrinterInfoManagerLpr::get()
255 - static PrinterInfoManager aManager;
256 + static PrinterInfoManagerLpr aManager;
261 // -----------------------------------------------------------------
263 -PrinterInfoManager::PrinterInfoManager()
264 +PrinterInfoManagerLpr::PrinterInfoManagerLpr()
266 m_pQueueInfo = new SystemQueueInfo();
268 @@ -128,14 +160,14 @@ PrinterInfoManager::PrinterInfoManager()
270 // -----------------------------------------------------------------
272 -PrinterInfoManager::~PrinterInfoManager()
273 +PrinterInfoManagerLpr::~PrinterInfoManagerLpr()
278 // -----------------------------------------------------------------
280 -bool PrinterInfoManager::checkPrintersChanged()
281 +bool PrinterInfoManagerLpr::checkPrintersChanged()
283 // check if files were created, deleted or modified since initialize()
285 @@ -172,7 +204,7 @@ bool PrinterInfoManager::checkPrintersCh
287 // -----------------------------------------------------------------
289 -void PrinterInfoManager::initialize()
290 +void PrinterInfoManagerLpr::initialize()
292 rtl_TextEncoding aEncoding = gsl_getSystemTextEncoding();
294 @@ -542,7 +574,7 @@ void PrinterInfoManager::initialize()
296 // -----------------------------------------------------------------
298 -void PrinterInfoManager::listPrinters( ::std::list< OUString >& rList ) const
299 +void PrinterInfoManagerLpr::listPrinters( ::std::list< OUString >& rList ) const
301 ::std::hash_map< OUString, Printer, OUStringHash >::const_iterator it;
303 @@ -552,7 +584,7 @@ void PrinterInfoManager::listPrinters( :
305 // -----------------------------------------------------------------
307 -const PrinterInfo& PrinterInfoManager::getPrinterInfo( const OUString& rPrinter ) const
308 +const PrinterInfo& PrinterInfoManagerLpr::getPrinterInfo( const OUString& rPrinter ) const
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
314 // -----------------------------------------------------------------
316 -void PrinterInfoManager::changePrinterInfo( const OUString& rPrinter, const PrinterInfo& rNewInfo )
317 +void PrinterInfoManagerLpr::changePrinterInfo( const OUString& rPrinter, const PrinterInfo& rNewInfo )
319 ::std::hash_map< OUString, Printer, OUStringHash >::iterator it = m_aPrinters.find( rPrinter );
321 @@ -593,7 +625,7 @@ static bool checkWriteability( const OUS
325 -bool PrinterInfoManager::writePrinterConfig()
326 +bool PrinterInfoManagerLpr::writePrinterConfig()
328 // find at least one writeable config
329 ::std::hash_map< OUString, Config*, OUStringHash > files;
330 @@ -724,7 +756,7 @@ bool PrinterInfoManager::writePrinterCon
332 // -----------------------------------------------------------------
334 -bool PrinterInfoManager::addPrinter( const OUString& rPrinterName, const OUString& rDriverName )
335 +bool PrinterInfoManagerLpr::addPrinter( const OUString& rPrinterName, const OUString& rDriverName )
337 bool bSuccess = false;
339 @@ -769,7 +801,7 @@ bool PrinterInfoManager::addPrinter( con
341 // -----------------------------------------------------------------
343 -bool PrinterInfoManager::removePrinter( const OUString& rPrinterName, bool bCheckOnly )
344 +bool PrinterInfoManagerLpr::removePrinter( const OUString& rPrinterName, bool bCheckOnly )
346 bool bSuccess = true;
348 @@ -823,7 +855,7 @@ bool PrinterInfoManager::removePrinter(
350 // -----------------------------------------------------------------
352 -bool PrinterInfoManager::setDefaultPrinter( const OUString& rPrinterName )
353 +bool PrinterInfoManagerLpr::setDefaultPrinter( const OUString& rPrinterName )
355 bool bSuccess = false;
357 @@ -841,7 +873,7 @@ bool PrinterInfoManager::setDefaultPrint
359 // -----------------------------------------------------------------
361 -void PrinterInfoManager::fillFontSubstitutions( PrinterInfo& rInfo ) const
362 +void PrinterInfoManagerLpr::fillFontSubstitutions( PrinterInfo& rInfo ) const
364 PrintFontManager& rFontManager( PrintFontManager::get() );
365 rInfo.m_aFontSubstitutions.clear();
366 @@ -938,7 +970,7 @@ void PrinterInfoManager::fillFontSubstit
368 // -----------------------------------------------------------------
370 -void PrinterInfoManager::getSystemPrintCommands( std::list< OUString >& rCommands )
371 +void PrinterInfoManagerLpr::getSystemPrintCommands( std::list< OUString >& rCommands )
373 if( m_pQueueInfo->hasChanged() )
375 @@ -957,7 +989,7 @@ void PrinterInfoManager::getSystemPrintC
379 -const std::list< OUString >& PrinterInfoManager::getSystemPrintQueues()
380 +const std::list< OUString >& PrinterInfoManagerLpr::getSystemPrintQueues()
382 if( m_pQueueInfo->hasChanged() )
384 @@ -1097,4 +1129,36 @@ void SystemQueueInfo::run()
385 m_aQueues = aSysPrintQueues;
386 m_aCommand = aPrintCommand;
390 +// --- untested, just to show willing ---
393 +PrinterInfoManagerLpr::getParserForPrinter( ::rtl::OUString rPrinter )
395 + PrinterInfo rInfo( getPrinterInfo( rPrinter ) );
396 + return rInfo.m_pParser;
399 +::std::hash_map< fontID, fontID > *
400 +PrinterInfoManagerLpr::getFontSubstitutesForPrinter( ::rtl::OUString rPrinter )
402 + PrinterInfo rInfo( getPrinterInfo( rPrinter ) );
404 + if( !rInfo.m_bPerformFontSubstitution )
407 + return new ::std::hash_map< fontID, fontID >( rInfo.m_aFontSubstitutions );
411 +PrinterInfoManagerLpr::getPipeToPrinter( ::rtl::OUString rPrinter )
413 + const PrinterInfo& rPrinterInfo = getPrinterInfo (rPrinter);
414 + const rtl::OUString& rCommand = rPrinterInfo.m_aCommand;
416 + const rtl::OString aShellCommand = rtl::OUStringToOString
417 + ( rCommand, RTL_TEXTENCODING_ISO_8859_1);
419 + return popen (aShellCommand.getStr(), "w");