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 &pPolyPoly, bool bStartHandleVisible, bool bEndHandleVisible) { +void ImpEditView::lokSelectionCallback(const std::optional &pPolyPoly, bool bStartHandleVisible, bool bEndHandleVisible) { VclPtr 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 pPolyPoly; + std::optional 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 &pPolyPoly, bool bStartHandleVisible, bool bEndHandleVisible); + void lokSelectionCallback(const std::optional &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* 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 mRangeCache; //!< Cached range calculations. tools::PolyPolygon maPolyPolygon; // Surface polygon - std::unique_ptr mpLinePolyPolygon; // Line polygon + std::optional mpLinePolyPolygon; // Line polygon mutable std::optional 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 +#include +#include #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 m_pContour; + mutable std::optional 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(this)->m_bContourMapModeValid = true; - const_cast(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 xPolyPoly; + std::optional 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 xPolyPoly; + std::optional 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 );