vcl/unx/generic/printer/cupsmgr.cxx |   11 +++++++++++
 1 file changed, 11 insertions(+)

New commits:
commit 06da42353c53193685da3d2aa0b313bd5c1b1026
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Oct 29 12:10:13 2024 +0100
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Thu Oct 31 09:32:28 2024 +0100

    tdf#161152 vcl: Set CUPS "sides" option for duplex mode
    
    When the PPD "Duplex" option is set in a print job,
    also set the CUPS "sides" option documented at [1],
    section "Printing On Both Sides of the Paper".
    
    This is apparently required for at least some Brother
    printers where the "Duplex" PPD option is not evaluated
    during the print process.
    
    [1] https://www.cups.org/doc/options.html
    
    Change-Id: Ib280c3c65eaf7bf74b611f0ce921eda51b1ebe19
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175782
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    (cherry picked from commit 152896274aca291a5d2181db6dd639c3e36c2a02)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175836
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/vcl/unx/generic/printer/cupsmgr.cxx 
b/vcl/unx/generic/printer/cupsmgr.cxx
index c28635e5cdcd..45ffb49f46fc 100644
--- a/vcl/unx/generic/printer/cupsmgr.cxx
+++ b/vcl/unx/generic/printer/cupsmgr.cxx
@@ -649,6 +649,17 @@ 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) );
+                // for duplex, also set the corresponding CUPS "sides" option, 
see section
+                // "Printing On Both Sides of the Paper" at 
https://www.cups.org/doc/options.html
+                if (aKey == "Duplex")
+                {
+                    if (aValue == "None")
+                        rNumOptions = cupsAddOption("sides", "one-sided", 
rNumOptions, reinterpret_cast<cups_option_t**>(rOptions));
+                    else if (aValue == "DuplexTumble")
+                        rNumOptions = cupsAddOption("sides", 
"two-sided-short-edge", rNumOptions, 
reinterpret_cast<cups_option_t**>(rOptions));
+                    else if (aValue == "DuplexNoTumble")
+                        rNumOptions = cupsAddOption("sides", 
"two-sided-long-edge", rNumOptions, 
reinterpret_cast<cups_option_t**>(rOptions));
+                }
             }
         }
     }

Reply via email to