[Libreoffice-commits] core.git: sw/inc sw/source
Noel Grandin
noel.grandin at collabora.co.uk
Thu Jun 7 10:14:35 UTC 2018
sw/inc/doc.hxx | 2 +-
sw/inc/extinput.hxx | 5 +++++
sw/inc/swcrsr.hxx | 10 ++++++++++
sw/inc/viscrs.hxx | 11 ++++++++++-
sw/source/core/crsr/crsrsh.cxx | 15 +++++++--------
sw/source/core/doc/extinput.cxx | 6 +++---
sw/source/core/frmedt/fefly1.cxx | 2 +-
sw/source/core/unocore/unocrsr.cxx | 2 +-
sw/source/core/unocore/unoobj.cxx | 2 +-
sw/source/core/view/vprint.cxx | 4 ++--
10 files changed, 41 insertions(+), 18 deletions(-)
New commits:
commit 8e156f009e29a90883c2536943f338be163dad45
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Apr 5 13:18:07 2018 +0200
provide overrides of GetNext/GetPrev in SwPaM subclasses
so we don't need to cast at the call sites.
Also fix the type of mpExtInputRing in SwDoc
Change-Id: I60794a4b5c24ca552eafa87b8810dc08efdee3ea
Reviewed-on: https://gerrit.libreoffice.org/52455
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index ab3acf7d9070..5aac6bcd5061 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -266,7 +266,7 @@ class SW_DLLPUBLIC SwDoc final
mutable std::unordered_map<OUString, SwNumRule *> maNumRuleMap;
std::unique_ptr<SwPagePreviewPrtData> m_pPgPViewPrtData; //< Indenting / spacing for printing of page view.
- SwPaM *mpExtInputRing;
+ SwExtTextInput *mpExtInputRing;
IStyleAccess *mpStyleAccess; //< handling of automatic styles
SwLayoutCache *mpLayoutCache; /**< Layout cache to read and save with the
diff --git a/sw/inc/extinput.hxx b/sw/inc/extinput.hxx
index 262471bf2711..5fcda8748c88 100644
--- a/sw/inc/extinput.hxx
+++ b/sw/inc/extinput.hxx
@@ -42,6 +42,11 @@ public:
bool IsOverwriteCursor() const { return bIsOverwriteCursor; }
void SetOverwriteCursor( bool bFlag );
void SetLanguage(LanguageType eSet) { eInputLanguage = eSet;}
+
+ SwExtTextInput* GetNext() { return static_cast<SwExtTextInput *>(GetNextInRing()); }
+ const SwExtTextInput* GetNext() const { return static_cast<SwExtTextInput const *>(GetNextInRing()); }
+ SwExtTextInput* GetPrev() { return static_cast<SwExtTextInput *>(GetPrevInRing()); }
+ const SwExtTextInput* GetPrev() const { return static_cast<SwExtTextInput const *>(GetPrevInRing()); }
};
#endif // INCLUDED_SW_INC_EXTINPUT_HXX
diff --git a/sw/inc/swcrsr.hxx b/sw/inc/swcrsr.hxx
index 6d306073de26..b195a12f579f 100644
--- a/sw/inc/swcrsr.hxx
+++ b/sw/inc/swcrsr.hxx
@@ -218,6 +218,11 @@ public:
long GetCursorRowSpanOffset() const { return m_nRowSpanOffset; }
+ SwCursor* GetNext() { return dynamic_cast<SwCursor *>(GetNextInRing()); }
+ const SwCursor* GetNext() const { return dynamic_cast<SwCursor const *>(GetNextInRing()); }
+ SwCursor* GetPrev() { return dynamic_cast<SwCursor *>(GetPrevInRing()); }
+ const SwCursor* GetPrev() const { return dynamic_cast<SwCursor const *>(GetPrevInRing()); }
+
DECL_FIXEDMEMPOOL_NEWDEL( SwCursor )
};
@@ -301,6 +306,11 @@ public:
bool NewTableSelection();
void ActualizeSelection( const SwSelBoxes &rBoxes );
+
+ SwTableCursor* GetNext() { return dynamic_cast<SwTableCursor *>(GetNextInRing()); }
+ const SwTableCursor* GetNext() const { return dynamic_cast<SwTableCursor const *>(GetNextInRing()); }
+ SwTableCursor* GetPrev() { return dynamic_cast<SwTableCursor *>(GetPrevInRing()); }
+ const SwTableCursor* GetPrev() const { return dynamic_cast<SwTableCursor const *>(GetPrevInRing()); }
};
#endif
diff --git a/sw/inc/viscrs.hxx b/sw/inc/viscrs.hxx
index e30fd59283f3..902a25314a00 100644
--- a/sw/inc/viscrs.hxx
+++ b/sw/inc/viscrs.hxx
@@ -114,7 +114,7 @@ public:
long* pX = nullptr, long* pY = nullptr );
};
-class SwShellCursor : public virtual SwCursor, public SwSelPaintRects
+class SW_DLLPUBLIC SwShellCursor : public virtual SwCursor, public SwSelPaintRects
{
private:
// Document positions of start/end characters of a SSelection.
@@ -163,6 +163,11 @@ public:
virtual bool IsReadOnlyAvailable() const override;
+ SwShellCursor* GetNext() { return dynamic_cast<SwShellCursor *>(GetNextInRing()); }
+ const SwShellCursor* GetNext() const { return dynamic_cast<SwShellCursor const *>(GetNextInRing()); }
+ SwShellCursor* GetPrev() { return dynamic_cast<SwShellCursor *>(GetPrevInRing()); }
+ const SwShellCursor* GetPrev() const { return dynamic_cast<SwShellCursor const *>(GetPrevInRing()); }
+
DECL_FIXEDMEMPOOL_NEWDEL( SwShellCursor )
};
@@ -199,6 +204,10 @@ public:
// true: Cursor can be set to this position.
virtual bool IsAtValidPos( bool bPoint = true ) const override;
+ SwShellTableCursor* GetNext() { return dynamic_cast<SwShellTableCursor *>(GetNextInRing()); }
+ const SwShellTableCursor* GetNext() const { return dynamic_cast<SwShellTableCursor const *>(GetNextInRing()); }
+ SwShellTableCursor* GetPrev() { return dynamic_cast<SwShellTableCursor *>(GetPrevInRing()); }
+ const SwShellTableCursor* GetPrev() const { return dynamic_cast<SwShellTableCursor const *>(GetPrevInRing()); }
};
#endif // INCLUDED_SW_INC_VISCRS_HXX
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 5c7869a5c331..1158e82afdc8 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -964,8 +964,7 @@ bool SwCursorShell::TestCurrPam(
{
return true; // return without update
}
- } while( m_pCurrentCursor !=
- ( pCmp = dynamic_cast<SwShellCursor*>(pCmp->GetNext()) ) );
+ } while( m_pCurrentCursor != ( pCmp = pCmp->GetNext() ) );
return false;
}
@@ -1219,7 +1218,7 @@ bool SwCursorShell::GoNextCursor()
SET_CURR_SHELL( this );
SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
- m_pCurrentCursor = dynamic_cast<SwShellCursor*>(m_pCurrentCursor->GetNext());
+ m_pCurrentCursor = m_pCurrentCursor->GetNext();
// #i24086#: show also all others
if( !ActionPend() )
@@ -1238,7 +1237,7 @@ bool SwCursorShell::GoPrevCursor()
SET_CURR_SHELL( this );
SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
- m_pCurrentCursor = dynamic_cast<SwShellCursor*>(m_pCurrentCursor->GetPrev());
+ m_pCurrentCursor = m_pCurrentCursor->GetPrev();
// #i24086#: show also all others
if( !ActionPend() )
@@ -1839,11 +1838,11 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd )
m_pCurrentCursor->SwSelPaintRects::Show();
if( m_pBlockCursor )
{
- SwShellCursor* pNxt = dynamic_cast<SwShellCursor*>(m_pCurrentCursor->GetNext());
+ SwShellCursor* pNxt = m_pCurrentCursor->GetNext();
while( pNxt && pNxt != m_pCurrentCursor )
{
pNxt->SwSelPaintRects::Show();
- pNxt = dynamic_cast<SwShellCursor*>(pNxt->GetNext());
+ pNxt = pNxt->GetNext();
}
}
}
@@ -2023,7 +2022,7 @@ bool SwCursorShell::Pop(PopMode const eDelete)
// the successor becomes the current one
if (m_pStackCursor->GetNext() != m_pStackCursor)
{
- pTmp = dynamic_cast<SwShellCursor*>(m_pStackCursor->GetNext());
+ pTmp = m_pStackCursor->GetNext();
}
if (PopMode::DeleteStack == eDelete)
@@ -2095,7 +2094,7 @@ void SwCursorShell::Combine()
SwShellCursor * pTmp = nullptr;
if (m_pStackCursor->GetNext() != m_pStackCursor)
{
- pTmp = dynamic_cast<SwShellCursor*>(m_pStackCursor->GetNext());
+ pTmp = m_pStackCursor->GetNext();
}
delete m_pCurrentCursor;
m_pCurrentCursor = m_pStackCursor;
diff --git a/sw/source/core/doc/extinput.cxx b/sw/source/core/doc/extinput.cxx
index 8eb26bacd64c..8a34a9011bf9 100644
--- a/sw/source/core/doc/extinput.cxx
+++ b/sw/source/core/doc/extinput.cxx
@@ -270,7 +270,7 @@ SwExtTextInput* SwDoc::GetExtTextInput( const SwNode& rNd,
if( mpExtInputRing )
{
sal_uLong nNdIdx = rNd.GetIndex();
- SwExtTextInput* pTmp = static_cast<SwExtTextInput*>(mpExtInputRing);
+ SwExtTextInput* pTmp = mpExtInputRing;
do {
sal_uLong nPt = pTmp->GetPoint()->nNode.GetIndex(),
nMk = pTmp->GetMark()->nNode.GetIndex();
@@ -290,7 +290,7 @@ SwExtTextInput* SwDoc::GetExtTextInput( const SwNode& rNd,
pRet = pTmp;
break;
}
- pTmp = static_cast<SwExtTextInput*>(pTmp->GetNext());
+ pTmp = pTmp->GetNext();
} while ( pTmp!=mpExtInputRing );
}
return pRet;
@@ -300,7 +300,7 @@ SwExtTextInput* SwDoc::GetExtTextInput() const
{
OSL_ENSURE( !mpExtInputRing || !mpExtInputRing->IsMultiSelection(),
"more than one InputEngine available" );
- return static_cast<SwExtTextInput*>(mpExtInputRing);
+ return mpExtInputRing;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index 856870f2cf4f..8f1519fcb768 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -841,7 +841,7 @@ void SwFEShell::Insert( const OUString& rGrfName, const OUString& rFltName,
nullptr, nullptr );
OSL_ENSURE(pFormat, "IDocumentContentOperations::InsertGraphic failed.");
- pCursor = dynamic_cast<SwShellCursor*>(pCursor->GetNext());
+ pCursor = pCursor->GetNext();
} while( pCursor != pStartCursor );
EndAllAction();
diff --git a/sw/source/core/unocore/unocrsr.cxx b/sw/source/core/unocore/unocrsr.cxx
index da347c2801b9..56dd18792dca 100644
--- a/sw/source/core/unocore/unocrsr.cxx
+++ b/sw/source/core/unocore/unocrsr.cxx
@@ -47,7 +47,7 @@ SwUnoCursor::~SwUnoCursor()
// delete the whole ring
while( GetNext() != this )
{
- Ring* pNxt = GetNext();
+ Ring* pNxt = GetNextInRing();
pNxt->MoveTo(nullptr); // remove from chain
delete pNxt; // and delete
}
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index c66685d35f59..c1c91b365bf0 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -747,7 +747,7 @@ void SwXTextCursor::DeleteAndInsert(const OUString& rText,
SwUnoCursorHelper::SelectPam(*pUnoCursor, true);
pCurrent->Left(rText.getLength());
}
- pCurrent = static_cast<SwCursor*>(pCurrent->GetNext());
+ pCurrent = pCurrent->GetNext();
} while (pCurrent != pUnoCursor);
pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
}
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
index 08a69f624dd6..ebae2c55c8f0 100644
--- a/sw/source/core/view/vprint.cxx
+++ b/sw/source/core/view/vprint.cxx
@@ -346,10 +346,10 @@ void SwViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt)
pPrtDoc->ReplaceStyles( *GetDoc() );
SwShellCursor *pActCursor = pFESh->GetCursor_();
- SwShellCursor *pFirstCursor = dynamic_cast<SwShellCursor*>(pActCursor->GetNext());
+ SwShellCursor *pFirstCursor = pActCursor->GetNext();
if( !pActCursor->HasMark() ) // with a multi-selection the current cursor might be empty
{
- pActCursor = dynamic_cast<SwShellCursor*>(pActCursor->GetPrev());
+ pActCursor = pActCursor->GetPrev();
}
// Y-position of the first selection
More information about the Libreoffice-commits
mailing list