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

New commits:
commit 152896274aca291a5d2181db6dd639c3e36c2a02
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Oct 29 12:10:13 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Oct 29 13:34:32 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>

diff --git a/vcl/unx/generic/printer/cupsmgr.cxx 
b/vcl/unx/generic/printer/cupsmgr.cxx
index 8fc18bb5fa1e..fa61a6052b20 100644
--- a/vcl/unx/generic/printer/cupsmgr.cxx
+++ b/vcl/unx/generic/printer/cupsmgr.cxx
@@ -649,6 +649,18 @@ 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, ppOptions);
+
+                // 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, ppOptions);
+                    else if (aValue == "DuplexTumble")
+                        rNumOptions = cupsAddOption("sides", 
"two-sided-short-edge", rNumOptions, ppOptions);
+                    else if (aValue == "DuplexNoTumble")
+                        rNumOptions = cupsAddOption("sides", 
"two-sided-long-edge", rNumOptions, ppOptions);
+                }
             }
         }
     }

Reply via email to