From 5a7157d319477830426797532e02ac39d3b859f4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 11:29:03 +0200 Subject: Merging upstream version 4:24.2.1. Signed-off-by: Daniel Baumann --- sw/source/core/unocore/unostyle.cxx | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'sw/source/core/unocore/unostyle.cxx') diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 94219281b5..665c1d2c6a 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -1669,27 +1669,37 @@ void SwXStyle::SetPropertyValue(const SfxItemPropertyMapE template<> void SwXStyle::SetPropertyValue(const SfxItemPropertyMapEntry& rEntry, const SfxItemPropertySet& rPropSet, const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase) { - if(!rValue.has()) + if (!rValue.has() && !rValue.has()) throw lang::IllegalArgumentException(); SfxPrinter* pPrinter = m_pDoc->getIDocumentDeviceAccess().getPrinter(true); - OUString sValue(rValue.get()); using printeridx_t = decltype(pPrinter->GetPaperBinCount()); printeridx_t nBin = std::numeric_limits::max(); - if(sValue == "[From printer settings]") - nBin = std::numeric_limits::max()-1; - else if(pPrinter) + if(rValue.has()) { - for(sal_uInt16 i=0, nEnd = pPrinter->GetPaperBinCount(); i < nEnd; ++i) + OUString sValue(rValue.get()); + if(sValue == "[From printer settings]") + nBin = std::numeric_limits::max()-1; + else if(pPrinter) { - if (sValue == pPrinter->GetPaperBinName(i)) + for(printeridx_t i=0, nEnd = pPrinter->GetPaperBinCount(); i < nEnd; ++i) { - nBin = i; - break; + if (sValue == pPrinter->GetPaperBinName(i)) + { + nBin = i; + break; + } } } } + else if (rValue.has() && pPrinter) + { + sal_Int32 nValue (rValue.get()); + nBin = pPrinter->GetPaperBinBySourceIndex(nValue); + } + if(nBin == std::numeric_limits::max()) throw lang::IllegalArgumentException(); + SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet(); SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID); aSet.SetParent(&rStyleSet); -- cgit v1.2.3