1. mst
  2. ooo340

Commits

kz  committed 1a8a969

CWS-TOOLING: integrate CWS clnoundo
2009-05-18 09:40:22 +0200 wg r271998 : i102011
2009-04-28 12:20:24 +0200 cl r271318 : CWS-TOOLING: rebase CWS clnoundo to trunk@270723 (milestone: DEV300:m46)
2009-04-02 11:37:14 +0200 cl r270388 : #i100371# check valid positions all the time to avoid crashes during model lock
2009-03-30 13:02:27 +0200 cl r270219 : #i100371# do not create undo actions in drawing layer during load
2009-03-30 12:59:41 +0200 cl r270218 : #i100371# do not create undo actions in drawing layer during load
2009-03-30 12:55:06 +0200 cl r270217 : #i100371# do not create undo actions in drawing layer during load
2009-03-30 12:53:27 +0200 cl r270216 : #i100371# do not create undo actions in drawing layer during load
2009-03-30 12:49:28 +0200 cl r270215 : #i100371# added EnableUndo() and IsUndoEnabled()

  • Participants
  • Parent commits cc69e10
  • Branches default

Comments (0)

Files changed (65)

File sc/inc/document.hxx

View file
  • Ignore whitespace
 class ScTemporaryChartLock;
 class ScLookupCache;
 struct ScLookupCacheMapImpl;
+class SfxUndoManager;
 
 namespace com { namespace sun { namespace star {
     namespace lang {
 friend class ScHorizontalAttrIterator;
 friend class ScDocAttrIterator;
 friend class ScAttrRectIterator;
+friend class ScDocShell;
 #if OLD_PIVOT_IMPLEMENTATION
 friend class ScPivot;
 #endif
 
 	vos::ORef<ScPoolHelper> xPoolHelper;
 
+	SfxUndoManager* 	mpUndoManager;
 	ScFieldEditEngine*	pEditEngine;					// uses pEditPool from xPoolHelper
 	ScNoteEditEngine*	pNoteEngine;					// uses pEditPool from xPoolHelper
 	SfxItemPool*	pNoteItemPool; // SfxItemPool to be used if pDrawLayer not created.
 
     mutable BOOL        bStyleSheetUsageInvalid;
 
-    BOOL                bUndoEnabled;
+    bool                mbUndoEnabled;
     bool                mbAdjustHeightEnabled;
     bool                mbExecuteLinkEnabled;
     bool                mbChangeReadOnlyEnabled;    // allow changes in read-only document (for API import filters)
 	BOOL			IsClipOrUndo() const 						{ return bIsClip || bIsUndo; }
 	BOOL			IsUndo() const								{ return bIsUndo; }
 	BOOL			IsClipboard() const 						{ return bIsClip; }
-	BOOL			IsUndoEnabled() const						{ return bUndoEnabled; }
-    void            EnableUndo( BOOL bVal )                     { bUndoEnabled = bVal; }
+	bool			IsUndoEnabled() const						{ return mbUndoEnabled; }
+	void            EnableUndo( bool bVal );
+	
     bool            IsAdjustHeightEnabled() const               { return mbAdjustHeightEnabled; }
     void            EnableAdjustHeight( bool bVal )             { mbAdjustHeightEnabled = bVal; }
     bool            IsExecuteLinkEnabled() const                { return mbExecuteLinkEnabled; }
     formula::FormulaGrammar::Grammar  GetStorageGrammar() const
                             { return eStorageGrammar; }
 
+	SfxUndoManager*     GetUndoManager();
 private: // CLOOK-Impl-Methoden
 
 	void	ImplCreateOptions(); // bei Gelegenheit auf on-demand umstellen?

File sc/source/core/data/documen2.cxx

View file
  • Ignore whitespace
 ScDocument::ScDocument( ScDocumentMode	eMode,
 						SfxObjectShell* pDocShell ) :
 		xServiceManager( ::comphelper::getProcessServiceFactory() ),
+		mpUndoManager( NULL ),
 		pEditEngine( NULL ),
 		pNoteEngine( NULL ),
 		pNoteItemPool( NULL ),
         bInUnoListenerCall( FALSE ),
         eGrammar( formula::FormulaGrammar::GRAM_NATIVE ),
         bStyleSheetUsageInvalid( TRUE ),
-        bUndoEnabled( TRUE ),
+        mbUndoEnabled( true ),
         mbAdjustHeightEnabled( true ),
         mbExecuteLinkEnabled( true ),
         mbChangeReadOnlyEnabled( false ),

File sc/source/core/data/document.cxx

View file
  • Ignore whitespace
 	return FALSE;		// sonst nicht
 }
 
-
-
+SfxUndoManager* ScDocument::GetUndoManager()
+{
+	if (!mpUndoManager)
+		mpUndoManager = new SfxUndoManager;
+	return mpUndoManager;
+}
+
+
+void ScDocument::EnableUndo( bool bVal )
+{
+	GetUndoManager()->EnableUndo(bVal);
+	mbUndoEnabled = bVal;
+}
+
+

File sc/source/ui/docshell/docsh.cxx

View file
  • Ignore whitespace
         aDdeTextFmt(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("TEXT"))), \
 		nPrtToScreenFactor( 1.0 ), \
         pImpl           ( new DocShell_Impl ), \
-		pUndoManager	( NULL ), \
 		bHeaderOn		( TRUE ), \
 		bFooterOn		( TRUE ), \
         bNoInformLost   ( TRUE ), \
 		pSfxApp->RemoveDdeTopic( this );
 
 	delete pDocFunc;
-	delete pUndoManager;
+	delete aDocument.mpUndoManager;
+	aDocument.mpUndoManager = 0;
     delete pImpl;
 
 	delete pPaintLockData;
 
 SfxUndoManager* __EXPORT ScDocShell::GetUndoManager()
 {
-	if (!pUndoManager)
-		pUndoManager = new SfxUndoManager;
-	return pUndoManager;
+	return aDocument.GetUndoManager();
 }
 
 void ScDocShell::SetModified( BOOL bModified )

File sc/source/ui/inc/docsh.hxx

View file
  • Ignore whitespace
 	double				nPrtToScreenFactor;
 //!   FontList*           pFontList;
     DocShell_Impl*      pImpl;
-	SfxUndoManager* 	pUndoManager;
 	ScDocFunc*			pDocFunc;
 
 	//SfxObjectCreateMode	eShellMode;

File sd/source/core/drawdoc2.cxx

View file
  • Ignore whitespace
 	USHORT	nNoOfPages		   = GetSdPageCount(PK_STANDARD);
 	BOOL	bSomethingHappened = FALSE;
 
-	BegUndo(String(SdResId(STR_UNDO_MOVEPAGES)));
+	const bool bUndo = IsUndoEnabled();
+
+	if( bUndo )
+		BegUndo(String(SdResId(STR_UNDO_MOVEPAGES)));
 
 	// Liste mit selektierten Seiten
 	List	aPageList;
 			if (nPage != 0)
 			{
 				SdrPage* pPg = GetPage(nPage);
-				AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage, 1));
+				if( bUndo )
+					AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage, 1));
 				MovePage(nPage, 1);
 				pPg = GetPage(nPage+1);
-				AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage+1, 2));
+				if( bUndo )
+					AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage+1, 2));
 				MovePage(nPage+1, 2);
 				bSomethingHappened = TRUE;
 			}
 				if (nPage != nTargetPage)
 				{
 					SdrPage* pPg = GetPage(nPage);
-					AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage, nTargetPage));
+					if( bUndo )
+						AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage, nTargetPage));
 					MovePage(nPage, nTargetPage);
 					pPg = GetPage(nPage+1);
-					AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage+1, nTargetPage+1));
+					if( bUndo )
+						AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage+1, nTargetPage+1));
 					MovePage(nPage+1, nTargetPage+1);
 					bSomethingHappened = TRUE;
 				}
 				if (nPage != nTargetPage)
 				{
 					SdrPage* pPg = GetPage(nPage+1);
-					AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage+1, nTargetPage+1));
+					if( bUndo )
+						AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage+1, nTargetPage+1));
 					MovePage(nPage+1, nTargetPage+1);
 					pPg = GetPage(nPage);
-					AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage, nTargetPage));
+					if( bUndo )
+						AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage, nTargetPage));
 					MovePage(nPage, nTargetPage);
 					bSomethingHappened = TRUE;
 				}
 		}
 	}
 
-	EndUndo();
+	if( bUndo )
+		EndUndo();
 
 	return bSomethingHappened;
 }

File sd/source/core/drawdoc3.cxx

View file
  • Ignore whitespace
 	/**************************************************************************
 	* Dokument einfuegen
 	**************************************************************************/
-	BegUndo(String(SdResId(STR_UNDO_INSERTPAGES)));
+
+	const bool bUndo = IsUndoEnabled();
+
+	if( bUndo )
+		BegUndo(String(SdResId(STR_UNDO_INSERTPAGES)));
 
 	if (!pBookmarkList)
 	{
                             pPage->SetName( pStandardPage->GetRealName() );
                         }
 
-						AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pStandardPage));
+						if( bUndo )
+							AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pStandardPage));
+
 						RemovePage(nDestPageNum);
+
+						if( !bUndo )
+							delete pStandardPage;
 					}
 
 					SdPage* pNotesPage = 0L;
 	                            pNewNotesPage->SetName( pStandardPage->GetRealName() );
                         }
 
-						AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
+						if( bUndo )
+							AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
+
 						RemovePage(nDestPageNum);
+
+						if( !bUndo )
+							delete pNotesPage;
 					}
 
 					nReplacedStandardPages++;
 			     aTest == aMPLayout &&
 				 eKind == pTest->GetPageKind() )
 			{
-                AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pRefPage));
+				if( bUndo )
+					AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pRefPage));
+
                 RemoveMasterPage(nPage);
+
+				if( !bUndo )
+					delete pRefPage;
                 nNewMPageCount--;
 				break;
 			}
 
             // update layout and referred master page
 			pRefPage->SetPresentationLayout(aLayout);
-			AddUndo( GetSdrUndoFactory().CreateUndoPageChangeMasterPage( *pRefPage ) );
+			if( bUndo )
+				AddUndo( GetSdrUndoFactory().CreateUndoPageChangeMasterPage( *pRefPage ) );
 
 			if (bScaleObjects)
 			{
 
             // update layout and referred master page
 			pRefPage->SetPresentationLayout(aLayout);
-			AddUndo( GetSdrUndoFactory().CreateUndoPageChangeMasterPage( *pRefPage ) );
+			if( bUndo )
+				AddUndo( GetSdrUndoFactory().CreateUndoPageChangeMasterPage( *pRefPage ) );
 
 			if (bScaleObjects)
 			{
     // #91146# Make absolutely sure no double masterpages are there
     RemoveUnnecessaryMasterPages(NULL, TRUE, TRUE);
 
-    EndUndo();
+	if( bUndo )
+		EndUndo();
 	pUndoMgr->LeaveListAction();
 
 	return bContinue;
 	::sd::View* pView = NULL;
 	SfxUndoManager* pUndoMgr = NULL;
 
+	if( bUndo && !IsUndoEnabled() )
+		bUndo = FALSE;
+
 	if (mpDocSh)
 	{
 		pUndoMgr = mpDocSh->GetUndoManager();
 
 				RemoveMasterPage( pNotesMaster->GetPageNum() );
 
+				if( !bUndo )
+					delete pNotesMaster;
+
 				if( bUndo )
 					AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pMaster));
 
 				RemoveMasterPage( pMaster->GetPageNum() );
 
+				if( !bUndo )
+					delete pMaster;
+
 				if( bUndo )
 					EndUndo();	// schon hier, damit sich Joes Actions ZWISCHEN unsere eigenen schieben
 
 		mpDocSh->SetWaitCursor( TRUE );
 
 	SfxUndoManager* pUndoMgr = mpDocSh->GetUndoManager();
-	pUndoMgr->EnterListAction(String(SdResId(STR_UNDO_SET_PRESLAYOUT)), String());
+
+	const bool bUndo = IsUndoEnabled();
+
+	if( bUndo )
+	{
+		pUndoMgr->EnterListAction(String(SdResId(STR_UNDO_SET_PRESLAYOUT)), String());
+	}
 
 	SdPage* pSelectedPage   = GetSdPage(nSdPageNum, PK_STANDARD);
 	SdPage* pNotes			= (SdPage*) GetPage(pSelectedPage->GetPageNum()+1);
 			if (!bLayoutReloaded)
 				nInsertPos = 0xFFFF;
 			InsertMasterPage(pMaster, nInsertPos);
-			AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pMaster));
+			if( bUndo )
+				AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pMaster));
 
 			nInsertPos++;
 			if (!bLayoutReloaded)
 				nInsertPos = 0xFFFF;
 			InsertMasterPage(pNotesMaster, nInsertPos);
-			AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pNotesMaster));
+			if( bUndo )
+			{
+				AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pNotesMaster));
 
-			EndUndo(); // schon hier, damit sich Joes Actions ZWISCHEN unsere eigenen schieben
+				EndUndo(); // schon hier, damit sich Joes Actions ZWISCHEN unsere eigenen schieben
+			}
 		}
 
 		// Liste mit Seiten fuellen
 		{
 			AutoLayout eAutoLayout = pPage->GetAutoLayout();
 
-			SdPresentationLayoutUndoAction * pPLUndoAction =
-				new SdPresentationLayoutUndoAction
-					(this,
-					pPage->IsMasterPage() ? aLayoutName : aOldLayoutName,
-					aLayoutName,
-					 eAutoLayout, eAutoLayout, FALSE, pPage);
-			pUndoMgr->AddUndoAction(pPLUndoAction);
+			if( bUndo )
+			{
+				SdPresentationLayoutUndoAction * pPLUndoAction =
+					new SdPresentationLayoutUndoAction
+						(this,
+						pPage->IsMasterPage() ? aLayoutName : aOldLayoutName,
+						aLayoutName,
+						 eAutoLayout, eAutoLayout, FALSE, pPage);
+				pUndoMgr->AddUndoAction(pPLUndoAction);
+			}
 			pPage->SetPresentationLayout(aLayoutName);
 			pPage->SetAutoLayout(eAutoLayout);
 
 		static_cast<SdStyleSheetPool*>( mxStyleSheetPool.get())->CreateLayoutStyleSheets(aName);
 		SdStyleSheetVector aCreatedStyles;
 		static_cast<SdStyleSheetPool*>( mxStyleSheetPool.get())->CreateLayoutSheetList(aName, aCreatedStyles);
-		SdMoveStyleSheetsUndoAction* pMovStyles = new SdMoveStyleSheetsUndoAction(this, aCreatedStyles, TRUE);
-		pUndoMgr->AddUndoAction(pMovStyles);
+
+		if( bUndo )
+		{
+			SdMoveStyleSheetsUndoAction* pMovStyles = new SdMoveStyleSheetsUndoAction(this, aCreatedStyles, TRUE);
+			pUndoMgr->AddUndoAction(pMovStyles);
+		}
 
 		/*********************************************************************
 		|* Neue MasterPages erzeugen und ins Dokument eintragen
 		\********************************************************************/
-		BegUndo();
+
+		if( bUndo )
+			BegUndo();
+
 		pMaster = (SdPage*) AllocPage(TRUE);
 		pMaster->SetSize(pSelectedPage->GetSize());
 		pMaster->SetBorder(pSelectedPage->GetLftBorder(),
 		pMaster->SetName(aName);
 		pMaster->SetLayoutName(aPageLayoutName);
 		InsertMasterPage(pMaster);
-		AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pMaster));
+
+		if( bUndo )
+			AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pMaster));
+
 		pMaster->SetAutoLayout(AUTOLAYOUT_NONE, true, true);
 
 		pNotesMaster = (SdPage*) AllocPage(TRUE);
 		pNotesMaster->SetName(aName);
 		pNotesMaster->SetLayoutName(aPageLayoutName);
 		InsertMasterPage(pNotesMaster);
-		AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pNotesMaster));
+
+		if( bUndo )
+			AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pNotesMaster));
+
 		pNotesMaster->SetAutoLayout(AUTOLAYOUT_NOTES, true, true);
-		EndUndo();
+
+		if( bUndo )
+			EndUndo();
 
 		/*********************************************************************
 		|* Liste der betroffenen Standard- und Notizseiten erstellen
 			AutoLayout eNewAutoLayout =
 				pPage->GetPageKind() == PK_STANDARD ? AUTOLAYOUT_NONE : AUTOLAYOUT_NOTES;
 
-			SdPresentationLayoutUndoAction * pPLUndoAction =
-				new SdPresentationLayoutUndoAction
-						(this, aOldLayoutName, aName,
-						 eOldAutoLayout, eNewAutoLayout, TRUE,
-						 pPage);
-			pUndoMgr->AddUndoAction(pPLUndoAction);
+			if( bUndo )
+			{
+				SdPresentationLayoutUndoAction * pPLUndoAction =
+					new SdPresentationLayoutUndoAction
+							(this, aOldLayoutName, aName,
+							 eOldAutoLayout, eNewAutoLayout, TRUE,
+							 pPage);
+				pUndoMgr->AddUndoAction(pPLUndoAction);
+			}
 
 			pPage->SetPresentationLayout(aName);
 			pPage->SetAutoLayout(eNewAutoLayout);
 		RemoveUnnecessaryMasterPages(&rOldMaster);
 	}
 
-	pUndoMgr->LeaveListAction();
+	if( bUndo )
+		pUndoMgr->LeaveListAction();
 
 	if( mpDocSh )
 		mpDocSh->SetWaitCursor( FALSE );

File sd/source/filter/xml/sdxmlwrp.cxx

View file
  • Ignore whitespace
 	// -------------------------------------
 
 	SdDrawDocument* pDoc = mrDocShell.GetDoc();
+	pDoc->EnableUndo(false);
 	pDoc->NewOrLoadCompleted( NEW_DOC );
 	pDoc->CreateFirstPages();
 	pDoc->StopWorkStartupDelay();
 		}
 	}
 
+	pDoc->EnableUndo(true);
 	mrDocShell.ClearUndoBuffer();
 	return nRet == 0;
 }

File sd/source/ui/dlg/masterlayoutdlg.cxx

View file
  • Ignore whitespace
 
 	if( pObject )
 	{
-		mpDoc->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pObject));
+		const bool bUndo = mpDoc->IsUndoEnabled();
+		if( bUndo )
+			mpDoc->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pObject));
 		SdrObjList* pOL =pObject->GetObjList();
 		UINT32 nOrdNum=pObject->GetOrdNumDirect();
 		pOL->RemoveObject(nOrdNum);
+
+		if( !bUndo )
+			SdrObject::Free(pObject);
 	}
 }

File sd/source/ui/func/fuexpand.cxx

View file
  • Ignore whitespace
 
 		if (pActualOutline)
 		{
-			mpView->BegUndo(String(SdResId(STR_UNDO_EXPAND_PAGE)));
+			const bool bUndo = mpView->IsUndoEnabled();
+
+			if( bUndo )
+				mpView->BegUndo(String(SdResId(STR_UNDO_EXPAND_PAGE)));
 
 			// Aktuelles Gliederungsobjekt in Outliner setzen
 			OutlinerParaObject* pParaObj = pActualOutline->GetOutlinerParaObject();
 					// Seite hinter aktueller Seite einfuegen
 					mpDoc->InsertPage(pPage, nActualPageNum + nPos);
 					nPos++;
-					mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pPage));
+
+					if( bUndo )
+						mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pPage));
 
 					// MasterPage der aktuellen Seite verwenden
 					pPage->TRG_SetMasterPage(pActualPage->TRG_GetMasterPage());
 					// Seite hinter aktueller Seite einfuegen
 					mpDoc->InsertPage(pNotesPage, nActualPageNum + nPos);
 					nPos++;
-					mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
+
+					if( bUndo )
+						mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
 
 					// MasterPage der aktuellen Seite verwenden
 					pNotesPage->TRG_SetMasterPage(pActualNotesPage->TRG_GetMasterPage());
 				pPara = pOutl->GetParagraph( ++nParaPos );
 			}
 
-			mpView->EndUndo();
+			if( bUndo )
+				mpView->EndUndo();
 		}
 
 		delete pOutl;

File sd/source/ui/func/fuinsfil.cxx

View file
  • Ignore whitespace
 				SdrRectObj* pTO = new SdrRectObj(OBJ_TEXT);
 				pTO->SetOutlinerParaObject(pOPO);
 
-				mpView->BegUndo(String(SdResId(STR_UNDO_INSERT_TEXTFRAME)));
+				const bool bUndo = mpView->IsUndoEnabled();
+				if( bUndo )
+					mpView->BegUndo(String(SdResId(STR_UNDO_INSERT_TEXTFRAME)));
 				pPage->InsertObject(pTO);
 
 				// koennte groesser sein als die max. erlaubte Groesse:
 					pTO->SetTextLink(aFile, aFilterName, gsl_getSystemTextEncoding() );
 				}
 
-				mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoInsertObject(*pTO));
-				mpView->EndUndo();
+				if( bUndo )
+				{
+					mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoInsertObject(*pTO));
+					mpView->EndUndo();
+				}
 			}
 		}
 		delete pOutliner;

File sd/source/ui/func/fusel.cxx

View file
  • Ignore whitespace
                     {
                         SfxStyleSheet* pStyleSheet = static_cast<SfxStyleSheet*>(
                             pPool->GetActualStyleSheet());
-                        if (pStyleSheet != NULL)
+                        if (pStyleSheet != NULL && mpView->IsUndoEnabled() )
                         {
 							// #108981#
 							// Added UNDOs for the WaterCan mode. This was never done in

File sd/source/ui/func/fusumry.cxx

View file
  • Ignore whitespace
 		i++;
 	}
 
+	bool bBegUndo = false;
+
 	SfxStyleSheet* pStyle = NULL;
 
 	for (i = nFirstPage; i < nCount; i++)
 					/**********************************************************
 					* Inhaltsverzeichnis-Seite einfuegen und Outliner anlegen
 					**********************************************************/
-					mpView->BegUndo(String(SdResId(STR_UNDO_SUMMARY_PAGE)));
+					const bool bUndo = mpView->IsUndoEnabled();
+
+					if( bUndo )
+					{
+						mpView->BegUndo(String(SdResId(STR_UNDO_SUMMARY_PAGE)));
+						bBegUndo = true;
+					}
+
 					SetOfByte aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
 
 					// Seite mit Titel & Gliederung!
 
 					// Seite hinten einfuegen
 					mpDoc->InsertPage(pSummaryPage, nCount * 2 + 1);
-					mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pSummaryPage));
+					if( bUndo )
+						mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pSummaryPage));
 
 					// MasterPage der aktuellen Seite verwenden
 					pSummaryPage->TRG_SetMasterPage(pActualPage->TRG_GetMasterPage());
 
 					// Seite hinten einfuegen
 					mpDoc->InsertPage(pNotesPage, nCount * 2 + 2);
-					mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
+
+					if( bUndo )
+						mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
 
 					// MasterPage der aktuellen Seite verwenden
 					pNotesPage->TRG_SetMasterPage(pActualNotesPage->TRG_GetMasterPage());
 		aAttr.Put(XFillStyleItem(XFILL_NONE));
 		pTextObj->SetMergedItemSet(aAttr);
 
-		mpView->EndUndo();
+		if( bBegUndo )
+			mpView->EndUndo();
 		delete pOutl;
 
 		DrawViewShell* pDrawViewShell= dynamic_cast< DrawViewShell* >( mpViewShell );

File sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx

View file
  • Ignore whitespace
 
 
 using namespace ::com::sun::star;
+using namespace ::com::sun::star::drawing;
 using namespace ::com::sun::star::uno;
 using namespace ::sd::slidesorter::model;
 using namespace ::sd::slidesorter::view;
 void SelectionManager::DeleteSelectedNormalPages (const ::std::vector<SdPage*>& rSelectedPages)
 {
     // Prepare the deletion via the UNO API.
-    Reference<drawing::XDrawPages> xPages;
-    OSL_ASSERT(mrSlideSorter.GetModel().GetEditMode() == EM_PAGE);
+	OSL_ASSERT(mrSlideSorter.GetModel().GetEditMode() == EM_PAGE);
 
-    Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier (
-        mrSlideSorter.GetModel().GetDocument()->getUnoModel(), UNO_QUERY);
-    if (xDrawPagesSupplier.is())
-        xPages = xDrawPagesSupplier->getDrawPages();
+	try
+	{
+	    Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier( mrSlideSorter.GetModel().GetDocument()->getUnoModel(), UNO_QUERY_THROW );
+	    Reference<drawing::XDrawPages> xPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
 
-    SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument();
-    OSL_ASSERT(pDocument!=NULL);
+		// Iterate over all pages that where seleted when this method was called
+		// and delete the draw page the notes page.  The iteration is done in
+		// reverse order so that when one slide is not deleted (to avoid an
+		// empty document) the remaining slide is the first one.
+		::std::vector<SdPage*>::const_reverse_iterator aI;
+		for (aI=rSelectedPages.rbegin(); aI!=rSelectedPages.rend(); aI++)
+		{
+			// Do not delete the last slide in the document.
+			if (xPages->getCount() <= 1)
+				break;
 
-    // Iterate over all pages that where seleted when this method was called
-    // and delete the draw page the notes page.  The iteration is done in
-    // reverse order so that when one slide is not deleted (to avoid an
-    // empty document) the remaining slide is the first one.
-    ::std::vector<SdPage*>::const_reverse_iterator aI;
-    for (aI=rSelectedPages.rbegin(); aI!=rSelectedPages.rend(); aI++)
-    {
-        // Do not delete the last slide in the document.
-        if (pDocument->GetSdPageCount(PK_STANDARD) <= 1)
-            break;
+			USHORT nPage = ((*aI)->GetPageNum()-1) / 2;
 
-        USHORT nPage = ((*aI)->GetPageNum()-1) / 2;
-
-        // Get pointers to the page and its notes page.
-        SdPage* pPage = pDocument->GetSdPage (nPage, PK_STANDARD);
-        SdPage* pNotesPage = pDocument->GetSdPage (nPage, PK_NOTES);
-
-        DBG_ASSERT(pPage!=NULL, "page does not exist");
-        DBG_ASSERT(pNotesPage!=NULL, "notes does not exist");
-
-        // Remove regular slides with the API.
-        if (xPages.is())
-        {
-            SlideSorterView& rView (mrSlideSorter.GetView());
-            
-            // Add undo actions and delete the pages.  The order of adding
-            // the undo actions is important.
-            rView.AddUndo(rView.GetModel()->GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
-            rView.AddUndo(rView.GetModel()->GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
-
-            // The XDrawPagesSupplier deletes both the slide and notes page.
-            xPages->remove (Reference<drawing::XDrawPage>(
-                pPage->getUnoPage(), UNO_QUERY));
-        }
+			Reference< XDrawPage > xPage( xPages->getByIndex( nPage ), UNO_QUERY_THROW );
+			xPages->remove(xPage);
+		}
+	}
+	catch( Exception& )
+	{
+		DBG_ERROR("SelectionManager::DeleteSelectedNormalPages(), exception caught!");
 	}
 }
 
     // Prepare the deletion via the UNO API.
     OSL_ASSERT(mrSlideSorter.GetModel().GetEditMode() == EM_MASTERPAGE);
 
-    SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument();
-    OSL_ASSERT(pDocument!=NULL);
+	try
+	{
+	    Reference<drawing::XMasterPagesSupplier> xDrawPagesSupplier( mrSlideSorter.GetModel().GetDocument()->getUnoModel(), UNO_QUERY_THROW );
+	    Reference<drawing::XDrawPages> xPages( xDrawPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
 
-    // Iterate over all pages that where seleted when this method was called
-    // and delete the draw page the notes page.  The iteration is done in
-    // reverse order so that when one slide is not deleted (to avoid an
-    // empty document) the remaining slide is the first one.
-    ::std::vector<SdPage*>::const_reverse_iterator aI;
-    for (aI=rSelectedPages.rbegin(); aI!=rSelectedPages.rend(); aI++)
-    {
-        // Do not delete the last slide in the document.
-        if (pDocument->GetMasterSdPageCount(PK_STANDARD) <= 1)
-            break;
+		// Iterate over all pages that where seleted when this method was called
+		// and delete the draw page the notes page.  The iteration is done in
+		// reverse order so that when one slide is not deleted (to avoid an
+		// empty document) the remaining slide is the first one.
+		::std::vector<SdPage*>::const_reverse_iterator aI;
+		for (aI=rSelectedPages.rbegin(); aI!=rSelectedPages.rend(); aI++)
+		{
+			// Do not delete the last slide in the document.
+			if (xPages->getCount() <= 1)
+				break;
 
-        USHORT nPage = ((*aI)->GetPageNum()-1) / 2;
+			USHORT nPage = ((*aI)->GetPageNum()-1) / 2;
 
-        // Get pointers to the page and its notes page.
-        SdPage* pPage = pDocument->GetMasterSdPage (nPage, PK_STANDARD);
-        SdPage* pNotesPage = pDocument->GetMasterSdPage (nPage, PK_NOTES);
-
-        DBG_ASSERT(pPage!=NULL, "page does not exist");
-        DBG_ASSERT(pNotesPage!=NULL, "notes does not exist");
-
-        // Remove master slides with the core since the API does not only
-        // remove but also delete the page.
-        if (pDocument->GetMasterPageUserCount(pPage) == 0)
-        {
-            SlideSorterView& rView (mrSlideSorter.GetView());
-
-            // Add undo actions and delete the pages.  The order of adding
-            // the undo actions is important.
-            rView.AddUndo(rView.GetModel()->GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
-            rView.AddUndo(rView.GetModel()->GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
-
-            pDocument->RemoveMasterPage (pPage->GetPageNum());
-            pDocument->RemoveMasterPage (pNotesPage->GetPageNum());
-        }
+			Reference< XDrawPage > xPage( xPages->getByIndex( nPage ), UNO_QUERY_THROW );
+			xPages->remove(xPage);
+		}
+	}
+	catch( Exception& )
+	{
+		DBG_ERROR("SelectionManager::DeleteSelectedMasterPages(), exception caught!");
 	}
 }
 

File sd/source/ui/toolpanel/controls/DocumentHelper.cxx

View file
  • Ignore whitespace
         if (pMasterPage->GetModel() != &rTargetDocument)
         {
             pMasterPageInDocument = AddMasterPage (rTargetDocument, pMasterPage, nInsertionIndex);
-            rTargetDocument.AddUndo(
-                rTargetDocument.GetSdrUndoFactory().CreateUndoNewPage(*pMasterPageInDocument));
+			if( rTargetDocument.IsUndoEnabled() )
+				rTargetDocument.AddUndo(
+					rTargetDocument.GetSdrUndoFactory().CreateUndoNewPage(*pMasterPageInDocument));
         }
         else
             pMasterPageInDocument = pMasterPage;
         {
             SdPage* pClonedNotesMasterPage 
                 = AddMasterPage (rTargetDocument, pNotesMasterPage, nInsertionIndex+1);
-            rTargetDocument.AddUndo(
-                rTargetDocument.GetSdrUndoFactory().CreateUndoNewPage(*pClonedNotesMasterPage));
+			if( rTargetDocument.IsUndoEnabled() )
+	            rTargetDocument.AddUndo(
+		            rTargetDocument.GetSdrUndoFactory().CreateUndoNewPage(*pClonedNotesMasterPage));
         }
     }
     return pMasterPageInDocument;

File sd/source/ui/unoidl/unomodel.cxx

View file
  • Ignore whitespace
 #include <sdresid.hxx>
 #include <sdpage.hxx>
 
+#include <strings.hrc>
 #include "unohelp.hxx"
 #include <unolayer.hxx>
 #include <unoprnms.hxx>
 {
 	OGuard aGuard( Application::GetSolarMutex() );
 
-	if( NULL == mpModel )
+	if( NULL == mpModel || mpModel->mpDoc == NULL )
 		throw lang::DisposedException();
 
-	sal_uInt16 nPageCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
+	SdDrawDocument& rDoc = *mpModel->mpDoc;
+
+	sal_uInt16 nPageCount = rDoc.GetSdPageCount( PK_STANDARD );
 	if( nPageCount > 1 )
 	{
 		// pPage von xPage besorgen und dann die Id (nPos )ermitteln
 		if( pSvxPage )
 		{
 			SdPage* pPage = (SdPage*) pSvxPage->GetSdrPage();
-			if(pPage)
+			if(pPage && ( pPage->GetPageKind() == PK_STANDARD ) )
 			{
-				// Es duerfen nur Standardpages DIREKT geloescht werden
-				if( pPage->GetPageKind() == PK_STANDARD )
+				sal_uInt16 nPage = pPage->GetPageNum();
+
+				SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetPage( nPage+1 ) );
+
+				bool bUndo = rDoc.IsUndoEnabled();
+				if( bUndo )
 				{
-					sal_uInt16 nPage = pPage->GetPageNum();
-					mpModel->mpDoc->RemovePage( nPage );
-
-					// Die darauffolgende Seite ist die dazugeoerige Notizseite
-					mpModel->mpDoc->RemovePage( nPage );
+					// Add undo actions and delete the pages.  The order of adding
+					// the undo actions is important.
+					rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGES ) );
+					rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
+					rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
+				}
+
+				rDoc.RemovePage( nPage ); // the page
+				rDoc.RemovePage( nPage ); // the notes page
+
+				if( bUndo )
+				{
+					rDoc.EndUndo();
+				}
+				else
+				{
+					delete pNotesPage;
+					delete pPage;
 				}
 			}
 		}
 {
 	OGuard aGuard( Application::GetSolarMutex() );
 
-	if( NULL == mpModel )
+	if( NULL == mpModel || mpModel->mpDoc == NULL )
 		throw lang::DisposedException();
 
+	SdDrawDocument& rDoc = *mpModel->mpDoc;
+
 	SdMasterPage* pSdPage = SdMasterPage::getImplementation( xPage );
 	if(pSdPage == NULL)
 		return;
 	if( pPage->GetPageKind() == PK_STANDARD )
 	{
 		sal_uInt16 nPage = pPage->GetPageNum();
-		mpModel->mpDoc->RemoveMasterPage( nPage );
-
-		// next page is the notes master
-		mpModel->mpDoc->RemoveMasterPage( nPage );
+
+		SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetMasterPage( nPage+1 ) );
+
+		bool bUndo = rDoc.IsUndoEnabled();
+		if( bUndo )
+		{
+			// Add undo actions and delete the pages.  The order of adding
+			// the undo actions is important.
+			rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGES ) );
+			rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
+			rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
+		}
+
+		rDoc.RemoveMasterPage( nPage );
+		rDoc.RemoveMasterPage( nPage );
+
+		if( bUndo )
+		{
+			rDoc.EndUndo();
+		}
+		else
+		{
+			delete pNotesPage;
+			delete pPage;
+		}
 	}
 }
 

File sd/source/ui/view/drbezob.cxx

View file
  • Ignore whitespace
 					case SID_BEZIER_CLOSE:
 					{
 						SdrPathObj* pPathObj = (SdrPathObj*) rMarkList.GetMark(0)->GetMarkedSdrObj();
-						mpView->BegUndo(String(SdResId(STR_UNDO_BEZCLOSE)));
+						const bool bUndo = mpView->IsUndoEnabled();
+						if( bUndo )
+							mpView->BegUndo(String(SdResId(STR_UNDO_BEZCLOSE)));
+
 						mpView->UnmarkAllPoints();
-						mpView->AddUndo(mpView->GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPathObj));
+
+						if( bUndo )
+							mpView->AddUndo(mpView->GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPathObj));
+
 						pPathObj->ToggleClosed();
-						mpView->EndUndo();
+
+						if( bUndo )
+							mpView->EndUndo();
 						break;
 					}
 				}

File sd/source/ui/view/drviews2.cxx

View file
  • Ignore whitespace
 					const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
 					ULONG nCount = rMarkList.GetMarkCount();
 
+					const bool bUndo = mpDrawView->IsUndoEnabled();
+
 					for (ULONG i=0; i<nCount; i++)
 					{
 						SfxItemSet aAttr(GetDoc()->GetPool());
 
 							if (rFillStyle.GetValue() == XFILL_NONE)
 							{
-								// Vorlage hat keine Fuellung,
-								// daher hart attributieren: Fuellung setzen
-								if (!bMergeUndo)
+								if( bUndo )
 								{
-									bMergeUndo = TRUE;
-									pUndoManager->EnterListAction( String(), String() );
-									mpDrawView->BegUndo();
+									// Vorlage hat keine Fuellung,
+									// daher hart attributieren: Fuellung setzen
+									if (!bMergeUndo)
+									{
+										bMergeUndo = TRUE;
+										pUndoManager->EnterListAction( String(), String() );
+										mpDrawView->BegUndo();
+									}
+
+									mpDrawView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj));
 								}
-								mpDrawView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj));
 
 								aAttr.Put(XFillStyleItem(XFILL_SOLID));
 								aAttr.Put(XFillColorItem(String(), COL_WHITE));

File sd/source/ui/view/drviews4.cxx

View file
  • Ignore whitespace
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sd.hxx"
 
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+
 #include "DrawViewShell.hxx"
 #include <vcl/msgbox.hxx>
 #include <svtools/urlbmk.hxx>
 #pragma optimize ( "", off )
 #endif
 
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing;
 
 /*************************************************************************
 |*
 void DrawViewShell::DeleteActualPage()
 {
 	USHORT			nPage = maTabControl.GetCurPageId() - 1;
-	SdPage* 		pPage = GetDoc()->GetSdPage(nPage,PK_STANDARD);
-
-#ifdef DBG_UTIL
-	USHORT nPageCount = GetDoc()->GetPageCount();
-	DBG_ASSERT(nPageCount > 1, "aber das ist die letzte!");
-#endif
 
 	mpDrawView->SdrEndTextEdit();
 
-	mpDrawView->BegUndo();
-
-	mpDrawView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
-	GetDoc()->RemovePage(pPage->GetPageNum());
-
-	pPage = GetDoc()->GetSdPage(nPage, PK_NOTES);
-	mpDrawView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
-	GetDoc()->RemovePage(pPage->GetPageNum());
-
-	mpDrawView->EndUndo();
+	try
+	{
+	    Reference<XDrawPagesSupplier> xDrawPagesSupplier( GetDoc()->getUnoModel(), UNO_QUERY_THROW );
+	    Reference<XDrawPages> xPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
+		Reference< XDrawPage > xPage( xPages->getByIndex( nPage ), UNO_QUERY_THROW );
+		xPages->remove( xPage );
+	}
+	catch( Exception& )
+	{
+		DBG_ERROR("SelectionManager::DeleteSelectedMasterPages(), exception caught!");
+	}
 }
 
 /*************************************************************************

File sd/source/ui/view/drviewse.cxx

View file
  • Ignore whitespace
 			if ( rMarkList.GetMark(0) && !mpDrawView->IsAction() )
 			{
 				SdrPathObj* pPathObj = (SdrPathObj*) rMarkList.GetMark(0)->GetMarkedSdrObj();
-                mpDrawView->BegUndo(String(SdResId(STR_UNDO_BEZCLOSE)));
+				const bool bUndo = mpDrawView->IsUndoEnabled();
+				if( bUndo )
+					mpDrawView->BegUndo(String(SdResId(STR_UNDO_BEZCLOSE)));
+
 				mpDrawView->UnmarkAllPoints();
-				mpDrawView->AddUndo(new SdrUndoGeoObj(*pPathObj));
+
+				if( bUndo )
+					mpDrawView->AddUndo(new SdrUndoGeoObj(*pPathObj));
+
 				pPathObj->ToggleClosed();
-				mpDrawView->EndUndo();
+
+				if( bUndo )
+					mpDrawView->EndUndo();
 			}
 			rReq.Done();
 		}

File sd/source/ui/view/sdview.cxx

View file
  • Ignore whitespace
 
 bool View::isRecordingUndo() const
 {
-	sd::UndoManager* pUndoManager = mpDoc ? mpDoc->GetUndoManager() : 0;
-	return pUndoManager && pUndoManager->isInListAction();
+	if( mpDoc && mpDoc->IsUndoEnabled() )
+	{
+		sd::UndoManager* pUndoManager = mpDoc ? mpDoc->GetUndoManager() : 0;
+		return pUndoManager && pUndoManager->isInListAction();
+	}
+	else
+	{
+		return false;
+	}
 }
 
 void View::AddCustomHdl()

File sd/source/ui/view/sdview2.cxx

View file
  • Ignore whitespace
 		mpDragSrcMarkList = new SdrMarkList(GetMarkedObjectList());
 		mnDragSrcPgNum = GetSdrPageView()->GetPage()->GetPageNum();
 
-		String aStr( SdResId(STR_UNDO_DRAGDROP) );
-		aStr += sal_Unicode(' ');
-		aStr += mpDragSrcMarkList->GetMarkDescription();
-		BegUndo(aStr);
+		if( IsUndoEnabled() )
+		{
+			String aStr( SdResId(STR_UNDO_DRAGDROP) );
+			aStr += sal_Unicode(' ');
+			aStr += mpDragSrcMarkList->GetMarkDescription();
+			BegUndo(aStr);
+		}
 		CreateDragDataObject( this, *pWindow, rStartPos );
 	}
 }
 
 void View::DragFinished( sal_Int8 nDropAction )
 {
+	const bool bUndo = IsUndoEnabled();
+
 	SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag;
 
 	if( pDragTransferable )
 		!IsPresObjSelected() )
 	{
 		mpDragSrcMarkList->ForceSort();
-		BegUndo();
+
+		if( bUndo )
+			BegUndo();
 
 		ULONG nm, nAnz = mpDragSrcMarkList->GetMarkCount();
 
 		{
 			nm--;
 			SdrMark* pM=mpDragSrcMarkList->GetMark(nm);
-			AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pM->GetMarkedSdrObj()));
+			if( bUndo )
+				AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pM->GetMarkedSdrObj()));
 		}
 
 		mpDragSrcMarkList->GetMark(0)->GetMarkedSdrObj()->GetOrdNum();
             }
 		}
 
-		EndUndo();
+		if( bUndo )
+			EndUndo();
 	}
 
 	if( pDragTransferable )
 		pDragTransferable->SetInternalMove( FALSE );
 
-	EndUndo();
+	if( bUndo )
+		EndUndo();
 	mnDragSrcPgNum = SDRPAGE_NOTFOUND;
 	delete mpDragSrcMarkList;
 	mpDragSrcMarkList = NULL;

File sd/source/ui/view/sdview3.cxx

View file
  • Ignore whitespace
 							if( pO )
 							{
 								// #i11702#
-								BegUndo(String(SdResId(STR_MODIFYLAYER)));
-								AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectLayerChange(*pO, pO->GetLayer(), (SdrLayerID)nLayer));
-								EndUndo();
+								if( IsUndoEnabled() )
+								{
+									BegUndo(String(SdResId(STR_MODIFYLAYER)));
+									AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectLayerChange(*pO, pO->GetLayer(), (SdrLayerID)nLayer));
+									EndUndo();
+								}
 
 								pO->SetLayer( (SdrLayerID) nLayer );
 							}
 
 										pPage->InsertObject(pObj);
 
-										BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
-										AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
-										EndUndo();
+										if( IsUndoEnabled() )
+										{
+											BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
+											AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
+											EndUndo();
+										}
 
 										// #83525#
 										ImpRememberOrigAndClone* pRem = new ImpRememberOrigAndClone;
 							aVec -= aObjRect.TopLeft();
 							pNewObj->NbcMove( Size( aVec.X(), aVec.Y() ) );
 
-							BegUndo( String( SdResId(STR_UNDO_DRAGDROP ) ) );
+							const bool bUndo = IsUndoEnabled();
+
+							if( bUndo )
+								BegUndo( String( SdResId(STR_UNDO_DRAGDROP ) ) );
 							pNewObj->NbcSetLayer( pPickObj->GetLayer() );
 							SdrPage* pWorkPage = GetSdrPageView()->GetPage();
 							pWorkPage->InsertObject( pNewObj );
-							AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoNewObject( *pNewObj ) );
-							AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject( *pPickObj2 ) );
+							if( bUndo )
+							{
+								AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoNewObject( *pNewObj ) );
+								AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject( *pPickObj2 ) );
+							}
 							pWorkPage->RemoveObject( pPickObj2->GetOrdNum() );
-							EndUndo();
+
+							if( bUndo )
+							{
+								EndUndo();
+							}
+							else
+							{
+								SdrObject::Free(pPickObj2 );
+							}
 							bChanged = TRUE;
 							mnAction = DND_ACTION_COPY;
 						}
 							SfxItemSet aSet( mpDoc->GetPool() );
 
 							// set new attributes to object
-							BegUndo( String( SdResId( STR_UNDO_DRAGDROP ) ) );
-							AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj ) );
+							const bool bUndo = IsUndoEnabled();
+							if( bUndo )
+							{
+								BegUndo( String( SdResId( STR_UNDO_DRAGDROP ) ) );
+								AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj ) );
+							}
 							aSet.Put( pObj->GetMergedItemSet() );
 
 							// Eckenradius soll nicht uebernommen werden.
 								aOldSet.Put(pPickObj->GetMergedItemSet());
 								aNewSet.Put( pObj->GetMergedItemSet() );
 
-								AddUndo( new E3dAttributesUndoAction( *mpDoc, this, (E3dObject*) pPickObj, aNewSet, aOldSet, FALSE ) );
+								if( bUndo )
+									AddUndo( new E3dAttributesUndoAction( *mpDoc, this, (E3dObject*) pPickObj, aNewSet, aOldSet, FALSE ) );
 								pPickObj->SetMergedItemSetAndBroadcast( aNewSet );
 							}
 
-							EndUndo();
+							if( bUndo )
+								EndUndo();
 							bChanged = TRUE;
 						}
 					}
 
 			*xStm >> aFillData;
 
-			BegUndo( String( SdResId( STR_UNDO_DRAGDROP ) ) );
-			AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj ) );
-			EndUndo();
+			if( IsUndoEnabled() )
+			{
+				BegUndo( String( SdResId( STR_UNDO_DRAGDROP ) ) );
+				AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj ) );
+				EndUndo();
+			}
 
 			XFillAttrSetItem*	pSetItem = aFillData.GetXFillAttrSetItem();
 			SfxItemSet			rSet = pSetItem->GetItemSet();

File sd/source/ui/view/sdview4.cxx

View file
  • Ignore whitespace
 				pNewGrafObj->SetEmptyPresObj(FALSE);
 			}
 
-			BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
+			const bool bUndo = IsUndoEnabled();
+			if( bUndo )
+				BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
 
 			SdPage* pPage = (SdPage*) pPickObj->GetPage();
 
 			{
 				// Neues PresObj in die Liste eintragen
 				pNewGrafObj->SetUserCall(pPickObj->GetUserCall());
-				AddUndo( new sd::UndoObjectPresentationKind( *pPickObj ) );
-				AddUndo( new sd::UndoObjectPresentationKind( *pNewGrafObj ) );
+				if( bUndo )
+				{
+					AddUndo( new sd::UndoObjectPresentationKind( *pPickObj ) );
+					AddUndo( new sd::UndoObjectPresentationKind( *pNewGrafObj ) );
+				}
 				pPage->RemovePresObj(pPickObj);
 				pPage->InsertPresObj(pNewGrafObj, PRESOBJ_GRAPHIC);
+
+				if( !bUndo )
+				{
+					SdrObject::Free( pPickObj );
+				}
 			}
 
 			if (pImageMap)
 				pNewGrafObj->InsertUserData(new SdIMapInfo(*pImageMap));
 
 			ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj); // maybe ReplaceObjectAtView
-			EndUndo();
+
+			if( bUndo )
+				EndUndo();
 		}
 		else if (pPickObj->IsClosedObj() && !pPickObj->ISA(SdrOle2Obj))
 		{
 			/******************************************************************
 			* Das Objekt wird mit der Graphik gefuellt
 			******************************************************************/
-			BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
-			AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pPickObj));
-			EndUndo();
+			if( IsUndoEnabled() )
+			{
+				BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
+				AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pPickObj));
+				EndUndo();
+			}
 
 			XOBitmap aXOBitmap( rGraphic.GetBitmap() );
 			SfxItemSet aSet(mpDocSh->GetPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP);
 			Point aVec = aPickObjRect.TopLeft() - aObjRect.TopLeft();
 			pNewGrafObj->NbcMove(Size(aVec.X(), aVec.Y()));
 
-			BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
+			const bool bUndo = IsUndoEnabled();
+
+			if( bUndo )
+				BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
 			pNewGrafObj->NbcSetLayer(pPickObj->GetLayer());
 			SdrPage* pP = pPV->GetPage();
 			pP->InsertObject(pNewGrafObj);
-			AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewObject(*pNewGrafObj));
-			AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pPickObj));
+			if( bUndo )
+			{
+				AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewObject(*pNewGrafObj));
+				AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pPickObj));
+			}
 			pP->RemoveObject(pPickObj->GetOrdNum());
-			EndUndo();
+
+			if( bUndo )
+			{
+				EndUndo();
+			}
+			else
+			{
+				SdrObject::Free(pPickObj);
+			}
 			mnAction = DND_ACTION_COPY;
 		}
 		else

File sd/source/ui/view/viewshe3.cxx

View file
  • Ignore whitespace
 
     // 2. Create a new page or duplicate an existing one.
     View* pDrView = GetView();
-    pDrView->BegUndo( String( SdResId(STR_INSERTPAGE) ) );
+	const bool bUndo = pDrView && pDrView->IsUndoEnabled();
+	if( bUndo )
+		pDrView->BegUndo( String( SdResId(STR_INSERTPAGE) ) );
 
     USHORT nNewPageIndex = 0xffff;
     switch (nSId)
             DBG_WARNING("wrong slot id given to CreateOrDuplicatePage");
             // Try to handle another slot id gracefully.
     }
-    SdPage* pNewPage = 0;
-    if(nNewPageIndex != 0xffff)
+	SdPage* pNewPage = 0;
+	if(nNewPageIndex != 0xffff)
+		pNewPage = pDocument->GetSdPage(nNewPageIndex, PK_STANDARD);
+
+	if( bUndo )
 	{
-        pNewPage = pDocument->GetSdPage(nNewPageIndex, PK_STANDARD);
-        pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pNewPage));
-        pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pDocument->GetSdPage (nNewPageIndex, PK_NOTES)));
+		if( pNewPage )
+		{
+			pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pNewPage));
+			pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pDocument->GetSdPage (nNewPageIndex, PK_NOTES)));
+		}
+
+		pDrView->EndUndo();
 	}
 
-    pDrView->EndUndo();
-
     return pNewPage;
 }
 

File svtools/inc/svtools/undo.hxx

View file
  • Ignore whitespace
 	SfxUndoArray			*pActUndoArray;
 	SfxUndoArray			*pFatherUndoArray;
 
+	bool					mbUndoEnabled;
 public:
 							SfxUndoManager( USHORT nMaxUndoActionCount = 20 );
 	virtual 				~SfxUndoManager();
 
 	/** clears the redo stack and removes the top undo action */
 	void					RemoveLastUndoAction();
+
+	// enables (true) or disables (false) recording of undo actions
+	// If undo actions are added while undo is disabled, they are deleted.
+	// Disabling undo does not clear the current undo buffer!
+	void					EnableUndo( bool bEnable );
+
+	// returns true if undo is currently enabled
+	// This returns false if undo was disabled using EnableUndo( false ) and
+	// also during the runtime of the Undo() and Redo() methods.
+	bool					IsUndoEnabled() const { return mbUndoEnabled; }
 };
 
 //=========================================================================

File svtools/source/undo/makefile.mk

View file
  • Ignore whitespace
 
 PRJNAME=svtools
 TARGET=undo
+ENABLE_EXCEPTIONS=TRUE
 
 # --- Settings -----------------------------------------------------
 

File svtools/source/undo/undo.cxx

View file
  • Ignore whitespace
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_svtools.hxx"
 
+#include <com/sun/star/uno/Exception.hpp>
 
 #include <tools/debug.hxx>
 
 #include <svtools/undo.hxx>
 
+using ::com::sun::star::uno::Exception;
+
 // STATIC DATA -----------------------------------------------------------
 
 DBG_NAME(SfxUndoAction)
 
 SfxUndoManager::SfxUndoManager( USHORT nMaxUndoActionCount )
  : pFatherUndoArray(0)
+ , mbUndoEnabled( true )
 {
 	pUndoArray=new SfxUndoArray(nMaxUndoActionCount);
 	pActUndoArray=pUndoArray;
 	delete pUndoArray;
 }
 
+//------------------------------------------------------------------------
+
+void SfxUndoManager::EnableUndo( bool bEnable )
+{
+	mbUndoEnabled = bEnable;
+}
 
 //------------------------------------------------------------------------
 
 
 void SfxUndoManager::AddUndoAction( SfxUndoAction *pAction, BOOL bTryMerge )
 {
-	// Redo-Actions loeschen
-	for ( USHORT nPos = pActUndoArray->aUndoActions.Count();
-		  nPos > pActUndoArray->nCurUndoAction; --nPos )
-		delete pActUndoArray->aUndoActions[nPos-1];
+	if( mbUndoEnabled )
+	{
+		// Redo-Actions loeschen
+		for ( USHORT nPos = pActUndoArray->aUndoActions.Count();
+			  nPos > pActUndoArray->nCurUndoAction; --nPos )
+			delete pActUndoArray->aUndoActions[nPos-1];
 
-	pActUndoArray->aUndoActions.Remove(
-		pActUndoArray->nCurUndoAction,
-		pActUndoArray->aUndoActions.Count() - pActUndoArray->nCurUndoAction );
+		pActUndoArray->aUndoActions.Remove(
+			pActUndoArray->nCurUndoAction,
+			pActUndoArray->aUndoActions.Count() - pActUndoArray->nCurUndoAction );
 
-	if ( pActUndoArray->nMaxUndoActions )
-	{
-		SfxUndoAction *pTmpAction = pActUndoArray->nCurUndoAction ?
-			pActUndoArray->aUndoActions[pActUndoArray->nCurUndoAction-1] : 0;
+		if ( pActUndoArray->nMaxUndoActions )
+		{
+			SfxUndoAction *pTmpAction = pActUndoArray->nCurUndoAction ?
+				pActUndoArray->aUndoActions[pActUndoArray->nCurUndoAction-1] : 0;
 
-		if ( !bTryMerge || !(pTmpAction && pTmpAction->Merge(pAction)) )
-		{
-			// auf Max-Anzahl anpassen
-			if( pActUndoArray == pUndoArray )
-				while( pActUndoArray->aUndoActions.Count() >=
-					   pActUndoArray->nMaxUndoActions &&
-					   !pActUndoArray->aUndoActions[0]->IsLinked() )
-				{
-					delete pActUndoArray->aUndoActions[0];
-					pActUndoArray->aUndoActions.Remove(0);
-					--pActUndoArray->nCurUndoAction;
-				}
+			if ( !bTryMerge || !(pTmpAction && pTmpAction->Merge(pAction)) )
+			{
+				// auf Max-Anzahl anpassen
+				if( pActUndoArray == pUndoArray )
+					while( pActUndoArray->aUndoActions.Count() >=
+						   pActUndoArray->nMaxUndoActions &&
+						   !pActUndoArray->aUndoActions[0]->IsLinked() )
+					{
+						delete pActUndoArray->aUndoActions[0];
+						pActUndoArray->aUndoActions.Remove(0);
+						--pActUndoArray->nCurUndoAction;
+					}
 
-			// neue Action anh"angen
-			const SfxUndoAction* pTemp = pAction;
-			pActUndoArray->aUndoActions.Insert(
-				pTemp, pActUndoArray->nCurUndoAction++ );
-			return;
+				// neue Action anh"angen
+				const SfxUndoAction* pTemp = pAction;
+				pActUndoArray->aUndoActions.Insert(
+					pTemp, pActUndoArray->nCurUndoAction++ );
+				return;
+			}
 		}
 	}
-
 	delete pAction;
 }
 
 
 BOOL SfxUndoManager::Undo( USHORT )
 {
-	DBG_ASSERT( pActUndoArray == pUndoArray, "svtools::SfxUndoManager::Undo(), LeaveListAction() not yet called!" );
-	if ( pActUndoArray->nCurUndoAction )
+	bool bUndoWasEnabled = 	mbUndoEnabled;
+	mbUndoEnabled = false;
+	
+	BOOL bRet = FALSE;
+
+	try
 	{
-		Undo( *pActUndoArray->aUndoActions[ --pActUndoArray->nCurUndoAction ] );
-		return TRUE;
+		DBG_ASSERT( pActUndoArray == pUndoArray, "svtools::SfxUndoManager::Undo(), LeaveListAction() not yet called!" );
+		if ( pActUndoArray->nCurUndoAction )
+		{
+			Undo( *pActUndoArray->aUndoActions[ --pActUndoArray->nCurUndoAction ] );
+			bRet = TRUE;
+		}
 	}
-	return FALSE;
+	catch( Exception& e )
+	{
+		mbUndoEnabled = bUndoWasEnabled;
+		throw e;
+	}
+	mbUndoEnabled = bUndoWasEnabled;
+	return bRet;
 }
 
 //------------------------------------------------------------------------
 
 void SfxUndoManager::Undo( SfxUndoAction &rAction )
 {
-	rAction.Undo();
+	bool bUndoWasEnabled = 	mbUndoEnabled;
+	mbUndoEnabled = false;
+	try
+	{
+		rAction.Undo();
+	}
+	catch( Exception& e )
+	{
+		mbUndoEnabled = bUndoWasEnabled;
+		throw e;
+	}
+
+	mbUndoEnabled = bUndoWasEnabled;
 }
 
 //------------------------------------------------------------------------
 
 BOOL SfxUndoManager::Redo( USHORT )
 {
-	if ( pActUndoArray->aUndoActions.Count() > pActUndoArray->nCurUndoAction )
+	bool bUndoWasEnabled = 	mbUndoEnabled;
+	mbUndoEnabled = false;
+	
+	BOOL bRet = FALSE;
+
+	try
 	{
-		Redo( *pActUndoArray->aUndoActions[pActUndoArray->nCurUndoAction++] );
-		return TRUE;
+		if ( pActUndoArray->aUndoActions.Count() > pActUndoArray->nCurUndoAction )
+		{
+			Redo( *pActUndoArray->aUndoActions[pActUndoArray->nCurUndoAction++] );
+			bRet = TRUE;
+		}
+	}
+	catch( Exception& e )
+	{
+		mbUndoEnabled = bUndoWasEnabled;
+		throw e;
 	}
 
-	return FALSE;
+	mbUndoEnabled = bUndoWasEnabled;
+	return bRet;
 }
 
 //------------------------------------------------------------------------
 
 void SfxUndoManager::Redo( SfxUndoAction &rAction )
 {
-	rAction.Redo();
+	bool bUndoWasEnabled = 	mbUndoEnabled;
+	mbUndoEnabled = false;
+
+	try
+	{
+		rAction.Redo();
+	}
+	catch( Exception& e )
+	{
+		mbUndoEnabled = bUndoWasEnabled;
+		throw e;
+	}
+
+	mbUndoEnabled = bUndoWasEnabled;
 }
 
 //------------------------------------------------------------------------
 */
 
 {
+	if( !mbUndoEnabled )
+		return;
+
 	if ( !pUndoArray->nMaxUndoActions )
 		return;
 
 	Verlaesst die aktuelle ListAction und geht eine Ebene nach oben.
 */
 {
+	if ( !mbUndoEnabled )
+		return;
+
 	if ( !pUndoArray->nMaxUndoActions )
 		return;
 
 }
 
 
+

File svx/inc/svx/svdedtv.hxx

View file
  • Ignore whitespace
 	void SetUndoComment(const String& rComment);
 	void SetUndoComment(const String& rComment, const String& rObjDescr);
 #endif
+	bool IsUndoEnabled() const;
 
 	std::vector< SdrUndoAction* > CreateConnectorUndo( SdrObject& rO );
 	void AddUndoActions( std::vector< SdrUndoAction* >& );

File svx/inc/svx/svdmodel.hxx

View file
  • Ignore whitespace
 	Container*      pRedoStack;
 	SdrUndoGroup*   pAktUndoGroup;  // Fuer mehrstufige
 	USHORT          nUndoLevel;     // Undo-Klammerung
+	bool			mbUndoEnabled;	// If false no undo is recorded or we are during the execution of an undo action
 	USHORT          nProgressPercent; // fuer den ProgressBar-Handler
 	USHORT          nLoadVersion;   // Versionsnummer der geladenen Datei
 	FASTBOOL        bExtColorTable; // Keinen eigenen ColorTable
 	bool IsInDestruction() const;
 
     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelImplementationId();
+
+	/** enables (true) or disables (false) recording of undo actions
+		If undo actions are added while undo is disabled, they are deleted.
+		Disabling undo does not clear the current undo buffer! */
+	void EnableUndo( bool bEnable );
+
+	/** returns true if undo is currently enabled
+		This returns false if undo was disabled using EnableUndo( false ) and
+		also during the runtime of the Undo() and Redo() methods. */
+	bool IsUndoEnabled() const;
+
 };
 
 typedef tools::WeakReference< SdrModel > SdrModelWeakRef;

File svx/source/engine3d/dragmt3d.cxx

View file
  • Ignore whitespace
 	// Alle Transformationen anwenden und UnDo's anlegen
 	if(mbMovedAtAll)
 	{
-		getSdrDragView().BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_ROTATE));
+		const bool bUndo = getSdrDragView().IsUndoEnabled();
+		if( bUndo )
+			getSdrDragView().BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_ROTATE));
 		sal_uInt32 nOb(0);
 
 		for(nOb=0;nOb<nCnt;nOb++)
 			E3dDragMethodUnit& rCandidate = maGrp[nOb];
 			E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
 			rCandidate.mp3DObj->SetTransform(rCandidate.maTransform);
-			getSdrDragView().AddUndo(new E3dRotateUndoAction(rCandidate.mp3DObj->GetModel(),
-				rCandidate.mp3DObj, rCandidate.maInitTransform,
-				rCandidate.maTransform));
+			if( bUndo )
+			{
+				getSdrDragView().AddUndo(new E3dRotateUndoAction(rCandidate.mp3DObj->GetModel(),
+					rCandidate.mp3DObj, rCandidate.maInitTransform,
+					rCandidate.maTransform));
+			}
 		}
-		getSdrDragView().EndUndo();
+		if( bUndo )
+			getSdrDragView().EndUndo();
 	}
 
 	return TRUE;

File svx/source/engine3d/view3d.cxx

View file
  • Ignore whitespace
 					bRetval = TRUE;
 
 					// Undo anlegen
-				    AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNewCompoundObj));
+					if( GetModel()->IsUndoEnabled() )
+						AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNewCompoundObj));
 				}
 			}
 		}
 				pObj->SetMergedItem(SvxColorItem(RGB_Color(COL_BLACK), EE_CHAR_COLOR));
 
 				// add undo now
-				AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj, false, false));
+				if( GetModel()->IsUndoEnabled() )
+					AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj, false, false));
 			}
 
 			pObj->SetMergedItem(SvxColorItem(RGB_Color(COL_GRAY), EE_CHAR_COLOR));
 			&& !nLineWidth 
 			&& eFillStyle != XFILL_NONE)
 		{
-			if(pObj->GetPage())
+			if(pObj->GetPage() && GetModel()->IsUndoEnabled() )
 				AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj, false, false));
 			pObj->SetMergedItem(XLineStyleItem(XLINE_NONE));
 			pObj->SetMergedItem(XLineWidthItem(0L));

File svx/source/form/fmpgeimp.cxx

View file
  • Ignore whitespace
 	if ( !xForm.is() )
 	{
 		SdrModel* pModel = pPage->GetModel();
-		XubString aStr(SVX_RES(RID_STR_FORM));
-		XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
-		aUndoStr.SearchAndReplace('#', aStr);
-		pModel->BegUndo(aUndoStr);
+
+		if( pModel->IsUndoEnabled() )
+		{
+			XubString aStr(SVX_RES(RID_STR_FORM));
+			XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
+			aUndoStr.SearchAndReplace('#', aStr);
+			pModel->BegUndo(aUndoStr);
+		}
 
         try
         {
 		    xFormProps->setPropertyValue( FM_PROP_NAME, makeAny( sName ) );
 
             Reference< XIndexContainer > xContainer( xForms, UNO_QUERY );