You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2013/06/23 13:25:32 UTC

svn commit: r1495808 - in /openoffice/trunk/main: editeng/source/editeng/ sc/source/ui/inc/ sc/source/ui/undo/ sd/source/ui/slidesorter/controller/ svl/inc/svl/ svl/source/undo/

Author: alg
Date: Sun Jun 23 11:25:32 2013
New Revision: 1495808

URL: http://svn.apache.org/r1495808
Log:
i120020 corected paragraph merge, corresponding undo and ownership of linked undo actions

Modified:
    openoffice/trunk/main/editeng/source/editeng/impedit2.cxx
    openoffice/trunk/main/sc/source/ui/inc/undobase.hxx
    openoffice/trunk/main/sc/source/ui/inc/undodraw.hxx
    openoffice/trunk/main/sc/source/ui/undo/undobase.cxx
    openoffice/trunk/main/sc/source/ui/undo/undodraw.cxx
    openoffice/trunk/main/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx
    openoffice/trunk/main/svl/inc/svl/undo.hxx
    openoffice/trunk/main/svl/source/undo/undo.cxx

Modified: openoffice/trunk/main/editeng/source/editeng/impedit2.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/editeng/source/editeng/impedit2.cxx?rev=1495808&r1=1495807&r2=1495808&view=diff
==============================================================================
--- openoffice/trunk/main/editeng/source/editeng/impedit2.cxx (original)
+++ openoffice/trunk/main/editeng/source/editeng/impedit2.cxx Sun Jun 23 11:25:32 2013
@@ -2298,6 +2298,16 @@ EditPaM ImpEditEngine::ImpConnectParagra
 	DBG_ASSERT( aEditDoc.GetPos( pLeft ) != USHRT_MAX, "Einzufuegenden Node nicht gefunden(1)" );
 	DBG_ASSERT( aEditDoc.GetPos( pRight ) != USHRT_MAX, "Einzufuegenden Node nicht gefunden(2)" );
 
+    // #120020# 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_uInt16 nParagraphTobeDeleted = aEditDoc.GetPos( pRight );
 	DeletedNodeInfo* pInf = new DeletedNodeInfo( (sal_uLong)pRight, nParagraphTobeDeleted );
 	aDeletedNodes.Insert( pInf, aDeletedNodes.Count() );
@@ -2423,22 +2433,38 @@ EditPaM ImpEditEngine::DeleteLeftOrRight
 		}
 		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
-				{
-					aDelEnd = EndOfWord( WordRight( aCurPos ) );
-					// if there'n no next word...
-					if (aDelEnd.GetIndex() == nLen )
-						aDelEnd.SetIndex( nLen );
-				}
-			}
-		}
+            aDelEnd = EndOfWord( aCurPos );
+
+            if (aDelEnd.GetIndex() == aCurPos.GetIndex())
+            {
+                const xub_StrLen nLen(aCurPos.GetNode()->Len());
+
+                // #120020# 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
+                {
+                    aDelStart = WordLeft(aCurPos);
+                }
+            }
+        }
 		else	// DELMODE_RESTOFCONTENT
 		{
 			aDelEnd.SetIndex( aCurPos.GetNode()->Len() );

Modified: openoffice/trunk/main/sc/source/ui/inc/undobase.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/ui/inc/undobase.hxx?rev=1495808&r1=1495807&r2=1495808&view=diff
==============================================================================
--- openoffice/trunk/main/sc/source/ui/inc/undobase.hxx (original)
+++ openoffice/trunk/main/sc/source/ui/inc/undobase.hxx Sun Jun 23 11:25:32 2013
@@ -155,8 +155,8 @@ public:
     SfxUndoAction*          GetWrappedUndo()        { return pWrappedUndo; }
     void                    ForgetWrappedUndo();
 
-    virtual sal_Bool            IsLinked();
-    virtual void            SetLinked( sal_Bool bIsLinked );
+    virtual void SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction);
+
     virtual void            Undo();
     virtual void            Redo();
     virtual void            Repeat(SfxRepeatTarget& rTarget);

Modified: openoffice/trunk/main/sc/source/ui/inc/undodraw.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/ui/inc/undodraw.hxx?rev=1495808&r1=1495807&r2=1495808&view=diff
==============================================================================
--- openoffice/trunk/main/sc/source/ui/inc/undodraw.hxx (original)
+++ openoffice/trunk/main/sc/source/ui/inc/undodraw.hxx Sun Jun 23 11:25:32 2013
@@ -43,9 +43,9 @@ public:
 	SfxUndoAction*			GetDrawUndo()		{ return pDrawUndo; }
 	void					ForgetDrawUndo();
 
-	virtual sal_Bool			IsLinked();
-	virtual void			SetLinked( sal_Bool bIsLinked );
-	virtual void			Undo();
+    virtual void SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction);
+
+    virtual void			Undo();
 	virtual void			Redo();
 	virtual void			Repeat(SfxRepeatTarget& rTarget);
 	virtual sal_Bool			CanRepeat(SfxRepeatTarget& rTarget) const;

Modified: openoffice/trunk/main/sc/source/ui/undo/undobase.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/ui/undo/undobase.cxx?rev=1495808&r1=1495807&r2=1495808&view=diff
==============================================================================
--- openoffice/trunk/main/sc/source/ui/undo/undobase.cxx (original)
+++ openoffice/trunk/main/sc/source/ui/undo/undobase.cxx Sun Jun 23 11:25:32 2013
@@ -519,18 +519,12 @@ sal_uInt16 ScUndoWrapper::GetId() const
         return 0;
 }
 
-sal_Bool ScUndoWrapper::IsLinked()
+void ScUndoWrapper::SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction)
 {
     if (pWrappedUndo)
-        return pWrappedUndo->IsLinked();
+        pWrappedUndo->SetLinkToSfxLinkUndoAction(pSfxLinkUndoAction);
     else
-        return sal_False;
-}
-
-void ScUndoWrapper::SetLinked( sal_Bool bIsLinked )
-{
-    if (pWrappedUndo)
-        pWrappedUndo->SetLinked(bIsLinked);
+        SetLinkToSfxLinkUndoAction(pSfxLinkUndoAction);
 }
 
 sal_Bool ScUndoWrapper::Merge( SfxUndoAction* pNextAction )

Modified: openoffice/trunk/main/sc/source/ui/undo/undodraw.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/ui/undo/undodraw.cxx?rev=1495808&r1=1495807&r2=1495808&view=diff
==============================================================================
--- openoffice/trunk/main/sc/source/ui/undo/undodraw.cxx (original)
+++ openoffice/trunk/main/sc/source/ui/undo/undodraw.cxx Sun Jun 23 11:25:32 2013
@@ -79,18 +79,12 @@ sal_uInt16 __EXPORT ScUndoDraw::GetId() 
 		return 0;
 }
 
-sal_Bool __EXPORT ScUndoDraw::IsLinked()
+void __EXPORT ScUndoDraw::SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction)
 {
 	if (pDrawUndo)
-		return pDrawUndo->IsLinked();
-	else
-		return sal_False;
-}
-
-void __EXPORT ScUndoDraw::SetLinked( sal_Bool bIsLinked )
-{
-	if (pDrawUndo)
-		pDrawUndo->SetLinked(bIsLinked);
+		pDrawUndo->SetLinkToSfxLinkUndoAction(pSfxLinkUndoAction);
+    else
+        SetLinkToSfxLinkUndoAction(pSfxLinkUndoAction);
 }
 
 sal_Bool  __EXPORT ScUndoDraw::Merge( SfxUndoAction* pNextAction )

Modified: openoffice/trunk/main/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx?rev=1495808&r1=1495807&r2=1495808&view=diff
==============================================================================
--- openoffice/trunk/main/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx (original)
+++ openoffice/trunk/main/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx Sun Jun 23 11:25:32 2013
@@ -262,7 +262,11 @@ void PageSelector::CheckConsistency (voi
     }
     if (nSelectionCount!=mnSelectedPageCount)
     {
-        assert(nSelectionCount==mnSelectedPageCount);
+        // #120020# The former call to assert(..) internally calls 
+        // SlideSorterModel::GetPageDescriptor which will crash in this situation
+        // (only in non-pro code). All what is wanted there is to assert it (the
+        // error is already detected), so do this directly.
+        OSL_ENSURE(false, "PageSelector: Consistency error (!)");
     }
 }
 

Modified: openoffice/trunk/main/svl/inc/svl/undo.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svl/inc/svl/undo.hxx?rev=1495808&r1=1495807&r2=1495808&view=diff
==============================================================================
--- openoffice/trunk/main/svl/inc/svl/undo.hxx (original)
+++ openoffice/trunk/main/svl/inc/svl/undo.hxx Sun Jun 23 11:25:32 2013
@@ -51,18 +51,21 @@ public:
 };
 
 //====================================================================
+class SfxLinkUndoAction;
 
 class SVL_DLLPUBLIC SfxUndoAction
 {
-	sal_Bool bLinked;
+private:
+    SfxLinkUndoAction*      mpSfxLinkUndoAction;
+
 public:
 							TYPEINFO();
 							SfxUndoAction();
 	virtual 				~SfxUndoAction();
 
-	virtual sal_Bool            IsLinked();
-	virtual void            SetLinked( sal_Bool bIsLinked = sal_True );
-	virtual void			Undo();
+    virtual void SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction);
+
+    virtual void			Undo();
     virtual void            UndoWithContext( SfxUndoContext& i_context );
 	virtual void			Redo();
     virtual void            RedoWithContext( SfxUndoContext& i_context );
@@ -448,6 +451,10 @@ class SVL_DLLPUBLIC SfxLinkUndoAction : 
 */
 
 {
+private:
+    friend class SfxUndoAction;
+    void LinkedSfxUndoActionDestructed(const SfxUndoAction& rCandidate);
+
 public:
 							TYPEINFO();
                             SfxLinkUndoAction(::svl::IUndoManager *pManager);

Modified: openoffice/trunk/main/svl/source/undo/undo.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svl/source/undo/undo.cxx?rev=1495808&r1=1495807&r2=1495808&view=diff
==============================================================================
--- openoffice/trunk/main/svl/source/undo/undo.cxx (original)
+++ openoffice/trunk/main/svl/source/undo/undo.cxx Sun Jun 23 11:25:32 2013
@@ -63,31 +63,29 @@ SfxUndoContext::~SfxUndoContext()
 
 //------------------------------------------------------------------------
 
-sal_Bool SfxUndoAction::IsLinked()
+void SfxUndoAction::SetLinkToSfxLinkUndoAction(SfxLinkUndoAction* pSfxLinkUndoAction)
 {
-	return bLinked;
-}
-
-//------------------------------------------------------------------------
-
-void SfxUndoAction::SetLinked( sal_Bool bIsLinked )
-{
-	bLinked = bIsLinked;
+    mpSfxLinkUndoAction = pSfxLinkUndoAction;
 }
 
 //------------------------------------------------------------------------
 
 SfxUndoAction::~SfxUndoAction()
 {
-	DBG_DTOR(SfxUndoAction, 0);
-	DBG_ASSERT( !IsLinked(), "Gelinkte Action geloescht" );
+    DBG_DTOR(SfxUndoAction, 0);
+
+    if(mpSfxLinkUndoAction)
+    {
+        mpSfxLinkUndoAction->LinkedSfxUndoActionDestructed(*this);
+        mpSfxLinkUndoAction = 0;
+    }
 }
 
 
 SfxUndoAction::SfxUndoAction()
+:   mpSfxLinkUndoAction(0)
 {
 	DBG_CTOR(SfxUndoAction, 0);
-	SetLinked( sal_False );
 }
 
 //------------------------------------------------------------------------
@@ -455,24 +453,18 @@ void SfxUndoManager::SetMaxUndoActionCou
 		if ( nPos > m_pData->pActUndoArray->nCurUndoAction )
 		{
             SfxUndoAction* pAction = m_pData->pActUndoArray->aUndoActions[nPos-1].pAction;
-			if ( !pAction->IsLinked() )
-			{
-                aGuard.markForDeletion( pAction );
-                m_pData->pActUndoArray->aUndoActions.Remove( nPos-1 );
-				--nNumToDelete;
-			}
+            aGuard.markForDeletion( pAction );
+            m_pData->pActUndoArray->aUndoActions.Remove( nPos-1 );
+			--nNumToDelete;
 		}
 
 		if ( nNumToDelete > 0 && m_pData->pActUndoArray->nCurUndoAction > 0 )
 		{
             SfxUndoAction* pAction = m_pData->pActUndoArray->aUndoActions[0].pAction;
-			if ( !pAction->IsLinked() )
-			{
-                aGuard.markForDeletion( pAction );
-                m_pData->pActUndoArray->aUndoActions.Remove(0);
-				--m_pData->pActUndoArray->nCurUndoAction;
-				--nNumToDelete;
-			}
+            aGuard.markForDeletion( pAction );
+            m_pData->pActUndoArray->aUndoActions.Remove(0);
+			--m_pData->pActUndoArray->nCurUndoAction;
+			--nNumToDelete;
 		}
 		
 		if ( nPos == m_pData->pActUndoArray->aUndoActions.size() )
@@ -640,9 +632,7 @@ bool SfxUndoManager::ImplAddUndoAction_N
 	// respect max number
 	if( m_pData->pActUndoArray == m_pData->pUndoArray )
     {
-		while( m_pData->pActUndoArray->aUndoActions.size() >=
-			   m_pData->pActUndoArray->nMaxUndoActions &&
-			   !m_pData->pActUndoArray->aUndoActions[0].pAction->IsLinked() )
+		while(m_pData->pActUndoArray->aUndoActions.size() >= m_pData->pActUndoArray->nMaxUndoActions)
 		{
             i_guard.markForDeletion( m_pData->pActUndoArray->aUndoActions[0].pAction );
 			m_pData->pActUndoArray->aUndoActions.Remove(0);
@@ -1400,7 +1390,7 @@ SfxLinkUndoAction::SfxLinkUndoAction(::s
 	{
 		size_t nPos = pManager->GetUndoActionCount()-1;
 		pAction = pUndoManagerImplementation->m_pData->pActUndoArray->aUndoActions[nPos].pAction;
-		pAction->SetLinked();
+		pAction->SetLinkToSfxLinkUndoAction(this);
 	}
 	else
 		pAction = 0;
@@ -1467,9 +1457,18 @@ XubString SfxLinkUndoAction::GetRepeatCo
 SfxLinkUndoAction::~SfxLinkUndoAction()
 {
 	if( pAction )
-		pAction->SetLinked( sal_False );
+		pAction->SetLinkToSfxLinkUndoAction(0);
 }
 
+//------------------------------------------------------------------------
+
+void SfxLinkUndoAction::LinkedSfxUndoActionDestructed(const SfxUndoAction& rCandidate)
+{
+    OSL_ENSURE(0 != pAction, "OOps, we have no linked SfxUndoAction (!)");
+    OSL_ENSURE(pAction == &rCandidate, "OOps, the destroyed and linked UndoActions differ (!)");
+    (void)rCandidate;
+    pAction = 0;
+}
 
 //------------------------------------------------------------------------