summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2024-12-16 16:47:36 -0500
committerJustin Luth <jluth@mail.com>2024-12-19 21:42:42 +0100
commit1dc4846e76570ab19c028ac23786e4ffd8fc4679 (patch)
tree7a7f8c38f3dff22dbf4cd1cf910e9c06939b841c
parent5414e48ef97b4734912d64adcdadfca2f50e2aa4 (diff)
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 <jluth@mail.com> Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178827
-rw-r--r--sw/source/core/unocore/unostyle.cxx5
1 files changed, 5 insertions, 0 deletions
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>())