Index: source/gdi/jobset.cxx =================================================================== RCS file: /cvs/gsl/vcl/source/gdi/jobset.cxx,v retrieving revision 1.5.6.1 diff -u -r1.5.6.1 jobset.cxx --- source/gdi/jobset.cxx 4 Jun 2002 12:48:53 -0000 1.5.6.1 +++ source/gdi/jobset.cxx 11 Jun 2003 18:54:42 -0000 @@ -67,6 +67,9 @@ #ifndef _STREAM_HXX #include #endif +#ifndef _RTL_ALLOC_H +#include +#endif #ifndef _SV_JOBSET_HXX #include @@ -134,7 +137,7 @@ mnDriverDataLen = rJobSetup.mnDriverDataLen; if ( rJobSetup.mpDriverData ) { - mpDriverData = new BYTE[mnDriverDataLen]; + mpDriverData = (BYTE*)rtl_allocateMemory( mnDriverDataLen ); memcpy( mpDriverData, rJobSetup.mpDriverData, mnDriverDataLen ); } else @@ -146,7 +149,7 @@ ImplJobSetup::~ImplJobSetup() { - delete[] mpDriverData; + rtl_freeMemory( mpDriverData ); } // ======================================================================= @@ -381,7 +384,7 @@ if ( pJobData->mnDriverDataLen ) { BYTE* pDriverData = ((BYTE*)pOldJobData) + nOldJobDataSize; - pJobData->mpDriverData = new BYTE[pJobData->mnDriverDataLen]; + pJobData->mpDriverData = (BYTE*)rtl_allocateMemory( pJobData->mnDriverDataLen ); memcpy( pJobData->mpDriverData, pDriverData, pJobData->mnDriverDataLen ); } if( nSystem == JOBSET_FILE605_SYSTEM ) Index: unx/source/gdi/salprnpsp.cxx =================================================================== RCS file: /cvs/gsl/vcl/unx/source/gdi/salprnpsp.cxx,v retrieving revision 1.15.2.1.2.4 diff -u -r1.15.2.1.2.4 salprnpsp.cxx --- unx/source/gdi/salprnpsp.cxx 22 Jan 2003 07:20:41 -0000 1.15.2.1.2.4 +++ unx/source/gdi/salprnpsp.cxx 11 Jun 2003 18:55:07 -0000 @@ -296,7 +296,7 @@ // copy the whole context if( pJobSetup->mpDriverData ) - delete pJobSetup->mpDriverData; + rtl_freeMemory( pJobSetup->mpDriverData ); int nBytes; void* pBuffer = NULL; @@ -613,7 +613,7 @@ if( pSetupFunction( aInfo ) ) { - delete pJobSetup->mpDriverData; + rtl_freeMemory( pJobSetup->mpDriverData ); pJobSetup->mpDriverData = NULL; int nBytes; @@ -678,12 +678,59 @@ nHeight = pJobSetup->mnPaperWidth; } String aPaper; - if( pJobSetup->mePaperFormat == PAPER_USER ) + +#ifdef MACOSX + // For Mac OS X, many printers are directly attached + // USB/Serial printers with a stripped-down PPD that gives us + // problems. We need to do PS->PDF conversion for these printers + // but they are not able to handle multiple page sizes in the same + // document at all, since we must pass -o media=... to them to get + // a good printout. + // So, we must find a match between the paper size from OOo and what + // the PPD of the printer has, and pass that paper size to -o media=... + // If a match cannot be found (ie the paper size from Format->Page is + // nowhere near anything in the PPD), we default to what has been + // chosen in File->Print->Properties. + // + // For printers capable of directly accepting PostScript data, none + // of this occurs and we default to the normal OOo behavior. + const PPDKey *pCupsFilterKey; + const PPDValue *pCupsFilterValue; + BOOL bIsCUPSPrinter = TRUE; + + // Printers that need PS->PDF conversion have a "cupsFilter" key and + // a value of "application/pdf" in that key + pCupsFilterKey = aData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("cupsFilter")) ); + pCupsFilterValue = pCupsFilterKey != NULL ? aData.m_aContext.getValue( pCupsFilterKey ) : NULL; + if ( pCupsFilterValue ) + { + // PPD had a cupsFilter key, check for PS->PDF conversion requirement + ByteString aCupsFilterString( pCupsFilterValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 ); + if ( aCupsFilterString.Search("application/pdf") == 0 ) + bIsCUPSPrinter = FALSE; + } + else + bIsCUPSPrinter = FALSE; + + if ( TRUE == bIsCUPSPrinter ) + { + // If its a directly attached printer, with a + // stripped down PPD (most OS X printers are) always + // match the paper size. aPaper = aData.m_pParser->matchPaper( TenMuToPt( pJobSetup->mnPaperWidth ), TenMuToPt( pJobSetup->mnPaperHeight ) ); + } else - aPaper = String( ByteString( aPaperTab[ pJobSetup->mePaperFormat ].name ), RTL_TEXTENCODING_ISO_8859_1 ); +#endif + { + if( pJobSetup->mePaperFormat == PAPER_USER ) + aPaper = aData.m_pParser->matchPaper( + TenMuToPt( pJobSetup->mnPaperWidth ), + TenMuToPt( pJobSetup->mnPaperHeight ) ); + else + aPaper = String( ByteString( aPaperTab[ pJobSetup->mePaperFormat ].name ), RTL_TEXTENCODING_ISO_8859_1 ); + } pKey = aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) ); pValue = pKey ? pKey->getValue( aPaper ) : NULL; if( ! ( pKey && pValue && aData.m_aContext.setValue( pKey, pValue, false ) == pValue ) )