[Libreoffice-commits] core.git: 2 commits - basegfx/source svgio/inc svgio/source svx/source sw/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Sun Aug 22 08:31:46 UTC 2021
basegfx/source/polygon/b2dpolygon.cxx | 4 ++--
svgio/inc/svgpathnode.hxx | 7 ++++---
svgio/inc/svgpolynode.hxx | 5 +++--
svgio/source/svgreader/svgpathnode.cxx | 2 +-
svgio/source/svgreader/svgpolynode.cxx | 2 +-
svgio/source/svgreader/svgtextpathnode.cxx | 4 ++--
svx/source/svdraw/svdotext.cxx | 6 +++---
sw/source/core/text/txtfly.cxx | 7 +++----
8 files changed, 19 insertions(+), 18 deletions(-)
New commits:
commit 3a668a2398fdbe7cfe0176900b26ca6145fb0e8c
Author: Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Aug 21 19:57:35 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Aug 22 10:31:24 2021 +0200
no need to use unique_ptr for B2DPolygon
it is already a COW type
Change-Id: I86c4be9dd83b98eedf169c3b6668a7994204bca0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120827
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx
index 9c8604e6ad32..141982aef10b 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -461,7 +461,7 @@ class ImplBufferedData : public basegfx::SystemDependentDataHolder
{
private:
// Possibility to hold the last subdivision
- std::unique_ptr< basegfx::B2DPolygon > mpDefaultSubdivision;
+ std::optional< basegfx::B2DPolygon > mpDefaultSubdivision;
// Possibility to hold the last B2DRange calculation
std::unique_ptr< basegfx::B2DRange > mpB2DRange;
@@ -478,7 +478,7 @@ public:
{
if(!mpDefaultSubdivision)
{
- const_cast< ImplBufferedData* >(this)->mpDefaultSubdivision.reset(new basegfx::B2DPolygon(basegfx::utils::adaptiveSubdivideByAngle(rSource)));
+ const_cast< ImplBufferedData* >(this)->mpDefaultSubdivision = basegfx::utils::adaptiveSubdivideByAngle(rSource);
}
return *mpDefaultSubdivision;
diff --git a/svgio/inc/svgpolynode.hxx b/svgio/inc/svgpolynode.hxx
index abd14271d543..f5974cd28c08 100644
--- a/svgio/inc/svgpolynode.hxx
+++ b/svgio/inc/svgpolynode.hxx
@@ -23,6 +23,7 @@
#include "svgstyleattributes.hxx"
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
+#include <optional>
namespace svgio::svgreader
{
@@ -33,7 +34,7 @@ namespace svgio::svgreader
SvgStyleAttributes maSvgStyleAttributes;
/// variable scan values, dependent of given XAttributeList
- std::unique_ptr<basegfx::B2DPolygon> mpPolygon;
+ std::optional<basegfx::B2DPolygon> mpPolygon;
std::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
bool mbIsPolyline : 1; // true = polyline, false = polygon
@@ -50,7 +51,7 @@ namespace svgio::svgreader
virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
/// Polygon content, set if found in current context
- void setPolygon(const basegfx::B2DPolygon* pPolygon) { mpPolygon.reset(); if(pPolygon) mpPolygon.reset(new basegfx::B2DPolygon(*pPolygon)); }
+ void setPolygon(const std::optional<basegfx::B2DPolygon>& pPolygon) { mpPolygon = pPolygon; }
/// transform content, set if found in current context
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
diff --git a/svgio/source/svgreader/svgpolynode.cxx b/svgio/source/svgreader/svgpolynode.cxx
index d7bcb0f07330..584a94e30d79 100644
--- a/svgio/source/svgreader/svgpolynode.cxx
+++ b/svgio/source/svgreader/svgpolynode.cxx
@@ -72,7 +72,7 @@ namespace svgio::svgreader
aPath.setClosed(true);
}
- setPolygon(&aPath);
+ setPolygon(aPath);
}
}
break;
commit 523bba89cd5ad6372fb0431cecabdca02ea2b9e3
Author: Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Aug 21 19:54:07 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Aug 22 10:31:12 2021 +0200
no need to use unique_ptr for B2DPolyPolygon
it is already a COW type
Change-Id: Iaf8bf1671781923555df3e43b0db78e87c2c5a87
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120826
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/svgio/inc/svgpathnode.hxx b/svgio/inc/svgpathnode.hxx
index 3bb0327db559..59daac852891 100644
--- a/svgio/inc/svgpathnode.hxx
+++ b/svgio/inc/svgpathnode.hxx
@@ -24,6 +24,7 @@
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <optional>
namespace svgio::svgreader
{
@@ -34,7 +35,7 @@ namespace svgio::svgreader
SvgStyleAttributes maSvgStyleAttributes;
/// variable scan values, dependent of given XAttributeList
- std::unique_ptr<basegfx::B2DPolyPolygon> mpPolyPolygon;
+ std::optional<basegfx::B2DPolyPolygon> mpPolyPolygon;
std::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
SvgNumber maPathLength;
basegfx::utils::PointIndexSet maHelpPointIndices;
@@ -50,8 +51,8 @@ namespace svgio::svgreader
virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
/// path content, set if found in current context
- const basegfx::B2DPolyPolygon* getPath() const { return mpPolyPolygon.get(); }
- void setPath(const basegfx::B2DPolyPolygon* pPath) { mpPolyPolygon.reset(); if(pPath) mpPolyPolygon.reset(new basegfx::B2DPolyPolygon(*pPath)); }
+ const std::optional<basegfx::B2DPolyPolygon>& getPath() const { return mpPolyPolygon; }
+ void setPath(const std::optional<basegfx::B2DPolyPolygon>& pPath) { mpPolyPolygon = pPath; }
/// transform content, set if found in current context
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
diff --git a/svgio/source/svgreader/svgpathnode.cxx b/svgio/source/svgreader/svgpathnode.cxx
index 773f34f2cf4d..5187df877261 100644
--- a/svgio/source/svgreader/svgpathnode.cxx
+++ b/svgio/source/svgreader/svgpathnode.cxx
@@ -64,7 +64,7 @@ namespace svgio::svgreader
{
if(aPath.count())
{
- setPath(&aPath);
+ setPath(aPath);
}
}
break;
diff --git a/svgio/source/svgreader/svgtextpathnode.cxx b/svgio/source/svgreader/svgtextpathnode.cxx
index 210d674b09ac..e04b8380735e 100644
--- a/svgio/source/svgreader/svgtextpathnode.cxx
+++ b/svgio/source/svgreader/svgtextpathnode.cxx
@@ -320,7 +320,7 @@ namespace svgio::svgreader
return false;
}
- const basegfx::B2DPolyPolygon* pPolyPolyPath = pSvgPathNode->getPath();
+ const std::optional<basegfx::B2DPolyPolygon>& pPolyPolyPath = pSvgPathNode->getPath();
if(!pPolyPolyPath || !pPolyPolyPath->count())
{
@@ -352,7 +352,7 @@ namespace svgio::svgreader
if(!pSvgPathNode)
return;
- const basegfx::B2DPolyPolygon* pPolyPolyPath = pSvgPathNode->getPath();
+ const std::optional<basegfx::B2DPolyPolygon>& pPolyPolyPath = pSvgPathNode->getPath();
if(!(pPolyPolyPath && pPolyPolyPath->count()))
return;
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index eefee015e866..32541331fca0 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -571,7 +571,7 @@ void SdrTextObj::AdaptTextMinSize()
void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, tools::Rectangle const & rAnchorRect, bool bLineWidth ) const
{
basegfx::B2DPolyPolygon aXorPolyPolygon(TakeXorPoly());
- std::unique_ptr<basegfx::B2DPolyPolygon> pContourPolyPolygon;
+ std::optional<basegfx::B2DPolyPolygon> pContourPolyPolygon;
basegfx::B2DHomMatrix aMatrix(basegfx::utils::createTranslateB2DHomMatrix(
-rAnchorRect.Left(), -rAnchorRect.Top()));
@@ -587,7 +587,7 @@ void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, tools::Rectangle
{
// Take line width into account.
// When doing the hit test, avoid this. (Performance!)
- pContourPolyPolygon.reset(new basegfx::B2DPolyPolygon());
+ pContourPolyPolygon.emplace();
// test if shadow needs to be avoided for TakeContour()
const SfxItemSet& rSet = GetObjectItemSet();
@@ -622,7 +622,7 @@ void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, tools::Rectangle
pContourPolyPolygon->transform(aMatrix);
}
- rOutliner.SetPolygon(aXorPolyPolygon, pContourPolyPolygon.get());
+ rOutliner.SetPolygon(aXorPolyPolygon, pContourPolyPolygon ? &*pContourPolyPolygon : nullptr);
}
void SdrTextObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const
diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index 2daaf4ac6d6c..b2799b08acf8 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -216,7 +216,7 @@ SwRect SwContourCache::ContourRect( const SwFormat* pFormat,
mvItems.pop_back();
}
::basegfx::B2DPolyPolygon aPolyPolygon;
- std::unique_ptr<::basegfx::B2DPolyPolygon> pPolyPolygon;
+ std::optional<::basegfx::B2DPolyPolygon> pPolyPolygon;
if ( auto pVirtFlyDrawObj = dynamic_cast< const SwVirtFlyDrawObj *>( pObj ) )
{
@@ -236,14 +236,13 @@ SwRect SwContourCache::ContourRect( const SwFormat* pFormat,
aPolyPolygon = pObj->TakeXorPoly();
}
- ::basegfx::B2DPolyPolygon aContourPoly(pObj->TakeContour());
- pPolyPolygon.reset(new ::basegfx::B2DPolyPolygon(aContourPoly));
+ pPolyPolygon = pObj->TakeContour();
}
const SvxLRSpaceItem &rLRSpace = pFormat->GetLRSpace();
const SvxULSpaceItem &rULSpace = pFormat->GetULSpace();
CacheItem item {
pObj, // due to #37347 the Object must be entered only after GetContour()
- std::make_unique<TextRanger>( aPolyPolygon, pPolyPolygon.get(), 20,
+ std::make_unique<TextRanger>( aPolyPolygon, pPolyPolygon ? &*pPolyPolygon : nullptr, 20,
o3tl::narrowing<sal_uInt16>(rLRSpace.GetLeft()), o3tl::narrowing<sal_uInt16>(rLRSpace.GetRight()),
pFormat->GetSurround().IsOutside(), false, pFrame->IsVertical() )
};
More information about the Libreoffice-commits
mailing list