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

New commits:
commit 1dc4846e76570ab19c028ac23786e4ffd8fc4679
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Mon Dec 16 16:47:36 2024 -0500
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Thu Dec 19 21:42:42 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 <jl...@mail.com>
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178827

diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index 4f9d17063b76..97db183dc17f 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