diff options
-rw-r--r-- | config_host/config_cups.h.in | 6 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | include/vcl/jobdata.hxx | 6 | ||||
-rw-r--r-- | include/vcl/printerinfomanager.hxx | 10 | ||||
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 40 | ||||
-rw-r--r-- | vcl/inc/unx/cupsmgr.hxx | 24 | ||||
-rw-r--r-- | vcl/unx/generic/printer/cupsmgr.cxx | 105 | ||||
-rw-r--r-- | vcl/unx/generic/printer/jobdata.cxx | 18 | ||||
-rw-r--r-- | vcl/unx/generic/printer/printerinfomanager.cxx | 15 |
9 files changed, 20 insertions, 207 deletions
diff --git a/config_host/config_cups.h.in b/config_host/config_cups.h.in deleted file mode 100644 index 6794703664d9..000000000000 --- a/config_host/config_cups.h.in +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef CONFIG_CUPS_H -#define CONFIG_CUPS_H - -#define ENABLE_CUPS 0 - -#endif diff --git a/configure.ac b/configure.ac index 6e455d57d492..c81bd1aae570 100644 --- a/configure.ac +++ b/configure.ac @@ -4850,7 +4850,7 @@ if test "$test_cups" = "yes"; then if test "$ac_cv_lib_cups_cupsPrintFiles" != "yes" -o "$ac_cv_header_cups_cups_h" != "yes"; then AC_MSG_ERROR([Could not find CUPS. Install libcups2-dev or cups-devel.]) fi - AC_DEFINE(ENABLE_CUPS) + else AC_MSG_RESULT([no]) fi @@ -12967,7 +12967,6 @@ AC_CONFIG_HEADERS([config_host/config_dconf.h]) AC_CONFIG_HEADERS([config_host/config_eot.h]) AC_CONFIG_HEADERS([config_host/config_extension_update.h]) AC_CONFIG_HEADERS([config_host/config_cairo_canvas.h]) -AC_CONFIG_HEADERS([config_host/config_cups.h]) AC_CONFIG_HEADERS([config_host/config_cxxabi.h]) AC_CONFIG_HEADERS([config_host/config_dbus.h]) AC_CONFIG_HEADERS([config_host/config_features.h]) diff --git a/include/vcl/jobdata.hxx b/include/vcl/jobdata.hxx index 771f73c314ea..13b34de93320 100644 --- a/include/vcl/jobdata.hxx +++ b/include/vcl/jobdata.hxx @@ -79,12 +79,6 @@ struct VCL_DLLPUBLIC JobData static bool constructFromStreamBuffer( void* pData, sal_uInt32 bytes, JobData& rJobData ); }; -bool operator==(const psp::JobData& rLeft, const psp::JobData& rRight); -inline bool operator!=(const psp::JobData& rLeft, const psp::JobData& rRight) -{ - return !( rLeft == rRight ); -} - } // namespace diff --git a/include/vcl/printerinfomanager.hxx b/include/vcl/printerinfomanager.hxx index d41a7c8bc270..f548bf239e91 100644 --- a/include/vcl/printerinfomanager.hxx +++ b/include/vcl/printerinfomanager.hxx @@ -195,16 +195,6 @@ public: // check whether a printer's feature string contains a subfeature bool checkFeatureToken( const OUString& rPrinterName, const char* pToken ) const; - // Starts printing in a batch mode, in which all printing will be done together instead of separate jobs. - // If the implementation supports it, calls to endSpool() will only delay the printing until flushBatchPrint() - // is called to print all delayed jobs. - // Returns false if failed or not supported (in which case endSpool() will print normally). - virtual bool startBatchPrint(); - // Actually spools all delayed print jobs, if enabled, and disables batch mode. - virtual bool flushBatchPrint(); - // Returns true batch printing is supported at all. - virtual bool supportsBatchPrint() const; - virtual ~PrinterInfoManager(); }; diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 0c26cb120d2a..2eb6b4336893 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -137,10 +137,6 @@ #include <dbfld.hxx> #include <memory> -#include <config_cups.h> -#if ENABLE_CUPS && !defined(MACOSX) -#include <vcl/printerinfomanager.hxx> -#endif #include <comphelper/propertysequence.hxx> #include <officecfg/Office/Common.hxx> @@ -910,27 +906,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, bool bNoError = true; const bool bEMail = rMergeDescriptor.nMergeType == DBMGR_MERGE_EMAIL; const bool bMergeShell = rMergeDescriptor.nMergeType == DBMGR_MERGE_SHELL; - bool bCreateSingleFile = rMergeDescriptor.bCreateSingleFile; - - if( rMergeDescriptor.nMergeType == DBMGR_MERGE_PRINTER ) - { - // It is possible to do MM printing in both modes for the same result, but the singlefile mode - // is slower because of all the temporary document copies and merging them together - // into the single file, while the other mode simply updates fields and prints for every record. - // However, this would cause one print job for every record, and e.g. CUPS refuses new jobs - // if it has many jobs enqueued (500 by default), and with the current printing framework - // (which uses a pull model) it's rather complicated to create a single print job - // in steps. - // To handle this, CUPS backend has been changed to cache all the documents to print - // and send them to CUPS only as one job at the very end. Therefore, with CUPS, it's ok - // to use the faster mode. As I have no idea about other platforms, keep them using - // the slower singlefile mode (or feel free to check them, or rewrite the printing code). -#if ENABLE_CUPS && !defined(MACOSX) - bCreateSingleFile = !psp::PrinterInfoManager::get().supportsBatchPrint(); -#else - bCreateSingleFile = true; -#endif - } + const bool bCreateSingleFile = rMergeDescriptor.bCreateSingleFile; ::rtl::Reference< MailDispatcher > xMailDispatcher; OUString sBodyMimeType; @@ -1342,13 +1318,10 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, } } pWorkView->StartPrint( aOptions, IsMergeSilent(), rMergeDescriptor.bPrintAsync ); - SfxPrinter* pDocPrt = pWorkView->GetPrinter(); - JobSetup aJobSetup = pDocPrt ? pDocPrt->GetJobSetup() : SfxViewShell::GetJobSetup(); + // some GetPrinter functions have a true default, so keep the false + SfxPrinter* pDocPrt = pWorkView->GetPrinter( false ); + JobSetup aJobSetup = pDocPrt ? pDocPrt->GetJobSetup() : pWorkView->GetJobSetup(); bCancel = !Printer::PreparePrintJob( pWorkView->GetPrinterController(), aJobSetup ); -#if ENABLE_CUPS && !defined(MACOSX) - if( !bCancel ) - psp::PrinterInfoManager::get().startBatchPrint(); -#endif } if( !bCancel && !Printer::ExecutePrintJob( pWorkView->GetPrinterController())) bCancel = true; @@ -1491,12 +1464,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, if( !bCreateSingleFile ) { if( rMergeDescriptor.nMergeType == DBMGR_MERGE_PRINTER ) - { Printer::FinishPrintJob( pWorkView->GetPrinterController()); -#if ENABLE_CUPS && !defined(MACOSX) - psp::PrinterInfoManager::get().flushBatchPrint(); -#endif - } if( !bIsPDFexport ) { pWorkDoc->SetDBManager( pOldDBManager ); diff --git a/vcl/inc/unx/cupsmgr.hxx b/vcl/inc/unx/cupsmgr.hxx index e7860e2f8f5c..576afd4fe3cc 100644 --- a/vcl/inc/unx/cupsmgr.hxx +++ b/vcl/inc/unx/cupsmgr.hxx @@ -58,23 +58,6 @@ class CUPSManager : public PrinterInfoManager osl::Mutex m_aGetPPDMutex; bool m_bPPDThreadRunning; - struct PendingJob - { - OUString printerName; - OUString jobTitle; - JobData jobData; - bool banner; - OUString faxNumber; - OString file; - PendingJob( const OUString& printerName_, const OUString& jobTitle_, const JobData& jobData_, - bool banner_, const OUString& faxNumber_, const OString& file_ ) - : printerName( printerName_ ), jobTitle( jobTitle_ ), jobData( jobData_ ), banner( banner_ ), faxNumber( faxNumber_ ), file( file_ ) - {} - PendingJob() : banner( false ) {} - }; - std::list< PendingJob > pendingJobs; - bool batchMode; - CUPSManager(); virtual ~CUPSManager(); @@ -83,9 +66,6 @@ class CUPSManager : public PrinterInfoManager static void getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner, int& rNumOptions, void** rOptions ); void runDests(); OString threadedCupsGetPPD(const char* pPrinter); - - bool processPendingJobs(); - bool printJobs( const PendingJob& job, const std::vector< OString >& files ); public: static void runDestThread(void* pMgr); @@ -100,10 +80,6 @@ public: virtual bool endSpool( const OUString& rPrinterName, const OUString& rJobTitle, FILE* pFile, const JobData& rDocumentJobData, bool bBanner, const OUString& rFaxNumber ) override; virtual void setupJobContextData( JobData& rData ) override; - virtual bool startBatchPrint() override; - virtual bool flushBatchPrint() override; - virtual bool supportsBatchPrint() const override; - /// changes the info about a named printer virtual void changePrinterInfo( const OUString& rPrinter, const PrinterInfo& rNewInfo ) override; diff --git a/vcl/unx/generic/printer/cupsmgr.cxx b/vcl/unx/generic/printer/cupsmgr.cxx index 71464d7e9157..2da3bf90e4fc 100644 --- a/vcl/unx/generic/printer/cupsmgr.cxx +++ b/vcl/unx/generic/printer/cupsmgr.cxx @@ -183,8 +183,7 @@ CUPSManager::CUPSManager() : m_nDests( 0 ), m_pDests( nullptr ), m_bNewDests( false ), - m_bPPDThreadRunning( false ), - batchMode( false ) + m_bPPDThreadRunning( false ) { m_aDestThread = osl_createThread( run_dest_thread_stub, this ); } @@ -626,6 +625,8 @@ bool CUPSManager::endSpool( const OUString& rPrintername, const OUString& rJobTi rDocumentJobData.m_nCopies ); + int nJobID = 0; + osl::MutexGuard aGuard( m_aCUPSMutex ); std::unordered_map< OUString, int, OUStringHash >::iterator dest_it = @@ -637,106 +638,32 @@ bool CUPSManager::endSpool( const OUString& rPrintername, const OUString& rJobTi } std::unordered_map< FILE*, OString, FPtrHash >::const_iterator it = m_aSpoolFiles.find( pFile ); - if( it == m_aSpoolFiles.end() ) - return false; - fclose( pFile ); - PendingJob job( rPrintername, rJobTitle, rDocumentJobData, bBanner, rFaxNumber, it->second ); - m_aSpoolFiles.erase( pFile ); - pendingJobs.push_back( job ); - if( !batchMode ) // process immediately, otherwise will be handled by flushBatchPrint() - return processPendingJobs(); - return true; -} - -bool CUPSManager::startBatchPrint() -{ - batchMode = true; - return true; -} - -bool CUPSManager::supportsBatchPrint() const -{ - return true; -} - -bool CUPSManager::flushBatchPrint() -{ - osl::MutexGuard aGuard( m_aCUPSMutex ); - batchMode = false; // reset the batch print mode - return processPendingJobs(); -} - -bool CUPSManager::processPendingJobs() -{ - // Print all jobs that have the same data using one CUPS call (i.e. merge all jobs that differ only in files to print). - PendingJob currentJobData; - bool first = true; - std::vector< OString > files; - bool ok = true; - while( !pendingJobs.empty()) - { - if( first ) - { - currentJobData = pendingJobs.front(); - first = false; - } - else if( currentJobData.printerName != pendingJobs.front().printerName - || currentJobData.jobTitle != pendingJobs.front().jobTitle - || currentJobData.jobData != pendingJobs.front().jobData - || currentJobData.banner != pendingJobs.front().banner ) - { - if( !printJobs( currentJobData, files )) - ok = false; - files.clear(); - currentJobData = pendingJobs.front(); - } - files.push_back( pendingJobs.front().file ); - pendingJobs.pop_front(); - } - if( !first ) + if( it != m_aSpoolFiles.end() ) { - if( !printJobs( currentJobData, files )) // print the last batch - ok = false; - } - return ok; -} - -bool CUPSManager::printJobs( const PendingJob& job, const std::vector< OString >& files ) -{ - std::unordered_map< OUString, int, OUStringHash >::iterator dest_it = - m_aCUPSDestMap.find( job.printerName ); - + fclose( pFile ); rtl_TextEncoding aEnc = osl_getThreadTextEncoding(); // setup cups options int nNumOptions = 0; cups_option_t* pOptions = nullptr; - getOptionsFromDocumentSetup( job.jobData, job.banner, nNumOptions, reinterpret_cast<void**>(&pOptions) ); + getOptionsFromDocumentSetup( rDocumentJobData, bBanner, nNumOptions, reinterpret_cast<void**>(&pOptions) ); - OString sJobName(OUStringToOString(job.jobTitle, aEnc)); + OString sJobName(OUStringToOString(rJobTitle, aEnc)); //fax4CUPS, "the job name will be dialled for you" //so override the jobname with the desired number - if (!job.faxNumber.isEmpty()) + if (!rFaxNumber.isEmpty()) { - sJobName = OUStringToOString(job.faxNumber, aEnc); + sJobName = OUStringToOString(rFaxNumber, aEnc); } cups_dest_t* pDest = static_cast<cups_dest_t*>(m_pDests) + dest_it->second; - - std::vector< const char* > fnames; - for( std::vector< OString >::const_iterator it = files.begin(); - it != files.end(); - ++it ) - fnames.push_back( it->getStr()); - - int nJobID = cupsPrintFiles(pDest->name, - fnames.size(), - fnames.data(), + nJobID = cupsPrintFile(pDest->name, + it->second.getStr(), sJobName.getStr(), nNumOptions, pOptions); SAL_INFO("vcl.unx.print", "cupsPrintFile( " << pDest->name << ", " - << ( fnames.size() == 1 ? files.front() : OString::number( fnames.size()) ).getStr() << ", " << sJobName << ", " << nNumOptions + << it->second << ", " << rJobTitle << ", " << nNumOptions << ", " << pOptions << " ) returns " << nJobID); for( int n = 0; n < nNumOptions; n++ ) SAL_INFO("vcl.unx.print", @@ -748,13 +675,11 @@ bool CUPSManager::printJobs( const PendingJob& job, const std::vector< OString > system( aCmd.getStr() ); #endif - for( std::vector< OString >::const_iterator it = files.begin(); - it != files.end(); - ++it ) - unlink( it->getStr()); - + unlink( it->second.getStr() ); + m_aSpoolFiles.erase( pFile ); if( pOptions ) cupsFreeOptions( nNumOptions, pOptions ); + } return nJobID != 0; } diff --git a/vcl/unx/generic/printer/jobdata.cxx b/vcl/unx/generic/printer/jobdata.cxx index f52e577bf31b..aead34c96eb1 100644 --- a/vcl/unx/generic/printer/jobdata.cxx +++ b/vcl/unx/generic/printer/jobdata.cxx @@ -52,24 +52,6 @@ JobData& JobData::operator=(const JobData& rRight) return *this; } -bool psp::operator==(const psp::JobData& rLeft, const psp::JobData& rRight) -{ - return rLeft.m_nCopies == rRight.m_nCopies -// && rLeft.m_bCollate == rRight.m_bCollate - && rLeft.m_nLeftMarginAdjust == rRight.m_nLeftMarginAdjust - && rLeft.m_nRightMarginAdjust == rRight.m_nRightMarginAdjust - && rLeft.m_nTopMarginAdjust == rRight.m_nTopMarginAdjust - && rLeft.m_nBottomMarginAdjust == rRight.m_nBottomMarginAdjust - && rLeft.m_nColorDepth == rRight.m_nColorDepth - && rLeft.m_eOrientation == rRight.m_eOrientation - && rLeft.m_aPrinterName == rRight.m_aPrinterName - && rLeft.m_pParser == rRight.m_pParser -// && rLeft.m_aContext == rRight.m_aContext - && rLeft.m_nPSLevel == rRight.m_nPSLevel - && rLeft.m_nPDFDevice == rRight.m_nPDFDevice - && rLeft.m_nColorDevice == rRight.m_nColorDevice; -} - void JobData::setCollate( bool bCollate ) { if (m_nPDFDevice > 0) diff --git a/vcl/unx/generic/printer/printerinfomanager.cxx b/vcl/unx/generic/printer/printerinfomanager.cxx index c61a04c52aa4..993c898d068a 100644 --- a/vcl/unx/generic/printer/printerinfomanager.cxx +++ b/vcl/unx/generic/printer/printerinfomanager.cxx @@ -934,21 +934,6 @@ void PrinterInfoManager::setDefaultPaper( PPDContext& rContext ) const } } -bool PrinterInfoManager::startBatchPrint() -{ - return false; // not implemented -} - -bool PrinterInfoManager::supportsBatchPrint() const -{ - return false; -} - -bool PrinterInfoManager::flushBatchPrint() -{ - return false; -} - SystemQueueInfo::SystemQueueInfo() : m_bChanged( false ) { |