sw/source/core/layout/calcmove.cxx | 16 ++++++++-------- sw/source/core/layout/flowfrm.cxx | 22 +++++++++++----------- sw/source/core/layout/hffrm.cxx | 12 ++++++------ sw/source/core/layout/tabfrm.cxx | 36 ++++++++++++++++++------------------ 4 files changed, 43 insertions(+), 43 deletions(-)
New commits: commit a7f5225f2900fcb21ed5565de1b606b3c3e1c81c Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sun Sep 26 08:37:20 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun Sep 26 13:29:18 2021 +0200 no need to allocate these SwBorderAttrAccess on the heap Change-Id: I9200ff5072babf11afe37ec0fe0d7401779be7c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122616 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index 31a9e2f80045..f8ab0e2e29fc 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -810,7 +810,7 @@ void SwPageFrame::MakeAll(vcl::RenderContext* pRenderContext) const SwRect aOldRect( getFrameArea() ); // Adjust root size const SwLayNotify aNotify( this ); // takes care of the notification in the dtor - std::unique_ptr<SwBorderAttrAccess> pAccess; + std::optional<SwBorderAttrAccess> oAccess; const SwBorderAttrs*pAttrs = nullptr; while ( !isFrameAreaPositionValid() || !isFrameAreaSizeValid() || !isFramePrintAreaValid() ) @@ -839,10 +839,10 @@ void SwPageFrame::MakeAll(vcl::RenderContext* pRenderContext) } else { - if (!pAccess) + if (!oAccess) { - pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this); - pAttrs = pAccess->Get(); + oAccess.emplace(SwFrame::GetCache(), this); + pAttrs = oAccess->Get(); } assert(pAttrs); @@ -964,7 +964,7 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) SwRectFn fnRect = ( IsNeighbourFrame() == bVert )? fnRectHori : ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ); - std::unique_ptr<SwBorderAttrAccess> pAccess; + std::optional<SwBorderAttrAccess> oAccess; const SwBorderAttrs*pAttrs = nullptr; while ( !isFrameAreaPositionValid() || !isFrameAreaSizeValid() || !isFramePrintAreaValid() ) @@ -1030,10 +1030,10 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) if ( !isFrameAreaSizeValid() || !isFramePrintAreaValid() ) { - if ( !pAccess ) + if ( !oAccess ) { - pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this); - pAttrs = pAccess->Get(); + oAccess.emplace(SwFrame::GetCache(), this); + pAttrs = oAccess->Get(); } Format( getRootFrame()->GetCurrShell()->GetOut(), pAttrs ); } diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 1ffbbeed764e..dd6872c1750f 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -1434,8 +1434,8 @@ static bool lcl_IdenticalStyles(const SwFrame* pPrevFrame, const SwFrame* pFrame static bool lcl_getContextualSpacing(const SwFrame* pPrevFrame) { bool bRet; - auto pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), pPrevFrame); - const SwBorderAttrs *pAttrs = pAccess->Get(); + SwBorderAttrAccess aAccess(SwFrame::GetCache(), pPrevFrame); + const SwBorderAttrs *pAttrs = aAccess.Get(); bRet = pAttrs->GetULSpace().GetContext(); @@ -1449,7 +1449,7 @@ SwTwips SwFlowFrame::CalcUpperSpace( const SwBorderAttrs *pAttrs, { const SwFrame* pPrevFrame = GetPrevFrameForUpperSpaceCalc_( pPr ); - std::unique_ptr<SwBorderAttrAccess> pAccess; + std::optional<SwBorderAttrAccess> oAccess; SwFrame* pOwn; if( !pAttrs ) { @@ -1464,8 +1464,8 @@ SwTwips SwFlowFrame::CalcUpperSpace( const SwBorderAttrs *pAttrs, } else pOwn = &m_rThis; - pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), pOwn); - pAttrs = pAccess->Get(); + oAccess.emplace(SwFrame::GetCache(), pOwn); + pAttrs = oAccess->Get(); } else { @@ -1744,11 +1744,11 @@ SwTwips SwFlowFrame::CalcLowerSpace( const SwBorderAttrs* _pAttrs ) const { SwTwips nLowerSpace = 0; - std::unique_ptr<SwBorderAttrAccess> pAttrAccess; + std::optional<SwBorderAttrAccess> oAttrAccess; if ( !_pAttrs ) { - pAttrAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), &m_rThis); - _pAttrs = pAttrAccess->Get(); + oAttrAccess.emplace(SwFrame::GetCache(), &m_rThis); + _pAttrs = oAttrAccess->Get(); } bool bCommonBorder = true; @@ -1810,11 +1810,11 @@ SwTwips SwFlowFrame::CalcAddLowerSpaceAsLastInTableCell( } } - std::unique_ptr<SwBorderAttrAccess> pAttrAccess; + std::optional<SwBorderAttrAccess> oAttrAccess; if (pFrame && (!_pAttrs || pFrame != &m_rThis)) { - pAttrAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), pFrame); - _pAttrs = pAttrAccess->Get(); + oAttrAccess.emplace(SwFrame::GetCache(), pFrame); + _pAttrs = oAttrAccess->Get(); } if (_pAttrs) diff --git a/sw/source/core/layout/hffrm.cxx b/sw/source/core/layout/hffrm.cxx index b29713b18841..2d971400743d 100644 --- a/sw/source/core/layout/hffrm.cxx +++ b/sw/source/core/layout/hffrm.cxx @@ -453,10 +453,10 @@ SwTwips SwHeadFootFrame::GrowFrame( SwTwips nDist, bool bTst, bool bInfo ) { nResult = 0; - auto pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this); - OSL_ENSURE(pAccess, "no border attributes"); + std::optional<SwBorderAttrAccess> oAccess(std::in_place, SwFrame::GetCache(), this); + OSL_ENSURE(oAccess, "no border attributes"); - SwBorderAttrs * pAttrs = pAccess->Get(); + SwBorderAttrs * pAttrs = oAccess->Get(); /* First assume the whole amount to grow can be provided by eating spacing. */ @@ -582,10 +582,10 @@ SwTwips SwHeadFootFrame::ShrinkFrame( SwTwips nDist, bool bTst, bool bInfo ) bool bNotifyFlys = false; if (nRest > 0) { - auto pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this); - OSL_ENSURE(pAccess, "no border attributes"); + std::optional<SwBorderAttrAccess> oAccess(std::in_place, SwFrame::GetCache(), this); + OSL_ENSURE(oAccess, "no border attributes"); - SwBorderAttrs * pAttrs = pAccess->Get(); + SwBorderAttrs * pAttrs = oAccess->Get(); /* minimal height of print area */ SwTwips nMinPrtHeight = nMinHeight diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 38d8c0e14305..fcb3d2c3bcfb 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -1922,8 +1922,8 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) const bool bFootnotesInDoc = !GetFormat()->GetDoc()->GetFootnoteIdxs().empty(); const bool bFly = IsInFly(); - auto pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this); - const SwBorderAttrs *pAttrs = pAccess->Get(); + std::optional<SwBorderAttrAccess> oAccess(std::in_place, SwFrame::GetCache(), this); + const SwBorderAttrs *pAttrs = oAccess->Get(); // All rows should keep together const bool bDontSplit = !IsFollow() && @@ -2036,11 +2036,11 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) SwHTMLTableLayout *pLayout = GetTable()->GetHTMLTableLayout(); if( pLayout ) { - pAccess.reset(); + oAccess.reset(); m_bCalcLowers |= pLayout->Resize( pLayout->GetBrowseWidthByTabFrame( *this ) ); - pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this); - pAttrs = pAccess->Get(); + oAccess.emplace(SwFrame::GetCache(), this); + pAttrs = oAccess->Get(); } setFramePrintAreaValid(false); @@ -2082,11 +2082,11 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) (aRectFnSet.GetWidth(getFramePrintArea()) != nOldPrtWidth || aRectFnSet.GetWidth(getFrameArea()) != nOldFrameWidth) ) { - pAccess.reset(); + oAccess.reset(); m_bCalcLowers |= pLayout->Resize( pLayout->GetBrowseWidthByTabFrame( *this ) ); - pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this); - pAttrs = pAccess->Get(); + oAccess.emplace(SwFrame::GetCache(), this); + pAttrs = oAccess->Get(); } if ( aOldPrtPos != aRectFnSet.GetPos(getFramePrintArea()) ) aNotify.SetLowersComplete( false ); @@ -2131,12 +2131,12 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) GetTable()->GetHTMLTableLayout(); if( pHTMLLayout ) { - pAccess.reset(); + oAccess.reset(); m_bCalcLowers |= pHTMLLayout->Resize( pHTMLLayout->GetBrowseWidthByTabFrame( *this ) ); - pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this); - pAttrs = pAccess->Get(); + oAccess.emplace(SwFrame::GetCache(), this); + pAttrs = oAccess->Get(); } setFramePrintAreaValid(false); @@ -2316,7 +2316,7 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) if ( bFormat ) { - pAccess.reset(); + oAccess.reset(); // Consider case that table is inside another table, because // it has to be avoided, that superior table is formatted. @@ -2324,8 +2324,8 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) // is found, get its first content. const SwFrame* pTmpNxt = sw_FormatNextContentForKeep( this ); - pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this); - pAttrs = pAccess->Get(); + oAccess.emplace(SwFrame::GetCache(), this); + pAttrs = oAccess->Get(); // The last row wants to keep with the frame behind the table. // Check if the next frame is on a different page and valid. @@ -2568,12 +2568,12 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) { ++nStack; StackHack aHack; - pAccess.reset(); + oAccess.reset(); GetFollow()->MakeAll(pRenderContext); - pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this); - pAttrs = pAccess->Get(); + oAccess.emplace(SwFrame::GetCache(), this); + pAttrs = oAccess->Get(); GetFollow()->SetLowersFormatted(false); // #i43913# - lock follow table @@ -2724,7 +2724,7 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) } m_bCalcLowers = m_bONECalcLowers = false; - pAccess.reset(); + oAccess.reset(); UnlockJoin(); if ( bMovedFwd || bMovedBwd || !bOldValidPos ) aNotify.SetInvaKeep();