starmath/qa/cppunit/test_node.cxx | 8 ++++++-- starmath/source/node.cxx | 5 ++++- starmath/source/rect.cxx | 2 ++ vcl/source/animate/Animation.cxx | 25 +++++++++---------------- 4 files changed, 21 insertions(+), 19 deletions(-)
New commits: commit 13894996601daf10d133f4a71eb0b26794d782bc Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Sat May 4 21:46:31 2019 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun May 5 08:05:16 2019 +0200 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: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/starmath/qa/cppunit/test_node.cxx b/starmath/qa/cppunit/test_node.cxx index a4c7df456399..7ee441ec1941 100644 --- a/starmath/qa/cppunit/test_node.cxx +++ b/starmath/qa/cppunit/test_node.cxx @@ -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() diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx index 97d97582826d..fcdcbbdb2e07 100644 --- a/starmath/source/node.cxx +++ b/starmath/source/node.cxx @@ -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 ); diff --git a/starmath/source/rect.cxx b/starmath/source/rect.cxx index ab32022aac2a..113cf4998a65 100644 --- a/starmath/source/rect.cxx +++ b/starmath/source/rect.cxx @@ -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); commit d83b1383ffbe98502c196cccae4bcb2eb3978f6a Author: Adrien Ollier <adr.oll...@hotmail.fr> AuthorDate: Sat May 4 07:20:36 2019 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun May 5 08:05:08 2019 +0200 using an algorithm of the STL makes the function shorter Change-Id: I22118d9b86e5497cb9b566efe9151f2da646cb16 Signed-off-by: Adrien Ollier <adr.oll...@hotmail.fr> Reviewed-on: https://gerrit.libreoffice.org/71806 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx index 1382178aa6a0..3aeeadc649a8 100644 --- a/vcl/source/animate/Animation.cxx +++ b/vcl/source/animate/Animation.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <algorithm> #include <sal/config.h> #include <tools/stream.hxx> @@ -107,28 +108,20 @@ void Animation::Clear() bool Animation::IsTransparent() const { - tools::Rectangle aRect(Point(), maGlobalSize); - bool bRet = false; + tools::Rectangle aRect{ Point(), maGlobalSize }; // If some small bitmap needs to be replaced by the background, // we need to be transparent, in order to be displayed correctly // as the application (?) does not invalidate on non-transparent // graphics due to performance reasons. - for (auto const& pAnimationBitmap : maList) - { - if (Disposal::Back == pAnimationBitmap->meDisposal - && tools::Rectangle(pAnimationBitmap->maPositionPixel, pAnimationBitmap->maSizePixel) - != aRect) - { - bRet = true; - break; - } - } - if (!bRet) - bRet = maBitmapEx.IsTransparent(); - - return bRet; + return std::any_of(maList.begin(), maList.end(), + [&aRect](const std::unique_ptr<AnimationBitmap>& pAnim) -> bool { + return pAnim->meDisposal == Disposal::Back + && tools::Rectangle{ pAnim->maPositionPixel, pAnim->maSizePixel } + != aRect; + }) + || maBitmapEx.IsTransparent(); } sal_uLong Animation::GetSizeBytes() const _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits