sw/source/core/unocore/unostyle.cxx | 5 +++++ sw/source/writerfilter/dmapper/PropertyMap.cxx | 10 ---------- 2 files changed, 5 insertions(+), 10 deletions(-)
New commits: commit 662b5eaf86b5fc15d67ef4f0cf43fd31630ac77e Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Wed Dec 18 17:54:43 2024 -0500 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Dec 19 13:48:44 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(). This replaces my earlier, very focused patch for writerfilter. I'm afraid that this Exception could evidence itself in many different areas, so this more generic fix ought to resolve any problems triggered by SAL_DISABLE_PRINTERLIST. 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> diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 618b0fd49632..96d3056f83af 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>()) diff --git a/sw/source/writerfilter/dmapper/PropertyMap.cxx b/sw/source/writerfilter/dmapper/PropertyMap.cxx index 950c62d61029..ce373b092890 100644 --- a/sw/source/writerfilter/dmapper/PropertyMap.cxx +++ b/sw/source/writerfilter/dmapper/PropertyMap.cxx @@ -1507,16 +1507,6 @@ void SectionPropertyMap::CreateEvenOddPageStyleCopy(DomainMapper_Impl& rDM_Impl, else if (rProperty.Name == u"RightMargin"_ustr) sSetName = u"LeftMargin"_ustr; } - - if (rProperty.Name == u"PrinterPaperTray"_ustr - || rProperty.Name == u"PrinterPaperTrayIndex"_ustr) - { - const uno::Any aTray = pageProperties->getPropertyValue(rProperty.Name); - // exception if tray SET with an empty value (even though it may be empty) - if (aTray.has<OUString>() && aTray.get<OUString>().isEmpty()) - continue; - } - evenOddStyle->setPropertyValue( sSetName, pageProperties->getPropertyValue(rProperty.Name));