diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-06-14 15:52:08 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-06-14 20:58:28 +0200 |
commit | 64da52a94738aa73cbcf2411952914d4e8e0f9ef (patch) | |
tree | fdc5f81628c55458d28c2cd620e0a6b2a5c189a4 /chart2 | |
parent | 4890e08519103b0252767e0dd8b810894293f815 (diff) |
crashtesting: avoid eventual assert when double inf is cast to sal_Int32
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 <caolan.mcnamara@collabora.com>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
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<VTitle> lcl_createTitle( TitleHelper::eTitleType eType aNewPosition = RelativePositionHelper::getCenterOfAnchoredObject( awt::Point(static_cast<sal_Int32>(fX),static_cast<sal_Int32>(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 { |