Lines 740-746
Link Here
|
740 |
const PPDValue *pCupsFilterValue; |
740 |
const PPDValue *pCupsFilterValue; |
741 |
|
741 |
|
742 |
pCupsFilterKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("cupsFilter")) ); |
742 |
pCupsFilterKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("cupsFilter")) ); |
743 |
pCupsFilterValue = pJobData.m_aContext.getValue( pCupsFilterKey ); |
743 |
pCupsFilterValue = pCupsFilterKey != NULL ? pJobData.m_aContext.getValue( pCupsFilterKey ) : NULL; |
744 |
if ( pCupsFilterValue ) |
744 |
if ( pCupsFilterValue ) |
745 |
{ |
745 |
{ |
746 |
ByteString aCupsFilterString( pCupsFilterValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 ); |
746 |
ByteString aCupsFilterString( pCupsFilterValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 ); |
Lines 815-830
Link Here
|
815 |
{ |
815 |
{ |
816 |
#define kJobOptionsStringSize 500 |
816 |
#define kJobOptionsStringSize 500 |
817 |
char jobOptions[ kJobOptionsStringSize ]; |
817 |
char jobOptions[ kJobOptionsStringSize ]; |
818 |
/* Determine which printing system we are using, either 'lp' or 'lpr'. They |
|
|
819 |
* each have a different switch for number of copies. |
820 |
* Note that neither of these two actually honors these arguments on 10.2 right now. |
821 |
*/ |
822 |
/* |
823 |
if ( (strstr(psprintPrintCmd.getStr(), "lp ") != NULL) || (psprintPrintCmd=="lp") ) |
824 |
strncpy( numCopiesSwitch, "-n", 4 ); |
825 |
else if ( (strstr(psprintPrintCmd.getStr(), "lpr ") != NULL) || (psprintPrintCmd=="lpr") ) |
826 |
strncpy( numCopiesSwitch, "-#", 4 ); |
827 |
*/ |
828 |
|
818 |
|
829 |
jobOptions[ 0 ] = NULL; |
819 |
jobOptions[ 0 ] = NULL; |
830 |
/* Based on job options, find out what parameters to pass to the printer. */ |
820 |
/* Based on job options, find out what parameters to pass to the printer. */ |
Lines 834-856
Link Here
|
834 |
const PPDValue *pSizeValue; |
824 |
const PPDValue *pSizeValue; |
835 |
const PPDKey *pSlotKey; |
825 |
const PPDKey *pSlotKey; |
836 |
const PPDValue *pSlotValue; |
826 |
const PPDValue *pSlotValue; |
|
|
827 |
BOOL needComma = FALSE; |
837 |
|
828 |
|
838 |
pSizeKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("PageSize")) ); |
829 |
// Only CUPS PS->PDF printers require the page size options |
839 |
pSizeValue = pJobData.m_aContext.getValue( pSizeKey ); |
830 |
if ( printFormat == kApplePrintingUsePDF ) |
840 |
if ( pSizeValue ) |
|
|
841 |
{ |
831 |
{ |
842 |
ByteString aSizeString( pSizeValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 ); |
832 |
// Add page size option if necessary |
843 |
snprintf( jobOptions, kJobOptionsStringSize, "-o media=%s", aSizeString.GetBuffer() ); |
833 |
pSizeKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("PageSize")) ); |
844 |
|
834 |
pSizeValue = pSizeKey != NULL ? pJobData.m_aContext.getValue( pSizeKey ) : NULL; |
845 |
pSlotKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("InputSlot")) ); |
835 |
if ( pSizeValue ) |
846 |
pSlotValue = pJobData.m_aContext.getValue( pSlotKey ); |
|
|
847 |
if ( pSlotValue ) |
848 |
{ |
836 |
{ |
849 |
ByteString aSlotString( pSlotValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 ); |
837 |
ByteString aSizeString( pSizeValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 ); |
850 |
strncat( jobOptions, ",", kJobOptionsStringSize - strlen(jobOptions) ); |
838 |
snprintf( jobOptions, kJobOptionsStringSize, "-o \"media=" ); |
851 |
strncat( jobOptions, aSlotString.GetBuffer(), kJobOptionsStringSize - strlen(jobOptions) ); |
839 |
strncat( jobOptions, aSizeString.GetBuffer(), kJobOptionsStringSize-strlen(jobOptions) ); |
|
|
840 |
needComma = TRUE; |
852 |
} |
841 |
} |
853 |
} |
842 |
} |
|
|
843 |
|
844 |
// Add paper tray option if necessary |
845 |
pSlotKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("InputSlot")) ); |
846 |
pSlotValue = pSlotKey != NULL ? pJobData.m_aContext.getValue( pSlotKey ) : NULL; |
847 |
if ( pSlotValue ) |
848 |
{ |
849 |
ByteString aSlotString( pSlotValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 ); |
850 |
// If the string wasn't created from PageSize, create it now |
851 |
if ( strlen(jobOptions) == 0 ) |
852 |
snprintf( jobOptions, kJobOptionsStringSize, "-o \"media=" ); |
853 |
if ( TRUE == needComma ) |
854 |
strncat( jobOptions, ",", kJobOptionsStringSize - strlen(jobOptions) ); |
855 |
|
856 |
strncat( jobOptions, aSlotString.GetBuffer(), kJobOptionsStringSize - strlen(jobOptions) ); |
857 |
} |
858 |
|
859 |
// Add on the ending " to the media= part |
860 |
if ( strlen(jobOptions) > 0 ) |
861 |
strncat( jobOptions, "\"", kJobOptionsStringSize - strlen(jobOptions) ); |
854 |
|
862 |
|
855 |
/* Deal with landscape orientation */ |
863 |
/* Deal with landscape orientation */ |
856 |
// Disable for the moment since testers say it has undesired effects |
864 |
// Disable for the moment since testers say it has undesired effects |
Lines 869-877
Link Here
|
869 |
#endif |
877 |
#endif |
870 |
|
878 |
|
871 |
/* Stupid lp and lpr on 10.2 don't actually honor their respective # copies arguments. |
879 |
/* Stupid lp and lpr on 10.2 don't actually honor their respective # copies arguments. |
872 |
* So we have to just keep printing the job over and over for multiple copies. |
880 |
* So we have to just keep printing the job over and over for multiple copies for PS->PDF |
|
|
881 |
* printers. Direct-to-PostScript printers can handle the # copies _inside_ the PostScript |
882 |
* document we are sending to them. |
873 |
*/ |
883 |
*/ |
874 |
for( index = 1; index <= pJobData.m_nCopies; index++ ) |
884 |
int numCopies = (printFormat == kApplePrintingUsePDF ) ? pJobData.m_nCopies : 1; |
|
|
885 |
for( index = 1; index <= numCopies; index++ ) |
875 |
printCmdErr = system( sysCommandBuffer ); |
886 |
printCmdErr = system( sysCommandBuffer ); |
876 |
} |
887 |
} |
877 |
unlink( pdfFileName ); |
888 |
unlink( pdfFileName ); |
Lines 1252-1259
Link Here
|
1252 |
aKeys[i] = rJob.m_aContext.getModifiedKey( i ); |
1263 |
aKeys[i] = rJob.m_aContext.getModifiedKey( i ); |
1253 |
::std::sort( aKeys.begin(), aKeys.end(), less_ppd_key() ); |
1264 |
::std::sort( aKeys.begin(), aKeys.end(), less_ppd_key() ); |
1254 |
|
1265 |
|
1255 |
fprintf( stderr, "----- FEATURE: %d keys in feature section\n", nKeys ); |
|
|
1256 |
|
1257 |
for( i = 0; i < nKeys && bSuccess; i++ ) |
1266 |
for( i = 0; i < nKeys && bSuccess; i++ ) |
1258 |
{ |
1267 |
{ |
1259 |
const PPDKey* pKey = aKeys[i]; |
1268 |
const PPDKey* pKey = aKeys[i]; |
Lines 1262-1283
Link Here
|
1262 |
pKey->getSetupType() == PPDKey::AnySetup ) |
1271 |
pKey->getSetupType() == PPDKey::AnySetup ) |
1263 |
{ |
1272 |
{ |
1264 |
const PPDValue* pValue = rJob.m_aContext.getValue( pKey ); |
1273 |
const PPDValue* pValue = rJob.m_aContext.getValue( pKey ); |
1265 |
{ |
|
|
1266 |
ByteString bsOption( pValue->m_aOption, RTL_TEXTENCODING_UTF8 ); |
1267 |
ByteString bsValue( pValue->m_aValue, RTL_TEXTENCODING_UTF8 ); |
1268 |
fprintf( stderr," Trying Key, Option: %s, Value: %s\n", bsOption.GetBuffer(), bsValue.GetBuffer() ); |
1269 |
fflush(stderr); |
1270 |
} |
1271 |
if(pValue |
1274 |
if(pValue |
1272 |
&& pValue->m_eType == eInvocation |
1275 |
&& pValue->m_eType == eInvocation |
1273 |
#ifdef MACOSX |
|
|
1274 |
// Some CUPS PPDs on OS X do not have values for PageSize. So we have |
1275 |
// to let the key through anyway and fudge the values. |
1276 |
&& (pValue->m_aValue.Len() |
1277 |
|| (pKey->getKey().EqualsIgnoreCaseAscii("PageSize"))) |
1278 |
#else |
1279 |
&& pValue->m_aValue.Len() |
1276 |
&& pValue->m_aValue.Len() |
1280 |
#endif |
|
|
1281 |
&& ( m_aLastJobData.m_pParser == NULL |
1277 |
&& ( m_aLastJobData.m_pParser == NULL |
1282 |
|| m_aLastJobData.m_aContext.getValue( pKey ) != pValue ) |
1278 |
|| m_aLastJobData.m_aContext.getValue( pKey ) != pValue ) |
1283 |
) |
1279 |
) |
Lines 1291-1333
Link Here
|
1291 |
if( bHavePS2 ) |
1287 |
if( bHavePS2 ) |
1292 |
continue; |
1288 |
continue; |
1293 |
} |
1289 |
} |
1294 |
#ifdef MACOSX |
|
|
1295 |
// Some CUPS PPDs on Mac OS X (Epson, HP) don't include the requisite |
1296 |
// PageSize information for the value. We have to fudge it from the |
1297 |
// margin information. Others (Canon BJC 8200) have the coordinates |
1298 |
// but not the "setpagedevice" stuff |
1299 |
if ( !(pValue->m_aValue.Len()) && pKey->getKey().EqualsIgnoreCaseAscii("PageSize") ) |
1300 |
{ |
1301 |
char aWidth[ 32 ]; |
1302 |
char aHeight[ 32 ]; |
1303 |
|
1304 |
snprintf( aWidth, 32, "%d", mnWidthPt ); |
1305 |
snprintf( aHeight, 32, "%d", mnHeightPt ); |
1306 |
|
1307 |
// bounding box was blank, construct from margin info |
1308 |
pValue->m_aValue.AppendAscii( "<</PageSize [" ); |
1309 |
pValue->m_aValue.AppendAscii( aWidth ); |
1310 |
pValue->m_aValue.AppendAscii( " " ); |
1311 |
pValue->m_aValue.AppendAscii( aHeight ); |
1312 |
pValue->m_aValue.AppendAscii( "] /ImagingBBox null>> setpagedevice" ); |
1313 |
} |
1314 |
else if ( pValue->m_aValue.Len() && (pValue->m_aValue.SearchAscii("setpagedevice")==STRING_NOTFOUND) ) |
1315 |
{ |
1316 |
String aBox( pValue->m_aValue ); |
1317 |
|
1318 |
// The value was just the bounding box, add in the correct postscript |
1319 |
pValue->m_aValue.AssignAscii( "" ); |
1320 |
pValue->m_aValue.AppendAscii( "<</PageSize [" ); |
1321 |
pValue->m_aValue.Append( aBox ); |
1322 |
pValue->m_aValue.AppendAscii( "] /ImagingBBox null>> setpagedevice" ); |
1323 |
} |
1324 |
#endif |
1325 |
bSuccess = writeFeature( pFile, pKey, pValue ); |
1290 |
bSuccess = writeFeature( pFile, pKey, pValue ); |
1326 |
fprintf( stderr," Attempted to write key, success = %s\n", bSuccess ? "good" : "bad" ); |
|
|
1327 |
} |
1291 |
} |
1328 |
} |
1292 |
} |
1329 |
} |
1293 |
} |
1330 |
fprintf( stderr, "----- END FEATURE\n" ); |
|
|
1331 |
} |
1294 |
} |
1332 |
else |
1295 |
else |
1333 |
bSuccess = false; |
1296 |
bSuccess = false; |