core.git: basegfx/source
basegfx/source/polygon/b2dsvgpolypolygon.cxx | 15 +-- 1 file changed, 1 insertion(+), 14 deletions(-) New commits: commit 35b3abf5831fe05360f58dd7d292602785a55281 Author: Mike Kaganski AuthorDate: Mon Nov 4 21:06:15 2024 +0200 Commit: Mike Kaganski CommitDate: Tue Nov 5 05:35:12 2024 +0100 Simplify a bit The expression can't be negative. It's a Pythagorean sum. Change-Id: Ic07783c5291da71de6701a139227def2f1c4f77b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175989 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx b/basegfx/source/polygon/b2dsvgpolypolygon.cxx index 7e525d5e1644..a7a25e6e17bb 100644 --- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx +++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx @@ -543,20 +543,7 @@ namespace basegfx::utils // of radicant solved for fRY, // with s=fRX/fRY) const double fRatio(fRX/fRY); -const double fRadicant2( -p1_prime.getY()*p1_prime.getY() + - p1_prime.getX()*p1_prime.getX()/(fRatio*fRatio)); -if( fRadicant2 < 0.0 ) -{ -// only trivial solution, one -// of the axes 0 -> straight -// line segment according to -// SVG spec -aCurrPoly.append(B2DPoint(nX, nY)); -continue; -} - -fRY=sqrt(fRadicant2); +fRY=std::hypot(p1_prime.getY(), p1_prime.getX()/fRatio); fRX=fRatio*fRY; // keep center_prime forced to (0,0)
core.git: basegfx/source scaddins/source sfx2/source svl/source svx/source sw/source
basegfx/source/polygon/b2dsvgpolypolygon.cxx|6 -- scaddins/source/analysis/analysis.cxx |2 +- sfx2/source/view/lokcharthelper.cxx |3 ++- svl/source/numbers/zformat.cxx |2 +- svx/source/svdraw/svdpage.cxx |2 +- sw/source/core/crsr/trvlfnfl.cxx|9 + sw/source/core/doc/DocumentStylePoolManager.cxx |5 - sw/source/core/doc/doccomp.cxx |2 +- sw/source/core/doc/docftn.cxx |2 +- sw/source/uibase/dochdl/gloshdl.cxx |8 10 files changed, 24 insertions(+), 17 deletions(-) New commits: commit 35dfb73889a084fc4a428071471429396a7d1287 Author: Caolán McNamara AuthorDate: Tue Sep 17 17:02:10 2024 +0100 Commit: Caolán McNamara CommitDate: Wed Sep 18 21:24:57 2024 +0200 cid#1607355 silence Overflowed constant and cid#1607426 Overflowed constant cid#1608151 Overflowed constant cid#1608163 Overflowed constant cid#1608208 Overflowed constant cid#1608228 Overflowed constant cid#1608299 Overflowed constant cid#1608549 Overflowed constant cid#1607982 Overflowed constant cid#1608078 Overflowed return value Change-Id: Id4ccc03b610f4dcf7912c239c7c079da1aef4ba2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173615 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx b/basegfx/source/polygon/b2dsvgpolypolygon.cxx index fe4f646eb3ba..9728a3896de6 100644 --- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx +++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx @@ -265,15 +265,17 @@ namespace basegfx::utils } // ensure existence of start point -if(!aCurrPoly.count()) +sal_uInt32 nCurrPolyCount = aCurrPoly.count(); +if (nCurrPolyCount == 0) { aCurrPoly.append(B2DPoint(nLastX, nLastY)); +nCurrPolyCount = 1; } // get first control point. It's the reflection of the PrevControlPoint // of the last point. If not existent, use current point (see SVG) B2DPoint aPrevControl(nLastX, nLastY); -const sal_uInt32 nIndex(aCurrPoly.count() - 1); +const sal_uInt32 nIndex(nCurrPolyCount - 1); if(aCurrPoly.areControlPointsUsed() && aCurrPoly.isPrevControlPointUsed(nIndex)) { diff --git a/scaddins/source/analysis/analysis.cxx b/scaddins/source/analysis/analysis.cxx index 249946f3699c..81e12782a320 100644 --- a/scaddins/source/analysis/analysis.cxx +++ b/scaddins/source/analysis/analysis.cxx @@ -407,7 +407,7 @@ sal_Int32 SAL_CALL AnalysisAddIn::getWeeknum( const uno::Reference< beans::XProp DaysToDate( nDate, nDay, nMonth, nYear ); sal_Int32 nFirstInYear = DateToDays( 1, 1, nYear ); -sal_uInt16 nFirstDayInYear = GetDayOfWeek( nFirstInYear ); +sal_Int16 nFirstDayInYear = GetDayOfWeek( nFirstInYear ); return ( nDate - nFirstInYear + ( ( nMode == 1 )? ( nFirstDayInYear + 1 ) % 7 : nFirstDayInYear ) ) / 7 + 1; } diff --git a/sfx2/source/view/lokcharthelper.cxx b/sfx2/source/view/lokcharthelper.cxx index f8e8ec47ea4e..f8b31f7c4f10 100644 --- a/sfx2/source/view/lokcharthelper.cxx +++ b/sfx2/source/view/lokcharthelper.cxx @@ -85,8 +85,9 @@ vcl::Window* LokChartHelper::GetWindow() if (pParent) { sal_uInt16 nTotChildren = pParent->GetChildCount(); -while (nTotChildren--) +while (nTotChildren > 0) { +--nTotChildren; vcl::Window* pChildWin = pParent->GetChild(nTotChildren); if (pChildWin && pChildWin->IsChart()) { diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 31991e8c20b5..eda77fc62859 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -1554,7 +1554,7 @@ OUString SvNumberformat::LocaleType::generateCode() const { aBuf.append(toUniChar(n)); } -n16 = n16 << 4; +n16 = (n16 << 4) & 0x; } return aBuf.makeStringAndClear(); diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index 7618c51c825a..db4a041c577d 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -684,7 +684,7 @@ void SdrObjList::sort( std::vector& sortOrder) { if (nPrev != aDuplicates[i]) aNewSortOrder[i] = aDuplicates[i] + aIncrements[aDuplicates
core.git: basegfx/source
basegfx/source/polygon/b2dpolygon.cxx | 20 +++- 1 file changed, 3 insertions(+), 17 deletions(-) New commits: commit 5456431aff45c7080ad894f055bcd7513a93a6a6 Author: Noel Grandin AuthorDate: Sun Sep 1 09:16:24 2024 +0200 Commit: Noel Grandin CommitDate: Sun Sep 1 15:19:01 2024 +0200 ImplB2DPolygon could do with a move constructor somewhat surprising coverity did not flag this Change-Id: I52684c6adbf3e051c3ada88fc427078cf0867460 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172709 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx index dabca6674f8f..5c68036f7644 100644 --- a/basegfx/source/polygon/b2dpolygon.cxx +++ b/basegfx/source/polygon/b2dpolygon.cxx @@ -611,6 +611,8 @@ public: } } +ImplB2DPolygon(ImplB2DPolygon&&) = default; + ImplB2DPolygon(const ImplB2DPolygon& rToBeCopied, sal_uInt32 nIndex, sal_uInt32 nCount) : maPoints(rToBeCopied.maPoints, nIndex, nCount), mbIsClosed(rToBeCopied.mbIsClosed) @@ -625,24 +627,8 @@ public: } } -ImplB2DPolygon& operator=(const ImplB2DPolygon& rOther) -{ -if (this != &rOther) -{ -moControlVector.reset(); -mpBufferedData.reset(); -maPoints = rOther.maPoints; -mbIsClosed = rOther.mbIsClosed; -if (rOther.moControlVector && rOther.moControlVector->isUsed()) -{ -moControlVector.emplace( *rOther.moControlVector ); -if(!moControlVector->isUsed()) -moControlVector.reset(); -} -} -return *this; -} +ImplB2DPolygon& operator=(ImplB2DPolygon&&) = default; sal_uInt32 count() const {
core.git: basegfx/source
basegfx/source/polygon/b2dpolygon.cxx | 58 +- 1 file changed, 57 insertions(+), 1 deletion(-) New commits: commit 9686a654506999a806a51ee1a13c871be4ba27a0 Author: Noel Grandin AuthorDate: Sun Sep 1 09:13:06 2024 +0200 Commit: Noel Grandin CommitDate: Sun Sep 1 12:39:13 2024 +0200 avoid intermediate copy in B2DPolygon::append Change-Id: If187028195afcef42f9171f54651ada35bf3be4e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172708 Reviewed-by: Noel Grandin Tested-by: Jenkins diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx index b54570df36ac..dabca6674f8f 100644 --- a/basegfx/source/polygon/b2dpolygon.cxx +++ b/basegfx/source/polygon/b2dpolygon.cxx @@ -100,6 +100,16 @@ public: maVector.insert(aIndex, aStart, aEnd); } +void insert(sal_uInt32 nIndex, const CoordinateDataArray2D& rSource, sal_uInt32 nSourceIndex, sal_uInt32 nSourceCount) +{ +// insert data +auto aIndex = maVector.begin(); +aIndex += nIndex; +auto aStart = rSource.maVector.cbegin() + nSourceIndex; +auto aEnd = rSource.maVector.cbegin() + nSourceIndex + nSourceCount; +maVector.insert(aIndex, aStart, aEnd); +} + void remove(sal_uInt32 nIndex, sal_uInt32 nCount) { assert(nCount > 0); @@ -365,6 +375,27 @@ public: } } +void insert(sal_uInt32 nIndex, const ControlVectorArray2D& rSource, sal_uInt32 nSourceIndex, sal_uInt32 nSourceCount) +{ +assert(rSource.maVector.size() > 0); +assert(nIndex + nSourceCount <= maVector.size()); + +// insert data +ControlVectorPair2DVector::iterator aIndex(maVector.begin() + nIndex); +ControlVectorPair2DVector::const_iterator aStart(rSource.maVector.begin() + nSourceIndex); +ControlVectorPair2DVector::const_iterator aEnd(rSource.maVector.begin() + nSourceIndex + nSourceCount); +maVector.insert(aIndex, aStart, aEnd); + +for(; aStart != aEnd; ++aStart) +{ +if(!aStart->getPrevVector().equalZero()) +mnUsedVectors++; + +if(!aStart->getNextVector().equalZero()) +mnUsedVectors++; +} +} + void remove(sal_uInt32 nIndex, sal_uInt32 nCount) { assert(nCount > 0); @@ -807,6 +838,31 @@ public: setPrevControlVector(nCount, rPrev); } +void append(const ImplB2DPolygon& rSource, sal_uInt32 nSourceIndex, sal_uInt32 nSourceCount) +{ +assert(rSource.maPoints.count() > 0); +const sal_uInt32 nIndex = count(); + +mpBufferedData.reset(); + +maPoints.insert(nIndex, rSource.maPoints, nSourceIndex, nSourceCount); + +if(rSource.moControlVector && rSource.moControlVector->isUsed()) +{ +if (!moControlVector) +moControlVector.emplace(nIndex); +moControlVector->insert(nIndex, *rSource.moControlVector, nSourceIndex, nSourceCount); + +if(!moControlVector->isUsed()) +moControlVector.reset(); +} +else if(moControlVector) +{ +ControlVectorPair2D aVectorPair; +moControlVector->insert(nIndex, aVectorPair, rSource.count()); +} +} + void append(const ImplB2DPolygon& rSource) { assert(rSource.maPoints.count() > 0); @@ -1378,7 +1434,7 @@ namespace basegfx } else { -mpPolygon->append(ImplB2DPolygon(*rPoly.mpPolygon, nIndex, nCount)); +mpPolygon->append(*rPoly.mpPolygon, nIndex, nCount); } }
core.git: basegfx/source chart2/qa drawinglayer/source oox/qa sc/qa sd/qa svgio/source svx/source sw/qa vcl/headless
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 AuthorDate: Fri Aug 2 11:33:14 2024 +0500 Commit: Mike Kaganski 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 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
core.git: basegfx/source
basegfx/source/polygon/b2dpolypolygon.cxx |7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) New commits: commit 257b635dfa9bb65206b10b9a11810b30a7f345e8 Author: Caolán McNamara AuthorDate: Wed Jul 31 21:53:53 2024 +0100 Commit: Caolán McNamara CommitDate: Thu Aug 1 09:25:45 2024 +0200 ofz#70815 Timeout I see the cow_wrapper up copies the ImplB2DPolyPolygon during construction when it doesn't need to do that. #9 0x5ad39043b7f4 in void std::__1::vector>::__construct_at_end(basegfx::B2DPolygon*, basegfx::B2DPolygon*, unsigned long) /usr/local/include/c++/v1/vector:1144:25 #10 0x5ad39043b48d in void std::__1::vector>::__init_with_size[abi:v18](basegfx::B2DPolygon*, basegfx::B2DPolygon*, unsigned long) /usr/local/include/c++/v1/vector:776:9 #11 0x5ad393935cee in vector /usr/local/include/c++/v1/vector:1279:3 #12 0x5ad393935cee in ImplB2DPolyPolygon /src/libreoffice/basegfx/source/polygon/b2dpolypolygon.cxx:46:9 #13 0x5ad393935cee in impl_t /src/libreoffice/include/o3tl/cow_wrapper.hxx:195:17 #14 0x5ad393935cee in cow_wrapper /src/libreoffice/include/o3tl/cow_wrapper.hxx:236:26 #15 0x5ad393935cee in basegfx::B2DPolyPolygon::B2DPolyPolygon(basegfx::B2DPolygon const&) /src/libreoffice/basegfx/source/polygon/b2dpolypolygon.cxx:221:9 #16 0x5ad390b31418 in CairoCommon::drawPolygon(unsigned int, Point const*, bool) /src/libreoffice/vcl/headless/CairoCommon.cxx:864:46 #17 0x5ad39014ec77 in OutputDevice::ImplDrawPolygon(tools::Polygon const&, tools::PolyPolygon const*) /src/libreoffice/vcl/source/outdev/polygon.cxx:451:21 Change-Id: I801cf20d7fbc815ea285fde5c1f80f5b2681e6f8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171336 Reviewed-by: Caolán McNamara Tested-by: Jenkins diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx index e830ea728921..f7203a46d88e 100644 --- a/basegfx/source/polygon/b2dpolypolygon.cxx +++ b/basegfx/source/polygon/b2dpolypolygon.cxx @@ -42,8 +42,13 @@ public: { } +explicit ImplB2DPolyPolygon(ImplB2DPolyPolygon&& rSource) noexcept +: maPolygons(std::move(rSource.maPolygons)) +{ +} + explicit ImplB2DPolyPolygon(const ImplB2DPolyPolygon& rSource) -: maPolygons(rSource.maPolygons) +: maPolygons(rSource.maPolygons) { }
core.git: basegfx/source chart2/source connectivity/source linguistic/source oox/source sc/source sdext/source sd/source slideshow/source svgio/source svx/source sw/source tools/source vcl/source xmlo
basegfx/source/tools/bgradient.cxx |4 ++-- chart2/source/view/axes/Tickmarks_Equidistant.cxx |2 +- connectivity/source/drivers/postgresql/pq_array.cxx |2 +- linguistic/source/spelldsp.cxx |2 +- oox/source/drawingml/diagram/layoutnodecontext.cxx |2 +- oox/source/drawingml/textbodycontext.cxx|4 ++-- oox/source/ppt/pptshape.cxx |2 +- sc/source/core/data/document.cxx|2 +- sc/source/filter/excel/xehelper.cxx |2 +- sd/source/ui/dlg/headerfooterdlg.cxx|2 +- sdext/source/minimizer/optimizerdialog.cxx |2 +- slideshow/source/engine/slideview.cxx |2 +- svgio/source/svgreader/svgtextnode.cxx |2 +- svx/source/svdraw/svdedtv2.cxx |2 +- svx/source/svdraw/svdocapt.cxx |2 +- svx/source/svdraw/svdotextdecomposition.cxx |4 ++-- svx/source/table/tablecontroller.cxx|3 ++- sw/source/core/doc/docnum.cxx |2 +- sw/source/filter/xml/swxml.cxx |2 +- sw/source/uibase/uno/SwXDocumentSettings.cxx|2 +- tools/source/generic/poly2.cxx |2 +- vcl/source/bitmap/bitmap.cxx|2 +- vcl/source/gdi/print.cxx|2 +- vcl/source/treelist/transfer.cxx|2 +- xmloff/source/forms/formattributes.cxx |2 +- 25 files changed, 29 insertions(+), 28 deletions(-) New commits: commit 07d357756922e35220a924dab82d315fea22cecb Author: Caolán McNamara AuthorDate: Mon Jul 29 14:05:12 2024 +0100 Commit: Caolán McNamara CommitDate: Wed Jul 31 09:33:06 2024 +0200 cid#1555417 COPY_INSTEAD_OF_MOVE and cid#1555423 COPY_INSTEAD_OF_MOVE cid#1555430 COPY_INSTEAD_OF_MOVE cid#1555436 COPY_INSTEAD_OF_MOVE cid#1555440 COPY_INSTEAD_OF_MOVE cid#1555443 COPY_INSTEAD_OF_MOVE cid#1555454 COPY_INSTEAD_OF_MOVE cid#1555459 COPY_INSTEAD_OF_MOVE cid#1555461 COPY_INSTEAD_OF_MOVE cid#1555468 COPY_INSTEAD_OF_MOVE cid#1555477 COPY_INSTEAD_OF_MOVE cid#1555484 COPY_INSTEAD_OF_MOVE cid#111 COPY_INSTEAD_OF_MOVE cid#115 COPY_INSTEAD_OF_MOVE cid#119 COPY_INSTEAD_OF_MOVE cid#134 COPY_INSTEAD_OF_MOVE cid#137 COPY_INSTEAD_OF_MOVE cid#144 COPY_INSTEAD_OF_MOVE cid#153 COPY_INSTEAD_OF_MOVE cid#159 COPY_INSTEAD_OF_MOVE cid#161 COPY_INSTEAD_OF_MOVE cid#163 COPY_INSTEAD_OF_MOVE cid#164 COPY_INSTEAD_OF_MOVE cid#168 COPY_INSTEAD_OF_MOVE cid#171 COPY_INSTEAD_OF_MOVE cid#180 COPY_INSTEAD_OF_MOVE Change-Id: Ia42a78bffddc80d0e82144f4db51dc6e4d2e9a1d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171237 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index bac738ad3221..d80f52974a35 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -560,7 +560,7 @@ void BColorStops::removeSpaceAtStart(double fOffset) } } -*this = aNewStops; +*this = std::move(aNewStops); } // try to detect if an empty/no-color-change area exists @@ -730,7 +730,7 @@ void BColorStops::doApplySteps(sal_uInt16 nStepCount) } // apply the change to color stops -*this = aNewColorStops; +*this = std::move(aNewColorStops); } void BColorStops::tryToApplyBColorModifierStack(const BColorModifierStack& rBColorModifierStack) diff --git a/chart2/source/view/axes/Tickmarks_Equidistant.cxx b/chart2/source/view/axes/Tickmarks_Equidistant.cxx index c1991fb3ba6e..b55af39ca8bf 100644 --- a/chart2/source/view/axes/Tickmarks_Equidistant.cxx +++ b/chart2/source/view/axes/Tickmarks_Equidistant.cxx @@ -409,7 +409,7 @@ void EquidistantTickFactory::getAllTicksShifted( TickInfoArraysType& rAllTickInf { ExplicitIncrementData aShiftedIncrement( m_rIncrement ); aShiftedIncrement.BaseValue = m_rIncrement.BaseValue-m_rIncrement.Distance/2.0; -EquidistantTickFactory( m_rScale, aShiftedIncrement ).getAllTicks(rAllTickInfos); +EquidistantTickFactory( m_rScale, std::move(aShiftedIncrement) ).getAllTicks(rAllTickInfos); } EquidistantTickIter::EquidistantTickIter( const uno::Sequence< uno::Sequence< double > >& rTicks diff --git a/connectivity/source/drivers/postgresql/pq_array.cxx b/connectivity/source/drivers/postgresql/pq_array.cxx index 03c93537f828..2b7ab3c9491f 100644 --- a/connectivity/source/drivers/postgresql/pq_array.cxx +++ b/connectivity/source/drivers/postgresql/pq_array.cxx @@ -96,7 +96,7 @@ css::uno::Reference< css::sdbc::XResultSet > Array::getResultSetAtIndex( std::vector< Any > row( 2 ); row[0] <<= static_cast( i + index ); r
core.git: basegfx/source binaryurp/source connectivity/source dbaccess/source lotuswordpro/source oox/source sc/inc sc/source svgio/source svx/source sw/source ucb/source unoidl/source vcl/source
basegfx/source/polygon/b2dpolypolygoncutter.cxx|2 +- binaryurp/source/reader.cxx|4 ++-- connectivity/source/drivers/postgresql/pq_databasemetadata.cxx |2 +- dbaccess/source/core/api/RowSetCache.cxx |2 +- dbaccess/source/ui/misc/dsmeta.cxx |2 +- lotuswordpro/source/filter/lwpbookmarkmgr.cxx |4 ++-- oox/source/vml/vmlshape.cxx|4 ++-- sc/inc/externalrefmgr.hxx |2 +- sc/source/core/data/dptabsrc.cxx |2 +- sc/source/core/tool/interpr5.cxx |2 +- sc/source/ui/docshell/externalrefmgr.cxx |2 +- svgio/source/svgreader/svgfedropshadownode.cxx |2 +- svx/source/svdraw/svdfmtf.cxx |2 +- sw/source/writerfilter/ooxml/OOXMLPropertySet.cxx |2 +- ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx |2 +- unoidl/source/sourceprovider-parser.y |2 +- vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx |2 +- vcl/source/bitmap/BitmapScaleSuperFilter.cxx |2 +- vcl/source/gdi/print.cxx |2 +- vcl/source/window/builder.cxx |2 +- 20 files changed, 23 insertions(+), 23 deletions(-) New commits: commit 4504d921a6ac45617ab700316182e68c3248a045 Author: Caolán McNamara AuthorDate: Wed Jul 17 12:08:10 2024 +0100 Commit: Caolán McNamara CommitDate: Wed Jul 17 21:49:14 2024 +0200 cid#1555694 COPY_INSTEAD_OF_MOVE and cid#1555695 COPY_INSTEAD_OF_MOVE cid#1555696 COPY_INSTEAD_OF_MOVE cid#1555705 COPY_INSTEAD_OF_MOVE cid#1555711 COPY_INSTEAD_OF_MOVE cid#1555713 COPY_INSTEAD_OF_MOVE cid#1555727 COPY_INSTEAD_OF_MOVE cid#1555742 COPY_INSTEAD_OF_MOVE cid#1555745 COPY_INSTEAD_OF_MOVE cid#1555749 COPY_INSTEAD_OF_MOVE cid#1555760 COPY_INSTEAD_OF_MOVE cid#1555773 COPY_INSTEAD_OF_MOVE cid#1555774 COPY_INSTEAD_OF_MOVE cid#1555778 COPY_INSTEAD_OF_MOVE cid#1555790 COPY_INSTEAD_OF_MOVE cid#1555831 COPY_INSTEAD_OF_MOVE cid#1555847 COPY_INSTEAD_OF_MOVE cid#1555851 COPY_INSTEAD_OF_MOVE cid#1555853 COPY_INSTEAD_OF_MOVE cid#1607763 COPY_INSTEAD_OF_MOVE cid#1607504 COPY_INSTEAD_OF_MOVE Change-Id: I991f15f12e773d325ed9725498df5725b049a858 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170625 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/basegfx/source/polygon/b2dpolypolygoncutter.cxx b/basegfx/source/polygon/b2dpolypolygoncutter.cxx index 4ad6eb5b219d..bec0c20fa7e4 100644 --- a/basegfx/source/polygon/b2dpolypolygoncutter.cxx +++ b/basegfx/source/polygon/b2dpolypolygoncutter.cxx @@ -1118,7 +1118,7 @@ namespace basegfx::utils } } -aResult = aResult2; +aResult = std::move(aResult2); } // third step: get result diff --git a/binaryurp/source/reader.cxx b/binaryurp/source/reader.cxx index 6930bd900124..9aa27ec7782f 100644 --- a/binaryurp/source/reader.cxx +++ b/binaryurp/source/reader.cxx @@ -330,8 +330,8 @@ void Reader::readMessage(Unmarshal & unmarshal) { } std::unique_ptr< IncomingRequest > req( new IncomingRequest( -bridge_, tid, oid, obj, type, functionId, synchronous, memberTd, -bSetter, std::move(inArgs), ccMode, cc)); +bridge_, tid, oid, std::move(obj), type, functionId, synchronous, +memberTd, bSetter, std::move(inArgs), ccMode, cc)); if (synchronous) { bridge_->incrementActiveCalls(); } diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx index 0b471a92fa9c..76157bc4c305 100644 --- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx +++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx @@ -1778,7 +1778,7 @@ css::uno::Reference< XResultSet > DatabaseMetaData::getPrimaryKeys( if( closeable.is() ) closeable->close(); } -ret[elements] = row; +ret[elements] = std::move(row); elements ++; } return new SequenceResultSet( diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index ae596d48d1d4..086e7a055201 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -627,7 +627,7 @@ void ORowSetCache::updateNumericObject( sal_Int32 columnIndex, const Any& x if ( rInsert[columnIndex] != aTemp ) { rInsert[columnIndex].setBound(true); -
core.git: basegfx/source drawinglayer/source include/basegfx include/drawinglayer svx/inc svx/source
basegfx/source/tools/bgradient.cxx | 19 drawinglayer/source/attribute/fillgradientattribute.cxx | 33 +++ drawinglayer/source/primitive2d/PolyPolygonGradientPrimitive2D.cxx | 46 ++ drawinglayer/source/primitive2d/Tools.cxx |2 include/basegfx/utils/bgradient.hxx |4 include/drawinglayer/attribute/fillgradientattribute.hxx|4 include/drawinglayer/primitive2d/PolyPolygonGradientPrimitive2D.hxx | 41 include/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx |2 svx/inc/sdr/primitive2d/sdrdecompositiontools.hxx |4 svx/source/sdr/primitive2d/sdrdecompositiontools.cxx| 40 ++-- 10 files changed, 183 insertions(+), 12 deletions(-) New commits: commit a073b6133960734b809c1bc93e39a76fdf1e7c15 Author: Armin Le Grand (Collabora) AuthorDate: Mon Jul 15 18:55:56 2024 +0200 Commit: Armin Le Grand CommitDate: Tue Jul 16 13:10:10 2024 +0200 CairoSDPR: Direct support for RGBA Gradients (I) Detect where created when a RGBA gradient could be used directly and create a primitive representing that, a PolyPolygonRGBAGradientPrimitive2D. That primitive decomposes to what was created before, so no primitive renderer has to be touched, all will work as before. NOTE: That helper primitive just holds references to what would be created anyways, so one depth step added but not really any additional data. This is the 1st step for direct support, the 2nd is to then detect and use that primitive in SDPR implementations directly. Change-Id: I4f247636ce58a8a1fd1e0df32dabed0d6cc10d0e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170527 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index e27ab160463b..bac738ad3221 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -746,6 +746,25 @@ void BColorStops::tryToApplyBColorModifierStack(const BColorModifierStack& rBCol } } +bool BColorStops::sameSizeAndDistances(const BColorStops& rComp) const +{ +if (size() != rComp.size()) +{ +return false; +} + +BColorStops::const_iterator EntryA(begin()); +BColorStops::const_iterator EntryB(rComp.begin()); + +while (EntryA != end() && fTools::equal(EntryA->getStopOffset(), EntryB->getStopOffset())) +{ +EntryA++; +EntryB++; +} + +return EntryA == end(); +} + std::string BGradient::GradientStyleToString(css::awt::GradientStyle eStyle) { switch (eStyle) diff --git a/drawinglayer/source/attribute/fillgradientattribute.cxx b/drawinglayer/source/attribute/fillgradientattribute.cxx index e02fdd4a5dad..54f455f647ef 100644 --- a/drawinglayer/source/attribute/fillgradientattribute.cxx +++ b/drawinglayer/source/attribute/fillgradientattribute.cxx @@ -223,6 +223,39 @@ namespace drawinglayer::attribute return mpFillGradientAttribute->getSteps(); } +bool FillGradientAttribute::sameDefinitionThanAlpha(const FillGradientAttribute& rAlpha) const +{ +// entries that are used by all gradient styles +if (getStyle() != rAlpha.getStyle() +|| getBorder() != rAlpha.getBorder() +|| getSteps() != rAlpha.getSteps()) +{ +return false; +} + +// check for offsets if not ignored +const bool bIgnoreOffset(css::awt::GradientStyle_LINEAR == getStyle() || css::awt::GradientStyle_AXIAL == getStyle()); +if (!bIgnoreOffset && (getOffsetX() != rAlpha.getOffsetX() || getOffsetY() != rAlpha.getOffsetY())) +{ +return false; +} + +// check for angle if not ignored +const bool bIgnoreAngle(css::awt::GradientStyle_RADIAL == getStyle()); +if (!bIgnoreAngle && getAngle() != rAlpha.getAngle()) +{ +return false; +} + +// check for same count & offsets in the gradients (all except 'colors') +if (!getColorStops().sameSizeAndDistances(rAlpha.getColorStops())) +{ +return false; +} + +return true; +} + } // end of namespace /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/source/primitive2d/PolyPolygonGradientPrimitive2D.cxx b/drawinglayer/source/primitive2d/PolyPolygonGradientPrimitive2D.cxx index 4fe3321e62f8..2e6b83ab526f 100644 --- a/drawinglayer/source/primitive2d/PolyPolygonGradientPrimitive2D.cxx +++ b/drawinglayer/source/primitive2d/PolyPolygonGradientPrimitive2D.cxx @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include @@ -84,6 +86,
core.git: basegfx/source drawinglayer/source include/basegfx vcl/headless vcl/inc vcl/source vcl/win
basegfx/source/polygon/b2dpolygon.cxx |8 +-- basegfx/source/polygon/b2dpolypolygon.cxx |8 +-- basegfx/source/tools/systemdependentdata.cxx | 17 +++ drawinglayer/source/processor2d/cairopixelprocessor2d.cxx | 15 +++--- drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx | 15 +++--- include/basegfx/polygon/b2dpolygon.hxx| 10 +--- include/basegfx/polygon/b2dpolypolygon.hxx|6 +- include/basegfx/utils/systemdependentdata.hxx | 34 ++ vcl/headless/BitmapHelper.cxx | 12 +++- vcl/headless/CairoCommon.cxx |9 ++- vcl/inc/salbmp.hxx|4 - vcl/source/app/svdata.cxx |2 vcl/source/bitmap/BitmapEx.cxx|7 +- vcl/win/gdi/gdiimpl.cxx |8 ++- vcl/win/gdi/salbmp.cxx|6 +- 15 files changed, 97 insertions(+), 64 deletions(-) New commits: commit f74bb604ff043caa552d809bd8e9157ac7854f96 Author: Armin Le Grand (allotropia) AuthorDate: Thu Jul 11 17:54:18 2024 +0200 Commit: Armin Le Grand CommitDate: Fri Jul 12 17:59:50 2024 +0200 Make SystemDependentData mechanism type-based Up to now that genereal buffering mechanism used typeid.*hash_code to identify the class. As we have learned this is not safe. Thus I changed it to use enum'ed SystemDependentDataType definitions Change-Id: I803912ec419290db1d40bae0bc41364fad64cbfd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170385 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx index cf7309d20dd3..90634a377a72 100644 --- a/basegfx/source/polygon/b2dpolygon.cxx +++ b/basegfx/source/polygon/b2dpolygon.cxx @@ -1062,11 +1062,11 @@ public: mpBufferedData->addOrReplaceSystemDependentData(rData); } -basegfx::SystemDependentData_SharedPtr getSystemDependentData(size_t hash_code) const +basegfx::SystemDependentData_SharedPtr getSystemDependentData(basegfx::SDD_Type aType) const { if(mpBufferedData) { -return mpBufferedData->getSystemDependentData(hash_code); +return mpBufferedData->getSystemDependentData(aType); } return basegfx::SystemDependentData_SharedPtr(); @@ -1445,9 +1445,9 @@ namespace basegfx mpPolygon->addOrReplaceSystemDependentData(rData); } -SystemDependentData_SharedPtr B2DPolygon::getSystemDependantDataInternal(size_t hash_code) const +SystemDependentData_SharedPtr B2DPolygon::getSystemDependantDataInternal(SDD_Type aType) const { -return mpPolygon->getSystemDependentData(hash_code); +return mpPolygon->getSystemDependentData(aType); } } // end of namespace basegfx diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx index fe2a7c7f94c8..e830ea728921 100644 --- a/basegfx/source/polygon/b2dpolypolygon.cxx +++ b/basegfx/source/polygon/b2dpolypolygon.cxx @@ -73,14 +73,14 @@ public: mpSystemDependentDataHolder->addOrReplaceSystemDependentData(rData); } -basegfx::SystemDependentData_SharedPtr getSystemDependentData(size_t hash_code) const +basegfx::SystemDependentData_SharedPtr getSystemDependentData(SDD_Type aType) const { if(!mpSystemDependentDataHolder) { return basegfx::SystemDependentData_SharedPtr(); } -return mpSystemDependentDataHolder->getSystemDependentData(hash_code); +return mpSystemDependentDataHolder->getSystemDependentData(aType); } bool operator==(const ImplB2DPolyPolygon& rPolygonList) const @@ -417,9 +417,9 @@ public: mpPolyPolygon->addOrReplaceSystemDependentData(rData); } -SystemDependentData_SharedPtr B2DPolyPolygon::getSystemDependantDataInternal(size_t hash_code) const +SystemDependentData_SharedPtr B2DPolyPolygon::getSystemDependantDataInternal(SDD_Type aType) const { -return mpPolyPolygon->getSystemDependentData(hash_code); +return mpPolyPolygon->getSystemDependentData(aType); } } // end of namespace basegfx diff --git a/basegfx/source/tools/systemdependentdata.cxx b/basegfx/source/tools/systemdependentdata.cxx index 0d64d9982cef..c32be27ac945 100644 --- a/basegfx/source/tools/systemdependentdata.cxx +++ b/basegfx/source/tools/systemdependentdata.cxx @@ -25,9 +25,11 @@ namespace basegfx namespace basegfx { SystemDependentData::SystemDependentData( -SystemDependentDataManager& rSystemDependentDataManager) -: mrSystemDependentDataManager(rSystemDependentDataManager), -mnCalculatedCycles(0) +SystemDependentDataManager& rSystemDependentD
core.git: basegfx/source drawinglayer/source include/basegfx vcl/source
basegfx/source/color/bcolormodifier.cxx| 136 +++- drawinglayer/source/primitive2d/graphicprimitive2d.cxx | 49 +-- include/basegfx/color/bcolormodifier.hxx | 64 +++- vcl/source/bitmap/BitmapEx.cxx | 268 ++--- 4 files changed, 305 insertions(+), 212 deletions(-) New commits: commit 27829e4a6c5a4a1162599550c46b5e7f974aba91 Author: Armin Le Grand (allotropia) AuthorDate: Wed Jul 10 13:16:20 2024 +0200 Commit: Armin Le Grand CommitDate: Thu Jul 11 10:58:24 2024 +0200 CairoSDPR: Improve BColorModified Bitmaps There is the complete BColorModifierStack support for primitives for Bitmaps, e.g. hue/saturation, etc, but it was slow due to not being buffered, so had to be re-created often. I changed this to use the common buffering mechanism to improve this. Up to now a fallback to use the old Graphic manipulators for that purpose was in place since this was faster, but had to be done every time. I have now changed the priority to using the primitive way to handle things, but kept the fallback code - just in case. Note that the new stuff is faster, but even much faster when the bitmap is copied and appears multiple times -> the same buffered instance is used, and SDPRs then use the system-dependent data buffered at that prepared data. Also note that this change does not only speedup CairoSDPR, but all PrimitiveRenderers, including the VCL and Metafile ones. In principle everything that uses BitmapEx::ModifyBitmapEx. Had a 2nd thought: Only the content Bitmap gets changed, so for this case we do not need AssociatedAlpha and watch for it to not have changed. Removed that. Change-Id: I2ee36cc84bdc1c723aa01f872edbfd1f51e11c2d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170305 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/color/bcolormodifier.cxx b/basegfx/source/color/bcolormodifier.cxx index 04ab3757cb45..e0e0ebbd6203 100644 --- a/basegfx/source/color/bcolormodifier.cxx +++ b/basegfx/source/color/bcolormodifier.cxx @@ -33,11 +33,6 @@ namespace basegfx { } -bool BColorModifier_gray::operator==(const BColorModifier& rCompare) const -{ -return dynamic_cast< const BColorModifier_gray* >(&rCompare) != nullptr; -} - ::basegfx::BColor BColorModifier_gray::getModifiedColor(const ::basegfx::BColor& aSourceColor) const { const double fLuminance(aSourceColor.luminance()); @@ -54,11 +49,6 @@ namespace basegfx { } -bool BColorModifier_invert::operator==(const BColorModifier& rCompare) const -{ -return dynamic_cast< const BColorModifier_invert* >(&rCompare) != nullptr; -} - ::basegfx::BColor BColorModifier_invert::getModifiedColor(const ::basegfx::BColor& aSourceColor) const { return ::basegfx::BColor(1.0 - aSourceColor.getRed(), 1.0 - aSourceColor.getGreen(), 1.0 - aSourceColor.getBlue()); @@ -73,11 +63,6 @@ namespace basegfx { } -bool BColorModifier_luminance_to_alpha::operator==(const BColorModifier& rCompare) const -{ -return dynamic_cast< const BColorModifier_luminance_to_alpha* >(&rCompare) != nullptr; -} - ::basegfx::BColor BColorModifier_luminance_to_alpha::getModifiedColor(const ::basegfx::BColor& aSourceColor) const { const double fAlpha(1.0 - ((aSourceColor.getRed() * 0.2125) + (aSourceColor.getGreen() * 0.7154) + (aSourceColor.getBlue() * 0.0721))); @@ -96,13 +81,10 @@ namespace basegfx bool BColorModifier_replace::operator==(const BColorModifier& rCompare) const { -const BColorModifier_replace* pCompare = dynamic_cast< const BColorModifier_replace* >(&rCompare); - -if(!pCompare) -{ +if (!BColorModifier::operator==(rCompare)) return false; -} +const BColorModifier_replace* pCompare(static_cast< const BColorModifier_replace* >(&rCompare)); return getBColor() == pCompare->getBColor(); } @@ -122,13 +104,10 @@ namespace basegfx bool BColorModifier_interpolate::operator==(const BColorModifier& rCompare) const { -const BColorModifier_interpolate* pCompare = dynamic_cast< const BColorModifier_interpolate* >(&rCompare); - -if(!pCompare) -{ +if (!BColorModifier::operator==(rCompare)) return false; -} +const BColorModifier_interpolate* pCompare(static_cast< const BColorModifier_interpolate* >(&rCompare)); return maBColor == pCompare->maBColor && mfValue == pCompare->mfValue; } @@ -148,13 +127,10 @@ namespace basegfx bool BColorModifier_matrix::operator==(const BColorModifier& rCompare) const { -const BColorModifier_matrix* pCompare = dynamic_cast< const BColorModifier_matrix* >(&rCompare); - -if(!pCompare)
core.git: basegfx/source include/basegfx
basegfx/source/polygon/b3dpolygon.cxx | 57 +++-- include/basegfx/polygon/b3dpolygon.hxx |2 - 2 files changed, 7 insertions(+), 52 deletions(-) New commits: commit 115f60037409c511ae01006dedd32306ddf274ff Author: Noel Grandin AuthorDate: Wed Jul 10 11:12:04 2024 +0200 Commit: Noel Grandin CommitDate: Wed Jul 10 19:04:37 2024 +0200 tsan: ImplB3DPolygon cannot have mutable state because it lives inside a cow_wrapper, which means multiple threads will see inconsistent state. WARNING: ThreadSanitizer: data race (pid=1448100) Read of size 1 at 0x7218002d5a48 by thread T333: 0 ImplB3DPolygon::getNormal() basegfx/source/polygon/b3dpolygon.cxx:998 (libbasegfxlo.so+0xef47a) 1 basegfx::B3DPolygon::getNormal() const basegfx/source/polygon/b3dpolygon.cxx:1477 (libbasegfxlo.so+0xe1834) 2 drawinglayer::processor3d::DefaultProcessor3D::impRenderPolyPolygonMaterialPrimitive3D(drawinglayer::primitive3d::PolyPolygonMaterialPrimitive3D const&) const drawinglayer/source/processor3d/defaultprocessor3d.cxx:424 (libdrawinglayerlo.so+0x1ed388) 3 drawinglayer::processor3d::DefaultProcessor3D::processBasePrimitive3D(drawinglayer::primitive3d::BasePrimitive3D const&) drawinglayer/source/processor3d/defaultprocessor3d.cxx:531 (libdrawinglayerlo.so+0x1edb6f) 4 drawinglayer::processor3d::BaseProcessor3D::process(drawinglayer::primitive3d::Primitive3DContainer const&) drawinglayer/source/processor3d/baseprocessor3d.cxx:57 (libdrawinglayerlo.so+0x1e91c1) 5 drawinglayer::processor3d::DefaultProcessor3D::processBasePrimitive3D(drawinglayer::primitive3d::BasePrimitive3D const&) drawinglayer/source/processor3d/defaultprocessor3d.cxx:543 (libdrawinglayerlo.so+0x1edbe4) 6 drawinglayer::processor3d::BaseProcessor3D::process(drawinglayer::primitive3d::Primitive3DContainer const&) drawinglayer/source/processor3d/baseprocessor3d.cxx:57 (libdrawinglayerlo.so+0x1e91c1) 7 drawinglayer::primitive2d::ScenePrimitive2D::create2DDecomposition(drawinglayer::geometry::ViewInformation2D const&) const::Executor::doWork() drawinglayer/source/primitive2d/sceneprimitive2d.cxx:462 (libdrawinglayerlo.so+0x12469f) 8 comphelper::ThreadTask::exec() comphelper/source/misc/threadpool.cxx:319 (libcomphelper.so+0x2bd587) 9 comphelper::ThreadPool::ThreadWorker::execute() comphelper/source/misc/threadpool.cxx:85 (libcomphelper.so+0x2c3930) 10 salhelper::Thread::run() salhelper/source/thread.cxx:39 (libuno_salhelpergcc3.so.3+0x5d22) 11 non-virtual thunk to salhelper::Thread::run() salhelper/source/thread.cxx:? (libuno_salhelpergcc3.so.3+0x5ed9) 12 threadFunc include/osl/thread.hxx:189 (libuno_salhelpergcc3.so.3+0x6b1e) 13 osl_thread_start_Impl(void*) sal/osl/unx/thread.cxx:237 (libuno_sal.so.3+0xfc937) Previous write of size 8 at 0x7218002d5a48 by thread T334: 0 operator new(unsigned long) /home/noel/llvm-project/compiler-rt/lib/tsan/rtl/tsan_new_delete.cpp:64 (discriminator 8) (cppunittester+0x10c8a1) 1 o3tl::cow_wrapper::make_unique() include/o3tl/cow_wrapper.hxx:304 (libbasegfxlo.so+0xfe798) 2 o3tl::cow_wrapper::operator->() include/o3tl/cow_wrapper.hxx:329 (libbasegfxlo.so+0xef0e5) 3 basegfx::B3DPolygon::getNormal() const basegfx/source/polygon/b3dpolygon.cxx:1477 (libbasegfxlo.so+0xe1825) 4 drawinglayer::processor3d::DefaultProcessor3D::impRenderPolyPolygonMaterialPrimitive3D(drawinglayer::primitive3d::PolyPolygonMaterialPrimitive3D const&) const drawinglayer/source/processor3d/defaultprocessor3d.cxx:424 (libdrawinglayerlo.so+0x1ed388) 5 drawinglayer::processor3d::DefaultProcessor3D::processBasePrimitive3D(drawinglayer::primitive3d::BasePrimitive3D const&) drawinglayer/source/processor3d/defaultprocessor3d.cxx:531 (libdrawinglayerlo.so+0x1edb6f) 6 drawinglayer::processor3d::BaseProcessor3D::process(drawinglayer::primitive3d::Primitive3DContainer const&) drawinglayer/source/processor3d/baseprocessor3d.cxx:57 (libdrawinglayerlo.so+0x1e91c1) 7 drawinglayer::processor3d::DefaultProcessor3D::processBasePrimitive3D(drawinglayer::primitive3d::BasePrimitive3D const&) drawinglayer/source/processor3d/defaultprocessor3d.cxx:543 (libdrawinglayerlo.so+0x1edbe4) 8 drawinglayer::processor3d::BaseProcessor3D::process(drawinglayer::primitive3d::Primitive3DContainer const&) drawinglayer/source/processor3d/baseprocessor3d.cxx:57 (libdrawinglayerlo.so+0x1e91c1) 9 drawinglayer::primitive2d::ScenePrimitive2D::create2DDecomposition(drawinglayer::geometry::ViewInformation2D const&) const::Executor::doWork() drawinglayer/source/primitive2d/sceneprimitive2d.cxx:462 (libdrawinglayerlo.so+0x12469f) 10 comphelper::ThreadTask::exec() comphelper/source/misc/threadpool.cxx:319 (libcomphelper.so+0
core.git: basegfx/source
basegfx/source/curve/b2dcubicbezier.cxx | 26 ++ 1 file changed, 14 insertions(+), 12 deletions(-) New commits: commit c0adf5a90a51f500d633aad9786015f187531d31 Author: HakimOttey AuthorDate: Mon May 20 15:25:20 2024 -0400 Commit: Mike Kaganski CommitDate: Thu Jun 13 15:58:40 2024 +0200 Related: tdf#147906 Rename fQuadDist to pointDistance after commit 9dad7c0f1095e85ad40ad874215f1051137b0347 Author: HakimOttey Date: Mon May 6 12:44:29 2024 -0400 tdf#147906 implement hypot function for s1 x s1 + s2 x s2 statements where the names were kept, but became confusing. Change-Id: If2bfa4b5fc1dd04bb4f1026b6f89e3c97a43caf8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167850 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx index 31801db53559..788c63b828c1 100644 --- a/basegfx/source/curve/b2dcubicbezier.cxx +++ b/basegfx/source/curve/b2dcubicbezier.cxx @@ -22,7 +22,9 @@ #include #include #include + #include + #include #include @@ -644,17 +646,17 @@ namespace basegfx // now look for the closest point const sal_uInt32 nPointCount(aInitialPolygon.count()); B2DVector aVector(rTestPoint - aInitialPolygon.getB2DPoint(0)); -double fQuadDist(std::hypot(aVector.getX(), aVector.getY())); -double fNewQuadDist; +double pointDistance(std::hypot(aVector.getX(), aVector.getY())); +double newPointDistance; sal_uInt32 nSmallestIndex(0); for(sal_uInt32 a(1); a < nPointCount; a++) { aVector = B2DVector(rTestPoint - aInitialPolygon.getB2DPoint(a)); -fNewQuadDist = std::hypot(aVector.getX(), aVector.getY()); -if(fNewQuadDist < fQuadDist) +newPointDistance = std::hypot(aVector.getX(), aVector.getY()); +if(newPointDistance < pointDistance) { -fQuadDist = fNewQuadDist; +pointDistance = newPointDistance; nSmallestIndex = a; } } @@ -678,11 +680,11 @@ namespace basegfx aVector = B2DVector(rTestPoint - interpolatePoint(fPosLeft)); } -fNewQuadDist = std::hypot(aVector.getX(), aVector.getY()); +newPointDistance = std::hypot(aVector.getX(), aVector.getY()); -if(fTools::less(fNewQuadDist, fQuadDist)) +if(fTools::less(newPointDistance, pointDistance)) { -fQuadDist = fNewQuadDist; +pointDistance = newPointDistance; fPosition = fPosLeft; } else @@ -700,11 +702,11 @@ namespace basegfx aVector = B2DVector(rTestPoint - interpolatePoint(fPosRight)); } -fNewQuadDist = std::hypot(aVector.getX(), aVector.getY()); +newPointDistance = std::hypot(aVector.getX(), aVector.getY()); -if(fTools::less(fNewQuadDist, fQuadDist)) +if(fTools::less(newPointDistance, pointDistance)) { -fQuadDist = fNewQuadDist; +pointDistance = newPointDistance; fPosition = fPosRight; } else @@ -725,7 +727,7 @@ namespace basegfx } rCut = fPosition; -return fQuadDist; +return pointDistance; } void B2DCubicBezier::split(double t, B2DCubicBezier* pBezierA, B2DCubicBezier* pBezierB) const
core.git: basegfx/source
basegfx/source/curve/b2dcubicbezier.cxx | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) New commits: commit 9dad7c0f1095e85ad40ad874215f1051137b0347 Author: HakimOttey AuthorDate: Mon May 6 12:44:29 2024 -0400 Commit: Ilmari Lauhakangas CommitDate: Mon May 20 08:20:40 2024 +0200 tdf#147906 implement hypot function for s1 x s1 + s2 x s2 statements Change-Id: I50a2f4cf7738ee3797723929fb6840d2633c882c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166814 Tested-by: Ilmari Lauhakangas Tested-by: Jenkins Reviewed-by: Ilmari Lauhakangas diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx index 3f5d87aa79f6..31801db53559 100644 --- a/basegfx/source/curve/b2dcubicbezier.cxx +++ b/basegfx/source/curve/b2dcubicbezier.cxx @@ -22,9 +22,8 @@ #include #include #include - #include - +#include #include // #i37443# @@ -645,15 +644,14 @@ namespace basegfx // now look for the closest point const sal_uInt32 nPointCount(aInitialPolygon.count()); B2DVector aVector(rTestPoint - aInitialPolygon.getB2DPoint(0)); -double fQuadDist(aVector.getX() * aVector.getX() + aVector.getY() * aVector.getY()); +double fQuadDist(std::hypot(aVector.getX(), aVector.getY())); double fNewQuadDist; sal_uInt32 nSmallestIndex(0); for(sal_uInt32 a(1); a < nPointCount; a++) { aVector = B2DVector(rTestPoint - aInitialPolygon.getB2DPoint(a)); -fNewQuadDist = aVector.getX() * aVector.getX() + aVector.getY() * aVector.getY(); - +fNewQuadDist = std::hypot(aVector.getX(), aVector.getY()); if(fNewQuadDist < fQuadDist) { fQuadDist = fNewQuadDist; @@ -680,7 +678,7 @@ namespace basegfx aVector = B2DVector(rTestPoint - interpolatePoint(fPosLeft)); } -fNewQuadDist = aVector.getX() * aVector.getX() + aVector.getY() * aVector.getY(); +fNewQuadDist = std::hypot(aVector.getX(), aVector.getY()); if(fTools::less(fNewQuadDist, fQuadDist)) { @@ -702,7 +700,7 @@ namespace basegfx aVector = B2DVector(rTestPoint - interpolatePoint(fPosRight)); } -fNewQuadDist = aVector.getX() * aVector.getX() + aVector.getY() * aVector.getY(); +fNewQuadDist = std::hypot(aVector.getX(), aVector.getY()); if(fTools::less(fNewQuadDist, fQuadDist)) { @@ -727,7 +725,7 @@ namespace basegfx } rCut = fPosition; -return sqrt(fQuadDist); +return fQuadDist; } void B2DCubicBezier::split(double t, B2DCubicBezier* pBezierA, B2DCubicBezier* pBezierB) const
core.git: basegfx/source canvas/source chart2/source cppcanvas/source cui/source drawinglayer/source editeng/source emfio/source filter/source include/basegfx include/svx oox/source sc/source sd/qa sd
basegfx/source/curve/b2dcubicbezier.cxx | 24 +++ canvas/source/directx/dx_textlayout_drawhelper.cxx |4 - canvas/source/opengl/ogl_canvashelper.cxx|2 canvas/source/tools/surface.cxx |9 -- canvas/source/vcl/canvasfont.cxx |2 canvas/source/vcl/canvashelper.cxx |4 - canvas/source/vcl/canvashelper_texturefill.cxx | 36 +-- canvas/source/vcl/impltools.cxx |8 +- chart2/source/controller/main/SelectionHelper.cxx|2 cppcanvas/source/mtfrenderer/transparencygroupaction.cxx |4 - cui/source/tabpages/transfrm.cxx |4 - drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx |2 drawinglayer/source/processor2d/SDPRProcessor2dTools.cxx |6 + drawinglayer/source/processor2d/helperwrongspellrenderer.cxx |6 + drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx | 32 + drawinglayer/source/processor2d/vclprocessor2d.cxx | 19 +++-- drawinglayer/source/tools/converters.cxx |2 editeng/source/editeng/impedit3.cxx |6 - editeng/source/editeng/impedit4.cxx |3 editeng/source/outliner/outliner.cxx |4 - emfio/source/reader/mtftools.cxx |6 - filter/source/msfilter/escherex.cxx |2 filter/source/msfilter/eschesdo.cxx |4 - filter/source/svg/svgfilter.cxx |2 include/basegfx/numeric/ftools.hxx | 16 include/svx/transfrmhelper.hxx |8 +- oox/source/export/drawingml.cxx |2 sc/source/core/data/drwlayer.cxx |4 - sc/source/ui/miscdlgs/autofmt.cxx|8 +- sc/source/ui/view/drawview.cxx |4 - sd/qa/unit/layout-tests.cxx |6 - sd/source/core/sdpage.cxx| 16 ++-- slideshow/source/engine/eventmultiplexer.cxx |8 +- slideshow/source/engine/slideview.cxx|4 - svx/source/customshapes/EnhancedCustomShape3d.cxx|2 svx/source/dialog/frmsel.cxx | 12 +-- svx/source/engine3d/obj3d.cxx|2 svx/source/engine3d/view3d.cxx |6 - svx/source/svdraw/svdcrtv.cxx|4 - svx/source/svdraw/svddrgmt.cxx | 16 ++-- svx/source/svdraw/svddrgv.cxx| 16 ++-- svx/source/svdraw/svdedxv.cxx|8 +- svx/source/svdraw/svdfmtf.cxx|8 +- svx/source/svdraw/svdmrkv.cxx| 12 +-- svx/source/svdraw/svdoedge.cxx | 16 ++-- svx/source/svdraw/svdograf.cxx | 16 ++-- svx/source/svdraw/svdomeas.cxx |6 - svx/source/svdraw/svdpdf.cxx |8 +- svx/source/unodraw/UnoGraphicExporter.cxx|8 +- svx/source/unodraw/unoshape.cxx |8 +- sw/source/core/draw/dflyobj.cxx | 32 - sw/source/core/layout/wsfrm.cxx | 28 sw/source/ui/table/autoformatpreview.cxx | 15 ++-- vcl/source/bitmap/BitmapEx.cxx |2 vcl/source/bitmap/BitmapTools.cxx| 16 ++-- vcl/source/gdi/gdimetafiletools.cxx |8 +- vcl/source/gdi/impgraph.cxx |6 - vcl/source/gdi/region.cxx|4 - vcl/source/gdi/regionband.cxx|4 - vcl/source/graphic/GraphicObject.cxx |8 +- vcl/source/outdev/bitmapex.cxx | 18 ++--- vcl/source/outdev/text.cxx |2 vcl/source/window/printdlg.cxx |4 - vcl/win/gdi/gdiimpl.cxx |4 - 64 files changed, 297 insertions(+), 271 deletions(-) New commits: commit 690526f95e3ee4fd25bb2c987e093543e4bc435b Author: Mike Kaganski AuthorDate: Sun Apr 14 12:50:42 2024 +0500 Commit: Mike Kaganski CommitDate: Mon Apr 15 06:34:33 2024 +0200 Generalize basegfx::fround for templated return type And use it when assigning to tools::Long Change-
core.git: basegfx/source include/basegfx vcl/source
basegfx/source/vector/b2dvector.cxx | 27 +++ basegfx/source/vector/b2ivector.cxx |4 ++-- basegfx/source/vector/b3dvector.cxx | 10 +++--- include/basegfx/vector/b3dvector.hxx | 19 +-- vcl/source/filter/idxf/dxfvec.cxx|2 +- 5 files changed, 26 insertions(+), 36 deletions(-) New commits: commit 45d951492a34d8d4134a518662377fa4c1e08395 Author: RMZeroFour AuthorDate: Fri Mar 29 20:19:58 2024 +0530 Commit: Hossein CommitDate: Fri Apr 5 13:59:33 2024 +0200 tdf#147906 Use std::hypot for Pythagorean distance As part of the efforts in tdf#147906 to replace expressions like sqrt(a^2 + b^2) with std::hypot(a, b), to eliminate overflow errors, this commit performs the changes in certain files. This also changes the B3DVector::normalize and B2DVector::normalize methods to have similar behaviour. Change-Id: I142585cfa594849f06cd06517ad9d40430df2ade Reviewed-on: https://gerrit.libreoffice.org/c/core/+/16 Tested-by: Hossein Reviewed-by: Hossein diff --git a/basegfx/source/vector/b2dvector.cxx b/basegfx/source/vector/b2dvector.cxx index 85ec6ca81116..1f696237fecf 100644 --- a/basegfx/source/vector/b2dvector.cxx +++ b/basegfx/source/vector/b2dvector.cxx @@ -25,28 +25,23 @@ namespace basegfx { B2DVector& B2DVector::normalize() { -double fLen(scalar(*this)); +double fLen(std::hypot(mnX, mnY)); -if(fTools::equalZero(fLen)) -{ -mnX = 0.0; -mnY = 0.0; -} -else +if(!fTools::equalZero(fLen)) { const double fOne(1.0); if(!fTools::equal(fOne, fLen)) { -fLen = sqrt(fLen); - -if(!fTools::equalZero(fLen)) -{ -mnX /= fLen; -mnY /= fLen; -} +mnX /= fLen; +mnY /= fLen; } } +else +{ +mnX = 0.0; +mnY = 0.0; +} return *this; } @@ -90,7 +85,7 @@ namespace basegfx B2DVector& B2DVector::setLength(double fLen) { -double fLenNow(scalar(*this)); +double fLenNow(std::hypot(mnX, mnY)); if(!fTools::equalZero(fLenNow)) { @@ -98,7 +93,7 @@ namespace basegfx if(!fTools::equal(fOne, fLenNow)) { -fLen /= sqrt(fLenNow); +fLen /= fLenNow; } mnX *= fLen; diff --git a/basegfx/source/vector/b2ivector.cxx b/basegfx/source/vector/b2ivector.cxx index 5b45871a39cf..6d618facf48f 100644 --- a/basegfx/source/vector/b2ivector.cxx +++ b/basegfx/source/vector/b2ivector.cxx @@ -42,7 +42,7 @@ namespace basegfx B2IVector& B2IVector::setLength(double fLen) { -double fLenNow(scalar(*this)); +double fLenNow(std::hypot(mnX, mnY)); if(!::basegfx::fTools::equalZero(fLenNow)) { @@ -50,7 +50,7 @@ namespace basegfx if(!::basegfx::fTools::equal(fOne, fLenNow)) { -fLen /= sqrt(fLenNow); +fLen /= fLenNow; } mnX = fround( mnX*fLen ); diff --git a/basegfx/source/vector/b3dvector.cxx b/basegfx/source/vector/b3dvector.cxx index 89bc33c2bd9e..68e3fcf205c4 100644 --- a/basegfx/source/vector/b3dvector.cxx +++ b/basegfx/source/vector/b3dvector.cxx @@ -24,7 +24,7 @@ namespace basegfx { B3DVector& B3DVector::normalize() { -double fLen(scalar(*this)); +double fLen(std::hypot(mnX, mnY, mnZ)); if(!::basegfx::fTools::equalZero(fLen)) { @@ -32,13 +32,17 @@ namespace basegfx if(!::basegfx::fTools::equal(fOne, fLen)) { -fLen = sqrt(fLen); - mnX /= fLen; mnY /= fLen; mnZ /= fLen; } } +else +{ +mnX = 0.0; +mnY = 0.0; +mnZ = 0.0; +} return *this; } diff --git a/include/basegfx/vector/b3dvector.hxx b/include/basegfx/vector/b3dvector.hxx index 44c926e805c8..df7638f73268 100644 --- a/include/basegfx/vector/b3dvector.hxx +++ b/include/basegfx/vector/b3dvector.hxx @@ -106,10 +106,7 @@ namespace basegfx */ double getLength() const { -double fLen(scalar(*this)); -if((0.0 == fLen) || (1.0 == fLen)) -return fLen; -return sqrt(fLen); +return std::hypot(mnX, mnY, mnZ); } /** Calculate the length in the XZ-Plane for this 3D Vector @@ -118,10 +115,7 @@ namespace basegfx */ double getXZLength() const { -double fLen((mnX * mnX) + (mnZ * mnZ)); // #i73040# -if((0.0 == fLen) || (1.0 == fLen)) -return fLen; -return sqrt(fLen); +
core.git: basegfx/source include/basegfx
basegfx/source/polygon/b2dpolygontools.cxx | 51 ++-- include/basegfx/polygon/b2dpolygontools.hxx |2 - 2 files changed, 13 insertions(+), 40 deletions(-) New commits: commit fc5d84681d5d898b56171a9622294ecb23623bfd Author: Noel Grandin AuthorDate: Tue Mar 26 13:35:53 2024 +0200 Commit: Noel Grandin CommitDate: Tue Mar 26 19:02:42 2024 +0100 tdf#159805 Printing line style dotted lines (horizontal) turns into dashes. I could not find a good place to distinguish between the dragging visualisation (where we could safely use approximation), and the non-dragging case, so just revert. Revert commit 9f4ccc63346b26d8d774b22124da0842ef18e0bc Author: Noel Grandin Date: Wed Sep 13 14:27:02 2023 +0200 tdf#156995 speed up dragging complex group objects Change-Id: I2ba52f07ea7299643c0f145459038e368a17dea8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165332 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index 0d9dbc15b42d..482d35d4df1d 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -475,7 +475,7 @@ namespace basegfx::utils return fRetval; } -double getLength(const B2DPolygon& rCandidate, bool bApproximateBezierLength) +double getLength(const B2DPolygon& rCandidate) { double fRetval(0.0); const sal_uInt32 nPointCount(rCandidate.count()); @@ -486,45 +486,18 @@ namespace basegfx::utils if(rCandidate.areControlPointsUsed()) { -if (bApproximateBezierLength) -{ -B2DPoint aStartPoint = rCandidate.getB2DPoint(0); - -for(sal_uInt32 a(0); a < nEdgeCount; a++) -{ -// An approximate length of a cubic Bezier curve is the average -// of its chord length and the sum of the lengths of its control net sides. -const sal_uInt32 nNextIndex((a + 1) % nPointCount); -const B2DPoint& aControlPoint1 = rCandidate.getNextControlPoint(a); -const B2DPoint& aControlPoint2 = rCandidate.getPrevControlPoint(nNextIndex); -const B2DPoint& aEndPoint = rCandidate.getB2DPoint(nNextIndex); - -double chord_length = B2DVector(aEndPoint - aStartPoint).getLength(); -double control_net_length = B2DVector(aStartPoint - aControlPoint1).getLength() -+ B2DVector(aControlPoint2 - aControlPoint1).getLength() -+ B2DVector(aEndPoint - aControlPoint2).getLength(); -double approximate_arc_length = (control_net_length + chord_length) / 2; - -fRetval += approximate_arc_length; -aStartPoint = aEndPoint; -} +B2DCubicBezier aEdge; +aEdge.setStartPoint(rCandidate.getB2DPoint(0)); -} -else +for(sal_uInt32 a(0); a < nEdgeCount; a++) { -B2DCubicBezier aEdge; -aEdge.setStartPoint(rCandidate.getB2DPoint(0)); - -for(sal_uInt32 a(0); a < nEdgeCount; a++) -{ -const sal_uInt32 nNextIndex((a + 1) % nPointCount); - aEdge.setControlPointA(rCandidate.getNextControlPoint(a)); - aEdge.setControlPointB(rCandidate.getPrevControlPoint(nNextIndex)); - aEdge.setEndPoint(rCandidate.getB2DPoint(nNextIndex)); +const sal_uInt32 nNextIndex((a + 1) % nPointCount); + aEdge.setControlPointA(rCandidate.getNextControlPoint(a)); + aEdge.setControlPointB(rCandidate.getPrevControlPoint(nNextIndex)); +aEdge.setEndPoint(rCandidate.getB2DPoint(nNextIndex)); -fRetval += aEdge.getLength(); -aEdge.setStartPoint(aEdge.getEndPoint()); -} +fRetval += aEdge.getLength(); +aEdge.setStartPoint(aEdge.getEndPoint()); } } else @@ -1259,9 +1232,9 @@ namespace basegfx::utils // precalculate maximal acceptable length of candidate polygon assuming // we want to create a maximum of fNumberOfAllowedSnippets. For // fNumberOfAllowedSnippets use ca. 65536, double due to line & gap.
core.git: basegfx/source
basegfx/source/color/bcolormodifier.cxx |2 +- basegfx/source/tools/bgradient.cxx |8 2 files changed, 5 insertions(+), 5 deletions(-) New commits: commit b0f26f460c8f9afceaaf0aa26de3ebfa1bf2cefa Author: Bogdan Buzea AuthorDate: Fri Mar 22 20:07:40 2024 +0100 Commit: Noel Grandin CommitDate: Tue Mar 26 17:26:53 2024 +0100 tdf#160084 Simplify comparison for basegfx::fTools Change-Id: If1a2d000e7059856280bd1acb959b35c412777df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165184 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/basegfx/source/color/bcolormodifier.cxx b/basegfx/source/color/bcolormodifier.cxx index 75c06f5cb8f3..3b9d1ce158c3 100644 --- a/basegfx/source/color/bcolormodifier.cxx +++ b/basegfx/source/color/bcolormodifier.cxx @@ -331,7 +331,7 @@ namespace basegfx BColorModifier_gamma::BColorModifier_gamma(double fValue) : mfValue(fValue), mfInvValue(fValue), -mbUseIt(!basegfx::fTools::equal(fValue, 1.0) && basegfx::fTools::more(fValue, 0.0) && basegfx::fTools::lessOrEqual(fValue, 10.0)) +mbUseIt(!basegfx::fTools::equal(fValue, 1.0) && fValue > 0.0 && basegfx::fTools::lessOrEqual(fValue, 10.0)) { if(mbUseIt) { diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index ffa75a898c53..9f98c54cfc1c 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -332,13 +332,13 @@ void BColorStops::sortAndCorrect() // get offset of entry at read position double fOff((*this)[read].getStopOffset()); -if (basegfx::fTools::less(fOff, 0.0) && read + 1 < size()) +if (fOff < 0.0 && read + 1 < size()) { // value < 0.0 and we have a next entry. check for gradient snippet // containing 0.0 resp. StartColor const double fOff2((*this)[read + 1].getStopOffset()); -if (basegfx::fTools::more(fOff2, 0.0)) +if (fOff2 > 0.0) { // read is the start of a gradient snippet containing 0.0. Correct // entry to StartColor, interpolate to correct StartColor @@ -353,7 +353,7 @@ void BColorStops::sortAndCorrect() } // step over < 0 values, these are outside and will be removed -if (basegfx::fTools::less(fOff, 0.0)) +if (fOff < 0.0) { continue; } @@ -410,7 +410,7 @@ void BColorStops::sortAndCorrect() // no valid entries at all, but not empty. This can only happen // when all entries are below 0.0 or above 1.0 (else a gradient // snippet spawning over both would have been detected) -if (basegfx::fTools::less(back().getStopOffset(), 0.0)) +if (back().getStopOffset() < 0.0) { // all outside too low, rescue last due to being closest to content const BColor aBackColor(back().getStopColor());
core.git: basegfx/source include/basegfx
basegfx/source/curve/b2dcubicbezier.cxx | 10 -- basegfx/source/matrix/b2dhommatrix.cxx|5 - basegfx/source/polygon/b2dpolygontriangulator.cxx |5 - basegfx/source/polygon/b2dpolypolygon.cxx |5 - basegfx/source/polygon/b3dpolypolygon.cxx |5 - basegfx/source/range/b2dpolyrange.cxx |5 - basegfx/source/tools/b2dclipstate.cxx |5 - include/basegfx/curve/b2dcubicbezier.hxx |1 - include/basegfx/matrix/b2dhommatrix.hxx |1 - include/basegfx/polygon/b2dpolypolygon.hxx|1 - include/basegfx/polygon/b3dpolypolygon.hxx|1 - include/basegfx/range/b2dpolyrange.hxx|1 - include/basegfx/utils/b2dclipstate.hxx|1 - 13 files changed, 46 deletions(-) New commits: commit 64a55911eae1cf5f913f07b45a7c8379b325e471 Author: RMZeroFour AuthorDate: Sat Mar 23 14:06:40 2024 +0530 Commit: Mike Kaganski CommitDate: Sat Mar 23 11:17:06 2024 +0100 tdf#157664 Drop redundant operator != in basegfx module As part of the efforts in #157664 to remove redundant definitions of operator!=, to upgrade the codebase to C++20, this commit removes the remaining definitions in the basegfx module. Change-Id: I19f2b9ddf42185435313445c8395a851030e2149 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165199 Reviewed-by: Mike Kaganski Tested-by: Jenkins diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx index 927230fabcb1..fa7b69e1e5e8 100644 --- a/basegfx/source/curve/b2dcubicbezier.cxx +++ b/basegfx/source/curve/b2dcubicbezier.cxx @@ -351,16 +351,6 @@ namespace basegfx ); } -bool B2DCubicBezier::operator!=(const B2DCubicBezier& rBezier) const -{ -return ( -maStartPoint != rBezier.maStartPoint -|| maEndPoint != rBezier.maEndPoint -|| maControlPointA != rBezier.maControlPointA -|| maControlPointB != rBezier.maControlPointB -); -} - bool B2DCubicBezier::equal(const B2DCubicBezier& rBezier) const { return ( diff --git a/basegfx/source/matrix/b2dhommatrix.cxx b/basegfx/source/matrix/b2dhommatrix.cxx index e4a9dda9e3c5..dc5c02b0e33f 100644 --- a/basegfx/source/matrix/b2dhommatrix.cxx +++ b/basegfx/source/matrix/b2dhommatrix.cxx @@ -182,11 +182,6 @@ namespace basegfx return true; } -bool B2DHomMatrix::operator!=(const B2DHomMatrix& rMat) const -{ -return !(*this == rMat); -} - void B2DHomMatrix::rotate(double fRadiant) { if(fTools::equalZero(fRadiant)) diff --git a/basegfx/source/polygon/b2dpolygontriangulator.cxx b/basegfx/source/polygon/b2dpolygontriangulator.cxx index 8742ade70e46..b72e3da6039d 100644 --- a/basegfx/source/polygon/b2dpolygontriangulator.cxx +++ b/basegfx/source/polygon/b2dpolygontriangulator.cxx @@ -92,11 +92,6 @@ namespace basegfx return (maStart.equal(rComp.maStart) && maEnd.equal(rComp.maEnd)); } -bool operator!=(const EdgeEntry& rComp) const -{ -return !(*this == rComp); -} - const B2DPoint& getStart() const { return maStart; } const B2DPoint& getEnd() const { return maEnd; } diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx index 547634dc4dad..fe2a7c7f94c8 100644 --- a/basegfx/source/polygon/b2dpolypolygon.cxx +++ b/basegfx/source/polygon/b2dpolypolygon.cxx @@ -241,11 +241,6 @@ public: return ((*mpPolyPolygon) == (*rPolyPolygon.mpPolyPolygon)); } -bool B2DPolyPolygon::operator!=(const B2DPolyPolygon& rPolyPolygon) const -{ -return !((*this) == rPolyPolygon); -} - sal_uInt32 B2DPolyPolygon::count() const { return mpPolyPolygon->count(); diff --git a/basegfx/source/polygon/b3dpolypolygon.cxx b/basegfx/source/polygon/b3dpolypolygon.cxx index 017906eef5b8..5a43cb876be6 100644 --- a/basegfx/source/polygon/b3dpolypolygon.cxx +++ b/basegfx/source/polygon/b3dpolypolygon.cxx @@ -223,11 +223,6 @@ namespace basegfx return ((*mpPolyPolygon) == (*rPolyPolygon.mpPolyPolygon)); } -bool B3DPolyPolygon::operator!=(const B3DPolyPolygon& rPolyPolygon) const -{ -return !(*this == rPolyPolygon); -} - sal_uInt32 B3DPolyPolygon::count() const { return mpPolyPolygon->count(); diff --git a/basegfx/source/range/b2dpolyrange.cxx b/basegfx/source/range/b2dpolyrange.cxx index beb506fc8e4d..42ee21ec0d64 100644 --- a/basegfx/source/range/b2dpolyrange.cxx +++ b/basegfx/source/range/b2dpolyrange.cxx @@ -109,11 +109,6 @@ namespace basegfx return ((*mpImpl) == (*rRange.mpImpl)); } -bool B2DPolyRange::operator!=(const B2DPolyRange& rRange) const -{ -return !(*this == rRange); -} - sal_uInt32
core.git: basegfx/source
basegfx/source/tools/bgradient.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 7ef7bdca3c1c82cf0338542c107e8f9e0b838b66 Author: Andrea Gelmini AuthorDate: Thu Mar 7 16:57:14 2024 +0100 Commit: Julien Nabet CommitDate: Thu Mar 21 08:33:23 2024 +0100 Fix typo Change-Id: Ib12a2b2f76f3819a3c0355f45ef56d3e861530a6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164545 Tested-by: Julien Nabet Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index b22df74d52e8..ffa75a898c53 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -914,7 +914,7 @@ void BGradient::tryToApplyBorder() } else { -// apply border to GradientSteps +// apply border to GradientStops aColorStops.createSpaceAtStart(fOffset); }
core.git: basegfx/source
basegfx/source/tools/unopolypolygon.cxx |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit be6243144eb39838294258a80b1f153bcd3e7029 Author: Arnaud VERSINI AuthorDate: Sun Mar 3 16:33:19 2024 +0100 Commit: Arnaud Versini CommitDate: Sun Mar 10 17:17:00 2024 +0100 basegfx : use OUstring literal for XServiceInfo implementation Change-Id: I18a17e38897c1feda7fbba330c14a79c9b6d6f93 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164306 Tested-by: Jenkins Reviewed-by: Arnaud Versini diff --git a/basegfx/source/tools/unopolypolygon.cxx b/basegfx/source/tools/unopolypolygon.cxx index 41f149731965..323e06a96f18 100644 --- a/basegfx/source/tools/unopolypolygon.cxx +++ b/basegfx/source/tools/unopolypolygon.cxx @@ -421,7 +421,7 @@ namespace basegfx::unotools OUString SAL_CALL UnoPolyPolygon::getImplementationName() { -return "gfx::internal::UnoPolyPolygon"; +return u"gfx::internal::UnoPolyPolygon"_ustr; } sal_Bool SAL_CALL UnoPolyPolygon::supportsService( const OUString& ServiceName ) @@ -431,7 +431,7 @@ namespace basegfx::unotools uno::Sequence< OUString > SAL_CALL UnoPolyPolygon::getSupportedServiceNames() { -return { "com.sun.star.rendering.PolyPolygon2D" }; +return { u"com.sun.star.rendering.PolyPolygon2D"_ustr }; } B2DPolyPolygon UnoPolyPolygon::getPolyPolygon() const
core.git: basegfx/source drawinglayer/source svgio/inc svgio/source svx/source
basegfx/source/curve/b2dcubicbezier.cxx |2 +- basegfx/source/numeric/ftools.cxx |2 +- basegfx/source/polygon/b2dlinegeometry.cxx|4 ++-- basegfx/source/polygon/b2dpolygontools.cxx|6 +++--- basegfx/source/polygon/b2dpolypolygoncutter.cxx |8 basegfx/source/polygon/b2dtrapezoid.cxx |8 basegfx/source/polygon/b3dpolygontools.cxx|4 ++-- basegfx/source/tools/bgradient.cxx|3 +-- drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx |4 ++-- drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx |4 ++-- svgio/inc/SvgNumber.hxx |2 +- svgio/source/svgreader/svgsvgnode.cxx |4 ++-- svx/source/sdr/contact/viewcontactofe3dpolygon.cxx|2 +- svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx |2 +- svx/source/svdraw/svdfmtf.cxx |2 +- 15 files changed, 28 insertions(+), 29 deletions(-) New commits: commit 7979508e4328ceb9d6a2dff6a2a080ea64247c7e Author: Noel Grandin AuthorDate: Thu Mar 7 12:08:09 2024 +0200 Commit: Noel Grandin CommitDate: Thu Mar 7 12:53:27 2024 +0100 Simplify some basegfx::fTools::*orEqual calls Comparing with zero is simple - the implementation of basegfx::fTools::moreOrEqual calls rtl_math_approxEqual eventually, which special-zases zero. Change-Id: I62f10f63f103d91a201dfeb20e5b3f9010f377c1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164526 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx index d33cd82b194d..927230fabcb1 100644 --- a/basegfx/source/curve/b2dcubicbezier.cxx +++ b/basegfx/source/curve/b2dcubicbezier.cxx @@ -541,7 +541,7 @@ namespace basegfx B2DVector B2DCubicBezier::getTangent(double t) const { -if(fTools::lessOrEqual(t, 0.0)) +if(t <= 0.0) { // tangent in start point B2DVector aTangent(getControlPointA() - getStartPoint()); diff --git a/basegfx/source/numeric/ftools.cxx b/basegfx/source/numeric/ftools.cxx index 246d8d548aac..4a01a4c0eca0 100644 --- a/basegfx/source/numeric/ftools.cxx +++ b/basegfx/source/numeric/ftools.cxx @@ -99,7 +99,7 @@ namespace basegfx double normalizeToRange(double v, const double fRange) { -if(fTools::lessOrEqual(fRange, 0.0)) +if(fRange <= 0.0) { // with a zero (or less) range, all normalizes to 0.0 return 0.0; diff --git a/basegfx/source/polygon/b2dlinegeometry.cxx b/basegfx/source/polygon/b2dlinegeometry.cxx index 437ebcbb496e..4f5de36a8295 100644 --- a/basegfx/source/polygon/b2dlinegeometry.cxx +++ b/basegfx/source/polygon/b2dlinegeometry.cxx @@ -147,7 +147,7 @@ namespace basegfx const B2DVector aTangentA(rCandidate.getTangent(0.0)); const double fScalarAE(aEdge.scalar(aTangentA)); -if(fTools::lessOrEqual(fScalarAE, 0.0)) +if(fScalarAE <= 0.0) { // angle between TangentA and Edge is bigger or equal 90 degrees return false; @@ -174,7 +174,7 @@ namespace basegfx const B2DVector aTangentB(rCandidate.getTangent(1.0)); const double fScalarBE(aEdge.scalar(aTangentB)); -if(fTools::lessOrEqual(fScalarBE, 0.0)) +if(fScalarBE <= 0.0) { // angle between TangentB and Edge is bigger or equal 90 degrees return false; diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index b3f43669ddf4..0d9dbc15b42d 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -1239,12 +1239,12 @@ namespace basegfx::utils const sal_uInt32 nPointCount(rCandidate.count()); const sal_uInt32 nDotDashCount(rDotDashArray.size()); -if(fTools::lessOrEqual(fDotDashLength, 0.0)) +if(fDotDashLength <= 0.0) { fDotDashLength = std::accumulate(rDotDashArray.begin(), rDotDashArray.end(), 0.0); } -if(fTools::lessOrEqual(fDotDashLength, 0.0) || (!rLineTargetCallback && !rGapTargetCallback) || !nPointCount) +if(fDotDashLength <= 0.0 || (!rLineTargetCallback && !rGapTargetCallback) || !nPointCount) { // parameters make no sense, just add source to targets if (rLineTargetCallback) @@ -2846,7 +2846,7 @@ namespace basegfx::utils { OSL_ENSURE(rOld1.count() == rOld2.count(), "B2DPolygon interpolate: Different geometry (!)"); -if(fTools::lessOrEqual(t, 0.0) || rOld1 == rOld2) +if(t <= 0.0 || rOld1 ==
core.git: basegfx/source chart2/source include/basegfx
basegfx/source/matrix/b3dhommatrix.cxx |5 - chart2/source/inc/ObjectIdentifier.hxx |1 - chart2/source/tools/ObjectIdentifier.cxx |5 - include/basegfx/matrix/b3dhommatrix.hxx |1 - 4 files changed, 12 deletions(-) New commits: commit dad0ea5c75445dc8ca316c4e5af1a9d6875699c1 Author: AkshayWarrier AuthorDate: Sat Jan 20 22:03:50 2024 +0530 Commit: Mike Kaganski CommitDate: Sun Jan 21 04:46:31 2024 +0100 tdf#157664 Drop operator != where respective == is defined Change-Id: I9eb0ea94f10126270f6e7c4433227ea60c21db79 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162336 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/basegfx/source/matrix/b3dhommatrix.cxx b/basegfx/source/matrix/b3dhommatrix.cxx index f9018c69793f..96edab9158b6 100644 --- a/basegfx/source/matrix/b3dhommatrix.cxx +++ b/basegfx/source/matrix/b3dhommatrix.cxx @@ -142,11 +142,6 @@ namespace basegfx return mpImpl->isEqual(*rMat.mpImpl); } -bool B3DHomMatrix::operator!=(const B3DHomMatrix& rMat) const -{ -return !(*this == rMat); -} - void B3DHomMatrix::rotate(double fAngleX,double fAngleY,double fAngleZ) { if(fTools::equalZero(fAngleX) && fTools::equalZero(fAngleY) && fTools::equalZero(fAngleZ)) diff --git a/chart2/source/inc/ObjectIdentifier.hxx b/chart2/source/inc/ObjectIdentifier.hxx index c6d0c724bd3c..aefbd4c8a6e7 100644 --- a/chart2/source/inc/ObjectIdentifier.hxx +++ b/chart2/source/inc/ObjectIdentifier.hxx @@ -105,7 +105,6 @@ public: ObjectIdentifier( const css::uno::Any& rAny ); bool operator==( const ObjectIdentifier& rOID ) const; -bool operator!=( const ObjectIdentifier& rOID ) const; bool operator<( const ObjectIdentifier& rOID ) const; static OUString createClassifiedIdentifierForObject( diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index 6e7631c8a9e4..0b071d7d4041 100644 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -259,11 +259,6 @@ bool ObjectIdentifier::operator==( const ObjectIdentifier& rOID ) const ( m_xAdditionalShape == rOID.m_xAdditionalShape ); } -bool ObjectIdentifier::operator!=( const ObjectIdentifier& rOID ) const -{ -return !operator==( rOID ); -} - bool ObjectIdentifier::operator<( const ObjectIdentifier& rOID ) const { bool bReturn = false; diff --git a/include/basegfx/matrix/b3dhommatrix.hxx b/include/basegfx/matrix/b3dhommatrix.hxx index 29603f88ebdb..773898ccf65e 100644 --- a/include/basegfx/matrix/b3dhommatrix.hxx +++ b/include/basegfx/matrix/b3dhommatrix.hxx @@ -99,7 +99,6 @@ namespace basegfx // comparison bool operator==(const B3DHomMatrix& rMat) const; -bool operator!=(const B3DHomMatrix& rMat) const; // multiplication, division by constant value B3DHomMatrix& operator*=(double fValue);
[Libreoffice-commits] core.git: basegfx/source include/basegfx
basegfx/source/polygon/b2dpolygon.cxx |5 - basegfx/source/polygon/b3dpolygon.cxx |5 - include/basegfx/polygon/b2dpolygon.hxx |1 - include/basegfx/polygon/b3dpolygon.hxx |1 - 4 files changed, 12 deletions(-) New commits: commit 47e06b18ede70f3496bc7da97e1761fe1dbf629c Author: Ankit_Jaipuriar AuthorDate: Tue Oct 10 19:33:31 2023 +0530 Commit: Ilmari Lauhakangas CommitDate: Fri Nov 3 07:48:19 2023 +0100 tdf#157664 Drop operator !=, where respective operator == is defined Change-Id: I88b25dd676fc57303978e3d5e875af129240b676 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157762 Tested-by: Jenkins Tested-by: Ilmari Lauhakangas Reviewed-by: Ilmari Lauhakangas diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx index ed5954bf0cf7..cf7309d20dd3 100644 --- a/basegfx/source/polygon/b2dpolygon.cxx +++ b/basegfx/source/polygon/b2dpolygon.cxx @@ -1116,11 +1116,6 @@ namespace basegfx return ((*mpPolygon) == (*rPolygon.mpPolygon)); } -bool B2DPolygon::operator!=(const B2DPolygon& rPolygon) const -{ -return !(*this == rPolygon); -} - sal_uInt32 B2DPolygon::count() const { return mpPolygon->count(); diff --git a/basegfx/source/polygon/b3dpolygon.cxx b/basegfx/source/polygon/b3dpolygon.cxx index c1ee4b08345a..ebd9e3f4f7ea 100644 --- a/basegfx/source/polygon/b3dpolygon.cxx +++ b/basegfx/source/polygon/b3dpolygon.cxx @@ -1413,11 +1413,6 @@ namespace basegfx return (*mpPolygon == *rPolygon.mpPolygon); } -bool B3DPolygon::operator!=(const B3DPolygon& rPolygon) const -{ -return !(*this == rPolygon); -} - sal_uInt32 B3DPolygon::count() const { return mpPolygon->count(); diff --git a/include/basegfx/polygon/b2dpolygon.hxx b/include/basegfx/polygon/b2dpolygon.hxx index 435ebf419cba..c63bda845d96 100644 --- a/include/basegfx/polygon/b2dpolygon.hxx +++ b/include/basegfx/polygon/b2dpolygon.hxx @@ -72,7 +72,6 @@ namespace basegfx /// compare operators bool operator==(const B2DPolygon& rPolygon) const; -bool operator!=(const B2DPolygon& rPolygon) const; /// member count sal_uInt32 count() const; diff --git a/include/basegfx/polygon/b3dpolygon.hxx b/include/basegfx/polygon/b3dpolygon.hxx index ea9ea2fdedcf..13f8ed293f59 100644 --- a/include/basegfx/polygon/b3dpolygon.hxx +++ b/include/basegfx/polygon/b3dpolygon.hxx @@ -58,7 +58,6 @@ namespace basegfx // compare operators bool operator==(const B3DPolygon& rPolygon) const; -bool operator!=(const B3DPolygon& rPolygon) const; // member count sal_uInt32 count() const;
[Libreoffice-commits] core.git: basegfx/source include/basegfx
basegfx/source/point/b2dpoint.cxx| 12 +++ basegfx/source/point/b3dpoint.cxx| 30 +- basegfx/source/vector/b2dvector.cxx | 38 +++ basegfx/source/vector/b3dvector.cxx | 18 +-- include/basegfx/color/bcolor.hxx | 44 +-- include/basegfx/point/b2dpoint.hxx | 12 +++ include/basegfx/point/b3dpoint.hxx | 18 +-- include/basegfx/tuple/Tuple2D.hxx| 49 +++--- include/basegfx/tuple/Tuple3D.hxx| 56 +-- include/basegfx/tuple/b2dtuple.hxx |2 - include/basegfx/tuple/b3dtuple.hxx | 52 include/basegfx/vector/b2dvector.hxx | 16 +- include/basegfx/vector/b3dvector.hxx | 30 +- 13 files changed, 177 insertions(+), 200 deletions(-) New commits: commit 347112fbd89ebd2a244052f14e085c9d3c90838d Author: Mike Kaganski AuthorDate: Sun Oct 8 13:14:39 2023 +0300 Commit: Mike Kaganski CommitDate: Sun Oct 8 18:53:00 2023 +0200 Drop temporary aliases from Tuple2D and Tuple3D Change-Id: I091b68bbeee74452a3d6a03711cfc482b7a78e1d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157685 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/basegfx/source/point/b2dpoint.cxx b/basegfx/source/point/b2dpoint.cxx index 1d7f75158526..d12c3dd04c4f 100644 --- a/basegfx/source/point/b2dpoint.cxx +++ b/basegfx/source/point/b2dpoint.cxx @@ -26,16 +26,16 @@ namespace basegfx B2DPoint& B2DPoint::operator*=( const ::basegfx::B2DHomMatrix& rMat ) { double fTempX( -rMat.get(0, 0) * mfX + -rMat.get(0, 1) * mfY + +rMat.get(0, 0) * mnX + +rMat.get(0, 1) * mnY + rMat.get(0, 2)); double fTempY( -rMat.get(1, 0) * mfX + -rMat.get(1, 1) * mfY + +rMat.get(1, 0) * mnX + +rMat.get(1, 1) * mnY + rMat.get(1, 2)); -mfX = fTempX; -mfY = fTempY; +mnX = fTempX; +mnY = fTempY; return *this; } diff --git a/basegfx/source/point/b3dpoint.cxx b/basegfx/source/point/b3dpoint.cxx index ff70b501ed7a..7d2d4cf4a22b 100644 --- a/basegfx/source/point/b3dpoint.cxx +++ b/basegfx/source/point/b3dpoint.cxx @@ -26,28 +26,28 @@ namespace basegfx B3DPoint& B3DPoint::operator*=( const ::basegfx::B3DHomMatrix& rMat ) { double fTempX( -rMat.get(0, 0) * mfX + -rMat.get(0, 1) * mfY + -rMat.get(0, 2) * mfZ + +rMat.get(0, 0) * mnX + +rMat.get(0, 1) * mnY + +rMat.get(0, 2) * mnZ + rMat.get(0, 3)); double fTempY( -rMat.get(1, 0) * mfX + -rMat.get(1, 1) * mfY + -rMat.get(1, 2) * mfZ + +rMat.get(1, 0) * mnX + +rMat.get(1, 1) * mnY + +rMat.get(1, 2) * mnZ + rMat.get(1, 3)); double fTempZ( -rMat.get(2, 0) * mfX + -rMat.get(2, 1) * mfY + -rMat.get(2, 2) * mfZ + +rMat.get(2, 0) * mnX + +rMat.get(2, 1) * mnY + +rMat.get(2, 2) * mnZ + rMat.get(2, 3)); if(!rMat.isLastLineDefault()) { const double fOne(1.0); const double fTempM( -rMat.get(3, 0) * mfX + -rMat.get(3, 1) * mfY + -rMat.get(3, 2) * mfZ + +rMat.get(3, 0) * mnX + +rMat.get(3, 1) * mnY + +rMat.get(3, 2) * mnZ + rMat.get(3, 3)); if(!fTools::equalZero(fTempM) && !fTools::equal(fOne, fTempM)) @@ -58,9 +58,9 @@ namespace basegfx } } -mfX = fTempX; -mfY = fTempY; -mfZ = fTempZ; +mnX = fTempX; +mnY = fTempY; +mnZ = fTempZ; return *this; } diff --git a/basegfx/source/vector/b2dvector.cxx b/basegfx/source/vector/b2dvector.cxx index d0fcebb62eac..85ec6ca81116 100644 --- a/basegfx/source/vector/b2dvector.cxx +++ b/basegfx/source/vector/b2dvector.cxx @@ -29,8 +29,8 @@ namespace basegfx if(fTools::equalZero(fLen)) { -mfX = 0.0; -mfY = 0.0; +mnX = 0.0; +mnY = 0.0; } else { @@ -42,8 +42,8 @@ namespace basegfx if(!fTools::equalZero(fLen)) { -mfX /= fLen; -mfY /= fLen; +mnX /= fLen; +mnY /= fLen; } } } @@ -53,22 +53,22 @@ namespace basegfx double B2DVector::getLength() const { -if(fTools::equalZero(mfX)) +if(fTools::equalZero(mnX)) { -return fabs(mfY); +return fabs(mnY); } -else if(fTools::equalZero
[Libreoffice-commits] core.git: basegfx/source include/basegfx
basegfx/source/polygon/b2dpolygontools.cxx | 51 +--- include/basegfx/polygon/b2dpolygontools.hxx |2 - 2 files changed, 40 insertions(+), 13 deletions(-) New commits: commit 9f4ccc63346b26d8d774b22124da0842ef18e0bc Author: Noel Grandin AuthorDate: Wed Sep 13 14:27:02 2023 +0200 Commit: Noel Grandin CommitDate: Wed Sep 13 15:42:37 2023 +0200 tdf#156995 speed up dragging complex group objects These shaves 20% of the time of the construction of the "drag view" object. Of course, it is still heinously slow. Change-Id: I4c6ee2d7e0cc2030a9966a281d2fdbe7f6859289 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156896 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index 04a22df578a6..56b286403671 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -475,7 +475,7 @@ namespace basegfx::utils return fRetval; } -double getLength(const B2DPolygon& rCandidate) +double getLength(const B2DPolygon& rCandidate, bool bApproximateBezierLength) { double fRetval(0.0); const sal_uInt32 nPointCount(rCandidate.count()); @@ -486,18 +486,45 @@ namespace basegfx::utils if(rCandidate.areControlPointsUsed()) { -B2DCubicBezier aEdge; -aEdge.setStartPoint(rCandidate.getB2DPoint(0)); +if (bApproximateBezierLength) +{ +B2DPoint aStartPoint = rCandidate.getB2DPoint(0); -for(sal_uInt32 a(0); a < nEdgeCount; a++) +for(sal_uInt32 a(0); a < nEdgeCount; a++) +{ +// An approximate length of a cubic Bezier curve is the average +// of its chord length and the sum of the lengths of its control net sides. +const sal_uInt32 nNextIndex((a + 1) % nPointCount); +const B2DPoint& aControlPoint1 = rCandidate.getNextControlPoint(a); +const B2DPoint& aControlPoint2 = rCandidate.getPrevControlPoint(nNextIndex); +const B2DPoint& aEndPoint = rCandidate.getB2DPoint(nNextIndex); + +double chord_length = B2DVector(aEndPoint - aStartPoint).getLength(); +double control_net_length = B2DVector(aStartPoint - aControlPoint1).getLength() ++ B2DVector(aControlPoint2 - aControlPoint1).getLength() ++ B2DVector(aEndPoint - aControlPoint2).getLength(); +double approximate_arc_length = (control_net_length + chord_length) / 2; + +fRetval += approximate_arc_length; +aStartPoint = aEndPoint; +} + +} +else { -const sal_uInt32 nNextIndex((a + 1) % nPointCount); - aEdge.setControlPointA(rCandidate.getNextControlPoint(a)); - aEdge.setControlPointB(rCandidate.getPrevControlPoint(nNextIndex)); -aEdge.setEndPoint(rCandidate.getB2DPoint(nNextIndex)); +B2DCubicBezier aEdge; +aEdge.setStartPoint(rCandidate.getB2DPoint(0)); -fRetval += aEdge.getLength(); -aEdge.setStartPoint(aEdge.getEndPoint()); +for(sal_uInt32 a(0); a < nEdgeCount; a++) +{ +const sal_uInt32 nNextIndex((a + 1) % nPointCount); + aEdge.setControlPointA(rCandidate.getNextControlPoint(a)); + aEdge.setControlPointB(rCandidate.getPrevControlPoint(nNextIndex)); + aEdge.setEndPoint(rCandidate.getB2DPoint(nNextIndex)); + +fRetval += aEdge.getLength(); +aEdge.setStartPoint(aEdge.getEndPoint()); +} } } else @@ -1236,9 +1263,9 @@ namespace basegfx::utils // precalculate maximal acceptable length of candidate polygon assuming // we want to create a maximum of fNumberOfAllowedSnippets. For // fNumberOfAllowedSnippets use ca. 65536, double due to line & gap. -static const double fNumberOfAllowedSnippets(65535.0 * 2.0); +static const double fNumberOfAllowedSnippets(100.0 * 2.0); const double fAllowedLength((fNumberOfAllowedSnippets * fDotDashLength) / double(rDotDashArray.size())); -const doub
[Libreoffice-commits] core.git: basegfx/source include/basegfx slideshow/source
basegfx/source/polygon/b2dpolygontools.cxx | 100 include/basegfx/polygon/b2dpolygontools.hxx | 19 + slideshow/source/engine/slideshowimpl.cxx | 38 +++--- 3 files changed, 144 insertions(+), 13 deletions(-) New commits: commit 44c0f2da567b49ef8a539958a834f1bc841c2003 Author: Regina Henschel AuthorDate: Thu Aug 17 19:30:56 2023 +0200 Commit: Regina Henschel CommitDate: Thu Aug 24 17:54:46 2023 +0200 tdf#112687 Simplify polylines from slideshow annotations Drawing with 'mouse as pen' in a slideshow creates hundreds of points. By commit 631964a2ce1da3fbbeb53a5550c0e6728ba644aa they are at least already combines to a polyline. The patch here now reduces the amount of points in such polyline to a reasonable number. If at some point the drawings in the slideshow are improved, this can be removed. The reduction is performed using the Douglas-Peucker algorithm. I have added the method to b2dpolygontools because I think it could be useful in other contexts. Change-Id: I9224ec3546d4442da8bc348aea8ce7b88fcc46dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155811 Tested-by: Jenkins Reviewed-by: Regina Henschel diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index 900ab735a1e0..04a22df578a6 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -18,6 +18,7 @@ */ #include #include +#include #include #include @@ -3574,6 +3575,105 @@ namespace basegfx::utils } } +B2DPolygon createSimplifiedPolygon(const B2DPolygon& rCandidate, const double fTolerance) +{ +const sal_uInt32 nPointCount(rCandidate.count()); +if (nPointCount < 3 || rCandidate.areControlPointsUsed()) +return rCandidate; + +// The solution does not use recursion directly, since this could lead to a stack overflow if +// nPointCount is very large. Instead, an own stack is used. This does not contain points, but +// pairs of low and high index of a range in rCandidate. A parallel boolean vector is used to note +// whether a point of rCandidate belongs to the output polygon or not. +std::vector bIsKeptVec(nPointCount, false); +bIsKeptVec[0] = true; +bIsKeptVec[nPointCount - 1] = true; +sal_uInt32 nKept = 2; +std::stack> aUnfinishedRangesStack; + +// The RDP algorithm draws a straight line from the first point to the last point of a range. +// Then, from the inner points of the range, the point that has the largest distance to the line +// is determined. If the distance is greater than the tolerance, this point is kept and the lower +// and upper sub-segments of the range are treated in the same way. If the distance is smaller +// than the tolerance, none of the inner points will be kept. +sal_uInt32 nLowIndex = 0; +sal_uInt32 nHighIndex = nPointCount - 1; +bool bContinue = true; +do +{ +bContinue = false; +if (nHighIndex - nLowIndex < 2) // maximal two points, range is finished. +{ +// continue with sibling upper range if any +if (!aUnfinishedRangesStack.empty()) +{ +std::pair aIndexPair = aUnfinishedRangesStack.top(); +aUnfinishedRangesStack.pop(); +nLowIndex = aIndexPair.first; +nHighIndex = aIndexPair.second; +bContinue = true; +} +} +else // the range needs examine the max distance +{ +// Get maximal distance of inner points of the range to the straight line from start to +// end point of the range. +// For calculation of the distance we use the Hesse normal form of the straight line. +B2DPoint aLowPoint = rCandidate.getB2DPoint(nLowIndex); +B2DPoint aHighPoint = rCandidate.getB2DPoint(nHighIndex); +B2DVector aNormalVec += basegfx::getNormalizedPerpendicular(B2DVector(aHighPoint) - B2DVector(aLowPoint)); +double fLineOriginDistance = aNormalVec.scalar(B2DVector(aLowPoint)); +double fMaxDist = 0; +sal_uInt32 nMaxPointIndex = nLowIndex; +for (sal_uInt32 i = nLowIndex + 1; i < nHighIndex; i++) +{ +double fDistance += aNormalVec.scalar(B2DVector(rCandidate.getB2DPoint(i))) - fLineOriginDistance; +if (std::fabs(fDistance) > fMaxDist) +{ +fMaxDist = std::fabs(fDistance); +nMaxPointIndex = i; +} +} + +if (fMaxDist >= fTolerance) +{ +// We need to divide the current range into two sub ranges. +bIsKeptVec[nMaxPointIndex] = true; +nKept++; +// continue
[Libreoffice-commits] core.git: basegfx/source chart2/import_setup.mk chart2/Library_chartcontroller.mk chart2/qa chart2/source docmodel/Library_docmodel.mk docmodel/source include/basegfx include/doc
basegfx/source/tools/bgradient.cxx | 167 - chart2/Library_chartcontroller.mk |3 chart2/import_setup.mk |1 chart2/qa/extras/chart2import.cxx |5 chart2/source/controller/main/ChartController_Tools.cxx |4 docmodel/Library_docmodel.mk|2 docmodel/source/uno/UnoGradientTools.cxx| 200 include/basegfx/utils/bgradient.hxx | 22 - include/docmodel/uno/UnoGradientTools.hxx | 33 ++ oox/qa/unit/drawingml.cxx |4 oox/qa/unit/shape.cxx | 23 + oox/source/drawingml/fillproperties.cxx |5 oox/source/drawingml/fontworkhelpers.cxx|5 oox/source/export/chartexport.cxx | 13 - oox/source/export/drawingml.cxx | 12 sd/CppunitTest_sd_misc_tests.mk |1 sd/export_setup.mk |1 sd/qa/unit/export-tests-ooxml1.cxx |7 sd/qa/unit/export-tests-ooxml2.cxx |4 sd/qa/unit/export-tests-ooxml3.cxx |7 sd/qa/unit/import-tests.cxx |1 sd/qa/unit/import-tests2.cxx|1 sd/qa/unit/misc-tests.cxx |6 svx/source/unodraw/XPropertyTable.cxx | 24 - svx/source/xoutdev/xattr.cxx| 17 - sw/CppunitTest_sw_odfexport.mk |1 sw/qa/extras/odfexport/odfexport.cxx|5 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx |5 sw/qa/extras/rtfexport/rtfexport.cxx|5 sw/rtfexport_setup.mk |1 xmloff/source/style/GradientStyle.cxx |3 xmloff/source/style/TransGradientStyle.cxx |3 32 files changed, 329 insertions(+), 262 deletions(-) New commits: commit 242bb3fdda5be165bd00701518df47cc1276438f Author: Tomaž Vajngerl AuthorDate: Wed Aug 9 13:27:49 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Mon Aug 21 09:27:12 2023 +0200 move BGradient to awt::Gradient2 UNO conversion into docmodel This is needed because the module dependencies are an issues if the conversion is done in basegfx. The bigger issue will come when the ComplexColor conversion will be done as basegfx can't depend on docmodel because of circular dependencies. The BGradient is also more suitable for docmodel anyway as the previously it was part of the model and is not a basic (gfx) type - however this doesn't move the whole BGradient into docmodel yet. Change-Id: Id91ce52232f89f00e09b451c13da36e2854ae14b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155674 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index 7b62a19c9ad6..86e1812d21ac 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -68,41 +68,6 @@ basegfx::BGradient lcl_buildGradientFromStringMap(StringMap& rMap) namespace basegfx { -void BColorStops::setColorStopSequence(const css::awt::ColorStopSequence& rColorStops) -{ -const sal_Int32 nLen(rColorStops.getLength()); - -if (0 != nLen) -{ -// we have ColorStops -reserve(nLen); -const css::awt::ColorStop* pSourceColorStop(rColorStops.getConstArray()); - -for (sal_Int32 a(0); a < nLen; a++, pSourceColorStop++) -{ -emplace_back(pSourceColorStop->StopOffset, - BColor(pSourceColorStop->StopColor.Red, pSourceColorStop->StopColor.Green, -pSourceColorStop->StopColor.Blue)); -} -} -} - -BColorStops::BColorStops(const css::awt::ColorStopSequence& rColorStops) -{ -setColorStopSequence(rColorStops); -} - -BColorStops::BColorStops(const css::uno::Any& rVal) -{ -if (rVal.has()) -{ -// we can use awt::ColorStopSequence -css::awt::ColorStopSequence aColorStopSequence; -rVal >>= aColorStopSequence; -setColorStopSequence(aColorStopSequence); -} -} - // constructor with two colors to explicitly create a // BColorStops for a single StartColor @0.0 & EndColor @1.0 BColorStops::BColorStops(const BColor& rStart, const BColor& rEnd) @@ -498,28 +463,6 @@ bool BColorStops::checkPenultimate() const return true; } -/* Tooling method to fill a awt::ColorStopSequence with -the data from the given ColorStops. This is used in -UNO API implementations. -*/ -css::awt::ColorStopSequence BColorStops::getAsColorStopSequence() const -{ -css::awt::Colo
[Libreoffice-commits] core.git: basegfx/source compilerplugins/clang emfio/source sd/source toolkit/source vcl/source
basegfx/source/polygon/b2dsvgpolypolygon.cxx|4 ++-- compilerplugins/clang/redundantcast.cxx |9 + compilerplugins/clang/test/redundantcast.cxx| 12 emfio/source/reader/mtftools.cxx|2 +- sd/source/ui/dlg/animobjs.cxx |2 +- sd/source/ui/dlg/titledockwin.cxx |2 +- toolkit/source/controls/table/gridtablerenderer.cxx |2 +- vcl/source/window/window.cxx|2 +- 8 files changed, 28 insertions(+), 7 deletions(-) New commits: commit 1f2ff4a0a31c7919bc6d4e0ac63024252f0bd889 Author: Noel Grandin AuthorDate: Thu Jul 20 15:55:59 2023 +0200 Commit: Noel Grandin CommitDate: Fri Jul 21 11:05:05 2023 +0200 loplugin:redundantcast small improvement Change-Id: I2c96b367138b94d6178a3c4a0f83049f13a04f82 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154679 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx b/basegfx/source/polygon/b2dsvgpolypolygon.cxx index 6bb34614c6ae..fe4f646eb3ba 100644 --- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx +++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx @@ -272,7 +272,7 @@ namespace basegfx::utils // get first control point. It's the reflection of the PrevControlPoint // of the last point. If not existent, use current point (see SVG) -B2DPoint aPrevControl(B2DPoint(nLastX, nLastY)); +B2DPoint aPrevControl(nLastX, nLastY); const sal_uInt32 nIndex(aCurrPoly.count() - 1); if(aCurrPoly.areControlPointsUsed() && aCurrPoly.isPrevControlPointUsed(nIndex)) @@ -421,7 +421,7 @@ namespace basegfx::utils // get first control point. It's the reflection of the PrevControlPoint // of the last point. If not existent, use current point (see SVG) -B2DPoint aPrevControl(B2DPoint(nLastX, nLastY)); +B2DPoint aPrevControl(nLastX, nLastY); const sal_uInt32 nIndex(aCurrPoly.count() - 1); const B2DPoint aPrevPoint(aCurrPoly.getB2DPoint(nIndex)); diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index 80485e0e9bd6..eea609005228 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -373,6 +373,15 @@ bool RedundantCast::VisitVarDecl(VarDecl const * varDecl) { if (!varDecl->getInit()) return true; visitAssign(varDecl->getType(), varDecl->getInit()); +if (varDecl->getInitStyle() != VarDecl::CInit +&& isa(varDecl->getInit()) +&& !compiler.getSourceManager().isMacroBodyExpansion(varDecl->getInit()->getBeginLoc())) +{ +report( +DiagnosticsEngine::Warning, "redundant functional cast", +varDecl->getBeginLoc()) +<< varDecl->getSourceRange(); +} return true; } diff --git a/compilerplugins/clang/test/redundantcast.cxx b/compilerplugins/clang/test/redundantcast.cxx index 0c1087ab32af..f3573d0ad20d 100644 --- a/compilerplugins/clang/test/redundantcast.cxx +++ b/compilerplugins/clang/test/redundantcast.cxx @@ -473,6 +473,18 @@ void testSalIntTypes() { (void) static_cast(n); // doesn't warn either } +void testFunctionalCast2() { +struct S1 { S1(int, int, int, int) {} }; + +// expected-error@+1 {{redundant functional cast [loplugin:redundantcast]}} +S1 aTitleBarBox(S1(0, 0, 0, 0)); +(void)aTitleBarBox; + +// no warning expected +#define S1_COL S1(0,0,0,0) +S1 aTest2(S1_COL); +} + int main() { testConstCast(); testStaticCast(); diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index f2446e1864de..0ba13d49727a 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -256,7 +256,7 @@ namespace emfio aFont.SetOrientation( Degree10(static_cast(rFont.lfEscapement)) ); -Size aFontSize( Size( rFont.lfWidth, rFont.lfHeight ) ); +Size aFontSize( rFont.lfWidth, rFont.lfHeight ); if ( rFont.lfHeight > 0 ) { // #i117968# VirtualDevice is not thread safe, but filter is used in multithreading diff --git a/sd/source/ui/dlg/animobjs.cxx b/sd/source/ui/dlg/animobjs.cxx index 9abb892e037c..0174855e1825 100644 --- a/sd/source/ui/dlg/animobjs.cxx +++ b/sd/source/ui/dlg/animobjs.cxx @@ -516,7 +516,7 @@ void AnimationWindow::UpdateControl(bool const bDisableCtrls) ScopedVclPtrInstance< VirtualDevice > pVD; ::tools::Rectangle aObjRect( pObject->GetCurrentBoundRect() ); SizeaObjSize( aObjRect.GetSize() ); -Point
[Libreoffice-commits] core.git: basegfx/source canvas/source include/basegfx include/vcl slideshow/source
basegfx/source/tools/canvastools.cxx | 12 - canvas/source/cairo/cairo_canvasbitmap.cxx |4 canvas/source/cairo/cairo_canvashelper.cxx | 12 - canvas/source/cairo/cairo_devicehelper.cxx | 10 - canvas/source/cairo/cairo_spritecanvashelper.cxx | 28 +-- canvas/source/cairo/cairo_spritedevicehelper.cxx |6 canvas/source/directx/dx_9rm.cxx | 92 -- canvas/source/directx/dx_bitmap.cxx| 18 - canvas/source/directx/dx_bitmap.hxx| 10 - canvas/source/directx/dx_bitmapcanvashelper.cxx|1 canvas/source/directx/dx_canvasbitmap.cxx | 42 ++-- canvas/source/directx/dx_canvascustomsprite.cxx|2 canvas/source/directx/dx_canvashelper.cxx |4 canvas/source/directx/dx_ibitmap.hxx |2 canvas/source/directx/dx_rendermodule.hxx |2 canvas/source/directx/dx_spritedevicehelper.cxx|2 canvas/source/directx/dx_surfacebitmap.cxx | 52 ++--- canvas/source/directx/dx_surfacebitmap.hxx |8 canvas/source/directx/dx_textlayout_drawhelper.cxx |4 canvas/source/tools/page.cxx | 11 - canvas/source/tools/page.hxx |3 canvas/source/tools/pagemanager.cxx|7 canvas/source/tools/surface.cxx| 36 +-- canvas/source/tools/surfaceproxy.cxx | 16 - canvas/source/tools/surfacerect.hxx| 16 - include/basegfx/tuple/Size2D.hxx |2 include/basegfx/utils/canvastools.hxx |5 include/basegfx/vector/b2dsize.hxx | 12 + include/basegfx/vector/b2isize.hxx | 38 +++- include/vcl/outdev.hxx |2 slideshow/source/engine/slide/slideimpl.cxx| 11 - slideshow/source/engine/slideshowimpl.cxx |5 slideshow/source/engine/tools.cxx |8 slideshow/source/engine/transitions/combtransition.cxx |4 slideshow/source/engine/transitions/slidechangebase.cxx| 20 +- slideshow/source/engine/transitions/slidetransitionfactory.cxx |6 slideshow/source/inc/tools.hxx |2 37 files changed, 271 insertions(+), 244 deletions(-) New commits: commit f896bbcffeccd27248f908d2628d03dddf83ea94 Author: Tomaž Vajngerl AuthorDate: Wed Sep 21 12:17:00 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Thu Jul 13 13:19:00 2023 +0200 basegfx: replace typedef with a class B2ISize based on Size2D Change-Id: Iaf7d02bb236f81a38a67a1430a718b6c3c78efae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139708 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/basegfx/source/tools/canvastools.cxx b/basegfx/source/tools/canvastools.cxx index d388356199a2..70f4787710ad 100644 --- a/basegfx/source/tools/canvastools.cxx +++ b/basegfx/source/tools/canvastools.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -427,16 +428,15 @@ namespace basegfx::unotools rRect.Z2); } -geometry::IntegerSize2D integerSize2DFromB2ISize( const ::basegfx::B2IVector& rSize ) +geometry::IntegerSize2D integerSize2DFromB2ISize( const ::basegfx::B2ISize& rSize ) { -return geometry::IntegerSize2D( rSize.getX(), -rSize.getY() ); +return geometry::IntegerSize2D( rSize.getWidth(), +rSize.getHeight() ); } -::basegfx::B2IVector b2ISizeFromIntegerSize2D( const geometry::IntegerSize2D& rSize ) +basegfx::B2ISize b2ISizeFromIntegerSize2D( const geometry::IntegerSize2D& rSize ) { -return ::basegfx::B2IVector( rSize.Width, - rSize.Height ); +return basegfx::B2ISize(rSize.Width, rSize.Height); } ::basegfx::B2IRange b2IRectangleFromIntegerRectangle2D( const geometry::IntegerRectangle2D& rRectangle ) diff --git a/canvas/source/cairo/cairo_canvasbitmap.cxx b/canvas/source/cairo/cairo_canvasbitmap.cxx index ebf4f26c5321..9f18be80824a 100644 --- a/canvas/source/cairo/cairo_canvasbitmap.cxx +++ b/canvas/source/cairo/cairo_canvasbitmap.cxx @@ -48,7 +48,7 @@ namespace cairocanvas SAL_INFO( "canvas.cairo", -"bitmap size: " << rSize.getX() << "x" << rSize
[Libreoffice-commits] core.git: basegfx/source basegfx/test include/basegfx svgio/inc svgio/source
basegfx/source/color/bcolormodifier.cxx | 40 +++--- basegfx/test/BColorModifierTest.cxx | 88 +--- include/basegfx/color/bcolormodifier.hxx|6 - svgio/inc/svgtools.hxx |3 svgio/source/svgreader/svgfecolormatrixnode.cxx |4 - svgio/source/svgreader/svgtools.cxx | 26 +-- 6 files changed, 92 insertions(+), 75 deletions(-) New commits: commit fa61e8b220aa1f34b022b9af485f0209b2cb25d1 Author: Xisco Fauli AuthorDate: Mon Jul 10 11:52:30 2023 +0200 Commit: Xisco Fauli CommitDate: Mon Jul 10 13:52:56 2023 +0200 tdf#99562: Do not ignore last column from matrix Change-Id: I1dff65963e2c414d1771a1592159930150c513e0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154241 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/basegfx/source/color/bcolormodifier.cxx b/basegfx/source/color/bcolormodifier.cxx index 4d3f277c6cc5..75c06f5cb8f3 100644 --- a/basegfx/source/color/bcolormodifier.cxx +++ b/basegfx/source/color/bcolormodifier.cxx @@ -155,23 +155,41 @@ namespace basegfx return false; } -return maMatrix == pCompare->maMatrix; +return maVector == pCompare->maVector; } ::basegfx::BColor BColorModifier_matrix::getModifiedColor(const ::basegfx::BColor& aSourceColor) const { -basegfx::B3DHomMatrix aColorMatrix; -aColorMatrix.set(0, 0, aSourceColor.getRed()); -aColorMatrix.set(1, 0, aSourceColor.getGreen()); -aColorMatrix.set(2, 0, aSourceColor.getBlue()); -aColorMatrix.set(3, 0, 1.0); -// TODO: add support for alpha +if (maVector.size() != 20) +return aSourceColor; + +const double aRed = maVector[0] * aSourceColor.getRed() ++ maVector[1] * aSourceColor.getGreen() ++ maVector[2] * aSourceColor.getBlue() ++ maVector[3] * 1.0 ++ maVector[4]; +const double aGreen = maVector[5] * aSourceColor.getRed() ++ maVector[6] * aSourceColor.getGreen() ++ maVector[7] * aSourceColor.getBlue() ++ maVector[8] * 1.0 ++ maVector[9]; +const double aBlue = maVector[10] * aSourceColor.getRed() ++ maVector[11] * aSourceColor.getGreen() ++ maVector[12] * aSourceColor.getBlue() ++ maVector[13] * 1.0 ++ maVector[14]; +/*TODO: add support for alpha +const double aAlpha = maVector[15] * aSourceColor.getRed() ++ maVector[16] * aSourceColor.getGreen() ++ maVector[17] * aSourceColor.getBlue() ++ maVector[18] * 1.0 ++ maVector[19]); +*/ -aColorMatrix = maMatrix * aColorMatrix; return ::basegfx::BColor( -std::clamp(aColorMatrix.get(0, 0), 0.0, 1.0), -std::clamp(aColorMatrix.get(1, 0), 0.0, 1.0), -std::clamp(aColorMatrix.get(2, 0), 0.0, 1.0)); +std::clamp(aRed, 0.0, 1.0), +std::clamp(aGreen, 0.0, 1.0), +std::clamp(aBlue, 0.0, 1.0)); } OUString BColorModifier_matrix::getModifierName() const diff --git a/basegfx/test/BColorModifierTest.cxx b/basegfx/test/BColorModifierTest.cxx index 237f6a982266..4a84c3662a6b 100755 --- a/basegfx/test/BColorModifierTest.cxx +++ b/basegfx/test/BColorModifierTest.cxx @@ -272,26 +272,15 @@ public: void testMatrix() { // green matrix -basegfx::B3DHomMatrix aMatrix; -aMatrix.set(0, 0, 0.0); -aMatrix.set(0, 1, 0.0); -aMatrix.set(0, 2, 0.0); -aMatrix.set(0, 3, 0.0); -aMatrix.set(1, 0, 1.0); -aMatrix.set(1, 1, 1.0); -aMatrix.set(1, 2, 1.0); -aMatrix.set(1, 3, 1.0); -aMatrix.set(2, 0, 0.0); -aMatrix.set(2, 1, 0.0); -aMatrix.set(2, 2, 0.0); -aMatrix.set(2, 3, 0.0); -aMatrix.set(3, 0, 0.0); -aMatrix.set(3, 1, 0.0); -aMatrix.set(3, 2, 0.0); -aMatrix.set(3, 3, 1.0); +// clang-format off +std::vector aVector = {0.0, 0.0, 0.0, 0.0, 0.0, + 1.0, 1.0, 1.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 1.0, 0.0}; +// clang-format on const basegfx::BColorModifierSharedPtr aBColorModifier -= std::make_shared(aMatrix); += std::make_shared(aVector); CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maWhite)); CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maGray)); @@ -310,32 +299,54 @@ public: CPPUNIT_ASSERT(*aBColorModifier != *aBColorModifierInvert); const basegfx::BColorModifierSharedPtr aBColorModifier2 -= std::make_shared(aMatrix); += std::make_shared(aVector); +CPPU
[Libreoffice-commits] core.git: basegfx/source basegfx/test
basegfx/source/color/bcolormodifier.cxx |6 +- basegfx/test/BColorModifierTest.cxx | 17 ++--- 2 files changed, 11 insertions(+), 12 deletions(-) New commits: commit 22e46544eebe027654bb4ecfc42e8d8ebb41ec48 Author: Xisco Fauli AuthorDate: Fri Jul 7 14:44:00 2023 +0200 Commit: Xisco Fauli CommitDate: Fri Jul 7 17:50:28 2023 +0200 related: tdf#155735: clamp RGB values So when a green matrix is used, everything becomes green. Also set alpha to 1.0 so at least a green matrix on black returns green and not black Change-Id: I9104c7511545fb244750b066bb1e996b6ce229f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154167 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/basegfx/source/color/bcolormodifier.cxx b/basegfx/source/color/bcolormodifier.cxx index 9c9a196bb7f8..4d3f277c6cc5 100644 --- a/basegfx/source/color/bcolormodifier.cxx +++ b/basegfx/source/color/bcolormodifier.cxx @@ -164,10 +164,14 @@ namespace basegfx aColorMatrix.set(0, 0, aSourceColor.getRed()); aColorMatrix.set(1, 0, aSourceColor.getGreen()); aColorMatrix.set(2, 0, aSourceColor.getBlue()); +aColorMatrix.set(3, 0, 1.0); // TODO: add support for alpha aColorMatrix = maMatrix * aColorMatrix; -return ::basegfx::BColor(aColorMatrix.get(0, 0), aColorMatrix.get(1, 0), aColorMatrix.get(2, 0)); +return ::basegfx::BColor( +std::clamp(aColorMatrix.get(0, 0), 0.0, 1.0), +std::clamp(aColorMatrix.get(1, 0), 0.0, 1.0), +std::clamp(aColorMatrix.get(2, 0), 0.0, 1.0)); } OUString BColorModifier_matrix::getModifierName() const diff --git a/basegfx/test/BColorModifierTest.cxx b/basegfx/test/BColorModifierTest.cxx index 3a08958018da..237f6a982266 100755 --- a/basegfx/test/BColorModifierTest.cxx +++ b/basegfx/test/BColorModifierTest.cxx @@ -293,21 +293,16 @@ public: const basegfx::BColorModifierSharedPtr aBColorModifier = std::make_shared(aMatrix); -BColor aExpectedWhite(0.0, 3.0, 0.0); -CPPUNIT_ASSERT_EQUAL(aExpectedWhite, aBColorModifier->getModifiedColor(maWhite)); -BColor aExpectedGray(0.0, 1.5, 0.0); -CPPUNIT_ASSERT_EQUAL(aExpectedGray, aBColorModifier->getModifiedColor(maGray)); -CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maBlack)); +CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maWhite)); +CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maGray)); +CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maBlack)); CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maRed)); CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maGreen)); CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maBlue)); -BColor aExpectedYellow(0.0, 2.0, 0.0); -CPPUNIT_ASSERT_EQUAL(aExpectedYellow, aBColorModifier->getModifiedColor(maYellow)); -BColor aExpectedMagenta = aExpectedYellow; -CPPUNIT_ASSERT_EQUAL(aExpectedMagenta, aBColorModifier->getModifiedColor(maMagenta)); -BColor aExpectedCyan = aExpectedYellow; -CPPUNIT_ASSERT_EQUAL(aExpectedCyan, aBColorModifier->getModifiedColor(maCyan)); +CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maYellow)); +CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maMagenta)); +CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maCyan)); CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier)); const basegfx::BColorModifierSharedPtr aBColorModifierInvert
[Libreoffice-commits] core.git: basegfx/source comphelper/source include/basegfx include/comphelper include/svx oox/source svx/source
basegfx/source/polygon/b2dlinegeometry.cxx| 23 ++- comphelper/source/property/propmultiplex2.cxx | 10 +++--- include/basegfx/polygon/b2dlinegeometry.hxx |3 +-- include/comphelper/propmultiplex2.hxx |4 +--- include/svx/svdotable.hxx |2 +- oox/source/drawingml/shape.cxx|2 +- svx/source/table/svdotable.cxx|4 ++-- 7 files changed, 15 insertions(+), 33 deletions(-) New commits: commit 203476b6676505acafd1c41561800afd9316a0f6 Author: Noel Grandin AuthorDate: Tue Jul 4 16:12:19 2023 +0200 Commit: Noel Grandin CommitDate: Tue Jul 4 20:19:06 2023 +0200 loplugin:constantparam Change-Id: Iee554baae7239c9bf0ac35cab6ff235a88dc29a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153973 Tested-by: Noel Grandin Reviewed-by: Noel Grandin diff --git a/basegfx/source/polygon/b2dlinegeometry.cxx b/basegfx/source/polygon/b2dlinegeometry.cxx index 6dda8f9e7e1f..37c7cfc172d2 100644 --- a/basegfx/source/polygon/b2dlinegeometry.cxx +++ b/basegfx/source/polygon/b2dlinegeometry.cxx @@ -848,8 +848,7 @@ namespace basegfx css::drawing::LineCap eCap, double fMaxAllowedAngle, double fMaxPartOfEdge, -double fMiterMinimumAngle, -basegfx::triangulator::B2DTriangleVector* pTriangles) +double fMiterMinimumAngle) { if(fMaxAllowedAngle > M_PI_2) { @@ -959,7 +958,7 @@ namespace basegfx fHalfLineWidth, eJoin, fMiterMinimumAngle, -pTriangles)); +nullptr)); } else if(aOrientation == B2VectorOrientation::Negative) { @@ -976,7 +975,7 @@ namespace basegfx fHalfLineWidth, eJoin, fMiterMinimumAngle, -pTriangles)); +nullptr)); } } @@ -995,7 +994,7 @@ namespace basegfx bLast && eCap == css::drawing::LineCap_ROUND, bFirst && eCap == css::drawing::LineCap_SQUARE, bLast && eCap == css::drawing::LineCap_SQUARE, -pTriangles)); +nullptr)); } else { @@ -1007,7 +1006,7 @@ namespace basegfx false, false, false, -pTriangles)); +nullptr)); } // prepare next step @@ -1030,17 +1029,7 @@ namespace basegfx aCandidate.getB2DPoint(0), fHalfLineWidth)); -if(nullptr != pTriangles) -{ -const basegfx::triangulator::B2DTriangleVector aResult( -basegfx::triangulator::triangulate( -aCircle)); -pTriangles->insert(pTriangles->end(), aResult.begin(), aResult.end()); -} -else -{ -aRetval.append(aCircle); -} +aRetval.append(aCircle); } return aRetval; diff --git a/comphelper/source/property/propmultiplex2.cxx b/comphelper/source/property/propmultiplex2.cxx index 16c06c3bc1f9..b9d7719c4e1d 100644 --- a/comphelper/source/property/propmultiplex2.cxx +++ b/comphelper/source/property/propmultiplex2.cxx @@ -51,14 +51,12 @@ void OPropertyChangeListener2::setAdapter(std::unique_lock& /*rGuard OPropertyChangeMultiplexer2::OPropertyChangeMultiplexer2(std::mutex& rMutex, std::unique_lock& rGuard, OPropertyChangeListener2* _pListener, - const Reference& _rxSet, - bool _bAutoReleaseSet) + const Reference& _rxSet) : m_rMutex(rMutex) , m_xSet(_rxSet) , m_pListener(_pListener) , m_nLockCount(0) , m_bListening(false) -, m_bAutoSetRelease(_bAutoReleaseSet) { m_pListener->setAdapter(rGuard, this); } @@ -84,8 +82,7 @@ void
[Libreoffice-commits] core.git: basegfx/source basegfx/test include/basegfx svgio/inc svgio/qa svgio/source
basegfx/source/color/bcolormodifier.cxx | 19 --- basegfx/test/BColorModifierTest.cxx | 27 include/basegfx/color/bcolormodifier.hxx | 20 svgio/inc/svgfecolormatrixnode.hxx |2 - svgio/inc/svgfegaussianblurnode.hxx |2 - svgio/inc/svgfilternode.hxx |6 --- svgio/qa/cppunit/SvgImportTest.cxx |3 - svgio/qa/cppunit/data/filterFeGaussianBlur.svg |2 - svgio/source/svgreader/svgfecolormatrixnode.cxx | 21 - svgio/source/svgreader/svgfegaussianblurnode.cxx | 37 ++- 10 files changed, 6 insertions(+), 133 deletions(-) New commits: commit 9951ffedd6941234447b9655fbc49ed6ca4cc64c Author: Xisco Fauli AuthorDate: Mon Jun 26 22:16:12 2023 +0200 Commit: Xisco Fauli CommitDate: Mon Jun 26 23:15:03 2023 +0200 Revert "tdf#132246, tdf#155735: Add support for SourceAlpha" This reverts commit 75399b8aad6c0f0998b9d0a6eddb2e29f8bc114c. it was incomplete. While at it, do not parse 'in' attribute for now, so only in="SourceGraphic" is used. Implementing the 'in' attribute is not trivial Change-Id: I66c721c1144638f5e3759e0aa3a1c2c062499a90 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153627 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/basegfx/source/color/bcolormodifier.cxx b/basegfx/source/color/bcolormodifier.cxx index 1ed19a4003eb..9c9a196bb7f8 100644 --- a/basegfx/source/color/bcolormodifier.cxx +++ b/basegfx/source/color/bcolormodifier.cxx @@ -69,25 +69,6 @@ namespace basegfx return "invert"; } -BColorModifier_alpha::~BColorModifier_alpha() -{ -} - -bool BColorModifier_alpha::operator==(const BColorModifier& rCompare) const -{ -return dynamic_cast< const BColorModifier_alpha* >(&rCompare) != nullptr; -} - -::basegfx::BColor BColorModifier_alpha::getModifiedColor(const ::basegfx::BColor& /*aSourceColor*/) const -{ -return ::basegfx::BColor(0.0, 0.0, 0.0); -} - -OUString BColorModifier_alpha::getModifierName() const -{ -return "alpha"; -} - BColorModifier_luminance_to_alpha::~BColorModifier_luminance_to_alpha() { } diff --git a/basegfx/test/BColorModifierTest.cxx b/basegfx/test/BColorModifierTest.cxx index 5ada0a33ddf9..3a08958018da 100755 --- a/basegfx/test/BColorModifierTest.cxx +++ b/basegfx/test/BColorModifierTest.cxx @@ -389,32 +389,6 @@ public: CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2)); } -void testAlpha() -{ -const basegfx::BColorModifierSharedPtr aBColorModifier -= std::make_shared(); - -CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maWhite)); -CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maGray)); -CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maBlack)); - -CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maRed)); -CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maGreen)); -CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maBlue)); -CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maYellow)); -CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maMagenta)); -CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maCyan)); - -CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier)); -const basegfx::BColorModifierSharedPtr aBColorModifierInvert -= std::make_shared(); -CPPUNIT_ASSERT(*aBColorModifier != *aBColorModifierInvert); - -const basegfx::BColorModifierSharedPtr aBColorModifier2 -= std::make_shared(); -CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2)); -} - CPPUNIT_TEST_SUITE(bcolormodifier); CPPUNIT_TEST(testGray); CPPUNIT_TEST(testInvert); @@ -426,7 +400,6 @@ public: CPPUNIT_TEST(testMatrix); CPPUNIT_TEST(testIdentityMatrix); CPPUNIT_TEST(testBlackAndWhite); -CPPUNIT_TEST(testAlpha); CPPUNIT_TEST_SUITE_END(); }; diff --git a/include/basegfx/color/bcolormodifier.hxx b/include/basegfx/color/bcolormodifier.hxx index 37c6a5b9e2f3..6eb40b67e9d7 100644 --- a/include/basegfx/color/bcolormodifier.hxx +++ b/include/basegfx/color/bcolormodifier.hxx @@ -126,26 +126,6 @@ namespace basegfx SAL_DLLPRIVATE virtual OUString getModifierName() const override; }; -/** - * convert to alpha -*/ -class SAL_WARN_UNUSED BASEGFX_DLLPUBLIC BColorModifier_alpha final : public BColorModifier -{ -public: -BColorModifier_alpha() -{ -} - -virtual ~BColorModifier_alpha() override; - -// compare operator -SAL_DLLPRIVATE virtual bool operator==(const BColorModifier& r
[Libreoffice-commits] core.git: basegfx/source basegfx/test
basegfx/source/color/bcolormodifier.cxx |1 + basegfx/test/BColorModifierTest.cxx | 11 +++ 2 files changed, 12 insertions(+) New commits: commit 99b1459dbbe5faa47b5fc9b4ed767932d46a02cb Author: Xisco Fauli AuthorDate: Sun Jun 25 19:45:33 2023 +0200 Commit: Xisco Fauli CommitDate: Sun Jun 25 23:05:34 2023 +0200 tdf#155735: use 4x4 matrices in tests Change-Id: I7258443036eb89e7a67fce2a683f3212972a7395 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153565 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/basegfx/source/color/bcolormodifier.cxx b/basegfx/source/color/bcolormodifier.cxx index 52f34a69f205..1ed19a4003eb 100644 --- a/basegfx/source/color/bcolormodifier.cxx +++ b/basegfx/source/color/bcolormodifier.cxx @@ -183,6 +183,7 @@ namespace basegfx aColorMatrix.set(0, 0, aSourceColor.getRed()); aColorMatrix.set(1, 0, aSourceColor.getGreen()); aColorMatrix.set(2, 0, aSourceColor.getBlue()); +// TODO: add support for alpha aColorMatrix = maMatrix * aColorMatrix; return ::basegfx::BColor(aColorMatrix.get(0, 0), aColorMatrix.get(1, 0), aColorMatrix.get(2, 0)); diff --git a/basegfx/test/BColorModifierTest.cxx b/basegfx/test/BColorModifierTest.cxx index 5a4b941e1c44..5ada0a33ddf9 100755 --- a/basegfx/test/BColorModifierTest.cxx +++ b/basegfx/test/BColorModifierTest.cxx @@ -285,6 +285,10 @@ public: aMatrix.set(2, 1, 0.0); aMatrix.set(2, 2, 0.0); aMatrix.set(2, 3, 0.0); +aMatrix.set(3, 0, 0.0); +aMatrix.set(3, 1, 0.0); +aMatrix.set(3, 2, 0.0); +aMatrix.set(3, 3, 1.0); const basegfx::BColorModifierSharedPtr aBColorModifier = std::make_shared(aMatrix); @@ -321,12 +325,19 @@ public: aMatrix.set(0, 0, 1.0); aMatrix.set(0, 1, 0.0); aMatrix.set(0, 2, 0.0); +aMatrix.set(0, 3, 0.0); aMatrix.set(1, 0, 0.0); aMatrix.set(1, 1, 1.0); aMatrix.set(1, 2, 0.0); +aMatrix.set(1, 3, 0.0); aMatrix.set(2, 0, 0.0); aMatrix.set(2, 1, 0.0); aMatrix.set(2, 2, 1.0); +aMatrix.set(2, 3, 0.0); +aMatrix.set(3, 0, 0.0); +aMatrix.set(3, 1, 0.0); +aMatrix.set(3, 2, 0.0); +aMatrix.set(3, 3, 1.0); const basegfx::BColorModifierSharedPtr aBColorModifier = std::make_shared(aMatrix);
[Libreoffice-commits] core.git: basegfx/source basegfx/test include/basegfx svgio/inc svgio/qa svgio/source
basegfx/source/color/bcolormodifier.cxx | 19 basegfx/test/BColorModifierTest.cxx | 27 +++ include/basegfx/color/bcolormodifier.hxx | 20 + svgio/inc/svgfecolormatrixnode.hxx |2 + svgio/inc/svgfegaussianblurnode.hxx | 14 --- svgio/inc/svgfilternode.hxx |6 + svgio/qa/cppunit/SvgImportTest.cxx |3 +- svgio/qa/cppunit/data/filterFeGaussianBlur.svg |2 - svgio/source/svgreader/svgfecolormatrixnode.cxx | 21 + svgio/source/svgreader/svgfegaussianblurnode.cxx | 18 +-- 10 files changed, 115 insertions(+), 17 deletions(-) New commits: commit 75399b8aad6c0f0998b9d0a6eddb2e29f8bc114c Author: Xisco Fauli AuthorDate: Sat Jun 24 11:17:16 2023 +0200 Commit: Xisco Fauli CommitDate: Sat Jun 24 12:33:12 2023 +0200 tdf#132246, tdf#155735: Add support for SourceAlpha Change-Id: I8feae2447b17e15113ca45fe46c0d68cb6b6ab71 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153550 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/basegfx/source/color/bcolormodifier.cxx b/basegfx/source/color/bcolormodifier.cxx index 829b0abda659..52f34a69f205 100644 --- a/basegfx/source/color/bcolormodifier.cxx +++ b/basegfx/source/color/bcolormodifier.cxx @@ -69,6 +69,25 @@ namespace basegfx return "invert"; } +BColorModifier_alpha::~BColorModifier_alpha() +{ +} + +bool BColorModifier_alpha::operator==(const BColorModifier& rCompare) const +{ +return dynamic_cast< const BColorModifier_alpha* >(&rCompare) != nullptr; +} + +::basegfx::BColor BColorModifier_alpha::getModifiedColor(const ::basegfx::BColor& /*aSourceColor*/) const +{ +return ::basegfx::BColor(0.0, 0.0, 0.0); +} + +OUString BColorModifier_alpha::getModifierName() const +{ +return "alpha"; +} + BColorModifier_luminance_to_alpha::~BColorModifier_luminance_to_alpha() { } diff --git a/basegfx/test/BColorModifierTest.cxx b/basegfx/test/BColorModifierTest.cxx index 6be160ce43ae..5a4b941e1c44 100755 --- a/basegfx/test/BColorModifierTest.cxx +++ b/basegfx/test/BColorModifierTest.cxx @@ -378,6 +378,32 @@ public: CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2)); } +void testAlpha() +{ +const basegfx::BColorModifierSharedPtr aBColorModifier += std::make_shared(); + +CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maWhite)); +CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maGray)); +CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maBlack)); + +CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maRed)); +CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maGreen)); +CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maBlue)); +CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maYellow)); +CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maMagenta)); +CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maCyan)); + +CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier)); +const basegfx::BColorModifierSharedPtr aBColorModifierInvert += std::make_shared(); +CPPUNIT_ASSERT(*aBColorModifier != *aBColorModifierInvert); + +const basegfx::BColorModifierSharedPtr aBColorModifier2 += std::make_shared(); +CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2)); +} + CPPUNIT_TEST_SUITE(bcolormodifier); CPPUNIT_TEST(testGray); CPPUNIT_TEST(testInvert); @@ -389,6 +415,7 @@ public: CPPUNIT_TEST(testMatrix); CPPUNIT_TEST(testIdentityMatrix); CPPUNIT_TEST(testBlackAndWhite); +CPPUNIT_TEST(testAlpha); CPPUNIT_TEST_SUITE_END(); }; diff --git a/include/basegfx/color/bcolormodifier.hxx b/include/basegfx/color/bcolormodifier.hxx index 6eb40b67e9d7..37c6a5b9e2f3 100644 --- a/include/basegfx/color/bcolormodifier.hxx +++ b/include/basegfx/color/bcolormodifier.hxx @@ -126,6 +126,26 @@ namespace basegfx SAL_DLLPRIVATE virtual OUString getModifierName() const override; }; +/** + * convert to alpha +*/ +class SAL_WARN_UNUSED BASEGFX_DLLPUBLIC BColorModifier_alpha final : public BColorModifier +{ +public: +BColorModifier_alpha() +{ +} + +virtual ~BColorModifier_alpha() override; + +// compare operator +SAL_DLLPRIVATE virtual bool operator==(const BColorModifier& rCompare) const override; + +// compute modified color +SAL_DLLPRIVATE virtual ::basegfx::BColor getModifiedColor(const ::basegfx::BColor& aSourceColor) const override; +SAL_DLLPRIVATE virtual OUString
[Libreoffice-commits] core.git: basegfx/source basegfx/test include/basegfx svgio/inc svgio/qa svgio/source
basegfx/source/color/bcolormodifier.cxx | 32 + basegfx/test/BColorModifierTest.cxx | 85 include/basegfx/color/bcolormodifier.hxx| 28 +++ svgio/inc/svgfecolormatrixnode.hxx |3 svgio/inc/svgtools.hxx |2 svgio/qa/cppunit/SvgImportTest.cxx |8 +- svgio/source/svgreader/svgfecolormatrixnode.cxx | 13 +++ svgio/source/svgreader/svgtools.cxx | 34 + 8 files changed, 200 insertions(+), 5 deletions(-) New commits: commit e121f7b37c48b6d843dfdd1d774d2a40567c46c7 Author: Xisco Fauli AuthorDate: Fri Jun 16 11:50:57 2023 +0200 Commit: Xisco Fauli CommitDate: Thu Jun 22 17:19:27 2023 +0200 tdf#155735: Add support for matrix type Change-Id: Icc172c5f47731ddcf0beca64c72c2022313e74a7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153177 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/basegfx/source/color/bcolormodifier.cxx b/basegfx/source/color/bcolormodifier.cxx index 8d6f99a3faf5..829b0abda659 100644 --- a/basegfx/source/color/bcolormodifier.cxx +++ b/basegfx/source/color/bcolormodifier.cxx @@ -142,6 +142,38 @@ namespace basegfx return "interpolate"; } +BColorModifier_matrix::~BColorModifier_matrix() +{ +} + +bool BColorModifier_matrix::operator==(const BColorModifier& rCompare) const +{ +const BColorModifier_matrix* pCompare = dynamic_cast< const BColorModifier_matrix* >(&rCompare); + +if(!pCompare) +{ +return false; +} + +return maMatrix == pCompare->maMatrix; +} + +::basegfx::BColor BColorModifier_matrix::getModifiedColor(const ::basegfx::BColor& aSourceColor) const +{ +basegfx::B3DHomMatrix aColorMatrix; +aColorMatrix.set(0, 0, aSourceColor.getRed()); +aColorMatrix.set(1, 0, aSourceColor.getGreen()); +aColorMatrix.set(2, 0, aSourceColor.getBlue()); + +aColorMatrix = maMatrix * aColorMatrix; +return ::basegfx::BColor(aColorMatrix.get(0, 0), aColorMatrix.get(1, 0), aColorMatrix.get(2, 0)); +} + +OUString BColorModifier_matrix::getModifierName() const +{ +return "matrix"; +} + BColorModifier_saturate::BColorModifier_saturate(double fValue) { maSatMatrix.set(0, 0, 0.213 + 0.787 * fValue); diff --git a/basegfx/test/BColorModifierTest.cxx b/basegfx/test/BColorModifierTest.cxx index d6e0648d2c17..17b6a0c22257 100755 --- a/basegfx/test/BColorModifierTest.cxx +++ b/basegfx/test/BColorModifierTest.cxx @@ -269,6 +269,89 @@ public: CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2)); } +void testMatrix() +{ +// green matrix +basegfx::B3DHomMatrix aMatrix; +aMatrix.set(0, 0, 0.0); +aMatrix.set(0, 1, 0.0); +aMatrix.set(0, 2, 0.0); +aMatrix.set(0, 3, 0.0); +aMatrix.set(1, 0, 1.0); +aMatrix.set(1, 1, 1.0); +aMatrix.set(1, 2, 1.0); +aMatrix.set(1, 3, 1.0); +aMatrix.set(2, 0, 0.0); +aMatrix.set(2, 1, 0.0); +aMatrix.set(2, 2, 0.0); +aMatrix.set(2, 3, 0.0); + +const basegfx::BColorModifierSharedPtr aBColorModifier += std::make_shared(aMatrix); + +BColor aExpectedWhite(0.0, 3.0, 0.0); +CPPUNIT_ASSERT_EQUAL(aExpectedWhite, aBColorModifier->getModifiedColor(maWhite)); +BColor aExpectedGray(0.0, 1.5, 0.0); +CPPUNIT_ASSERT_EQUAL(aExpectedGray, aBColorModifier->getModifiedColor(maGray)); +CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maBlack)); + +CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maRed)); +CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maGreen)); +CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maBlue)); +BColor aExpectedYellow(0.0, 2.0, 0.0); +CPPUNIT_ASSERT_EQUAL(aExpectedYellow, aBColorModifier->getModifiedColor(maYellow)); +BColor aExpectedMagenta = aExpectedYellow; +CPPUNIT_ASSERT_EQUAL(aExpectedMagenta, aBColorModifier->getModifiedColor(maMagenta)); +BColor aExpectedCyan = aExpectedYellow; +CPPUNIT_ASSERT_EQUAL(aExpectedCyan, aBColorModifier->getModifiedColor(maCyan)); + +CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier)); +const basegfx::BColorModifierSharedPtr aBColorModifierInvert += std::make_shared(); +CPPUNIT_ASSERT(*aBColorModifier != *aBColorModifierInvert); + +const basegfx::BColorModifierSharedPtr aBColorModifier2 += std::make_shared(aMatrix); +CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2)); +} + +void testIdentityMatrix() +{ +basegfx::B3DHomMatrix aMatrix; +aMatrix.set(0, 0, 1.0); +aMatrix.set(0, 1, 0.0); +aMatrix.set(0,
[Libreoffice-commits] core.git: basegfx/source basegfx/test include/basegfx svgio/inc svgio/qa svgio/source
basegfx/source/color/bcolormodifier.cxx | 51 basegfx/test/BColorModifierTest.cxx | 33 +++ include/basegfx/color/bcolormodifier.hxx| 25 +++ svgio/inc/svgfecolormatrixnode.hxx |3 - svgio/qa/cppunit/SvgImportTest.cxx |4 - svgio/source/svgreader/svgfecolormatrixnode.cxx | 27 6 files changed, 132 insertions(+), 11 deletions(-) New commits: commit a62513e1e80e39f9928e9e1815a84761403a4f2b Author: Xisco Fauli AuthorDate: Thu Jun 15 12:19:39 2023 +0200 Commit: Xisco Fauli CommitDate: Thu Jun 22 08:23:53 2023 +0200 tdf#155735: Add support for hueRotate type Change-Id: I9c7ada2908c0739708fbc9e28ac58430350da7a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153112 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/basegfx/source/color/bcolormodifier.cxx b/basegfx/source/color/bcolormodifier.cxx index 480af66e7588..8d6f99a3faf5 100644 --- a/basegfx/source/color/bcolormodifier.cxx +++ b/basegfx/source/color/bcolormodifier.cxx @@ -187,6 +187,57 @@ namespace basegfx return "saturate"; } +BColorModifier_hueRotate::BColorModifier_hueRotate(double fRad) +{ +const double fCos = cos(fRad); +const double fSin = sin(fRad); + +maHueMatrix.set(0, 0, 0.213 + fCos * 0.787 - fSin * 0.213); +maHueMatrix.set(0, 1, 0.715 - fCos * 0.715 - fSin * 0.715); +maHueMatrix.set(0, 2, 0.072 - fCos * 0.072 + fSin * 0.928); +maHueMatrix.set(1, 0, 0.213 - fCos * 0.213 + fSin * 0.143); +maHueMatrix.set(1, 1, 0.715 + fCos * 0.285 + fSin * 0.140); +maHueMatrix.set(1, 2, 0.072 - fCos * 0.072 - fSin * 0.283); +maHueMatrix.set(2, 0, 0.213 - fCos * 0.213 - fSin * 0.787); +maHueMatrix.set(2, 1, 0.715 - fCos * 0.715 + fSin * 0.715); +maHueMatrix.set(2, 2, 0.072 + fCos * 0.928 + fSin * 0.072); +} + +BColorModifier_hueRotate::~BColorModifier_hueRotate() +{ +} + +bool BColorModifier_hueRotate::operator==(const BColorModifier& rCompare) const +{ +const BColorModifier_hueRotate* pCompare = dynamic_cast< const BColorModifier_hueRotate* >(&rCompare); + +if(!pCompare) +{ +return false; +} + +return maHueMatrix == pCompare->maHueMatrix; +} + +::basegfx::BColor BColorModifier_hueRotate::getModifiedColor(const ::basegfx::BColor& aSourceColor) const +{ +basegfx::B3DHomMatrix aColorMatrix; +aColorMatrix.set(0, 0, aSourceColor.getRed()); +aColorMatrix.set(1, 0, aSourceColor.getGreen()); +aColorMatrix.set(2, 0, aSourceColor.getBlue()); + +aColorMatrix = maHueMatrix * aColorMatrix; +return ::basegfx::BColor( +std::clamp(aColorMatrix.get(0, 0), 0.0, 1.0), +std::clamp(aColorMatrix.get(1, 0), 0.0, 1.0), +std::clamp(aColorMatrix.get(2, 0), 0.0, 1.0)); +} + +OUString BColorModifier_hueRotate::getModifierName() const +{ +return "hueRotate"; +} + BColorModifier_black_and_white::~BColorModifier_black_and_white() { } diff --git a/basegfx/test/BColorModifierTest.cxx b/basegfx/test/BColorModifierTest.cxx index 053540018206..d6e0648d2c17 100755 --- a/basegfx/test/BColorModifierTest.cxx +++ b/basegfx/test/BColorModifierTest.cxx @@ -237,6 +237,38 @@ public: CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2)); } +void testHueRotate() +{ +const basegfx::BColorModifierSharedPtr aBColorModifier += std::make_shared(basegfx::deg2rad(180.0)); + +CPPUNIT_ASSERT_EQUAL(maWhite, aBColorModifier->getModifiedColor(maWhite)); +CPPUNIT_ASSERT_EQUAL(maGray, aBColorModifier->getModifiedColor(maGray)); +CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maBlack)); + +BColor aExpectedRed(0.0, 0.426, 0.426); +CPPUNIT_ASSERT_EQUAL(aExpectedRed, aBColorModifier->getModifiedColor(maRed)); +BColor aExpectedGreen(1.0, 0.43, 1.0); +CPPUNIT_ASSERT_EQUAL(aExpectedGreen, aBColorModifier->getModifiedColor(maGreen)); +BColor aExpectedBlue(0.144, 0.144, 0); +CPPUNIT_ASSERT_EQUAL(aExpectedBlue, aBColorModifier->getModifiedColor(maBlue)); +BColor aExpectedYellow(0.856, 0.856, 1.0); +CPPUNIT_ASSERT_EQUAL(aExpectedYellow, aBColorModifier->getModifiedColor(maYellow)); +BColor aExpectedMagenta(0.0, 0.57, 0.0); +CPPUNIT_ASSERT_EQUAL(aExpectedMagenta, aBColorModifier->getModifiedColor(maMagenta)); +BColor aExpectedCyan(1.0, 0.574, 0.574); +CPPUNIT_ASSERT_EQUAL(aExpectedCyan, aBColorModifier->getModifiedColor(maCyan)); + +CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier)); +const basegfx::BColorModifierSharedPtr aBColorModifierInvert += std::make_shared(); +CPPUNIT_ASSERT
[Libreoffice-commits] core.git: basegfx/source oox/qa oox/source
basegfx/source/tools/bgradient.cxx | 14 oox/qa/unit/data/tdf155852_MCGR_StepCount4.fodp | 637 oox/qa/unit/mcgr.cxx| 25 oox/source/export/drawingml.cxx | 10 4 files changed, 679 insertions(+), 7 deletions(-) New commits: commit 2b1b2a758cc4666c6cf6b14773281dfe1f30 Author: Regina Henschel AuthorDate: Thu Jun 15 22:18:34 2023 +0200 Commit: Regina Henschel CommitDate: Fri Jun 16 10:35:23 2023 +0200 tdf#155852 same method for StepCount in OOXML as in rendering Rendering of stepped gradients uses a method that doesn't take the color from a cut point, but before or after respectively. For example, for StepCount 4, the colors at relative positions 0, 1/3, 2/3 and 1 are used. So sections are 'start color', '1/3 color', '2/3 color' and 'end color'. The output to OOXML now uses the same method. That way rendering in a produced pptx-file is the same as in the original odp-file. Since OOXML has nothing similar to StepCount, it is an export only problem. A second problem comes from the cuddle with StepCount in Gradient struct in API and FillStepCount in shape property set. The draw:gradient-stop-count attribute in ODF belongs to the graphic style of the shape. The gradient definition itself in the element has nothing about step count. When a file is opened, it can be that the StepCount component in the Gradient struct still has the default value 0, but the FillStepCount property has the correct value of the shape. The Gradient struct in the API should not have a component StepCount to be compatible with ODF. But the API is published and changing that struct is far-reaching in the code. So the fix here is not a general solution but solves the problem for export to OOXML by reading the FillStepCount property while exporting. Change-Id: Ie1cafe6bdda7c4d74b05f279f0d8212ff67ecc92 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153154 Tested-by: Jenkins Reviewed-by: Regina Henschel diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index d46530074787..7b62a19c9ad6 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -746,7 +746,6 @@ void BColorStops::doApplySteps(sal_uInt16 nStepCount) // the same color as the previous one ended aNewColorStops.push_back(*aColorL); } - if (!basegfx::fTools::equalZero(fDelta)) { // create in-between steps, always two at the same position to @@ -757,20 +756,21 @@ void BColorStops::doApplySteps(sal_uInt16 nStepCount) if (rStartColor != rEndColor) { // get relative single-step width -const double fSingleStep(1.0 / static_cast(nStepCount)); +// tdf155852 Use same method for the color as in rendering. +const double fSingleStep(1.0 / static_cast(nStepCount - 1)); +const double fOffsetStep(fDelta / static_cast(nStepCount)); for (sal_uInt16 a(1); a < nStepCount; a++) { -// calculate position since being used twice -const double fPosition(fStart - + (fDelta * (static_cast(a) * fSingleStep))); +// calculate stop position since being used twice +const double fPosition(fStart + fOffsetStep * static_cast(a)); -// add start color of sub-segment +// add end color of previous sub-segment aNewColorStops.emplace_back( fPosition, basegfx::interpolate(rStartColor, rEndColor, static_cast(a - 1) * fSingleStep)); -// add end color of sub-segment +// add start color of current sub-segment aNewColorStops.emplace_back( fPosition, basegfx::interpolate(rStartColor, rEndColor, static_cast(a) * fSingleStep)); diff --git a/oox/qa/unit/data/tdf155852_MCGR_StepCount4.fodp b/oox/qa/unit/data/tdf155852_MCGR_StepCount4.fodp new file mode 100644 index ..309cb3b0b1b9 --- /dev/null +++ b/oox/qa/unit/data/tdf155852_MCGR_StepCount4.fodp @@ -0,0 +1,637 @@ + + +http://openoffice.org/2004/office"; xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink"; xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:tex
[Libreoffice-commits] core.git: basegfx/source oox/qa
basegfx/source/tools/gradienttools.cxx |2 oox/qa/unit/data/tdf155825_MCGR_SourceOffsetRangeDifferent.fodp | 642 ++ oox/qa/unit/mcgr.cxx| 10 3 files changed, 654 insertions(+) New commits: commit f3f64c77585d0c3c01c0d960f4959e18e9668c30 Author: Regina Henschel AuthorDate: Wed Jun 14 15:53:19 2023 +0200 Commit: Caolán McNamara CommitDate: Wed Jun 14 21:29:50 2023 +0200 tdf155825 result same size in synchronize gradients While synchronizing color and transparency gradients two new sequences are generated. In case the last offsets where different, the remaining stops where not copied to the new sequence and thus they had different sizes which triggered an assert in oox/source/export/drawingml.cxx. Change-Id: I446f8cfafb23735f06ad4e05eee8c922141b864d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153063 Tested-by: Jenkins Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index f79895bc8b8b..8f3e8ae83c06 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -441,6 +441,7 @@ namespace basegfx { const double fColorOff(aCurrColor->getStopOffset()); aNewAlpha.emplace_back(fColorOff, rAlphaStops.getInterpolatedBColor(fColorOff, 0, aAlphaStopRange)); +aNewColor.emplace_back(fColorOff, aCurrColor->getStopColor()); bRealChange = true; aCurrColor++; } @@ -448,6 +449,7 @@ namespace basegfx { const double fAlphaOff(aCurrAlpha->getStopOffset()); aNewColor.emplace_back(fAlphaOff, rColorStops.getInterpolatedBColor(fAlphaOff, 0, aColorStopRange)); +aNewAlpha.emplace_back(fAlphaOff, aCurrAlpha->getStopColor()); bRealChange = true; aCurrAlpha++; } diff --git a/oox/qa/unit/data/tdf155825_MCGR_SourceOffsetRangeDifferent.fodp b/oox/qa/unit/data/tdf155825_MCGR_SourceOffsetRangeDifferent.fodp new file mode 100644 index ..97b39689d51d --- /dev/null +++ b/oox/qa/unit/data/tdf155825_MCGR_SourceOffsetRangeDifferent.fodp @@ -0,0 +1,642 @@ + + +http://openoffice.org/2004/office"; xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink"; xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:rpt="http://openoffice.org/2005/report"; xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:ooow="http://openoffice.org/200 4/writer" xmlns:oooc="http://openoffice.org/2004/calc"; xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xforms="http://www.w3.org/2002/xforms"; xmlns:tableooo="http://openoffice.org/2009/table"; xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:drawooo="http://openoffice.org/2010/draw"; xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML"; xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:dom="http://www.w3.org/2001/xml-events"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xhtml="http://www.w3.org/1999/xhtml"; xmlns:grddl="http://www.w3.org/2003/g/data-view#"; xmlns :css3t="http://www.w3.org/TR/css3-text/"; xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xmlns:officeooo="http://openoffice.org/2009/office"; office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.presentation"> + 2023-06-14T00:44:04.1630024x16impressPT3M3S3B2020/24.2.0.0.alpha0$Windows_X86_64 LibreOffice_project/0028c2311ca14669ca530cd4db422cd3cf9438
[Libreoffice-commits] core.git: basegfx/source drawinglayer/source include/basegfx svgio/inc svgio/qa svgio/source
basegfx/source/color/bcolormodifier.cxx | 74 +++ drawinglayer/source/tools/primitive2dxmldump.cxx | 12 ++- include/basegfx/color/bcolormodifier.hxx | 40 svgio/inc/svgfecolormatrixnode.hxx |6 + svgio/inc/svgtoken.hxx |1 svgio/qa/cppunit/SvgImportTest.cxx | 21 +- svgio/qa/cppunit/data/filterSaturate.svg | 11 +++ svgio/source/svgreader/svgfecolormatrixnode.cxx | 29 - svgio/source/svgreader/svgtoken.cxx |2 9 files changed, 183 insertions(+), 13 deletions(-) New commits: commit 41bf4139cab36984cff514bfdd6b1b13576746a3 Author: Xisco Fauli AuthorDate: Wed Jun 14 12:39:06 2023 +0200 Commit: Xisco Fauli CommitDate: Wed Jun 14 21:08:17 2023 +0200 tdf#155735: Add support for saturate type Add getModifierName to BColorModifier class so when can assert which modifier is being used Change-Id: I2bc2a36470a449df4dc84a8440f232149c1f8278 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153048 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/basegfx/source/color/bcolormodifier.cxx b/basegfx/source/color/bcolormodifier.cxx index f27ffcc9aaf0..2067257015b4 100644 --- a/basegfx/source/color/bcolormodifier.cxx +++ b/basegfx/source/color/bcolormodifier.cxx @@ -45,6 +45,11 @@ namespace basegfx return ::basegfx::BColor(fLuminance, fLuminance, fLuminance); } +OUString BColorModifier_gray::getModifierName() const +{ +return "gray"; +} + BColorModifier_invert::~BColorModifier_invert() { } @@ -59,6 +64,11 @@ namespace basegfx return ::basegfx::BColor(1.0 - aSourceColor.getRed(), 1.0 - aSourceColor.getGreen(), 1.0 - aSourceColor.getBlue()); } +OUString BColorModifier_invert::getModifierName() const +{ +return "invert"; +} + BColorModifier_luminance_to_alpha::~BColorModifier_luminance_to_alpha() { } @@ -75,6 +85,11 @@ namespace basegfx return ::basegfx::BColor(fAlpha, fAlpha, fAlpha); } +OUString BColorModifier_luminance_to_alpha::getModifierName() const +{ +return "luminance_to_alpha"; +} + BColorModifier_replace::~BColorModifier_replace() { } @@ -96,6 +111,11 @@ namespace basegfx return maBColor; } +OUString BColorModifier_replace::getModifierName() const +{ +return "replace"; +} + BColorModifier_interpolate::~BColorModifier_interpolate() { } @@ -117,6 +137,40 @@ namespace basegfx return interpolate(maBColor, aSourceColor, mfValue); } +OUString BColorModifier_interpolate::getModifierName() const +{ +return "interpolate"; +} + +BColorModifier_saturate::~BColorModifier_saturate() +{ +} + +bool BColorModifier_saturate::operator==(const BColorModifier& rCompare) const +{ +const BColorModifier_saturate* pCompare = dynamic_cast< const BColorModifier_saturate* >(&rCompare); + +if(!pCompare) +{ +return false; +} + +return mfValue == pCompare->mfValue; +} + +::basegfx::BColor BColorModifier_saturate::getModifiedColor(const ::basegfx::BColor& aSourceColor) const +{ +return basegfx::BColor( +(0.213 + 0.787 * mfValue) * aSourceColor.getRed() + (0.715 - 0.715 * mfValue) * aSourceColor.getGreen() + (0.072 - 0.072 * mfValue) * aSourceColor.getBlue(), +(0.213 - 0.213 * mfValue) * aSourceColor.getRed() + (0.715 + 0.285 * mfValue) * aSourceColor.getGreen() + (0.072 - 0.072 * mfValue) * aSourceColor.getBlue(), +(0.213 - 0.213 * mfValue) * aSourceColor.getRed() + (0.715 - 0.715 * mfValue) * aSourceColor.getGreen() + (0.072 + 0.928 * mfValue) * aSourceColor.getBlue()); +} + +OUString BColorModifier_saturate::getModifierName() const +{ +return "saturate"; +} + BColorModifier_black_and_white::~BColorModifier_black_and_white() { } @@ -147,6 +201,11 @@ namespace basegfx } } +OUString BColorModifier_black_and_white::getModifierName() const +{ +return "black_and_white"; +} + BColorModifier_gamma::BColorModifier_gamma(double fValue) : mfValue(fValue), mfInvValue(fValue), @@ -193,6 +252,11 @@ namespace basegfx } } +OUString BColorModifier_gamma::getModifierName() const +{ +return "gamma"; +} + BColorModifier_RGBLuminanceContrast::BColorModifier_RGBLuminanceContrast(double fRed, double fGreen, double fBlue, double fLuminance, double fContrast) : mfRed(std::clamp(fRed, -1.0, 1.0)), mfGreen(std::clamp(fGreen, -1.0, 1.0)), @@ -270,6 +334,11 @@ namespace basegfx } } +OUString BColorModifier_RGBLuminanceContrast::getModifierName() const +{ +return "RGBLuminanceContrast"; +} +
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/polygon/b2dpolygonclipper.cxx | 16 +++ basegfx/source/polygon/b2dpolygoncutandtouch.cxx |6 -- basegfx/source/polygon/b2dpolygontriangulator.cxx |9 +--- basegfx/source/polygon/b2dpolypolygoncutter.cxx | 46 +++--- basegfx/source/polygon/b3dpolypolygontools.cxx| 27 +--- 5 files changed, 41 insertions(+), 63 deletions(-) New commits: commit 65a20a85c20ddc87d66445657404a46041bcf6e1 Author: buldi AuthorDate: Mon Mar 13 23:09:18 2023 +0100 Commit: Hossein CommitDate: Tue Jun 13 09:23:54 2023 +0200 tdf#145538 Refactor to use range-based for-loop Change-Id: I7c75593fef6d3226011a938349850dc485b763c2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148204 Tested-by: Jenkins Reviewed-by: Hossein diff --git a/basegfx/source/polygon/b2dpolygonclipper.cxx b/basegfx/source/polygon/b2dpolygonclipper.cxx index e9099b730578..e2f1f060381e 100644 --- a/basegfx/source/polygon/b2dpolygonclipper.cxx +++ b/basegfx/source/polygon/b2dpolygonclipper.cxx @@ -162,12 +162,11 @@ namespace basegfx::utils B2DPolyPolygon clipPolyPolygonOnParallelAxis(const B2DPolyPolygon& rCandidate, bool bParallelToXAxis, bool bAboveAxis, double fValueOnOtherAxis, bool bStroke) { -const sal_uInt32 nPolygonCount(rCandidate.count()); B2DPolyPolygon aRetval; -for(sal_uInt32 a(0); a < nPolygonCount; a++) +for(const auto& rB2DPolygon : rCandidate ) { -const B2DPolyPolygon aClippedPolyPolygon(clipPolygonOnParallelAxis(rCandidate.getB2DPolygon(a), bParallelToXAxis, bAboveAxis, fValueOnOtherAxis, bStroke)); +const B2DPolyPolygon aClippedPolyPolygon(clipPolygonOnParallelAxis(rB2DPolygon, bParallelToXAxis, bAboveAxis, fValueOnOtherAxis, bStroke)); if(aClippedPolyPolygon.count()) { @@ -284,10 +283,9 @@ namespace basegfx::utils B2DPolyPolygon clipPolyPolygonOnRange(const B2DPolyPolygon& rCandidate, const B2DRange& rRange, bool bInside, bool bStroke) { -const sal_uInt32 nPolygonCount(rCandidate.count()); B2DPolyPolygon aRetval; -if(!nPolygonCount) +if(!rCandidate.count()) { // source is empty return aRetval; @@ -309,9 +307,9 @@ namespace basegfx::utils if(bInside) { -for(sal_uInt32 a(0); a < nPolygonCount; a++) +for( const auto& rClippedPoly : rCandidate) { -const B2DPolyPolygon aClippedPolyPolygon(clipPolygonOnRange(rCandidate.getB2DPolygon(a), rRange, bInside, bStroke)); +const B2DPolyPolygon aClippedPolyPolygon(clipPolygonOnRange(rClippedPoly , rRange, bInside, bStroke)); if(aClippedPolyPolygon.count()) { @@ -345,10 +343,10 @@ namespace basegfx::utils // line clipping, create line snippets by first adding all cut points and // then marching along the edges and detecting if they are inside or outside // the clip polygon -for(sal_uInt32 a(0); a < rCandidate.count(); a++) +for(const auto& rPolygon : rCandidate) { // add cuts with clip to polygon, including bezier segments -const B2DPolygon aCandidate(addPointsAtCuts(rCandidate.getB2DPolygon(a), rClip)); +const B2DPolygon aCandidate(addPointsAtCuts(rPolygon, rClip)); const sal_uInt32 nPointCount(aCandidate.count()); const sal_uInt32 nEdgeCount(aCandidate.isClosed() ? nPointCount : nPointCount - 1); B2DCubicBezier aEdge; diff --git a/basegfx/source/polygon/b2dpolygoncutandtouch.cxx b/basegfx/source/polygon/b2dpolygoncutandtouch.cxx index d5ab5887da61..92a0abce6c77 100644 --- a/basegfx/source/polygon/b2dpolygoncutandtouch.cxx +++ b/basegfx/source/polygon/b2dpolygoncutandtouch.cxx @@ -179,14 +179,12 @@ namespace basegfx // (as in adaptiveSubdivideByCount) it is now possible to calculate back the // cut positions in the polygon to relative cut positions on the original bezier // segment. -const sal_uInt32 nTempPointCount(rPointVector.size()); const sal_uInt32 nEdgeCount(rPolygon.count() ? rPolygon.count() - 1 : 0); -if(nTempPointCount && nEdgeCount) +if(!rPointVector.empty() && nEdgeCount) { -for(sal_uInt32 a(0); a < nTempPointCount; a++) +for( const auto& rTempPoint : rPointVector ) { -const temporaryPoint& rTempPoint = rPointVector[a]; const double fCutPosInPolygon(static_cast(rTempPoint.getIndex()) + rT
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/bgradient.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit cdc015ffd4b2460a9235db72a5411c421ab0e2d4 Author: Andrea Gelmini AuthorDate: Fri Jun 9 13:25:36 2023 +0200 Commit: Julien Nabet CommitDate: Fri Jun 9 17:57:39 2023 +0200 Fix typo Change-Id: Iaebe55927771985a6b574b2cb9410b0eb75441e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152789 Tested-by: Jenkins Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index 61a58b5e3cdb..d46530074787 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -749,7 +749,7 @@ void BColorStops::doApplySteps(sal_uInt16 nStepCount) if (!basegfx::fTools::equalZero(fDelta)) { -// create in-between steps, always two at the same positon to +// create in-between steps, always two at the same position to // define a 'hard' color stop. Get start/end color for the segment const basegfx::BColor& rStartColor(aColorL->getStopColor()); const basegfx::BColor& rEndColor(aColorR->getStopColor());
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/bgradient.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit e1dcf9464e56c0eee9f662f82928b3f99ba78217 Author: Andrea Gelmini AuthorDate: Fri Jun 9 13:25:06 2023 +0200 Commit: Julien Nabet CommitDate: Fri Jun 9 17:57:06 2023 +0200 Fix typo Change-Id: Ib02cc0e9aaf286d8c39523ea352cfeec17a6336f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152788 Tested-by: Jenkins Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index c96cd0b673cb..61a58b5e3cdb 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -681,7 +681,7 @@ bool BColorStops::isSymmetrical() const void BColorStops::doApplyAxial() { -// preapare new ColorStops +// prepare new ColorStops basegfx::BColorStops aNewColorStops; // add gradient stops in reverse order, scaled to [0.0 .. 0.5]
[Libreoffice-commits] core.git: basegfx/source drawinglayer/source filter/source include/basegfx include/svx include/vcl oox/source svx/source vcl/source
basegfx/source/tools/bgradient.cxx | 137 drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx | 188 +--- filter/source/svg/svgexport.cxx|3 filter/source/svg/svgwriter.cxx| 198 +++-- filter/source/svg/svgwriter.hxx| 10 include/basegfx/utils/bgradient.hxx| 17 + include/svx/svdxcgv.hxx|6 include/vcl/gdimtf.hxx |7 include/vcl/metaact.hxx| 11 oox/source/export/drawingml.cxx| 56 --- svx/source/svdraw/svdxcgv.cxx |4 vcl/source/control/fmtfield.cxx|2 vcl/source/filter/svm/SvmReader.cxx| 21 + vcl/source/filter/svm/SvmWriter.cxx| 23 + vcl/source/gdi/gdimtf.cxx |9 vcl/source/gdi/metaact.cxx |5 16 files changed, 523 insertions(+), 174 deletions(-) New commits: commit a6e72e2b314e64f3199f3eaf1ecf78157446f6dd Author: Armin Le Grand (allotropia) AuthorDate: Mon Jun 5 17:15:34 2023 +0200 Commit: Armin Le Grand CommitDate: Fri Jun 9 10:17:07 2023 +0200 MCGR: tdf#155479 repair gradient SVG export for MCGR Unfortunately SVG export is based on metafiles and thus there is (in principle) no way to get the BGradient/ColorStop/MCGR data transfered as needed. For that, using UNO API to read the model or using B2DPrimitives would help - as is better for the export respectively. Since there is not the time to re-design SVG export I added this 'compromize' as a fix. It gets the needed data transported over the metafile (that part is the compromize). It then exports the MCGR data to SVG (at least - as was already there - if it's a linear/axial gradient). This happens now with all Gradient Stops when there is a MCGR gradient. That part is/will hopefully be re-usable if SVG export gets redesigned. I also added a handling for StepCount feature, so when used (in LO, others do not have that) 'hard' color stops get generated to make the gradient look identical for SVG export. Had to make adding of that extra-information in metafiles dependent on exporting really to SVG. There are 51 cases which use 'MetaActionType::COMMENT' which would potentially have to be adapted. Also added code to solve the problem for TransparencePrimitive2D at VclMetafileProcessor2D::processTransparencePrimitive2D. This will now - also only for SVG export - directly create the needed MetaFloatTransparentAction and add additional MCGR information. This will be used on SVG export to write a 'Mask' as was done before. This is now capable of creating fill MCGR-Masks in the sense that any number of TransparencyStops will be supported. Change-Id: Ic6d022714eae96b8fbc09e60652851ac5799b757 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152623 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index b56ef0540d17..c96cd0b673cb 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -679,6 +679,117 @@ bool BColorStops::isSymmetrical() const return aIter > aRIter; } +void BColorStops::doApplyAxial() +{ +// preapare new ColorStops +basegfx::BColorStops aNewColorStops; + +// add gradient stops in reverse order, scaled to [0.0 .. 0.5] +basegfx::BColorStops::const_reverse_iterator aRevCurrColor(rbegin()); + +while (aRevCurrColor != rend()) +{ +aNewColorStops.emplace_back((1.0 - aRevCurrColor->getStopOffset()) * 0.5, +aRevCurrColor->getStopColor()); +aRevCurrColor++; +} + +// prepare non-reverse run +basegfx::BColorStops::const_iterator aCurrColor(begin()); + +if (basegfx::fTools::equalZero(aCurrColor->getStopOffset())) +{ +// Caution: do not add 1st entry again, that would be double since it was +// already added as last element of the inverse run above. But only if +// the gradient has a start entry for 0.0 aka StartColor, else it is correct. +aCurrColor++; +} + +// add gradient stops in non-reverse order, translated and scaled to [0.5 .. 1.0] +while (aCurrColor != end()) +{ +aNewColorStops.emplace_back((aCurrColor->getStopOffset() * 0.5) + 0.5, +aCurrColor->getStopColor()); +aCurrColor++; +} + +// apply color stops +*this = aNewColorStops; +} + +void BColorStops::doApplySteps(sal_uInt16 nStepCount) +{ +// check for zero or invalid steps setting -
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/gradienttools.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit bda52485d63e4cfc58453d9f46bf26c3ea078ed7 Author: Armin Le Grand (allotropia) AuthorDate: Tue Jun 6 12:53:42 2023 +0200 Commit: Armin Le Grand CommitDate: Tue Jun 6 15:44:32 2023 +0200 MCGR: tdf#155537 correct usage of wrong result in tooling Change-Id: I8f68ecc7ccaecf84abbcda1bcdd65e2295baaf0f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152673 Tested-by: Jenkins Reviewed-by: Regina Henschel Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 366e0b0840b8..f79895bc8b8b 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -465,7 +465,7 @@ namespace basegfx // This should always be the cease and should have been // detected as such above, see bNeedToSyncronize rColorStops = aNewColor; -rAlphaStops = aNewColor; +rAlphaStops = aNewAlpha; // MCGR: tdf#155537 used wrong result here } } }
[Libreoffice-commits] core.git: basegfx/source chart2/qa include/basegfx xmloff/qa xmloff/source
basegfx/source/tools/bgradient.cxx | 53 chart2/qa/extras/chart2geometry.cxx|5 include/basegfx/utils/bgradient.hxx|7 + xmloff/qa/unit/data/tdf155549_MCGR_AxialGradientCompatible.odt |binary xmloff/qa/unit/data/tdf155549_MCGR_AxialTransparencyCompatible.odt |binary xmloff/qa/unit/style.cxx | 63 ++ xmloff/source/style/GradientStyle.cxx |5 xmloff/source/style/TransGradientStyle.cxx |2 8 files changed, 130 insertions(+), 5 deletions(-) New commits: commit 6c49886ab46c53398d74610b264e5edb0332a059 Author: Regina Henschel AuthorDate: Sat Jun 3 14:56:29 2023 +0200 Commit: Regina Henschel CommitDate: Mon Jun 5 17:34:57 2023 +0200 tdf#155549 MCGR: Recreate 'axial' from symmetric 'linear' When exporting a shape with an axial gradient fill to OOXML, it is converted to a linear gradient with multiple color stops. Versions before MCGR had recreated it as axial gradient on import from OOXML. But now LO is able to handle multiple color stops and so the linear gradient from OOXML is imported as linear gradient in LO. When such file is then written as ODF, the multiple color stops are in elements in extended namespace and versions before MCGR do not understand them. They show only the first and last color (which are equal) and the gradient is lost. With this patch LO converts the linear gradient back to an axial gradient on export to ODF. The exported axial gradient is rendered in a version with MCGR same as the linear gradient when opening the OOXML file. The difference is, that versions without MCGR now render an axial gradient with two colors. Change-Id: I2b416b4cdca75d8327107a4f259d63c2e6e97ac3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152574 Tested-by: Jenkins Reviewed-by: Regina Henschel diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index b7ee0780a2cc..b56ef0540d17 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -657,6 +657,28 @@ double BColorStops::detectPossibleOffsetAtStart() const return aColorL->getStopOffset(); } +// checks whether the color stops are symmetrical in color and offset. +bool BColorStops::isSymmetrical() const +{ +if (empty()) +return false; +if (1 == size()) +return basegfx::fTools::equal(0.5, front().getStopOffset()); + +BColorStops::const_iterator aIter(begin()); // for going forward +BColorStops::const_iterator aRIter(end()); // for going backward +--aRIter; +// We have at least two elements, so aIter <= aRIter fails before iterators no longer point to +// an element. +while (aIter <= aRIter && aIter->getStopColor().equal(aRIter->getStopColor()) + && basegfx::fTools::equal(aIter->getStopOffset(), 1.0 - aRIter->getStopOffset())) +{ +++aIter; +--aRIter; +} +return aIter > aRIter; +} + std::string BGradient::GradientStyleToString(css::awt::GradientStyle eStyle) { switch (eStyle) @@ -917,7 +939,7 @@ void BGradient::tryToRecreateBorder(basegfx::BColorStops* pAssociatedTransparenc pAssociatedTransparencyStops->removeSpaceAtStart(fOffset); // ...and create border value -SetBorder(static_cast(fOffset * 100.0)); +SetBorder(static_cast(std::lround(fOffset * 100.0))); } if (bIsAxial) @@ -971,6 +993,35 @@ void BGradient::tryToApplyStartEndIntensity() SetStartIntens(100); SetEndIntens(100); } + +void BGradient::tryToConvertToAxial() +{ +if (css::awt::GradientStyle_LINEAR != GetGradientStyle() || 0 != GetBorder() +|| GetColorStops().empty()) +return; + +if (!GetColorStops().isSymmetrical()) +return; + +SetGradientStyle(css::awt::GradientStyle_AXIAL); + +// Stretch the first half of the color stops to double width +// and collect them in a new color stops vector. +BColorStops aAxialColorStops; +aAxialColorStops.reserve(std::ceil(GetColorStops().size() / 2.0)); +BColorStops::const_iterator aIter(GetColorStops().begin()); +while (basegfx::fTools::lessOrEqual(aIter->getStopOffset(), 0.5)) +{ +BColorStop aNextStop(std::clamp((*aIter).getStopOffset() * 2.0, 0.0, 1.0), + (*aIter).getStopColor()); +aAxialColorStops.push_back(aNextStop); +++aIter; +} +// Axial gradients have outmost color as last color stop. +aAxialColorStops.reverseColorStops(); + +SetColorStops(aAxialColorStops); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/qa/extras/chart2geometry.cxx b/chart2/qa/extras/chart2geometry.cxx index d52633c80814..f560d46ba054 100644 --- a/chart
[Libreoffice-commits] core.git: basegfx/source include/basegfx oox/source
basegfx/source/tools/bgradient.cxx | 206 +++- basegfx/source/tools/gradienttools.cxx | 97 --- include/basegfx/utils/bgradient.hxx | 29 +++- include/basegfx/utils/gradienttools.hxx | 11 + oox/source/drawingml/fillproperties.cxx | 98 ++- 5 files changed, 306 insertions(+), 135 deletions(-) New commits: commit c2bea1bedd2ee8bc4007fd23c6cb839a692297a7 Author: Armin Le Grand (allotropia) AuthorDate: Wed May 24 12:31:48 2023 +0200 Commit: Armin Le Grand CommitDate: Fri May 26 10:08:52 2023 +0200 MCGR: Border restoration support Due to tdf#155362 I added code to be able in case we would need it to convert a BGradient using added tooling from having offsets in the GradientSteps and no border to adapted GradientSteps and border. This is preferrable due to our GradientStyle_RECT (and GradientStyle_ELLIPTICAL too) use that 'non- linear' paint aka move-two-pixels-inside, someone else called it 'frame-paint'. This does not bode well with the border being applied 'linear' at the same time (argh). Thus - while in principle all is correct when re-importing a GradientStyle_RECT with a border after export to pptx, it looks slightly better ('correcter') wen doing so. That is because when being able to and restoring a border at least that border part *is* applied linearly. I took the chance to further apply tooling, move it to classes involved and instead of awt::Gradient2 use more basegfx::BGradient since it can and does host tooling. This is also a preparation to be able to adapt (restore) border in case of turn- around in ODF where the importing instance is before MCGR existance and has to handle Start/EndColor. Needed to take more care with using BGradient instead of awt::Gradient2 for initialization, also better dividing/organization of tooling, already preparation to use for other purposes. Change-Id: I2d3a4240a5ac6fff9211b46642ee80366dc09e3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152194 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index 52aa721f36a6..b7ee0780a2cc 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -563,6 +563,100 @@ void BColorStops::reverseColorStops() candidate = BColorStop(1.0 - candidate.getStopOffset(), candidate.getStopColor()); } +// createSpaceAtStart creates fOffset space at start by +// translating/scaling all entries to the right +void BColorStops::createSpaceAtStart(double fOffset) +{ +// nothing to do if empty +if (empty()) +return; + +// correct offset to [0.0 .. 1.0] +fOffset = std::max(std::min(1.0, fOffset), 0.0); + +// nothing to do if 0.0 == offset +if (basegfx::fTools::equalZero(fOffset)) +return; + +BColorStops aNewStops; + +for (const auto& candidate : *this) +{ +aNewStops.emplace_back(fOffset + (candidate.getStopOffset() * (1.0 - fOffset)), + candidate.getStopColor()); +} + +*this = aNewStops; +} + +// removeSpaceAtStart removes fOffset space from start by +// translating/scaling entries more or equal to fOffset +// to the left. Entries less than fOffset will be removed +void BColorStops::removeSpaceAtStart(double fOffset) +{ +// nothing to do if empty +if (empty()) +return; + +// correct factor to [0.0 .. 1.0] +fOffset = std::max(std::min(1.0, fOffset), 0.0); + +// nothing to do if fOffset == 0.0 +if (basegfx::fTools::equalZero(fOffset)) +return; + +BColorStops aNewStops; +const double fMul(basegfx::fTools::equal(fOffset, 1.0) ? 1.0 : 1.0 / (1.0 - fOffset)); + +for (const auto& candidate : *this) +{ +if (basegfx::fTools::moreOrEqual(candidate.getStopOffset(), fOffset)) +{ +aNewStops.emplace_back((candidate.getStopOffset() - fOffset) * fMul, + candidate.getStopColor()); +} +} + +*this = aNewStops; +} + +// try to detect if an empty/no-color-change area exists +// at the start and return offset to it. Returns 0.0 if not. +double BColorStops::detectPossibleOffsetAtStart() const +{ +BColor aSingleColor; +const bool bSingleColor(isSingleColor(aSingleColor)); + +// no useful offset for single color +if (bSingleColor) +return 0.0; + +// here we know that we have at least two colors, so we have a +// color change. Find colors left and right of that first color change +BColorStops::const_iterator aColorR(begin()); +BColorStops::const_iterator aColorL(aColorR++); + +// aColorR would 1st get equal to end(), so no need to also check aColorL +// for end(). Loop as long as same color. Since we *have* a color change +// not
[Libreoffice-commits] core.git: basegfx/source include/basegfx include/oox oox/source svx/source
basegfx/source/tools/bgradient.cxx | 42 + basegfx/source/tools/gradienttools.cxx | 57 + include/basegfx/utils/bgradient.hxx |6 + include/basegfx/utils/gradienttools.hxx |7 - include/oox/export/drawingml.hxx|9 +- oox/source/export/chartexport.cxx | 47 --- oox/source/export/drawingml.cxx | 136 ++-- svx/source/unodraw/XPropertyTable.cxx | 23 - svx/source/xoutdev/xattr.cxx| 62 -- 9 files changed, 128 insertions(+), 261 deletions(-) New commits: commit 428b8a8d23e473fecf2916591615ff38611b93c9 Author: Armin Le Grand (allotropia) AuthorDate: Tue May 16 15:59:42 2023 +0200 Commit: Armin Le Grand CommitDate: Fri May 19 10:09:11 2023 +0200 MCGR: Adaptions to WriteGradientFill and BGradient Added code to make WriteGradientFill directly use the available BGradient implementation. The goal is to never directly work on awt::Gradient2, but use BGradient & it's tooling methods. Added constructors and tooling to BGradient and BColorStops to make that easier (single line conversions between uno::Any, basesgfx classes and awt:: incarnations). Directly handle uno::Any and awt:: classes, changed stuff to make use of this. Change-Id: I083a323b9efee8ca4f3becb2966aac0a294b9a60 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151842 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index 134fda548ece..52aa721f36a6 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -94,10 +94,12 @@ BColorStops::BColorStops(const css::awt::ColorStopSequence& rColorStops) BColorStops::BColorStops(const css::uno::Any& rVal) { -css::awt::Gradient2 aGradient2; -if (rVal >>= aGradient2) +if (rVal.has()) { -setColorStopSequence(aGradient2.ColorStops); +// we can use awt::ColorStopSequence +css::awt::ColorStopSequence aColorStopSequence; +rVal >>= aColorStopSequence; +setColorStopSequence(aColorStopSequence); } } @@ -627,7 +629,7 @@ BGradient::BGradient(const basegfx::BColorStops& rColorStops, css::awt::Gradient SetColorStops(aColorStops); } -BGradient::BGradient(const css::awt::Gradient2& rGradient2) +void BGradient::setGradient2(const css::awt::Gradient2& rGradient2) { // set values SetGradientStyle(rGradient2.Style); @@ -640,10 +642,24 @@ BGradient::BGradient(const css::awt::Gradient2& rGradient2) SetSteps(rGradient2.StepCount); // set ColorStops -aColorStops = BColorStops(rGradient2.ColorStops); -aColorStops.sortAndCorrect(); +if (rGradient2.ColorStops.hasElements()) +{ +// if we have a awt::ColorStopSequence, use it +aColorStops = BColorStops(rGradient2.ColorStops); +aColorStops.sortAndCorrect(); +} +else +{ +// if not, for compatibility, use StartColor/EndColor +aColorStops = BColorStops{ +BColorStop(0.0, ColorToBColorConverter(rGradient2.StartColor).getBColor()), +BColorStop(1.0, ColorToBColorConverter(rGradient2.EndColor).getBColor()) +}; +} } +BGradient::BGradient(const css::awt::Gradient2& rGradient2) { setGradient2(rGradient2); } + BGradient::BGradient(const css::uno::Any& rVal) : BGradient() { @@ -653,19 +669,7 @@ BGradient::BGradient(const css::uno::Any& rVal) css::awt::Gradient2 aGradient2; rVal >>= aGradient2; -// set values -SetGradientStyle(aGradient2.Style); -SetAngle(Degree10(aGradient2.Angle)); -SetBorder(aGradient2.Border); -SetXOffset(aGradient2.XOffset); -SetYOffset(aGradient2.YOffset); -SetStartIntens(aGradient2.StartIntensity); -SetEndIntens(aGradient2.EndIntensity); -SetSteps(aGradient2.StepCount); - -// set ColorStops -aColorStops = BColorStops(aGradient2.ColorStops); -aColorStops.sortAndCorrect(); +setGradient2(aGradient2); } else if (rVal.has()) { diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index c778a5237676..d7b1bb167613 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -265,47 +265,6 @@ namespace basegfx namespace utils { -/// Tooling method to fill awt::Gradient2 from data contained in the given Any -bool fillGradient2FromAny(css::awt::Gradient2& rGradient, const css::uno::Any& rVal) -{ -bool bRetval(false); - -if (rVal.has< css::awt::Gradient2 >()) -{ -// we can use awt::Gradient2 directly -bRetval = (rVal >>= rGradient); -} -else if (rVal.has< css::awt::Gradient >()) -{ -
[Libreoffice-commits] core.git: basegfx/source basegfx/test chart2/source drawinglayer/source filter/source include/basegfx oox/source svx/source sw/source xmloff/source
basegfx/source/matrix/b2dhommatrix.cxx | 211 +++ basegfx/source/point/b2dpoint.cxx| 15 - basegfx/source/point/b2ipoint.cxx| 15 - basegfx/test/B2DHomMatrixTest.cxx| 54 - chart2/source/tools/CommonConverters.cxx | 13 - drawinglayer/source/texture/texture.cxx | 14 - drawinglayer/source/tools/primitive2dxmldump.cxx |6 filter/source/msfilter/eschesdo.cxx |7 include/basegfx/matrix/b2dhommatrix.hxx | 60 +++--- oox/source/drawingml/shape.cxx |6 oox/source/shape/WpsContext.cxx |7 svx/source/unodraw/unoshape.cxx | 13 - sw/source/core/edit/edfcol.cxx | 13 - sw/source/core/unocore/unodraw.cxx | 13 - xmloff/source/draw/shapeexport.cxx |7 xmloff/source/draw/ximpshap.cxx |6 16 files changed, 181 insertions(+), 279 deletions(-) New commits: commit fdd06037e0cf902d71270c4bf7a867efc7c9c1f4 Author: Noel Grandin AuthorDate: Wed May 17 20:13:03 2023 +0200 Commit: Noel Grandin CommitDate: Thu May 18 21:18:06 2023 +0200 improved B2DHomMatrix since we know that this is a matrix only used for 2D transforms, we know that the last row of the matrix is always { 0, 0, 1 }. Therefore, we don't need to store that information, and we can simplify some of the computations. Also remove operations like operator+ which are not legal for such a matrix. Change-Id: I482de9a45ebbedf79e3b6033575aab590e61c2d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151909 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/basegfx/source/matrix/b2dhommatrix.cxx b/basegfx/source/matrix/b2dhommatrix.cxx index 4222c7a351c2..e4a9dda9e3c5 100644 --- a/basegfx/source/matrix/b2dhommatrix.cxx +++ b/basegfx/source/matrix/b2dhommatrix.cxx @@ -26,50 +26,56 @@ namespace basegfx { - -B2DHomMatrix::B2DHomMatrix(double f_0x0, double f_0x1, double f_0x2, double f_1x0, double f_1x1, double f_1x2) -{ -maImpl.set(0, 0, f_0x0); -maImpl.set(0, 1, f_0x1); -maImpl.set(0, 2, f_0x2); -maImpl.set(1, 0, f_1x0); -maImpl.set(1, 1, f_1x1); -maImpl.set(1, 2, f_1x2); -} - -void B2DHomMatrix::set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue) -{ -maImpl.set(nRow, nColumn, fValue); -} +constexpr int RowSize = 3; void B2DHomMatrix::set3x2(double f_0x0, double f_0x1, double f_0x2, double f_1x0, double f_1x1, double f_1x2) { -maImpl.set(0, 0, f_0x0); -maImpl.set(0, 1, f_0x1); -maImpl.set(0, 2, f_0x2); -maImpl.set(1, 0, f_1x0); -maImpl.set(1, 1, f_1x1); -maImpl.set(1, 2, f_1x2); -} - -bool B2DHomMatrix::isLastLineDefault() const -{ -return maImpl.isLastLineDefault(); +mfValues[0][0] = f_0x0; +mfValues[0][1] = f_0x1; +mfValues[0][2] = f_0x2; +mfValues[1][0] = f_1x0; +mfValues[1][1] = f_1x1; +mfValues[1][2] = f_1x2; } bool B2DHomMatrix::isIdentity() const { -return maImpl.isIdentity(); +for(sal_uInt16 a(0); a < RowSize - 1; a++) +{ +for(sal_uInt16 b(0); b < RowSize; b++) +{ +const double fDefault(internal::implGetDefaultValue(a, b)); +const double fValueAB(get(a, b)); + +if(!::basegfx::fTools::equal(fDefault, fValueAB)) +{ +return false; +} +} +} + +return true; } void B2DHomMatrix::identity() { -maImpl = Impl2DHomMatrix(); +for(sal_uInt16 a(0); a < RowSize - 1; a++) +{ +for(sal_uInt16 b(0); b < RowSize; b++) +mfValues[a][b] = internal::implGetDefaultValue(a, b); +} } bool B2DHomMatrix::isInvertible() const { -return maImpl.isInvertible(); +double dst[6]; +/* Compute adjoint: */ +computeAdjoint(dst); +/* Compute determinant: */ +double det = computeDeterminant(dst); +if (fTools::equalZero(det)) +return false; +return true; } bool B2DHomMatrix::invert() @@ -77,85 +83,43 @@ namespace basegfx if(isIdentity()) return true; - -double dst[9]; +double dst[6]; /* Compute adjoint: */ - -dst[0] = + get(1, 1) * get(2, 2) - get(1, 2) * get(2, 1); -dst[1] = - get(0, 1) * get(2, 2) + get(0, 2) * get(2, 1); -dst[2] = + get(0, 1) * get(1, 2) - get(0, 2) * get(1, 1); -dst[3] = - get(1, 0) * get(2, 2) + get(1, 2) * get(2, 0); -dst[4] = + get(0, 0) * get(2, 2) - get(0, 2) * get(2, 0); -dst[5] = - get(0, 0) * get(1, 2) + get(0, 2) * get(1, 0); -
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/matrix/b2dhommatrix.cxx | 56 ++--- 1 file changed, 45 insertions(+), 11 deletions(-) New commits: commit a78a9ea3a5f935bf364f59426b22e9039d2c1784 Author: Noel Grandin AuthorDate: Tue May 16 13:02:47 2023 +0200 Commit: Noel Grandin CommitDate: Wed May 17 15:26:04 2023 +0200 tdf#63130 use a simpler, SIMD-friendly algorithm for matrix invert which is 10% faster loading this document Algorithm copied from https://github.com/niswegmann/small-matrix-inverse/blob/master/invert3x3_c.h, which is CC0-1.0 licensed. Change-Id: I7aa272cae90b1aee30eb6b3e8e5acb260b92ceef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151830 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/basegfx/source/matrix/b2dhommatrix.cxx b/basegfx/source/matrix/b2dhommatrix.cxx index 565be5c68b1c..4222c7a351c2 100644 --- a/basegfx/source/matrix/b2dhommatrix.cxx +++ b/basegfx/source/matrix/b2dhommatrix.cxx @@ -75,21 +75,55 @@ namespace basegfx bool B2DHomMatrix::invert() { if(isIdentity()) -{ return true; -} -Impl2DHomMatrix aWork(maImpl); -sal_uInt16* pIndex = static_cast(alloca( sizeof(sal_uInt16) * Impl2DHomMatrix::getEdgeLength() )); -sal_Int16 nParity; -if(aWork.ludcmp(pIndex, nParity)) -{ -maImpl.doInvert(aWork, pIndex); -return true; -} +double dst[9]; + +/* Compute adjoint: */ -return false; +dst[0] = + get(1, 1) * get(2, 2) - get(1, 2) * get(2, 1); +dst[1] = - get(0, 1) * get(2, 2) + get(0, 2) * get(2, 1); +dst[2] = + get(0, 1) * get(1, 2) - get(0, 2) * get(1, 1); +dst[3] = - get(1, 0) * get(2, 2) + get(1, 2) * get(2, 0); +dst[4] = + get(0, 0) * get(2, 2) - get(0, 2) * get(2, 0); +dst[5] = - get(0, 0) * get(1, 2) + get(0, 2) * get(1, 0); +dst[6] = + get(1, 0) * get(2, 1) - get(1, 1) * get(2, 0); +dst[7] = - get(0, 0) * get(2, 1) + get(0, 1) * get(2, 0); +dst[8] = + get(0, 0) * get(1, 1) - get(0, 1) * get(1, 0); + +/* Compute determinant: */ + +double det = get(0, 0) * dst[0] + get(0, 1) * dst[3] + get(0, 2) * dst[6]; +if (fTools::equalZero(det)) +return false; + +/* Multiply adjoint with reciprocal of determinant: */ + +det = 1.0 / det; + +maImpl.set(0, 0, dst[0] * det); +maImpl.set(0, 1, dst[1] * det); +maImpl.set(0, 2, dst[2] * det); +maImpl.set(1, 0, dst[3] * det); +maImpl.set(1, 1, dst[4] * det); +maImpl.set(1, 2, dst[5] * det); +maImpl.set(2, 0, dst[6] * det); +maImpl.set(2, 1, dst[7] * det); +maImpl.set(2, 2, dst[8] * det); + +// The above algorithm is very slightly less accurate then the old one, so +// we need to round the last row to make sure that functions like decompose +// still do the same thing with existing data, otherwise testTdf109143 +// in CppunitTest_vcl_pdfexport will fail. +if (fTools::equalZero(maImpl.get(2, 0))) +maImpl.set(2, 0, 0); +if (fTools::equalZero(maImpl.get(2, 1))) +maImpl.set(2, 1, 0); +if (fTools::equal(1.0, maImpl.get(2, 2))) +maImpl.set(2, 2, 1); + +return true; } B2DHomMatrix& B2DHomMatrix::operator+=(const B2DHomMatrix& rMat)
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/bgradient.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 68655b362f8129f6f3762bf7926690c1a40c9821 Author: Andrea Gelmini AuthorDate: Mon May 15 23:44:01 2023 +0200 Commit: Julien Nabet CommitDate: Tue May 16 09:47:25 2023 +0200 Fix typo Change-Id: Id590b13237bc148dac955d6f4d56092f86d1dd16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151817 Tested-by: Julien Nabet Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index f2e7d90190a9..134fda548ece 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -683,7 +683,7 @@ BGradient::BGradient(const css::uno::Any& rVal) SetEndIntens(aGradient.EndIntensity); SetSteps(aGradient.StepCount); -// complete data by creating ColorStops from fixe Start/EndColor +// complete data by creating ColorStops from fixed Start/EndColor aColorStops = BColorStops{ BColorStop(0.0, ColorToBColorConverter(aGradient.StartColor).getBColor()), BColorStop(1.0, ColorToBColorConverter(aGradient.EndColor).getBColor())
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/bgradient.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 8c76c0538d81a1425caca55c917367492b7cc631 Author: Andrea Gelmini AuthorDate: Mon May 15 23:43:29 2023 +0200 Commit: Julien Nabet CommitDate: Tue May 16 09:40:44 2023 +0200 Fix typo Change-Id: I5701a1fdfe9e4f139049ed6c0de1748ec7c06e07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151816 Tested-by: Julien Nabet Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index 7cb1ed85e859..f2e7d90190a9 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -101,7 +101,7 @@ BColorStops::BColorStops(const css::uno::Any& rVal) } } -// constuctor with two colors to explicitly create a +// constructor with two colors to explicitly create a // BColorStops for a single StartColor @0.0 & EndColor @1.0 BColorStops::BColorStops(const BColor& rStart, const BColor& rEnd) {
[Libreoffice-commits] core.git: basegfx/source include/basegfx solenv/clang-format
basegfx/source/matrix/b2dhommatrix.cxx | 92 +-- basegfx/source/matrix/b3dhommatrix.cxx |2 include/basegfx/matrix/b2dhommatrix.hxx | 27 --- include/basegfx/matrix/hommatrixtemplate.hxx |3 solenv/clang-format/excludelist |2 5 files changed, 51 insertions(+), 75 deletions(-) New commits: commit 83650c82b56f496cd165981aa34edef9d5547697 Author: Noel Grandin AuthorDate: Mon May 15 15:28:34 2023 +0200 Commit: Noel Grandin CommitDate: Tue May 16 07:57:51 2023 +0200 tdf#63130 make B2DHomMatrix a flat object instead of using COW for its data. This takes the load time from 1m29 to 1m12 Also fix a bug in ImplHomMatrixTemplate::operator= which never triggered before because the usage of o3tl::cow_wrapper means it very seldom gets used. Change-Id: Ib0a7bdddf6c014f583e06d15e8dce5025e67e4a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151793 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/basegfx/source/matrix/b2dhommatrix.cxx b/basegfx/source/matrix/b2dhommatrix.cxx index 9811304d..565be5c68b1c 100644 --- a/basegfx/source/matrix/b2dhommatrix.cxx +++ b/basegfx/source/matrix/b2dhommatrix.cxx @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include #include @@ -26,73 +26,50 @@ namespace basegfx { -typedef ::basegfx::internal::ImplHomMatrixTemplate< 3 > Impl2DHomMatrix_Base; -class Impl2DHomMatrix : public Impl2DHomMatrix_Base -{ -}; - -static o3tl::cow_wrapper DEFAULT; - -B2DHomMatrix::B2DHomMatrix() : mpImpl(DEFAULT) {} - -B2DHomMatrix::B2DHomMatrix(const B2DHomMatrix&) = default; - -B2DHomMatrix::B2DHomMatrix(B2DHomMatrix&&) = default; - -B2DHomMatrix::~B2DHomMatrix() = default; B2DHomMatrix::B2DHomMatrix(double f_0x0, double f_0x1, double f_0x2, double f_1x0, double f_1x1, double f_1x2) { -mpImpl->set(0, 0, f_0x0); -mpImpl->set(0, 1, f_0x1); -mpImpl->set(0, 2, f_0x2); -mpImpl->set(1, 0, f_1x0); -mpImpl->set(1, 1, f_1x1); -mpImpl->set(1, 2, f_1x2); -} - -B2DHomMatrix& B2DHomMatrix::operator=(const B2DHomMatrix&) = default; - -B2DHomMatrix& B2DHomMatrix::operator=(B2DHomMatrix&&) = default; - -double B2DHomMatrix::get(sal_uInt16 nRow, sal_uInt16 nColumn) const -{ -return mpImpl->get(nRow, nColumn); +maImpl.set(0, 0, f_0x0); +maImpl.set(0, 1, f_0x1); +maImpl.set(0, 2, f_0x2); +maImpl.set(1, 0, f_1x0); +maImpl.set(1, 1, f_1x1); +maImpl.set(1, 2, f_1x2); } void B2DHomMatrix::set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue) { -mpImpl->set(nRow, nColumn, fValue); +maImpl.set(nRow, nColumn, fValue); } void B2DHomMatrix::set3x2(double f_0x0, double f_0x1, double f_0x2, double f_1x0, double f_1x1, double f_1x2) { -mpImpl->set(0, 0, f_0x0); -mpImpl->set(0, 1, f_0x1); -mpImpl->set(0, 2, f_0x2); -mpImpl->set(1, 0, f_1x0); -mpImpl->set(1, 1, f_1x1); -mpImpl->set(1, 2, f_1x2); +maImpl.set(0, 0, f_0x0); +maImpl.set(0, 1, f_0x1); +maImpl.set(0, 2, f_0x2); +maImpl.set(1, 0, f_1x0); +maImpl.set(1, 1, f_1x1); +maImpl.set(1, 2, f_1x2); } bool B2DHomMatrix::isLastLineDefault() const { -return mpImpl->isLastLineDefault(); +return maImpl.isLastLineDefault(); } bool B2DHomMatrix::isIdentity() const { -return mpImpl.same_object(DEFAULT) || mpImpl->isIdentity(); +return maImpl.isIdentity(); } void B2DHomMatrix::identity() { -*mpImpl = Impl2DHomMatrix(); +maImpl = Impl2DHomMatrix(); } bool B2DHomMatrix::isInvertible() const { -return mpImpl->isInvertible(); +return maImpl.isInvertible(); } bool B2DHomMatrix::invert() @@ -102,13 +79,13 @@ namespace basegfx return true; } -Impl2DHomMatrix aWork(*mpImpl); -sal_uInt16* pIndex = static_cast(alloca( sizeof(sal_uInt16) * Impl2DHomMatrix_Base::getEdgeLength() )); +Impl2DHomMatrix aWork(maImpl); +sal_uInt16* pIndex = static_cast(alloca( sizeof(sal_uInt16) * Impl2DHomMatrix::getEdgeLength() )); sal_Int16 nParity; if(aWork.ludcmp(pIndex, nParity)) { -mpImpl->doInvert(aWork, pIndex); +maImpl.doInvert(aWork, pIndex); return true; } @@ -117,13 +94,13 @@ namespace basegfx B2DHomMatrix& B2DHomMatrix::operator+=(const B2DHomMatrix& rMat) { -mpImpl->doAddMatrix(*rMat.mpImpl); +maImpl.doAddMatrix(rMat.maImpl); return *this; } B2DHomMatrix& B2DHomMatrix::operator-=(const B2DHomMatrix& rMat) { -mpImpl->doSubMatrix(*rMat.mpImpl); +maImpl.doSubMatri
[Libreoffice-commits] core.git: basegfx/source cui/source include/basegfx include/oox include/svx oox/source sd/source svx/source
basegfx/source/tools/gradienttools.cxx| 97 +- cui/source/inc/cuitabarea.hxx | 12 + cui/source/tabpages/tpgradnt.cxx | 38 +++-- cui/source/tabpages/tptrans.cxx | 36 +++-- include/basegfx/utils/gradienttools.hxx |5 include/oox/export/drawingml.hxx |5 include/svx/sidebar/AreaPropertyPanelBase.hxx |6 include/svx/sidebar/AreaTransparencyGradientPopup.hxx |4 oox/source/export/chartexport.cxx |6 oox/source/export/drawingml.cxx | 48 -- sd/source/ui/sidebar/SlideBackground.cxx | 28 +++- sd/source/ui/sidebar/SlideBackground.hxx |6 svx/source/sidebar/area/AreaPropertyPanelBase.cxx | 34 svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx | 18 ++ svx/source/unodraw/XPropertyTable.cxx | 21 ++- 15 files changed, 272 insertions(+), 92 deletions(-) New commits: commit 4409cd197dfb1fab05c0285f3ae17a107c99b77e Author: Armin Le Grand (allotropia) AuthorDate: Tue Apr 18 15:36:35 2023 +0200 Commit: Armin Le Grand CommitDate: Wed Apr 19 20:43:45 2023 +0200 MCGR: 2nd corrections/adaptions to MCGR Adapted handling of 'border' argument from our gradients for oox export, so that it looks the same. Also added quite some cases to peserve in-between GradientStops for current UI implementations to be able to edit the gradients as usual without losing the in-between GradientStops. While we will not be able to modify these, we are at least able to modify all the other gradient attributes, including start/endColor. Done this for TransparencyGradients, too. Also moved more stuff to the gradient tooling in basegfx. Change-Id: I6e94011bbf3715baa1401ab97e5b59811298342f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150577 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index f9e9ad494c4e..372abe08254b 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -264,6 +265,80 @@ namespace basegfx namespace utils { +/* Internal helper to convert ::Color from tools::color.hxx to BColor + without the need to link against tools library. Be on the + safe side by using the same union +*/ +namespace { +struct ColorToBColorConverter +{ +union { +sal_uInt32 mValue; +struct { +#ifdef OSL_BIGENDIAN +sal_uInt8 T; +sal_uInt8 R; +sal_uInt8 G; +sal_uInt8 B; +#else +sal_uInt8 B; +sal_uInt8 G; +sal_uInt8 R; +sal_uInt8 T; +#endif +}; +}; + +ColorToBColorConverter(sal_uInt32 nColor) : mValue(nColor) { T=0; } +BColor getBColor() const +{ +return BColor(R / 255.0, G / 255.0, B / 255.0); +} +}; +} + +/// Tooling method to fill awt::Gradient2 from data contained in the given Any +bool fillGradient2FromAny(css::awt::Gradient2& rGradient, const css::uno::Any& rVal) +{ +bool bRetval(false); + +if (rVal.has< css::awt::Gradient2 >()) +{ +// we can use awt::Gradient2 directly +bRetval = (rVal >>= rGradient); +} +else if (rVal.has< css::awt::Gradient >()) +{ +// 1st get awt::Gradient +css::awt::Gradient aTmp; + +if (rVal >>= aTmp) +{ +// copy all awt::Gradient data to awt::Gradient2 +rGradient.Style = aTmp.Style; +rGradient.StartColor = aTmp.StartColor; +rGradient.EndColor = aTmp.EndColor; +rGradient.Angle = aTmp.Angle; +rGradient.Border = aTmp.Border; +rGradient.XOffset = aTmp.XOffset; +rGradient.YOffset = aTmp.YOffset; +rGradient.StartIntensity = aTmp.StartIntensity; +rGradient.EndIntensity = aTmp.EndIntensity; +rGradient.StepCount = aTmp.StepCount; + +// complete data by creating ColorStops for awt::Gradient2 +fillColorStopSequenceFromColorStops( +rGradient.ColorStops, +ColorStops { +ColorS
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/gradienttools.cxx |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) New commits: commit 3e8a356f5ca00d875981b0f4279894c569bcc694 Author: Andrea Gelmini AuthorDate: Fri Apr 14 12:09:23 2023 +0200 Commit: Julien Nabet CommitDate: Fri Apr 14 14:27:49 2023 +0200 Fix typos Change-Id: I7f8fa704199865e67c0543f92f89f63765c8c2ef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150406 Tested-by: Julien Nabet Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 9e1159c46f1b..f9e9ad494c4e 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -332,15 +332,15 @@ namespace basegfx The intention is that a color GradientStops and an alpha/transparence GradientStops gets synchronized for export. - Fo the corrections the single values for color and + For the corrections the single values for color and alpha may be used, e.g. when ColorStops is given and not empty, but AlphaStops is empty, it will get - sycronized so that it will have the same number and + synchronized so that it will have the same number and offsets in AlphaStops as in ColorStops, but with the given SingleAlpha as value. At return it guarantees that both have the same number of entries with the same StopOffsets, so - that synchonized pair of ColorStops can e.g. be used + that synchronized pair of ColorStops can e.g. be used to export a Gradient with defined/adapted alpha being 'coupled' indirectly using the 'FillTransparenceGradient' method (at import time).
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/gradienttools.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit d1e97808f54bef3e5e87647d82e37662580b607c Author: Andrea Gelmini AuthorDate: Fri Apr 14 12:06:49 2023 +0200 Commit: Julien Nabet CommitDate: Fri Apr 14 14:26:41 2023 +0200 Fix typo Change-Id: Idb607f8d35163de55e29415efe8a3cfb029eb9e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150403 Tested-by: Julien Nabet Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 1d701e4b8248..9e1159c46f1b 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -265,7 +265,7 @@ namespace basegfx namespace utils { /* Tooling method to extract data from given awt::Gradient2 - to ColorStops, doing some corrections, partitally based + to ColorStops, doing some corrections, partially based on given SingleColor. This will do quite some preparations for the gradient as follows:
[Libreoffice-commits] core.git: basegfx/source include/basegfx
basegfx/source/tools/gradienttools.cxx |4 ++-- include/basegfx/utils/gradienttools.hxx |4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) New commits: commit ac9cdc995bc0f8f43ec2c4ad2e509b440f5b1b68 Author: Andrea Gelmini AuthorDate: Fri Apr 14 12:10:36 2023 +0200 Commit: Julien Nabet CommitDate: Fri Apr 14 14:24:39 2023 +0200 Fix typos Change-Id: I2b087d0f97c675cfedd4e2e78c7f827df4605fb0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150407 Tested-by: Julien Nabet Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 46d8fc7ca216..1d701e4b8248 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -273,9 +273,9 @@ namespace basegfx this is the case) and return with empty ColorStops - It will blend ColorStops to Intensity if StartIntensity/ EndIntensity != 100 is set in awt::Gradient2, so applying - that value(s) to the gadient directly + that value(s) to the gradient directly - It will adapt to Border if Border != 0 is set at the - given awt::Gradient2, so applying that value to the gadient + given awt::Gradient2, so applying that value to the gradient directly */ void prepareColorStops( diff --git a/include/basegfx/utils/gradienttools.hxx b/include/basegfx/utils/gradienttools.hxx index 4e78ad2ff960..419a31b86a1b 100644 --- a/include/basegfx/utils/gradienttools.hxx +++ b/include/basegfx/utils/gradienttools.hxx @@ -223,9 +223,9 @@ namespace basegfx this is the case) and return with empty ColorStops - It will blend ColorStops to Intensity if StartIntensity/ EndIntensity != 100 is set in awt::Gradient2, so applying - that value(s) to the gadient directly + that value(s) to the gradient directly - It will adapt to Border if Border != 0 is set at the - given awt::Gradient2, so applying that value to the gadient + given awt::Gradient2, so applying that value to the gradient directly */ BASEGFX_DLLPUBLIC void prepareColorStops(
[Libreoffice-commits] core.git: basegfx/source include/basegfx include/oox oox/source
basegfx/source/tools/gradienttools.cxx | 260 ++- include/basegfx/utils/gradienttools.hxx | 49 include/oox/export/drawingml.hxx| 27 +- oox/source/drawingml/fillproperties.cxx | 31 ++ oox/source/export/chartexport.cxx | 75 -- oox/source/export/drawingml.cxx | 361 +--- 6 files changed, 684 insertions(+), 119 deletions(-) New commits: commit 70684ab604c5fb32a16614c708f986671dd2da3c Author: Armin Le Grand (allotropia) AuthorDate: Thu Apr 13 12:13:19 2023 +0200 Commit: Armin Le Grand CommitDate: Fri Apr 14 11:56:46 2023 +0200 MCGR: Adaptions to oox export This is a 1st version and might need more fine-tuning, so it is still 'hidden' behind the MCGR_TEST env var being set (as the import is, too). Still, when used, it can now import a MCGR with transparence and export it again. I will now do extended testing/experimenting, fine-tuning where needed and prepare final change/drive forward. The current state in master should not be changed as long as the mentioned env var is not set, but this will need to be checked, too, due to changes to the export api in oox. Corrected an error in GetAlphaFromTransparenceGradient method(s), css::rendering::RGBColor is [0.0 .. 1.0] Corercted an error in WriteSolidFill where transparence gradient gets checked. This should really check if TrGr is used, but only checks for 'empty/unused' color instead (assuming COL_BLACK is 'unused'). All usages of GetAlphaFromTransparenceGradient should be checked and adapted. Change-Id: If59d7a06b9207e2efe9e71f3f8ddeca4476408f3 Change-Id: If97f8abdd0e1597aa1fd865b7e884e06a22b71f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150391 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index ca315f33f973..46d8fc7ca216 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -264,6 +264,237 @@ namespace basegfx namespace utils { +/* Tooling method to extract data from given awt::Gradient2 + to ColorStops, doing some corrections, partitally based + on given SingleColor. + This will do quite some preparations for the gradient + as follows: + - It will check for single color (resetting rSingleColor when + this is the case) and return with empty ColorStops + - It will blend ColorStops to Intensity if StartIntensity/ + EndIntensity != 100 is set in awt::Gradient2, so applying + that value(s) to the gadient directly + - It will adapt to Border if Border != 0 is set at the + given awt::Gradient2, so applying that value to the gadient + directly +*/ +void prepareColorStops( +const com::sun::star::awt::Gradient2& rGradient, +ColorStops& rColorStops, +BColor& rSingleColor) +{ +fillColorStopsFromGradient2(rColorStops, rGradient); + +if (isSingleColor(rColorStops, rSingleColor)) +{ +// when single color, preserve value in rSingleColor +// and clear the ColorStops, done. +rColorStops.clear(); +return; +} + +if (rGradient.StartIntensity != 100 || rGradient.EndIntensity != 100) +{ +// apply 'old' blend stuff, blend against black +blendColorStopsToIntensity( +rColorStops, +rGradient.StartIntensity * 0.01, +rGradient.EndIntensity * 0.01, +basegfx::BColor()); // COL_BLACK + +// can lead to single color (e.g. both zero, so all black), +// so check again +if (isSingleColor(rColorStops, rSingleColor)) +{ +rColorStops.clear(); +return; +} +} + +if (rGradient.Border != 0) +{ +// apply Border if set +// NOTE: no new start node is added. If this is needed, +// do that in the caller +const double fFactor(rGradient.Border * 0.01); +ColorStops aNewStops; + +for (const auto& candidate : rColorStops) +{ +aNewStops.emplace_back(candidate.getStopOffset() * fFactor, candidate.getStopColor()); +} + +rColorStops = aNewStops; +} +} + +/* Tooling method to synchronize the given ColorStops. + The intention is that a color GradientStops and an + alpha/transparence GradientStops gets synchronized + for export. +
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/gradienttools.cxx | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) New commits: commit a6cc4d851f1a061af71e03af4c886638d6a5f3b3 Author: Armin Le Grand (allotropia) AuthorDate: Wed Apr 5 10:25:51 2023 +0200 Commit: Armin Le Grand CommitDate: Thu Apr 6 10:40:49 2023 +0200 MCGR: Moved color compare in common computation part The colors of a ColorStopRange can be equal in case of hit *and* miss, so in both cases. I moved it to the common computation part. Prev version worked and did no harm, but unnecessary color interpolations for equal colors. Change-Id: I19031f1021ee5955b48da5c0d8e3a03cb9512ebf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150046 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 61e3f9b459bc..ca315f33f973 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -686,12 +686,6 @@ namespace basegfx if (rColorStops.end() == lowerBound) return rColorStops.back().getStopColor(); -// when there are just two color steps this cannot happen, but when using -// a range of colors this *may* be used inside the range to represent -// single-colored regions inside a ColorRange. Use that color & done -if (lowerBound->getStopColor() == upperBound->getStopColor()) -return rLastColorStopRange.maColorStart; - // we have lower and upper bound, get colors and offsets rLastColorStopRange.maColorStart = lowerBound->getStopColor(); rLastColorStopRange.maColorEnd = upperBound->getStopColor(); @@ -699,6 +693,11 @@ namespace basegfx rLastColorStopRange.mfOffsetEnd = upperBound->getStopOffset(); } +// when there are just two color steps this cannot happen, but when using +// a range of colors this *may* be used inside the range to represent +// single-colored regions inside a ColorRange. Use that color & done +if (rLastColorStopRange.maColorStart == rLastColorStopRange.maColorEnd) +return rLastColorStopRange.maColorStart; // calculate number of steps and adapted proportional // range for scaler in [0.0 .. 1.0]
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/gradienttools.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 73d0723c466e63c247d37ec8b9fa0bd8db8766b5 Author: Andrea Gelmini AuthorDate: Tue Apr 4 21:16:51 2023 +0200 Commit: Julien Nabet CommitDate: Tue Apr 4 21:26:49 2023 +0200 Fix typo Change-Id: I4ff8556c954cae844fa35385535cf9b6e9477e08 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150033 Tested-by: Julien Nabet Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 7f7d50abeb8c..61e3f9b459bc 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -700,7 +700,7 @@ namespace basegfx } -// calculate number of steps and adapted proportinal +// calculate number of steps and adapted proportional // range for scaler in [0.0 .. 1.0] const double fAdaptedScaler((fScaler - rLastColorStopRange.mfOffsetStart) / (rLastColorStopRange.mfOffsetEnd - rLastColorStopRange.mfOffsetStart));
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/gradienttools.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 7e1138db4e472e0d5de851c724e0048f1a834c08 Author: Andrea Gelmini AuthorDate: Tue Apr 4 21:16:39 2023 +0200 Commit: Julien Nabet CommitDate: Tue Apr 4 21:26:10 2023 +0200 Fix typo Change-Id: I09163a500caf66c6ac2921dca3128997574d20d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150032 Tested-by: Julien Nabet Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index fdc8dd189531..7f7d50abeb8c 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -655,7 +655,7 @@ namespace basegfx // or if we can re-use from last time. // If this scope is not entered, we do not need the binary search. It's // only a single buffered entry, and only used when more than three -// ColorStops exist, but makes a huge difference compared with acessing +// ColorStops exist, but makes a huge difference compared with accessing // the sorted ColorStop vector each time. // NOTE: with this simple change I get very high hit rates, e.g. rotating // a donut with gradient test '1' hit rate is at 0.99909440357755486
[Libreoffice-commits] core.git: basegfx/source drawinglayer/inc drawinglayer/source include/basegfx
basegfx/source/tools/gradienttools.cxx | 100 ++-- drawinglayer/inc/texture/texture.hxx|4 + drawinglayer/source/texture/texture.cxx | 13 ++-- include/basegfx/utils/gradienttools.hxx | 20 ++ 4 files changed, 87 insertions(+), 50 deletions(-) New commits: commit 4b5203ebf4ca5894f4d7dd37a141832df26e8b9a Author: Armin Le Grand (allotropia) AuthorDate: Tue Apr 4 14:57:06 2023 +0200 Commit: Armin Le Grand CommitDate: Tue Apr 4 18:55:49 2023 +0200 MCGR: Improve performance for texture-mapped MCGR processing Change-Id: I20b32e7c272112c6c3d9f7ee0ef59c6d4d006d94 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150020 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index dc6e4dc3f66a..fdc8dd189531 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -607,7 +607,8 @@ namespace basegfx BColor modifyBColor( const ColorStops& rColorStops, double fScaler, -sal_uInt32 nRequestedSteps) +sal_uInt32 nRequestedSteps, +ColorStopRange& rLastColorStopRange) { // no color at all, done if (rColorStops.empty()) @@ -650,56 +651,69 @@ namespace basegfx nSteps > 1 ? floor(fScaler * nSteps) / double(nSteps - 1) : fScaler); } -// access needed spot in sorted array using binary search -// NOTE: This *seems* slow(er) when developing compared to just -// looping/accessing, but that's just due to the extensive -// debug test code created by the stl. In a pro version, -// all is good/fast as expected -const auto upperBound( -std::upper_bound( -rColorStops.begin(), -rColorStops.end(), -ColorStop(fScaler), -[](const ColorStop& x, const ColorStop& y) { return x.getStopOffset() < y.getStopOffset(); })); - -// no upper bound, done -if (rColorStops.end() == upperBound) -return rColorStops.back().getStopColor(); - -// lower bound is one entry back -const auto lowerBound(upperBound - 1); - -// no lower bound, done -if (rColorStops.end() == lowerBound) -return rColorStops.back().getStopColor(); - -// we have lower and upper bound, get colors -const BColor aCStart(lowerBound->getStopColor()); -const BColor aCEnd(upperBound->getStopColor()); +// check if we need to newly populate the needed interpolation data +// or if we can re-use from last time. +// If this scope is not entered, we do not need the binary search. It's +// only a single buffered entry, and only used when more than three +// ColorStops exist, but makes a huge difference compared with acessing +// the sorted ColorStop vector each time. +// NOTE: with this simple change I get very high hit rates, e.g. rotating +// a donut with gradient test '1' hit rate is at 0.99909440357755486 +if (rLastColorStopRange.mfOffsetStart == rLastColorStopRange.mfOffsetEnd +|| fScaler < rLastColorStopRange.mfOffsetStart +|| fScaler > rLastColorStopRange.mfOffsetEnd) +{ +// access needed spot in sorted array using binary search +// NOTE: This *seems* slow(er) when developing compared to just +// looping/accessing, but that's just due to the extensive +// debug test code created by the stl. In a pro version, +// all is good/fast as expected +const auto upperBound( +std::upper_bound( +rColorStops.begin(), +rColorStops.end(), +ColorStop(fScaler), +[](const ColorStop& x, const ColorStop& y) { return x.getStopOffset() < y.getStopOffset(); })); + +// no upper bound, done +if (rColorStops.end() == upperBound) +return rColorStops.back().getStopColor(); + +// lower bound is one entry back, access that +const auto lowerBound(upperBound - 1); + +// no lower bound, done +if (rColorStops.end() == lowerBound) +return rColorStops.back().getStopColor(); + +// when there are just two color steps this cannot happen, but when using +// a range of colors this *may* be used inside the range to represent +// single-colored regions inside a ColorRange. Use that color & done
[Libreoffice-commits] core.git: basegfx/source include/basegfx
basegfx/source/tools/gradienttools.cxx |2 +- include/basegfx/utils/gradienttools.hxx |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) New commits: commit c2cc3e696e27f3ab218c56e90065f5c102ae50b6 Author: Andrea Gelmini AuthorDate: Mon Apr 3 20:12:21 2023 +0200 Commit: Julien Nabet CommitDate: Mon Apr 3 20:32:21 2023 +0200 Fix typo Change-Id: I49fe9dbdc11291c02be1dd5e41171a987d896008 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149997 Tested-by: Julien Nabet Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index d1b5874e5b77..dc6e4dc3f66a 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -270,7 +270,7 @@ namespace basegfx The intensity values fStartIntensity, fEndIntensity are in the range of [0.0 .. 1.0] and describe how much the blend is supposed to be done at the start color position - and the end color position resprectively, where 0.0 means + and the end color position respectively, where 0.0 means to fully use the given BlendColor, 1.0 means to not change the existing color in the ColorStop. Every color entry in the given ColorStop is blended diff --git a/include/basegfx/utils/gradienttools.hxx b/include/basegfx/utils/gradienttools.hxx index dfa1f35b38c4..ea1802c291f8 100644 --- a/include/basegfx/utils/gradienttools.hxx +++ b/include/basegfx/utils/gradienttools.hxx @@ -202,7 +202,7 @@ namespace basegfx The intensity values fStartIntensity, fEndIntensity are in the range of [0.0 .. 1.0] and describe how much the blend is supposed to be done at the start color position - and the end color position resprectively, where 0.0 means + and the end color position respectively, where 0.0 means to fully use the given BlendColor, 1.0 means to not change the existing color in the ColorStop. Every color entry in the given ColorStop is blended
[Libreoffice-commits] core.git: basegfx/source include/basegfx svx/source
basegfx/source/tools/gradienttools.cxx | 38 + include/basegfx/utils/gradienttools.hxx| 15 +++ svx/source/sdr/primitive2d/sdrattributecreator.cxx | 45 + 3 files changed, 81 insertions(+), 17 deletions(-) New commits: commit 64007cb308ead90ba6ffa2963c5de8ef89cec5ce Author: Armin Le Grand (allotropia) AuthorDate: Mon Apr 3 12:09:16 2023 +0200 Commit: Armin Le Grand CommitDate: Mon Apr 3 17:16:48 2023 +0200 MCGR: Unify Gradient intensity handling in tooling Moved the Gradient intensity handling to tooling since it is also needed for TransparencyGradients. Added missing use of GradientStepCount for transparency. Change-Id: I63ae6683fa0131be7faadc8572e19f5c43bf27e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149957 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 49cf831da262..d1b5874e5b77 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -264,6 +264,44 @@ namespace basegfx namespace utils { +/* Tooling method to linearly blend the Colors contained in + a given ColorStop vector against a given Color using the + given intensity values. + The intensity values fStartIntensity, fEndIntensity are + in the range of [0.0 .. 1.0] and describe how much the + blend is supposed to be done at the start color position + and the end color position resprectively, where 0.0 means + to fully use the given BlendColor, 1.0 means to not change + the existing color in the ColorStop. + Every color entry in the given ColorStop is blended + relative to it's StopPosition, interpolating the + given intensities with the range [0.0 .. 1.0] to do so. +*/ +void blendColorStopsToIntensity(ColorStops& rColorStops, double fStartIntensity, double fEndIntensity, const basegfx::BColor& rBlendColor) +{ +// no entries, done +if (rColorStops.empty()) +return; + +// correct intensities (maybe assert when input was wrong) +fStartIntensity = std::max(std::min(1.0, fStartIntensity), 0.0); +fEndIntensity = std::max(std::min(1.0, fEndIntensity), 0.0); + +// all 100%, no real blend, done +if (basegfx::fTools::equal(fStartIntensity, 1.0) && basegfx::fTools::equal(fEndIntensity, 1.0)) +return; + +// blend relative to StopOffset position +for (auto& candidate : rColorStops) +{ +const double fOffset(candidate.getStopOffset()); +const double fIntensity((fStartIntensity * (1.0 - fOffset)) + (fEndIntensity * fOffset)); +candidate = basegfx::ColorStop( +fOffset, +basegfx::interpolate(rBlendColor, candidate.getStopColor(), fIntensity)); +} +} + /* Tooling method to check if a ColorStop vector is defined by a single color. It returns true if this is the case. If true is returned, rSingleColor contains that single diff --git a/include/basegfx/utils/gradienttools.hxx b/include/basegfx/utils/gradienttools.hxx index c7123bc81db3..dfa1f35b38c4 100644 --- a/include/basegfx/utils/gradienttools.hxx +++ b/include/basegfx/utils/gradienttools.hxx @@ -196,6 +196,21 @@ namespace basegfx namespace utils { +/* Tooling method to linearly blend the Colors contained in + a given ColorStop vector against a given Color using the + given intensity values. + The intensity values fStartIntensity, fEndIntensity are + in the range of [0.0 .. 1.0] and describe how much the + blend is supposed to be done at the start color position + and the end color position resprectively, where 0.0 means + to fully use the given BlendColor, 1.0 means to not change + the existing color in the ColorStop. + Every color entry in the given ColorStop is blended + relative to it's StopPosition, interpolating the + given intensities with the range [0.0 .. 1.0] to do so. +*/ +BASEGFX_DLLPUBLIC void blendColorStopsToIntensity(ColorStops& rColorStops, double fStartIntensity, double fEndIntensity, const basegfx::BColor& rBlendColor); + /* Tooling method to check if a ColorStop vector is defined by a single color. It returns true if this is the case. If true is returned, rSingleColor contains that single diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx index 813c9884bc9b..89493e4d5a45 100644 --- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx ++
[Libreoffice-commits] core.git: basegfx/source include/basegfx include/oox oox/source svx/source
basegfx/source/tools/gradienttools.cxx | 32 ++ include/basegfx/utils/gradienttools.hxx|9 + include/oox/helper/modelobjecthelper.hxx |3 oox/source/drawingml/fillproperties.cxx| 110 - oox/source/drawingml/shapepropertymap.cxx | 16 ++- oox/source/helper/modelobjecthelper.cxx| 12 ++ svx/source/sdr/primitive2d/sdrattributecreator.cxx | 21 +--- 7 files changed, 184 insertions(+), 19 deletions(-) New commits: commit ce86e5b4a8d54eb55fdde7756ad6fde6e6967d55 Author: Armin Le Grand (allotropia) AuthorDate: Wed Mar 29 11:04:27 2023 +0200 Commit: Armin Le Grand CommitDate: Sun Apr 2 13:19:27 2023 +0200 MCGR: 1st additions to OOXML MCGR import This change provides 1st changes to get Gradients with muti color stops imported from MSO in the oox import filter. It supports currently multiple ColorStops and transparency. Also 'border'(s) should work, but -remember- this is work in progress. Since it is work in progress it is currently and temporaily secured by ENV VAR "MCGR_TEST=0", so when not using this the master version will not be touched at all. The number defines various ColorStop tests, 0 for none, but some changes are active, e.g. MSO import. You may try 1 or 16 to see all your Gradients hard replaced by something using that feature. I will take care fo cleaning this up again when the feature progresses/gets complete. Change-Id: I92e10d8cd5150733741a6def20a542abf97bd903 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149682 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index a98eeddf641c..49cf831da262 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -264,6 +264,38 @@ namespace basegfx namespace utils { +/* Tooling method to check if a ColorStop vector is defined + by a single color. It returns true if this is the case. + If true is returned, rSingleColor contains that single + color for convenience. + NOTE: If no ColorStop is defined, a fallback to BColor-default + (which is black) and true will be returned +*/ +bool isSingleColor(const ColorStops& rColorStops, BColor& rSingleColor) +{ +if (rColorStops.empty()) +{ +rSingleColor = BColor(); +return true; +} + +if (1 == rColorStops.size()) +{ +rSingleColor = rColorStops.front().getStopColor(); +return true; +} + +rSingleColor = rColorStops.front().getStopColor(); + +for (auto const& rCandidate : rColorStops) +{ +if (rCandidate.getStopColor() != rSingleColor) +return false; +} + +return true; +} + /* Tooling method to reverse ColorStops, including offsets. When also mirroring offsets a valid sort keeps valid. */ diff --git a/include/basegfx/utils/gradienttools.hxx b/include/basegfx/utils/gradienttools.hxx index 33f87717528b..c7123bc81db3 100644 --- a/include/basegfx/utils/gradienttools.hxx +++ b/include/basegfx/utils/gradienttools.hxx @@ -196,6 +196,15 @@ namespace basegfx namespace utils { +/* Tooling method to check if a ColorStop vector is defined + by a single color. It returns true if this is the case. + If true is returned, rSingleColor contains that single + color for convenience. + NOTE: If no ColorStop is defined, a fallback to BColor-default + (which is black) and true will be returned +*/ +BASEGFX_DLLPUBLIC bool isSingleColor(const ColorStops& rColorStops, BColor& rSingleColor); + /* Tooling method to reverse ColorStops, including offsets. When also mirroring offsets a valid sort keeps valid. */ diff --git a/include/oox/helper/modelobjecthelper.hxx b/include/oox/helper/modelobjecthelper.hxx index 9aba2538fdc4..6d4b1fea1925 100644 --- a/include/oox/helper/modelobjecthelper.hxx +++ b/include/oox/helper/modelobjecthelper.hxx @@ -28,6 +28,7 @@ namespace com::sun::star { namespace awt { struct Gradient; +struct Gradient2; class XBitmap; } namespace graphic { class XGraphic; } namespace container { class XNameContainer; } @@ -102,8 +103,10 @@ public: /** Inserts a new named fill gradient, returns the gradient name, based on an internal constant name with a new unused index appended. */ +OUString insertFillGradient( const css::awt::Gradient2& rGradient ); OUString insertFillGradient( const css::awt::Gradient& rGra
[Libreoffice-commits] core.git: basegfx/source svx/source
basegfx/source/tools/gradienttools.cxx | 71 +- svx/source/sdr/primitive2d/sdrattributecreator.cxx | 106 + 2 files changed, 173 insertions(+), 4 deletions(-) New commits: commit 13c37d2c0f0a172d2522b255c0416a4ade639b7a Author: Armin Le Grand (allotropia) AuthorDate: Mon Mar 27 12:35:07 2023 +0200 Commit: Armin Le Grand CommitDate: Mon Mar 27 12:42:28 2023 + MCGR: More corrections fo sortAndCorrectColorStops Handle cases where gradient snippets overlap Start/End- Color to preverve input information. Added more test cases to createNewSdrFillAttribute to check these cases. All 27 look good, so add this changes. Change-Id: I6b2ba190ac8cf5a00c5a27865cea6bb41efe5110 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149624 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 3b9fcda25ea1..a98eeddf641c 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -436,16 +436,60 @@ namespace basegfx for (size_t read(0); read < rColorStops.size(); read++) { // get offset of entry at read position -const double rOff(rColorStops[read].getStopOffset()); +double fOff(rColorStops[read].getStopOffset()); + +if (basegfx::fTools::less(fOff, 0.0) && read + 1 < rColorStops.size()) +{ +// value < 0.0 and we have a next entry. check for gradient snippet +// containing 0.0 resp. StartColor +const double fOff2(rColorStops[read + 1].getStopOffset()); + +if (basegfx::fTools::more(fOff2, 0.0)) +{ +// read is the start of a gradient snippet containing 0.0. Correct +// entry to StartColor, interpolate to correct StartColor +rColorStops[read] = ColorStop(0.0, basegfx::interpolate( +rColorStops[read].getStopColor(), +rColorStops[read + 1].getStopColor(), +(0.0 - fOff) / (fOff2 - fOff))); + +// adapt fOff +fOff = 0.0; +} +} // step over < 0 values, these are outside and will be removed -if (basegfx::fTools::less(rOff, 0.0)) +if (basegfx::fTools::less(fOff, 0.0)) +{ continue; +} + +if (basegfx::fTools::less(fOff, 1.0) && read + 1 < rColorStops.size()) +{ +// value < 1.0 and we have a next entry. check for gradient snippet +// containing 1.0 resp. EndColor +const double fOff2(rColorStops[read + 1].getStopOffset()); + +if (basegfx::fTools::more(fOff2, 1.0)) +{ +// read is the start of a gradient snippet containing 1.0. Correct +// next entry to EndColor, interpolate to correct EndColor +rColorStops[read + 1] = ColorStop(1.0, basegfx::interpolate( +rColorStops[read].getStopColor(), +rColorStops[read + 1].getStopColor(), +(1.0 - fOff) / (fOff2 - fOff))); + +// adapt fOff +fOff = 1.0; +} +} // step over > 1 values; even break, since all following // entries will also be bigger due to being sorted, so done -if (basegfx::fTools::more(rOff, 1.0)) +if (basegfx::fTools::more(fOff, 1.0)) +{ break; +} // entry is valid value at read position // copy if write target is empty (write at start) or when @@ -467,7 +511,26 @@ namespace basegfx // last used position + 1 if (rColorStops.size() > write) { -rColorStops.resize(write); +if (0 == write) +{ +// no valid entries at all, but not empty. This can only happen +// when all entries are below 0.0 or above 1.0 (else a gradient +// snippet spawning over both would have been detected) +if (basegfx::fTools::less(rColorStops.back().getStopOffset(), 0.0)) +{ +// all outside too low, rescue last due to being closest to content +rColorStops = ColorStops { ColorStop(0.0, rColorStops.back().getStopColor()) }; +} +else // if
[Libreoffice-commits] core.git: basegfx/source drawinglayer/source
basegfx/source/tools/gradienttools.cxx |2 +- drawinglayer/source/texture/texture.cxx |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) New commits: commit 6fc0de7ce23f8faec052c744434006d40a33110a Author: Andrea Gelmini AuthorDate: Tue Mar 21 20:46:59 2023 +0100 Commit: Julien Nabet CommitDate: Wed Mar 22 07:01:51 2023 + Fix typos Change-Id: Iaf63fce5295f00e5d6fff020498a01a25fc0ee93 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149262 Tested-by: Julien Nabet Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 6055143d5abd..3b9fcda25ea1 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -508,7 +508,7 @@ namespace basegfx // we need to extend the interpolation to the local // range of ColorStops. Despite having two ColorStops -// these are not necessarily at 0.0 and 1.0, so mabe +// these are not necessarily at 0.0 and 1.0, so may be // not the classical Start/EndColor (what is allowed) fScaler = (fScaler - fMin) / (fMax - fMin); return basegfx::interpolate( diff --git a/drawinglayer/source/texture/texture.cxx b/drawinglayer/source/texture/texture.cxx index 136284635e1b..de0f02057b4e 100644 --- a/drawinglayer/source/texture/texture.cxx +++ b/drawinglayer/source/texture/texture.cxx @@ -115,7 +115,7 @@ namespace drawinglayer::texture return false; // not needed when the last two ColorStops have different offset, then -// a visible range will be pocessed already +// a visible range will be processed already if (!basegfx::fTools::equal(mnColorStops.back().getStopOffset(), penultimate->getStopOffset())) return false;
[Libreoffice-commits] core.git: basegfx/source drawinglayer/inc drawinglayer/source include/basegfx svx/source
basegfx/source/tools/gradienttools.cxx | 76 +++ drawinglayer/inc/texture/texture.hxx|3 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx | 14 + drawinglayer/source/texture/texture.cxx | 173 +--- include/basegfx/utils/gradienttools.hxx | 12 - svx/source/sdr/primitive2d/sdrattributecreator.cxx | 75 ++ 6 files changed, 269 insertions(+), 84 deletions(-) New commits: commit 808c5bf66370f78f36e98887db0848ee7e55bb3a Author: Armin Le Grand (allotropia) AuthorDate: Tue Mar 21 13:13:15 2023 +0100 Commit: Armin Le Grand CommitDate: Tue Mar 21 15:53:06 2023 + MCGR: Model data changes for ColorSteps (II) The biggest change here is to allow multiple ColorStops with the same Offset. That allows to define gradients with 'hard' color changes at any place using two ColorStops with the same Offset and different Colors. This required quite some adaptions, but works well. Also removed in this context checking for all Colors being the same to not mix up things. Also works well. Also changed the need for having Start/EndColors AKA ColorStops for 0.0 and 1.0 in place, instead 'imply' the 1st ColorStop to also define the StartColor and the last one the EndColor. This allows e.g. Gradient definitions with two GradientStops at the same Offset e.g. 0.5 with different colors to already define a full Gradient. Also added a tooling method to reverse ColorSteps, which changes the order and mirrors the Offsets (what even keeps an existing sort valid). This is useful e.g. for GradientAxial which is the only one where for decomposition the Gradient had to be interpreted 'reverse' since it's defined from center to edge, but for creating correct filled polygons to represent this the inverse order had to be used, creating polygons from edge to center. This led to 'wild' code for this one of six cases and prevented unifications with the other cases (also made your brain flip). Thus I adapted this now to use the reversed ColorSteps consequently, and the same principle loops than the other implementations to make things easier for the future and to use common tooling. Change-Id: If2943348d17d5b9cd165f4d78f22638a1dff5237 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149208 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index d43f7899121a..6055143d5abd 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -264,6 +264,17 @@ namespace basegfx namespace utils { +/* Tooling method to reverse ColorStops, including offsets. + When also mirroring offsets a valid sort keeps valid. +*/ +void reverseColorStops(ColorStops& rColorStops) +{ +// can use std::reverse, but also need to adapt offset(s) +std::reverse(rColorStops.begin(), rColorStops.end()); +for (auto& candidate : rColorStops) +candidate = ColorStop(1.0 - candidate.getStopOffset(), candidate.getStopColor()); +} + /* Tooling method to convert UNO API data to ColorStops This will try to extract ColorStop data from the given Any, so if it's of type awt::Gradient2 that data will be @@ -374,13 +385,8 @@ namespace basegfx be removed) - contains no ColorStops with offset > 1.0 (will be removed) - - contains no two ColorStops with identical offsets - (will be removed, 1st one/smallest offset wins - which is also given by sort tooling) + - ColorStops with identical offsets are now allowed - will be sorted from lowest offset to highest - - if all colors are the same, the content will - be reduced to a single entry with offset 0.0 - (force to StartColor) Some more notes: - It can happen that the result is empty @@ -404,8 +410,15 @@ namespace basegfx if (1 == rColorStops.size()) { // no gradient at all, but preserve given color -// and force it to be the StartColor -rColorStops[0] = ColorStop(0.0, rColorStops[0].getStopColor()); +// evtl. correct offset to be in valid range [0.0 .. 1.0] +// NOTE: This does not move it to 0.0 or 1.0, it *can* still +// be somewhere in-between what is allowed +rColorStops[0] = ColorStop( +std::max(0.0, std::min(1.0, rColorStops[0].getStopOffset())), +rColorStops[0].getStopColor()); + +// done +return; }
[Libreoffice-commits] core.git: basegfx/source chart2/source cui/source drawinglayer/inc drawinglayer/qa drawinglayer/source filter/source include/basegfx include/drawinglayer include/svx offapi/com o
basegfx/source/tools/gradienttools.cxx | 191 +++--- chart2/source/controller/main/ChartController_Tools.cxx |7 cui/source/tabpages/tpgradnt.cxx| 32 + cui/source/tabpages/tptrans.cxx | 23 - drawinglayer/inc/texture/texture.hxx| 16 drawinglayer/qa/unit/vclpixelprocessor2d.cxx|8 drawinglayer/source/attribute/fillgradientattribute.cxx | 34 - drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx | 12 drawinglayer/source/primitive3d/textureprimitive3d.cxx | 10 drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx |8 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx | 12 drawinglayer/source/processor3d/defaultprocessor3d.cxx | 14 drawinglayer/source/texture/texture.cxx | 198 +- drawinglayer/source/tools/primitive2dxmldump.cxx| 17 drawinglayer/source/tools/wmfemfhelper.cxx | 12 filter/source/msfilter/msdffimp.cxx |8 filter/source/msfilter/svdfppt.cxx |6 include/basegfx/utils/gradienttools.hxx | 136 --- include/drawinglayer/attribute/fillgradientattribute.hxx| 20 - include/svx/unomid.hxx |1 include/svx/xgrad.hxx | 21 - offapi/UnoApi_offapi.mk |3 offapi/com/sun/star/awt/ColorStop.idl | 32 + offapi/com/sun/star/awt/ColorStopSequence.idl | 17 offapi/com/sun/star/awt/Gradient2.idl | 26 + reportdesign/source/ui/misc/UITools.cxx |4 reportdesign/source/ui/report/ReportController.cxx |3 sc/qa/unit/subsequent_filters_test3.cxx | 16 sd/qa/unit/uiimpress.cxx|4 sd/source/core/drawdoc4.cxx | 49 +- sd/source/ui/sidebar/SlideBackground.cxx| 11 sd/source/ui/view/drviews9.cxx | 41 +- svx/source/customshapes/EnhancedCustomShape2d.cxx | 21 - svx/source/sdr/attribute/sdrallfillattributeshelper.cxx |8 svx/source/sdr/primitive2d/sdrattributecreator.cxx | 113 ++--- svx/source/sidebar/area/AreaPropertyPanelBase.cxx | 21 - svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx | 17 svx/source/svdraw/gradtrns.cxx | 16 svx/source/svdraw/svdetc.cxx|4 svx/source/svdraw/svdfmtf.cxx | 17 svx/source/svdraw/svdoashp.cxx | 10 svx/source/unodraw/XPropertyTable.cxx | 11 svx/source/unodraw/unobrushitemhelper.cxx |8 svx/source/xoutdev/xattr.cxx| 227 +++- svx/source/xoutdev/xpool.cxx| 14 svx/source/xoutdev/xtabgrdt.cxx | 25 - sw/source/core/unocore/unoframe.cxx |6 sw/source/filter/ww8/docxattributeoutput.cxx|4 sw/source/filter/ww8/rtfattributeoutput.cxx |8 sw/source/uibase/docvw/HeaderFooterWin.cxx |6 sw/source/uibase/docvw/ShadowOverlayObject.cxx | 21 - sw/source/uibase/sidebar/PageStylesPanel.cxx| 11 52 files changed, 959 insertions(+), 601 deletions(-) New commits: commit 01d0019c851b9e942f9a3b94d6dd554fb1adb40c Author: Armin Le Grand (allotropia) AuthorDate: Mon Mar 13 19:39:34 2023 +0100 Commit: Armin Le Grand CommitDate: Sun Mar 19 17:38:38 2023 + MCGR: Model data changes for ColorSteps Added tooling replaceStart/EndColor to allow simple transition for code that does not immediately adapt to multi color gradients. Also added createColorStepsFromStartEndColor for the same purpose. Adapted XGradient to no longer have Start/EndColor at all, but only use ColorSteps. Adapted all usages of XGradient to no longer use Get/Set/Start/EndColor, but access the ColorSteps instead. Replaced quite some XGradient constructors that used XGradient() as Start/EndColor since this is already the default. Adapted ColorBlending to black AKA Start/EndIntens in XGradient to work now on all ColorSteps in the required linearly-scaled manner. UNO API changes: Added com::sun::star::awt::ColorStep as basic data element that holds a pair of Offset and Color. Added com::sun::star::awt::ColorStepSequence to handle an array of sorted entries. Added com::sun::star::awt::Gradient2 derived from com::sun:
[Libreoffice-commits] core.git: basegfx/source sax/source ucb/source vcl/source vcl/unx
basegfx/source/polygon/b2dpolygontools.cxx|1 - basegfx/source/polygon/b3dpolygontools.cxx|1 - sax/source/fastparser/fastparser.cxx |2 +- ucb/source/cacher/contentresultsetwrapper.cxx |3 --- vcl/source/filter/ipict/ipict.cxx |2 +- vcl/source/outdev/bitmapex.cxx|2 -- vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx |2 +- 7 files changed, 3 insertions(+), 10 deletions(-) New commits: commit 363512d39ba1543b7e91af1d59dadb5378da7649 Author: Noel Grandin AuthorDate: Mon Mar 6 15:09:25 2023 +0200 Commit: Noel Grandin CommitDate: Mon Mar 6 16:48:15 2023 + clang-tidy dead-store Change-Id: I842114880c43dfcc342b6255b7d17befb905bccb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148345 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index 03f5299ca505..900ab735a1e0 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -1255,7 +1255,6 @@ namespace basegfx::utils // to enlarge these as needed const double fFactor(fCandidateLength / fAllowedLength); std::for_each(aDotDashArray.begin(), aDotDashArray.end(), [&fFactor](double &f){ f *= fFactor; }); -fDotDashLength *= fFactor; } // prepare current edge's start diff --git a/basegfx/source/polygon/b3dpolygontools.cxx b/basegfx/source/polygon/b3dpolygontools.cxx index a1f65bef2f48..3b3779d7460a 100644 --- a/basegfx/source/polygon/b3dpolygontools.cxx +++ b/basegfx/source/polygon/b3dpolygontools.cxx @@ -219,7 +219,6 @@ namespace basegfx::utils // to enlarge these as needed const double fFactor(fCandidateLength / fAllowedLength); std::for_each(aDotDashArray.begin(), aDotDashArray.end(), [&fFactor](double &f){ f *= fFactor; }); -fDotDashLength *= fFactor; } // prepare current edge's start diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx index aae3c1162d47..06e2fb1e3e92 100644 --- a/sax/source/fastparser/fastparser.cxx +++ b/sax/source/fastparser/fastparser.cxx @@ -1565,7 +1565,7 @@ static void NormalizeURI( OUString& rName ) // try OASIS + W3 URI normalization bool bSuccess = NormalizeOasisURN( rName ); if( ! bSuccess ) -bSuccess = NormalizeW3URI( rName ); +NormalizeW3URI( rName ); } constexpr OUStringLiteral XML_URI_W3_PREFIX(u"http://www.w3.org/";); diff --git a/ucb/source/cacher/contentresultsetwrapper.cxx b/ucb/source/cacher/contentresultsetwrapper.cxx index f6e7c0058a65..72388222f12d 100644 --- a/ucb/source/cacher/contentresultsetwrapper.cxx +++ b/ucb/source/cacher/contentresultsetwrapper.cxx @@ -275,10 +275,7 @@ void SAL_CALL ContentResultSetWrapper::dispose() } if (isCleared) -{ aGuard.lock(); -isCleared = false; -} if( m_aDisposeEventListeners.getLength(aGuard) ) { EventObject aEvt; diff --git a/vcl/source/filter/ipict/ipict.cxx b/vcl/source/filter/ipict/ipict.cxx index fcdef08e3592..2d9be6f8cd9c 100644 --- a/vcl/source/filter/ipict/ipict.cxx +++ b/vcl/source/filter/ipict/ipict.cxx @@ -783,7 +783,7 @@ sal_uInt64 PictReader::ReadPixMapEtc( BitmapEx &rBitmap, bool bBaseAddr, bool bC else { nRowBytes &= 0x3fff; -nPixelSize = nCmpCount = nCmpSize = 1; +nPixelSize = nCmpCount = 1; nDataSize += 10; aPalette.resize(2); aPalette[0] = Color(0xff, 0xff, 0xff); diff --git a/vcl/source/outdev/bitmapex.cxx b/vcl/source/outdev/bitmapex.cxx index 57851f943f51..9935a18bdee6 100644 --- a/vcl/source/outdev/bitmapex.cxx +++ b/vcl/source/outdev/bitmapex.cxx @@ -522,8 +522,6 @@ void OutputDevice::DrawTransformedBitmapEx( aAlpha.BlendWith( bitmapEx.GetAlphaMask()); bitmapEx = BitmapEx( bitmapEx.GetBitmap(), aAlpha ); } -if(rtl::math::approxEqual( fAlpha, 1.0 )) -fAlpha = 1.0; // avoid the need for approxEqual in backends // If the backend's implementation is known to not need any optimizations here, pass to it directly. // With most backends it's more performant to try to simplify to DrawBitmapEx() first. diff --git a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx index 9afb55f0eb21..36278074c446 100644 --- a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx +++ b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx @@ -1677,7 +1677,7 @@ void SalGtkFilePicker::impl_initialize(GtkWidget* pParentWidget, sal_Int16 templ GtkFileChooserAction eAction = GTK_FILE_CHOOSER_ACTION_OPEN; OString sOpen = getOpenText(); OString sSave = getSaveText(); -const gchar *first_button_text = sOpen.getStr(); +const gchar *first_button_text; SolarMutexGuard
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/gradienttools.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit e540da2caadf4da228ddcc8c704f1f90a147493a Author: Andrea Gelmini AuthorDate: Sun Mar 5 00:57:28 2023 +0100 Commit: Julien Nabet CommitDate: Sun Mar 5 08:46:25 2023 + Fix typo Change-Id: Iddc3e2a28eb638f52a0560925bdeffddb20d3a86 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148264 Tested-by: Jenkins Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 9f147fd9b357..0bb45ba4d523 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -308,7 +308,7 @@ namespace basegfx // equal is defined here by offset (see use operator==) std::sort(rColorSteps.begin(), rColorSteps.end()); -// preapare status values +// prepare status values bool bSameColorInit(false); bool bAllTheSameColor(true); basegfx::BColor aFirstColor;
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/gradienttools.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit abe7425d44a2f367440da2d5d552d781e5511958 Author: Andrea Gelmini AuthorDate: Sun Mar 5 00:57:58 2023 +0100 Commit: Julien Nabet CommitDate: Sun Mar 5 08:46:05 2023 + Fix typo Change-Id: I5b58180d4d048155b927156be1fb6fb22f0e657c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148265 Tested-by: Jenkins Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 5743f71ad980..9f147fd9b357 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -274,7 +274,7 @@ namespace basegfx (will be removed, 1st one wins) - will be sorted from lowest offset to highest - if all colors are the same, the content will - be reducved to a single entry with offset 0.0 + be reduced to a single entry with offset 0.0 (StartColor) Some more notes:
[Libreoffice-commits] core.git: basegfx/source drawinglayer/qa drawinglayer/source include/basegfx include/drawinglayer svx/source sw/source
basegfx/source/tools/gradienttools.cxx | 115 ++ drawinglayer/qa/unit/vclpixelprocessor2d.cxx |5 drawinglayer/source/attribute/fillgradientattribute.cxx | 116 ++- drawinglayer/source/primitive3d/textureprimitive3d.cxx |9 + drawinglayer/source/texture/texture.cxx | 46 ++--- drawinglayer/source/tools/wmfemfhelper.cxx |8 - include/basegfx/utils/gradienttools.hxx | 31 +++- include/drawinglayer/attribute/fillgradientattribute.hxx | 21 +- svx/source/sdr/primitive2d/sdrattributecreator.cxx | 45 - svx/source/xoutdev/xtabgrdt.cxx |8 - sw/source/uibase/docvw/HeaderFooterWin.cxx |7 sw/source/uibase/docvw/ShadowOverlayObject.cxx | 20 +- 12 files changed, 264 insertions(+), 167 deletions(-) New commits: commit ecae66c41d82fecddd630cfdc144055a069134b0 Author: Armin Le Grand (allotropia) AuthorDate: Fri Mar 3 18:03:56 2023 +0100 Commit: Armin Le Grand CommitDate: Sat Mar 4 16:32:16 2023 + MCGR: ColorSteps handling moved to tooling Due to the fact that handling of a vector GradientSteps will get used more often with ongoing changes I moved some handling to tooling, see sortAndCorrectColorSteps. That method sorts and corrects a vector of ColorSteps so that only valid entreis remain in a sorted order, for details please refer to the docu at function definition. I took the occasion to rearrange that to work on the single provided vector which is better for speed & ressources. Also changed the ColorStep constructor to not automatically correct constructed entries: While that is formally correct, it moves an invalid entry to 0.0 or 1.0, thus creating additional wrong Start/EndColor entries. Those may then 'overlay' the correct entry when corrections are applied to the vector of entries which leads to getting the wanted Start/EndColor to be factically deleted, what is an error. Also rearranged FillGradientAttribute to now work initially with ColorSteps, no longer requires the Start/EndColor, also adapted all usages. This securely allows start/end and in-between single-color sections in gradients. Also needed to re-formulate GradientRect & GradientElliptical ::appendTransformationsAndColors method for correct 2D mapping(s) - always incrementing from the start to end conflicts with the adaption of the start value for the inner loop mainly because increment is at start of inner loop (pre-increment). Corrected errors from clang plugin, but also some wrong initialiations for basegfx::ColorSteps. Change-Id: I292592ed9abcfa591f68a680479f4fcdda46cbeb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148196 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index f35f91f5a79a..5743f71ad980 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -263,6 +263,121 @@ namespace basegfx namespace utils { +/* Tooling method to guarantee sort and correctness for + the given ColorSteps vector. + At return, the following conditions are guaranteed: + - contains no ColorSteps with offset < 0.0 (will + be removed) + - contains no ColorSteps with offset > 0.0 (will + be removed) + - contains no ColorSteps with identical offset + (will be removed, 1st one wins) + - will be sorted from lowest offset to highest + - if all colors are the same, the content will + be reducved to a single entry with offset 0.0 + (StartColor) + + Some more notes: + - It can happen that the result is empty + - It is allowed to have consecutive entries with + the same color, this represents single-color + regions inside the gradient + - A entry with 0.0 is not required or forced, so + no 'StartColor' is required on this level + - A entry with 1.0 is not required or forced, so + no 'EndColor' is required on this level + + All this is done in one run (sort + O(N)) without + creating a copy of the data in any form +*/ +void sortAndCorrectColorSteps(ColorSteps& rColorSteps) +{ +// no content, we are done +if (rColorSteps.empty()) +return; + +if (1 == rColorSteps.size()) +{ +// no gradient at all, but preserve given color +// and force it to be the StartColor +rColorSteps[0] = ColorStep(0.0, rColorSteps[0].getColor()); +} + +// start wit
[Libreoffice-commits] core.git: basegfx/source drawinglayer/source
basegfx/source/tools/gradienttools.cxx | 27 --- drawinglayer/source/texture/texture.cxx | 253 +++- 2 files changed, 159 insertions(+), 121 deletions(-) New commits: commit 16e728a8a88a7a04acec069512a5268ae89cf420 Author: Armin Le Grand (allotropia) AuthorDate: Fri Feb 24 17:34:53 2023 +0100 Commit: Armin Le Grand CommitDate: Mon Feb 27 17:43:13 2023 + MCGR: Adapted other Gradient* to make use of MCGR Added to make GeoTexSvxGradientElliptical GeoTexSvxGradientSquare GeoTexSvxGradientRect work using the MCGR. It is still 100% backward-compatible, so as long as there is no source using this it will stay invisible - by purpose. Tests look good with all three, see the static variable nUseGradientSteps. NOTE: GeoTexSvxGradientElliptical still looks not optimal due to texture back-mapping method getEllipticalGradientAlpha, see notes in commit "MCGR: Adapted GradientRadial to make use of MCGR" ac824594c577ab4880177b3411a25297b1d08074 Change-Id: I56b82b867af88fe532f840dde15e0f5c299ed6a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147662 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 37671374262c..f35f91f5a79a 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -544,13 +544,6 @@ namespace basegfx t = 1.0 - std::hypot(aCoor.getX(), aCoor.getY() * fAspectRatio); } -const sal_uInt32 nSteps(rGradInfo.getRequestedSteps()); - -if(nSteps && t < 1.0) -{ -return floor(t * nSteps) / double(nSteps - 1); -} - return t; } @@ -571,15 +564,7 @@ namespace basegfx return 0.0; } -const double t(1.0 - std::max(fAbsX, fAbsY)); -const sal_uInt32 nSteps(rGradInfo.getRequestedSteps()); - -if(nSteps && t < 1.0) -{ -return floor(t * nSteps) / double(nSteps - 1); -} - -return t; +return 1.0 - std::max(fAbsX, fAbsY); } double getRectangularGradientAlpha(const B2DPoint& rUV, const ODFGradientInfo& rGradInfo) @@ -643,15 +628,7 @@ namespace basegfx fAbsY = ((fAbsY - 1) / fAspectRatio) + 1; } -const double t(1.0 - std::max(fAbsX, fAbsY)); -const sal_uInt32 nSteps(rGradInfo.getRequestedSteps()); - -if(nSteps && t < 1.0) -{ -return floor(t * nSteps) / double(nSteps - 1); -} - -return t; +return 1.0 - std::max(fAbsX, fAbsY); } } // namespace utils } // namespace basegfx diff --git a/drawinglayer/source/texture/texture.cxx b/drawinglayer/source/texture/texture.cxx index e3ed2780af4e..22f56f33b8bd 100644 --- a/drawinglayer/source/texture/texture.cxx +++ b/drawinglayer/source/texture/texture.cxx @@ -455,60 +455,79 @@ namespace drawinglayer::texture std::vector< B2DHomMatrixAndBColor >& rEntries, basegfx::BColor& rOuterColor) { -if(mnColorSteps.size() <= 1) +// no color at all, done +if (mnColorSteps.empty()) return; -const basegfx::BColor maStart(mnColorSteps.front().getColor()); -const basegfx::BColor maEnd(mnColorSteps.back().getColor()); -const sal_uInt32 nSteps(basegfx::utils::calculateNumberOfSteps( -maGradientInfo.getRequestedSteps(), maStart, maEnd)); +// fill in return parameter rOuterColor before returning +rOuterColor = mnColorSteps.front().getColor(); -rOuterColor = maStart; -double fWidth(1.0); -double fHeight(1.0); -double fIncrementX(0.0); -double fIncrementY(0.0); +// only one color, done +if (mnColorSteps.size() < 2) +return; -if(maGradientInfo.getAspectRatio() > 1.0) -{ -fIncrementY = fHeight / nSteps; -fIncrementX = fIncrementY / maGradientInfo.getAspectRatio(); -} -else +// need to start with the offsets *outside* of all loops, these will +// get modified non-linear below, now in more than one gradient section, +// but *constantly* over the whole range +double fAllWidth(0.0); +double fAllHeight(0.0); + +// outer loop over ColorSteps, each is from cs_l to cs_r +for (auto cs_l(mnColorSteps.begin()), cs_r(cs_l + 1); cs_r != mnColorSteps.end(); cs_l++, cs_r++) { -fIncrementX = fWidth / nSteps; -fIncrementY = fIncrementX * maGradientInfo.getA
[Libreoffice-commits] core.git: basegfx/source drawinglayer/source
basegfx/source/tools/gradienttools.cxx | 10 drawinglayer/source/texture/texture.cxx | 67 +--- 2 files changed, 46 insertions(+), 31 deletions(-) New commits: commit ae51dfb2379a9e9183afa9a1e5ee4fe4f4f0f7ef Author: Armin Le Grand (allotropia) AuthorDate: Fri Feb 24 10:56:43 2023 +0100 Commit: Armin Le Grand CommitDate: Fri Feb 24 16:22:36 2023 + MCGR: Adapted GradientRadial to make use of MCGR Added to make GradientRadial work using the MCGR. It is still 100% backward-compatible, so as long as there is no source using this it will stay invisible - by purpose. Tests look good with this one, see the static variable nUseGradientSteps. Change-Id: Ie7134fe2995b23ceb180c7daf3f5b2310c8a8a78 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147617 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index b27443898f4e..37671374262c 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -515,15 +515,7 @@ namespace basegfx return 0.0; } -const double t(1.0 - std::hypot(aCoor.getX(), aCoor.getY())); -const sal_uInt32 nSteps(rGradInfo.getRequestedSteps()); - -if(nSteps && t < 1.0) -{ -return floor(t * nSteps) / double(nSteps - 1); -} - -return t; +return 1.0 - std::hypot(aCoor.getX(), aCoor.getY()); } double getEllipticalGradientAlpha(const B2DPoint& rUV, const ODFGradientInfo& rGradInfo) diff --git a/drawinglayer/source/texture/texture.cxx b/drawinglayer/source/texture/texture.cxx index 73110fc8b8fd..44ce9336ac89 100644 --- a/drawinglayer/source/texture/texture.cxx +++ b/drawinglayer/source/texture/texture.cxx @@ -367,42 +367,65 @@ namespace drawinglayer::texture std::vector< B2DHomMatrixAndBColor >& rEntries, basegfx::BColor& rOuterColor) { -if(mnColorSteps.size() <= 1) +// no color at all, done +if (mnColorSteps.empty()) return; -const basegfx::BColor maStart(mnColorSteps.front().getColor()); -const basegfx::BColor maEnd(mnColorSteps.back().getColor()); -const sal_uInt32 nSteps(basegfx::utils::calculateNumberOfSteps( -maGradientInfo.getRequestedSteps(), maStart, maEnd)); +// fill in return parameter rOuterColor before returning +rOuterColor = mnColorSteps.front().getColor(); -rOuterColor = maStart; -const double fStepSize(1.0 / nSteps); -B2DHomMatrixAndBColor aB2DHomMatrixAndBColor; +// only one color, done +if (mnColorSteps.size() < 2) +return; -for(sal_uInt32 a(1); a < nSteps; a++) +// outer loop over ColorSteps, each is from cs_l to cs_r +for (auto cs_l(mnColorSteps.begin()), cs_r(cs_l + 1); cs_r != mnColorSteps.end(); cs_l++, cs_r++) { -const double fSize(1.0 - (fStepSize * a)); -aB2DHomMatrixAndBColor.maB2DHomMatrix = maGradientInfo.getTextureTransform() * basegfx::utils::createScaleB2DHomMatrix(fSize, fSize); -aB2DHomMatrixAndBColor.maBColor = interpolate(maStart, maEnd, double(a) / double(nSteps - 1)); -rEntries.push_back(aB2DHomMatrixAndBColor); +// get colors & calculate steps +const basegfx::BColor aCStart(cs_l->getColor()); +const basegfx::BColor aCEnd(cs_r->getColor()); +const sal_uInt32 nSteps(basegfx::utils::calculateNumberOfSteps( +maGradientInfo.getRequestedSteps(), aCStart, aCEnd)); + +// get offsets & calculate StripeWidth +const double fOffsetStart(cs_l->getOffset()); +const double fOffsetEnd(cs_r->getOffset()); +const double fStripeWidth((fOffsetEnd - fOffsetStart) / nSteps); + +// get correct start for innner loop (see above) +const sal_uInt32 nStartInnerLoop(cs_l == mnColorSteps.begin() ? 1 : 0); + +for (sal_uInt32 innerLoop(nStartInnerLoop); innerLoop < nSteps; innerLoop++) +{ +// calculate size/radius +const double fSize(1.0 - (fOffsetStart + (fStripeWidth * innerLoop))); + +// set and add at target +B2DHomMatrixAndBColor aB2DHomMatrixAndBColor; + +aB2DHomMatrixAndBColor.maB2DHomMatrix = maGradientInfo.getTextureTransform() * basegfx::utils::createScaleB2DHomMatrix(fSize, fSize); +aB2DHomMatrixAndBColor.maBColor = interpolate(aCStart, aCEnd, double(innerLoop) / double(nSteps - 1)); +r
[Libreoffice-commits] core.git: basegfx/source drawinglayer/source
basegfx/source/tools/gradienttools.cxx | 18 drawinglayer/source/texture/texture.cxx | 119 +++- 2 files changed, 73 insertions(+), 64 deletions(-) New commits: commit 94cdbfb9316ab3b04327f960fa40aee07abbba91 Author: Armin Le Grand (allotropia) AuthorDate: Thu Feb 23 11:22:31 2023 +0100 Commit: Armin Le Grand CommitDate: Thu Feb 23 13:06:06 2023 + MCGR: Adapted GradientAxial to make use of MCGR Added to make GradientAxial work using the MCGR as 2nd of six types. This one was complicated since it uses the gradient(s) 'reversed' when you look at it, from outside to inside. Had to do quite some tickeling to get it all work, but looks good now. For modifyBColor I Could re-use the started tooling as planned. To get the reverse usage working I ended up in 1st adapting the previous usage to make more use of std::iterator and reverse_iterator to be able to use the reversed state of the ColorSteps more 'controlled' as if trying to adapt the numerical indices to the vector (that ended in chaos). It is still 100% backward-compatible, so as long as there is no source using this it will stay invisible - by purpose. Tests look good with this one, see the static variable nUseGradientSteps. Change-Id: I0117ec9a24b5e55869b3e2741c67fb87b549db97 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147510 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 4aa909fcf58c..b27443898f4e 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -467,7 +467,7 @@ namespace basegfx { const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV); -// Ignore Y, this is not needed at all for Y-Oriented gradients +// Ignore X, this is not needed at all for Y-Oriented gradients // if(aCoor.getX() < 0.0 || aCoor.getX() > 1.0) // { // return 0.0; @@ -483,13 +483,6 @@ namespace basegfx return 1.0; // end value for outside } -// const sal_uInt32 nSteps(rGradInfo.getRequestedSteps()); - -// if(nSteps) -// { -// return floor(aCoor.getY() * nSteps) / double(nSteps - 1); -// } - return aCoor.getY(); } @@ -497,7 +490,7 @@ namespace basegfx { const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV); -// Ignore Y, this is not needed at all for Y-Oriented gradients +// Ignore X, this is not needed at all for Y-Oriented gradients //if(aCoor.getX() < 0.0 || aCoor.getX() > 1.0) //{ //return 0.0; @@ -510,13 +503,6 @@ namespace basegfx return 1.0; // use end value when outside in Y } -const sal_uInt32 nSteps(rGradInfo.getRequestedSteps()); - -if(nSteps) -{ -return floor(fAbsY * nSteps) / double(nSteps - 1); -} - return fAbsY; } diff --git a/drawinglayer/source/texture/texture.cxx b/drawinglayer/source/texture/texture.cxx index 326d3bbe9146..73110fc8b8fd 100644 --- a/drawinglayer/source/texture/texture.cxx +++ b/drawinglayer/source/texture/texture.cxx @@ -138,18 +138,13 @@ namespace drawinglayer::texture if (mnColorSteps.empty()) return; -// get start color and also cc to rOuterColor -basegfx::BColor aCStart(mnColorSteps[0].getColor()); -rOuterColor = aCStart; +// fill in return parameter rOuterColor before returning +rOuterColor = mnColorSteps.front().getColor(); // only one color, done if (mnColorSteps.size() < 2) return; -// here we could check that fOffsetStart == mnColorSteps[0].getOffset(), -// but just assume/correct that StartColor is at 0.0 -double fOffsetStart(0.0 /*mnColorSteps[0].getOffset()*/); - // prepare unit range transform basegfx::B2DHomMatrix aPattern; @@ -161,14 +156,19 @@ namespace drawinglayer::texture aPattern.scale(mfUnitWidth, 1.0); aPattern.translate(mfUnitMinX, 0.0); -for (size_t outerLoop(1); outerLoop < mnColorSteps.size(); outerLoop++) +// outer loop over ColorSteps, each is from cs_l to cs_r +for (auto cs_l(mnColorSteps.begin()), cs_r(cs_l + 1); cs_r != mnColorSteps.end(); cs_l++, cs_r++) { -const basegfx::BColor aCEnd(mnColorSteps[outerLoop].getColor()); +// get colors & calculate steps +const basegfx::BColor aCStart(cs_l->getColor()); +const bas
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/polygon/b2dtrapezoid.cxx |3 +++ 1 file changed, 3 insertions(+) New commits: commit 29d795b772cb75ee1d12cc6bcd4d905f1c520a79 Author: Noel Grandin AuthorDate: Thu Feb 23 08:44:10 2023 +0200 Commit: Noel Grandin CommitDate: Thu Feb 23 12:48:27 2023 + avoid div/0 in getCutPointForGivenY Change-Id: I8e5e5689ee11777938ca7d0268b8e04e77466734 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147496 Reviewed-by: Michael Meeks Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/basegfx/source/polygon/b2dtrapezoid.cxx b/basegfx/source/polygon/b2dtrapezoid.cxx index b7991dbf55d4..2870c46d8236 100644 --- a/basegfx/source/polygon/b2dtrapezoid.cxx +++ b/basegfx/source/polygon/b2dtrapezoid.cxx @@ -174,6 +174,9 @@ namespace basegfx::trapezoidhelper // method for cut support B2DPoint getCutPointForGivenY(double fGivenY) const { +// avoid div/0 +if (getDeltaY() == 0) +return B2DPoint(getStart().getX(), fGivenY); // Calculate cut point locally (do not use interpolate) since it is numerically // necessary to guarantee the new, equal Y-coordinate const double fFactor((fGivenY - getStart().getY()) / getDeltaY());
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/gradienttools.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit b2eb17829a8da7828cdc60f262991aafda84f3ea Author: Andrea Gelmini AuthorDate: Wed Feb 22 14:42:13 2023 +0100 Commit: Julien Nabet CommitDate: Wed Feb 22 14:03:12 2023 + Fix typo Change-Id: I17aa944a68ac80f67034cc92fca3f7531e0d5385 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147475 Tested-by: Julien Nabet Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 605ed4bf8834..4aa909fcf58c 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -282,7 +282,7 @@ namespace basegfx // special case for the 'classic' case with just two colors: // we can optimize that and keep the speed/resources low -// by avoiding some calculatins and an O(log(N)) array access +// by avoiding some calculations and an O(log(N)) array access if (2 == rColorSteps.size()) { const basegfx::BColor aCStart(rColorSteps.front().getColor());
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/gradienttools.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit a2d61d9ff7cb7e0e0a0cb97d606a3b43a518704e Author: Andrea Gelmini AuthorDate: Wed Feb 22 14:39:52 2023 +0100 Commit: Julien Nabet CommitDate: Wed Feb 22 13:56:10 2023 + Fix typo Change-Id: I9bfdabcb7ba99c9e64dfc36aadfea8f6de02058b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147471 Tested-by: Julien Nabet Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 43cca3f1c7ea..605ed4bf8834 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -281,7 +281,7 @@ namespace basegfx return rColorSteps.back().getColor(); // special case for the 'classic' case with just two colors: -// we can optimize that and keep the speed/ressources low +// we can optimize that and keep the speed/resources low // by avoiding some calculatins and an O(log(N)) array access if (2 == rColorSteps.size()) {
[Libreoffice-commits] core.git: basegfx/source drawinglayer/source include/basegfx svx/source
basegfx/source/tools/gradienttools.cxx | 101 +++- drawinglayer/source/attribute/fillgradientattribute.cxx | 40 -- drawinglayer/source/texture/texture.cxx | 95 +-- include/basegfx/utils/gradienttools.hxx | 23 +++ svx/source/sdr/primitive2d/sdrattributecreator.cxx | 94 +- 5 files changed, 292 insertions(+), 61 deletions(-) New commits: commit c4f252035cd71f9a1b226e69095cc9f4e8f19f3e Author: Armin Le Grand (allotropia) AuthorDate: Tue Feb 21 18:35:39 2023 +0100 Commit: Armin Le Grand CommitDate: Wed Feb 22 09:13:20 2023 + MCGR: Adapted GradientLinear to make use of MCGR Added to make GradientLinear work using the MCGR as 1st of six types. Had to do quite some tickeling to get it all work, but looks good. Five more to go, already started to put some things to tooling to make re-usable for the other types. Besides adapting this the main change is that the adaption of defined step-count (versus automatic) has to be done in modifyBColor now instead of the back-mapping methods (e.g. getLinearGradientAlpha). It is still 100% backward-compatible, so as long as there is no source using this it will stay invisible - by purpose. I started to do quite some tests (and fixes/ adaptions in consequence), see the static variable nUseGradientSteps. If you want to play with this, you might set it to '1' instead of '0' and use a linear gradient on an object. Change-Id: I9d61934defb0674456247f2879f0a89b6a5e50f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147413 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index b2635b3f09cc..43cca3f1c7ea 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -21,6 +21,8 @@ #include #include #include + +#include #include namespace basegfx @@ -261,6 +263,95 @@ namespace basegfx namespace utils { +BColor modifyBColor( +const ColorSteps& rColorSteps, +double fScaler, +sal_uInt32 nRequestedSteps) +{ +// no color at all, done +if (rColorSteps.empty()) +return BColor(); + +// outside range -> at start +if (fScaler <= 0.0) +return rColorSteps.front().getColor(); + +// outside range -> at end +if (fScaler >= 1.0) +return rColorSteps.back().getColor(); + +// special case for the 'classic' case with just two colors: +// we can optimize that and keep the speed/ressources low +// by avoiding some calculatins and an O(log(N)) array access +if (2 == rColorSteps.size()) +{ +const basegfx::BColor aCStart(rColorSteps.front().getColor()); +const basegfx::BColor aCEnd(rColorSteps.back().getColor()); +const sal_uInt32 nSteps( +calculateNumberOfSteps( +nRequestedSteps, +aCStart, +aCEnd)); + +return basegfx::interpolate( +aCStart, +aCEnd, +nSteps > 1 ? floor(fScaler * nSteps) / double(nSteps - 1) : fScaler); +} + +// access needed spot in sorted array using binary search +// NOTE: This *seems* slow(er) when developing compared to just +// looping/accessing, but that's just due to the extensive +// debug test code created by the stl. In a pro version, +// all is good/fast as expected +const auto upperBound( +std::lower_bound( +rColorSteps.begin(), +rColorSteps.end(), +ColorStep(fScaler), +[](const ColorStep& x, const ColorStep& y) { return x.getOffset() < y.getOffset(); })); + +// no upper bound, done +if (rColorSteps.end() == upperBound) +return rColorSteps.back().getColor(); + +// lower bound is one entry back +const auto lowerBound(upperBound - 1); + +// no lower bound, done +if (rColorSteps.end() == lowerBound) +return rColorSteps.back().getColor(); + +// we have lower and upper bound, get colors +const BColor aCStart(lowerBound->getColor()); +const BColor aCEnd(upperBound->getColor()); + +// when there are just two color steps this cannot happen, but when using +// a range of colors this *may* be used inside the range to represent +// single-colored regions inside a ColorRange. Use that color
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/gradienttools.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 71a67048f5eafcf668d1ee6d70c66c04cb323b0f Author: Andrea Gelmini AuthorDate: Mon Feb 20 12:02:30 2023 +0100 Commit: Julien Nabet CommitDate: Mon Feb 20 21:16:07 2023 + Fix typo Change-Id: I0247eec84ea4c7dc5386bd8bcb9792601758e8c8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147317 Tested-by: Julien Nabet Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 5af4397eb3cd..b2635b3f09cc 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -464,7 +464,7 @@ namespace basegfx // MCGR: Similar to getRectangularGradientAlpha (please // see there) we need to use aspect ratio here. Due to // initEllipticalGradientInfo using M_SQRT2 to make this -// gradient look 'nicer' this correciton seems not 100% +// gradient look 'nicer' this correction seems not 100% // correct, but is close enough for now if(fAspectRatio > 1.0) {
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/gradienttools.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 389c6267974a90b9b0e1eaf2a7434ca4aea38f76 Author: Andrea Gelmini AuthorDate: Mon Feb 20 12:03:31 2023 +0100 Commit: Julien Nabet CommitDate: Mon Feb 20 21:15:45 2023 + Fix typo Change-Id: I34f84c957ba9480a1e8aa17a394e139a7f736050 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147318 Tested-by: Julien Nabet Reviewed-by: Julien Nabet diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index b3bb18f918da..5af4397eb3cd 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -530,7 +530,7 @@ namespace basegfx return 0.0; } -// MCGR: Visualiations using the texturing method for +// MCGR: Visualizations using the texturing method for // displaying gradients (getBackTextureTransform is // involved) show wrong results for GradientElliptical // and GradientRect, this can be best seen when using
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/tools/gradienttools.cxx | 102 - 1 file changed, 100 insertions(+), 2 deletions(-) New commits: commit ac824594c577ab4880177b3411a25297b1d08074 Author: Armin Le Grand (allotropia) AuthorDate: Fri Feb 17 14:05:59 2023 +0100 Commit: Armin Le Grand CommitDate: Mon Feb 20 09:18:18 2023 + MCGR: Correct GradientElliptical & GradientRect The visualizations when using the texturing methods modifyBColor/get*GradientAlpha were both not correct since they did not apply the aspect ratio. I corrected both where GradientRect is correct, but GradientElliptical is close and may have small divergencies. Change-Id: I6bcc07ec7cd4cdeb7863b51b20db3a7dd5afc41c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147218 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 3f2480c82e84..b3bb18f918da 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -451,7 +451,38 @@ namespace basegfx double getEllipticalGradientAlpha(const B2DPoint& rUV, const ODFGradientInfo& rGradInfo) { -return getRadialGradientAlpha(rUV, rGradInfo); // only matrix setup differs +const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV); + +if(aCoor.getX() < -1.0 || aCoor.getX() > 1.0 || aCoor.getY() < -1.0 || aCoor.getY() > 1.0) +{ +return 0.0; +} + +double fAspectRatio(rGradInfo.getAspectRatio()); +double t(1.0); + +// MCGR: Similar to getRectangularGradientAlpha (please +// see there) we need to use aspect ratio here. Due to +// initEllipticalGradientInfo using M_SQRT2 to make this +// gradient look 'nicer' this correciton seems not 100% +// correct, but is close enough for now +if(fAspectRatio > 1.0) +{ +t = 1.0 - std::hypot(aCoor.getX() / fAspectRatio, aCoor.getY()); +} +else if(fAspectRatio > 0.0) +{ +t = 1.0 - std::hypot(aCoor.getX(), aCoor.getY() * fAspectRatio); +} + +const sal_uInt32 nSteps(rGradInfo.getRequestedSteps()); + +if(nSteps && t < 1.0) +{ +return floor(t * nSteps) / double(nSteps - 1); +} + +return t; } double getSquareGradientAlpha(const B2DPoint& rUV, const ODFGradientInfo& rGradInfo) @@ -484,7 +515,74 @@ namespace basegfx double getRectangularGradientAlpha(const B2DPoint& rUV, const ODFGradientInfo& rGradInfo) { -return getSquareGradientAlpha(rUV, rGradInfo); // only matrix setup differs +const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV); +double fAbsX(fabs(aCoor.getX())); + +if(fAbsX >= 1.0) +{ +return 0.0; +} + +double fAbsY(fabs(aCoor.getY())); + +if(fAbsY >= 1.0) +{ +return 0.0; +} + +// MCGR: Visualiations using the texturing method for +// displaying gradients (getBackTextureTransform is +// involved) show wrong results for GradientElliptical +// and GradientRect, this can be best seen when using +// less steps, e.g. just four. This thus has influence +// on cppcanvas (slideshow) and 3D textures, so needs +// to be corrected. +// Missing is to use the aspect ratio of the object +// in this [-1, -1, 1, 1] unified coordinate space +// after getBackTextureTransform is applied. Optically +// in the larger direction of the texturing the color +// step distances are too big *because* we are in that +// unit range now. +// To correct that, a kind of 'limo stretching' needs to +// be applied, adding space around the center +// proportional to the aspect ratio, so the intuitive +// idea would be to do +// +// fAbsX' = ((fAspectRatio - 1) + fAbsX) / fAspectRatio +// +// which scales from the center. This does not work, and +// after some thoughts it's clear why: It's not the +// position that needs to be moved (this cannot be +// changed), but the position *before* that scale has +// to be determined to get the correct, shifted color +// for the already 'new' position. Thus, turn around +// the expression as +// +// fAbsX' * fAspectRatio = fAspectRatio - 1 + fAbsX +// fAbsX' * fAspectRatio - fAspectRatio + 1 = fAbsX +// fAbsX = (fAbsX' - 1) *
[Libreoffice-commits] core.git: basegfx/source drawinglayer/inc drawinglayer/source include/basegfx include/drawinglayer svx/source
basegfx/source/tools/gradienttools.cxx | 30 + drawinglayer/inc/texture/texture.hxx| 38 - drawinglayer/source/attribute/fillgradientattribute.cxx | 122 +++-- drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx | 53 -- drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx |1 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |1 drawinglayer/source/processor3d/defaultprocessor3d.cxx | 55 -- drawinglayer/source/texture/texture.cxx | 265 +++- drawinglayer/source/tools/primitive2dxmldump.cxx|1 drawinglayer/source/tools/wmfemfhelper.cxx |1 include/basegfx/utils/gradienttools.hxx | 115 - include/drawinglayer/attribute/fillgradientattribute.hxx| 68 --- svx/source/sdr/attribute/sdrallfillattributeshelper.cxx |1 svx/source/sdr/primitive2d/sdrattributecreator.cxx | 13 14 files changed, 437 insertions(+), 327 deletions(-) New commits: commit ea1d3d11ca113042a99effc168da834894005370 Author: Armin Le Grand (allotropia) AuthorDate: Wed Feb 15 10:45:10 2023 +0100 Commit: Armin Le Grand CommitDate: Wed Feb 15 14:46:11 2023 + MCGR: Add GradientSteps to GeoTexSvxGradient Move GradientSteps data to GeoTexSvxGradient and adapt interfaces. Also move tooling to more isolated place in gradienttools in basegfx. Keep everything still compatible, the work will be now to adapt all six different derivations of GeoTexSvxGradient to make use of the evtl. given GradientSteps. Change-Id: Iaa212763c603d46de0a94b1b203b979bb7ce359d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147050 Tested-by: Jenkins Reviewed-by: Armin Le Grand diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index c6e716510432..3f2480c82e84 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -29,7 +29,7 @@ namespace basegfx { return getTextureTransform() == rODFGradientInfo.getTextureTransform() && getAspectRatio() == rODFGradientInfo.getAspectRatio() -&& getSteps() == rODFGradientInfo.getSteps(); +&& getRequestedSteps() == rODFGradientInfo.getRequestedSteps(); } const B2DHomMatrix& ODFGradientInfo::getBackTextureTransform() const @@ -261,6 +261,26 @@ namespace basegfx namespace utils { +sal_uInt32 calculateNumberOfSteps( +sal_uInt32 nRequestedSteps, +const BColor& rStart, +const BColor& rEnd) +{ +const sal_uInt32 nMaxSteps(sal_uInt32((rStart.getMaximumDistance(rEnd) * 127.5) + 0.5)); + +if (0 == nRequestedSteps) +{ +nRequestedSteps = nMaxSteps; +} + +if(nRequestedSteps > nMaxSteps) +{ +nRequestedSteps = nMaxSteps; +} + +return std::max(sal_uInt32(1), nRequestedSteps); +} + ODFGradientInfo createLinearODFGradientInfo( const B2DRange& rTargetArea, sal_uInt32 nSteps, @@ -372,7 +392,7 @@ namespace basegfx return 1.0; // end value for outside } -const sal_uInt32 nSteps(rGradInfo.getSteps()); +const sal_uInt32 nSteps(rGradInfo.getRequestedSteps()); if(nSteps) { @@ -399,7 +419,7 @@ namespace basegfx return 1.0; // use end value when outside in Y } -const sal_uInt32 nSteps(rGradInfo.getSteps()); +const sal_uInt32 nSteps(rGradInfo.getRequestedSteps()); if(nSteps) { @@ -419,7 +439,7 @@ namespace basegfx } const double t(1.0 - std::hypot(aCoor.getX(), aCoor.getY())); -const sal_uInt32 nSteps(rGradInfo.getSteps()); +const sal_uInt32 nSteps(rGradInfo.getRequestedSteps()); if(nSteps && t < 1.0) { @@ -452,7 +472,7 @@ namespace basegfx } const double t(1.0 - std::max(fAbsX, fAbsY)); -const sal_uInt32 nSteps(rGradInfo.getSteps()); +const sal_uInt32 nSteps(rGradInfo.getRequestedSteps()); if(nSteps && t < 1.0) { diff --git a/drawinglayer/inc/texture/texture.hxx b/drawinglayer/inc/texture/texture.hxx index 9cfb2d6d56f7..567a24417f51 100644 --- a/drawinglayer/inc/texture/texture.hxx +++ b/drawinglayer/inc/texture/texture.hxx @@ -56,15 +56,15 @@ namespace drawinglayer::texture protected: basegfx::ODFGradientInfomaGradientInfo; basegfx::B2DRange maDefinitionRange; -basegfx::BColor maStart; -basegfx::BColor maEnd; +sal_uInt32
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/polygon/b2dpolygonclipper.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit df470d9658c202a990b9c75e2a8d6e3fd7a06dfd Author: Caolán McNamara AuthorDate: Wed Jan 25 19:42:37 2023 + Commit: Caolán McNamara CommitDate: Wed Jan 25 20:39:08 2023 + ofz#54437 Timeout Change-Id: Ib9b581a5e8b2385300923b2dc5bfaf7cee9c6bb4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146146 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/basegfx/source/polygon/b2dpolygonclipper.cxx b/basegfx/source/polygon/b2dpolygonclipper.cxx index 69eba2c84fa7..e9099b730578 100644 --- a/basegfx/source/polygon/b2dpolygonclipper.cxx +++ b/basegfx/source/polygon/b2dpolygonclipper.cxx @@ -489,7 +489,7 @@ namespace basegfx::utils // be solved again, they were solved in the preparation. aRetval.append(aMergePolyPolygonA); aRetval.append(aMergePolyPolygonB); -aRetval = solveCrossovers(aRetval); +aRetval = solveCrossovers(aRetval, pPointLimit); // now remove neutral polygons (closed, but no area). In a last // step throw away all polygons which have a depth of less than 1
[Libreoffice-commits] core.git: basegfx/source include/basegfx
basegfx/source/tools/canvastools.cxx |3 ++- basegfx/source/tools/unopolypolygon.cxx | 12 +++- include/basegfx/utils/unopolypolygon.hxx |8 +++- 3 files changed, 20 insertions(+), 3 deletions(-) New commits: commit d6a70bb641b96e8e5616448c2378131ed62658b4 Author: Stephan Bergmann AuthorDate: Thu Dec 1 08:48:48 2022 +0100 Commit: Stephan Bergmann CommitDate: Thu Dec 22 12:21:37 2022 + loplugin:unocast (basegfx::unotools::UnoPolyPolygon) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: I166d8f31a13a98caf0bb7a3b5025a9d942808096 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144746 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/basegfx/source/tools/canvastools.cxx b/basegfx/source/tools/canvastools.cxx index d388356199a2..1f65e89b182b 100644 --- a/basegfx/source/tools/canvastools.cxx +++ b/basegfx/source/tools/canvastools.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -251,7 +252,7 @@ namespace basegfx::unotools ::basegfx::B2DPolyPolygon b2DPolyPolygonFromXPolyPolygon2D( const uno::Reference< rendering::XPolyPolygon2D >& xPoly ) { ::basegfx::unotools::UnoPolyPolygon* pPolyImpl = -dynamic_cast< ::basegfx::unotools::UnoPolyPolygon* >( xPoly.get() ); +comphelper::getFromUnoTunnel< ::basegfx::unotools::UnoPolyPolygon >( xPoly ); if( pPolyImpl ) { diff --git a/basegfx/source/tools/unopolypolygon.cxx b/basegfx/source/tools/unopolypolygon.cxx index 0c3b59abac9b..099cbee5eb75 100644 --- a/basegfx/source/tools/unopolypolygon.cxx +++ b/basegfx/source/tools/unopolypolygon.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -60,7 +61,7 @@ namespace basegfx::unotools } B2DPolyPolygonaSrcPoly; -const UnoPolyPolygon* pSrc( dynamic_cast< UnoPolyPolygon* >(polyPolygon.get()) ); +const UnoPolyPolygon* pSrc( comphelper::getFromUnoTunnel< UnoPolyPolygon >(polyPolygon) ); // try to extract polygon data from interface. First, // check whether it's the same implementation object, @@ -434,6 +435,15 @@ namespace basegfx::unotools return { "com.sun.star.rendering.PolyPolygon2D" }; } +sal_Int64 UnoPolyPolygon::getSomething(css::uno::Sequence const & aIdentifier) { +return comphelper::getSomethingImpl(aIdentifier, this); +} + +css::uno::Sequence const & UnoPolyPolygon::getUnoTunnelId() { +static comphelper::UnoIdInit const id; +return id.getSeq(); +} + B2DPolyPolygon UnoPolyPolygon::getPolyPolygon() const { std::unique_lock const guard( m_aMutex ); diff --git a/include/basegfx/utils/unopolypolygon.hxx b/include/basegfx/utils/unopolypolygon.hxx index 48788b074ede..4392f798c6ce 100644 --- a/include/basegfx/utils/unopolypolygon.hxx +++ b/include/basegfx/utils/unopolypolygon.hxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -34,7 +35,8 @@ namespace basegfx::unotools typedef comphelper::WeakComponentImplHelper< css::rendering::XLinePolyPolygon2D, css::rendering::XBezierPolyPolygon2D, -css::lang::XServiceInfo > UnoPolyPolygonBase; +css::lang::XServiceInfo, +css::lang::XUnoTunnel > UnoPolyPolygonBase; class BASEGFX_DLLPUBLIC UnoPolyPolygon : public UnoPolyPolygonBase @@ -68,6 +70,10 @@ namespace basegfx::unotools SAL_DLLPRIVATE virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; SAL_DLLPRIVATE virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; +SAL_DLLPRIVATE sal_Int64 SAL_CALL getSomething( +css::uno::Sequence const & aIdentifier) override; +static SAL_DLLPRIVATE css::uno::Sequence const & getUnoTunnelId(); + SAL_DLLPRIVATE B2DPolyPolygon getPolyPolygon() const; protected:
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/color/bcolormodifier.cxx | 20 1 file changed, 12 insertions(+), 8 deletions(-) New commits: commit 2ce749a428d1df2c659ecfdaf2e151dd07d3f1b3 Author: Caolán McNamara AuthorDate: Wed Dec 21 14:23:10 2022 + Commit: Caolán McNamara CommitDate: Wed Dec 21 23:59:31 2022 + cid#1517814 Calling risky function Change-Id: I0451ac0375ad5a29a5bf65ebcc028ae44c43d934 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144688 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/basegfx/source/color/bcolormodifier.cxx b/basegfx/source/color/bcolormodifier.cxx index bd6157f373d5..f27ffcc9aaf0 100644 --- a/basegfx/source/color/bcolormodifier.cxx +++ b/basegfx/source/color/bcolormodifier.cxx @@ -18,10 +18,10 @@ */ #include - #include - +#include #include +#include namespace basegfx { @@ -304,17 +304,21 @@ namespace basegfx if(1.0 <= mfRandomPart) { // full randomized color -const double fMul(1.0 / RAND_MAX); -return basegfx::BColor(rand() * fMul, rand() * fMul, rand() * fMul); +return basegfx::BColor( +comphelper::rng::uniform_real_distribution(0.0, nextafter(1.0, DBL_MAX)), +comphelper::rng::uniform_real_distribution(0.0, nextafter(1.0, DBL_MAX)), +comphelper::rng::uniform_real_distribution(0.0, nextafter(1.0, DBL_MAX))); } // mixed color const double fMulA(1.0 - mfRandomPart); -const double fMulB(mfRandomPart / RAND_MAX); return basegfx::BColor( -aSourceColor.getRed() * fMulA + rand() * fMulB, -aSourceColor.getGreen() * fMulA + rand() * fMulB, -aSourceColor.getBlue() * fMulA + rand() * fMulB); +aSourceColor.getRed() * fMulA + +comphelper::rng::uniform_real_distribution(0.0, nextafter(mfRandomPart, DBL_MAX)), +aSourceColor.getGreen() * fMulA + +comphelper::rng::uniform_real_distribution(0.0, nextafter(mfRandomPart, DBL_MAX)), +aSourceColor.getBlue() * fMulA + +comphelper::rng::uniform_real_distribution(0.0, nextafter(mfRandomPart, DBL_MAX))); } ::basegfx::BColor BColorModifierStack::getModifiedColor(const ::basegfx::BColor& rSource) const
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/polygon/b2dpolygon.cxx |5 - 1 file changed, 4 insertions(+), 1 deletion(-) New commits: commit 24a2c65e7ea15166061d96352164b51c5ffd9fa8 Author: Noel Grandin AuthorDate: Sun Oct 30 08:01:00 2022 +0200 Commit: Noel Grandin CommitDate: Sun Oct 30 11:26:39 2022 +0100 tdf#126788 use singleton to avoid initial allocation Change-Id: I55011cdd3e6c457c6ab91d90579ace3524a9889d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142029 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx index b0171ef000e2..ed5954bf0cf7 100644 --- a/basegfx/source/polygon/b2dpolygon.cxx +++ b/basegfx/source/polygon/b2dpolygon.cxx @@ -1075,7 +1075,10 @@ public: namespace basegfx { -B2DPolygon::B2DPolygon() = default; +static o3tl::cow_wrapper DEFAULT; + +B2DPolygon::B2DPolygon() +: mpPolygon(DEFAULT) {} B2DPolygon::B2DPolygon(std::initializer_list aPoints) {
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/polygon/b2dpolypolygon.cxx |9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) New commits: commit 4e738b824d825717b7c6b895d816dcac1adf08e1 Author: Mike Kaganski AuthorDate: Wed Sep 21 15:28:12 2022 +0300 Commit: Mike Kaganski CommitDate: Wed Sep 21 17:06:05 2022 +0200 basegfx: remove global ImplB2DPolyPolygon Similar to commit 7e911e9cd469d30369c213aa529675b3f7c4f0e8 Author Michael Stahl Date Fri Aug 25 20:51:22 2017 +0200 basegfx: remove global ImplB2DPolygon There shouldn't be allocations of the objects just to destroy them without populating with data (it there are, they should be optimized away); and for any reasonable use, defaulting to a shared instance means that there is an unnecessary refcount increase and decrease aside from inevitable allocation of the unique instance. Change-Id: Ia92c229165c0836e56778d9274f0728181048e8c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140341 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx index 1889ddae4220..547634dc4dad 100644 --- a/basegfx/source/polygon/b2dpolypolygon.cxx +++ b/basegfx/source/polygon/b2dpolypolygon.cxx @@ -211,10 +211,7 @@ public: } }; -static o3tl::cow_wrapper DEFAULT; - -B2DPolyPolygon::B2DPolyPolygon() : -mpPolyPolygon(DEFAULT) {} +B2DPolyPolygon::B2DPolyPolygon() = default; B2DPolyPolygon::B2DPolyPolygon(const B2DPolyPolygon&) = default; @@ -301,9 +298,7 @@ public: B2DPolyPolygon aRetval; if (count()) { -// Avoid CoW overhead for the local variable -// But detach from shared static DEFAULT -ImplB2DPolyPolygon& dest = aRetval.mpPolyPolygon.make_unique(); +ImplB2DPolyPolygon& dest = *aRetval.mpPolyPolygon; dest.reserve(count()); for (sal_uInt32 a(0); a < count(); a++)
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/polygon/b2dpolypolygon.cxx | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) New commits: commit e4a72aa946b6c41a91dc6e74634093a83b9c22bd Author: Mike Kaganski AuthorDate: Tue Sep 20 18:28:36 2022 +0300 Commit: Mike Kaganski CommitDate: Tue Sep 20 21:20:08 2022 +0200 tdf#151056: avoid modifying the static shared DEFAULT instance This was a thinko in commit e39fa3c4f5ae2560a4b6f6f789a0c5098ac43cf4 Simplify b2d(poly)polygon implementation This led to exponential growth of elements in each next polypolygon created from scratch, that immediately manifested with the complex SVG logo shown on the backing window. And finally, there's no const_cast/as_const left in the file :) Change-Id: Ie60f75ec86a8fa21799f4f1b589c04c9e4646183 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140248 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx index 6ce3b398a1fb..1889ddae4220 100644 --- a/basegfx/source/polygon/b2dpolypolygon.cxx +++ b/basegfx/source/polygon/b2dpolypolygon.cxx @@ -299,13 +299,17 @@ public: B2DPolyPolygon B2DPolyPolygon::getDefaultAdaptiveSubdivision() const { B2DPolyPolygon aRetval; -// Avoid CoW overhead for the local variable -auto dest = const_cast(std::as_const(aRetval).mpPolyPolygon.get()); -dest->reserve(count()); - -for(sal_uInt32 a(0); a < count(); a++) +if (count()) { -dest->append(getB2DPolygon(a).getDefaultAdaptiveSubdivision(), 1); +// Avoid CoW overhead for the local variable +// But detach from shared static DEFAULT +ImplB2DPolyPolygon& dest = aRetval.mpPolyPolygon.make_unique(); +dest.reserve(count()); + +for (sal_uInt32 a(0); a < count(); a++) +{ +dest.append(getB2DPolygon(a).getDefaultAdaptiveSubdivision(), 1); +} } return aRetval;
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/polygon/b2dpolygon.cxx |9 + basegfx/source/polygon/b2dpolypolygon.cxx |2 ++ 2 files changed, 11 insertions(+) New commits: commit c8649af8d0353e2fba2e472f0ace50f5bd8167b2 Author: Mike Kaganski AuthorDate: Tue Sep 20 11:16:17 2022 +0300 Commit: Mike Kaganski CommitDate: Tue Sep 20 17:26:54 2022 +0200 Assert that cow_wrapped objects aren't called to do nothing An omission from commit e39fa3c4f5ae2560a4b6f6f789a0c5098ac43cf4 Simplify b2d(poly)polygon implementation Change-Id: Ib0b10e06baf91888f0e9797e670e0626f512af15 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140229 Tested-by: Mike Kaganski Reviewed-by: Mike Kaganski diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx index 03957c8710a3..b0171ef000e2 100644 --- a/basegfx/source/polygon/b2dpolygon.cxx +++ b/basegfx/source/polygon/b2dpolygon.cxx @@ -82,6 +82,7 @@ public: void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rValue, sal_uInt32 nCount) { +assert(nCount > 0); assert(nIndex <= maVector.size()); // add nCount copies of rValue maVector.insert(maVector.begin() + nIndex, nCount, rValue); @@ -89,6 +90,7 @@ public: void insert(sal_uInt32 nIndex, const CoordinateDataArray2D& rSource) { +assert(rSource.maVector.size() > 0); assert(nIndex <= maVector.size()); // insert data auto aIndex = maVector.begin(); @@ -100,6 +102,7 @@ public: void remove(sal_uInt32 nIndex, sal_uInt32 nCount) { +assert(nCount > 0); assert(nIndex + nCount <= maVector.size()); // remove point data const auto aStart = maVector.begin() + nIndex; @@ -328,6 +331,7 @@ public: void insert(sal_uInt32 nIndex, const ControlVectorPair2D& rValue, sal_uInt32 nCount) { +assert(nCount > 0); assert(nIndex <= maVector.size()); // add nCount copies of rValue @@ -342,6 +346,7 @@ public: void insert(sal_uInt32 nIndex, const ControlVectorArray2D& rSource) { +assert(rSource.maVector.size() > 0); assert(nIndex <= maVector.size()); // insert data @@ -362,6 +367,7 @@ public: void remove(sal_uInt32 nIndex, sal_uInt32 nCount) { +assert(nCount > 0); assert(nIndex + nCount <= maVector.size()); const ControlVectorPair2DVector::iterator aDeleteStart(maVector.begin() + nIndex); @@ -689,6 +695,7 @@ public: void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rPoint, sal_uInt32 nCount) { +assert(nCount > 0); mpBufferedData.reset(); auto aCoordinate = rPoint; maPoints.insert(nIndex, aCoordinate, nCount); @@ -804,6 +811,7 @@ public: void append(const ImplB2DPolygon& rSource) { +assert(rSource.maPoints.count() > 0); const sal_uInt32 nIndex = count(); mpBufferedData.reset(); @@ -828,6 +836,7 @@ public: void remove(sal_uInt32 nIndex, sal_uInt32 nCount) { +assert(nCount > 0); mpBufferedData.reset(); maPoints.remove(nIndex, nCount); diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx index dc8f0f53e98c..6ce3b398a1fb 100644 --- a/basegfx/source/polygon/b2dpolypolygon.cxx +++ b/basegfx/source/polygon/b2dpolypolygon.cxx @@ -102,6 +102,7 @@ public: void insert(sal_uInt32 nIndex, const basegfx::B2DPolygon& rPolygon, sal_uInt32 nCount) { +assert(nCount > 0); assert(nIndex <= maPolygons.size()); // add nCount copies of rPolygon maPolygons.insert(maPolygons.begin() + nIndex, nCount, rPolygon); @@ -131,6 +132,7 @@ public: void remove(sal_uInt32 nIndex, sal_uInt32 nCount) { +assert(nCount > 0); assert(nIndex + nCount <= maPolygons.size()); // remove polygon data auto aStart(maPolygons.begin() + nIndex);
[Libreoffice-commits] core.git: basegfx/source include/basegfx
basegfx/source/polygon/b2dpolygon.cxx | 270 -- basegfx/source/polygon/b2dpolypolygon.cxx | 121 + include/basegfx/polygon/b2dpolygon.hxx|3 3 files changed, 163 insertions(+), 231 deletions(-) New commits: commit e39fa3c4f5ae2560a4b6f6f789a0c5098ac43cf4 Author: Mike Kaganski AuthorDate: Sat Sep 17 21:02:44 2022 +0300 Commit: Mike Kaganski CommitDate: Sat Sep 17 21:50:38 2022 +0200 Simplify b2d(poly)polygon implementation Most size checks should be only done in the outer object; implementations inside cow_wrapper only assert correctness. All const_cast and as_const are replaced with correct const method calls (and, where needed, mutable members). Change-Id: I69e9f72086d07257ebd5cefaff7f214e198b901e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140106 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx index 8a413eaa..03957c8710a3 100644 --- a/basegfx/source/polygon/b2dpolygon.cxx +++ b/basegfx/source/polygon/b2dpolygon.cxx @@ -17,7 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include +#include + #include #include #include @@ -59,11 +60,13 @@ public: const basegfx::B2DPoint& getCoordinate(sal_uInt32 nIndex) const { +assert(nIndex < maVector.size()); return maVector[nIndex]; } void setCoordinate(sal_uInt32 nIndex, const basegfx::B2DPoint& rValue) { +assert(nIndex < maVector.size()); maVector[nIndex] = rValue; } @@ -79,46 +82,34 @@ public: void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rValue, sal_uInt32 nCount) { -if(nCount) -{ -// add nCount copies of rValue -auto aIndex = maVector.begin(); -aIndex += nIndex; -maVector.insert(aIndex, nCount, rValue); -} +assert(nIndex <= maVector.size()); +// add nCount copies of rValue +maVector.insert(maVector.begin() + nIndex, nCount, rValue); } void insert(sal_uInt32 nIndex, const CoordinateDataArray2D& rSource) { -const sal_uInt32 nCount(rSource.maVector.size()); - -if(nCount) -{ -// insert data -auto aIndex = maVector.begin(); -aIndex += nIndex; -auto aStart = rSource.maVector.cbegin(); -auto aEnd = rSource.maVector.cend(); -maVector.insert(aIndex, aStart, aEnd); -} +assert(nIndex <= maVector.size()); +// insert data +auto aIndex = maVector.begin(); +aIndex += nIndex; +auto aStart = rSource.maVector.cbegin(); +auto aEnd = rSource.maVector.cend(); +maVector.insert(aIndex, aStart, aEnd); } void remove(sal_uInt32 nIndex, sal_uInt32 nCount) { -if(nCount) -{ -// remove point data -auto aStart = maVector.begin(); -aStart += nIndex; -const auto aEnd = aStart + nCount; -maVector.erase(aStart, aEnd); -} +assert(nIndex + nCount <= maVector.size()); +// remove point data +const auto aStart = maVector.begin() + nIndex; +const auto aEnd = aStart + nCount; +maVector.erase(aStart, aEnd); } void flip(bool bIsClosed) { -if(maVector.size() <= 1) -return; +assert(maVector.size() > 1); // to keep the same point at index 0, just flip all points except the // first one when closed @@ -231,10 +222,9 @@ public: ControlVectorArray2D(const ControlVectorArray2D& rOriginal, sal_uInt32 nIndex, sal_uInt32 nCount) : mnUsedVectors(0) { -ControlVectorPair2DVector::const_iterator aStart(rOriginal.maVector.begin()); -aStart += nIndex; -ControlVectorPair2DVector::const_iterator aEnd(aStart); -aEnd += nCount; +assert(nIndex + nCount <= rOriginal.maVector.size()); +auto aStart(rOriginal.maVector.begin() + nIndex); +auto aEnd(aStart + nCount); maVector.reserve(nCount); for(; aStart != aEnd; ++aStart) @@ -261,6 +251,7 @@ public: const basegfx::B2DVector& getPrevVector(sal_uInt32 nIndex) const { +assert(nIndex < maVector.size()); return maVector[nIndex].getPrevVector(); } @@ -293,6 +284,7 @@ public: const basegfx::B2DVector& getNextVector(sal_uInt32 nIndex) const { +assert(nIndex < maVector.size()); return maVector[nIndex].getNextVector(); } @@ -336,13 +328,10 @@ public: void insert(sal_uInt32 nIndex, const ControlVectorPair2D& rValue, sal_uInt32 nCount) { -if(!nCount) -return; +assert(nIndex <= maVector.size()); // add nCount copies of rValue -ControlVectorPair2DVector:
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/workbench/gauss.hxx |6 +- 1 file changed, 1 insertion(+), 5 deletions(-) New commits: commit 51a780a26e4fbf339d4136ff0c7d75e01d6fad08 Author: Radhey Parekh AuthorDate: Thu Sep 15 15:37:50 2022 +0200 Commit: Hossein CommitDate: Thu Sep 15 18:07:06 2022 +0200 tdf#148251 Use std::swap() instead of using temporary values Change-Id: Ifdf59f4957428efdc56009947f8c87f6b6351603 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139273 Tested-by: Jenkins Reviewed-by: Hossein diff --git a/basegfx/source/workbench/gauss.hxx b/basegfx/source/workbench/gauss.hxx index 3605c1cac9bd..4ef050ccbc52 100644 --- a/basegfx/source/workbench/gauss.hxx +++ b/basegfx/source/workbench/gauss.hxx @@ -47,8 +47,6 @@ bool eliminate( Matrix& matrix, int cols, const BaseType& minPivot) { -BaseTypetemp; - /* i, j, k *must* be signed, when looping like: j>=0 ! */ /* eliminate below main diagonal */ for(int i=0; i
[Libreoffice-commits] core.git: basegfx/source include/basegfx
basegfx/source/point/b2dpoint.cxx|7 - basegfx/source/vector/b2dvector.cxx |7 - include/basegfx/point/b2dpoint.hxx |9 +- include/basegfx/tuple/Tuple2D.hxx| 48 +-- include/basegfx/tuple/b2dtuple.hxx | 32 ++- include/basegfx/vector/b2dvector.hxx | 11 +--- 6 files changed, 59 insertions(+), 55 deletions(-) New commits: commit c2d3f4be406b3bef8e89b17b781cb7e827a0fe3d Author: Tomaž Vajngerl AuthorDate: Tue Sep 6 19:37:20 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Sat Sep 10 08:45:51 2022 +0200 basegfx: simplify Tuple2D, B2DPoint, B2DVector, B2DTuple Change-Id: I97e41fc62288ec4ee5805747fd3a3a6e019cfb57 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139681 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/basegfx/source/point/b2dpoint.cxx b/basegfx/source/point/b2dpoint.cxx index 0dc18b513db1..02e6711ac44c 100644 --- a/basegfx/source/point/b2dpoint.cxx +++ b/basegfx/source/point/b2dpoint.cxx @@ -23,13 +23,6 @@ namespace basegfx { -B2DPoint& B2DPoint::operator=( const ::basegfx::B2DTuple& rPoint ) -{ -mfX = rPoint.getX(); -mfY = rPoint.getY(); -return *this; -} - B2DPoint& B2DPoint::operator*=( const ::basegfx::B2DHomMatrix& rMat ) { double fTempX( diff --git a/basegfx/source/vector/b2dvector.cxx b/basegfx/source/vector/b2dvector.cxx index 1ad51a9b5a4c..d0fcebb62eac 100644 --- a/basegfx/source/vector/b2dvector.cxx +++ b/basegfx/source/vector/b2dvector.cxx @@ -51,13 +51,6 @@ namespace basegfx return *this; } -B2DVector& B2DVector::operator=( const B2DTuple& rVec ) -{ -mfX = rVec.getX(); -mfY = rVec.getY(); -return *this; -} - double B2DVector::getLength() const { if(fTools::equalZero(mfX)) diff --git a/include/basegfx/point/b2dpoint.hxx b/include/basegfx/point/b2dpoint.hxx index d2f77aa493a3..3bd6af90af9c 100644 --- a/include/basegfx/point/b2dpoint.hxx +++ b/include/basegfx/point/b2dpoint.hxx @@ -73,7 +73,7 @@ namespace basegfx /** constructor with tuple to allow copy-constructing from B2DTuple-based classes */ -B2DPoint(const ::basegfx::B2DTuple& rTuple) +B2DPoint(Tuple2D const& rTuple) : B2DTuple(rTuple) {} @@ -98,7 +98,12 @@ namespace basegfx /** assignment operator to allow assigning the results of B2DTuple calculations */ -BASEGFX_DLLPUBLIC B2DPoint& operator=( const ::basegfx::B2DTuple& rPoint ); +BASEGFX_DLLPUBLIC B2DPoint& operator=(Tuple2D& rPoint) +{ +mfX = rPoint.getX(); +mfY = rPoint.getY(); +return *this; +} /** Transform point by given transformation matrix. diff --git a/include/basegfx/tuple/Tuple2D.hxx b/include/basegfx/tuple/Tuple2D.hxx index 44d546df6a30..8bc53fe9b88d 100644 --- a/include/basegfx/tuple/Tuple2D.hxx +++ b/include/basegfx/tuple/Tuple2D.hxx @@ -105,53 +105,85 @@ public: // operator overrides -Tuple2D& operator+=(const Tuple2D& rTup) +Tuple2D& operator+=(const Tuple2D& rTup) { mfX += rTup.mfX; mfY += rTup.mfY; return *this; } -Tuple2D& operator-=(const Tuple2D& rTup) +Tuple2D& operator-=(const Tuple2D& rTup) { mfX -= rTup.mfX; mfY -= rTup.mfY; return *this; } -Tuple2D& operator/=(const Tuple2D& rTup) +Tuple2D& operator/=(const Tuple2D& rTup) { mfX /= rTup.mfX; mfY /= rTup.mfY; return *this; } -Tuple2D& operator*=(const Tuple2D& rTup) +Tuple2D& operator*=(const Tuple2D& rTup) { mfX *= rTup.mfX; mfY *= rTup.mfY; return *this; } -Tuple2D& operator*=(TYPE t) +Tuple2D& operator*=(TYPE t) { mfX *= t; mfY *= t; return *this; } -Tuple2D& operator/=(TYPE t) +Tuple2D& operator/=(TYPE t) { mfX /= t; mfY /= t; return *this; } -bool operator==(const Tuple2D& rTup) const { return mfX == rTup.mfX && mfY == rTup.mfY; } +bool operator==(const Tuple2D& rTup) const { return mfX == rTup.mfX && mfY == rTup.mfY; } -bool operator!=(const Tuple2D& rTup) const { return !(*this == rTup); } +bool operator!=(const Tuple2D& rTup) const { return !(*this == rTup); } }; +template +inline Tuple2D operator-(const Tuple2D& rTupA, const Tuple2D& rTupB) +{ +Tuple2D aNew(rTupA); +aNew -= rTupB; +return aNew; +} + +template +inline Tuple2D operator+(const Tuple2D& rTupA, const Tuple2D& rTupB) +{ +Tuple2D aNew(rTupA); +aNew += rTupB; +return aNew; +} + +template +inline Tuple2D operator*(const Tuple2D& rTupA, const Tuple2D& rTupB) +{ +Tuple2D aNew(rTupA); +aNew *= rTupB; +return aNew; +} + +template +inl
[Libreoffice-commits] core.git: basegfx/source
basegfx/source/matrix/b2dhommatrix.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 153b51da381ba21d46a3d42c939080272818797c Author: Noel Grandin AuthorDate: Mon Aug 22 11:21:50 2022 +0200 Commit: Noel Grandin CommitDate: Thu Sep 1 19:31:07 2022 +0200 reduce cost of B2DHomMatrix::isIdentity often the matrix is still default Change-Id: Ieacf19c375e9988487047309187fce6b5b8c9561 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139213 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/basegfx/source/matrix/b2dhommatrix.cxx b/basegfx/source/matrix/b2dhommatrix.cxx index c21a4dceeccd..9811304d 100644 --- a/basegfx/source/matrix/b2dhommatrix.cxx +++ b/basegfx/source/matrix/b2dhommatrix.cxx @@ -82,7 +82,7 @@ namespace basegfx bool B2DHomMatrix::isIdentity() const { -return mpImpl->isIdentity(); +return mpImpl.same_object(DEFAULT) || mpImpl->isIdentity(); } void B2DHomMatrix::identity()
[Libreoffice-commits] core.git: basegfx/source include/basegfx vcl/source
basegfx/source/curve/b2dcubicbezier.cxx |4 ++-- basegfx/source/polygon/b2dpolygontools.cxx |4 ++-- basegfx/source/polygon/b2dpolypolygontools.cxx |4 ++-- include/basegfx/curve/b2dcubicbezier.hxx|5 - include/basegfx/polygon/b2dpolygontools.hxx |2 +- include/basegfx/polygon/b2dpolypolygontools.hxx |2 +- vcl/source/outdev/line.cxx |4 +++- 7 files changed, 15 insertions(+), 10 deletions(-) New commits: commit 8ab54ac42ca2516c333a49fb23f6d27196122c22 Author: Caolán McNamara AuthorDate: Sun Jul 17 15:26:16 2022 +0100 Commit: Caolán McNamara CommitDate: Sun Jul 17 17:23:44 2022 +0200 ofz#48585 Out-of-memory Change-Id: If6bb603cc78863df88d5630b4bd5b1198b4050de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137148 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx index 6528e1492a32..d33cd82b194d 100644 --- a/basegfx/source/curve/b2dcubicbezier.cxx +++ b/basegfx/source/curve/b2dcubicbezier.cxx @@ -610,12 +610,12 @@ namespace basegfx } // adaptive subdivide by distance -void B2DCubicBezier::adaptiveSubdivideByDistance(B2DPolygon& rTarget, double fDistanceBound) const +void B2DCubicBezier::adaptiveSubdivideByDistance(B2DPolygon& rTarget, double fDistanceBound, int nRecurseLimit) const { if(isBezier()) { ImpSubDivDistance(maStartPoint, maControlPointA, maControlPointB, maEndPoint, rTarget, -fDistanceBound * fDistanceBound, std::numeric_limits::max(), 30); +fDistanceBound * fDistanceBound, std::numeric_limits::max(), nRecurseLimit); } else { diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index 4b8550546e5c..03f5299ca505 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -157,7 +157,7 @@ namespace basegfx::utils return rCandidate.getContinuityInPoint(nIndex); } -B2DPolygon adaptiveSubdivideByDistance(const B2DPolygon& rCandidate, double fDistanceBound) +B2DPolygon adaptiveSubdivideByDistance(const B2DPolygon& rCandidate, double fDistanceBound, int nRecurseLimit) { if(rCandidate.areControlPointsUsed()) { @@ -213,7 +213,7 @@ namespace basegfx::utils } // call adaptive subdivide which adds edges to aRetval accordingly -aBezier.adaptiveSubdivideByDistance(aRetval, fBound); +aBezier.adaptiveSubdivideByDistance(aRetval, fBound, nRecurseLimit); } else { diff --git a/basegfx/source/polygon/b2dpolypolygontools.cxx b/basegfx/source/polygon/b2dpolypolygontools.cxx index 3f8f51c52404..faf734f6e79e 100644 --- a/basegfx/source/polygon/b2dpolypolygontools.cxx +++ b/basegfx/source/polygon/b2dpolypolygontools.cxx @@ -113,7 +113,7 @@ namespace basegfx::utils return rCandidate; } -B2DPolyPolygon adaptiveSubdivideByDistance(const B2DPolyPolygon& rCandidate, double fDistanceBound) +B2DPolyPolygon adaptiveSubdivideByDistance(const B2DPolyPolygon& rCandidate, double fDistanceBound, int nRecurseLimit) { if(rCandidate.areControlPointsUsed()) { @@ -123,7 +123,7 @@ namespace basegfx::utils { if(rPolygon.areControlPointsUsed()) { - aRetval.append(utils::adaptiveSubdivideByDistance(rPolygon, fDistanceBound)); + aRetval.append(utils::adaptiveSubdivideByDistance(rPolygon, fDistanceBound, nRecurseLimit)); } else { diff --git a/include/basegfx/curve/b2dcubicbezier.hxx b/include/basegfx/curve/b2dcubicbezier.hxx index 4d8d9406e930..fe81ed523d97 100644 --- a/include/basegfx/curve/b2dcubicbezier.hxx +++ b/include/basegfx/curve/b2dcubicbezier.hxx @@ -143,8 +143,11 @@ namespace basegfx @param fDistanceBound Bound on the maximal distance of the approximation to the true curve. + +@param nRecurseLimit +Bound on recursion for the bezier case. */ -void adaptiveSubdivideByDistance(B2DPolygon& rTarget, double fDistanceBound) const; +void adaptiveSubdivideByDistance(B2DPolygon& rTarget, double fDistanceBound, int nRecurseLimit = 30) const; // get point at given relative position B2DPoint interpolatePoint(double t) const; diff --git a/include/basegfx/polygon/b2dpolygontools.hxx b/include/basegfx/polygon/b2dpolygontools.hxx index 8f3ef342f3bc..d5aa092ed9cb 100644 --- a/include/basegfx/polygon/b2dpol
[Libreoffice-commits] core.git: basegfx/source include/basegfx
basegfx/source/polygon/b2dpolypolygon.cxx |2 +- basegfx/source/tools/unopolypolygon.cxx|7 +-- include/basegfx/polygon/b2dpolypolygon.hxx |2 +- 3 files changed, 3 insertions(+), 8 deletions(-) New commits: commit 1aaf5d44dceecc13a3bc8e08c13d0b2ba278c462 Author: Noel Grandin AuthorDate: Thu Jul 14 14:33:09 2022 +0200 Commit: Noel Grandin CommitDate: Thu Jul 14 19:11:22 2022 +0200 make B2DPolyPolygon thread-safe which is cheaper than copying it when querying from UnoPolyPolygon Change-Id: If4661dfdff7e277d5ef25a8f0c937e549f8be9f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137080 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx index a283828f661c..ad24ffa0b87c 100644 --- a/basegfx/source/polygon/b2dpolypolygon.cxx +++ b/basegfx/source/polygon/b2dpolypolygon.cxx @@ -205,7 +205,7 @@ public: } }; -static o3tl::cow_wrapper DEFAULT; +static o3tl::cow_wrapper DEFAULT; B2DPolyPolygon::B2DPolyPolygon() : mpPolyPolygon(DEFAULT) {} diff --git a/basegfx/source/tools/unopolypolygon.cxx b/basegfx/source/tools/unopolypolygon.cxx index 76341e6ea532..0c3b59abac9b 100644 --- a/basegfx/source/tools/unopolypolygon.cxx +++ b/basegfx/source/tools/unopolypolygon.cxx @@ -38,8 +38,6 @@ namespace basegfx::unotools maPolyPoly(std::move( aPolyPoly )), meFillRule( rendering::FillRule_EVEN_ODD ) { -// or else races will haunt us. -maPolyPoly.makeUnique(); } void SAL_CALL UnoPolyPolygon::addPolyPolygon( @@ -440,10 +438,7 @@ namespace basegfx::unotools { std::unique_lock const guard( m_aMutex ); -// detach result from us -B2DPolyPolygon aRet( maPolyPoly ); -aRet.makeUnique(); -return aRet; +return maPolyPoly; } } diff --git a/include/basegfx/polygon/b2dpolypolygon.hxx b/include/basegfx/polygon/b2dpolypolygon.hxx index 474c0cbdb40f..68f1b0d6a619 100644 --- a/include/basegfx/polygon/b2dpolypolygon.hxx +++ b/include/basegfx/polygon/b2dpolypolygon.hxx @@ -36,7 +36,7 @@ namespace basegfx class BASEGFX_DLLPUBLIC B2DPolyPolygon { private: -o3tl::cow_wrapper mpPolyPolygon; +o3tl::cow_wrapper mpPolyPolygon; public: B2DPolyPolygon();
[Libreoffice-commits] core.git: basegfx/source include/basegfx sc/inc sc/source sd/source svx/source sw/source
basegfx/source/tools/zoomtools.cxx | 16 include/basegfx/utils/zoomtools.hxx|5 ++--- sc/inc/global.hxx |4 ++-- sc/source/ui/view/prevwsh.cxx | 10 +- sc/source/ui/view/tabview.cxx |8 sc/source/ui/view/tabvwsh3.cxx |8 sd/source/ui/view/viewshel.cxx |8 svx/source/stbctrls/zoomsliderctrl.cxx |4 ++-- sw/source/uibase/uiview/view2.cxx |2 +- sw/source/uibase/uiview/viewport.cxx |6 +++--- 10 files changed, 35 insertions(+), 36 deletions(-) New commits: commit ac2a6ee9618e377806e529ed641f67e88684f7e7 Author: Chris Sherlock AuthorDate: Mon Jun 13 17:20:15 2022 +1000 Commit: Thorsten Behrens CommitDate: Wed Jul 13 18:54:28 2022 +0200 basegfx: zoomIn() and zoomOut() should be sal_uInt16 All zoom functions use sal_uInt16 values. For some reason, basegfx used long when zoomIn and zoomOut were created in 2012 (see commit 315d2ddc16: "optimized zoom to use more common intervals"), this then got mass converted to tools::Long in commit 387a88fa25: "use tools::Long in basegfx..chart2". So fix is to change zoomIn/Out() to use sal_uInt16. Change-Id: I2a56d6f58e14f77aeb8741d332fe9bc282eb969f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135715 Tested-by: Jenkins Reviewed-by: Thorsten Behrens diff --git a/basegfx/source/tools/zoomtools.cxx b/basegfx/source/tools/zoomtools.cxx index 4fedb8ee848c..dd4c7a6cbbd3 100644 --- a/basegfx/source/tools/zoomtools.cxx +++ b/basegfx/source/tools/zoomtools.cxx @@ -26,7 +26,7 @@ const double ZOOM_FACTOR = 1.12246205; * @param nCurrent current value * @param nMultiple multiple against which the current value is rounded */ -static tools::Long roundMultiple(tools::Long nCurrent, int nMultiple) +static sal_uInt16 roundMultiple(sal_uInt16 nCurrent, int nMultiple) { // round zoom to a multiple of nMultiple return (( nCurrent + nMultiple / 2 ) - ( nCurrent + nMultiple / 2 ) % nMultiple); @@ -39,10 +39,10 @@ static tools::Long roundMultiple(tools::Long nCurrent, int nMultiple) * * @param nCurrent current zoom factor */ -static tools::Long roundZoom(double nCurrent) +static sal_uInt16 roundZoom(double nCurrent) { // convert nCurrent properly to int -tools::Long nNew = nCurrent + 0.5; +sal_uInt16 nNew = nCurrent + 0.5; // round to more common numbers above 50 if (nNew > 1000) { @@ -66,7 +66,7 @@ static tools::Long roundZoom(double nCurrent) * @param nPrevious previous zoom factor * @param nStep step which shouldn't be skipped */ -static tools::Long enforceStep(tools::Long nCurrent, tools::Long nPrevious, int nStep) +static sal_uInt16 enforceStep(sal_uInt16 nCurrent, sal_uInt16 nPrevious, unsigned int nStep) { if ((( nCurrent > nStep ) && ( nPrevious < nStep )) || (( nCurrent < nStep ) && ( nPrevious > nStep ))) @@ -80,9 +80,9 @@ static tools::Long enforceStep(tools::Long nCurrent, tools::Long nPrevious, int * * @param nCurrent current zoom factor */ -tools::Long zoomIn(tools::Long nCurrent) +sal_uInt16 zoomIn(sal_uInt16 nCurrent) { -tools::Long nNew = roundZoom( nCurrent * ZOOM_FACTOR ); +sal_uInt16 nNew = roundZoom( nCurrent * ZOOM_FACTOR ); // make sure some values are not skipped nNew = enforceStep(nNew, nCurrent, 200); nNew = enforceStep(nNew, nCurrent, 100); @@ -97,9 +97,9 @@ tools::Long zoomIn(tools::Long nCurrent) * * @param nCurrent current zoom factor */ -tools::Long zoomOut(tools::Long nCurrent) +sal_uInt16 zoomOut(sal_uInt16 nCurrent) { -tools::Long nNew = roundZoom( nCurrent / ZOOM_FACTOR ); +sal_uInt16 nNew = roundZoom( nCurrent / ZOOM_FACTOR ); // make sure some values are not skipped nNew = enforceStep(nNew, nCurrent, 200); nNew = enforceStep(nNew, nCurrent, 100); diff --git a/include/basegfx/utils/zoomtools.hxx b/include/basegfx/utils/zoomtools.hxx index 242c10e6dafc..16a36448af49 100644 --- a/include/basegfx/utils/zoomtools.hxx +++ b/include/basegfx/utils/zoomtools.hxx @@ -10,14 +10,13 @@ #pragma once #include -#include namespace basegfx::zoomtools { /** This namespace provides functions for optimized geometric zooming */ -BASEGFX_DLLPUBLIC tools::Long zoomOut(tools::Long nCurrent); -BASEGFX_DLLPUBLIC tools::Long zoomIn(tools::Long nCurrent); +BASEGFX_DLLPUBLIC sal_uInt16 zoomOut(sal_uInt16 nCurrent); +BASEGFX_DLLPUBLIC sal_uInt16 zoomIn(sal_uInt16 nCurrent); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 47b93c845296..8401ca4c6f7e 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -75,8 +75,8 @@ const sal_Unicode CHAR_NNBSP= 0x202F; //NARROW NO-BREAK SPACE #define MINDOUBLE 1.7e-307 #define MAXDOUBLE 1.7e307 -#define MINZOOM 20 -#define MAXZOOM 400 +const sal_uInt16 MINZOOM = 20; +const sal_uInt16 MAXZOOM = 400; const
[Libreoffice-commits] core.git: basegfx/source include/basegfx
basegfx/source/polygon/b2dpolypolygon.cxx | 11 +++ basegfx/source/polygon/b2dpolypolygontools.cxx |1 + include/basegfx/polygon/b2dpolypolygon.hxx |1 + 3 files changed, 13 insertions(+) New commits: commit f1e15482bcf6bf65dc611e19cbd2479ef141 Author: Noel Grandin AuthorDate: Fri Jul 1 14:03:22 2022 +0200 Commit: Noel Grandin CommitDate: Mon Jul 4 21:04:30 2022 +0200 tdf#137544 reserve space in polypolygon Change-Id: Ic8dc5b7479c1353487bac883fc0e704356e90798 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136802 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx index 4a81a82c4c71..a283828f661c 100644 --- a/basegfx/source/polygon/b2dpolypolygon.cxx +++ b/basegfx/source/polygon/b2dpolypolygon.cxx @@ -108,6 +108,11 @@ public: } } +void reserve(sal_uInt32 nCount) +{ +maPolygons.reserve(nCount); +} + void insert(sal_uInt32 nIndex, const basegfx::B2DPolyPolygon& rPolyPolygon) { // add nCount polygons from rPolyPolygon @@ -288,6 +293,12 @@ public: mpPolyPolygon->insert(std::as_const(mpPolyPolygon)->count(), rPolygon, nCount); } +void B2DPolyPolygon::reserve(sal_uInt32 nCount) +{ +if(nCount) +mpPolyPolygon->reserve(nCount); +} + B2DPolyPolygon B2DPolyPolygon::getDefaultAdaptiveSubdivision() const { B2DPolyPolygon aRetval; diff --git a/basegfx/source/polygon/b2dpolypolygontools.cxx b/basegfx/source/polygon/b2dpolypolygontools.cxx index b49de907d45c..3f8f51c52404 100644 --- a/basegfx/source/polygon/b2dpolypolygontools.cxx +++ b/basegfx/source/polygon/b2dpolypolygontools.cxx @@ -553,6 +553,7 @@ namespace basegfx::utils const css::drawing::PointSequenceSequence& rPointSequenceSequenceSource) { B2DPolyPolygon aRetval; +aRetval.reserve(rPointSequenceSequenceSource.getLength()); const css::drawing::PointSequence* pPointSequence = rPointSequenceSequenceSource.getConstArray(); const css::drawing::PointSequence* pPointSeqEnd = pPointSequence + rPointSequenceSequenceSource.getLength(); diff --git a/include/basegfx/polygon/b2dpolypolygon.hxx b/include/basegfx/polygon/b2dpolypolygon.hxx index f1420edef79a..474c0cbdb40f 100644 --- a/include/basegfx/polygon/b2dpolypolygon.hxx +++ b/include/basegfx/polygon/b2dpolypolygon.hxx @@ -68,6 +68,7 @@ namespace basegfx // insert/append single polygon void insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount = 1); void append(const B2DPolygon& rPolygon, sal_uInt32 nCount = 1); +void reserve(sal_uInt32 nCount); /** Default adaptive subdivision access