diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-08-26 15:56:08 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-08-27 07:30:48 +0200 |
commit | 5c24f11c54fcfbe825e845e7e32b1bc6f3fd2d6f (patch) | |
tree | 70fb07d3c9ac8c62cf535b47d33a00127a44fbc4 /vcl | |
parent | f4c665b530d7fd29495c86a34cdae133907b86d7 (diff) |
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 <m.weghorn@posteo.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/unx/cupsmgr.hxx | 5 | ||||
-rw-r--r-- | vcl/unx/generic/printer/cupsmgr.cxx | 17 | ||||
-rw-r--r-- | vcl/unx/generic/printer/ppdparser.cxx | 7 |
3 files changed, 18 insertions, 11 deletions
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> |