vcl/Library_vcl.mk | 2 ++ vcl/inc/unx/cupsmgr.hxx | 5 ++++- vcl/unx/generic/printer/cupsmgr.cxx | 17 ++++++++--------- vcl/unx/generic/printer/ppdparser.cxx | 7 ++++++- vcl/unx/generic/printer/printerinfomanager.cxx | 6 ++++++ 5 files changed, 26 insertions(+), 11 deletions(-)
New commits: commit 5c24f11c54fcfbe825e845e7e32b1bc6f3fd2d6f Author: Michael Weghorn <[email protected]> AuthorDate: Mon Aug 26 15:56:08 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Tue Aug 27 07:30:48 2024 +0200 vcl: Use cups_option_t** param instead of void** Use `cups_option_t**` for the param type instead of passing the `cups_option_t**` as `void**` and casting to `cups_option_t**` again everywhere it is used. Make the `<unx/cupsmgr.hxx>` include in vcl/unx/generic/printer/ppdparser.cxx depend on `ENABLE_CUPS`, to not require the CUPS header newly included in cupsmgr.hxx otherwise. Change-Id: Iac1362866099496f59101149ca02f1477cbd2b11 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172402 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/inc/unx/cupsmgr.hxx b/vcl/inc/unx/cupsmgr.hxx index fb172103bbd9..200beb8e7e13 100644 --- a/vcl/inc/unx/cupsmgr.hxx +++ b/vcl/inc/unx/cupsmgr.hxx @@ -19,6 +19,8 @@ #pragma once +#include <cups/cups.h> + #include <printerinfomanager.hxx> #include <osl/thread.h> #include <osl/mutex.hxx> @@ -63,7 +65,8 @@ class CUPSManager final : public PrinterInfoManager virtual void initialize() override; - static void getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner, int& rNumOptions, void** rOptions ); + static void getOptionsFromDocumentSetup(const JobData& rJob, bool bBanner, int& rNumOptions, + cups_option_t** rOptions); void runDests(); OString threadedCupsGetPPD(const char* pPrinter); public: diff --git a/vcl/unx/generic/printer/cupsmgr.cxx b/vcl/unx/generic/printer/cupsmgr.cxx index c28635e5cdcd..8fc18bb5fa1e 100644 --- a/vcl/unx/generic/printer/cupsmgr.cxx +++ b/vcl/unx/generic/printer/cupsmgr.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <cups/cups.h> #include <cups/http.h> #include <cups/ipp.h> #include <cups/ppd.h> @@ -616,10 +615,11 @@ struct less_ppd_key } -void CUPSManager::getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner, int& rNumOptions, void** rOptions ) +void CUPSManager::getOptionsFromDocumentSetup(const JobData& rJob, bool bBanner, int& rNumOptions, + cups_option_t** ppOptions) { rNumOptions = 0; - *rOptions = nullptr; + *ppOptions = nullptr; // emit features ordered to OrderDependency // ignore features that are set to default @@ -648,7 +648,7 @@ void CUPSManager::getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner { OString aKey = OUStringToOString( pKey->getKey(), RTL_TEXTENCODING_ASCII_US ); OString aValue = OUStringToOString( sPayLoad, RTL_TEXTENCODING_ASCII_US ); - rNumOptions = cupsAddOption( aKey.getStr(), aValue.getStr(), rNumOptions, reinterpret_cast<cups_option_t**>(rOptions) ); + rNumOptions = cupsAddOption(aKey.getStr(), aValue.getStr(), rNumOptions, ppOptions); } } } @@ -656,13 +656,13 @@ void CUPSManager::getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner if( rJob.m_nCopies > 1 ) { OString aVal( OString::number( rJob.m_nCopies ) ); - rNumOptions = cupsAddOption( "copies", aVal.getStr(), rNumOptions, reinterpret_cast<cups_option_t**>(rOptions) ); + rNumOptions = cupsAddOption("copies", aVal.getStr(), rNumOptions, ppOptions); aVal = OString::boolean(rJob.m_bCollate); - rNumOptions = cupsAddOption( "collate", aVal.getStr(), rNumOptions, reinterpret_cast<cups_option_t**>(rOptions) ); + rNumOptions = cupsAddOption("collate", aVal.getStr(), rNumOptions, ppOptions); } if( ! bBanner ) { - rNumOptions = cupsAddOption( "job-sheets", "none", rNumOptions, reinterpret_cast<cups_option_t**>(rOptions) ); + rNumOptions = cupsAddOption("job-sheets", "none", rNumOptions, ppOptions); } } @@ -808,8 +808,7 @@ bool CUPSManager::endSpool( const OUString& rPrintername, const OUString& rJobTi // setup cups options int nNumOptions = 0; cups_option_t* pOptions = nullptr; - auto ppOptions = reinterpret_cast<void**>(&pOptions); - getOptionsFromDocumentSetup( rDocumentJobData, bBanner, nNumOptions, ppOptions ); + getOptionsFromDocumentSetup(rDocumentJobData, bBanner, nNumOptions, &pOptions); PrinterInfo aInfo(getPrinterInfo(rPrintername)); if (!aInfo.m_aAuthInfoRequired.isEmpty()) diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index cc16c4f563bb..7f1df3848537 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -26,19 +26,24 @@ #include <comphelper/string.hxx> #include <o3tl/string_view.hxx> #include <i18nlangtag/languagetag.hxx> +#include <jobdata.hxx> #include <ppdparser.hxx> +#include <printerinfomanager.hxx> #include <strhelper.hxx> #include <utility> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <unx/helper.hxx> -#include <unx/cupsmgr.hxx> #if ENABLE_CPDB #include <unx/cpdmgr.hxx> #endif +#if ENABLE_CUPS +#include <unx/cupsmgr.hxx> +#endif + #include <tools/urlobj.hxx> #include <tools/stream.hxx> #include <tools/zcodec.hxx> commit f4c665b530d7fd29495c86a34cdae133907b86d7 Author: Michael Weghorn <[email protected]> AuthorDate: Mon Aug 26 15:37:44 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Tue Aug 27 07:30:37 2024 +0200 Make CPDB work with --enable-cpdb --disable-cups The `PrinterInfoManager` implementation in vcl/unx/generic/printer/printerinfomanager.cxx takes care of actually using the `CUPSManager` or the `CPDManager` for handling printers/printing. Therefore, build that one also when `--disable-cups` is used in addition to `--enable-cpdb`, and only make the CUPS-specific bits depend on `ENABLE_CUPS`, rather than building the dummy version of the `PrinterInfoManager` implemented in vcl/null/printerinfomanager.cxx. This makes the CPDB printers show up in the print dialog with WIP Gerrit change [1] in place in addition. [1] https://gerrit.libreoffice.org/c/core/+/169617/25 Change-Id: I5dddc72b8e679a84225f1dfb9c87d7562613a9f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172401 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 1635358258a0..8d51d7157bcf 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -634,6 +634,8 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ $(if $(USE_HEADLESS_CODE), \ $(if $(ENABLE_CUPS), \ vcl/unx/generic/printer/cupsmgr \ + ) \ + $(if $(filter TRUE,$(ENABLE_CPDB) $(ENABLE_CUPS)),\ vcl/unx/generic/printer/printerinfomanager \ , \ vcl/null/printerinfomanager \ diff --git a/vcl/unx/generic/printer/printerinfomanager.cxx b/vcl/unx/generic/printer/printerinfomanager.cxx index 6091bc2e3639..ad55d7448d8b 100644 --- a/vcl/unx/generic/printer/printerinfomanager.cxx +++ b/vcl/unx/generic/printer/printerinfomanager.cxx @@ -18,12 +18,16 @@ */ #include <config_cpdb.h> +#include <config_cups.h> #if ENABLE_CPDB #include <unx/cpdmgr.hxx> #endif +#if ENABLE_CUPS #include <unx/cupsmgr.hxx> +#endif + #include <unx/gendata.hxx> #include <unx/helper.hxx> @@ -89,8 +93,10 @@ PrinterInfoManager& PrinterInfoManager::get() #if ENABLE_CPDB pPIM = CPDManager::tryLoadCPD(); #endif +#if ENABLE_CUPS if (!pPIM) pPIM = CUPSManager::tryLoadCUPS(); +#endif if (!pPIM) pPIM = new PrinterInfoManager(); pSalData->m_pPrinterInfoManager.reset(pPIM);
