vcl/unx/generic/printer/cupsmgr.cxx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
New commits: commit 21a31eefab1401d288dbb8220f3df3365be9efaf Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Jul 19 17:27:19 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Tue Jul 19 21:47:51 2022 +0200 tdf#149439 set initial customoption values from lpoptions when present I presume there's a better way to do all this. Change-Id: Id7e6cd3be5b82e419f17bba31834fef7cfe8299b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137237 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/unx/generic/printer/cupsmgr.cxx b/vcl/unx/generic/printer/cupsmgr.cxx index 6acfe1db6ee1..5cb91e05df66 100644 --- a/vcl/unx/generic/printer/cupsmgr.cxx +++ b/vcl/unx/generic/printer/cupsmgr.cxx @@ -494,6 +494,32 @@ const PPDParser* CUPSManager::createCUPSParser( const OUString& rPrinter ) for( int i = 0; i < pPPD->num_groups; i++ ) updatePrinterContextInfo( pPPD->groups + i, rContext ); + // tdf#149439 Set Custom values. + for (int k = 0; k < pDest->num_options; ++k) + { + if (strncmp(pDest->options[k].value, RTL_CONSTASCII_STRINGPARAM("Custom.")) == 0) + { + const PPDKey* pKey = rContext.getParser()->getKey(OStringToOUString(pDest->options[k].name, aEncoding)); + if (!pKey) + { + SAL_WARN("vcl.unx.print", "Custom key " << pDest->options[k].name << " not found"); + continue; + } + const PPDValue* pCustomValue = rContext.getValue(pKey); + if (!pCustomValue) + { + SAL_WARN("vcl.unx.print", "Value for " << pDest->options[k].name << " not found"); + continue; + } + if (!pCustomValue->m_bCustomOption) + { + SAL_WARN("vcl.unx.print", "Value for " << pDest->options[k].name << " not set to custom option"); + continue; + } + pCustomValue->m_aCustomOption = OStringToOUString(pDest->options[k].value, aEncoding); + } + } + rInfo.m_pParser = pNewParser; rInfo.m_aContext = rContext;