sw/source/core/text/atrhndl.hxx | 10 +++++----- sw/source/core/text/atrstck.cxx | 16 ++++++---------- sw/source/core/text/inftxt.cxx | 20 ++++++++++---------- sw/source/core/text/inftxt.hxx | 2 +- sw/source/core/text/txttab.cxx | 6 +++--- 5 files changed, 25 insertions(+), 29 deletions(-)
New commits: commit 8156a8f87996e353f8d36935e0497624245f1ad1 Author: Noel Grandin <n...@peralex.com> AuthorDate: Tue Sep 28 15:01:45 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Sep 28 18:25:48 2021 +0200 no need to allocate SwFont separately in SwAttrHandler Change-Id: I08ef59f48b1f986854c6d194fb856b2da73c2ccd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122775 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/text/atrhndl.hxx b/sw/source/core/text/atrhndl.hxx index 8a3c438fd91d..92d0153eefc3 100644 --- a/sw/source/core/text/atrhndl.hxx +++ b/sw/source/core/text/atrhndl.hxx @@ -45,7 +45,7 @@ private: // This is the base font for the paragraph. It is stored in order to have // a template, if we have to restart the attribute evaluation - std::unique_ptr<SwFont> m_pFnt; + std::optional<SwFont> m_oFnt; bool m_bVertLayout; bool m_bVertLayoutLRBT; @@ -104,14 +104,14 @@ public: inline void SwAttrHandler::ResetFont( SwFont& rFnt ) const { - OSL_ENSURE(m_pFnt, "ResetFont without a font"); - if (m_pFnt) - rFnt = *m_pFnt; + OSL_ENSURE(m_oFnt, "ResetFont without a font"); + if (m_oFnt) + rFnt = *m_oFnt; }; inline const SwFont* SwAttrHandler::GetFont() const { - return m_pFnt.get(); + return m_oFnt ? &*m_oFnt : nullptr; }; diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx index 794390a63ede..79dc822361c6 100644 --- a/sw/source/core/text/atrstck.cxx +++ b/sw/source/core/text/atrstck.cxx @@ -322,14 +322,10 @@ void SwAttrHandler::Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAS, // SwTextFrame::FormatOnceMore situation or (since sw_redlinehide) // from SwAttrIter::Seek(); in the latter case SwTextSizeInfo::m_pFnt // is an alias of m_pFnt so it must not be deleted! - if (m_pFnt) - { - *m_pFnt = rFnt; - } + if (m_oFnt) + *m_oFnt = rFnt; else - { - m_pFnt.reset(new SwFont(rFnt)); - } + m_oFnt.emplace(rFnt); } void SwAttrHandler::Reset( ) @@ -826,11 +822,11 @@ void SwAttrHandler::FontChg(const SfxPoolItem& rItem, SwFont& rFnt, bool bPush ) void SwAttrHandler::GetDefaultAscentAndHeight( SwViewShell const * pShell, OutputDevice const & rOut, sal_uInt16& nAscent, sal_uInt16& nHeight ) const { - OSL_ENSURE(m_pFnt, "No font available for GetDefaultAscentAndHeight"); + OSL_ENSURE(m_oFnt, "No font available for GetDefaultAscentAndHeight"); - if (m_pFnt) + if (m_oFnt) { - SwFont aFont( *m_pFnt ); + SwFont aFont( *m_oFnt ); nHeight = aFont.GetHeight( pShell, rOut ); nAscent = aFont.GetAscent( pShell, rOut ); } commit 2d45cef3cd18c9d0198b9d302016a7598ce0484c Author: Noel Grandin <n...@peralex.com> AuthorDate: Tue Sep 28 14:55:22 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Sep 28 18:25:33 2021 +0200 no need to allocate SvxTabStopItem separately in SwLineInfo Change-Id: Ia2cbf997427a2450a576436d7c0159b7bbe34578 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122774 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 26e7246a2a98..e3546c66db1a 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -99,7 +99,7 @@ SwLineInfo::~SwLineInfo() void SwLineInfo::CtorInitLineInfo( const SwAttrSet& rAttrSet, const SwTextNode& rTextNode ) { - m_pRuler.reset( new SvxTabStopItem( rAttrSet.GetTabStops() ) ); + m_oRuler.emplace( rAttrSet.GetTabStops() ); if ( rTextNode.GetListTabStopPosition( m_nListTabStopPosition ) ) { m_bListTabStopIncluded = true; @@ -107,15 +107,15 @@ void SwLineInfo::CtorInitLineInfo( const SwAttrSet& rAttrSet, // insert the list tab stop into SvxTabItem instance <pRuler> const SvxTabStop aListTabStop( m_nListTabStopPosition, SvxTabAdjust::Left ); - m_pRuler->Insert( aListTabStop ); + m_oRuler->Insert( aListTabStop ); // remove default tab stops, which are before the inserted list tab stop - for ( sal_uInt16 i = 0; i < m_pRuler->Count(); i++ ) + for ( sal_uInt16 i = 0; i < m_oRuler->Count(); i++ ) { - if ( (*m_pRuler)[i].GetTabPos() < m_nListTabStopPosition && - (*m_pRuler)[i].GetAdjustment() == SvxTabAdjust::Default ) + if ( (*m_oRuler)[i].GetTabPos() < m_nListTabStopPosition && + (*m_oRuler)[i].GetAdjustment() == SvxTabAdjust::Default ) { - m_pRuler->Remove(i); + m_oRuler->Remove(i); continue; } } @@ -124,12 +124,12 @@ void SwLineInfo::CtorInitLineInfo( const SwAttrSet& rAttrSet, if ( !rTextNode.getIDocumentSettingAccess()->get(DocumentSettingId::TABS_RELATIVE_TO_INDENT) ) { // remove default tab stop at position 0 - for ( sal_uInt16 i = 0; i < m_pRuler->Count(); i++ ) + for ( sal_uInt16 i = 0; i < m_oRuler->Count(); i++ ) { - if ( (*m_pRuler)[i].GetTabPos() == 0 && - (*m_pRuler)[i].GetAdjustment() == SvxTabAdjust::Default ) + if ( (*m_oRuler)[i].GetTabPos() == 0 && + (*m_oRuler)[i].GetAdjustment() == SvxTabAdjust::Default ) { - m_pRuler->Remove(i); + m_oRuler->Remove(i); break; } } diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx index 91fbf0c3aa7c..9ee658364355 100644 --- a/sw/source/core/text/inftxt.hxx +++ b/sw/source/core/text/inftxt.hxx @@ -61,7 +61,7 @@ class SwLineInfo { friend class SwTextIter; - std::unique_ptr<SvxTabStopItem> m_pRuler; + std::optional<SvxTabStopItem> m_oRuler; const SvxLineSpacingItem *m_pSpace; SvxParaVertAlignItem::Align m_nVertAlign; sal_uInt16 m_nDefTabStop; diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx index f4690a9aa496..fec16e962f0a 100644 --- a/sw/source/core/text/txttab.cxx +++ b/sw/source/core/text/txttab.cxx @@ -42,9 +42,9 @@ */ const SvxTabStop* SwLineInfo::GetTabStop(const SwTwips nSearchPos, SwTwips& nRight) const { - for( sal_uInt16 i = 0; i < m_pRuler->Count(); ++i ) + for( sal_uInt16 i = 0; i < m_oRuler->Count(); ++i ) { - const SvxTabStop &rTabStop = m_pRuler->operator[](i); + const SvxTabStop &rTabStop = m_oRuler->operator[](i); if (nRight && rTabStop.GetTabPos() > nRight) { // Consider the first tabstop to always be in-bounds. @@ -64,7 +64,7 @@ const SvxTabStop* SwLineInfo::GetTabStop(const SwTwips nSearchPos, SwTwips& nRig sal_uInt16 SwLineInfo::NumberOfTabStops() const { - return m_pRuler->Count(); + return m_oRuler->Count(); } SwTabPortion *SwTextFormatter::NewTabPortion( SwTextFormatInfo &rInf, bool bAuto ) const