Lines 73-83
Link Here
|
73 |
#include <osl/thread.hxx> |
73 |
#include <osl/thread.hxx> |
74 |
#include <osl/mutex.hxx> |
74 |
#include <osl/mutex.hxx> |
75 |
|
75 |
|
|
|
76 |
#ifdef MACOSX |
77 |
#include <sys/stat.h> |
78 |
#endif |
79 |
|
76 |
// filename of configuration files |
80 |
// filename of configuration files |
77 |
#define PRINT_FILENAME "psprint.conf" |
81 |
#define PRINT_FILENAME "psprint.conf" |
78 |
// the group of the global defaults |
82 |
// the group of the global defaults |
79 |
#define GLOBAL_DEFAULTS_GROUP "__Global_Printer_Defaults__" |
83 |
#define GLOBAL_DEFAULTS_GROUP "__Global_Printer_Defaults__" |
80 |
|
84 |
|
|
|
85 |
#ifdef MACOSX |
86 |
// filename of CUPS config file |
87 |
#define MACXP_CUPS_CONF_FILENAME "printers.conf" |
88 |
#define MACXP_CUPS_CONF_DIR "/etc/cups/" |
89 |
#endif |
90 |
|
81 |
using namespace psp; |
91 |
using namespace psp; |
82 |
using namespace rtl; |
92 |
using namespace rtl; |
83 |
using namespace osl; |
93 |
using namespace osl; |
Lines 165-171
Link Here
|
165 |
if( ! bChanged ) |
175 |
if( ! bChanged ) |
166 |
bChanged = m_pQueueInfo->hasChanged(); |
176 |
bChanged = m_pQueueInfo->hasChanged(); |
167 |
if( bChanged ) |
177 |
if( bChanged ) |
|
|
178 |
{ |
179 |
#ifdef MACOSX |
180 |
// For Mac OS X 10.2, the user may change print queues via the Print Center |
181 |
// at any point. Therefore, we need to completely requery the system |
182 |
// for print queues when our watch file changes. |
183 |
sal_Int32 applePrintSystem; |
184 |
|
185 |
applePrintSystem = macxp_GetSystemPrintMethod(); |
186 |
if ( applePrintSystem == kApplePrintingCUPS ) |
187 |
m_aSystemPrintQueues.clear(); |
188 |
#endif |
168 |
initialize(); |
189 |
initialize(); |
|
|
190 |
} |
169 |
|
191 |
|
170 |
return bChanged; |
192 |
return bChanged; |
171 |
} |
193 |
} |
Lines 174-184
Link Here
|
174 |
|
196 |
|
175 |
void PrinterInfoManager::initialize() |
197 |
void PrinterInfoManager::initialize() |
176 |
{ |
198 |
{ |
|
|
199 |
#ifdef MACOSX |
200 |
sal_Int32 applePrintSystem; |
201 |
#endif |
177 |
rtl_TextEncoding aEncoding = gsl_getSystemTextEncoding(); |
202 |
rtl_TextEncoding aEncoding = gsl_getSystemTextEncoding(); |
178 |
m_aPrinters.clear(); |
203 |
m_aPrinters.clear(); |
179 |
m_aWatchFiles.clear(); |
204 |
m_aWatchFiles.clear(); |
180 |
OUString aDefaultPrinter; |
205 |
OUString aDefaultPrinter; |
181 |
|
206 |
|
|
|
207 |
#ifdef MACOSX |
208 |
// Discover the print system to use on Mac OS X/Darwin |
209 |
applePrintSystem = macxp_GetSystemPrintMethod(); |
210 |
#endif |
211 |
|
182 |
// first initialize the global defaults |
212 |
// first initialize the global defaults |
183 |
// have to iterate over all possible files |
213 |
// have to iterate over all possible files |
184 |
// there should be only one global setup section in all |
214 |
// there should be only one global setup section in all |
Lines 273-278
Link Here
|
273 |
} |
303 |
} |
274 |
fillFontSubstitutions( m_aGlobalDefaults ); |
304 |
fillFontSubstitutions( m_aGlobalDefaults ); |
275 |
|
305 |
|
|
|
306 |
#ifdef MACOSX |
307 |
// For Mac OS X 10.2 with CUPS printing, we also wish to be |
308 |
// notified of queue/printer updates, but these don't necessarily |
309 |
// happen when psprint.conf changes. The user can change settings in |
310 |
// the Print Center which should also make OOo update its queue list. |
311 |
if ( applePrintSystem == kApplePrintingCUPS ) |
312 |
{ |
313 |
// /etc/cups/printers.conf gets modified every time the Print Center printer |
314 |
// list is modified, so we want to watch this file too. |
315 |
INetURLObject aCUPSDir( String(RTL_CONSTASCII_USTRINGPARAM(MACXP_CUPS_CONF_DIR)), INET_PROT_FILE, INetURLObject::ENCODE_ALL ); |
316 |
INetURLObject aCUPSConfFile( aCUPSDir ); |
317 |
aCUPSConfFile.Append( String(RTL_CONSTASCII_USTRINGPARAM(MACXP_CUPS_CONF_FILENAME)) ); |
318 |
|
319 |
// check directory validity |
320 |
OUString aCUPSUniPath; |
321 |
FileBase::getFileURLFromSystemPath( aCUPSDir.PathToFileName(), aCUPSUniPath ); |
322 |
Directory aTestDirectory( aCUPSUniPath ); |
323 |
|
324 |
// If aTestDirectory.open() returns E_None (0), then we are OK. |
325 |
// If not, don't add the watch file because we can't get to it. |
326 |
if( aTestDirectory.open() == FileBase::E_None ) |
327 |
{ |
328 |
aTestDirectory.close(); |
329 |
|
330 |
FileBase::getFileURLFromSystemPath( aCUPSConfFile.PathToFileName(), aCUPSUniPath ); |
331 |
FileStatus aTestStatus( FileStatusMask_All ); |
332 |
DirectoryItem aTestItem; |
333 |
|
334 |
// setup WatchFile list |
335 |
WatchFile aCUPSWatchFile; |
336 |
aCUPSWatchFile.m_aFilePath = aCUPSUniPath; |
337 |
if( ! DirectoryItem::get( aCUPSUniPath, aTestItem ) && |
338 |
! aTestItem.getFileStatus( aTestStatus ) ) |
339 |
{ |
340 |
aCUPSWatchFile.m_aModified = aTestStatus.getModifyTime(); |
341 |
} |
342 |
else |
343 |
{ |
344 |
aCUPSWatchFile.m_aModified.Seconds = 0; |
345 |
aCUPSWatchFile.m_aModified.Nanosec = 0; |
346 |
} |
347 |
m_aWatchFiles.push_back( aCUPSWatchFile ); |
348 |
} |
349 |
} |
350 |
#endif |
351 |
|
276 |
// now collect all available printers |
352 |
// now collect all available printers |
277 |
for( print_dir_it = aDirList.begin(); print_dir_it != aDirList.end(); ++print_dir_it ) |
353 |
for( print_dir_it = aDirList.begin(); print_dir_it != aDirList.end(); ++print_dir_it ) |
278 |
{ |
354 |
{ |
Lines 377-382
Link Here
|
377 |
*/ |
453 |
*/ |
378 |
#if defined SOLARIS || defined(IRIX) |
454 |
#if defined SOLARIS || defined(IRIX) |
379 |
aValue = "lp"; |
455 |
aValue = "lp"; |
|
|
456 |
#elif defined(MACOSX) |
457 |
if ( applePrintSystem == kApplePrintingCUPS ) |
458 |
aValue = "lp"; |
459 |
else if ( applePrintSystem == kApplePrintingPrintCenter ) |
460 |
aValue = kApplePCPrintCommand; |
461 |
else |
462 |
{ |
463 |
// Fallback case is kApplePrintingLPR |
464 |
aValue = "lpr"; |
465 |
} |
380 |
#else |
466 |
#else |
381 |
aValue = "lpr"; |
467 |
aValue = "lpr"; |
382 |
#endif |
468 |
#endif |
Lines 536-541
Link Here
|
536 |
aPrinter.m_bModified = false; |
622 |
aPrinter.m_bModified = false; |
537 |
aPrinter.m_aGroup = ByteString( aPrinterName, aEncoding ); //provide group name in case user makes this one permanent in padmin |
623 |
aPrinter.m_aGroup = ByteString( aPrinterName, aEncoding ); //provide group name in case user makes this one permanent in padmin |
538 |
|
624 |
|
|
|
625 |
#ifdef MACOSX |
626 |
// If we are using OS X 10.2 CUPS printing, we want to grab the PPD that this printer |
627 |
// is associated with from /etc/cups/ppd (it's autocreated by the OS X printing system) and |
628 |
// use those values instead of the ones generated in the merged defaults. We want to make |
629 |
// this system printer just like we assigned it a PPD in padmin. |
630 |
if ( applePrintSystem == kApplePrintingCUPS ) |
631 |
{ |
632 |
aPrinter.m_aInfo.m_aFontSubstitutes.clear(); |
633 |
aPrinter.m_aInfo.m_aFontSubstitutions.clear(); |
634 |
|
635 |
// Printer's autogenerated PPD will be /etc/cups/ppd/<printername-from-lpstat>.ppd |
636 |
aPrinter.m_aInfo.m_aDriverName = String( *it ); |
637 |
aPrinter.m_aInfo.m_pParser = PPDParser::getParser( aPrinter.m_aInfo.m_aDriverName ); |
638 |
aPrinter.m_aInfo.m_aContext.setParser( aPrinter.m_aInfo.m_pParser ); |
639 |
|
640 |
if( aPrinter.m_aInfo.m_pParser ) |
641 |
{ |
642 |
// merge the ppd context keys if the printer has the same keys and values |
643 |
// it is mainly to select default paper sizes for new printers |
644 |
for( int nPPDValueModified = 0; nPPDValueModified < m_aGlobalDefaults.m_aContext.countValuesModified(); nPPDValueModified++ ) |
645 |
{ |
646 |
const PPDKey* pDefKey = m_aGlobalDefaults.m_aContext.getModifiedKey( nPPDValueModified ); |
647 |
const PPDValue* pDefValue = m_aGlobalDefaults.m_aContext.getValue( pDefKey ); |
648 |
// If the default PPD has a certain key, attempt to get that same key in the Printer's PPD |
649 |
const PPDKey* pPrinterKey = pDefKey ? aPrinter.m_aInfo.m_pParser->getKey( pDefKey->getKey() ) : NULL; |
650 |
|
651 |
// The key usually merged is PageSize |
652 |
if( pDefKey && pPrinterKey ) |
653 |
{ |
654 |
// Key exists in both the Default PPD and the printer's specific PPD. |
655 |
if( pDefValue ) |
656 |
{ |
657 |
const PPDValue* pPrinterValue = pPrinterKey->getValue( pDefValue->m_aOption ); |
658 |
// If the printer has a corresponding option for the key, use printer PPD's option |
659 |
if( pPrinterValue ) |
660 |
aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, pPrinterValue ); |
661 |
} |
662 |
else |
663 |
aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, NULL ); |
664 |
} |
665 |
} |
666 |
|
667 |
// Some CUPS PPDs on Mac OS X (Epson, HP) don't include the requisite |
668 |
// PageSize information for the value. We have to fudge it from the |
669 |
// margin information. Others (Canon BJC 8200) have the coordinates |
670 |
// but not the "setpagedevice" stuff |
671 |
const PPDKey* pPSizeKey = aPrinter.m_aInfo.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("PageSize")) ); |
672 |
if ( pPSizeKey ) |
673 |
{ |
674 |
int psIndex = 0; |
675 |
int nNumValues = pPSizeKey->countValues(); |
676 |
|
677 |
for ( psIndex = 0; psIndex < nNumValues; psIndex++ ) |
678 |
{ |
679 |
const PPDValue* pPSizeValue = pPSizeKey->getValue( psIndex ); |
680 |
|
681 |
// Only take care of PPD values that are not formatted correctly. |
682 |
if ( pPSizeValue && |
683 |
( !(pPSizeValue->m_aValue.Len()) || |
684 |
(pPSizeValue->m_aValue.Len() && (pPSizeValue->m_aValue.SearchAscii("setpagedevice")==STRING_NOTFOUND)) ) |
685 |
) |
686 |
{ |
687 |
// Deal with the two cases: 1) where there is a blank PageSize value and |
688 |
// 2) where there are simply the dimensions as the PageSize value |
689 |
if ( !pPSizeValue->m_aValue.Len() ) |
690 |
{ |
691 |
int paperWidth; |
692 |
int paperHeight; |
693 |
char aWidth[ 32 ]; |
694 |
char aHeight[ 32 ]; |
695 |
|
696 |
// Grab dimensions for this paper size from the "PaperDimension" key of the PPD |
697 |
aPrinter.m_aInfo.m_pParser->getPaperDimension( pPSizeValue->m_aOption, paperWidth, paperHeight ); |
698 |
snprintf( aWidth, 32, "%d", paperWidth ); |
699 |
snprintf( aHeight, 32, "%d", paperHeight ); |
700 |
|
701 |
// Construct a suitable PageSize key value from the PaperDimension values for this paper size |
702 |
pPSizeValue->m_aValue.AppendAscii( "<</PageSize [" ); |
703 |
pPSizeValue->m_aValue.AppendAscii( aWidth ); |
704 |
pPSizeValue->m_aValue.AppendAscii( " " ); |
705 |
pPSizeValue->m_aValue.AppendAscii( aHeight ); |
706 |
pPSizeValue->m_aValue.AppendAscii( "] /ImagingBBox null>> setpagedevice" ); |
707 |
} |
708 |
else |
709 |
{ |
710 |
String aBox( pPSizeValue->m_aValue ); |
711 |
|
712 |
// The PageSize value was just the bounding box, add in the correct postscript |
713 |
pPSizeValue->m_aValue.AssignAscii( "" ); |
714 |
pPSizeValue->m_aValue.AppendAscii( "<</PageSize [" ); |
715 |
pPSizeValue->m_aValue.Append( aBox ); |
716 |
pPSizeValue->m_aValue.AppendAscii( "] /ImagingBBox null>> setpagedevice" ); |
717 |
} |
718 |
} |
719 |
} |
720 |
} |
721 |
} |
722 |
else |
723 |
{ |
724 |
ByteString aBytePrinterName = ByteString( UniString(aPrinter.m_aInfo.m_aDriverName), RTL_TEXTENCODING_UTF8 ); |
725 |
fprintf( stderr, "Could not get Printer PPD from /etc/cups/ppd for printer '%s'! Using simple shared printer PPD...\n", aBytePrinterName.GetBuffer() ); |
726 |
|
727 |
// Some printers don't have the PPDs in /etc/cups/ppd (like Rendezvous-shared ones) |
728 |
// so we have to simply use a stripped down shared printer PPD for them |
729 |
aPrinter.m_aInfo.m_aDriverName = String( RTL_CONSTASCII_USTRINGPARAM("MacShared") ); |
730 |
aPrinter.m_aInfo.m_pParser = PPDParser::getParser( aPrinter.m_aInfo.m_aDriverName ); |
731 |
aPrinter.m_aInfo.m_aContext.setParser( aPrinter.m_aInfo.m_pParser ); |
732 |
if( !(aPrinter.m_aInfo.m_pParser) ) |
733 |
{ |
734 |
fprintf( stderr, "Warning: still couldn't load the PPD, MacShared.ppd may be missing. Will use generic printer PPD.\n" ); |
735 |
aPrinter.m_aInfo.m_aDriverName = String( RTL_CONSTASCII_USTRINGPARAM("SGENPRT") ); |
736 |
aPrinter.m_aInfo.m_pParser = PPDParser::getParser( aPrinter.m_aInfo.m_aDriverName ); |
737 |
aPrinter.m_aInfo.m_aContext.setParser( aPrinter.m_aInfo.m_pParser ); |
738 |
} |
739 |
} |
740 |
} |
741 |
#endif |
742 |
|
539 |
m_aPrinters[ aPrinterName ] = aPrinter; |
743 |
m_aPrinters[ aPrinterName ] = aPrinter; |
540 |
} |
744 |
} |
541 |
} |
745 |
} |
Lines 1017-1022
Link Here
|
1017 |
{ "/usr/sbin/lpc status", "lpr -P \"(PRINTER)\"", "", ":", 0 }, |
1221 |
{ "/usr/sbin/lpc status", "lpr -P \"(PRINTER)\"", "", ":", 0 }, |
1018 |
{ "lpc status", "lpr -P \"(PRINTER)\"", "", ":", 0 }, |
1222 |
{ "lpc status", "lpr -P \"(PRINTER)\"", "", ":", 0 }, |
1019 |
{ "LANG=C;LC_ALL=C;export LANG LC_ALL;lpstat -s", "lp -d \"(PRINTER)\"", "system for ", ": ", 1 } |
1223 |
{ "LANG=C;LC_ALL=C;export LANG LC_ALL;lpstat -s", "lp -d \"(PRINTER)\"", "system for ", ": ", 1 } |
|
|
1224 |
#elif defined(MACOSX) |
1225 |
/* These elements correspond to the constants defined for Apple printing in |
1226 |
* printerinfomanager.hxx and are indexed by those constants. ORDER IS IMPORTANT!!! |
1227 |
*/ |
1228 |
/* Apple LPR printing (kApplePrintingLPR) */ |
1229 |
{ "/usr/bin/lpc status", "lpr -P (PRINTER)", "", ":", 0 }, |
1230 |
/* Apple CUPS printing (kApplePrintingCUPS) */ |
1231 |
{ "LANG=C;LC_ALL=C;export LANG LC_ALL;/usr/bin/lpstat -s", "lp -d (PRINTER)", "device for ", ": ", 1 }, |
1232 |
/* Apple Print Center printing (kApplePrintingPrintCenter) */ |
1233 |
{ kApplePCQueueName, kApplePCPrintCommand, "", ":", 0 } |
1020 |
#else |
1234 |
#else |
1021 |
{ "LANG=C;LC_ALL=C;export LANG LC_ALL;lpstat -s", "lp -d \"(PRINTER)\"", "system for ", ": ", 1 }, |
1235 |
{ "LANG=C;LC_ALL=C;export LANG LC_ALL;lpstat -s", "lp -d \"(PRINTER)\"", "system for ", ": ", 1 }, |
1022 |
{ "/usr/sbin/lpc status", "lpr -P \"(PRINTER)\"", "", ":", 0 }, |
1236 |
{ "/usr/sbin/lpc status", "lpr -P \"(PRINTER)\"", "", ":", 0 }, |
Lines 1033-1041
Link Here
|
1033 |
bool bSuccess = false; |
1247 |
bool bSuccess = false; |
1034 |
std::list< ByteString > aLines; |
1248 |
std::list< ByteString > aLines; |
1035 |
rtl_TextEncoding aEncoding = gsl_getSystemTextEncoding(); |
1249 |
rtl_TextEncoding aEncoding = gsl_getSystemTextEncoding(); |
1036 |
|
|
|
1037 |
OUString aPrintCommand; |
1250 |
OUString aPrintCommand; |
1038 |
|
1251 |
|
|
|
1252 |
#ifdef MACOSX |
1253 |
sal_Int32 applePrintSysType; |
1254 |
|
1255 |
/* Get our OS specific printing scheme for MacOS X */ |
1256 |
applePrintSysType = macxp_GetSystemPrintMethod(); |
1257 |
#endif |
1258 |
|
1259 |
/* Discover which command we can use to get a list of all printer queues */ |
1039 |
for( i = 0; i < sizeof(aParms)/sizeof(aParms[0]) && ! bSuccess; i++ ) |
1260 |
for( i = 0; i < sizeof(aParms)/sizeof(aParms[0]) && ! bSuccess; i++ ) |
1040 |
{ |
1261 |
{ |
1041 |
aLines.clear(); |
1262 |
aLines.clear(); |
Lines 1047-1100
Link Here
|
1047 |
#if OSL_DEBUG_LEVEL > 1 |
1268 |
#if OSL_DEBUG_LEVEL > 1 |
1048 |
fprintf( stderr, "trying print queue command \"%s\" ... ", aParms[i].pQueueCommand ); |
1269 |
fprintf( stderr, "trying print queue command \"%s\" ... ", aParms[i].pQueueCommand ); |
1049 |
#endif |
1270 |
#endif |
1050 |
if( pPipe = popen( aPrtQueueCmd.GetBuffer(), "r" ) ) |
1271 |
#ifdef MACOSX |
|
|
1272 |
/* For Mac OS X 10.1 Print Center printing, we only use the default queue. We do not |
1273 |
* need to discover it. So when it comes up in the list of possible queues, |
1274 |
* recognize it and declare success. |
1275 |
*/ |
1276 |
if ( applePrintSysType == kApplePrintingPrintCenter ) |
1051 |
{ |
1277 |
{ |
1052 |
while( fgets( pBuffer, 1024, pPipe ) ) |
1278 |
if ( strstr(aPrtQueueCmd.GetBuffer(), kApplePCQueueName) != NULL ) |
1053 |
aLines.push_back( ByteString( pBuffer ) ); |
1279 |
bSuccess = TRUE; |
1054 |
if( ! pclose( pPipe ) ) |
1280 |
#ifdef DEBUG |
1055 |
bSuccess = true; |
1281 |
else |
|
|
1282 |
fprintf( stderr, "Ignoring print queue command \"%s\" because using 10.1 Print Center printing.\n", aParms[i].pQueueCommand ); |
1283 |
#endif |
1284 |
} |
1285 |
else |
1286 |
#endif |
1287 |
{ |
1288 |
if( pPipe = popen( aPrtQueueCmd.GetBuffer(), "r" ) ) |
1289 |
{ |
1290 |
while( fgets( pBuffer, 1024, pPipe ) ) |
1291 |
aLines.push_back( ByteString( pBuffer ) ); |
1292 |
if( ! pclose( pPipe ) ) |
1293 |
bSuccess = true; |
1294 |
} |
1056 |
} |
1295 |
} |
1057 |
#if OSL_DEBUG_LEVEL > 1 |
1296 |
#if OSL_DEBUG_LEVEL > 1 |
1058 |
fprintf( stderr, "%s\n", bSuccess ? "success" : "failed" ); |
1297 |
fprintf( stderr, "%s\n", bSuccess ? "success" : "failed" ); |
1059 |
#endif |
1298 |
#endif |
1060 |
} |
1299 |
} |
1061 |
|
1300 |
|
1062 |
if( bSuccess ) |
1301 |
#ifdef MACOSX |
|
|
1302 |
/* Since we only print to the default printer for MacOS X 10.1, |
1303 |
* queue discovery serves no purpose. |
1304 |
*/ |
1305 |
if ( applePrintSysType == kApplePrintingPrintCenter ) |
1063 |
{ |
1306 |
{ |
1064 |
std::list< OUString > aSysPrintQueues; |
1307 |
std::list< OUString > aSysPrintQueues; |
1065 |
|
1308 |
|
1066 |
while( aLines.begin() != aLines.end() ) |
1309 |
aSysPrintQueues.push_back( OUString::createFromAscii(kApplePCQueueName) ); |
|
|
1310 |
#ifdef DEBUG |
1311 |
fprintf( stderr, "printerinfomanager.cxx: using Print Center default print queue.\n" ); |
1312 |
#endif |
1313 |
|
1314 |
MutexGuard aGuard( m_aMutex ); |
1315 |
m_bChanged = true; |
1316 |
m_aQueues = aSysPrintQueues; |
1317 |
m_aCommand = aPrintCommand; |
1318 |
} |
1319 |
else |
1320 |
#endif /* MACOSX */ |
1321 |
{ |
1322 |
/* Normal Unix print queue discovery, also used for Darwin 5 LPR printing |
1323 |
* and MacOS X 10.2/Darwin 6 CUPS printing. |
1324 |
*/ |
1325 |
if( bSuccess ) |
1067 |
{ |
1326 |
{ |
1068 |
int nPos = 0, nAftPos; |
1327 |
std::list< OUString > aSysPrintQueues; |
|
|
1328 |
|
1329 |
while( aLines.begin() != aLines.end() ) |
1330 |
{ |
1331 |
int nPos = 0, nAftPos; |
1069 |
|
1332 |
|
1070 |
ByteString aOutLine( aLines.front() ); |
1333 |
ByteString aOutLine( aLines.front() ); |
1071 |
aLines.pop_front(); |
1334 |
aLines.pop_front(); |
1072 |
|
1335 |
|
1073 |
for( int i = 0; i < nForeTokenCount && nPos != STRING_NOTFOUND; i++ ) |
1336 |
for( int i = 0; i < nForeTokenCount && nPos != STRING_NOTFOUND; i++ ) |
1074 |
{ |
|
|
1075 |
nPos = aOutLine.Search( aForeToken, nPos ); |
1076 |
if( nPos != STRING_NOTFOUND && aOutLine.Len() >= nPos+aForeToken.Len() ) |
1077 |
nPos += aForeToken.Len(); |
1078 |
} |
1079 |
if( nPos != STRING_NOTFOUND ) |
1080 |
{ |
1081 |
nAftPos = aOutLine.Search( aAftToken, nPos ); |
1082 |
if( nAftPos != STRING_NOTFOUND ) |
1083 |
{ |
1337 |
{ |
1084 |
OUString aSysQueue( String( aOutLine.Copy( nPos, nAftPos - nPos ), aEncoding ) ); |
1338 |
nPos = aOutLine.Search( aForeToken, nPos ); |
1085 |
// do not insert duplicates (e.g. lpstat tends to produce such lines) |
1339 |
if( nPos != STRING_NOTFOUND && aOutLine.Len() >= nPos+aForeToken.Len() ) |
1086 |
std::list< OUString >::const_iterator it; |
1340 |
nPos += aForeToken.Len(); |
1087 |
for( it = aSysPrintQueues.begin(); it != aSysPrintQueues.end() && *it != aSysQueue; ++it ) |
1341 |
} |
1088 |
; |
1342 |
if( nPos != STRING_NOTFOUND ) |
1089 |
if( it == aSysPrintQueues.end() ) |
1343 |
{ |
1090 |
aSysPrintQueues.push_back( aSysQueue ); |
1344 |
nAftPos = aOutLine.Search( aAftToken, nPos ); |
|
|
1345 |
if( nAftPos != STRING_NOTFOUND ) |
1346 |
{ |
1347 |
OUString aSysQueue( String( aOutLine.Copy( nPos, nAftPos - nPos ), aEncoding ) ); |
1348 |
// do not insert duplicates (e.g. lpstat tends to produce such lines) |
1349 |
std::list< OUString >::const_iterator it; |
1350 |
for( it = aSysPrintQueues.begin(); it != aSysPrintQueues.end() && *it != aSysQueue; ++it ) |
1351 |
; |
1352 |
if( it == aSysPrintQueues.end() ) |
1353 |
aSysPrintQueues.push_back( aSysQueue ); |
1354 |
} |
1091 |
} |
1355 |
} |
1092 |
} |
1356 |
} |
1093 |
} |
|
|
1094 |
|
1357 |
|
1095 |
MutexGuard aGuard( m_aMutex ); |
1358 |
MutexGuard aGuard( m_aMutex ); |
1096 |
m_bChanged = true; |
1359 |
m_bChanged = true; |
1097 |
m_aQueues = aSysPrintQueues; |
1360 |
m_aQueues = aSysPrintQueues; |
1098 |
m_aCommand = aPrintCommand; |
1361 |
m_aCommand = aPrintCommand; |
|
|
1362 |
} |
1099 |
} |
1363 |
} |
1100 |
} |
1364 |
} |
|
|
1365 |
|
1366 |
#ifdef MACOSX |
1367 |
|
1368 |
/* On Apple systems printing gets more complicated... |
1369 |
* 1) Darwin 5: use straight lpr system, user has to configure lpr correctly |
1370 |
* 2) MacOS X 10.1: use /usr/sbin/Print which prints to default Print Center printer |
1371 |
* 3) MacOS X 10.2: use CUPS duo of lpstat/lp |
1372 |
* 4) Darwin 6: Like MacOS X 10.2, use CUPS |
1373 |
* |
1374 |
* --- FIXME --- We don't support printer choosing on MacOS X 10.1 at this time, |
1375 |
* only printing to default Print Center printer. The user can |
1376 |
* change the default Print Center printer at any point however. |
1377 |
*/ |
1378 |
|
1379 |
/* |
1380 |
* macxp_GetSystemPrintMethod() |
1381 |
* |
1382 |
* Find out which printing system/OS we are using. |
1383 |
* |
1384 |
* Darwin 5 is the fallback case. To check for 10.1 printing we try to see if |
1385 |
* /usr/sbin/Print exists. For 10.2/Darwin 6, we attempt to find lpstat. Users |
1386 |
* might also have installed CUPS on Darwin 5 or MacOS X 10.1, but we default to |
1387 |
* Print Center (/usr/sbin/Print) printing on 10.1. |
1388 |
* |
1389 |
*/ |
1390 |
sal_Int32 macxp_GetSystemPrintMethod( void ) |
1391 |
{ |
1392 |
int applePrintSysType; |
1393 |
int err; |
1394 |
struct stat status; |
1395 |
|
1396 |
/* Attempt to find out which OS we are on... */ |
1397 |
applePrintSysType = kApplePrintingLPR; |
1398 |
|
1399 |
/* Check for MacOS X 10.1 first. */ |
1400 |
err = stat( "/usr/sbin/Print", &status ); |
1401 |
if ( err == 0 ) |
1402 |
{ |
1403 |
applePrintSysType = kApplePrintingPrintCenter; |
1404 |
#ifdef DEBUG |
1405 |
fprintf( stderr, "printerinfomanager.cxx: found MacOS X 10.1-type printing system.\n" ); |
1406 |
#endif |
1407 |
} |
1408 |
else |
1409 |
{ |
1410 |
/* Test for MacOS X 10.2/Darwin6 CUPS printing */ |
1411 |
err = stat( "/usr/bin/lpstat", &status ); |
1412 |
if ( err == 0 ) |
1413 |
{ |
1414 |
applePrintSysType = kApplePrintingCUPS; |
1415 |
#ifdef DEBUG |
1416 |
fprintf( stderr, "printerinfomanager.cxx: found MacOS X 10.2-type CUPS-based printing system.\n" ); |
1417 |
#endif |
1418 |
} |
1419 |
} |
1420 |
|
1421 |
#ifdef DEBUG |
1422 |
if ( applePrintSysType == kApplePrintingLPR ) |
1423 |
fprintf( stderr, "printerinfomanager.cxx: falling back to Darwin5-type LPR printing system.\n" ); |
1424 |
#endif |
1425 |
|
1426 |
return( applePrintSysType ); |
1427 |
} |
1428 |
|
1429 |
/* |
1430 |
* macxp_GetSystemPrintFormat() |
1431 |
* |
1432 |
* There are two ways to print: using PostScript (PS) and using PDF. |
1433 |
* Because MacOS X 10.2 CUPS printing has PDF converts built in for |
1434 |
* almost every printer, it is very easy to print using PDF. For 10.1, |
1435 |
* extra steps must be taken to print with PDF, but it is still more |
1436 |
* compatible. For Darwin 5 and 6, we default to PS printing. |
1437 |
* |
1438 |
* The user may still wish to print PS to PS compatible printers and |
1439 |
* therefore the environment variable OOO_PRINT_PS_DIRECTLY, if set, |
1440 |
* forces OOo to NOT undergo the PS -> PDF translation by default. |
1441 |
*/ |
1442 |
/*sal_Int32 macxp_GetSystemPrintFormat( void ) |
1443 |
{ |
1444 |
int printFormat; |
1445 |
int err; |
1446 |
struct stat status; |
1447 |
sal_Char *pPDFOverride = NULL; |
1448 |
|
1449 |
printFormat = kApplePrintingUsePS; |
1450 |
|
1451 |
/* Check for presence of OSAScript executable, which is |
1452 |
* believed to be MacOS X only (ie not present on Darwin). |
1453 |
* |
1454 |
err = stat( "/usr/bin/osascript", &status ); |
1455 |
if ( err == 0 ) |
1456 |
{ |
1457 |
/* Check to see if the user wants to print PS anyway * |
1458 |
pPDFOverride = getenv( "OOO_PRINT_PS_DIRECTLY" ); |
1459 |
if ( pPDFOverride == NULL ) |
1460 |
{ |
1461 |
/* Now we have to check for ps2pdf to make sure we can do the conversion * |
1462 |
err = stat( kApplePS2PDFLocation, &status ); |
1463 |
if ( err == 0 ) |
1464 |
{ |
1465 |
printFormat = kApplePrintingUsePDF; |
1466 |
#ifdef DEBUG |
1467 |
fprintf( stderr, "printerinfomanager.cxx: Will print in PDF format using PS->PDF coversion filters.\n" ); |
1468 |
#endif |
1469 |
} |
1470 |
} |
1471 |
} |
1472 |
|
1473 |
return( printFormat ); |
1474 |
}*/ |
1475 |
#endif |
1476 |
|