[Libreoffice-commits] core.git: editeng/source include/editeng sw/inc sw/source vcl/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sun Aug 22 16:54:43 UTC 2021


 editeng/source/editeng/impedit.cxx |   10 +++++-----
 editeng/source/editeng/impedit.hxx |    2 +-
 editeng/source/misc/txtrange.cxx   |    6 +++---
 include/editeng/txtrange.hxx       |    2 +-
 sw/inc/ndnotxt.hxx                 |   12 ++++++------
 sw/source/core/docnode/ndnotxt.cxx |   12 ++++++------
 vcl/source/outdev/gradient.cxx     |    8 ++++----
 7 files changed, 26 insertions(+), 26 deletions(-)

New commits:
commit 4c5e264df432f4e6836535cbac7231ab579af424
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Aug 21 18:21:48 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Aug 22 18:54:08 2021 +0200

    no need to use unique_ptr for PolyPolygon
    
    it is already a COW type
    
    Change-Id: If28f67bff3f8df7763bf4b574b1125d568f0ee27
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120821
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 720e50e8a998..d1b00e478560 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -322,7 +322,7 @@ void ImpEditView::SelectionChanged()
 }
 
 // This function is also called when a text's font || size is changed. Because its highlight rectangle must be updated.
-void ImpEditView::lokSelectionCallback(const std::unique_ptr<tools::PolyPolygon> &pPolyPoly, bool bStartHandleVisible, bool bEndHandleVisible) {
+void ImpEditView::lokSelectionCallback(const std::optional<tools::PolyPolygon> &pPolyPoly, bool bStartHandleVisible, bool bEndHandleVisible) {
     VclPtr<vcl::Window> pParent = pOutWin->GetParentWithLOKNotifier();
     vcl::Region aRegion( *pPolyPoly );
 
@@ -487,7 +487,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion,
     bool bClipRegion = rTarget.IsClipRegion();
     vcl::Region aOldRegion = rTarget.GetClipRegion();
 
-    std::unique_ptr<tools::PolyPolygon> pPolyPoly;
+    std::optional<tools::PolyPolygon> pPolyPoly;
 
     if ( !pRegion && !comphelper::LibreOfficeKit::isActive())
     {
@@ -511,7 +511,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion,
     }
 
     if (comphelper::LibreOfficeKit::isActive() || pRegion)
-        pPolyPoly.reset(new tools::PolyPolygon);
+        pPolyPoly = tools::PolyPolygon();
 
     DBG_ASSERT( !pEditEngine->IsIdleFormatterActive(), "DrawSelectionXOR: Not formatted!" );
     aTmpSel.Adjust( pEditEngine->GetEditDoc() );
@@ -601,7 +601,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion,
                 aTmpRect.SetRight(aLineXPosStartEnd.Max());
                 aTmpRect.Move(aLineOffset.Width(), 0);
                 ImplDrawHighlightRect(rTarget, aTmpRect.TopLeft(), aTmpRect.BottomRight(),
-                                      pPolyPoly.get());
+                                      pPolyPoly ? &*pPolyPoly : nullptr);
             }
             else
             {
@@ -627,7 +627,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion,
                     aTmpRect.Move(aLineOffset.Width(), 0);
 
                     ImplDrawHighlightRect(rTarget, aTmpRect.TopLeft(), aTmpRect.BottomRight(),
-                                          pPolyPoly.get());
+                                          pPolyPoly ? &*pPolyPoly : nullptr);
                     nTmpStartIndex = nTmpEndIndex;
                 }
             }
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 33504968bf18..216506c98828 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -307,7 +307,7 @@ private:
         return mpEditViewCallbacks;
     }
 
-    void lokSelectionCallback(const std::unique_ptr<tools::PolyPolygon> &pPolyPoly, bool bStartHandleVisible, bool bEndHandleVisible);
+    void lokSelectionCallback(const std::optional<tools::PolyPolygon> &pPolyPoly, bool bStartHandleVisible, bool bEndHandleVisible);
 
     void setEditViewCallbacks(EditViewCallbacks* pEditViewCallbacks)
     {
diff --git a/editeng/source/misc/txtrange.cxx b/editeng/source/misc/txtrange.cxx
index dadc4fc6f315..6374747be3c9 100644
--- a/editeng/source/misc/txtrange.cxx
+++ b/editeng/source/misc/txtrange.cxx
@@ -54,7 +54,7 @@ TextRanger::TextRanger( const basegfx::B2DPolyPolygon& rPolyPolygon,
     if( pLinePolyPolygon )
     {
         nCount = pLinePolyPolygon->count();
-        mpLinePolyPolygon.reset( new tools::PolyPolygon() );
+        mpLinePolyPolygon = tools::PolyPolygon(nCount);
 
         for(sal_uInt32 i(0); i < nCount; i++)
         {
@@ -64,7 +64,7 @@ TextRanger::TextRanger( const basegfx::B2DPolyPolygon& rPolyPolygon,
         }
     }
     else
-        mpLinePolyPolygon = nullptr;
+        mpLinePolyPolygon.reset();
 }
 
 
@@ -647,7 +647,7 @@ std::deque<tools::Long>* TextRanger::GetTextRanges( const Range& rRange )
     SvxBoundArgs aArg( this, &(rngCache.results), rRange );
     aArg.Calc( maPolyPolygon );
     if( mpLinePolyPolygon )
-        aArg.Concat( mpLinePolyPolygon.get() );
+        aArg.Concat( &*mpLinePolyPolygon );
     //Add new result to the cache
     mRangeCache.push_back(std::move(rngCache));
     if (mRangeCache.size() > nCacheSize)
diff --git a/include/editeng/txtrange.hxx b/include/editeng/txtrange.hxx
index e6509291d388..ab6be6d283a2 100644
--- a/include/editeng/txtrange.hxx
+++ b/include/editeng/txtrange.hxx
@@ -42,7 +42,7 @@ class EDITENG_DLLPUBLIC TextRanger
     };
     std::deque<RangeCacheItem> mRangeCache; //!< Cached range calculations.
     tools::PolyPolygon     maPolyPolygon; // Surface polygon
-    std::unique_ptr<tools::PolyPolygon> mpLinePolyPolygon; // Line polygon
+    std::optional<tools::PolyPolygon> mpLinePolyPolygon; // Line polygon
     mutable std::optional<tools::Rectangle> mxBound;  // Comprehensive rectangle
     sal_uInt16 nCacheSize;  // Cache-Size
     sal_uInt16 nRight;      // Distance Contour-Text
diff --git a/sw/inc/ndnotxt.hxx b/sw/inc/ndnotxt.hxx
index ac2611966953..2782ab66c840 100644
--- a/sw/inc/ndnotxt.hxx
+++ b/sw/inc/ndnotxt.hxx
@@ -19,11 +19,11 @@
 #ifndef INCLUDED_SW_INC_NDNOTXT_HXX
 #define INCLUDED_SW_INC_NDNOTXT_HXX
 
-#include <memory>
+#include <optional>
+#include <tools/poly.hxx>
 #include "node.hxx"
 
 class Size;
-namespace tools { class PolyPolygon; }
 
 // SwNoTextNode
 
@@ -32,12 +32,12 @@ class SW_DLLPUBLIC SwNoTextNode : public SwContentNode
     friend class SwNodes;
     friend class SwNoTextFrame;
 
-    std::unique_ptr<tools::PolyPolygon> m_pContour;
+    mutable std::optional<tools::PolyPolygon> m_pContour;
     bool m_bAutomaticContour : 1; // automatic contour polygon, not manipulated
-    bool m_bContourMapModeValid : 1; // contour map mode is not the graphics's
+    mutable bool m_bContourMapModeValid : 1; // contour map mode is not the graphics's
                                    // preferred map mode, but either
                                       // MM100 or pixel
-    bool m_bPixelContour : 1;     // contour map mode is invalid and pixel.
+    mutable bool m_bPixelContour : 1;     // contour map mode is invalid and pixel.
 
     // Creates for all derivations an AttrSet with ranges for frame- and
     // graphics-attributes (only called by SwContentNode).
@@ -70,7 +70,7 @@ public:
     void               SetContour( const tools::PolyPolygon *pPoly,
                                    bool bAutomatic = false );
     const tools::PolyPolygon *HasContour() const;
-    bool               HasContour_() const { return m_pContour!=nullptr; };
+    bool               HasContour_() const { return bool(m_pContour); };
     void               GetContour( tools::PolyPolygon &rPoly ) const;
     void               CreateContour();
 
diff --git a/sw/source/core/docnode/ndnotxt.cxx b/sw/source/core/docnode/ndnotxt.cxx
index 4e04943b92c3..7ae423a04c69 100644
--- a/sw/source/core/docnode/ndnotxt.cxx
+++ b/sw/source/core/docnode/ndnotxt.cxx
@@ -85,7 +85,7 @@ bool SwNoTextNode::SavePersistentData()
 void SwNoTextNode::SetContour( const tools::PolyPolygon *pPoly, bool bAutomatic )
 {
     if ( pPoly )
-        m_pContour.reset( new tools::PolyPolygon( *pPoly ) );
+        m_pContour = *pPoly;
     else
         m_pContour.reset();
     m_bAutomaticContour = bAutomatic;
@@ -96,7 +96,7 @@ void SwNoTextNode::SetContour( const tools::PolyPolygon *pPoly, bool bAutomatic
 void SwNoTextNode::CreateContour()
 {
     OSL_ENSURE( !m_pContour, "Contour available." );
-    m_pContour.reset( new tools::PolyPolygon(SvxContourDlg::CreateAutoContour(GetGraphic())) );
+    m_pContour = SvxContourDlg::CreateAutoContour(GetGraphic());
     m_bAutomaticContour = true;
     m_bContourMapModeValid = true;
     m_bPixelContour = false;
@@ -154,11 +154,11 @@ const tools::PolyPolygon *SwNoTextNode::HasContour() const
                 }
             }
         }
-        const_cast<SwNoTextNode *>(this)->m_bContourMapModeValid = true;
-        const_cast<SwNoTextNode *>(this)->m_bPixelContour = false;
+        m_bContourMapModeValid = true;
+        m_bPixelContour = false;
     }
 
-    return m_pContour.get();
+    return m_pContour ? &*m_pContour : nullptr;
 }
 
 void SwNoTextNode::GetContour( tools::PolyPolygon &rPoly ) const
@@ -170,7 +170,7 @@ void SwNoTextNode::GetContour( tools::PolyPolygon &rPoly ) const
 void SwNoTextNode::SetContourAPI( const tools::PolyPolygon *pPoly )
 {
     if ( pPoly )
-        m_pContour.reset( new tools::PolyPolygon( *pPoly ) );
+        m_pContour = *pPoly;
     else
         m_pContour.reset();
     m_bContourMapModeValid = false;
diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx
index 1250654d372d..ea10b6bcdf0a 100644
--- a/vcl/source/outdev/gradient.cxx
+++ b/vcl/source/outdev/gradient.cxx
@@ -457,7 +457,7 @@ void OutputDevice::DrawComplexGradient( const tools::Rectangle& rRect,
     // Also for printers always use PolyPolygon, as not all printers
     // can print polygons on top of each other.
 
-    std::unique_ptr<tools::PolyPolygon> xPolyPoly;
+    std::optional<tools::PolyPolygon> xPolyPoly;
     tools::Rectangle       aRect;
     Point           aCenter;
     Color           aStartCol( rGradient.GetStartColor() );
@@ -476,7 +476,7 @@ void OutputDevice::DrawComplexGradient( const tools::Rectangle& rRect,
     rGradient.GetBoundRect( rRect, aRect, aCenter );
 
     if ( UsePolyPolygonForComplexGradient() )
-        xPolyPoly.reset(new tools::PolyPolygon( 2 ));
+        xPolyPoly = tools::PolyPolygon( 2 );
 
     tools::Long nStepCount = GetGradientSteps( rGradient, rRect, false/*bMtf*/, true/*bComplex*/ );
 
@@ -807,7 +807,7 @@ void OutputDevice::DrawComplexGradientToMetafile( const tools::Rectangle& rRect,
     // Also for printers always use PolyPolygon, as not all printers
     // can print polygons on top of each other.
 
-    std::unique_ptr<tools::PolyPolygon> xPolyPoly;
+    std::optional<tools::PolyPolygon> xPolyPoly;
     tools::Rectangle       aRect;
     Point           aCenter;
     Color           aStartCol( rGradient.GetStartColor() );
@@ -825,7 +825,7 @@ void OutputDevice::DrawComplexGradientToMetafile( const tools::Rectangle& rRect,
 
     rGradient.GetBoundRect( rRect, aRect, aCenter );
 
-    xPolyPoly.reset(new tools::PolyPolygon( 2 ));
+    xPolyPoly = tools::PolyPolygon( 2 );
 
     // last parameter - true if complex gradient, false if linear
     tools::Long nStepCount = GetGradientSteps( rGradient, rRect, true, true );


More information about the Libreoffice-commits mailing list