diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-31 09:49:55 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-31 18:32:39 +0200 |
commit | 21ad3e6cbdf9568c1152a2eab8178e4219e40c33 (patch) | |
tree | 2d18a74a588e1f1c2c688873acf4e66f5b90f12c /editeng | |
parent | 962bc9059e875f98e244b584c582f5b1674106b9 (diff) |
EditPosition does not need to be allocated separately
it's just two pointers big
Change-Id: Ie2d71f4530fa92a3d125446a6c45035e88617b97
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116473
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/eertfpar.cxx | 5 | ||||
-rw-r--r-- | editeng/source/rtf/rtfitem.cxx | 12 | ||||
-rw-r--r-- | editeng/source/rtf/svxrtf.cxx | 40 |
3 files changed, 26 insertions, 31 deletions
diff --git a/editeng/source/editeng/eertfpar.cxx b/editeng/source/editeng/eertfpar.cxx index 2be675266f36..ecc1247c913d 100644 --- a/editeng/source/editeng/eertfpar.cxx +++ b/editeng/source/editeng/eertfpar.cxx @@ -612,11 +612,6 @@ sal_Int32 EditNodeIdx::GetIdx() const EditPosition::EditPosition(EditEngine* pEE, EditSelection* pSel) : mpEditEngine(pEE), mpCurSel(pSel) {} -std::unique_ptr<EditPosition> EditPosition::Clone() const -{ - return std::unique_ptr<EditPosition>(new EditPosition(mpEditEngine, mpCurSel)); -} - std::unique_ptr<EditNodeIdx> EditPosition::MakeNodeIdx() const { return std::make_unique<EditNodeIdx>(mpEditEngine, mpCurSel->Max().GetNode()); diff --git a/editeng/source/rtf/rtfitem.cxx b/editeng/source/rtf/rtfitem.cxx index de9a66d8eddc..699fe0834f7e 100644 --- a/editeng/source/rtf/rtfitem.cxx +++ b/editeng/source/rtf/rtfitem.cxx @@ -206,8 +206,8 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) break; SvxRTFItemStackType* pCurrent = aAttrStack.empty() ? nullptr : aAttrStack.back().get(); - if( !pCurrent || (pCurrent->pSttNd->GetIdx() == pInsPos->GetNodeIdx() && - pCurrent->nSttCnt == pInsPos->GetCntIdx() )) + if( !pCurrent || (pCurrent->pSttNd->GetIdx() == mxInsertPosition->GetNodeIdx() && + pCurrent->nSttCnt == mxInsertPosition->GetCntIdx() )) break; int nLastToken = GetStackPtr(-1)->nTokenId; @@ -219,7 +219,7 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) { // Open a new Group std::unique_ptr<SvxRTFItemStackType> pNew(new SvxRTFItemStackType( - *pCurrent, *pInsPos, true )); + *pCurrent, *mxInsertPosition, true )); pNew->SetRTFDefaults( GetRTFDefaults() ); // "Set" all valid attributes up until this point @@ -232,7 +232,7 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) } else // continue to use this entry as a new one - pCurrent->SetStartPos( *pInsPos ); + pCurrent->SetStartPos( *mxInsertPosition ); pSet = &pCurrent->aAttrSet; } while( false ); @@ -1704,7 +1704,7 @@ void SvxRTFParser::RTFPardPlain( bool const bPard, SfxItemSet** ppSet ) if (pCurrent->aAttrSet.Count() || pCurrent->m_pChildList || pCurrent->nStyleNo) { // open a new group - std::unique_ptr<SvxRTFItemStackType> pNew(new SvxRTFItemStackType( *pCurrent, *pInsPos, true )); + std::unique_ptr<SvxRTFItemStackType> pNew(new SvxRTFItemStackType( *pCurrent, *mxInsertPosition, true )); pNew->SetRTFDefaults( GetRTFDefaults() ); // Set all until here valid attributes @@ -1717,7 +1717,7 @@ void SvxRTFParser::RTFPardPlain( bool const bPard, SfxItemSet** ppSet ) else { // continue to use this entry as new - pCurrent->SetStartPos( *pInsPos ); + pCurrent->SetStartPos( *mxInsertPosition ); bNewStkEntry = false; } } diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx index 4bf5c3811bdc..df0f030f0c57 100644 --- a/editeng/source/rtf/svxrtf.cxx +++ b/editeng/source/rtf/svxrtf.cxx @@ -83,14 +83,14 @@ SvxRTFParser::~SvxRTFParser() void SvxRTFParser::SetInsPos( const EditPosition& rNew ) { - pInsPos = rNew.Clone(); + mxInsertPosition = rNew; } SvParserState SvxRTFParser::CallParser() { - DBG_ASSERT( pInsPos, "no insertion position"); + DBG_ASSERT( mxInsertPosition, "no insertion position"); - if( !pInsPos ) + if( !mxInsertPosition ) return SvParserState::Error; if( !maColorTable.empty() ) @@ -614,10 +614,10 @@ SvxRTFItemStackType* SvxRTFParser::GetAttrSet_() SvxRTFItemStackType* pCurrent = aAttrStack.empty() ? nullptr : aAttrStack.back().get(); std::unique_ptr<SvxRTFItemStackType> pNew; if( pCurrent ) - pNew.reset(new SvxRTFItemStackType( *pCurrent, *pInsPos, false/*bCopyAttr*/ )); + pNew.reset(new SvxRTFItemStackType( *pCurrent, *mxInsertPosition, false/*bCopyAttr*/ )); else pNew.reset(new SvxRTFItemStackType( *pAttrPool, aWhichMap.data(), - *pInsPos )); + *mxInsertPosition )); pNew->SetRTFDefaults( GetRTFDefaults() ); aAttrStack.push_back( std::move(pNew) ); @@ -683,8 +683,8 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack sal_Int32 nOldSttNdIdx = pOld->pSttNd->GetIdx(); if (!pOld->m_pChildList && ((!pOld->aAttrSet.Count() && !pOld->nStyleNo ) || - (nOldSttNdIdx == pInsPos->GetNodeIdx() && - pOld->nSttCnt == pInsPos->GetCntIdx() ))) + (nOldSttNdIdx == mxInsertPosition->GetNodeIdx() && + pOld->nSttCnt == mxInsertPosition->GetCntIdx() ))) break; // no attributes or Area // set only the attributes that are different from the parent @@ -708,25 +708,25 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack } // Set all attributes which have been defined from start until here - bool bCrsrBack = !pInsPos->GetCntIdx(); + bool bCrsrBack = !mxInsertPosition->GetCntIdx(); if( bCrsrBack ) { // at the beginning of a paragraph? Move back one position - sal_Int32 nNd = pInsPos->GetNodeIdx(); + sal_Int32 nNd = mxInsertPosition->GetNodeIdx(); MovePos(false); // if can not move backward then later don't move forward ! - bCrsrBack = nNd != pInsPos->GetNodeIdx(); + bCrsrBack = nNd != mxInsertPosition->GetNodeIdx(); } - if( pOld->pSttNd->GetIdx() < pInsPos->GetNodeIdx() || - ( pOld->pSttNd->GetIdx() == pInsPos->GetNodeIdx() && - pOld->nSttCnt <= pInsPos->GetCntIdx() ) ) + if( pOld->pSttNd->GetIdx() < mxInsertPosition->GetNodeIdx() || + ( pOld->pSttNd->GetIdx() == mxInsertPosition->GetNodeIdx() && + pOld->nSttCnt <= mxInsertPosition->GetCntIdx() ) ) { if( !bCrsrBack ) { // all pard attributes are only valid until the previous // paragraph !! - if( nOldSttNdIdx == pInsPos->GetNodeIdx() ) + if( nOldSttNdIdx == mxInsertPosition->GetNodeIdx() ) { } else @@ -736,7 +736,7 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack // - all paragraph attributes to get the area // up to the previous paragraph std::unique_ptr<SvxRTFItemStackType> pNew( - new SvxRTFItemStackType(*pOld, *pInsPos, true)); + new SvxRTFItemStackType(*pOld, *mxInsertPosition, true)); pNew->aAttrSet.SetParent( pOld->aAttrSet.GetParent() ); // Delete all paragraph attributes from pNew @@ -783,8 +783,8 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack } } - pOld->pEndNd = pInsPos->MakeNodeIdx().release(); - pOld->nEndCnt = pInsPos->GetCntIdx(); + pOld->pEndNd = mxInsertPosition->MakeNodeIdx().release(); + pOld->nEndCnt = mxInsertPosition->GetCntIdx(); /* #i21422# @@ -812,7 +812,7 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack // Open a new Group. std::unique_ptr<SvxRTFItemStackType> pNew(new SvxRTFItemStackType( - *pCurrent, *pInsPos, true )); + *pCurrent, *mxInsertPosition, true )); pNew->SetRTFDefaults( GetRTFDefaults() ); // Set all until here valid Attributes @@ -874,8 +874,8 @@ void SvxRTFParser::SetAttrSet( SvxRTFItemStackType &rSet ) bool SvxRTFParser::IsAttrSttPos() { SvxRTFItemStackType* pCurrent = aAttrStack.empty() ? nullptr : aAttrStack.back().get(); - return !pCurrent || (pCurrent->pSttNd->GetIdx() == pInsPos->GetNodeIdx() && - pCurrent->nSttCnt == pInsPos->GetCntIdx()); + return !pCurrent || (pCurrent->pSttNd->GetIdx() == mxInsertPosition->GetNodeIdx() && + pCurrent->nSttCnt == mxInsertPosition->GetCntIdx()); } |