summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2013-06-23 11:25:32 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-06-24 16:08:17 +0100
commit91b8728108193706e142c25903c0dcd4ea8b0b21 (patch)
tree7a979cf11476fc5dd2bcd39ca3a1efa0ad7b5a1b /editeng
parentb139f6fedfcf3cbed0eadeb007e2155b576413d2 (diff)
Resolves: #i120020# corrected paragraph merge...
corresponding undo and ownership of linked undo actions (cherry picked from commit e58fe7afee5163833479b76a474416a77d95f075) Conflicts: editeng/source/editeng/impedit2.cxx sc/source/ui/undo/undobase.cxx sc/source/ui/undo/undodraw.cxx svl/inc/svl/undo.hxx Change-Id: I6672990558a496dfc692554437897d013e258f40
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/impedit2.cxx44
1 files changed, 35 insertions, 9 deletions
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 4bc6d7082cdb..d6e1de54601a 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -2185,6 +2185,16 @@ EditPaM ImpEditEngine::ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pR
OSL_ENSURE( aEditDoc.GetPos( pLeft ) != EE_PARA_NOT_FOUND, "Inserted node not found (1)" );
OSL_ENSURE( aEditDoc.GetPos( pRight ) != EE_PARA_NOT_FOUND, "Inserted node not found (2)" );
+ // #i120020# it is possible that left and right are *not* in the desired order (left/right)
+ // so correct it. This correction is needed, else an invalid SfxLinkUndoAction will be
+ // created from ConnectParagraphs below. Assert this situation, it should be corrected by the
+ // caller.
+ if(aEditDoc.GetPos( pLeft ) > aEditDoc.GetPos( pRight ))
+ {
+ OSL_ENSURE(false, "ImpConnectParagraphs wit wrong order of pLeft/pRight nodes (!)");
+ std::swap(pLeft, pRight);
+ }
+
sal_Int32 nParagraphTobeDeleted = aEditDoc.GetPos( pRight );
DeletedNodeInfo* pInf = new DeletedNodeInfo( (sal_uIntPtr)pRight, nParagraphTobeDeleted );
aDeletedNodes.push_back(pInf);
@@ -2301,18 +2311,34 @@ EditPaM ImpEditEngine::DeleteLeftOrRight( const EditSelection& rSel, sal_uInt8 n
else if ( nDelMode == DELMODE_RESTOFWORD )
{
aDelEnd = EndOfWord( aCurPos );
+
if (aDelEnd.GetIndex() == aCurPos.GetIndex())
{
- xub_StrLen nLen = aCurPos.GetNode()->Len();
- // end of para?
- if (aDelEnd.GetIndex() == nLen)
- aDelEnd = WordLeft( aCurPos );
- else // there's still sth to delete on the right
+ const xub_StrLen nLen(aCurPos.GetNode()->Len());
+
+ // #i120020# when 0 == nLen, aDelStart needs to be adapted, not
+ // aDelEnd. This would (and did) lead to a wrong order in the
+ // ImpConnectParagraphs call later.
+ if(nLen)
+ {
+ // end of para?
+ if (aDelEnd.GetIndex() == nLen)
+ {
+ aDelEnd = WordLeft( aCurPos );
+ }
+ else // there's still sth to delete on the right
+ {
+ aDelEnd = EndOfWord( WordRight( aCurPos ) );
+ // if there'n no next word...
+ if (aDelEnd.GetIndex() == nLen )
+ {
+ aDelEnd.SetIndex( nLen );
+ }
+ }
+ }
+ else
{
- aDelEnd = EndOfWord( WordRight( aCurPos ) );
- // if there'n no next word...
- if (aDelEnd.GetIndex() == nLen )
- aDelEnd.SetIndex( nLen );
+ aDelStart = WordLeft(aCurPos);
}
}
}