Kaydet (Commit) 13894996 authored tarafından Noel Grandin's avatar Noel Grandin

handle empty Rectangle better in starmath

which required fixing a unit test to call Prepare, otherwise the nodes
are not ready for layout

Change-Id: I763c1b05d4dfafa73ebaee55d080876848de94f6
Reviewed-on: https://gerrit.libreoffice.org/71800
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst d83b1383
......@@ -72,17 +72,21 @@ void NodeTest::testTdf47813()
#undef MATRIX
ScopedVclPtrInstance<VirtualDevice> pOutputDevice;
SmFormat aFmt;
pNodeA->Prepare(aFmt, *mxDocShell, 0);
pNodeA->Arrange(*pOutputDevice, aFmt);
pNodeC->Prepare(aFmt, *mxDocShell, 0);
pNodeC->Arrange(*pOutputDevice, aFmt);
pNodeL->Prepare(aFmt, *mxDocShell, 0);
pNodeL->Arrange(*pOutputDevice, aFmt);
pNodeR->Prepare(aFmt, *mxDocShell, 0);
pNodeR->Arrange(*pOutputDevice, aFmt);
long nWidthA = pNodeA->GetRect().GetWidth();
long nWidthC = pNodeC->GetRect().GetWidth();
long nWidthL = pNodeL->GetRect().GetWidth();
long nWidthR = pNodeR->GetRect().GetWidth();
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, nWidthC/static_cast<double>(nWidthA), 0.01);
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, nWidthL/static_cast<double>(nWidthA), 0.01);
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, nWidthR/static_cast<double>(nWidthA), 0.01);
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, nWidthL/static_cast<double>(nWidthA), 0.02);
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, nWidthR/static_cast<double>(nWidthA), 0.02);
}
void NodeTest::testTdf52225()
......
......@@ -2064,6 +2064,7 @@ void SmTextNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, i
SetRectHorAlign( RectHorAlign::Left );
maText = GetToken().aText;
assert(!maText.isEmpty());
GetFont() = rFormat.GetFont(GetFontDesc());
if (IsItalic( GetFont() ))
......@@ -2402,7 +2403,9 @@ void SmMathSymbolNode::AdaptToY(OutputDevice &rDev, sal_uLong nHeight)
// get denominator of error factor for height
long nTmpBorderWidth = GetFont().GetBorderWidth();
long nDenom = SmRect(aTmpDev, nullptr, GetText(), nTmpBorderWidth).GetHeight();
long nDenom = 0;
if (!GetText().isEmpty())
nDenom = SmRect(aTmpDev, nullptr, GetText(), nTmpBorderWidth).GetHeight();
// scale fontwidth with this error factor
aFntSize.setHeight( aFntSize.Height() * nHeight );
......
......@@ -38,6 +38,7 @@ bool SmGetGlyphBoundRect(const vcl::RenderContext &rDev,
// basically the same as 'GetTextBoundRect' (in class 'OutputDevice')
// but with a string as argument.
{
assert(!rText.isEmpty());
// handle special case first
if (rText.isEmpty())
{
......@@ -183,6 +184,7 @@ SmRect::SmRect(const OutputDevice &rDev, const SmFormat *pFormat,
: aTopLeft(0, 0)
, aSize(rDev.GetTextWidth(rText), rDev.GetTextHeight())
{
assert(!rText.isEmpty());
const FontMetric aFM (rDev.GetFontMetric());
bool bIsMath = aFM.GetFamilyName().equalsIgnoreAsciiCase( FONTNAME_MATH );
bool bAllowSmaller = bIsMath && !SmIsMathAlpha(rText);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment