[ooo-build-commit] Branch 'ooo/master' - sd/source

Jan Holesovsky kendy at kemper.freedesktop.org
Thu Jun 4 17:36:10 PDT 2009


 sd/source/core/drawdoc2.cxx                                 |   26 +-
 sd/source/core/drawdoc3.cxx                                 |  125 +++++++++---
 sd/source/filter/xml/sdxmlwrp.cxx                           |    2 
 sd/source/ui/dlg/masterlayoutdlg.cxx                        |    7 
 sd/source/ui/func/fuexpand.cxx                              |   16 +
 sd/source/ui/func/fuinsfil.cxx                              |   11 -
 sd/source/ui/func/fusel.cxx                                 |    2 
 sd/source/ui/func/fusumry.cxx                               |   21 +-
 sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx |  113 ++++------
 sd/source/ui/toolpanel/controls/DocumentHelper.cxx          |   10 
 sd/source/ui/unoidl/unomodel.cxx                            |   69 +++++-
 sd/source/ui/view/drbezob.cxx                               |   14 +
 sd/source/ui/view/drviews2.cxx                              |   20 +
 sd/source/ui/view/drviews4.cxx                              |   31 +-
 sd/source/ui/view/drviewse.cxx                              |   14 +
 sd/source/ui/view/sdview.cxx                                |   11 -
 sd/source/ui/view/sdview2.cxx                               |   26 +-
 sd/source/ui/view/sdview3.cxx                               |   63 ++++--
 sd/source/ui/view/sdview4.cxx                               |   51 +++-
 sd/source/ui/view/viewshe3.cxx                              |   19 +
 20 files changed, 438 insertions(+), 213 deletions(-)

New commits:
commit ef954bbb29be7ed0f1bb9279c8d80e208207fb4e
Author: Kurt Zenker <kz at openoffice.org>
Date:   Thu Jun 4 16:21:29 2009 +0000

    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 at 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()

diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index f0562f3..6e99f3e 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -812,7 +812,10 @@ BOOL SdDrawDocument::MovePages(USHORT nTargetPage)
     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;
@@ -853,10 +856,12 @@ BOOL SdDrawDocument::MovePages(USHORT nTargetPage)
             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;
             }
@@ -880,10 +885,12 @@ BOOL SdDrawDocument::MovePages(USHORT nTargetPage)
                 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;
                 }
@@ -893,10 +900,12 @@ BOOL SdDrawDocument::MovePages(USHORT nTargetPage)
                 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;
                 }
@@ -906,7 +915,8 @@ BOOL SdDrawDocument::MovePages(USHORT nTargetPage)
         }
     }
 
-    EndUndo();
+    if( bUndo )
+        EndUndo();
 
     return bSomethingHappened;
 }
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index 7a6f50f..2fe1f33 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -577,7 +577,11 @@ BOOL SdDrawDocument::InsertBookmarkAsPage(
     /**************************************************************************
     * Dokument einfuegen
     **************************************************************************/
-    BegUndo(String(SdResId(STR_UNDO_INSERTPAGES)));
+
+    const bool bUndo = IsUndoEnabled();
+
+    if( bUndo )
+        BegUndo(String(SdResId(STR_UNDO_INSERTPAGES)));
 
     if (!pBookmarkList)
     {
@@ -766,8 +770,13 @@ BOOL SdDrawDocument::InsertBookmarkAsPage(
                             pPage->SetName( pStandardPage->GetRealName() );
                         }
 
-                        AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pStandardPage));
+                        if( bUndo )
+                            AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pStandardPage));
+
                         RemovePage(nDestPageNum);
+
+                        if( !bUndo )
+                            delete pStandardPage;
                     }
 
                     SdPage* pNotesPage = 0L;
@@ -787,8 +796,13 @@ BOOL SdDrawDocument::InsertBookmarkAsPage(
                                 pNewNotesPage->SetName( pStandardPage->GetRealName() );
                         }
 
-                        AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
+                        if( bUndo )
+                            AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
+
                         RemovePage(nDestPageNum);
+
+                        if( !bUndo )
+                            delete pNotesPage;
                     }
 
                     nReplacedStandardPages++;
@@ -825,8 +839,13 @@ BOOL SdDrawDocument::InsertBookmarkAsPage(
                  aTest == aMPLayout &&
                  eKind == pTest->GetPageKind() )
             {
-                AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pRefPage));
+                if( bUndo )
+                    AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pRefPage));
+
                 RemoveMasterPage(nPage);
+
+                if( !bUndo )
+                    delete pRefPage;
                 nNewMPageCount--;
                 break;
             }
@@ -876,7 +895,8 @@ BOOL SdDrawDocument::InsertBookmarkAsPage(
 
             // update layout and referred master page
             pRefPage->SetPresentationLayout(aLayout);
-            AddUndo( GetSdrUndoFactory().CreateUndoPageChangeMasterPage( *pRefPage ) );
+            if( bUndo )
+                AddUndo( GetSdrUndoFactory().CreateUndoPageChangeMasterPage( *pRefPage ) );
 
             if (bScaleObjects)
             {
@@ -894,7 +914,8 @@ BOOL SdDrawDocument::InsertBookmarkAsPage(
 
             // update layout and referred master page
             pRefPage->SetPresentationLayout(aLayout);
-            AddUndo( GetSdrUndoFactory().CreateUndoPageChangeMasterPage( *pRefPage ) );
+            if( bUndo )
+                AddUndo( GetSdrUndoFactory().CreateUndoPageChangeMasterPage( *pRefPage ) );
 
             if (bScaleObjects)
             {
@@ -944,7 +965,8 @@ BOOL SdDrawDocument::InsertBookmarkAsPage(
     // #91146# Make absolutely sure no double masterpages are there
     RemoveUnnecessaryMasterPages(NULL, TRUE, TRUE);
 
-    EndUndo();
+    if( bUndo )
+        EndUndo();
     pUndoMgr->LeaveListAction();
 
     return bContinue;
@@ -1321,6 +1343,9 @@ void SdDrawDocument::RemoveUnnecessaryMasterPages(SdPage* pMasterPage, BOOL bOnl
     ::sd::View* pView = NULL;
     SfxUndoManager* pUndoMgr = NULL;
 
+    if( bUndo && !IsUndoEnabled() )
+        bUndo = FALSE;
+
     if (mpDocSh)
     {
         pUndoMgr = mpDocSh->GetUndoManager();
@@ -1406,11 +1431,17 @@ void SdDrawDocument::RemoveUnnecessaryMasterPages(SdPage* pMasterPage, BOOL bOnl
 
                 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
 
@@ -1480,7 +1511,13 @@ void SdDrawDocument::SetMasterPage(USHORT nSdPageNum,
         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);
@@ -1715,15 +1752,19 @@ void SdDrawDocument::SetMasterPage(USHORT nSdPageNum,
             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
@@ -1758,13 +1799,16 @@ void SdDrawDocument::SetMasterPage(USHORT nSdPageNum,
         {
             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);
 
@@ -1865,13 +1909,20 @@ void SdDrawDocument::SetMasterPage(USHORT nSdPageNum,
         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(),
@@ -1881,7 +1932,10 @@ void SdDrawDocument::SetMasterPage(USHORT nSdPageNum,
         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);
@@ -1894,9 +1948,14 @@ void SdDrawDocument::SetMasterPage(USHORT nSdPageNum,
         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
@@ -1930,12 +1989,15 @@ void SdDrawDocument::SetMasterPage(USHORT nSdPageNum,
             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);
@@ -1963,7 +2025,8 @@ void SdDrawDocument::SetMasterPage(USHORT nSdPageNum,
         RemoveUnnecessaryMasterPages(&rOldMaster);
     }
 
-    pUndoMgr->LeaveListAction();
+    if( bUndo )
+        pUndoMgr->LeaveListAction();
 
     if( mpDocSh )
         mpDocSh->SetWaitCursor( FALSE );
diff --git a/sd/source/filter/xml/sdxmlwrp.cxx b/sd/source/filter/xml/sdxmlwrp.cxx
index bb3a498..d3b6417 100644
--- a/sd/source/filter/xml/sdxmlwrp.cxx
+++ b/sd/source/filter/xml/sdxmlwrp.cxx
@@ -460,6 +460,7 @@ sal_Bool SdXMLFilter::Import( ErrCode& nError )
     // -------------------------------------
 
     SdDrawDocument* pDoc = mrDocShell.GetDoc();
+    pDoc->EnableUndo(false);
     pDoc->NewOrLoadCompleted( NEW_DOC );
     pDoc->CreateFirstPages();
     pDoc->StopWorkStartupDelay();
@@ -806,6 +807,7 @@ sal_Bool SdXMLFilter::Import( ErrCode& nError )
         }
     }
 
+    pDoc->EnableUndo(true);
     mrDocShell.ClearUndoBuffer();
     return nRet == 0;
 }
diff --git a/sd/source/ui/dlg/masterlayoutdlg.cxx b/sd/source/ui/dlg/masterlayoutdlg.cxx
index 905f421..411ad98 100644
--- a/sd/source/ui/dlg/masterlayoutdlg.cxx
+++ b/sd/source/ui/dlg/masterlayoutdlg.cxx
@@ -169,9 +169,14 @@ void MasterLayoutDialog::remove( PresObjKind eKind )
 
     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);
     }
 }
diff --git a/sd/source/ui/func/fuexpand.cxx b/sd/source/ui/func/fuexpand.cxx
index 89bc81d..d642bd6 100644
--- a/sd/source/ui/func/fuexpand.cxx
+++ b/sd/source/ui/func/fuexpand.cxx
@@ -122,7 +122,10 @@ void FuExpandPage::DoExecute( SfxRequest& )
 
         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();
@@ -159,7 +162,9 @@ void FuExpandPage::DoExecute( SfxRequest& )
                     // 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());
@@ -180,7 +185,9 @@ void FuExpandPage::DoExecute( SfxRequest& )
                     // 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());
@@ -258,7 +265,8 @@ void FuExpandPage::DoExecute( SfxRequest& )
                 pPara = pOutl->GetParagraph( ++nParaPos );
             }
 
-            mpView->EndUndo();
+            if( bUndo )
+                mpView->EndUndo();
         }
 
         delete pOutl;
diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx
index 6511a57..7cc0860 100644
--- a/sd/source/ui/func/fuinsfil.cxx
+++ b/sd/source/ui/func/fuinsfil.cxx
@@ -586,7 +586,9 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
                 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:
@@ -611,8 +613,11 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
                     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;
diff --git a/sd/source/ui/func/fusel.cxx b/sd/source/ui/func/fusel.cxx
index 67e7437..2de7832 100644
--- a/sd/source/ui/func/fusel.cxx
+++ b/sd/source/ui/func/fusel.cxx
@@ -796,7 +796,7 @@ BOOL FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
                     {
                         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
diff --git a/sd/source/ui/func/fusumry.cxx b/sd/source/ui/func/fusumry.cxx
index 8c1d279..07c27bd 100644
--- a/sd/source/ui/func/fusumry.cxx
+++ b/sd/source/ui/func/fusumry.cxx
@@ -110,6 +110,8 @@ void FuSummaryPage::DoExecute( SfxRequest& )
         i++;
     }
 
+    bool bBegUndo = false;
+
     SfxStyleSheet* pStyle = NULL;
 
     for (i = nFirstPage; i < nCount; i++)
@@ -128,7 +130,14 @@ void FuSummaryPage::DoExecute( SfxRequest& )
                     /**********************************************************
                     * 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!
@@ -141,7 +150,8 @@ void FuSummaryPage::DoExecute( SfxRequest& )
 
                     // 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());
@@ -161,7 +171,9 @@ void FuSummaryPage::DoExecute( SfxRequest& )
 
                     // 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());
@@ -218,7 +230,8 @@ void FuSummaryPage::DoExecute( SfxRequest& )
         aAttr.Put(XFillStyleItem(XFILL_NONE));
         pTextObj->SetMergedItemSet(aAttr);
 
-        mpView->EndUndo();
+        if( bBegUndo )
+            mpView->EndUndo();
         delete pOutl;
 
         DrawViewShell* pDrawViewShell= dynamic_cast< DrawViewShell* >( mpViewShell );
diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx
index 6b2ea6d..f46cb06 100644
--- a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx
@@ -60,6 +60,7 @@
 
 
 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;
@@ -156,52 +157,34 @@ void SelectionManager::DeleteSelectedPages (void)
 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);
 
-    Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier (
-        mrSlideSorter.GetModel().GetDocument()->getUnoModel(), UNO_QUERY);
-    if (xDrawPagesSupplier.is())
-        xPages = xDrawPagesSupplier->getDrawPages();
-
-    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++)
+    try
     {
-        // Do not delete the last slide in the document.
-        if (pDocument->GetSdPageCount(PK_STANDARD) <= 1)
-            break;
-
-        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);
+        Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier( mrSlideSorter.GetModel().GetDocument()->getUnoModel(), UNO_QUERY_THROW );
+        Reference<drawing::XDrawPages> xPages( xDrawPagesSupplier->getDrawPages(), 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 (xPages->getCount() <= 1)
+                break;
 
-        DBG_ASSERT(pPage!=NULL, "page does not exist");
-        DBG_ASSERT(pNotesPage!=NULL, "notes does not exist");
+            USHORT nPage = ((*aI)->GetPageNum()-1) / 2;
 
-        // 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!");
+    }
 }
 
 
@@ -212,44 +195,32 @@ void SelectionManager::DeleteSelectedMasterPages (const ::std::vector<SdPage*>&
     // Prepare the deletion via the UNO API.
     OSL_ASSERT(mrSlideSorter.GetModel().GetEditMode() == EM_MASTERPAGE);
 
-    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++)
+    try
     {
-        // Do not delete the last slide in the document.
-        if (pDocument->GetMasterSdPageCount(PK_STANDARD) <= 1)
-            break;
-
-        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)
+        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++)
         {
-            SlideSorterView& rView (mrSlideSorter.GetView());
+            // Do not delete the last slide in the document.
+            if (xPages->getCount() <= 1)
+                break;
 
-            // 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));
+            USHORT nPage = ((*aI)->GetPageNum()-1) / 2;
 
-            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!");
+    }
 }
 
 
diff --git a/sd/source/ui/toolpanel/controls/DocumentHelper.cxx b/sd/source/ui/toolpanel/controls/DocumentHelper.cxx
index e42ba8d..a503fa6 100644
--- a/sd/source/ui/toolpanel/controls/DocumentHelper.cxx
+++ b/sd/source/ui/toolpanel/controls/DocumentHelper.cxx
@@ -529,8 +529,9 @@ SdPage* DocumentHelper::ProvideMasterPage (
         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;
@@ -538,8 +539,9 @@ SdPage* DocumentHelper::ProvideMasterPage (
         {
             SdPage* pClonedNotesMasterPage 
                 = AddMasterPage (rTargetDocument, pNotesMasterPage, nInsertionIndex+1);
-            rTargetDocument.AddUndo(
-                rTargetDocument.GetSdrUndoFactory().CreateUndoNewPage(*pClonedNotesMasterPage));
+            if( rTargetDocument.IsUndoEnabled() )
+                rTargetDocument.AddUndo(
+                    rTargetDocument.GetSdrUndoFactory().CreateUndoNewPage(*pClonedNotesMasterPage));
         }
     }
     return pMasterPageInDocument;
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index d384ddb..6934db0 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -88,6 +88,7 @@
 #include <sdresid.hxx>
 #include <sdpage.hxx>
 
+#include <strings.hrc>
 #include "unohelp.hxx"
 #include <unolayer.hxx>
 #include <unoprnms.hxx>
@@ -2453,10 +2454,12 @@ void SAL_CALL SdDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPag
 {
     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
@@ -2464,16 +2467,33 @@ void SAL_CALL SdDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPag
         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 );
+                    // 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
 
-                    // Die darauffolgende Seite ist die dazugeoerige Notizseite
-                    mpModel->mpDoc->RemovePage( nPage );
+                if( bUndo )
+                {
+                    rDoc.EndUndo();
+                }
+                else
+                {
+                    delete pNotesPage;
+                    delete pPage;
                 }
             }
         }
@@ -2708,9 +2728,11 @@ void SAL_CALL SdMasterPagesAccess::remove( const uno::Reference< drawing::XDrawP
 {
     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;
@@ -2726,10 +2748,31 @@ void SAL_CALL SdMasterPagesAccess::remove( const uno::Reference< drawing::XDrawP
     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;
+        }
     }
 }
 
diff --git a/sd/source/ui/view/drbezob.cxx b/sd/source/ui/view/drbezob.cxx
index 6195c1a..e31bf7a 100644
--- a/sd/source/ui/view/drbezob.cxx
+++ b/sd/source/ui/view/drbezob.cxx
@@ -307,11 +307,19 @@ void BezierObjectBar::Execute(SfxRequest& rReq)
                     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;
                     }
                 }
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 4957de0..187f021 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -254,6 +254,8 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
                     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());
@@ -269,15 +271,19 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
                             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));
diff --git a/sd/source/ui/view/drviews4.cxx b/sd/source/ui/view/drviews4.cxx
index f6bb812..660d2e0 100644
--- a/sd/source/ui/view/drviews4.cxx
+++ b/sd/source/ui/view/drviews4.cxx
@@ -31,6 +31,8 @@
 // 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>
@@ -92,6 +94,8 @@ namespace sd {
 #pragma optimize ( "", off )
 #endif
 
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing;
 
 /*************************************************************************
 |*
@@ -102,25 +106,20 @@ namespace sd {
 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!");
+    }
 }
 
 /*************************************************************************
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index 34f4c2e..d580c44 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -727,11 +727,19 @@ void DrawViewShell::FuSupport(SfxRequest& rReq)
             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();
         }
diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx
index 02dc216..fa5724b 100644
--- a/sd/source/ui/view/sdview.cxx
+++ b/sd/source/ui/view/sdview.cxx
@@ -1252,8 +1252,15 @@ IMPL_LINK( View, OnParagraphRemovingHdl, ::Outliner *, pOutliner )
 
 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()
diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx
index 2e1f719..e4221b1 100644
--- a/sd/source/ui/view/sdview2.cxx
+++ b/sd/source/ui/view/sdview2.cxx
@@ -421,10 +421,13 @@ void View::StartDrag( const Point& rStartPos, ::Window* pWindow )
         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 );
     }
 }
@@ -433,6 +436,8 @@ void View::StartDrag( const Point& rStartPos, ::Window* pWindow )
 
 void View::DragFinished( sal_Int8 nDropAction )
 {
+    const bool bUndo = IsUndoEnabled();
+
     SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag;
 
     if( pDragTransferable )
@@ -444,7 +449,9 @@ void View::DragFinished( sal_Int8 nDropAction )
         !IsPresObjSelected() )
     {
         mpDragSrcMarkList->ForceSort();
-        BegUndo();
+
+        if( bUndo )
+            BegUndo();
 
         ULONG nm, nAnz = mpDragSrcMarkList->GetMarkCount();
 
@@ -452,7 +459,8 @@ void View::DragFinished( sal_Int8 nDropAction )
         {
             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();
@@ -474,13 +482,15 @@ void View::DragFinished( sal_Int8 nDropAction )
             }
         }
 
-        EndUndo();
+        if( bUndo )
+            EndUndo();
     }
 
     if( pDragTransferable )
         pDragTransferable->SetInternalMove( FALSE );
 
-    EndUndo();
+    if( bUndo )
+        EndUndo();
     mnDragSrcPgNum = SDRPAGE_NOTFOUND;
     delete mpDragSrcMarkList;
     mpDragSrcMarkList = NULL;
diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index 3a4d85a..6087b89 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -423,9 +423,12 @@ BOOL View::InsertData( const TransferableDataHelper& rDataHelper,
                             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 );
                             }
@@ -504,9 +507,12 @@ BOOL View::InsertData( const TransferableDataHelper& rDataHelper,
 
                                         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;
@@ -734,14 +740,28 @@ BOOL View::InsertData( const TransferableDataHelper& rDataHelper,
                             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;
                         }
@@ -750,8 +770,12 @@ BOOL View::InsertData( const TransferableDataHelper& rDataHelper,
                             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.
@@ -771,11 +795,13 @@ BOOL View::InsertData( const TransferableDataHelper& rDataHelper,
                                 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;
                         }
                     }
@@ -1252,9 +1278,12 @@ BOOL View::InsertData( const TransferableDataHelper& rDataHelper,
 
             *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();
diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx
index db431f0..1a573e6 100644
--- a/sd/source/ui/view/sdview4.cxx
+++ b/sd/source/ui/view/sdview4.cxx
@@ -134,7 +134,9 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
                 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();
 
@@ -142,26 +144,39 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
             {
                 // 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);
@@ -238,14 +253,28 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
             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
diff --git a/sd/source/ui/view/viewshe3.cxx b/sd/source/ui/view/viewshe3.cxx
index 6690b9c..0327694 100644
--- a/sd/source/ui/view/viewshe3.cxx
+++ b/sd/source/ui/view/viewshe3.cxx
@@ -324,7 +324,9 @@ SdPage* ViewShell::CreateOrDuplicatePage (
 
     // 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)
@@ -403,13 +405,18 @@ SdPage* ViewShell::CreateOrDuplicatePage (
     }
     SdPage* pNewPage = 0;
     if(nNewPageIndex != 0xffff)
-    {
         pNewPage = pDocument->GetSdPage(nNewPageIndex, PK_STANDARD);
-        pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pNewPage));
-        pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pDocument->GetSdPage (nNewPageIndex, PK_NOTES)));
-    }
 
-    pDrView->EndUndo();
+    if( bUndo )
+    {
+        if( pNewPage )
+        {
+            pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pNewPage));
+            pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pDocument->GetSdPage (nNewPageIndex, PK_NOTES)));
+        }
+
+        pDrView->EndUndo();
+    }
 
     return pNewPage;
 }


More information about the ooo-build-commit mailing list