diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/undobj.hxx | 6 | ||||
-rw-r--r-- | sw/source/core/doc/doc.cxx | 19 | ||||
-rw-r--r-- | sw/source/core/doc/docedt.cxx | 28 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/undo/untbl.cxx | 16 |
5 files changed, 33 insertions, 38 deletions
diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx index cece9260a7f0..11da23447f4a 100644 --- a/sw/inc/undobj.hxx +++ b/sw/inc/undobj.hxx @@ -449,8 +449,6 @@ public: void SetTableName(const String & rName); // SwUndoTblCpyTbl needs this information: - long NodeDiff() const { return nSttNode - nEndNode; } - xub_StrLen ContentStart() const { return nSttCntnt; } BOOL IsDelFullPara() const { return bDelFullPara; } DECL_FIXEDMEMPOOL_NEWDEL(SwUndoDelete) @@ -1760,6 +1758,10 @@ public: SwUndoRedlineDelete( const SwPaM& rRange, SwUndoId nUserId = UNDO_EMPTY ); BOOL CanGrouping( const SwUndoRedlineDelete& rPrev ); + + // SwUndoTblCpyTbl needs this information: + long NodeDiff() const { return nSttNode - nEndNode; } + xub_StrLen ContentStart() const { return nSttCntnt; } }; class SwUndoRedlineSort : public SwUndoRedline diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index ed561397f353..6a51fc0ffd1c 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -876,22 +876,11 @@ bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr, // -> #111827# { SwUndo *const pLastUndo = GetUndoManager().GetLastUndo(); - if (pLastUndo) + SwUndoInsert *const pUndoInsert( + dynamic_cast<SwUndoInsert *>(pLastUndo) ); + if (pUndoInsert && pUndoInsert->CanGrouping(rPos)) { - switch (pLastUndo->GetId()) - { - case UNDO_INSERT: - case UNDO_TYPING: - if (static_cast<SwUndoInsert*>(pLastUndo) - ->CanGrouping( rPos )) - { - pUndo = static_cast<SwUndoInsert*>(pLastUndo); - } - break; - - default: - break; - } + pUndo = pUndoInsert; } } // <- #111827# diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 0b1a4411961b..032bcccc23b8 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -785,7 +785,6 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) SwIndex& rIdx = rPt.nContent; xub_StrLen nStart = 0; - SwUndo * pUndo; sal_Unicode c; String aStr; @@ -806,12 +805,13 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) bool bMerged(false); if (GetIDocumentUndoRedo().DoesGroupUndo()) { - pUndo = GetUndoManager().GetLastUndo(); - if (pUndo && (UNDO_OVERWRITE == pUndo->GetId())) + SwUndo *const pUndo = GetUndoManager().GetLastUndo(); + SwUndoOverwrite *const pUndoOW( + dynamic_cast<SwUndoOverwrite *>(pUndo) ); + if (pUndoOW) { // if CanGrouping() returns true it's already merged - bMerged = static_cast<SwUndoOverwrite*>(pUndo) - ->CanGrouping( this, rPt, c ); + bMerged = pUndoOW->CanGrouping( this, rPt, c ); } } if (!bMerged) @@ -1588,14 +1588,11 @@ bool SwDoc::DeleteAndJoinWithRedlineImpl( SwPaM & rPam, const bool ) if (GetIDocumentUndoRedo().DoesGroupUndo()) { SwUndo *const pLastUndo( GetUndoManager().GetLastUndo() ); - if (pLastUndo && - (UNDO_REDLINE == pLastUndo->GetId()) && - (UNDO_DELETE == - static_cast<SwUndoRedline*>(pLastUndo)->GetUserId())) + SwUndoRedlineDelete *const pUndoRedlineDel( + dynamic_cast<SwUndoRedlineDelete*>(pLastUndo) ); + if (pUndoRedlineDel) { - bool const bMerged = - static_cast<SwUndoRedlineDelete*>(pLastUndo) - ->CanGrouping( *pUndo ); + bool const bMerged = pUndoRedlineDel->CanGrouping(*pUndo); if (bMerged) { ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); @@ -1710,10 +1707,11 @@ bool SwDoc::DeleteRangeImplImpl(SwPaM & rPam) if (GetIDocumentUndoRedo().DoesGroupUndo()) { SwUndo *const pLastUndo( GetUndoManager().GetLastUndo() ); - if (pLastUndo && (UNDO_DELETE == pLastUndo->GetId())) + SwUndoDelete *const pUndoDelete( + dynamic_cast<SwUndoDelete *>(pLastUndo) ); + if (pUndoDelete) { - bMerged = static_cast<SwUndoDelete*>(pLastUndo) - ->CanGrouping( this, rPam ); + bMerged = pUndoDelete->CanGrouping( this, rPam ); // if CanGrouping() returns true it's already merged } } diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 1a3a5a9668e8..97e197b97fdc 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -2382,7 +2382,7 @@ USHORT SwDoc::MergeTbl( SwPaM& rPam ) delete pUndo; if (UNDO_REDLINE == GetIDocumentUndoRedo().GetLastUndoInfo(0)) { - SwUndoRedline *const pU = static_cast<SwUndoRedline*>( + SwUndoRedline *const pU = dynamic_cast<SwUndoRedline*>( GetIDocumentUndoRedo().RemoveLastUndo(UNDO_REDLINE)); if( pU->GetRedlSaveCount() ) { diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 2a6e41ae054a..b96fe8d05440 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -2558,23 +2558,29 @@ void SwUndoTblCpyTbl::Undo( SwUndoIter& rIter ) // There are a couple of different situations to consider during redlining if( pEntry->pUndo ) { - SwUndoDelete *pUnDel = (SwUndoDelete*)pEntry->pUndo; - if( UNDO_REDLINE == pUnDel->GetId() ) + SwUndoDelete *const pUndoDelete = + dynamic_cast<SwUndoDelete*>(pEntry->pUndo); + SwUndoRedlineDelete *const pUndoRedlineDelete = + dynamic_cast<SwUndoRedlineDelete*>(pEntry->pUndo); + OSL_ASSERT(pUndoDelete || pUndoRedlineDelete); + if (pUndoRedlineDelete) { // The old content was not empty or he has been merged with the new content bDeleteCompleteParagraph = !pEntry->bJoin; // bJoin is set when merged // Set aTmpIdx to the beginning fo the old content - SwNodeIndex aTmpIdx( *pEndNode, pUnDel->NodeDiff()-1 ); + SwNodeIndex aTmpIdx( *pEndNode, + pUndoRedlineDelete->NodeDiff()-1 ); SwTxtNode *pTxt = aTmpIdx.GetNode().GetTxtNode(); if( pTxt ) { aPam.GetPoint()->nNode = *pTxt; - aPam.GetPoint()->nContent.Assign( pTxt, pUnDel->ContentStart() ); + aPam.GetPoint()->nContent.Assign( pTxt, + pUndoRedlineDelete->ContentStart() ); } else *aPam.GetPoint() = SwPosition( aTmpIdx ); } - else if( pUnDel->IsDelFullPara() ) + else if (pUndoDelete && pUndoDelete->IsDelFullPara()) { // When the old content was an empty paragraph, but could not be joined // with the new content (e.g. because of a section or table) |