sw/source/uibase/uno/unotxdoc.cxx | 41 ++++++++++++++------------------------ 1 file changed, 16 insertions(+), 25 deletions(-)
New commits: commit 76a3c01c3abd01f404f8f5ac572e52b2f8a2927e Author: Julien Nabet <serval2...@yahoo.fr> AuthorDate: Mon May 8 17:16:22 2023 +0200 Commit: Julien Nabet <serval2...@yahoo.fr> CommitDate: Mon May 8 20:47:27 2023 +0200 Simplify initialization in sw/unotxdoc + flatten a bit static_cast<sal_Int32> could be removed since: - GetLeftSpace, GetRightSpace, etc. return a sal_Int32 - convertTwipToMm100 is a template method defined like this: 93 template <typename N> constexpr auto convertTwipToMm100(N n) 94 { 95 return o3tl::convert(n, o3tl::Length::twip, o3tl::Length::mm100); 96 } (see https://opengrok.libreoffice.org/xref/core/include/tools/UnitConversion.hxx?r=bfed5882&mo=2801&fi=93#93) so will return sal_Int32 if its argument is a sal_Int32 "comphelper::makePropertyValue" would have simplified even more but the handle here is -1 not 0. Now, I don't know what would be the impact. Change-Id: Ie39e6c5984930e53dff7de3584cb80f421f9288c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151540 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2...@yahoo.fr> diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index b57cea597759..8fff673fdda0 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -931,36 +931,27 @@ Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface > Sequence< beans::PropertyValue > SwXTextDocument::getPagePrintSettings() { SolarMutexGuard aGuard; - Sequence< beans::PropertyValue > aSeq(9); if(!IsValid()) throw DisposedException("", static_cast< XTextDocument* >(this)); - beans::PropertyValue* pArray = aSeq.getArray(); SwPagePreviewPrtData aData; const SwPagePreviewPrtData* pData = m_pDocShell->GetDoc()->GetPreviewPrtData(); - if(pData) - aData = *pData; - Any aVal; - aVal <<= aData.GetRow(); - pArray[0] = beans::PropertyValue("PageRows", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= aData.GetCol(); - pArray[1] = beans::PropertyValue("PageColumns", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetLeftSpace())); - pArray[2] = beans::PropertyValue("LeftMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetRightSpace())); - pArray[3] = beans::PropertyValue("RightMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetTopSpace())); - pArray[4] = beans::PropertyValue("TopMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetBottomSpace())); - pArray[5] = beans::PropertyValue("BottomMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetHorzSpace())); - pArray[6] = beans::PropertyValue("HoriMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetVertSpace())); - pArray[7] = beans::PropertyValue("VertMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= aData.GetLandscape(); - pArray[8] = beans::PropertyValue("IsLandscape", -1, aVal, PropertyState_DIRECT_VALUE); - - return aSeq; + if (!pData) + return {}; + + aData = *pData; + return + { + beans::PropertyValue("PageRows", -1, Any(aData.GetRow()), PropertyState_DIRECT_VALUE), + beans::PropertyValue("PageColumns", -1, Any(aData.GetCol()), PropertyState_DIRECT_VALUE), + beans::PropertyValue("LeftMargin", -1, Any(convertTwipToMm100(aData.GetLeftSpace())), PropertyState_DIRECT_VALUE), + beans::PropertyValue("RightMargin", -1, Any(convertTwipToMm100(aData.GetRightSpace())), PropertyState_DIRECT_VALUE), + beans::PropertyValue("TopMargin", -1, Any(convertTwipToMm100(aData.GetTopSpace())), PropertyState_DIRECT_VALUE), + beans::PropertyValue("BottomMargin", -1, Any(convertTwipToMm100(aData.GetBottomSpace())), PropertyState_DIRECT_VALUE), + beans::PropertyValue("HoriMargin", -1, Any(convertTwipToMm100(aData.GetHorzSpace())), PropertyState_DIRECT_VALUE), + beans::PropertyValue("VertMargin", -1, Any(convertTwipToMm100(aData.GetVertSpace())), PropertyState_DIRECT_VALUE), + beans::PropertyValue("IsLandscape", -1, Any(aData.GetLandscape()), PropertyState_DIRECT_VALUE) + }; } static sal_uInt32 lcl_Any_To_ULONG(const Any& rValue, bool& bException)