From 64da52a94738aa73cbcf2411952914d4e8e0f9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Fri, 14 Jun 2024 15:52:08 +0100 Subject: [PATCH] crashtesting: avoid eventual assert when double inf is cast to sal_Int32 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit seen on loading forum-mso-en4-604220.xlsx and asserting on export to ods lets assume that an infinite Y position equates to ALIGN_BOTTOM which is the case seen in this example, and assume the same for infinite X and ALIGN_RIGHT if it arises Change-Id: I009a9cd94b7bd9ed66e18f8dbbb9eb91d37eaa65 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168892 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- chart2/source/view/main/ChartView.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 5d2c2bf6cc90..50264035e316 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1119,6 +1119,20 @@ std::shared_ptr lcl_createTitle( TitleHelper::eTitleType eType aNewPosition = RelativePositionHelper::getCenterOfAnchoredObject( awt::Point(static_cast(fX),static_cast(fY)) , aTitleUnrotatedSize, aRelativePosition.Anchor, fAnglePi ); + + const bool bInfiniteY = std::isinf(aRelativePosition.Secondary); + if (bInfiniteY) + { + SAL_WARN("chart2", "infinite aRelativePosition.Secondary position, using ALIGN_BOTTOM"); + aNewPosition.Y = rRemainingSpace.Y + rRemainingSpace.Height - aTitleSize.Height/2 - nYDistance; + } + + const bool bInfiniteX = std::isinf(aRelativePosition.Primary); + if (bInfiniteX) + { + SAL_WARN("chart2", "infinite aRelativePosition.Primary position, using ALIGN_RIGHT"); + aNewPosition.X = rRemainingSpace.X + rRemainingSpace.Width - aTitleSize.Width/2 - nXDistance; + } } else //auto position {