basegfx/source/curve/b2dcubicbezier.cxx | 19 +---------- basegfx/source/numeric/ftools.cxx | 4 -- basegfx/source/polygon/b2dpolygontools.cxx | 8 ++-- basegfx/source/polygon/b3dpolygontools.cxx | 2 - chart2/qa/extras/chart2import.cxx | 4 +- drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx | 2 - drawinglayer/source/primitive2d/polygonprimitive2d.cxx | 6 +-- drawinglayer/source/primitive2d/svggradientprimitive2d.cxx | 2 - drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx | 2 - drawinglayer/source/processor2d/cairopixelprocessor2d.cxx | 2 - drawinglayer/source/processor3d/shadow3dextractor.cxx | 2 - drawinglayer/source/processor3d/zbufferprocessor3d.cxx | 4 +- drawinglayer/source/tools/converters.cxx | 2 - drawinglayer/source/tools/wmfemfhelper.cxx | 2 - oox/qa/unit/shape.cxx | 14 ++++---- sc/qa/unit/subsequent_filters_test3.cxx | 4 +- sd/qa/unit/export-tests-ooxml1.cxx | 4 +- sd/qa/unit/export-tests-ooxml2.cxx | 2 - sd/qa/unit/export-tests-ooxml4.cxx | 4 +- sd/qa/unit/misc-tests.cxx | 2 - sd/qa/unit/uiimpress.cxx | 2 - svgio/source/svgreader/svgimagenode.cxx | 4 +- svgio/source/svgreader/svgstyleattributes.cxx | 6 +-- svgio/source/svgreader/svgsvgnode.cxx | 6 +-- svgio/source/svgreader/svgtextpathnode.cxx | 2 - svx/source/customshapes/EnhancedCustomShape3d.cxx | 2 - svx/source/svdraw/svdotextdecomposition.cxx | 7 +--- sw/qa/extras/odfexport/odfexport.cxx | 4 +- sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 2 - sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 4 +- vcl/headless/CairoCommon.cxx | 4 +- 31 files changed, 58 insertions(+), 76 deletions(-)
New commits: commit 8bd57009d38f7551a77566a0e782a7b371aece23 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Fri Aug 2 11:33:14 2024 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Fri Aug 2 11:31:00 2024 +0200 Fix wrong / misleading uses of fTools::(more|less|equal) with literal 0 These will never compare with tolerance (the zero is a special case in rtl_math_approxEqual used internally), so the calls like those don't do what they appear to do in these cases. Change-Id: I495ac92b7f45637e118e4fdc04bb6fad6fff31ab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171391 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx index 788c63b828c1..7485ccc54a9b 100644 --- a/basegfx/source/curve/b2dcubicbezier.cxx +++ b/basegfx/source/curve/b2dcubicbezier.cxx @@ -790,23 +790,8 @@ namespace basegfx { B2DCubicBezier aRetval; - if(fTools::more(fStart, 1.0)) - { - fStart = 1.0; - } - else if(fTools::less(fStart, 0.0)) - { - fStart = 0.0; - } - - if(fTools::more(fEnd, 1.0)) - { - fEnd = 1.0; - } - else if(fTools::less(fEnd, 0.0)) - { - fEnd = 0.0; - } + fStart = std::clamp(fStart, 0.0, 1.0); + fEnd = std::clamp(fEnd, 0.0, 1.0); if(fEnd <= fStart) { diff --git a/basegfx/source/numeric/ftools.cxx b/basegfx/source/numeric/ftools.cxx index 4a01a4c0eca0..d603d4e6df45 100644 --- a/basegfx/source/numeric/ftools.cxx +++ b/basegfx/source/numeric/ftools.cxx @@ -105,9 +105,7 @@ namespace basegfx return 0.0; } - const bool bNegative(fTools::less(v, 0.0)); - - if(bNegative) + if(v < 0.0) { if(fTools::moreOrEqual(v, -fRange)) { diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index d63a33c0a9b0..564a24e99c8b 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -540,7 +540,7 @@ namespace basegfx::utils fLength = getLength(rCandidate); } - if(fTools::less(fDistance, 0.0)) + if (fDistance < 0.0) { // handle fDistance < 0.0 if(rCandidate.isClosed()) @@ -681,7 +681,7 @@ namespace basegfx::utils } // test and correct fFrom - if(fTools::less(fFrom, 0.0)) + if (fFrom < 0.0) { fFrom = 0.0; } @@ -1820,7 +1820,7 @@ namespace basegfx::utils // truncate fStart, fEnd to a range of [0.0 .. 2PI[ where 2PI // falls back to 0.0 to ensure a unique definition - if(fTools::less(fStart, 0.0)) + if(fStart < 0.0) { fStart = 0.0; } @@ -1830,7 +1830,7 @@ namespace basegfx::utils fStart = 0.0; } - if(fTools::less(fEnd, 0.0)) + if(fEnd < 0.0) { fEnd = 0.0; } diff --git a/basegfx/source/polygon/b3dpolygontools.cxx b/basegfx/source/polygon/b3dpolygontools.cxx index 14e5abf46b64..916ff6f47f3a 100644 --- a/basegfx/source/polygon/b3dpolygontools.cxx +++ b/basegfx/source/polygon/b3dpolygontools.cxx @@ -701,7 +701,7 @@ namespace basegfx::utils } } - if(fTools::more(fParamTestOnCurr, 0.0) && fTools::less(fParamTestOnCurr, 1.0)) + if(fParamTestOnCurr > 0.0 && fTools::less(fParamTestOnCurr, 1.0)) { return true; } diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 2f8777f66a29..3cef1b785fae 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -639,7 +639,7 @@ CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testBnc889755) const basegfx::BColorStops aColorStops = model::gradient::getColorStopsFromUno(aTransparence.ColorStops); CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(Color(0x404040), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 0.070000000000000007)); CPPUNIT_ASSERT_EQUAL(Color(0x404040), Color(aColorStops[1].getStopColor())); @@ -683,7 +683,7 @@ CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTransparencyGradientValue) // MCGR: Use the whole completely imported transparency gradient to check for correctness CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(Color(0x4d4d4d), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(Color(0x333333), Color(aColorStops[1].getStopColor())); diff --git a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx index 09573c6772a6..7ff6b1c32c71 100644 --- a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx @@ -662,7 +662,7 @@ namespace drawinglayer::primitive2d else { // dependent of transparency used create the needed bitmap primitive - if(basegfx::fTools::equal(fTransparency, 0.0)) + if (basegfx::fTools::equalZero(fTransparency)) { rContainer.append( new BitmapPrimitive2D( diff --git a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx index ab6833a44ffa..ab36bc6b4c18 100644 --- a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx @@ -46,7 +46,7 @@ void implGrowHairline(basegfx::B2DRange& rRange, rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)); const double fDiscreteHalfLineWidth(aDiscreteSize.getLength() * 0.5); - if (basegfx::fTools::more(fDiscreteHalfLineWidth, 0.0)) + if (fDiscreteHalfLineWidth > 0.0) { rRange.grow(fDiscreteHalfLineWidth); } @@ -282,7 +282,7 @@ PolygonMarkerPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewIn rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)); const double fDiscreteHalfLineWidth(aDiscreteSize.getLength() * 0.5); - if (basegfx::fTools::more(fDiscreteHalfLineWidth, 0.0)) + if (fDiscreteHalfLineWidth > 0.0) { aRetval.grow(fDiscreteHalfLineWidth); } @@ -583,7 +583,7 @@ PolygonStrokePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewIn rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)); const double fDiscreteHalfLineWidth(aDiscreteSize.getLength() * 0.5); - if (basegfx::fTools::more(fDiscreteHalfLineWidth, 0.0)) + if (fDiscreteHalfLineWidth > 0.0) { aHairlineRange.grow(fDiscreteHalfLineWidth); } diff --git a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx index 3c6e7ab6b494..69881695a22b 100644 --- a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx @@ -79,7 +79,7 @@ namespace drawinglayer::primitive2d const SvgGradientEntry& rSingleEntry(rEntries[nCount - 1]); const double fOpacity(rSingleEntry.getOpacity()); - if (basegfx::fTools::lessOrEqual(fOpacity, 0.0)) + if (fOpacity <= 0.0 || basegfx::fTools::equalZero(fOpacity)) { // completely opaque, done return nullptr; diff --git a/drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx b/drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx index a7015ff8e578..2afaa977c3c2 100644 --- a/drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx +++ b/drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx @@ -71,7 +71,7 @@ namespace { rOuterPolyPolygon = rPolygon; - if(!basegfx::fTools::more(fOffset, 0.0)) + if (fOffset <= 0.0 || basegfx::fTools::equalZero(fOffset)) return; if(bCharacterMode) diff --git a/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx b/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx index 21ee580c3cf4..f6483e4a795e 100644 --- a/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx @@ -2035,7 +2035,7 @@ bool CairoPixelProcessor2D::processFillGradientPrimitive2D_isCompletelyBordered( // check if completely 'bordered out'. This can be the case for all // types of gradients - if (basegfx::fTools::less(fBorder, 1.0) && basegfx::fTools::moreOrEqual(fBorder, 0.0)) + if (basegfx::fTools::less(fBorder, 1.0) && fBorder >= 0.0) { // no, we have visible content besides border return false; diff --git a/drawinglayer/source/processor3d/shadow3dextractor.cxx b/drawinglayer/source/processor3d/shadow3dextractor.cxx index c4c0e0ba1249..d26d3219dfca 100644 --- a/drawinglayer/source/processor3d/shadow3dextractor.cxx +++ b/drawinglayer/source/processor3d/shadow3dextractor.cxx @@ -224,7 +224,7 @@ namespace drawinglayer::processor3d mfLightPlaneScalar = maLightNormal.scalar(maShadowPlaneNormal); // use only when scalar is > 0.0, so the light is in front of the object - if(!basegfx::fTools::more(mfLightPlaneScalar, 0.0)) + if(mfLightPlaneScalar <= 0.0 || basegfx::fTools::equalZero(mfLightPlaneScalar)) return; // prepare buffered WorldToEye and EyeToView diff --git a/drawinglayer/source/processor3d/zbufferprocessor3d.cxx b/drawinglayer/source/processor3d/zbufferprocessor3d.cxx index 7f8f24f3b872..82c1129fa585 100644 --- a/drawinglayer/source/processor3d/zbufferprocessor3d.cxx +++ b/drawinglayer/source/processor3d/zbufferprocessor3d.cxx @@ -119,14 +119,14 @@ private: mrProcessor.getGeoTexSvx()->modifyBColor(aTexCoor, rColor, fOpacity); } - if(basegfx::fTools::more(fOpacity, 0.0) && mrProcessor.getTransparenceGeoTexSvx()) + if (fOpacity > 0.0 && !basegfx::fTools::equalZero(fOpacity) && mrProcessor.getTransparenceGeoTexSvx()) { // calc opacity. Object has a 2nd texture, a transparence texture mrProcessor.getTransparenceGeoTexSvx()->modifyOpacity(aTexCoor, fOpacity); } } - if(basegfx::fTools::more(fOpacity, 0.0)) + if (fOpacity > 0.0 && !basegfx::fTools::equalZero(fOpacity)) { if(mrProcessor.getGeoTexSvx()) { diff --git a/drawinglayer/source/tools/converters.cxx b/drawinglayer/source/tools/converters.cxx index cf339f8aaa20..049c2db22aa4 100644 --- a/drawinglayer/source/tools/converters.cxx +++ b/drawinglayer/source/tools/converters.cxx @@ -322,7 +322,7 @@ BitmapEx convertPrimitive2DContainerToBitmapEx(primitive2d::Primitive2DContainer const double fWidth(aRange.getWidth()); const double fHeight(aRange.getHeight()); - if (!(basegfx::fTools::more(fWidth, 0.0) && basegfx::fTools::more(fHeight, 0.0))) + if (fWidth <= 0.0 || fHeight <= 0.0 || basegfx::fTools::equalZero(fWidth) || basegfx::fTools::equalZero(fHeight)) return BitmapEx(); if (0 == DPI_X) diff --git a/drawinglayer/source/tools/wmfemfhelper.cxx b/drawinglayer/source/tools/wmfemfhelper.cxx index 13634c9ad1a5..e5c631e60d7f 100644 --- a/drawinglayer/source/tools/wmfemfhelper.cxx +++ b/drawinglayer/source/tools/wmfemfhelper.cxx @@ -1179,7 +1179,7 @@ namespace wmfemfhelper fTextWidth = rDXArray.back(); } - if(basegfx::fTools::more(fTextWidth, 0.0)) + if (fTextWidth > 0.0 && !basegfx::fTools::equalZero(fTextWidth)) { // build text range const basegfx::B2DRange aTextRange( diff --git a/oox/qa/unit/shape.cxx b/oox/qa/unit/shape.cxx index 28266b8783c6..929fecc64a7c 100644 --- a/oox/qa/unit/shape.cxx +++ b/oox/qa/unit/shape.cxx @@ -590,7 +590,7 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWriterFontwork3) aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops); CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE, Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(Color(0xf79646), Color(aColorStops[1].getStopColor())); @@ -638,7 +638,7 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWriterFontwork3) aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops); CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(Color(0xf79646), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE, Color(aColorStops[1].getStopColor())); @@ -762,7 +762,7 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient) aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops); CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(Color(0xffc000), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(Color(0xc00000), Color(aColorStops[1].getStopColor())); @@ -794,7 +794,7 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient) aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops); CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(Color(0x0083e0), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(Color(0xe6e600), Color(aColorStops[1].getStopColor())); @@ -809,7 +809,7 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient) // Transparency is encoded in gray color. CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(COL_GRAY7, Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(Color(0x4d4d4d), Color(aColorStops[1].getStopColor())); @@ -846,7 +846,7 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient) aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops); CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(Color(0x4472c4), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(Color(0x4472c4), Color(aColorStops[1].getStopColor())); @@ -861,7 +861,7 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient) // Transparency is encoded in gray color. CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(COL_WHITE, Color(aColorStops[1].getStopColor())); diff --git a/sc/qa/unit/subsequent_filters_test3.cxx b/sc/qa/unit/subsequent_filters_test3.cxx index 5d91a95b65ac..e2808a623070 100644 --- a/sc/qa/unit/subsequent_filters_test3.cxx +++ b/sc/qa/unit/subsequent_filters_test3.cxx @@ -1681,7 +1681,7 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testTdf129789) const basegfx::BColorStops& rColorStops(rGradientItem.GetGradientValue().GetColorStops()); CPPUNIT_ASSERT_EQUAL(size_t(2), rColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(rColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, rColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(Color(0xdde8cb), Color(rColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(rColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(Color(0xffd7d7), Color(rColorStops[1].getStopColor())); @@ -1695,7 +1695,7 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testTdf129789) const basegfx::BColorStops& rColorStops2(rGradientItem2.GetGradientValue().GetColorStops()); CPPUNIT_ASSERT_EQUAL(size_t(2), rColorStops2.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(rColorStops2[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, rColorStops2[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(Color(0xdde8cb), Color(rColorStops2[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(rColorStops2[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(Color(0xffd7d7), Color(rColorStops2[1].getStopColor())); diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx index 231d3175d677..7634e6fe9078 100644 --- a/sd/qa/unit/export-tests-ooxml1.cxx +++ b/sd/qa/unit/export-tests-ooxml1.cxx @@ -1262,7 +1262,7 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest1, testTdf94238) // 'Expected: 0, Actual : 10592673', i.e. the start color of the gradient // was incorrect. CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 0.39000000000000001)); CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(aColorStops[1].getStopColor())); @@ -1525,7 +1525,7 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest1, testTdf128345GradientAxial) = model::gradient::getColorStopsFromUno(aTransparenceGradient.ColorStops); CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(COL_WHITE, Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 0.5)); CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(aColorStops[1].getStopColor())); diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index de161cbd877b..24295879c087 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -1039,7 +1039,7 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf105739) = model::gradient::getColorStopsFromUno(aFillGradient.ColorStops); CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(Color(0x00b050), Color(aColorStops[1].getStopColor())); diff --git a/sd/qa/unit/export-tests-ooxml4.cxx b/sd/qa/unit/export-tests-ooxml4.cxx index 0e11eb581bf0..054e2232107a 100644 --- a/sd/qa/unit/export-tests-ooxml4.cxx +++ b/sd/qa/unit/export-tests-ooxml4.cxx @@ -340,7 +340,7 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testTdf127372) = model::gradient::getColorStopsFromUno(aTransparenceGradient.ColorStops); CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(aColorStops[1].getStopColor())); @@ -373,7 +373,7 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testTdf127379) = model::gradient::getColorStopsFromUno(aGradient.ColorStops); CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(Color(0x2a6099), Color(aColorStops[1].getStopColor())); diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index 9b7aed2dfd30..7363cd09df2d 100644 --- a/sd/qa/unit/misc-tests.cxx +++ b/sd/qa/unit/misc-tests.cxx @@ -295,7 +295,7 @@ void SdMiscTest::testFillGradient() = model::gradient::getColorStopsFromUno(aGradient2.ColorStops); CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(COL_LIGHTGREEN, Color(aColorStops[1].getStopColor())); diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index f3d24b6f1c59..d4f1effbab8b 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -839,7 +839,7 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testPageFillGradient) const basegfx::BColorStops& rColorStops(aGradient.GetColorStops()); CPPUNIT_ASSERT_EQUAL(size_t(2), rColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(rColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, rColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, Color(rColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(rColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE, Color(rColorStops[1].getStopColor())); diff --git a/svgio/source/svgreader/svgimagenode.cxx b/svgio/source/svgreader/svgimagenode.cxx index 7e068136287b..789186d9f4b3 100644 --- a/svgio/source/svgreader/svgimagenode.cxx +++ b/svgio/source/svgreader/svgimagenode.cxx @@ -271,12 +271,12 @@ namespace svgio::svgreader // calculate centered unit size const double fAspectRatio = static_cast<double>(aBitmapEx.GetSizePixel().Width()) / static_cast<double>(aBitmapEx.GetSizePixel().Height()); - if(basegfx::fTools::equal(fAspectRatio, 0.0)) + if (basegfx::fTools::equalZero(fAspectRatio)) { // use unit range aViewBox = basegfx::B2DRange(0.0, 0.0, 1.0, 1.0); } - else if(basegfx::fTools::more(fAspectRatio, 0.0)) + else if (fAspectRatio > 0.0) { // width bigger height const double fHalfHeight((1.0 / fAspectRatio) * 0.5); diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx index 95229ddd93bf..87b162ad906d 100644 --- a/svgio/source/svgreader/svgstyleattributes.cxx +++ b/svgio/source/svgreader/svgstyleattributes.cxx @@ -610,7 +610,7 @@ namespace svgio::svgreader double fFillOpacity(getFillOpacity().solve(mrOwner)); - if(!basegfx::fTools::more(fFillOpacity, 0.0)) + if (fFillOpacity <= 0.0 || basegfx::fTools::equalZero(fFillOpacity)) return; drawinglayer::primitive2d::Primitive2DContainer aNewFill; @@ -680,13 +680,13 @@ namespace svgio::svgreader drawinglayer::primitive2d::Primitive2DContainer aNewStroke; const double fStrokeOpacity(getStrokeOpacity().solve(mrOwner)); - if(!basegfx::fTools::more(fStrokeOpacity, 0.0)) + if (fStrokeOpacity <= 0.0 || basegfx::fTools::equalZero(fStrokeOpacity)) return; // get stroke width; SVG does not use 0.0 == hairline, so 0.0 is no line at all const double fStrokeWidth(getStrokeWidth().isSet() ? getStrokeWidth().solve(mrOwner) : 1.0); - if (!basegfx::fTools::more(fStrokeWidth, 0.0)) + if (fStrokeWidth <= 0.0 || basegfx::fTools::equalZero(fStrokeWidth)) return; if (fStrokeWidth > std::numeric_limits<sal_Int32>::max()) diff --git a/svgio/source/svgreader/svgsvgnode.cxx b/svgio/source/svgreader/svgsvgnode.cxx index eef8ba7ead32..e1c94e7b556a 100644 --- a/svgio/source/svgreader/svgsvgnode.cxx +++ b/svgio/source/svgreader/svgsvgnode.cxx @@ -408,7 +408,7 @@ namespace svgio::svgreader { // SVG 1.1 defines in section 7.7 that a negative value for width or height // in viewBox is an error and that 0.0 disables rendering - if(basegfx::fTools::more(getViewBox()->getWidth(),0.0) && basegfx::fTools::more(getViewBox()->getHeight(),0.0)) + if (getViewBox()->getWidth() > 0.0 && getViewBox()->getHeight() > 0.0 && !basegfx::fTools::equalZero(getViewBox()->getWidth()) && !basegfx::fTools::equalZero(getViewBox()->getHeight())) { // create target range homing x,y, width and height as calculated above const basegfx::B2DRange aTarget(fX, fY, fX + fW, fY + fH); @@ -454,7 +454,7 @@ namespace svgio::svgreader else // no viewBox attribute { // Svg defines that a negative value is an error and that 0.0 disables rendering - if(basegfx::fTools::more(fW, 0.0) && basegfx::fTools::more(fH, 0.0)) + if (fW > 0.0 && fH > 0.0 && !basegfx::fTools::equalZero(fW) && !basegfx::fTools::equalZero(fH)) { if(!basegfx::fTools::equalZero(fX) || !basegfx::fTools::equalZero(fY)) { @@ -495,7 +495,7 @@ namespace svgio::svgreader // in viewBox is an error and that 0.0 disables rendering const double fViewBoxWidth = pBox->getWidth(); const double fViewBoxHeight = pBox->getHeight(); - if(basegfx::fTools::more(fViewBoxWidth,0.0) && basegfx::fTools::more(fViewBoxHeight,0.0)) + if (fViewBoxWidth > 0.0 && fViewBoxHeight > 0.0 && !basegfx::fTools::equalZero(fViewBoxWidth) && !basegfx::fTools::equalZero(fViewBoxHeight)) { // The intrinsic aspect ratio of the svg element is given by absolute values of svg width and svg height // or by the width and height of the viewBox, if svg width or svg height is relative. diff --git a/svgio/source/svgreader/svgtextpathnode.cxx b/svgio/source/svgreader/svgtextpathnode.cxx index ee197f9d68fd..5a36e7fcfa7f 100644 --- a/svgio/source/svgreader/svgtextpathnode.cxx +++ b/svgio/source/svgreader/svgtextpathnode.cxx @@ -147,7 +147,7 @@ namespace svgio::svgreader nIndex, nLength)); - if(basegfx::fTools::more(fSnippetWidth, 0.0)) + if (fSnippetWidth > 0.0 && !basegfx::fTools::equalZero(fSnippetWidth)) { const OUString aText(getSource().getText()); const std::u16string_view aTrimmedChars(o3tl::trim(aText.subView(nIndex, nLength))); diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx index 56dd2a18337a..cd2d1c751eba 100644 --- a/svx/source/customshapes/EnhancedCustomShape3d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx @@ -1034,7 +1034,7 @@ rtl::Reference<SdrObject> EnhancedCustomShape3d::Create3DObject( const Color& rMatColor = pNext->GetProperties().GetItem(XATTR_FILLCOLOR).GetColorValue(); Color aOldMatColor(rMatColor); - if (basegfx::fTools::more(fDiffusion, 0.0) + if (fDiffusion > 0.0 && !basegfx::fTools::equalZero(fDiffusion) && !basegfx::fTools::equal(fDiffusion, 1.0)) { // Occurs e.g. with MS surface preset 'Metal'. diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index 76e27768224c..21db5c3da4c0 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -1455,7 +1455,6 @@ void SdrTextObj::impDecomposeStretchTextPrimitive( // timing generators #define ENDLESS_LOOP (0xffffffff) #define ENDLESS_TIME (double(0xffffffff)) -#define PIXEL_DPI (96.0) void SdrTextObj::impGetBlinkTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList) const { @@ -1639,12 +1638,12 @@ void SdrTextObj::impGetScrollTextTiming(drawinglayer::animation::AnimationEntryL fAnimationDelay = 50.0; } - if(basegfx::fTools::less(fSingleStepWidth, 0.0)) + if (fSingleStepWidth < 0.0) { - // data is in pixels, convert to logic. Imply PIXEL_DPI dpi. + // data is in pixels, convert to logic. Imply 96 dpi. // It makes no sense to keep the view-transformation centered // definitions, so get rid of them here. - fSingleStepWidth = (-fSingleStepWidth * (2540.0 / PIXEL_DPI)); + fSingleStepWidth = o3tl::convert(-fSingleStepWidth, o3tl::Length::px, o3tl::Length::mm100); } if(basegfx::fTools::equalZero(fSingleStepWidth)) diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 67c1d7859d04..32c716cffc0a 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -777,7 +777,7 @@ DECLARE_ODFEXPORT_TEST(testTextframeGradient, "textframe-gradient.odt") basegfx::BColorStops aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops); CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(Color(0xc0504d), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(Color(0xd99594), Color(aColorStops[1].getStopColor())); @@ -791,7 +791,7 @@ DECLARE_ODFEXPORT_TEST(testTextframeGradient, "textframe-gradient.odt") aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops); CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(COL_GRAY7, Color(aColorStops[1].getStopColor())); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index 68bb65cdca67..47462ab2e9dd 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -631,7 +631,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf77219_backgroundShape, "tdf77219_backgroundShape basegfx::BColorStops aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops); CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size()); - CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aColorStops[0].getStopOffset()); CPPUNIT_ASSERT_EQUAL(Color(0x5f497a), Color(aColorStops[0].getStopColor())); CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0)); CPPUNIT_ASSERT_EQUAL(COL_WHITE, Color(aColorStops[1].getStopColor())); diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index c098bf36e50d..7e0a1a7676c3 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1484,8 +1484,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf95970) CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line2.Column1, 1095.3035265135941)); CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line2.Column2, 5523.4525711162969)); CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line2.Column3, 672.04166666666663)); - CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line3.Column1, 0.0)); - CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line3.Column2, 0.0)); + CPPUNIT_ASSERT_EQUAL(0.0, aTransform.Line3.Column1); + CPPUNIT_ASSERT_EQUAL(0.0, aTransform.Line3.Column2); CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line3.Column3, 1.0)); } diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 80833b18f49c..163007e46823 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1160,8 +1160,8 @@ bool CairoCommon::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice, } // check for basegfx::B2DLineJoin::NONE to react accordingly - const bool bNoJoin( - (basegfx::B2DLineJoin::NONE == eLineJoin && basegfx::fTools::more(fLineWidth, 0.0))); + const bool bNoJoin(basegfx::B2DLineJoin::NONE == eLineJoin && fLineWidth > 0.0 + && !basegfx::fTools::equalZero(fLineWidth)); if (pSystemDependentData_CairoPath) {