return SwCursor from IShellCursorSupplier
rather than casting it
Change-Id: Ia950f521c8f73d8a0da59344db9b5aacb727aca8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122576
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/sw/inc/IShellCursorSupplier.hxx b/sw/inc/IShellCursorSupplier.hxx
index 991e8bb..ec945f2 100644
--- a/sw/inc/IShellCursorSupplier.hxx
+++ b/sw/inc/IShellCursorSupplier.hxx
@@ -20,7 +20,7 @@
#ifndef INCLUDED_SW_INC_ISHELLCURSORSUPPLIER_HXX
#define INCLUDED_SW_INC_ISHELLCURSORSUPPLIER_HXX
class SwPaM;
class SwCursor;
namespace sw
{
@@ -32,8 +32,8 @@ class IShellCursorSupplier
{
public:
virtual ~IShellCursorSupplier() {}
virtual SwPaM& CreateNewShellCursor() = 0;
virtual SwPaM& GetCurrentShellCursor() = 0;
virtual SwCursor& CreateNewShellCursor() = 0;
virtual SwCursor& GetCurrentShellCursor() = 0;
};
} // namespace sw
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index ddc4ef5..9f60a87 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -300,8 +300,8 @@ public:
virtual ~SwCursorShell() override;
// create new cursor and append the old one
virtual SwPaM & CreateNewShellCursor() override;
virtual SwPaM & GetCurrentShellCursor() override;
virtual SwCursor & CreateNewShellCursor() override;
virtual SwCursor & GetCurrentShellCursor() override;
SwPaM * CreateCursor();
///< delete the current cursor and make the following into the current
@@ -322,8 +322,7 @@ public:
/// If document body starts with a table.
bool StartsWithTable();
SwPaM* GetCursor( bool bMakeTableCursor = true ) const;
inline SwCursor* GetSwCursor() const;
SwCursor* GetCursor( bool bMakeTableCursor = true ) const;
// return only the current cursor
SwShellCursor* GetCursor_() { return m_pCurrentCursor; }
const SwShellCursor* GetCursor_() const { return m_pCurrentCursor; }
@@ -865,11 +864,6 @@ inline SwMoveFnCollection const & SwCursorShell::MakeFindRange(
return m_pCurrentCursor->MakeFindRange( nStt, nEnd, pPam );
}
inline SwCursor* SwCursorShell::GetSwCursor() const
{
return static_cast<SwCursor*>(GetCursor());
}
inline SwPaM* SwCursorShell::GetStackCursor() const { return m_pStackCursor; }
inline void SwCursorShell::SetMark() { m_pCurrentCursor->SetMark(); }
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx
index 431eafe..acafb12 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -2777,11 +2777,11 @@ void SwUiWriterTest4::testTdf115132()
pWrtShell->GotoTable(rTableName);
do
{
const SwStartNode* pNd = pWrtShell->GetSwCursor()->GetNode().FindTableBoxStartNode();
const SwStartNode* pNd = pWrtShell->GetCursor()->GetNode().FindTableBoxStartNode();
pWrtShell->DelRight();
CPPUNIT_ASSERT_EQUAL(pNd, pWrtShell->GetSwCursor()->GetNode().FindTableBoxStartNode());
CPPUNIT_ASSERT_EQUAL(pNd, pWrtShell->GetCursor()->GetNode().FindTableBoxStartNode());
pWrtShell->DelLeft();
CPPUNIT_ASSERT_EQUAL(pNd, pWrtShell->GetSwCursor()->GetNode().FindTableBoxStartNode());
CPPUNIT_ASSERT_EQUAL(pNd, pWrtShell->GetCursor()->GetNode().FindTableBoxStartNode());
} while (pWrtShell->GoNextCell(false));
}
}
diff --git a/sw/source/core/crsr/crbm.cxx b/sw/source/core/crsr/crbm.cxx
index 1b60a3f..30d2d6b 100644
--- a/sw/source/core/crsr/crbm.cxx
+++ b/sw/source/core/crsr/crbm.cxx
@@ -33,7 +33,7 @@ namespace
struct CursorStateHelper
{
explicit CursorStateHelper(SwCursorShell const & rShell)
: m_pCursor(rShell.GetSwCursor())
: m_pCursor(rShell.GetCursor())
, m_aSaveState(*m_pCursor)
{ }
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 7c6b94d..07092e1 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -170,7 +170,7 @@ void SwCursorShell::DestroyCursor()
* Simply returns the current shell cursor if there is no selection
* (HasSelection()).
*/
SwPaM & SwCursorShell::CreateNewShellCursor()
SwCursor & SwCursorShell::CreateNewShellCursor()
{
if (HasSelection())
{
@@ -183,16 +183,16 @@ SwPaM & SwCursorShell::CreateNewShellCursor()
* Return the current shell cursor
* @return - returns current `SwPaM` shell cursor
*/
SwPaM & SwCursorShell::GetCurrentShellCursor()
SwCursor & SwCursorShell::GetCurrentShellCursor()
{
return *GetCursor();
}
/**
* Return pointer to the current shell cursor
* @return - returns pointer to current `SwPaM` shell cursor
* @return - returns pointer to current `SwCursor` shell cursor
*/
SwPaM* SwCursorShell::GetCursor( bool bMakeTableCursor ) const
SwCursor* SwCursorShell::GetCursor( bool bMakeTableCursor ) const
{
if( m_pTableCursor )
{
@@ -1055,7 +1055,7 @@ int SwCursorShell::CompareCursorStackMkCurrPt() const
{
int nRet = 0;
const SwPosition *pFirst = nullptr, *pSecond = nullptr;
const SwPaM *pCur = GetCursor(), *pStack = m_pStackCursor;
const SwCursor *pCur = GetCursor(), *pStack = m_pStackCursor;
// cursor on stack is needed if we compare against stack
if( pStack )
{
@@ -3538,7 +3538,7 @@ sal_uLong SwCursorShell::FindAttrs( const SfxItemSet& rSet,
void SwCursorShell::SetSelection( const SwPaM& rCursor )
{
StartAction();
SwPaM* pCursor = GetCursor();
SwCursor* pCursor = GetCursor();
*pCursor->GetPoint() = *rCursor.GetPoint();
if(rCursor.GetNext() != &rCursor)
{
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 7b4a467..a5d8d64 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -2377,7 +2377,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
{
//JP 30.09.96: DoTable() builds on PopCursor and MoveCursor after AutoFormat!
pEdShell->Pop(SwCursorShell::PopMode::DeleteCurrent);
*pEdShell->GetCursor() = m_aDelPam;
*pEdShell->GetCursor() = static_cast<SwCursor&>(m_aDelPam);
pEdShell->Push();
eStat = IS_END;
diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index 71a5ae4..76d9e88 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -652,7 +652,7 @@ void SwEditShell::SpellStart(
if (pLinguIter)
{
SwCursor* pSwCursor = GetSwCursor();
SwCursor* pSwCursor = GetCursor();
SwPosition *pTmp = new SwPosition( *pSwCursor->GetPoint() );
pSwCursor->FillFindPos( eCurr, *pTmp );
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index 821b5b5..280f901 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -840,7 +840,7 @@ void SwFEShell::Insert( const OUString& rGrfName, const OUString& rFltName,
SwFlyFrameFormat* pFormat = nullptr;
CurrShell aCurr( this );
StartAllAction();
SwShellCursor *pStartCursor = dynamic_cast<SwShellCursor*>(GetSwCursor());
SwShellCursor *pStartCursor = dynamic_cast<SwShellCursor*>(GetCursor());
SwShellCursor *pCursor = pStartCursor;
do
{
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index 352ba86..170b17f 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -90,7 +90,7 @@ public:
void SwFEShell::ParkCursorInTab()
{
SwCursor * pSwCursor = GetSwCursor();
SwCursor * pSwCursor = GetCursor();
OSL_ENSURE(pSwCursor, "no SwCursor");
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index 09b7e44..1407437 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -39,6 +39,7 @@
#include <IDocumentRedlineAccess.hxx>
#include <IShellCursorSupplier.hxx>
#include <docary.hxx>
#include <swcrsr.hxx>
#include <swundo.hxx>
#include <pam.hxx>
#include <ndtxt.hxx>
@@ -1035,7 +1036,7 @@ SwUndoDontExpandFormat::SwUndoDontExpandFormat( const SwPosition& rPos )
void SwUndoDontExpandFormat::UndoImpl(::sw::UndoRedoContext & rContext)
{
SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
SwCursor *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
SwDoc *const pDoc = & rContext.GetDoc();
SwPosition& rPos = *pPam->GetPoint();
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index ba32c50..27d6c5e 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -28,6 +28,7 @@
#include <UndoManager.hxx>
#include <IDocumentRedlineAccess.hxx>
#include <docary.hxx>
#include <swcrsr.hxx>
#include <swundo.hxx>
#include <pam.hxx>
#include <ndtxt.hxx>
@@ -109,7 +110,7 @@ void SwUndRng::SetPaM( SwPaM & rPam, bool bCorrToContent ) const
SwPaM & SwUndRng::AddUndoRedoPaM(
::sw::UndoRedoContext & rContext, bool const bCorrToContent) const
{
SwPaM & rPaM( rContext.GetCursorSupplier().CreateNewShellCursor() );
SwCursor & rPaM( rContext.GetCursorSupplier().CreateNewShellCursor() );
SetPaM( rPaM, bCorrToContent );
return rPaM;
}
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index f5cc03b..f1fc4b2 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -45,6 +45,7 @@
#include <grfatr.hxx>
#include <cntfrm.hxx>
#include <flyfrm.hxx>
#include <swcrsr.hxx>
#include <swtable.hxx>
#include <redline.hxx>
#include <docary.hxx>
@@ -202,7 +203,7 @@ SwUndoInsert::~SwUndoInsert()
void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext)
{
SwDoc *const pTmpDoc = & rContext.GetDoc();
SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
SwCursor *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
if( m_bIsAppend )
{
@@ -289,7 +290,7 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext)
void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & rContext)
{
SwDoc *const pTmpDoc = & rContext.GetDoc();
SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
SwCursor *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
pPam->DeleteMark();
if( m_bIsAppend )
@@ -638,7 +639,7 @@ SwUndoReplace::Impl::Impl(
void SwUndoReplace::Impl::UndoImpl(::sw::UndoRedoContext & rContext)
{
SwDoc *const pDoc = & rContext.GetDoc();
SwPaM & rPam(rContext.GetCursorSupplier().CreateNewShellCursor());
SwCursor & rPam(rContext.GetCursorSupplier().CreateNewShellCursor());
rPam.DeleteMark();
SwTextNode* pNd = pDoc->GetNodes()[ m_nSttNd - m_nOffset ]->GetTextNode();
@@ -720,7 +721,7 @@ void SwUndoReplace::Impl::UndoImpl(::sw::UndoRedoContext & rContext)
void SwUndoReplace::Impl::RedoImpl(::sw::UndoRedoContext & rContext)
{
SwDoc & rDoc = rContext.GetDoc();
SwPaM & rPam(rContext.GetCursorSupplier().CreateNewShellCursor());
SwCursor & rPam(rContext.GetCursorSupplier().CreateNewShellCursor());
rPam.DeleteMark();
rPam.GetPoint()->nNode = m_nSttNd;
diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx
index 214ada2..4605aca 100644
--- a/sw/source/core/undo/unovwr.cxx
+++ b/sw/source/core/undo/unovwr.cxx
@@ -25,6 +25,7 @@
#include <IDocumentUndoRedo.hxx>
#include <IDocumentRedlineAccess.hxx>
#include <IShellCursorSupplier.hxx>
#include <swcrsr.hxx>
#include <swundo.hxx>
#include <pam.hxx>
#include <ndtxt.hxx>
@@ -178,7 +179,7 @@ bool SwUndoOverwrite::CanGrouping( SwDoc& rDoc, SwPosition& rPos,
void SwUndoOverwrite::UndoImpl(::sw::UndoRedoContext & rContext)
{
SwDoc& rDoc = rContext.GetDoc();
SwPaM& rCurrentPam(rContext.GetCursorSupplier().CreateNewShellCursor());
SwCursor& rCurrentPam(rContext.GetCursorSupplier().CreateNewShellCursor());
rCurrentPam.DeleteMark();
rCurrentPam.GetPoint()->nNode = m_nStartNode;
@@ -260,7 +261,7 @@ void SwUndoOverwrite::RepeatImpl(::sw::RepeatContext & rContext)
void SwUndoOverwrite::RedoImpl(::sw::UndoRedoContext & rContext)
{
SwDoc& rDoc = rContext.GetDoc();
SwPaM& rCurrentPam(rContext.GetCursorSupplier().CreateNewShellCursor());
SwCursor& rCurrentPam(rContext.GetCursorSupplier().CreateNewShellCursor());
rCurrentPam.DeleteMark();
rCurrentPam.GetPoint()->nNode = m_nStartNode;
diff --git a/sw/source/core/undo/unspnd.cxx b/sw/source/core/undo/unspnd.cxx
index 771c2650..1e8bbf0 100644
--- a/sw/source/core/undo/unspnd.cxx
+++ b/sw/source/core/undo/unspnd.cxx
@@ -23,6 +23,7 @@
#include <pam.hxx>
#include <swtable.hxx>
#include <ndtxt.hxx>
#include <swcrsr.hxx>
#include <swundo.hxx>
#include <frmfmt.hxx>
#include <UndoCore.hxx>
@@ -71,7 +72,7 @@ SwUndoSplitNode::~SwUndoSplitNode()
void SwUndoSplitNode::UndoImpl(::sw::UndoRedoContext & rContext)
{
SwDoc *const pDoc = & rContext.GetDoc();
SwPaM & rPam( rContext.GetCursorSupplier().CreateNewShellCursor() );
SwCursor & rPam( rContext.GetCursorSupplier().CreateNewShellCursor() );
rPam.DeleteMark();
if( m_bTableFlag )
{
@@ -149,7 +150,7 @@ void SwUndoSplitNode::UndoImpl(::sw::UndoRedoContext & rContext)
void SwUndoSplitNode::RedoImpl(::sw::UndoRedoContext & rContext)
{
SwPaM & rPam( rContext.GetCursorSupplier().CreateNewShellCursor() );
SwCursor & rPam( rContext.GetCursorSupplier().CreateNewShellCursor() );
rPam.GetPoint()->nNode = m_nNode;
SwTextNode * pTNd = rPam.GetNode().GetTextNode();
OSL_ENSURE(pTNd, "SwUndoSplitNode::RedoImpl(): SwTextNode expected");
diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx
index fc30657..ff25eb3 100644
--- a/sw/source/core/undo/untblk.cxx
+++ b/sw/source/core/undo/untblk.cxx
@@ -25,6 +25,7 @@
#include <IDocumentRedlineAccess.hxx>
#include <IShellCursorSupplier.hxx>
#include <docary.hxx>
#include <swcrsr.hxx>
#include <swundo.hxx>
#include <pam.hxx>
#include <mvsave.hxx>
@@ -372,7 +373,7 @@ void SwUndoInserts::UndoImpl(::sw::UndoRedoContext & rContext)
void SwUndoInserts::RedoImpl(::sw::UndoRedoContext & rContext)
{
// position cursor onto REDO section
SwPaM& rPam(rContext.GetCursorSupplier().CreateNewShellCursor());
SwCursor& rPam(rContext.GetCursorSupplier().CreateNewShellCursor());
SwDoc& rDoc = rPam.GetDoc();
rPam.DeleteMark();
rPam.GetPoint()->nNode = m_nSttNode - m_nNodeDiff;
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index f5ed679..13c0584 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -4101,7 +4101,7 @@ bool SwTransferable::PrivateDrop( SwWrtShell& rSh, const Point& rDragPt,
{
rSrcSh.CalcLayout();
rSrcSh.SwCursorShell::SetCursor(rDragPt);
rSrcSh.GetSwCursor()->SetMark();
rSrcSh.GetCursor()->SetMark();
}
}
diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx
index ba86732..c6d42d78 100644
--- a/sw/source/uibase/uiview/viewsrch.cxx
+++ b/sw/source/uibase/uiview/viewsrch.cxx
@@ -653,8 +653,8 @@ void SwView::Replace()
{
/* check that the selection match the search string*/
//save state
SwPosition aStartPos = * m_pWrtShell->GetSwCursor()->Start();
SwPosition aEndPos = * m_pWrtShell->GetSwCursor()->End();
SwPosition aStartPos = * m_pWrtShell->GetCursor()->Start();
SwPosition aEndPos = * m_pWrtShell->GetCursor()->End();
bool bHasSelection = s_pSrchItem->GetSelection();
SvxSearchCmd nOldCmd = s_pSrchItem->GetCommand();
@@ -672,13 +672,13 @@ void SwView::Replace()
if(! s_pSrchItem->GetBackward() )
{
(* m_pWrtShell->GetSwCursor()->Start()) = aStartPos;
(* m_pWrtShell->GetSwCursor()->End()) = aEndPos;
(* m_pWrtShell->GetCursor()->Start()) = aStartPos;
(* m_pWrtShell->GetCursor()->End()) = aEndPos;
}
else
{
(* m_pWrtShell->GetSwCursor()->Start()) = aEndPos;
(* m_pWrtShell->GetSwCursor()->End()) = aStartPos;
(* m_pWrtShell->GetCursor()->Start()) = aEndPos;
(* m_pWrtShell->GetCursor()->End()) = aStartPos;
}
bReqReplace = false;
}
diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx
index fc6891a..7e133b9 100644
--- a/sw/source/uibase/uno/unotxvw.cxx
+++ b/sw/source/uibase/uno/unotxvw.cxx
@@ -1448,7 +1448,7 @@ void SwXTextViewCursor::setString(const OUString& aString)
case ShellMode::Text :
{
SwWrtShell& rSh = m_pView->GetWrtShell();
SwCursor* pShellCursor = rSh.GetSwCursor();
SwCursor* pShellCursor = rSh.GetCursor();
SwUnoCursorHelper::SetString(*pShellCursor, aString);
break;
}
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index 9fb2367..2acbcc6 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -3651,7 +3651,7 @@ void SwContentTree::UpdateTracking()
void SwContentTree::SelectOutlinesWithSelection()
{
SwCursor* pFirstCursor = m_pActiveShell->GetSwCursor();
SwCursor* pFirstCursor = m_pActiveShell->GetCursor();
SwCursor* pCursor = pFirstCursor;
std::vector<SwOutlineNodes::size_type> aOutlinePositions;
do
diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx
index dae15a9..0c1cd4f 100644
--- a/sw/source/uibase/wrtsh/delete.cxx
+++ b/sw/source/uibase/wrtsh/delete.cxx
@@ -200,7 +200,7 @@ bool SwWrtShell::DelLeft()
// #i4032# Don't actually call a 'delete' if we
// changed the table cell, compare DelRight().
const SwStartNode * pSNdOld = pWasInTableNd ?
GetSwCursor()->GetNode().FindTableBoxStartNode() :
GetCursor()->GetNode().FindTableBoxStartNode() :
nullptr;
// If the cursor is at the beginning of a paragraph, try to step
@@ -216,7 +216,7 @@ bool SwWrtShell::DelLeft()
if (bDoSomething)
{
const SwStartNode* pSNdNew = pIsInTableNd ?
GetSwCursor()->GetNode().FindTableBoxStartNode() :
GetCursor()->GetNode().FindTableBoxStartNode() :
nullptr;
// #i4032# Don't actually call a 'delete' if we
@@ -345,7 +345,7 @@ bool SwWrtShell::DelRight()
const SwTableNode* pWasInTableNd = IsCursorInTable();
// #108049# Save the startnode of the current cell
const SwStartNode* pSNdOld = pWasInTableNd ?
GetSwCursor()->GetNode().FindTableBoxStartNode() : nullptr;
GetCursor()->GetNode().FindTableBoxStartNode() : nullptr;
bool bCheckDelFull = SelectionType::Text & nSelection && SwCursorShell::IsSttPara();
bool bDelFull = false;
bool bDoNothing = false;
@@ -366,7 +366,7 @@ bool SwWrtShell::DelRight()
// #108049# Save the startnode of the current cell.
// May be different to pSNdOld as we have moved.
const SwStartNode* pSNdNew = pCurrTableNd ?
GetSwCursor()->GetNode().FindTableBoxStartNode() : nullptr;
GetCursor()->GetNode().FindTableBoxStartNode() : nullptr;
// tdf#115132 Only keep cursor position instead of deleting
// if we have moved to a different cell