diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-03-20 12:38:03 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-03-20 14:40:32 +0000 |
commit | ed6171632005cdaa987214e84f0ad8fd0dbdd2da (patch) | |
tree | 4266a1c4de853724cc2377cc4d53c52b5b44316a | |
parent | 872de529584cd001431a2090eca0f52eb0b16539 (diff) |
Resolves: #i49980# Autosense fax4cups devices and configure automatically
If there is a "Dial" ppd key then it's a fax device. If the Dial is set to
"Manually" then ignore that it's a fax device and don't prompt for a fax
number.
If we have a fax number, then set the jobname to the number given that
"printing will result in sending the fax to the number contained in the job
name"
Remove the weird and wonderful non-macosx-unix-only, non-pdf-print-backend,
text "scraping" of phone numbers out of the print out in the @@#PHONE@@ format.
Allow the phone entry dialog to accept multiple fax numbers separated by ;
Change-Id: Ie1d84b68584e82df15ceda5f32c7c75086b035c8
Related: rhbz#159153, #i49981#, #i49920#
-rw-r--r-- | include/vcl/printerinfomanager.hxx | 2 | ||||
-rw-r--r-- | vcl/generic/print/genprnpsp.cxx | 214 | ||||
-rw-r--r-- | vcl/generic/print/genpspgraphics.cxx | 83 | ||||
-rw-r--r-- | vcl/generic/print/printerjob.cxx | 4 | ||||
-rw-r--r-- | vcl/inc/cupsmgr.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/generic/genprn.h | 3 | ||||
-rw-r--r-- | vcl/inc/generic/genpspgraphics.h | 5 | ||||
-rw-r--r-- | vcl/null/printerinfomanager.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/generic/printer/cupsmgr.cxx | 23 | ||||
-rw-r--r-- | vcl/unx/generic/printer/printerinfomanager.cxx | 2 |
10 files changed, 117 insertions, 223 deletions
diff --git a/include/vcl/printerinfomanager.hxx b/include/vcl/printerinfomanager.hxx index d35e1fb8e05d..6492f8cdaf23 100644 --- a/include/vcl/printerinfomanager.hxx +++ b/include/vcl/printerinfomanager.hxx @@ -193,7 +193,7 @@ public: // set bBanner to "false" will attempt to suppress banner printing // set bBanner to "true" will rely on the system default // returns true on success - virtual bool endSpool( const OUString& rPrinterName, const OUString& rJobTitle, FILE* pFile, const JobData& rDocumentJobData, bool bBanner ); + virtual bool endSpool( const OUString& rPrinterName, const OUString& rJobTitle, FILE* pFile, const JobData& rDocumentJobData, bool bBanner, const OUString &rFaxNumber ); // for spadmin: whether adding or removing a printer is possible virtual bool addOrRemovePossible() const; diff --git a/vcl/generic/print/genprnpsp.cxx b/vcl/generic/print/genprnpsp.cxx index 022e26c8a7eb..cc379e556607 100644 --- a/vcl/generic/print/genprnpsp.cxx +++ b/vcl/generic/print/genprnpsp.cxx @@ -304,69 +304,29 @@ static bool passFileToCommandLine( const OUString& rFilename, const OUString& rC } #endif -static bool sendAFax( const OUString& rFaxNumber, const OUString& rFileName, const OUString& rCommand ) +static std::vector<OUString> getFaxNumbers() { -#if defined( UNX ) - std::list< OUString > aFaxNumbers; + std::vector<OUString> aFaxNumbers; - if( rFaxNumber.isEmpty() ) - { - getPaLib(); - if( pFaxNrFunction ) - { - OUString aNewNr; - if( pFaxNrFunction( aNewNr ) ) - aFaxNumbers.push_back( aNewNr ); - } - } - else +#if defined( UNX ) + getPaLib(); + if (pFaxNrFunction) { - sal_Int32 nIndex = 0; - OUString aFaxes( rFaxNumber ); - OUString aBeginToken( "<Fax#>" ); - OUString aEndToken( "</Fax#>" ); - while( nIndex != -1 ) + OUString aNewNr; + if( pFaxNrFunction( aNewNr ) ) { - nIndex = aFaxes.indexOf( aBeginToken, nIndex ); - if( nIndex != -1 ) + sal_Int32 nIndex = 0; + do { - sal_Int32 nBegin = nIndex + aBeginToken.getLength(); - nIndex = aFaxes.indexOf( aEndToken, nIndex ); - if( nIndex != -1 ) - { - aFaxNumbers.push_back( aFaxes.copy( nBegin, nIndex-nBegin ) ); - nIndex += aEndToken.getLength(); - } + OUString sToken = aNewNr.getToken( 0, ';', nIndex ); + aFaxNumbers.push_back(sToken); } + while (nIndex >= 0); } } - - bool bSuccess = true; - if( aFaxNumbers.begin() != aFaxNumbers.end() ) - { - while( aFaxNumbers.begin() != aFaxNumbers.end() && bSuccess ) - { - OUString aFaxNumber( aFaxNumbers.front() ); - aFaxNumbers.pop_front(); - OUString aCmdLine( - rCommand.replaceAll("(PHONE)", aFaxNumber)); -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "sending fax to \"%s\"\n", OUStringToOString( aFaxNumber, osl_getThreadTextEncoding() ).getStr() ); #endif - bSuccess = passFileToCommandLine( rFileName, aCmdLine, false ); - } - } - else - bSuccess = false; - - // clean up temp file - unlink(OUStringToOString(rFileName, osl_getThreadTextEncoding()).getStr()); - return bSuccess; -#else - (void)rFaxNumber; (void)rFileName; (void)rCommand; - return false; -#endif + return aFaxNumbers; } static bool createPdf( const OUString& rToFile, const OUString& rFromFile, const OUString& rCommandLine ) @@ -544,7 +504,7 @@ SalGraphics* PspSalInfoPrinter::AcquireGraphics() if( ! m_pGraphics ) { m_pGraphics = GetGenericInstance()->CreatePrintGraphics(); - m_pGraphics->Init( &m_aJobData, &m_aPrinterGfx, NULL, false, this ); + m_pGraphics->Init(&m_aJobData, &m_aPrinterGfx, this); pRet = m_pGraphics; } return pRet; @@ -824,7 +784,19 @@ sal_uLong PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, sal case PRINTER_CAPABILITIES_SETPAPER: return 0; case PRINTER_CAPABILITIES_FAX: - return PrinterInfoManager::get().checkFeatureToken( pJobSetup->maPrinterName, "fax" ) ? 1 : 0; + { + // see if the PPD contains the fax4CUPS "Dial" option and that it's not set + // to "manually" + JobData aData = PrinterInfoManager::get().getPrinterInfo(pJobSetup->maPrinterName); + if( pJobSetup->mpDriverData ) + JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData ); + const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey(OUString("Dial")) : NULL; + const PPDValue* pValue = pKey ? aData.m_aContext.getValue(pKey) : NULL; + if (pValue && !pValue->m_aOption.equalsIgnoreAsciiCase("Manually")) + return 1; + return 0; + } + case PRINTER_CAPABILITIES_PDF: if( PrinterInfoManager::get().checkFeatureToken( pJobSetup->maPrinterName, "pdf" ) ) return 1; @@ -855,9 +827,7 @@ sal_uLong PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, sal * SalPrinter */ PspSalPrinter::PspSalPrinter( SalInfoPrinter* pInfoPrinter ) - : m_bFax( false ), - m_bPdf( false ), - m_bSwallowFaxNo( false ), + : m_bPdf( false ), m_bIsPDFWriterJob( false ), m_pGraphics( NULL ), m_nCopies( 1 ), @@ -890,8 +860,6 @@ bool PspSalPrinter::StartJob( { OSL_TRACE("PspSalPrinter::StartJob"); GetSalData()->m_pInstance->jobStartedPrinterUpdate(); - - m_bFax = false; m_bPdf = false; m_aFileName = pFileName ? *pFileName : OUString(); m_aTmpFile = OUString(); @@ -915,17 +883,6 @@ bool PspSalPrinter::StartJob( while( nIndex != -1 ) { OUString aToken( rInfo.m_aFeatures.getToken( 0, ',', nIndex ) ); - if( aToken.startsWith( "fax" ) ) - { - m_bFax = true; - m_aTmpFile = getTmpName(); - nMode = S_IRUSR | S_IWUSR; - - sal_Int32 nPos = 0; - m_bSwallowFaxNo = aToken.getToken( 1, '=', nPos ).startsWith( "swallow" ) ? true : false; - - break; - } if( aToken.startsWith( "pdf=" ) ) { m_bPdf = true; @@ -957,22 +914,12 @@ bool PspSalPrinter::EndJob() else { bSuccess = m_aPrintJob.EndJob(); - OSL_TRACE("PspSalPrinter::EndJob %d", bSuccess); + OSL_TRACE("PspSalPrinter::EndJob %d", bSuccess); - if( bSuccess ) + if( bSuccess && m_bPdf ) { - // check for fax - if( m_bFax ) - { - const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( m_aJobData.m_aPrinterName ) ); - // sendAFax removes the file after use - bSuccess = sendAFax( m_aFaxNr, m_aTmpFile, rInfo.m_aCommand ); - } - else if( m_bPdf ) - { - const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( m_aJobData.m_aPrinterName ) ); - bSuccess = createPdf( m_aFileName, m_aTmpFile, rInfo.m_aCommand ); - } + const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( m_aJobData.m_aPrinterName ) ); + bSuccess = createPdf( m_aFileName, m_aTmpFile, rInfo.m_aCommand ); } } GetSalData()->m_pInstance->jobEndedPrinterUpdate(); @@ -992,8 +939,8 @@ SalGraphics* PspSalPrinter::StartPage( ImplJobSetup* pJobSetup, bool ) JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, m_aJobData ); m_pGraphics = GetGenericInstance()->CreatePrintGraphics(); - m_pGraphics->Init( &m_aJobData, &m_aPrinterGfx, m_bFax ? &m_aFaxNr : NULL, - m_bSwallowFaxNo, m_pInfoPrinter ); + m_pGraphics->Init(&m_aJobData, &m_aPrinterGfx, m_pInfoPrinter); + if( m_nCopies > 1 ) { // in case user did not do anything (m_nCopies=1) @@ -1063,6 +1010,8 @@ bool PspSalPrinter::StartJob( const OUString* i_pFileName, const OUString& i_rJo m_bIsPDFWriterJob = true; // reset IsLastPage i_rController.setLastPage( false ); + // is this a fax device + bool bFax = m_pInfoPrinter->GetCapabilities(i_pSetupData, PRINTER_CAPABILITIES_FAX) == 1; // update job data if( i_pSetupData ) @@ -1214,58 +1163,77 @@ bool PspSalPrinter::StartJob( const OUString* i_pFileName, const OUString& i_rJo } } - bool bSuccess(true); + std::vector<OUString> aFaxNumbers; + + // check for fax numbers + if (!bAborted && bFax) + { + aFaxNumbers = getFaxNumbers(); + bAborted = aFaxNumbers.empty(); + } + bool bSuccess(true); // spool files if( ! i_pFileName && ! bAborted ) { - bool bFirstJob = true; - for( int nCurJob = 0; nCurJob < nOuterJobs; nCurJob++ ) + do { - for( size_t i = 0; i < aPDFFiles.size(); i++ ) + OUString sFaxNumber; + if (!aFaxNumbers.empty()) + { + sFaxNumber = aFaxNumbers.back(); + aFaxNumbers.pop_back(); + } + + bool bFirstJob = true; + for( int nCurJob = 0; nCurJob < nOuterJobs; nCurJob++ ) { - oslFileHandle pFile = NULL; - osl_openFile( aPDFFiles[i].maTmpURL.pData, &pFile, osl_File_OpenFlag_Read ); - if (pFile && (osl_setFilePos(pFile, osl_Pos_Absolut, 0) == osl_File_E_None)) + for( size_t i = 0; i < aPDFFiles.size(); i++ ) { - std::vector< char > buffer( 0x10000, 0 ); - // update job data with current page size - Size aPageSize( aPDFFiles[i].maParameters.maPageSize ); - m_aJobData.setPaper( TenMuToPt( aPageSize.Width() ), TenMuToPt( aPageSize.Height() ) ); - // update job data with current paperbin - m_aJobData.setPaperBin( aPDFFiles[i].maParameters.mnPaperBin ); - - // spool current file - FILE* fp = PrinterInfoManager::get().startSpool( pPrinter->GetName(), i_rController.isDirectPrint() ); - if( fp ) + oslFileHandle pFile = NULL; + osl_openFile( aPDFFiles[i].maTmpURL.pData, &pFile, osl_File_OpenFlag_Read ); + if (pFile && (osl_setFilePos(pFile, osl_Pos_Absolut, 0) == osl_File_E_None)) { - sal_uInt64 nBytesRead = 0; - do + std::vector< char > buffer( 0x10000, 0 ); + // update job data with current page size + Size aPageSize( aPDFFiles[i].maParameters.maPageSize ); + m_aJobData.setPaper( TenMuToPt( aPageSize.Width() ), TenMuToPt( aPageSize.Height() ) ); + // update job data with current paperbin + m_aJobData.setPaperBin( aPDFFiles[i].maParameters.mnPaperBin ); + + // spool current file + FILE* fp = PrinterInfoManager::get().startSpool( pPrinter->GetName(), i_rController.isDirectPrint() ); + if( fp ) { - osl_readFile( pFile, &buffer[0], buffer.size(), &nBytesRead ); - if( nBytesRead > 0 ) + sal_uInt64 nBytesRead = 0; + do + { + osl_readFile( pFile, &buffer[0], buffer.size(), &nBytesRead ); + if( nBytesRead > 0 ) + { + size_t nBytesWritten = fwrite(&buffer[0], 1, nBytesRead, fp); + OSL_ENSURE(nBytesRead == nBytesWritten, "short write"); + if (nBytesRead != nBytesWritten) + break; + } + } while( nBytesRead == buffer.size() ); + OUStringBuffer aBuf( i_rJobName.getLength() + 8 ); + aBuf.append( i_rJobName ); + if( i > 0 || nCurJob > 0 ) { - size_t nBytesWritten = fwrite(&buffer[0], 1, nBytesRead, fp); - OSL_ENSURE(nBytesRead == nBytesWritten, "short write"); - if (nBytesRead != nBytesWritten) - break; + aBuf.append( ' ' ); + aBuf.append( sal_Int32( i + nCurJob * aPDFFiles.size() ) ); } - } while( nBytesRead == buffer.size() ); - OUStringBuffer aBuf( i_rJobName.getLength() + 8 ); - aBuf.append( i_rJobName ); - if( i > 0 || nCurJob > 0 ) - { - aBuf.append( ' ' ); - aBuf.append( sal_Int32( i + nCurJob * aPDFFiles.size() ) ); + bSuccess &= + PrinterInfoManager::get().endSpool( pPrinter->GetName(), aBuf.makeStringAndClear(), fp, m_aJobData, bFirstJob, sFaxNumber ); + bFirstJob = false; } - bSuccess &= - PrinterInfoManager::get().endSpool( pPrinter->GetName(), aBuf.makeStringAndClear(), fp, m_aJobData, bFirstJob ); - bFirstJob = false; } + osl_closeFile( pFile ); } - osl_closeFile( pFile ); } } + while (!aFaxNumbers.empty()); } // job has been spooled diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx index 961d17f6e7b7..9e0221f499fc 100644 --- a/vcl/generic/print/genpspgraphics.cxx +++ b/vcl/generic/print/genpspgraphics.cxx @@ -266,9 +266,6 @@ SalPrinterBmp::GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const GenPspGraphics::GenPspGraphics() : m_pJobData( NULL ), m_pPrinterGfx( NULL ), - m_pPhoneNr( NULL ), - m_bSwallowFaxNo( false ), - m_bPhoneCollectionActive( false ), m_bFontVertical( false ), m_pInfoPrinter( NULL ) { @@ -276,14 +273,11 @@ GenPspGraphics::GenPspGraphics() m_pServerFont[i] = NULL; } -void GenPspGraphics::Init( psp::JobData* pJob, psp::PrinterGfx* pGfx, - OUString* pPhone, bool bSwallow, - SalInfoPrinter* pInfoPrinter ) +void GenPspGraphics::Init(psp::JobData* pJob, psp::PrinterGfx* pGfx, + SalInfoPrinter* pInfoPrinter) { m_pJobData = pJob; m_pPrinterGfx = pGfx; - m_pPhoneNr = pPhone; - m_bSwallowFaxNo = bSwallow; m_pInfoPrinter = pInfoPrinter; SetLayout( 0 ); } @@ -1200,78 +1194,9 @@ void GenPspGraphics::AnnounceFonts( ImplDevFontList* pFontList, const psp::FastP pFontList->Add( pFD ); } -bool GenPspGraphics::filterText( const OUString& rOrig, OUString& rNewText, sal_Int32 nIndex, sal_Int32& rLen, sal_Int32& rCutStart, sal_Int32& rCutStop ) +bool GenPspGraphics::filterText( const OUString& /*rOrig*/, OUString& /*rNewText*/, sal_Int32 /*nIndex*/, sal_Int32& /*rLen*/, sal_Int32& /*rCutStart*/, sal_Int32& /*rCutStop*/ ) { - if( ! m_pPhoneNr ) - return false; - - rNewText = rOrig; - rCutStop = rCutStart = -1; - -#define FAX_PHONE_TOKEN "@@#" -#define FAX_PHONE_TOKEN_LENGTH 3 -#define FAX_END_TOKEN "@@" -#define FAX_END_TOKEN_LENGTH 2 - - bool bRet = false; - bool bStarted = false; - sal_Int32 nPos; - sal_Int32 nStart = 0; - sal_Int32 nStop = rLen; - OUString aPhone = rOrig.copy( nIndex, rLen ); - - if( ! m_bPhoneCollectionActive ) - { - if( ( nPos = aPhone.indexOfAsciiL( FAX_PHONE_TOKEN, FAX_PHONE_TOKEN_LENGTH ) ) != -1 ) - { - nStart = nPos; - m_bPhoneCollectionActive = true; - m_aPhoneCollection = ""; - bRet = true; - bStarted = true; - } - } - if( m_bPhoneCollectionActive ) - { - bool bStopped = false; - bRet = true; - nPos = bStarted ? nStart + FAX_PHONE_TOKEN_LENGTH : 0; - if( ( nPos = aPhone.indexOfAsciiL( FAX_END_TOKEN, FAX_END_TOKEN_LENGTH, nPos ) ) != -1 ) - { - m_bPhoneCollectionActive = false; - nStop = nPos + FAX_END_TOKEN_LENGTH; - bStopped = true; - } - int nTokenStart = nStart + (bStarted ? FAX_PHONE_TOKEN_LENGTH : 0); - int nTokenStop = nStop - (bStopped ? FAX_END_TOKEN_LENGTH : 0); - m_aPhoneCollection += aPhone.copy( nTokenStart, nTokenStop - nTokenStart ); - if( ! m_bPhoneCollectionActive ) - { - OUStringBuffer aPhoneNr; - aPhoneNr.append( "<Fax#>" ); - aPhoneNr.append( m_aPhoneCollection ); - aPhoneNr.append( "</Fax#>" ); - *m_pPhoneNr = aPhoneNr.makeStringAndClear(); - m_aPhoneCollection = ""; - } - } - if( m_aPhoneCollection.getLength() > 1024 ) - { - m_bPhoneCollectionActive = false; - m_aPhoneCollection = ""; - bRet = false; - } - - if( bRet && m_bSwallowFaxNo ) - { - rLen -= nStop - nStart; - rCutStart = nStart+nIndex; - rCutStop = nStop+nIndex; - if (rCutStart != rCutStop) - rNewText = ( rCutStart ? rOrig.copy( 0, rCutStart ) : OUString() ) + rOrig.copy( rCutStop ); - } - - return bRet && m_bSwallowFaxNo; + return false; } bool GenPspGraphics::drawAlphaBitmap( const SalTwoRect&, diff --git a/vcl/generic/print/printerjob.cxx b/vcl/generic/print/printerjob.cxx index b6ef32f69d2a..9575169fb1fe 100644 --- a/vcl/generic/print/printerjob.cxx +++ b/vcl/generic/print/printerjob.cxx @@ -410,7 +410,7 @@ PrinterJob::StartJob ( } bool -PrinterJob::EndJob () +PrinterJob::EndJob() { // no pages ? that really means no print job if( maPageList.empty() ) @@ -531,7 +531,7 @@ PrinterJob::EndJob () { PrinterInfoManager& rPrinterInfoManager = PrinterInfoManager::get(); if (!rPrinterInfoManager.endSpool( m_aLastJobData.m_aPrinterName, - maJobTitle, pDestFILE, m_aDocumentJobData, true )) + maJobTitle, pDestFILE, m_aDocumentJobData, true, OUString())) { bSuccess = false; } diff --git a/vcl/inc/cupsmgr.hxx b/vcl/inc/cupsmgr.hxx index 08711a33e0c7..8454c313a1ad 100644 --- a/vcl/inc/cupsmgr.hxx +++ b/vcl/inc/cupsmgr.hxx @@ -77,7 +77,7 @@ public: const char* authenticateUser( const char* ); virtual FILE* startSpool( const OUString& rPrinterName, bool bQuickCommand ); - virtual bool endSpool( const OUString& rPrinterName, const OUString& rJobTitle, FILE* pFile, const JobData& rDocumentJobData, bool bBanner ); + virtual bool endSpool( const OUString& rPrinterName, const OUString& rJobTitle, FILE* pFile, const JobData& rDocumentJobData, bool bBanner, const OUString& rFaxNumber ); virtual void setupJobContextData( JobData& rData ); /// changes the info about a named printer diff --git a/vcl/inc/generic/genprn.h b/vcl/inc/generic/genprn.h index d21b97e19c5a..d3215f632966 100644 --- a/vcl/inc/generic/genprn.h +++ b/vcl/inc/generic/genprn.h @@ -59,10 +59,7 @@ class VCL_DLLPUBLIC PspSalPrinter : public SalPrinter public: OUString m_aFileName; OUString m_aTmpFile; - OUString m_aFaxNr; - bool m_bFax:1; bool m_bPdf:1; - bool m_bSwallowFaxNo:1; bool m_bIsPDFWriterJob:1; GenPspGraphics* m_pGraphics; psp::PrinterJob m_aPrintJob; diff --git a/vcl/inc/generic/genpspgraphics.h b/vcl/inc/generic/genpspgraphics.h index 9a2c8c559796..946f79c39b72 100644 --- a/vcl/inc/generic/genpspgraphics.h +++ b/vcl/inc/generic/genpspgraphics.h @@ -39,10 +39,6 @@ class VCL_DLLPUBLIC GenPspGraphics : public SalGraphics protected: psp::JobData* m_pJobData; psp::PrinterGfx* m_pPrinterGfx; - OUString* m_pPhoneNr; - bool m_bSwallowFaxNo; - OUString m_aPhoneCollection; - bool m_bPhoneCollectionActive; ServerFont* m_pServerFont[ MAX_FALLBACK ]; bool m_bFontVertical; @@ -52,7 +48,6 @@ public: virtual ~GenPspGraphics(); void Init( psp::JobData* pJob, psp::PrinterGfx* pGfx, - OUString* pPhone, bool bSwallow, SalInfoPrinter* pInfoPrinter ); // helper methods diff --git a/vcl/null/printerinfomanager.cxx b/vcl/null/printerinfomanager.cxx index cc31c8664062..d102f0cbbd3e 100644 --- a/vcl/null/printerinfomanager.cxx +++ b/vcl/null/printerinfomanager.cxx @@ -142,7 +142,7 @@ FILE* PrinterInfoManager::startSpool( const OUString& /* rPrintername */, bool / return NULL; } -bool PrinterInfoManager::endSpool( const OUString& /*rPrintername*/, const OUString& /*rJobTitle*/, FILE* /* pFile */, const JobData& /*rDocumentJobData*/, bool /*bBanner*/ ) +bool PrinterInfoManager::endSpool( const OUString& /*rPrintername*/, const OUString& /*rJobTitle*/, FILE* /* pFile */, const JobData& /*rDocumentJobData*/, bool /*bBanner*/, const OUString& /*rFaxNumber*/ ) { return true; } diff --git a/vcl/unx/generic/printer/cupsmgr.cxx b/vcl/unx/generic/printer/cupsmgr.cxx index 2cfcbaab5ec1..3627cd7670d0 100644 --- a/vcl/unx/generic/printer/cupsmgr.cxx +++ b/vcl/unx/generic/printer/cupsmgr.cxx @@ -541,7 +541,7 @@ void CUPSManager::setupJobContextData( JobData& rData ) FILE* CUPSManager::startSpool( const OUString& rPrintername, bool bQuickCommand ) { - OSL_TRACE( "endSpool: %s, %s", + OSL_TRACE( "startSpool: %s, %s", OUStringToOString( rPrintername, RTL_TEXTENCODING_UTF8 ).getStr(), bQuickCommand ? "true" : "false" ); @@ -612,7 +612,7 @@ void CUPSManager::getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner } } -bool CUPSManager::endSpool( const OUString& rPrintername, const OUString& rJobTitle, FILE* pFile, const JobData& rDocumentJobData, bool bBanner ) +bool CUPSManager::endSpool( const OUString& rPrintername, const OUString& rJobTitle, FILE* pFile, const JobData& rDocumentJobData, bool bBanner, const OUString& rFaxNumber ) { OSL_TRACE( "endSpool: %s, %s, copy count = %d", OUStringToOString( rPrintername, RTL_TEXTENCODING_UTF8 ).getStr(), @@ -629,7 +629,7 @@ bool CUPSManager::endSpool( const OUString& rPrintername, const OUString& rJobTi if( dest_it == m_aCUPSDestMap.end() ) { OSL_TRACE( "defer to PrinterInfoManager::endSpool" ); - return PrinterInfoManager::endSpool( rPrintername, rJobTitle, pFile, rDocumentJobData, bBanner ); + return PrinterInfoManager::endSpool( rPrintername, rJobTitle, pFile, rDocumentJobData, bBanner, rFaxNumber ); } boost::unordered_map< FILE*, OString, FPtrHash >::const_iterator it = m_aSpoolFiles.find( pFile ); @@ -643,11 +643,20 @@ bool CUPSManager::endSpool( const OUString& rPrintername, const OUString& rJobTi cups_option_t* pOptions = NULL; getOptionsFromDocumentSetup( rDocumentJobData, bBanner, nNumOptions, (void**)&pOptions ); + OString sJobName(OUStringToOString(rJobTitle, aEnc)); + + //fax4CUPS, "the job name will be dialled for you" + //so override the jobname with the desired number + if (!rFaxNumber.isEmpty()) + { + sJobName = OUStringToOString(rFaxNumber, aEnc); + } + cups_dest_t* pDest = ((cups_dest_t*)m_pDests) + dest_it->second; - nJobID = cupsPrintFile( pDest->name, - it->second.getStr(), - OUStringToOString( rJobTitle, aEnc ).getStr(), - nNumOptions, pOptions ); + nJobID = cupsPrintFile(pDest->name, + it->second.getStr(), + sJobName.getStr(), + nNumOptions, pOptions); SAL_INFO("vcl.unx.print", "cupsPrintFile( " << pDest->name << ", " << it->second << ", " << rJobTitle << ", " << nNumOptions << ", " << pOptions << " ) returns " << nJobID); diff --git a/vcl/unx/generic/printer/printerinfomanager.cxx b/vcl/unx/generic/printer/printerinfomanager.cxx index 0c6e7138977f..01d6ce62a7dd 100644 --- a/vcl/unx/generic/printer/printerinfomanager.cxx +++ b/vcl/unx/generic/printer/printerinfomanager.cxx @@ -966,7 +966,7 @@ FILE* PrinterInfoManager::startSpool( const OUString& rPrintername, bool bQuickC return popen (aShellCommand.getStr(), "w"); } -bool PrinterInfoManager::endSpool( const OUString& /*rPrintername*/, const OUString& /*rJobTitle*/, FILE* pFile, const JobData& /*rDocumentJobData*/, bool /*bBanner*/ ) +bool PrinterInfoManager::endSpool( const OUString& /*rPrintername*/, const OUString& /*rJobTitle*/, FILE* pFile, const JobData& /*rDocumentJobData*/, bool /*bBanner*/, const OUString& /*rFaxNumber*/ ) { return (0 == pclose( pFile )); } |