[Libreoffice-commits] core.git: sw/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Fri Sep 24 16:58:55 UTC 2021
sw/source/core/access/accpara.cxx | 4 ++--
sw/source/core/crsr/crsrsh.cxx | 16 ++++++++--------
sw/source/core/edit/eddel.cxx | 6 +++---
sw/source/core/undo/rolbck.cxx | 16 ++++++++--------
sw/source/core/undo/unredln.cxx | 4 +---
sw/source/core/unocore/unorefmk.cxx | 10 ++++++----
sw/source/filter/ascii/parasc.cxx | 4 ++--
sw/source/filter/basflt/shellio.cxx | 4 ++--
sw/source/uibase/app/docsh2.cxx | 4 ++--
sw/source/uibase/wrtsh/wrtsh2.cxx | 8 ++++----
10 files changed, 38 insertions(+), 38 deletions(-)
New commits:
commit e8edc8edbf820d8358b465b92e697eb6831d23de
Author: Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Fri Sep 24 13:41:24 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Sep 24 18:58:16 2021 +0200
no need to allocate these SwPaM on the heap
Change-Id: Ief142e6410599ea50aee4065d843d7eaea55e21c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122578
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index 9aed81d4759e..6d75fe4abf86 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -1630,7 +1630,7 @@ void SwAccessibleParagraph::_getRunAttributesImpl(
tAccParaPropValMap& rRunAttrSeq )
{
// create PaM for character at position <nIndex>
- std::unique_ptr<SwPaM> pPaM;
+ std::optional<SwPaM> pPaM;
const TextFrameIndex nCorePos(GetPortionData().GetCoreViewPosition(nIndex));
SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
SwPosition const aModelPos(pFrame->MapViewToModelPos(nCorePos));
@@ -1640,7 +1640,7 @@ void SwAccessibleParagraph::_getRunAttributesImpl(
aModelPos.nContent.GetIndex() == pTextNode->Len()
? pTextNode->Len() // ???
: aModelPos.nContent.GetIndex() + 1);
- pPaM.reset(new SwPaM(aModelPos, aEndPos));
+ pPaM.emplace(aModelPos, aEndPos);
}
// retrieve character attributes for the created PaM <pPaM>
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 7bce5b73b488..7c6b94df2da4 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2874,7 +2874,7 @@ void SwCursorShell::ParkCursor( const SwNodeIndex &rIdx )
SwNode *pNode = &rIdx.GetNode();
// create a new PaM
- std::unique_ptr<SwPaM> pNew( new SwPaM( *GetCursor()->GetPoint() ) );
+ SwPaM aNew( *GetCursor()->GetPoint() );
if( pNode->GetStartNode() )
{
pNode = pNode->StartOfSectionNode();
@@ -2882,18 +2882,18 @@ void SwCursorShell::ParkCursor( const SwNodeIndex &rIdx )
{
// the given node is in a table, thus park cursor to table node
// (outside of the table)
- pNew->GetPoint()->nNode = *pNode->StartOfSectionNode();
+ aNew.GetPoint()->nNode = *pNode->StartOfSectionNode();
}
else
// Also on the start node itself. Then we need to request the start
// node always via its end node! (StartOfSelection of StartNode is
// the parent)
- pNew->GetPoint()->nNode = *pNode->EndOfSectionNode()->StartOfSectionNode();
+ aNew.GetPoint()->nNode = *pNode->EndOfSectionNode()->StartOfSectionNode();
}
else
- pNew->GetPoint()->nNode = *pNode->StartOfSectionNode();
- pNew->SetMark();
- pNew->GetPoint()->nNode = *pNode->EndOfSectionNode();
+ aNew.GetPoint()->nNode = *pNode->StartOfSectionNode();
+ aNew.SetMark();
+ aNew.GetPoint()->nNode = *pNode->EndOfSectionNode();
// take care of all shells
for(SwViewShell& rTmp : GetRingContainer())
@@ -2901,9 +2901,9 @@ void SwCursorShell::ParkCursor( const SwNodeIndex &rIdx )
if( auto pSh = dynamic_cast<SwCursorShell *>(&rTmp))
{
if (pSh->m_pStackCursor)
- pSh->ParkPams(pNew.get(), &pSh->m_pStackCursor);
+ pSh->ParkPams(&aNew, &pSh->m_pStackCursor);
- pSh->ParkPams( pNew.get(), &pSh->m_pCurrentCursor );
+ pSh->ParkPams( &aNew, &pSh->m_pCurrentCursor );
if( pSh->m_pTableCursor )
{
// set table cursor always to 0 and the current one always to
diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index 87999e1f869e..94eb7f36abb6 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -91,12 +91,12 @@ void SwEditShell::DeleteSel( SwPaM& rPam, bool* pUndo )
}
else
{
- std::unique_ptr<SwPaM> pNewPam;
+ std::optional<SwPaM> pNewPam;
SwPaM * pPam = &rPam;
if (bSelectAll)
{
assert(dynamic_cast<SwShellCursor*>(&rPam)); // must be corrected pam
- pNewPam.reset(new SwPaM(*rPam.GetMark(), *rPam.GetPoint()));
+ pNewPam.emplace(*rPam.GetMark(), *rPam.GetPoint());
// Selection starts at the first para of the first cell, but we
// want to delete the table node before the first cell as well.
while (SwTableNode const* pTableNode =
@@ -111,7 +111,7 @@ void SwEditShell::DeleteSel( SwPaM& rPam, bool* pUndo )
pNewPam->Start()->nNode = *pSectionNode;
}
pNewPam->Start()->nContent.Assign(nullptr, 0);
- pPam = pNewPam.get();
+ pPam = &*pNewPam;
}
// delete everything
GetDoc()->getIDocumentContentOperations().DeleteAndJoin(*pPam);
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index b214da51543d..824874f4a3e0 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -644,7 +644,7 @@ void SwHistoryBookmark::SetInDoc( SwDoc* pDoc, bool )
SwNodes& rNds = pDoc->GetNodes();
IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
- std::unique_ptr<SwPaM> pPam;
+ std::optional<SwPaM> pPam;
::sw::mark::IMark* pMark = nullptr;
if(m_bSavePos)
@@ -656,12 +656,12 @@ void SwHistoryBookmark::SetInDoc( SwDoc* pDoc, bool )
// #111660# don't crash when nNode1 doesn't point to content node.
if(pContentNd)
- pPam.reset(new SwPaM(*pContentNd, m_nContent));
+ pPam.emplace(*pContentNd, m_nContent);
}
else
{
pMark = *pMarkAccess->findMark(m_aName);
- pPam.reset(new SwPaM(pMark->GetMarkPos()));
+ pPam.emplace(pMark->GetMarkPos());
}
if(m_bSaveOtherPos)
@@ -671,7 +671,7 @@ void SwHistoryBookmark::SetInDoc( SwDoc* pDoc, bool )
"<SwHistoryBookmark::SetInDoc(..)>"
" - wrong node for a mark");
- if (pPam != nullptr && pContentNd)
+ if (pPam && pContentNd)
{
pPam->SetMark();
pPam->GetMark()->nNode = m_nOtherNode;
@@ -739,11 +739,11 @@ void SwHistoryNoTextFieldmark::SetInDoc(SwDoc* pDoc, bool)
::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
SwNodes& rNds = pDoc->GetNodes();
- std::unique_ptr<SwPaM> pPam;
+ std::optional<SwPaM> pPam;
const SwContentNode* pContentNd = rNds[m_nNode]->GetContentNode();
if(pContentNd)
- pPam.reset(new SwPaM(*pContentNd, m_nContent));
+ pPam.emplace(*pContentNd, m_nContent);
if (pPam)
{
@@ -757,11 +757,11 @@ void SwHistoryNoTextFieldmark::ResetInDoc(SwDoc& rDoc)
::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
SwNodes& rNds = rDoc.GetNodes();
- std::unique_ptr<SwPaM> pPam;
+ std::optional<SwPaM> pPam;
const SwContentNode* pContentNd = rNds[m_nNode]->GetContentNode();
if(pContentNd)
- pPam.reset(new SwPaM(*pContentNd, m_nContent-1));
+ pPam.emplace(*pContentNd, m_nContent-1);
if (pPam)
{
diff --git a/sw/source/core/undo/unredln.cxx b/sw/source/core/undo/unredln.cxx
index 38caba313d8d..ec874cf93a28 100644
--- a/sw/source/core/undo/unredln.cxx
+++ b/sw/source/core/undo/unredln.cxx
@@ -128,9 +128,7 @@ void SwUndoRedline::UndoImpl(::sw::UndoRedoContext & rContext)
rPam = *pRedline;
else
{
- std::unique_ptr<SwPaM> pNewPam;
- pNewPam.reset(new SwPaM(*pRedline->GetMark(), *rPam.GetPoint()));
- rPam = *pNewPam;
+ rPam = SwPaM(*pRedline->GetMark(), *rPam.GetPoint());
}
}
}
diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx
index fd656af16a36..536aee4f4d16 100644
--- a/sw/source/core/unocore/unorefmk.cxx
+++ b/sw/source/core/unocore/unorefmk.cxx
@@ -310,10 +310,12 @@ SwXReferenceMark::getAnchor()
&m_pImpl->m_pDoc->GetNodes()))
{
SwTextNode const& rTextNode = pTextMark->GetTextNode();
- const std::unique_ptr<SwPaM> pPam( (pTextMark->End())
- ? new SwPaM( rTextNode, *pTextMark->End(),
- rTextNode, pTextMark->GetStart())
- : new SwPaM( rTextNode, pTextMark->GetStart()) );
+ std::optional<SwPaM> pPam;
+ if ( pTextMark->End() )
+ pPam.emplace( rTextNode, *pTextMark->End(),
+ rTextNode, pTextMark->GetStart());
+ else
+ pPam.emplace( rTextNode, pTextMark->GetStart());
return SwXTextRange::CreateXTextRange(
*m_pImpl->m_pDoc, *pPam->Start(), pPam->End());
diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx
index e57a03557637..c2312effadcc 100644
--- a/sw/source/filter/ascii/parasc.cxx
+++ b/sw/source/filter/ascii/parasc.cxx
@@ -155,12 +155,12 @@ ErrCode SwASCIIParser::CallParser()
::StartProgress(STR_STATSTR_W4WREAD, 0, m_nFileSize, m_rDoc.GetDocShell());
- std::unique_ptr<SwPaM> pInsPam;
+ std::optional<SwPaM> pInsPam;
sal_Int32 nSttContent = 0;
if (!m_bNewDoc)
{
const SwNodeIndex& rTmp = m_pPam->GetPoint()->nNode;
- pInsPam.reset(new SwPaM( rTmp, rTmp, 0, -1 ));
+ pInsPam.emplace( rTmp, rTmp, 0, -1 );
nSttContent = m_pPam->GetPoint()->nContent.GetIndex();
}
diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx
index 272e36a8ec6c..73cdb8d25caf 100644
--- a/sw/source/filter/basflt/shellio.cxx
+++ b/sw/source/filter/basflt/shellio.cxx
@@ -165,12 +165,12 @@ ErrCode SwReader::Read( const Reader& rOptions )
mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore );
- std::unique_ptr<SwPaM> pUndoPam;
+ std::optional<SwPaM> pUndoPam;
if( bDocUndo || mpCursor )
{
// set Pam to the previous node, so that it is not also moved
const SwNodeIndex& rTmp = pPam->GetPoint()->nNode;
- pUndoPam.reset(new SwPaM( rTmp, rTmp, 0, -1 ));
+ pUndoPam.emplace( rTmp, rTmp, 0, -1 );
}
// store for now all Fly's
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 54ffca724071..558e235bd318 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -1590,13 +1590,13 @@ ErrCode SwDocShell::LoadStylesFromFile(const OUString& rURL, SwgReaderOption& rO
{
Reader* pRead = ReadXML;
SwReaderPtr pReader;
- std::unique_ptr<SwPaM> pPam;
+ std::optional<SwPaM> pPam;
// the SW3IO - Reader need the pam/wrtshell, because only then he
// insert the styles!
if( bUnoCall )
{
SwNodeIndex aIdx( m_xDoc->GetNodes().GetEndOfContent(), -1 );
- pPam.reset(new SwPaM( aIdx ));
+ pPam.emplace( aIdx );
pReader.reset(new SwReader( aMed, rURL, *pPam ));
}
else
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index 90f08fd33a81..a4f050492328 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -72,10 +72,10 @@ void SwWrtShell::Insert(SwField const& rField, SwPaM* pAnnotationRange)
StartUndo(SwUndoId::INSERT, &aRewriter);
bool bDeleted = false;
- std::unique_ptr<SwPaM> pAnnotationTextRange;
+ std::optional<SwPaM> pAnnotationTextRange;
if (pAnnotationRange)
{
- pAnnotationTextRange.reset(new SwPaM(*pAnnotationRange->Start(), *pAnnotationRange->End()));
+ pAnnotationTextRange.emplace(*pAnnotationRange->Start(), *pAnnotationRange->End());
}
if ( HasSelection() )
@@ -95,13 +95,13 @@ void SwWrtShell::Insert(SwField const& rField, SwPaM* pAnnotationRange)
EndPara();
}
const SwPosition rEndPos( *GetCurrentShellCursor().GetPoint() );
- pAnnotationTextRange.reset(new SwPaM( rStartPos, rEndPos ));
+ pAnnotationTextRange.emplace( rStartPos, rEndPos );
}
else
{
NormalizePam( false );
const SwPaM& rCurrPaM = GetCurrentShellCursor();
- pAnnotationTextRange.reset(new SwPaM( *rCurrPaM.GetPoint(), *rCurrPaM.GetMark() ));
+ pAnnotationTextRange.emplace( *rCurrPaM.GetPoint(), *rCurrPaM.GetMark() );
ClearMark();
}
}
More information about the Libreoffice-commits
mailing list