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 {