diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-08-07 21:22:00 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-08-09 13:34:50 +0200 |
commit | 620b18d0dda96525d818698ea6ce84c9e27e9d7b (patch) | |
tree | 05dec6df2a752bc67b34a6d0247805e79ce0768e | |
parent | 892bd0dfc1b107a5b00af36a0d0db1f9f9c05147 (diff) |
unique_ptr->optional in SwAutoCorrDoc
Change-Id: I3280b588f365b73e08e17f14e2909b58e0fd85ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137998
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/source/core/edit/acorrect.cxx | 24 | ||||
-rw-r--r-- | sw/source/core/inc/acorrect.hxx | 4 |
2 files changed, 14 insertions, 14 deletions
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx index fe202c35f679..2adb75fa02e0 100644 --- a/sw/source/core/edit/acorrect.cxx +++ b/sw/source/core/edit/acorrect.cxx @@ -338,15 +338,15 @@ OUString const* SwAutoCorrDoc::GetPrevPara(bool const bAtNormalPos) { OUString const* pStr(nullptr); - if( bAtNormalPos || !m_pIndex ) + if( bAtNormalPos || !m_oIndex ) { - m_pIndex.reset(new SwNodeIndex(m_rCursor.GetPoint()->nNode)); + m_oIndex.emplace(m_rCursor.GetPoint()->nNode); } - sw::GotoPrevLayoutTextFrame(*m_pIndex, m_rEditSh.GetLayout()); + sw::GotoPrevLayoutTextFrame(*m_oIndex, m_rEditSh.GetLayout()); SwTextFrame const* pFrame(nullptr); - for (SwTextNode * pTextNd = m_pIndex->GetNode().GetTextNode(); - pTextNd; pTextNd = m_pIndex->GetNode().GetTextNode()) + for (SwTextNode * pTextNd = m_oIndex->GetNode().GetTextNode(); + pTextNd; pTextNd = m_oIndex->GetNode().GetTextNode()) { pFrame = static_cast<SwTextFrame const*>( pTextNd->getLayoutFrame(m_rEditSh.GetLayout())); @@ -354,7 +354,7 @@ OUString const* SwAutoCorrDoc::GetPrevPara(bool const bAtNormalPos) { break; } - sw::GotoPrevLayoutTextFrame(*m_pIndex, m_rEditSh.GetLayout()); + sw::GotoPrevLayoutTextFrame(*m_oIndex, m_rEditSh.GetLayout()); } if (pFrame && !pFrame->GetText().isEmpty() && 0 == pFrame->GetTextNodeForParaProps()->GetAttrOutlineLevel()) @@ -458,9 +458,9 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, if( pPara ) { - OSL_ENSURE( !m_pIndex, "who has not deleted his Index?" ); - m_pIndex.reset(new SwNodeIndex( m_rCursor.GetPoint()->nNode )); - sw::GotoPrevLayoutTextFrame(*m_pIndex, m_rEditSh.GetLayout()); + OSL_ENSURE( !m_oIndex, "who has not deleted his Index?" ); + m_oIndex.emplace(m_rCursor.GetPoint()->nNode); + sw::GotoPrevLayoutTextFrame(*m_oIndex, m_rEditSh.GetLayout()); } SwDoc* pAutoDoc = aTBlks.GetDoc(); @@ -490,8 +490,8 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, if( pPara ) { - sw::GotoNextLayoutTextFrame(*m_pIndex, m_rEditSh.GetLayout()); - pTextNd = m_pIndex->GetNode().GetTextNode(); + sw::GotoNextLayoutTextFrame(*m_oIndex, m_rEditSh.GetLayout()); + pTextNd = m_oIndex->GetNode().GetTextNode(); } bRet = true; } @@ -587,7 +587,7 @@ void SwAutoCorrDoc::SaveCpltSttWord( ACFlags nFlag, sal_Int32 nPos, const OUString& rExceptWord, sal_Unicode cChar ) { - SwNodeOffset nNode = m_pIndex ? m_pIndex->GetIndex() : m_rCursor.GetPoint()->GetNodeIndex(); + SwNodeOffset nNode = m_oIndex ? m_oIndex->GetIndex() : m_rCursor.GetPoint()->GetNodeIndex(); LanguageType eLang = GetLanguage(nPos); m_rEditSh.GetDoc()->SetAutoCorrExceptWord( std::make_unique<SwAutoCorrExceptWord>( nFlag, nNode, nPos, rExceptWord, cChar, eLang )); diff --git a/sw/source/core/inc/acorrect.hxx b/sw/source/core/inc/acorrect.hxx index 884e749e0d32..16df1c6a0b45 100644 --- a/sw/source/core/inc/acorrect.hxx +++ b/sw/source/core/inc/acorrect.hxx @@ -25,10 +25,10 @@ #include <svl/itemset.hxx> #include <editeng/svxacorr.hxx> #include <nodeoffset.hxx> +#include <ndindex.hxx> class SwEditShell; class SwPaM; -class SwNodeIndex; struct SwPosition; class SfxItemSet; @@ -49,7 +49,7 @@ class SwAutoCorrDoc final : public SvxAutoCorrDoc { SwEditShell& m_rEditSh; SwPaM& m_rCursor; - std::unique_ptr<SwNodeIndex> m_pIndex; + std::optional<SwNodeIndex> m_oIndex; int m_nEndUndoCounter; bool m_bUndoIdInitialized; |