sw/source/core/unocore/unostyle.cxx |    5 +++++
 1 file changed, 5 insertions(+)

New commits:
commit 3c909d9a97e82549e891020b6331ae77326c1133
Author:     Justin Luth <[email protected]>
AuthorDate: Mon Dec 16 16:47:36 2024 -0500
Commit:     Miklos Vajna <[email protected]>
CommitDate: Fri Dec 20 16:08:21 2024 +0100

    tdf#164263: avoid exception when SAL_DISABLE_PRINTERLIST #2
    
    This fixes a backported to 24.2.1 regression
    from commit e6f75eb50bc5d1ebccda0c0f80a7b353d991106e
    
    Although an empty OUString is returned when IsDisplayPrinter(),
    using that to setPropertyValue causes an exception.
    Since IsDisplayPrinter always returns static values for all queries,
    there is no need to actually attempt to make any changes
    when IsDisplayPrinter().
    
    I don't see any unit test examples from the offending regression,
    or anything else in SW relating to Printer or environment variables,
    nor is there any explict call available to set mpDisplayDev,
    so I don't know how I can create a unit test for this.
    
    Change-Id: I3d4054df57ab460833d9994d71133aef64cbb714
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178753
    Reviewed-by: Justin Luth <[email protected]>
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178827
    (cherry picked from commit 1dc4846e76570ab19c028ac23786e4ffd8fc4679)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178844
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index 665c1d2c6ac5..df67cc69d3d1 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1672,6 +1672,11 @@ void 
SwXStyle::SetPropertyValue<sal_uInt16(RES_PAPER_BIN)>(const SfxItemProperty
     if (!rValue.has<OUString>() && !rValue.has<sal_Int32>())
         throw lang::IllegalArgumentException();
     SfxPrinter* pPrinter = m_pDoc->getIDocumentDeviceAccess().getPrinter(true);
+
+    // PAPER_BINs have no meaning when there is no actual printer
+    if (pPrinter->IsDisplayPrinter())
+        return;
+
     using printeridx_t = decltype(pPrinter->GetPaperBinCount());
     printeridx_t nBin = std::numeric_limits<printeridx_t>::max();
     if(rValue.has<OUString>())

Reply via email to