diff options
author | Kurt Zenker <kz@openoffice.org> | 2009-06-04 16:21:29 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2009-06-04 16:21:29 +0000 |
commit | c3e9297cb1fd34478e529f95892bcd93be9121ab (patch) | |
tree | aadf115a00eafe8e5397143de95f242bcb436c8f /svx/source/svdraw | |
parent | 837a58b872594da72126e120e0575b5401c9e0c7 (diff) |
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()
Diffstat (limited to 'svx/source/svdraw')
-rw-r--r-- | svx/source/svdraw/svddrgmt.cxx | 104 | ||||
-rw-r--r-- | svx/source/svdraw/svddrgv.cxx | 14 | ||||
-rw-r--r-- | svx/source/svdraw/svdedtv.cxx | 139 | ||||
-rw-r--r-- | svx/source/svdraw/svdedtv1.cxx | 490 | ||||
-rw-r--r-- | svx/source/svdraw/svdedtv2.cxx | 519 | ||||
-rw-r--r-- | svx/source/svdraw/svdedxv.cxx | 104 | ||||
-rw-r--r-- | svx/source/svdraw/svdglev.cxx | 79 | ||||
-rw-r--r-- | svx/source/svdraw/svdhdl.cxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdmodel.cxx | 151 | ||||
-rw-r--r-- | svx/source/svdraw/svdmrkv.cxx | 9 | ||||
-rw-r--r-- | svx/source/svdraw/svdpoev.cxx | 103 | ||||
-rw-r--r-- | svx/source/svdraw/svdundo.cxx | 20 | ||||
-rw-r--r-- | svx/source/svdraw/svdxcgv.cxx | 50 |
13 files changed, 1263 insertions, 521 deletions
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index 20523c81b9fb..bbc31b803096 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -1238,34 +1238,39 @@ bool SdrDragObjOwn::EndSdrDrag(bool /*bCopy*/) if(pObj) { - if(!getSdrDragView().IsInsObjPoint() && pObj->IsInserted() ) + const bool bUndo = getSdrDragView().IsUndoEnabled(); + + if( bUndo ) { - if (DragStat().IsEndDragChangesAttributes()) + if(!getSdrDragView().IsInsObjPoint() && pObj->IsInserted() ) { - pUndo=getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj); + if (DragStat().IsEndDragChangesAttributes()) + { + pUndo=getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj); - if (DragStat().IsEndDragChangesGeoAndAttributes()) + if (DragStat().IsEndDragChangesGeoAndAttributes()) + { + vConnectorUndoActions = getSdrDragView().CreateConnectorUndo( *pObj ); + pUndo2 = getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj); + } + } + else { vConnectorUndoActions = getSdrDragView().CreateConnectorUndo( *pObj ); - pUndo2 = getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj); + pUndo= getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj); } } + + if( pUndo ) + { + getSdrDragView().BegUndo( pUndo->GetComment() ); + } else { - vConnectorUndoActions = getSdrDragView().CreateConnectorUndo( *pObj ); - pUndo= getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj); + getSdrDragView().BegUndo(); } } - if( pUndo ) - { - getSdrDragView().BegUndo( pUndo->GetComment() ); - } - else - { - getSdrDragView().BegUndo(); - } - // evtl. use opertator= for setting changed object data (do not change selection in // view, this will destroy the interactor). This is possible since a clone is now // directly modified by the modifiers. Only SdrTableObj is adding own UNDOs @@ -1290,32 +1295,39 @@ bool SdrDragObjOwn::EndSdrDrag(bool /*bCopy*/) if(bRet) { - getSdrDragView().AddUndoActions( vConnectorUndoActions ); - - if ( pUndo ) + if( bUndo ) { - getSdrDragView().AddUndo(pUndo); - } + getSdrDragView().AddUndoActions( vConnectorUndoActions ); - if ( pUndo2 ) - { - getSdrDragView().AddUndo(pUndo2); + if ( pUndo ) + { + getSdrDragView().AddUndo(pUndo); + } + + if ( pUndo2 ) + { + getSdrDragView().AddUndo(pUndo2); + } } } else { - std::vector< SdrUndoAction* >::iterator vConnectorUndoIter( vConnectorUndoActions.begin() ); - - while( vConnectorUndoIter != vConnectorUndoActions.end() ) + if( bUndo ) { - delete *vConnectorUndoIter++; - } + std::vector< SdrUndoAction* >::iterator vConnectorUndoIter( vConnectorUndoActions.begin() ); + + while( vConnectorUndoIter != vConnectorUndoActions.end() ) + { + delete *vConnectorUndoIter++; + } - delete pUndo; - delete pUndo2; + delete pUndo; + delete pUndo2; + } } - getSdrDragView().EndUndo(); + if( bUndo ) + getSdrDragView().EndUndo(); } return bRet; @@ -3255,11 +3267,13 @@ bool SdrDragCrook::EndSdrDrag(bool bCopy) if (bResize && aFact==Fraction(1,1)) bResize=false; + const bool bUndo = getSdrDragView().IsUndoEnabled(); + bool bDoCrook=aCenter!=aMarkCenter && aRad.X()!=0 && aRad.Y()!=0; if (bDoCrook || bResize) { - if (bResize) + if (bResize && bUndo) { XubString aStr; ImpTakeDescriptionStr(!bContortion?STR_EditCrook:STR_EditCrookContortion,aStr); @@ -3301,7 +3315,8 @@ bool SdrDragCrook::EndSdrDrag(bool bCopy) ResizePoint(aCtr1,aCenter,aFact,aFact1); Size aSiz(aCtr1.X()-aCtr0.X(),aCtr1.Y()-aCtr0.Y()); - AddUndo(getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pO,aSiz)); + if( bUndo ) + AddUndo(getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pO,aSiz)); pO->Move(aSiz); } } @@ -3315,7 +3330,7 @@ bool SdrDragCrook::EndSdrDrag(bool bCopy) getSdrDragView().SetLastCrookCenter(aCenter); } - if (bResize) + if (bResize && bUndo) getSdrDragView().EndUndo(); return true; @@ -3545,11 +3560,18 @@ bool SdrDragCrop::EndSdrDrag(bool bCopy) return false; const SdrGrafCropItem& rOldCrop = (const SdrGrafCropItem&)pObj->GetMergedItem(SDRATTR_GRAFCROP); - String aUndoStr; - ImpTakeDescriptionStr(STR_DragMethCrop, aUndoStr); - getSdrDragView().BegUndo( aUndoStr ); - getSdrDragView().AddUndo( getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) ); + const bool bUndo = getSdrDragView().IsUndoEnabled(); + + if( bUndo ) + { + String aUndoStr; + ImpTakeDescriptionStr(STR_DragMethCrop, aUndoStr); + + getSdrDragView().BegUndo( aUndoStr ); + getSdrDragView().AddUndo( getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) ); + } + Rectangle aOldRect( pObj->GetLogicRect() ); getSdrDragView().ResizeMarkedObj(DragStat().Ref1(),aXFact,aYFact,bCopy); Rectangle aNewRect( pObj->GetLogicRect() ); @@ -3571,7 +3593,9 @@ bool SdrDragCrop::EndSdrDrag(bool bCopy) SfxItemSet aSet( rPool, SDRATTR_GRAFCROP, SDRATTR_GRAFCROP ); aSet.Put( SdrGrafCropItem( nLeftCrop, nTopCrop, nRightCrop, nBottomCrop ) ); getSdrDragView().SetAttributes( aSet, false ); - getSdrDragView().EndUndo(); + + if( bUndo ) + getSdrDragView().EndUndo(); return true; } diff --git a/svx/source/svdraw/svddrgv.cxx b/svx/source/svdraw/svddrgv.cxx index 001bf7a4b4f8..4dfc001ed6fc 100644 --- a/svx/source/svdraw/svddrgv.cxx +++ b/svx/source/svdraw/svddrgv.cxx @@ -564,7 +564,8 @@ BOOL SdrDragView::EndDragObj(BOOL bCopy) nHdlAnzMerk=GetMarkablePointCount(); } - if (IsInsertGluePoint()) + const bool bUndo = IsUndoEnabled(); + if (IsInsertGluePoint() && bUndo) { BegUndo(aInsPointUndoStr); AddUndo(pInsPointUndo); @@ -572,7 +573,7 @@ BOOL SdrDragView::EndDragObj(BOOL bCopy) bRet = mpCurrentSdrDragMethod->EndSdrDrag(bCopy); - if (IsInsertGluePoint()) + if( IsInsertGluePoint() && bUndo) EndUndo(); delete mpCurrentSdrDragMethod; @@ -590,9 +591,12 @@ BOOL SdrDragView::EndDragObj(BOOL bCopy) { SetMarkHandles(); bInsPolyPoint=FALSE; - BegUndo(aInsPointUndoStr); - AddUndo(pInsPointUndo); - EndUndo(); + if( bUndo ) + { + BegUndo(aInsPointUndoStr); + AddUndo(pInsPointUndo); + EndUndo(); + } } eDragHdl=HDL_MOVE; diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx index 85292b417e60..8b893788363a 100644 --- a/svx/source/svdraw/svdedtv.cxx +++ b/svx/source/svdraw/svdedtv.cxx @@ -135,7 +135,10 @@ SdrLayer* SdrEditView::InsertNewLayer(const XubString& rName, USHORT nPos) USHORT nMax=rLA.GetLayerCount(); if (nPos>nMax) nPos=nMax; SdrLayer* pNewLayer=rLA.NewLayer(rName,nPos); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewLayer(nPos,rLA,*pMod)); + + if( GetModel()->IsUndoEnabled() ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewLayer(nPos,rLA,*pMod)); + pMod->SetChanged(); return pNewLayer; } @@ -181,19 +184,26 @@ void SdrEditView::ImpDelLayerDelObjs(SdrObjList* pOL, SdrLayerID nDelID) // make sure OrdNums are correct pOL->GetObj(0)->GetOrdNum(); + const bool bUndo = GetModel()->IsUndoEnabled(); + for(sal_uInt32 nObjNum(nObjAnz); nObjNum > 0;) { nObjNum--; SdrObject* pObj = pOL->GetObj(nObjNum); SdrObjList* pSubOL = pObj->GetSubList(); + // #104809# Test explicitely for group objects and 3d scenes if(pSubOL && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dScene))) { if(ImpDelLayerCheck(pSubOL, nDelID)) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); pOL->RemoveObject(nObjNum); + + if( !bUndo ) + SdrObject::Free( pObj ); } else { @@ -204,8 +214,11 @@ void SdrEditView::ImpDelLayerDelObjs(SdrObjList* pOL, SdrLayerID nDelID) { if(pObj->GetLayer() == nDelID) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); pOL->RemoveObject(nObjNum); + if( !bUndo ) + SdrObject::Free( pObj ); } } } @@ -219,8 +232,13 @@ void SdrEditView::DeleteLayer(const XubString& rName) if(SDRLAYER_NOTFOUND != nLayerNum) { + SdrLayerID nDelID = pLayer->GetID(); - BegUndo(ImpGetResStr(STR_UndoDelLayer)); + + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(ImpGetResStr(STR_UndoDelLayer)); + sal_Bool bMaPg(sal_True); for(sal_uInt16 nPageKind(0); nPageKind < 2; nPageKind++) @@ -249,8 +267,11 @@ void SdrEditView::DeleteLayer(const XubString& rName) { if(ImpDelLayerCheck(pSubOL, nDelID)) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); pPage->RemoveObject(nObjNum); + if( !bUndo ) + SdrObject::Free(pObj); } else { @@ -261,8 +282,11 @@ void SdrEditView::DeleteLayer(const XubString& rName) { if(pObj->GetLayer() == nDelID) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); pPage->RemoveObject(nObjNum); + if( !bUndo ) + SdrObject::Free(pObj); } } } @@ -270,9 +294,17 @@ void SdrEditView::DeleteLayer(const XubString& rName) bMaPg = sal_False; } - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteLayer(nLayerNum, rLA, *pMod)); - rLA.RemoveLayer(nLayerNum); - EndUndo(); + if( bUndo ) + { + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteLayer(nLayerNum, rLA, *pMod)); + rLA.RemoveLayer(nLayerNum); + EndUndo(); + } + else + { + delete rLA.RemoveLayer(nLayerNum); + } + pMod->SetChanged(); } } @@ -282,8 +314,10 @@ void SdrEditView::MoveLayer(const XubString& rName, USHORT nNewPos) SdrLayerAdmin& rLA=pMod->GetLayerAdmin(); SdrLayer* pLayer=rLA.GetLayer(rName,TRUE); USHORT nLayerNum=rLA.GetLayerPos(pLayer); - if (nLayerNum!=SDRLAYER_NOTFOUND) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveLayer(nLayerNum,rLA,*pMod,nNewPos)); + if (nLayerNum!=SDRLAYER_NOTFOUND) + { + if( IsUndoEnabled() ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveLayer(nLayerNum,rLA,*pMod,nNewPos)); rLA.MoveLayer(nLayerNum,nNewPos); pMod->SetChanged(); } @@ -328,7 +362,8 @@ void SdrEditView::ImpBroadcastEdgesOfMarkedNodes() && LIST_ENTRY_NOTFOUND == rAllMarkedObjects.GetPos(pObj1) && !pEdge->CheckNodeConnection(sal_False)) { - AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pEdge)); + if( IsUndoEnabled() ) + AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pEdge)); pEdge->DisconnectFromNode(sal_False); } @@ -336,7 +371,8 @@ void SdrEditView::ImpBroadcastEdgesOfMarkedNodes() && LIST_ENTRY_NOTFOUND == rAllMarkedObjects.GetPos(pObj2) && !pEdge->CheckNodeConnection(sal_True)) { - AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pEdge)); + if( IsUndoEnabled() ) + AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pEdge)); pEdge->DisconnectFromNode(sal_True); } } @@ -686,9 +722,13 @@ void SdrEditView::ForceMarkedObjToAnotherPage() void SdrEditView::DeleteMarkedList(const SdrMarkList& rMark) { - if (rMark.GetMarkCount()!=0) { + if (rMark.GetMarkCount()!=0) + { rMark.ForceSort(); - BegUndo(); + + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(); const sal_uInt32 nMarkAnz(rMark.GetMarkCount()); if(nMarkAnz) @@ -696,22 +736,27 @@ void SdrEditView::DeleteMarkedList(const SdrMarkList& rMark) sal_uInt32 nm(0); std::vector< E3DModifySceneSnapRectUpdater* > aUpdaters; - for(nm = nMarkAnz; nm > 0;) + if( bUndo ) { - nm--; - SdrMark* pM = rMark.GetMark(nm); - SdrObject* pObj = pM->GetMarkedSdrObj(); + for(nm = nMarkAnz; nm > 0;) + { + nm--; + SdrMark* pM = rMark.GetMark(nm); + SdrObject* pObj = pM->GetMarkedSdrObj(); - // extra undo actions for changed connector which now may hold it's layouted path (SJ) - std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pObj ) ); - AddUndoActions( vConnectorUndoActions ); + // extra undo actions for changed connector which now may hold it's layouted path (SJ) + std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pObj ) ); + AddUndoActions( vConnectorUndoActions ); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); + } } // Sicherstellen, dass die OrderNums stimmen: rMark.GetMark(0)->GetMarkedSdrObj()->GetOrdNum(); + std::vector< SdrObject* > aRemoved3DObjects; + for(nm = nMarkAnz; nm > 0;) { nm--; @@ -720,13 +765,22 @@ void SdrEditView::DeleteMarkedList(const SdrMarkList& rMark) SdrObjList* pOL = pObj->GetObjList(); //#52680# const sal_uInt32 nOrdNum(pObj->GetOrdNumDirect()); + bool bIs3D = dynamic_cast< E3dObject* >(pObj); // set up a scene updater if object is a 3d object - if(dynamic_cast< E3dObject* >(pObj)) + if(bIs3D) { aUpdaters.push_back(new E3DModifySceneSnapRectUpdater(pObj)); } pOL->RemoveObject(nOrdNum); + + if( !bUndo ) + { + if( bIs3D ) + aRemoved3DObjects.push_back( pObj ); // may be needed later + else + SdrObject::Free(pObj); + } } // fire scene updaters @@ -735,9 +789,20 @@ void SdrEditView::DeleteMarkedList(const SdrMarkList& rMark) delete aUpdaters.back(); aUpdaters.pop_back(); } + + if( !bUndo ) + { + // now delete removed scene objects + while(aRemoved3DObjects.size()) + { + SdrObject::Free( aRemoved3DObjects.back() ); + aRemoved3DObjects.pop_back(); + } + } } - EndUndo(); + if( bUndo ) + EndUndo(); } } @@ -774,6 +839,8 @@ void SdrEditView::CopyMarkedObj() // New mechanism to re-create the connections of cloned connectors CloneList aCloneList; + const bool bUndo = IsUndoEnabled(); + GetMarkedObjectListWriteAccess().Clear(); ULONG nCloneErrCnt=0; ULONG nMarkAnz=aSourceObjectsForCopy.GetMarkCount(); @@ -784,7 +851,10 @@ void SdrEditView::CopyMarkedObj() if (pO!=NULL) { SdrInsertReason aReason(SDRREASON_VIEWCALL); pM->GetPageView()->GetObjList()->InsertObject(pO,CONTAINER_APPEND,&aReason); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoCopyObject(*pO)); + + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoCopyObject(*pO)); + SdrMark aME(*pM); aME.SetMarkedSdrObj(pO); aCloneList.AddPair(pM->GetMarkedSdrObj(), pO); @@ -851,7 +921,9 @@ BOOL SdrEditView::InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, ULONG nO rPV.GetObjList()->InsertObject(pObj,CONTAINER_APPEND,&aReason); } } - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj)); + if( IsUndoEnabled() ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj)); + if ((nOptions & SDRINSERT_DONTMARK)==0) { if ((nOptions & SDRINSERT_ADDMARK)==0) UnmarkAllObj(); MarkObj(pObj,&rPV); @@ -862,8 +934,13 @@ BOOL SdrEditView::InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, ULONG nO void SdrEditView::ReplaceObjectAtView(SdrObject* pOldObj, SdrPageView& rPV, SdrObject* pNewObj, BOOL bMark) { SdrObjList* pOL=pOldObj->GetObjList(); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoReplaceObject(*pOldObj,*pNewObj)); + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoReplaceObject(*pOldObj,*pNewObj)); pOL->ReplaceObject(pNewObj,pOldObj->GetOrdNum()); + if( !bUndo ) + SdrObject::Free( pOldObj ); + if (bMark) MarkObj(pNewObj,&rPV); } @@ -901,6 +978,7 @@ void SdrEditView::SetUndoComment(const String& rComment) pMod->SetUndoComment(rComment); } + void SdrEditView::SetUndoComment(const String& rComment, const String& rObjDescr) { @@ -908,3 +986,8 @@ void SdrEditView::SetUndoComment(const String& rComment, } #endif +bool SdrEditView::IsUndoEnabled() const +{ + return pMod->IsUndoEnabled(); +} + diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx index ba1f8914ba8b..2c6f0891b396 100644 --- a/svx/source/svdraw/svdedtv1.cxx +++ b/svx/source/svdraw/svdedtv1.cxx @@ -98,17 +98,32 @@ void SdrEditView::SetMarkedObjRect(const Rectangle& rRect, BOOL bCopy) long h1=rRect.Bottom()-y1; XubString aStr; ImpTakeDescriptionStr(STR_EditPosSize,aStr); - if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy); - BegUndo(aStr); - if (bCopy) CopyMarkedObj(); - for (ULONG nm=0; nm<nAnz; nm++) { + if (bCopy) + aStr+=ImpGetResStr(STR_EditWithCopy); + + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(aStr); + + if (bCopy) + CopyMarkedObj(); + + for (ULONG nm=0; nm<nAnz; nm++) + { SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pO=pM->GetMarkedSdrObj(); - AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); + if( bUndo ) + AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); + Rectangle aR1(pO->GetSnapRect()); - if (!aR1.IsEmpty()) { - if (aR1==aR0) aR1=rRect; - else { // aR1 von aR0 nach rRect transformieren + if (!aR1.IsEmpty()) + { + if (aR1==aR0) + { + aR1=rRect; + } + else + { // aR1 von aR0 nach rRect transformieren aR1.Move(-x0,-y0); BigInt l(aR1.Left()); BigInt r(aR1.Right()); @@ -137,7 +152,8 @@ void SdrEditView::SetMarkedObjRect(const Rectangle& rRect, BOOL bCopy) DBG_ERROR("SetMarkedObjRect(): pObj->GetSnapRect() liefert leeres Rect"); } } - EndUndo(); + if( bUndo ) + EndUndo(); } std::vector< SdrUndoAction* > SdrEditView::CreateConnectorUndo( SdrObject& rO ) @@ -176,40 +192,69 @@ void SdrEditView::AddUndoActions( std::vector< SdrUndoAction* >& rUndoActions ) void SdrEditView::MoveMarkedObj(const Size& rSiz, bool bCopy) { - XubString aStr(ImpGetResStr(STR_EditMove)); - if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy); - // benoetigt eigene UndoGroup wegen Parameter - BegUndo(aStr,GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_MOVE); - if (bCopy) CopyMarkedObj(); + const bool bUndo = IsUndoEnabled(); + + if( bUndo ) + { + XubString aStr(ImpGetResStr(STR_EditMove)); + if (bCopy) + aStr+=ImpGetResStr(STR_EditWithCopy); + // benoetigt eigene UndoGroup wegen Parameter + BegUndo(aStr,GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_MOVE); + } + + if (bCopy) + CopyMarkedObj(); + ULONG nMarkAnz=GetMarkedObjectCount(); - for (ULONG nm=0; nm<nMarkAnz; nm++) { + for (ULONG nm=0; nm<nMarkAnz; nm++) + { SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pO=pM->GetMarkedSdrObj(); - std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) ); - AddUndoActions( vConnectorUndoActions ); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pO,rSiz)); + if( bUndo ) + { + std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) ); + AddUndoActions( vConnectorUndoActions ); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pO,rSiz)); + } pO->Move(rSiz); } - EndUndo(); + + if( bUndo ) + EndUndo(); } void SdrEditView::ResizeMarkedObj(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy) { - XubString aStr; - ImpTakeDescriptionStr(STR_EditResize,aStr); - if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy); - BegUndo(aStr); - if (bCopy) CopyMarkedObj(); + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + { + XubString aStr; + ImpTakeDescriptionStr(STR_EditResize,aStr); + if (bCopy) + aStr+=ImpGetResStr(STR_EditWithCopy); + BegUndo(aStr); + } + + if (bCopy) + CopyMarkedObj(); + ULONG nMarkAnz=GetMarkedObjectCount(); - for (ULONG nm=0; nm<nMarkAnz; nm++) { + for (ULONG nm=0; nm<nMarkAnz; nm++) + { SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pO=pM->GetMarkedSdrObj(); - std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) ); - AddUndoActions( vConnectorUndoActions ); - AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); + if( bUndo ) + { + std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) ); + AddUndoActions( vConnectorUndoActions ); + AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); + } pO->Resize(rRef,xFact,yFact); } - EndUndo(); + + if( bUndo ) + EndUndo(); } long SdrEditView::GetMarkedObjRotate() const @@ -232,11 +277,18 @@ long SdrEditView::GetMarkedObjRotate() const void SdrEditView::RotateMarkedObj(const Point& rRef, long nWink, bool bCopy) { - XubString aStr; - ImpTakeDescriptionStr(STR_EditRotate,aStr); - if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy); - BegUndo(aStr); - if (bCopy) CopyMarkedObj(); + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + { + XubString aStr; + ImpTakeDescriptionStr(STR_EditRotate,aStr); + if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy); + BegUndo(aStr); + } + + if (bCopy) + CopyMarkedObj(); + double nSin=sin(nWink*nPi180); double nCos=cos(nWink*nPi180); const sal_uInt32 nMarkAnz(GetMarkedObjectCount()); @@ -250,11 +302,14 @@ void SdrEditView::RotateMarkedObj(const Point& rRef, long nWink, bool bCopy) SdrMark* pM = GetSdrMarkByIndex(nm); SdrObject* pO = pM->GetMarkedSdrObj(); - // extra undo actions for changed connector which now may hold it's layouted path (SJ) - std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) ); - AddUndoActions( vConnectorUndoActions ); + if( bUndo ) + { + // extra undo actions for changed connector which now may hold it's layouted path (SJ) + std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) ); + AddUndoActions( vConnectorUndoActions ); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); + } // set up a scene updater if object is a 3d object if(dynamic_cast< E3dObject* >(pO)) @@ -273,20 +328,29 @@ void SdrEditView::RotateMarkedObj(const Point& rRef, long nWink, bool bCopy) } } - EndUndo(); + if( bUndo ) + EndUndo(); } void SdrEditView::MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool bCopy) { - XubString aStr; - Point aDif(rRef2-rRef1); - if (aDif.X()==0) ImpTakeDescriptionStr(STR_EditMirrorHori,aStr); - else if (aDif.Y()==0) ImpTakeDescriptionStr(STR_EditMirrorVert,aStr); - else if (Abs(aDif.X())==Abs(aDif.Y())) ImpTakeDescriptionStr(STR_EditMirrorDiag,aStr); - else ImpTakeDescriptionStr(STR_EditMirrorFree,aStr); - if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy); - BegUndo(aStr); - if (bCopy) CopyMarkedObj(); + const bool bUndo = IsUndoEnabled(); + + if( bUndo ) + { + XubString aStr; + Point aDif(rRef2-rRef1); + if (aDif.X()==0) ImpTakeDescriptionStr(STR_EditMirrorHori,aStr); + else if (aDif.Y()==0) ImpTakeDescriptionStr(STR_EditMirrorVert,aStr); + else if (Abs(aDif.X())==Abs(aDif.Y())) ImpTakeDescriptionStr(STR_EditMirrorDiag,aStr); + else ImpTakeDescriptionStr(STR_EditMirrorFree,aStr); + if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy); + BegUndo(aStr); + } + + if (bCopy) + CopyMarkedObj(); + const sal_uInt32 nMarkAnz(GetMarkedObjectCount()); if(nMarkAnz) @@ -298,11 +362,14 @@ void SdrEditView::MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool b SdrMark* pM = GetSdrMarkByIndex(nm); SdrObject* pO = pM->GetMarkedSdrObj(); - // extra undo actions for changed connector which now may hold it's layouted path (SJ) - std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) ); - AddUndoActions( vConnectorUndoActions ); + if( bUndo ) + { + // extra undo actions for changed connector which now may hold it's layouted path (SJ) + std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) ); + AddUndoActions( vConnectorUndoActions ); - AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); + AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); + } // set up a scene updater if object is a 3d object if(dynamic_cast< E3dObject* >(pO)) @@ -321,7 +388,8 @@ void SdrEditView::MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool b } } - EndUndo(); + if( bUndo ) + EndUndo(); } void SdrEditView::MirrorMarkedObjHorizontal(BOOL bCopy) @@ -362,22 +430,37 @@ long SdrEditView::GetMarkedObjShear() const void SdrEditView::ShearMarkedObj(const Point& rRef, long nWink, bool bVShear, bool bCopy) { - XubString aStr; - ImpTakeDescriptionStr(STR_EditShear,aStr); - if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy); - BegUndo(aStr); - if (bCopy) CopyMarkedObj(); + const bool bUndo = IsUndoEnabled(); + + if( bUndo ) + { + XubString aStr; + ImpTakeDescriptionStr(STR_EditShear,aStr); + if (bCopy) + aStr+=ImpGetResStr(STR_EditWithCopy); + BegUndo(aStr); + } + + if (bCopy) + CopyMarkedObj(); + double nTan=tan(nWink*nPi180); ULONG nMarkAnz=GetMarkedObjectCount(); - for (ULONG nm=0; nm<nMarkAnz; nm++) { + for (ULONG nm=0; nm<nMarkAnz; nm++) + { SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pO=pM->GetMarkedSdrObj(); - std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) ); - AddUndoActions( vConnectorUndoActions ); - AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); + if( bUndo ) + { + std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) ); + AddUndoActions( vConnectorUndoActions ); + AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); + } pO->Shear(rRef,nWink,nTan,bVShear); } - EndUndo(); + + if( bUndo ) + EndUndo(); } void SdrEditView::ImpCrookObj(SdrObject* pO, const Point& rRef, const Point& rRad, @@ -462,17 +545,30 @@ void SdrEditView::CrookMarkedObj(const Point& rRef, const Point& rRad, SdrCrookM bool bVertical, bool bNoContortion, bool bCopy) { Rectangle aMarkRect(GetMarkedObjRect()); - XubString aStr; - BOOL bRotate=bNoContortion && eMode==SDRCROOK_ROTATE && IsRotateAllowed(FALSE); - ImpTakeDescriptionStr(bNoContortion?STR_EditCrook:STR_EditCrookContortion,aStr); - if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy); - BegUndo(aStr); - if (bCopy) CopyMarkedObj(); + const bool bUndo = IsUndoEnabled(); + + bool bRotate=bNoContortion && eMode==SDRCROOK_ROTATE && IsRotateAllowed(FALSE); + + if( bUndo ) + { + XubString aStr; + ImpTakeDescriptionStr(bNoContortion?STR_EditCrook:STR_EditCrookContortion,aStr); + if (bCopy) + aStr+=ImpGetResStr(STR_EditWithCopy); + BegUndo(aStr); + } + + if (bCopy) + CopyMarkedObj(); + ULONG nMarkAnz=GetMarkedObjectCount(); - for (ULONG nm=0; nm<nMarkAnz; nm++) { + for (ULONG nm=0; nm<nMarkAnz; nm++) + { SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pO=pM->GetMarkedSdrObj(); - AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); + if( bUndo ) + AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); + const SdrObjList* pOL=pO->GetSubList(); if (bNoContortion || pOL==NULL) { ImpCrookObj(pO,rRef,rRad,eMode,bVertical,bNoContortion,bRotate,aMarkRect); @@ -484,7 +580,9 @@ void SdrEditView::CrookMarkedObj(const Point& rRef, const Point& rRad, SdrCrookM } } } - EndUndo(); + + if( bUndo ) + EndUndo(); } void SdrEditView::ImpDistortObj(SdrObject* pO, const Rectangle& rRef, const XPolygon& rDistortedRect, BOOL bNoContortion) @@ -523,16 +621,28 @@ void SdrEditView::ImpDistortObj(SdrObject* pO, const Rectangle& rRef, const XPol void SdrEditView::DistortMarkedObj(const Rectangle& rRef, const XPolygon& rDistortedRect, bool bNoContortion, bool bCopy) { - XubString aStr; - ImpTakeDescriptionStr(STR_EditDistort,aStr); - if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy); - BegUndo(aStr); - if (bCopy) CopyMarkedObj(); + const bool bUndo = IsUndoEnabled(); + + if( bUndo ) + { + XubString aStr; + ImpTakeDescriptionStr(STR_EditDistort,aStr); + if (bCopy) + aStr+=ImpGetResStr(STR_EditWithCopy); + BegUndo(aStr); + } + + if (bCopy) + CopyMarkedObj(); + ULONG nMarkAnz=GetMarkedObjectCount(); - for (ULONG nm=0; nm<nMarkAnz; nm++) { + for (ULONG nm=0; nm<nMarkAnz; nm++) + { SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pO=pM->GetMarkedSdrObj(); - AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); + if( bUndo ) + AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); + Rectangle aRefRect(rRef); XPolygon aRefPoly(rDistortedRect); const SdrObjList* pOL=pO->GetSubList(); @@ -546,7 +656,8 @@ void SdrEditView::DistortMarkedObj(const Rectangle& rRef, const XPolygon& rDisto } } } - EndUndo(); + if( bUndo ) + EndUndo(); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -621,13 +732,19 @@ void SdrEditView::SetNotPersistAttrToMarked(const SfxItemSet& rAttr, BOOL /*bRep long nAngle=((const SdrVertShearAllItem*)pPoolItem)->GetValue(); ShearMarkedObj(aAllSnapRect.Center(),nAngle,TRUE); } + + const bool bUndo = IsUndoEnabled(); + // Todo: WhichRange nach Notwendigkeit ueberpruefen. ULONG nMarkAnz=GetMarkedObjectCount(); - for (ULONG nm=0; nm<nMarkAnz; nm++) { + for (ULONG nm=0; nm<nMarkAnz; nm++) + { const SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pObj=pM->GetMarkedSdrObj(); //const SdrPageView* pPV=pM->GetPageView(); - AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); + if( bUndo ) + AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); + pObj->ApplyNotPersistAttr(rAttr); } } @@ -838,8 +955,6 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, BOOL bReplaceAll) // Joe, 2.7.98: Damit Undo nach Format.Standard auch die Textattribute korrekt restauriert BOOL bHasEEItems=SearchOutlinerItems(rAttr,bReplaceAll); - XubString aStr; - ImpTakeDescriptionStr(STR_EditSetAttributes,aStr); // AW 030100: save additional geom info when para or char attributes // are changed and the geom form of the text object might be changed @@ -864,7 +979,14 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, BOOL bReplaceAll) nWhich = aIter.NextWhich(); } - BegUndo(aStr); + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + { + XubString aStr; + ImpTakeDescriptionStr(STR_EditSetAttributes,aStr); + BegUndo(aStr); + } + const sal_uInt32 nMarkAnz(GetMarkedObjectCount()); std::vector< E3DModifySceneSnapRectUpdater* > aUpdaters; @@ -882,31 +1004,38 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, BOOL bReplaceAll) SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pObj = pM->GetMarkedSdrObj(); - std::vector< SdrUndoAction* > vConnectorUndoActions; - SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >( pObj ); - if ( pEdgeObj ) - bPossibleGeomChange = TRUE; - else - vConnectorUndoActions = CreateConnectorUndo( *pObj ); - AddUndoActions( vConnectorUndoActions ); + if( bUndo ) + { + std::vector< SdrUndoAction* > vConnectorUndoActions; + SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >( pObj ); + if ( pEdgeObj ) + bPossibleGeomChange = TRUE; + else if( bUndo ) + vConnectorUndoActions = CreateConnectorUndo( *pObj ); + + AddUndoActions( vConnectorUndoActions ); + } // new geometry undo - if(bPossibleGeomChange) + if(bPossibleGeomChange && bUndo) { // save position and size of obect, too AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); } - // #i8508# - // If this is a text object also rescue the OutlinerParaObject since - // applying attributes to the object may change text layout when - // multiple portions exist with multiple formats. If a OutlinerParaObject - // really exists and needs to be rescued is evaluated in the undo - // implementation itself. - sal_Bool bRescueText(pObj->ISA(SdrTextObj)); - - // add attribute undo - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj,FALSE,bHasEEItems || bPossibleGeomChange || bRescueText)); + if( bUndo ) + { + // #i8508# + // If this is a text object also rescue the OutlinerParaObject since + // applying attributes to the object may change text layout when + // multiple portions exist with multiple formats. If a OutlinerParaObject + // really exists and needs to be rescued is evaluated in the undo + // implementation itself. + const bool bRescueText = dynamic_cast< SdrTextObj* >(pObj) != 0; + + // add attribute undo + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj,FALSE,bHasEEItems || bPossibleGeomChange || bRescueText)); + } // set up a scxene updater if object is a 3d object if(dynamic_cast< E3dObject* >(pObj)) @@ -965,7 +1094,9 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, BOOL bReplaceAll) // pObj->SetAttr() oder SetNotPersistAttr() // !!! fehlende Implementation !!! SetNotPersistAttrToMarked(rAttr,bReplaceAll); - EndUndo(); + + if( bUndo ) + EndUndo(); } } @@ -986,19 +1117,34 @@ SfxStyleSheet* SdrEditView::GetStyleSheetFromMarked() const void SdrEditView::SetStyleSheetToMarked(SfxStyleSheet* pStyleSheet, BOOL bDontRemoveHardAttr) { - if (AreObjectsMarked()) { - XubString aStr; - if (pStyleSheet!=NULL) ImpTakeDescriptionStr(STR_EditSetStylesheet,aStr); - else ImpTakeDescriptionStr(STR_EditDelStylesheet,aStr); - BegUndo(aStr); + if (AreObjectsMarked()) + { + const bool bUndo = IsUndoEnabled(); + + if( bUndo ) + { + XubString aStr; + if (pStyleSheet!=NULL) + ImpTakeDescriptionStr(STR_EditSetStylesheet,aStr); + else + ImpTakeDescriptionStr(STR_EditDelStylesheet,aStr); + BegUndo(aStr); + } + ULONG nMarkAnz=GetMarkedObjectCount(); - for (ULONG nm=0; nm<nMarkAnz; nm++) { + for (ULONG nm=0; nm<nMarkAnz; nm++) + { SdrMark* pM=GetSdrMarkByIndex(nm); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pM->GetMarkedSdrObj())); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pM->GetMarkedSdrObj(),true,true)); + if( bUndo ) + { + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pM->GetMarkedSdrObj())); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pM->GetMarkedSdrObj(),true,true)); + } pM->GetMarkedSdrObj()->SetStyleSheet(pStyleSheet,bDontRemoveHardAttr); } - EndUndo(); + + if( bUndo ) + EndUndo(); } } @@ -1494,84 +1640,119 @@ BOOL SdrEditView::IsAlignPossible() const void SdrEditView::AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert, BOOL bBoundRects) { - if (eHor==SDRHALIGN_NONE && eVert==SDRVALIGN_NONE) return; + if (eHor==SDRHALIGN_NONE && eVert==SDRVALIGN_NONE) + return; + SortMarkedObjects(); - if (GetMarkedObjectCount()<1) return; - XubString aStr(GetDescriptionOfMarkedObjects()); - if (eHor==SDRHALIGN_NONE) { - switch (eVert) { - case SDRVALIGN_TOP : ImpTakeDescriptionStr(STR_EditAlignVTop ,aStr); break; - case SDRVALIGN_BOTTOM: ImpTakeDescriptionStr(STR_EditAlignVBottom,aStr); break; - case SDRVALIGN_CENTER: ImpTakeDescriptionStr(STR_EditAlignVCenter,aStr); break; - default: break; + if (GetMarkedObjectCount()<1) + return; + + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + { + XubString aStr(GetDescriptionOfMarkedObjects()); + if (eHor==SDRHALIGN_NONE) + { + switch (eVert) + { + case SDRVALIGN_TOP : ImpTakeDescriptionStr(STR_EditAlignVTop ,aStr); break; + case SDRVALIGN_BOTTOM: ImpTakeDescriptionStr(STR_EditAlignVBottom,aStr); break; + case SDRVALIGN_CENTER: ImpTakeDescriptionStr(STR_EditAlignVCenter,aStr); break; + default: break; + } + } + else if (eVert==SDRVALIGN_NONE) + { + switch (eHor) + { + case SDRHALIGN_LEFT : ImpTakeDescriptionStr(STR_EditAlignHLeft ,aStr); break; + case SDRHALIGN_RIGHT : ImpTakeDescriptionStr(STR_EditAlignHRight ,aStr); break; + case SDRHALIGN_CENTER: ImpTakeDescriptionStr(STR_EditAlignHCenter,aStr); break; + default: break; + } } - } else if (eVert==SDRVALIGN_NONE) { - switch (eHor) { - case SDRHALIGN_LEFT : ImpTakeDescriptionStr(STR_EditAlignHLeft ,aStr); break; - case SDRHALIGN_RIGHT : ImpTakeDescriptionStr(STR_EditAlignHRight ,aStr); break; - case SDRHALIGN_CENTER: ImpTakeDescriptionStr(STR_EditAlignHCenter,aStr); break; - default: break; + else if (eHor==SDRHALIGN_CENTER && eVert==SDRVALIGN_CENTER) + { + ImpTakeDescriptionStr(STR_EditAlignCenter,aStr); } - } else if (eHor==SDRHALIGN_CENTER && eVert==SDRVALIGN_CENTER) { - ImpTakeDescriptionStr(STR_EditAlignCenter,aStr); - } else { - ImpTakeDescriptionStr(STR_EditAlign,aStr); + else + { + ImpTakeDescriptionStr(STR_EditAlign,aStr); + } + BegUndo(aStr); } - BegUndo(aStr); + Rectangle aBound; ULONG nMarkAnz=GetMarkedObjectCount(); ULONG nm; BOOL bHasFixed=FALSE; - for (nm=0; nm<nMarkAnz; nm++) { + for (nm=0; nm<nMarkAnz; nm++) + { SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pObj=pM->GetMarkedSdrObj(); SdrObjTransformInfoRec aInfo; pObj->TakeObjInfo(aInfo); - if (!aInfo.bMoveAllowed || pObj->IsMoveProtect()) { + if (!aInfo.bMoveAllowed || pObj->IsMoveProtect()) + { Rectangle aObjRect(bBoundRects?pObj->GetCurrentBoundRect():pObj->GetSnapRect()); aBound.Union(aObjRect); bHasFixed=TRUE; } } - if (!bHasFixed) { - if (nMarkAnz==1) { // einzelnes Obj an der Seite ausrichten + if (!bHasFixed) + { + if (nMarkAnz==1) + { // einzelnes Obj an der Seite ausrichten const SdrObject* pObj=GetMarkedObjectByIndex(0L); const SdrPage* pPage=pObj->GetPage(); const SdrPageGridFrameList* pGFL=pPage->GetGridFrameList(GetSdrPageViewOfMarkedByIndex(0),&(pObj->GetSnapRect())); const SdrPageGridFrame* pFrame=NULL; - if (pGFL!=NULL && pGFL->GetCount()!=0) { // Writer + if (pGFL!=NULL && pGFL->GetCount()!=0) + { // Writer pFrame=&((*pGFL)[0]); } - if (pFrame!=NULL) { // Writer + + if (pFrame!=NULL) + { // Writer aBound=pFrame->GetUserArea(); - } else { + } + else + { aBound=Rectangle(pPage->GetLftBorder(),pPage->GetUppBorder(), pPage->GetWdt()-pPage->GetRgtBorder(), pPage->GetHgt()-pPage->GetLwrBorder()); } - } else { - if (bBoundRects) aBound=GetMarkedObjBoundRect(); - else aBound=GetMarkedObjRect(); + } + else + { + if (bBoundRects) + aBound=GetMarkedObjBoundRect(); + else + aBound=GetMarkedObjRect(); } } Point aCenter(aBound.Center()); - for (nm=0; nm<nMarkAnz; nm++) { + for (nm=0; nm<nMarkAnz; nm++) + { SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pObj=pM->GetMarkedSdrObj(); SdrObjTransformInfoRec aInfo; pObj->TakeObjInfo(aInfo); - if (aInfo.bMoveAllowed && !pObj->IsMoveProtect()) { + if (aInfo.bMoveAllowed && !pObj->IsMoveProtect()) + { // SdrPageView* pPV=pM->GetPageView(); long nXMov=0; long nYMov=0; Rectangle aObjRect(bBoundRects?pObj->GetCurrentBoundRect():pObj->GetSnapRect()); - switch (eVert) { + switch (eVert) + { case SDRVALIGN_TOP : nYMov=aBound.Top() -aObjRect.Top() ; break; case SDRVALIGN_BOTTOM: nYMov=aBound.Bottom()-aObjRect.Bottom() ; break; case SDRVALIGN_CENTER: nYMov=aCenter.Y() -aObjRect.Center().Y(); break; default: break; } - switch (eHor) { + switch (eHor) + { case SDRHALIGN_LEFT : nXMov=aBound.Left() -aObjRect.Left() ; break; case SDRHALIGN_RIGHT : nXMov=aBound.Right() -aObjRect.Right() ; break; case SDRHALIGN_CENTER: nXMov=aCenter.X() -aObjRect.Center().X(); break; @@ -1581,17 +1762,22 @@ void SdrEditView::AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert, BOOL { // #104104# SdrEdgeObj needs an extra SdrUndoGeoObj since the // connections may need to be saved - if(pObj && pObj->ISA(SdrEdgeObj)) + if( bUndo ) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); - } + if( dynamic_cast<SdrEdgeObj*>(pObj) ) + { + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); + } - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pObj,Size(nXMov,nYMov))); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pObj,Size(nXMov,nYMov))); + } pObj->Move(Size(nXMov,nYMov)); } } } - EndUndo(); + + if( bUndo ) + EndUndo(); } diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx index 68b1679dff49..8a9c80c37ec7 100644 --- a/svx/source/svdraw/svdedtv2.cxx +++ b/svx/source/svdraw/svdedtv2.cxx @@ -98,22 +98,30 @@ void SdrEditView::ObjOrderChanged(SdrObject* /*pObj*/, ULONG /*nOldPos*/, ULONG void SdrEditView::MovMarkedToTop() { ULONG nAnz=GetMarkedObjectCount(); - if (nAnz!=0) { - BegUndo(ImpGetResStr(STR_EditMovToTop),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_MOVTOTOP); + if (nAnz!=0) + { + const bool bUndo = IsUndoEnabled(); + + if( bUndo ) + BegUndo(ImpGetResStr(STR_EditMovToTop),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_MOVTOTOP); + SortMarkedObjects(); ULONG nm; - for (nm=0; nm<nAnz; nm++) { // Ordnums muessen alle stimmen! + for (nm=0; nm<nAnz; nm++) + { // Ordnums muessen alle stimmen! GetMarkedObjectByIndex(nm)->GetOrdNum(); } BOOL bChg=FALSE; SdrObjList* pOL0=NULL; ULONG nNewPos=0; - for (nm=nAnz; nm>0;) { + for (nm=nAnz; nm>0;) + { nm--; SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pObj=pM->GetMarkedSdrObj(); SdrObjList* pOL=pObj->GetObjList(); - if (pOL!=pOL0) { + if (pOL!=pOL0) + { nNewPos=ULONG(pOL->GetObjCount()-1); pOL0=pOL; } @@ -121,58 +129,87 @@ void SdrEditView::MovMarkedToTop() const Rectangle& rBR=pObj->GetCurrentBoundRect(); ULONG nCmpPos=nNowPos+1; SdrObject* pMaxObj=GetMaxToTopObj(pObj); - if (pMaxObj!=NULL) { + if (pMaxObj!=NULL) + { ULONG nMaxPos=pMaxObj->GetOrdNum(); - if (nMaxPos!=0) nMaxPos--; - if (nNewPos>nMaxPos) nNewPos=nMaxPos; // diesen nicht ueberholen. - if (nNewPos<nNowPos) nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben + if (nMaxPos!=0) + nMaxPos--; + if (nNewPos>nMaxPos) + nNewPos=nMaxPos; // diesen nicht ueberholen. + if (nNewPos<nNowPos) + nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben } BOOL bEnd=FALSE; - while (nCmpPos<nNewPos && !bEnd) { + while (nCmpPos<nNewPos && !bEnd) + { SdrObject* pCmpObj=pOL->GetObj(nCmpPos); - if (pCmpObj==NULL) { + if (pCmpObj==NULL) + { DBG_ERROR("MovMarkedToTop(): Vergleichsobjekt nicht gefunden"); bEnd=TRUE; - } else if (pCmpObj==pMaxObj) { + } + else if (pCmpObj==pMaxObj) + { nNewPos=nCmpPos; nNewPos--; bEnd=TRUE; - } else if (rBR.IsOver(pCmpObj->GetCurrentBoundRect())) { + } + else if (rBR.IsOver(pCmpObj->GetCurrentBoundRect())) + { nNewPos=nCmpPos; bEnd=TRUE; - } else nCmpPos++; + } + else + { + nCmpPos++; + } } - if (nNowPos!=nNewPos) { + if (nNowPos!=nNewPos) + { bChg=TRUE; pOL->SetObjectOrdNum(nNowPos,nNewPos); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos)); ObjOrderChanged(pObj,nNowPos,nNewPos); } nNewPos--; } - EndUndo(); - if (bChg) MarkListHasChanged(); + + if( bUndo ) + EndUndo(); + + if (bChg) + MarkListHasChanged(); } } void SdrEditView::MovMarkedToBtm() { ULONG nAnz=GetMarkedObjectCount(); - if (nAnz!=0) { - BegUndo(ImpGetResStr(STR_EditMovToBtm),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_MOVTOBTM); + if (nAnz!=0) + { + const bool bUndo = IsUndoEnabled(); + + if( bUndo ) + BegUndo(ImpGetResStr(STR_EditMovToBtm),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_MOVTOBTM); + SortMarkedObjects(); ULONG nm; - for (nm=0; nm<nAnz; nm++) { // Ordnums muessen alle stimmen! + for (nm=0; nm<nAnz; nm++) + { // Ordnums muessen alle stimmen! GetMarkedObjectByIndex(nm)->GetOrdNum(); } + BOOL bChg=FALSE; SdrObjList* pOL0=NULL; ULONG nNewPos=0; - for (nm=0; nm<nAnz; nm++) { + for (nm=0; nm<nAnz; nm++) + { SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pObj=pM->GetMarkedSdrObj(); SdrObjList* pOL=pObj->GetObjList(); - if (pOL!=pOL0) { + if (pOL!=pOL0) + { nNewPos=0; pOL0=pOL; } @@ -180,39 +217,58 @@ void SdrEditView::MovMarkedToBtm() const Rectangle& rBR=pObj->GetCurrentBoundRect(); ULONG nCmpPos=nNowPos; if (nCmpPos>0) nCmpPos--; SdrObject* pMaxObj=GetMaxToBtmObj(pObj); - if (pMaxObj!=NULL) { + if (pMaxObj!=NULL) + { ULONG nMinPos=pMaxObj->GetOrdNum()+1; - if (nNewPos<nMinPos) nNewPos=nMinPos; // diesen nicht ueberholen. - if (nNewPos>nNowPos) nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben + if (nNewPos<nMinPos) + nNewPos=nMinPos; // diesen nicht ueberholen. + if (nNewPos>nNowPos) + nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben } BOOL bEnd=FALSE; // nNewPos ist an dieser Stelle noch die maximale Position, // an der das Obj hinruecken darf, ohne seinen Vorgaenger // (Mehrfachselektion) zu ueberholen. - while (nCmpPos>nNewPos && !bEnd) { + while (nCmpPos>nNewPos && !bEnd) + { SdrObject* pCmpObj=pOL->GetObj(nCmpPos); - if (pCmpObj==NULL) { + if (pCmpObj==NULL) + { DBG_ERROR("MovMarkedToBtm(): Vergleichsobjekt nicht gefunden"); bEnd=TRUE; - } else if (pCmpObj==pMaxObj) { + } + else if (pCmpObj==pMaxObj) + { nNewPos=nCmpPos; nNewPos++; bEnd=TRUE; - } else if (rBR.IsOver(pCmpObj->GetCurrentBoundRect())) { + } + else if (rBR.IsOver(pCmpObj->GetCurrentBoundRect())) + { nNewPos=nCmpPos; bEnd=TRUE; - } else nCmpPos--; + } + else + { + nCmpPos--; + } } - if (nNowPos!=nNewPos) { + if (nNowPos!=nNewPos) + { bChg=TRUE; pOL->SetObjectOrdNum(nNowPos,nNewPos); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos)); ObjOrderChanged(pObj,nNowPos,nNewPos); } nNewPos++; } - EndUndo(); - if (bChg) MarkListHasChanged(); + + if(bUndo) + EndUndo(); + + if(bChg) + MarkListHasChanged(); } } @@ -224,10 +280,16 @@ void SdrEditView::PutMarkedToTop() void SdrEditView::PutMarkedInFrontOfObj(const SdrObject* pRefObj) { ULONG nAnz=GetMarkedObjectCount(); - if (nAnz!=0) { - BegUndo(ImpGetResStr(STR_EditPutToTop),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_PUTTOTOP); + if (nAnz!=0) + { + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(ImpGetResStr(STR_EditPutToTop),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_PUTTOTOP); + SortMarkedObjects(); - if (pRefObj!=NULL) { + + if (pRefObj!=NULL) + { // Damit "Vor das Objekt" auch funktioniert wenn die // markierten Objekte bereits vor dem Objekt stehen ULONG nRefMark=TryToFindMarkedObject(pRefObj); @@ -245,50 +307,70 @@ void SdrEditView::PutMarkedInFrontOfObj(const SdrObject* pRefObj) } } ULONG nm; - for (nm=0; nm<nAnz; nm++) { // Ordnums muessen alle stimmen! + for (nm=0; nm<nAnz; nm++) + { // Ordnums muessen alle stimmen! GetMarkedObjectByIndex(nm)->GetOrdNum(); } BOOL bChg=FALSE; SdrObjList* pOL0=NULL; ULONG nNewPos=0; - for (nm=nAnz; nm>0;) { + for (nm=nAnz; nm>0;) + { nm--; SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pObj=pM->GetMarkedSdrObj(); - if (pObj!=pRefObj) { + if (pObj!=pRefObj) + { SdrObjList* pOL=pObj->GetObjList(); - if (pOL!=pOL0) { + if (pOL!=pOL0) + { nNewPos=ULONG(pOL->GetObjCount()-1); pOL0=pOL; } ULONG nNowPos=pObj->GetOrdNumDirect(); SdrObject* pMaxObj=GetMaxToTopObj(pObj); - if (pMaxObj!=NULL) { + if (pMaxObj!=NULL) + { ULONG nMaxOrd=pMaxObj->GetOrdNum(); // geht leider nicht anders - if (nMaxOrd>0) nMaxOrd--; - if (nNewPos>nMaxOrd) nNewPos=nMaxOrd; // nicht ueberholen. - if (nNewPos<nNowPos) nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben + if (nMaxOrd>0) + nMaxOrd--; + if (nNewPos>nMaxOrd) + nNewPos=nMaxOrd; // nicht ueberholen. + if (nNewPos<nNowPos) + nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben } - if (pRefObj!=NULL) { - if (pRefObj->GetObjList()==pObj->GetObjList()) { + if (pRefObj!=NULL) + { + if (pRefObj->GetObjList()==pObj->GetObjList()) + { ULONG nMaxOrd=pRefObj->GetOrdNum(); // geht leider nicht anders - if (nNewPos>nMaxOrd) nNewPos=nMaxOrd; // nicht ueberholen. - if (nNewPos<nNowPos) nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben - } else { + if (nNewPos>nMaxOrd) + nNewPos=nMaxOrd; // nicht ueberholen. + if (nNewPos<nNowPos) + nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben + } + else + { nNewPos=nNowPos; // andere PageView, also nicht veraendern } } - if (nNowPos!=nNewPos) { + if (nNowPos!=nNewPos) + { bChg=TRUE; pOL->SetObjectOrdNum(nNowPos,nNewPos); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos)); ObjOrderChanged(pObj,nNowPos,nNewPos); } nNewPos--; } // if (pObj!=pRefObj) } // for-Schleife ueber alle Markierten Objekte - EndUndo(); - if (bChg) MarkListHasChanged(); + + if( bUndo ) + EndUndo(); + + if(bChg) + MarkListHasChanged(); } } @@ -300,10 +382,16 @@ void SdrEditView::PutMarkedToBtm() void SdrEditView::PutMarkedBehindObj(const SdrObject* pRefObj) { ULONG nAnz=GetMarkedObjectCount(); - if (nAnz!=0) { - BegUndo(ImpGetResStr(STR_EditPutToBtm),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_PUTTOBTM); + if (nAnz!=0) + { + const bool bUndo = IsUndoEnabled(); + + if( bUndo ) + BegUndo(ImpGetResStr(STR_EditPutToBtm),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_PUTTOBTM); + SortMarkedObjects(); - if (pRefObj!=NULL) { + if (pRefObj!=NULL) + { // Damit "Hinter das Objekt" auch funktioniert wenn die // markierten Objekte bereits hinter dem Objekt stehen ULONG nRefMark=TryToFindMarkedObject(pRefObj); @@ -355,14 +443,19 @@ void SdrEditView::PutMarkedBehindObj(const SdrObject* pRefObj) if (nNowPos!=nNewPos) { bChg=TRUE; pOL->SetObjectOrdNum(nNowPos,nNewPos); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos)); ObjOrderChanged(pObj,nNowPos,nNewPos); } nNewPos++; } // if (pObj!=pRefObj) } // for-Schleife ueber alle markierten Objekte - EndUndo(); - if (bChg) MarkListHasChanged(); + + if(bUndo) + EndUndo(); + + if(bChg) + MarkListHasChanged(); } } @@ -370,10 +463,15 @@ void SdrEditView::ReverseOrderOfMarked() { SortMarkedObjects(); ULONG nMarkAnz=GetMarkedObjectCount(); - if (nMarkAnz>0) { + if (nMarkAnz>0) + { //BOOL bNeedBundle=FALSE; BOOL bChg=FALSE; - BegUndo(ImpGetResStr(STR_EditRevOrder),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_REVORDER); + + bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(ImpGetResStr(STR_EditRevOrder),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_REVORDER); + ULONG a=0; do { // Markierung ueber mehrere PageViews berueksichtigen @@ -390,8 +488,11 @@ void SdrEditView::ReverseOrderOfMarked() SdrObject* pObj2=GetMarkedObjectByIndex(c); ULONG nOrd1=pObj1->GetOrdNumDirect(); ULONG nOrd2=pObj2->GetOrdNumDirect(); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj1,nOrd1,nOrd2)); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj2,nOrd2-1,nOrd1)); + if( bUndo ) + { + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj1,nOrd1,nOrd2)); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj2,nOrd2-1,nOrd1)); + } pOL->SetObjectOrdNum(nOrd1,nOrd2); // Obj 2 ist um eine Position nach vorn gerutscht, deshalb nun nOrd2-1 pOL->SetObjectOrdNum(nOrd2-1,nOrd1); @@ -401,16 +502,22 @@ void SdrEditView::ReverseOrderOfMarked() } a=b+1; } while (a<nMarkAnz); - EndUndo(); - if (bChg) MarkListHasChanged(); + + if(bUndo) + EndUndo(); + + if(bChg) + MarkListHasChanged(); } } void SdrEditView::ImpCheckToTopBtmPossible() { ULONG nAnz=GetMarkedObjectCount(); - if (nAnz==0) return; - if (nAnz==1) { // Sonderbehandlung fuer Einzelmarkierung + if (nAnz==0) + return; + if (nAnz==1) + { // Sonderbehandlung fuer Einzelmarkierung SdrObject* pObj=GetMarkedObjectByIndex(0); SdrObjList* pOL=pObj->GetObjList(); ULONG nMax=pOL->GetObjCount(); @@ -700,8 +807,6 @@ DECLARE_LIST(ImpDistributeEntryList, ImpDistributeEntry*) void SdrEditView::DistributeMarkedObjects() { -#ifndef SVX_LIGHT - UINT32 nMark(GetMarkedObjectCount()); if(nMark > 2) @@ -723,7 +828,9 @@ void SdrEditView::DistributeMarkedObjects() ImpDistributeEntryList aEntryList; UINT32 a, nInsPos, nFullLength; - BegUndo(); + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(); if(eHor != SvxDistributeHorizontalNone) { @@ -785,7 +892,8 @@ void SdrEditView::DistributeMarkedObjects() ImpDistributeEntry* pCurr = aEntryList.GetObject(a); ImpDistributeEntry* pNext = aEntryList.GetObject(a+1); INT32 nDelta = (INT32)(fStepStart + 0.5) - pCurr->mnPos; - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj)); pCurr->mpObj->Move(Size(nDelta, 0)); fStepStart += fStepWidth + (double)((pCurr->mnLength + pNext->mnLength) / 2); } @@ -803,7 +911,8 @@ void SdrEditView::DistributeMarkedObjects() { ImpDistributeEntry* pCurr = aEntryList.GetObject(a); INT32 nDelta = (INT32)(fStepStart + 0.5) - pCurr->mnPos; - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj)); pCurr->mpObj->Move(Size(nDelta, 0)); fStepStart += fStepWidth; } @@ -874,7 +983,8 @@ void SdrEditView::DistributeMarkedObjects() ImpDistributeEntry* pCurr = aEntryList.GetObject(a); ImpDistributeEntry* pNext = aEntryList.GetObject(a+1); INT32 nDelta = (INT32)(fStepStart + 0.5) - pCurr->mnPos; - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj)); pCurr->mpObj->Move(Size(0, nDelta)); fStepStart += fStepWidth + (double)((pCurr->mnLength + pNext->mnLength) / 2); } @@ -892,7 +1002,8 @@ void SdrEditView::DistributeMarkedObjects() { ImpDistributeEntry* pCurr = aEntryList.GetObject(a); INT32 nDelta = (INT32)(fStepStart + 0.5) - pCurr->mnPos; - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj)); pCurr->mpObj->Move(Size(0, nDelta)); fStepStart += fStepWidth; } @@ -905,13 +1016,14 @@ void SdrEditView::DistributeMarkedObjects() // UNDO-Comment and end of UNDO SetUndoComment(ImpGetResStr(STR_DistributeMarkedObjects)); - EndUndo(); + + if( bUndo ) + EndUndo(); } delete(pDlg); } } -#endif } void SdrEditView::MergeMarkedObjects(SdrMergeMode eMode) @@ -921,7 +1033,11 @@ void SdrEditView::MergeMarkedObjects(SdrMergeMode eMode) { SdrMarkList aRemove; SortMarkedObjects(); - BegUndo(); + + const bool bUndo = IsUndoEnabled(); + + if( bUndo ) + BegUndo(); UINT32 nInsPos=0xFFFFFFFF; const SdrObject* pAttrObj = NULL; @@ -1044,7 +1160,8 @@ void SdrEditView::MergeMarkedObjects(SdrMergeMode eMode) ImpCopyAttributes(pAttrObj, pPath); SdrInsertReason aReason(SDRREASON_VIEWCALL, pAttrObj); pInsOL->InsertObject(pPath, nInsPos, &aReason); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath)); MarkObj(pPath, pInsPV, FALSE, TRUE); } @@ -1075,7 +1192,8 @@ void SdrEditView::MergeMarkedObjects(SdrMergeMode eMode) } DeleteMarkedList(aRemove); - EndUndo(); + if( bUndo ) + EndUndo(); } } @@ -1084,8 +1202,11 @@ void SdrEditView::CombineMarkedObjects(sal_Bool bNoPolyPoly) // #105899# Start of Combine-Undo put to front, else ConvertMarkedToPolyObj would // create a 2nd Undo-action and Undo-Comment. + bool bUndo = IsUndoEnabled(); + // Undo-String will be set later - BegUndo(String(), String(), bNoPolyPoly ? SDRREPFUNC_OBJ_COMBINE_ONEPOLY : SDRREPFUNC_OBJ_COMBINE_POLYPOLY); + if( bUndo ) + BegUndo(String(), String(), bNoPolyPoly ? SDRREPFUNC_OBJ_COMBINE_ONEPOLY : SDRREPFUNC_OBJ_COMBINE_POLYPOLY); // #105899# First, guarantee that all objects are converted to polyobjects, // especially for SdrGrafObj with bitmap filling this is necessary to not @@ -1228,7 +1349,8 @@ void SdrEditView::CombineMarkedObjects(sal_Bool bNoPolyPoly) SdrInsertReason aReason(SDRREASON_VIEWCALL,pAttrObj); pInsOL->InsertObject(pPath,nInsPos,&aReason); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath)); // #111111# // Here was a severe error: Without UnmarkAllObj, the new object was marked @@ -1241,11 +1363,13 @@ void SdrEditView::CombineMarkedObjects(sal_Bool bNoPolyPoly) // UndoComment aus den tatsaechlich verwendeten Objekten zusammenbauen aRemoveMerker.ForceSort(); // wichtig fuer Remove (s.u.) - SetUndoComment(ImpGetResStr(bNoPolyPoly?STR_EditCombine_OnePoly:STR_EditCombine_PolyPoly),aRemoveMerker.GetMarkDescription()); + if( bUndo ) + SetUndoComment(ImpGetResStr(bNoPolyPoly?STR_EditCombine_OnePoly:STR_EditCombine_PolyPoly),aRemoveMerker.GetMarkDescription()); // die tatsaechlich verwendeten Objekten aus der Liste entfernen DeleteMarkedList(aRemoveMerker); - EndUndo(); + if( bUndo ) + EndUndo(); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1368,6 +1492,8 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL, const SdrPathObj* pSrcPath = PTR_CAST(SdrPathObj, pObj); const SdrObjCustomShape* pCustomShape = PTR_CAST(SdrObjCustomShape, pObj); + const bool bUndo = IsUndoEnabled(); + if(pSrcPath) { // #i74631# redesigned due to XpolyPolygon removal and explicit constructors @@ -1387,7 +1513,8 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL, pLast = pPath; SdrInsertReason aReason(SDRREASON_VIEWCALL, pSrcPath); rOL.InsertObject(pPath, rPos, &aReason); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath, TRUE)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath, TRUE)); MarkObj(pPath, pPV, FALSE, TRUE); rPos++; } @@ -1421,7 +1548,8 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL, pLast = pPath; SdrInsertReason aReason(SDRREASON_VIEWCALL, pSrcPath); rOL.InsertObject(pPath, rPos, &aReason); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath, TRUE)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath, TRUE)); MarkObj(pPath, pPV, FALSE, TRUE); rPos++; } @@ -1456,7 +1584,8 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL, SdrInsertReason aReason(SDRREASON_VIEWCALL, pCustomShape); rOL.InsertObject(pCandidate, rPos, &aReason); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pCandidate, true)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pCandidate, true)); MarkObj(pCandidate, pPV, FALSE, TRUE); if(pCustomShape->HasText() && !pCustomShape->IsTextPath()) @@ -1500,7 +1629,8 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL, // insert object rOL.InsertObject(pTextObj, rPos + 1, &aReason); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pTextObj, true)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pTextObj, true)); MarkObj(pTextObj, pPV, FALSE, TRUE); } } @@ -1515,9 +1645,15 @@ void SdrEditView::DismantleMarkedObjects(BOOL bMakeLines) SdrMarkList aRemoveMerker; SortMarkedObjects(); - // Der Comment wird spaeter zusammengebaut - BegUndo(String(), String(), - bMakeLines ? SDRREPFUNC_OBJ_DISMANTLE_LINES : SDRREPFUNC_OBJ_DISMANTLE_POLYS); + + const bool bUndo = IsUndoEnabled(); + + if( bUndo ) + { + // Der Comment wird spaeter zusammengebaut + BegUndo(String(), String(), + bMakeLines ? SDRREPFUNC_OBJ_DISMANTLE_LINES : SDRREPFUNC_OBJ_DISMANTLE_POLYS); + } ULONG nm; ULONG nAnz=GetMarkedObjectCount(); @@ -1543,14 +1679,22 @@ void SdrEditView::DismantleMarkedObjects(BOOL bMakeLines) } else { ImpDismantleOneObject(pObj,*pOL,nPos,pPV,bMakeLines); } - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj,TRUE)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj,TRUE)); pOL->RemoveObject(nPos0); + + if( !bUndo ) + SdrObject::Free(pObj); } } - // UndoComment aus den tatsaechlich verwendeten Objekten zusammenbauen - SetUndoComment(ImpGetResStr(bMakeLines?STR_EditDismantle_Lines:STR_EditDismantle_Polys),aRemoveMerker.GetMarkDescription()); - // die tatsaechlich verwendeten Objekten aus der Liste entfernen - EndUndo(); + + if( bUndo ) + { + // UndoComment aus den tatsaechlich verwendeten Objekten zusammenbauen + SetUndoComment(ImpGetResStr(bMakeLines?STR_EditDismantle_Lines:STR_EditDismantle_Polys),aRemoveMerker.GetMarkDescription()); + // die tatsaechlich verwendeten Objekten aus der Liste entfernen + EndUndo(); + } } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1565,17 +1709,26 @@ void SdrEditView::DismantleMarkedObjects(BOOL bMakeLines) void SdrEditView::GroupMarked(const SdrObject* pUserGrp) { - if (AreObjectsMarked()) { - BegUndo(ImpGetResStr(STR_EditGroup),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_GROUP); + if (AreObjectsMarked()) + { SortMarkedObjects(); - ULONG nAnz=GetMarkedObjectCount(); - for (ULONG nm=nAnz; nm>0;) { // UndoActions fuer alle betroffenen Objekte anlegen - nm--; - SdrMark* pM=GetSdrMarkByIndex(nm); - SdrObject* pObj = pM->GetMarkedSdrObj(); - std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pObj ) ); - AddUndoActions( vConnectorUndoActions ); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoRemoveObject( *pObj )); + + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + { + BegUndo(ImpGetResStr(STR_EditGroup),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_GROUP); + + const ULONG nAnz = GetMarkedObjectCount(); + for(ULONG nm = nAnz; nm>0; ) + { + // UndoActions fuer alle betroffenen Objekte anlegen + nm--; + SdrMark* pM=GetSdrMarkByIndex(nm); + SdrObject* pObj = pM->GetMarkedSdrObj(); + std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pObj ) ); + AddUndoActions( vConnectorUndoActions ); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoRemoveObject( *pObj )); + } } SdrMarkList aNewMark; @@ -1588,7 +1741,8 @@ void SdrEditView::GroupMarked(const SdrObject* pUserGrp) SdrObjList* pSrcLst0=pSrcLst; SdrPage* pPage=pPV->GetPage(); // sicherstellen, dass die OrdNums stimmen - if (pSrcLst->IsObjOrdNumsDirty()) pSrcLst->RecalcObjOrdNums(); + if (pSrcLst->IsObjOrdNumsDirty()) + pSrcLst->RecalcObjOrdNums(); SdrObject* pGrp=NULL; SdrObject* pRefObj=NULL; // Referenz fuer InsertReason (-> rumankern im Writer) SdrObject* pRefObj1=NULL; // Referenz fuer InsertReason (-> rumankern im Writer) @@ -1597,55 +1751,75 @@ void SdrEditView::GroupMarked(const SdrObject* pUserGrp) // kommen, kommt das Gruppenobjekt an das Ende der Liste. ULONG nInsPos=pSrcLst->GetObjCount(); BOOL bNeedInsPos=TRUE; - for (ULONG nm=GetMarkedObjectCount(); nm>0;) { + for (ULONG nm=GetMarkedObjectCount(); nm>0;) + { nm--; SdrMark* pM=GetSdrMarkByIndex(nm); - if (pM->GetPageView()==pPV) { - if (pGrp==NULL) { - if (pUserGrp!=NULL) pGrp=pUserGrp->Clone(); - if (pGrp==NULL) pGrp=new SdrObjGroup; + if (pM->GetPageView()==pPV) + { + if (pGrp==NULL) + { + if (pUserGrp!=NULL) + pGrp=pUserGrp->Clone(); + if (pGrp==NULL) + pGrp=new SdrObjGroup; pDstLst=pGrp->GetSubList(); DBG_ASSERT(pDstLst!=NULL,"Angebliches Gruppenobjekt liefert keine Objektliste"); } SdrObject* pObj=pM->GetMarkedSdrObj(); pSrcLst=pObj->GetObjList(); - if (pSrcLst!=pSrcLst0) { - if (pSrcLst->IsObjOrdNumsDirty()) pSrcLst->RecalcObjOrdNums(); + if (pSrcLst!=pSrcLst0) + { + if (pSrcLst->IsObjOrdNumsDirty()) + pSrcLst->RecalcObjOrdNums(); } BOOL bForeignList=pSrcLst!=pAktLst; BOOL bGrouped=pSrcLst!=pPage; - if (!bForeignList && bNeedInsPos) { + if (!bForeignList && bNeedInsPos) + { nInsPos=pObj->GetOrdNum(); // ua, damit sind alle ObjOrdNum der Page gesetzt nInsPos++; bNeedInsPos=FALSE; } pSrcLst->RemoveObject(pObj->GetOrdNumDirect()); - if (!bForeignList) nInsPos--; // InsertPos korregieren + if (!bForeignList) + nInsPos--; // InsertPos korregieren SdrInsertReason aReason(SDRREASON_VIEWCALL); pDstLst->InsertObject(pObj,0,&aReason); GetMarkedObjectListWriteAccess().DeleteMark(nm); - if (pRefObj1==NULL) pRefObj1=pObj; // Das oberste sichtbare Objekt - if (!bGrouped) { - if (pRefObj==NULL) pRefObj=pObj; // Das oberste sichtbare nicht gruppierte Objekt + if (pRefObj1==NULL) + pRefObj1=pObj; // Das oberste sichtbare Objekt + if (!bGrouped) + { + if (pRefObj==NULL) + pRefObj=pObj; // Das oberste sichtbare nicht gruppierte Objekt } pSrcLst0=pSrcLst; } } - if (pRefObj==NULL) pRefObj=pRefObj1; - if (pGrp!=NULL) { + if (pRefObj==NULL) + pRefObj=pRefObj1; + if (pGrp!=NULL) + { aNewMark.InsertEntry(SdrMark(pGrp,pPV)); - ULONG nAnz2=pDstLst->GetObjCount(); + ULONG nAnz=pDstLst->GetObjCount(); SdrInsertReason aReason(SDRREASON_VIEWCALL,pRefObj); pAktLst->InsertObject(pGrp,nInsPos,&aReason); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pGrp,true)); // Kein Recalc! - for (ULONG no=0; no<nAnz2; no++) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoInsertObject(*pDstLst->GetObj(no))); + if( bUndo ) + { + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pGrp,true)); // Kein Recalc! + for (ULONG no=0; no<nAnz; no++) + { + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoInsertObject(*pDstLst->GetObj(no))); + } } } } GetMarkedObjectListWriteAccess().Merge(aNewMark); MarkListHasChanged(); - EndUndo(); + + if( bUndo ) + EndUndo(); } } @@ -1663,7 +1837,10 @@ void SdrEditView::UnGroupMarked() { SdrMarkList aNewMark; - BegUndo(String(), String(), SDRREPFUNC_OBJ_UNGROUP); + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(String(), String(), SDRREPFUNC_OBJ_UNGROUP); + ULONG nCount=0; XubString aName1; XubString aName; @@ -1697,16 +1874,23 @@ void SdrEditView::UnGroupMarked() // when AddUndo(new SdrUndoDelObj(*pGrp)) is called. ULONG nAnz=pSrcLst->GetObjCount(); ULONG no; - for (no=nAnz; no>0;) { - no--; - SdrObject* pObj=pSrcLst->GetObj(no); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoRemoveObject(*pObj)); + + if( bUndo ) + { + for (no=nAnz; no>0;) + { + no--; + SdrObject* pObj=pSrcLst->GetObj(no); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoRemoveObject(*pObj)); + } } - for (no=0; no<nAnz; no++) { + for (no=0; no<nAnz; no++) + { SdrObject* pObj=pSrcLst->RemoveObject(0); SdrInsertReason aReason(SDRREASON_VIEWCALL,pGrp); pDstLst->InsertObject(pObj,nDstCnt,&aReason); - AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoInsertObject(*pObj,true)); + if( bUndo ) + AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoInsertObject(*pObj,true)); nDstCnt++; // Kein SortCheck beim einfuegen in die MarkList, denn das // wuerde wg. pObj->GetOrdNum() jedesmal ein RecalcOrdNums() @@ -1714,22 +1898,32 @@ void SdrEditView::UnGroupMarked() aNewMark.InsertEntry(SdrMark(pObj,pM->GetPageView()),FALSE); } - // Now it is safe to add the delete-UNDO which trigers the - // MigrateItemPool now only for itself, not for the subobjects. - // nDstCnt is right, because previous inserts move group - // object deeper and increase nDstCnt. - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pGrp)); + if( bUndo ) + { + // Now it is safe to add the delete-UNDO which trigers the + // MigrateItemPool now only for itself, not for the subobjects. + // nDstCnt is right, because previous inserts move group + // object deeper and increase nDstCnt. + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pGrp)); + } pDstLst->RemoveObject(nDstCnt); + if( !bUndo ) + SdrObject::Free(pGrp); + GetMarkedObjectListWriteAccess().DeleteMark(nm); } } if (nCount!=0) { - if (!bNameOk) aName=ImpGetResStr(STR_ObjNamePluralGRUP); // Oberbegriff Gruppenobjekte verwenden, wenn verschiedene Objekte. + if (!bNameOk) + aName=ImpGetResStr(STR_ObjNamePluralGRUP); // Oberbegriff Gruppenobjekte verwenden, wenn verschiedene Objekte. SetUndoComment(ImpGetResStr(STR_EditUngroup),aName); } - EndUndo(); + + if( bUndo ) + EndUndo(); + if (nCount!=0) { GetMarkedObjectListWriteAccess().Merge(aNewMark,TRUE); // Durch das obige Einsortieren ist aNewMark genau verkehrtherum @@ -1750,12 +1944,20 @@ void SdrEditView::UnGroupMarked() SdrObject* SdrEditView::ImpConvertOneObj(SdrObject* pObj, BOOL bPath, BOOL bLineToArea) { SdrObject* pNewObj = pObj->ConvertToPolyObj(bPath, bLineToArea); - if (pNewObj!=NULL) { + if (pNewObj!=NULL) + { SdrObjList* pOL=pObj->GetObjList(); DBG_ASSERT(pOL!=NULL,"ConvertTo: Obj liefert keine ObjList"); - if (pOL!=NULL) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoReplaceObject(*pObj,*pNewObj)); + if (pOL!=NULL) + { + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoReplaceObject(*pObj,*pNewObj)); + pOL->ReplaceObject(pNewObj,pObj->GetOrdNum()); + + if( !bUndo ) + SdrObject::Free(pObj); } } return pNewObj; @@ -1838,7 +2040,11 @@ void SdrEditView::ConvertMarkedToPolyObj(BOOL bLineToArea) void SdrEditView::DoImportMarkedMtf(SvdProgressInfo *pProgrInfo) { - BegUndo(String(), String(), SDRREPFUNC_OBJ_IMPORTMTF); + const bool bUndo = IsUndoEnabled(); + + if( bUndo ) + BegUndo(String(), String(), SDRREPFUNC_OBJ_IMPORTMTF); + SortMarkedObjects(); SdrMarkList aForTheDescription; SdrMarkList aNewMarked; @@ -1878,10 +2084,13 @@ void SdrEditView::DoImportMarkedMtf(SvdProgressInfo *pProgrInfo) aFilter.SetLayer(pObj->GetLayer()); nInsAnz=aFilter.DoImport(pOle2->GetGraphic()->GetGDIMetaFile(),*pOL,nInsPos,pProgrInfo); } - if (nInsAnz!=0) { + if (nInsAnz!=0) + { ULONG nObj=nInsPos; - for (ULONG i=0; i<nInsAnz; i++) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pOL->GetObj(nObj))); + for (ULONG i=0; i<nInsAnz; i++) + { + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pOL->GetObj(nObj))); // Neue MarkList pflegen SdrMark aNewMark(pOL->GetObj(nObj), pPV); @@ -1890,11 +2099,16 @@ void SdrEditView::DoImportMarkedMtf(SvdProgressInfo *pProgrInfo) nObj++; } aForTheDescription.InsertEntry(*pM); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); + + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); // Objekt aus selektion loesen und loeschen GetMarkedObjectListWriteAccess().DeleteMark(TryToFindMarkedObject(pObj)); pOL->RemoveObject(nInsPos-1); + + if( !bUndo ) + SdrObject::Free(pObj); } } @@ -1910,7 +2124,10 @@ void SdrEditView::DoImportMarkedMtf(SvdProgressInfo *pProgrInfo) SortMarkedObjects(); } - SetUndoComment(ImpGetResStr(STR_EditImportMtf),aForTheDescription.GetMarkDescription()); - EndUndo(); + if( bUndo ) + { + SetUndoComment(ImpGetResStr(STR_EditImportMtf),aForTheDescription.GetMarkDescription()); + EndUndo(); + } } diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index 49ba83ed35ae..75ce75240a6f 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -858,7 +858,8 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(sal_Bool bDontDeleteReally) pTextEditCursorMerker=NULL; aTextEditArea=Rectangle(); - if (pTEOutliner!=NULL) { + if (pTEOutliner!=NULL) + { BOOL bModified=pTEOutliner->IsModified(); if (pTEOutlinerView!=NULL) { @@ -886,9 +887,13 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(sal_Bool bDontDeleteReally) pTEOutliner->SetBeginPasteOrDropHdl(Link()); pTEOutliner->SetEndPasteOrDropHdl(Link()); - XubString aObjName; - pTEObj->TakeObjNameSingul(aObjName); - BegUndo(ImpGetResStr(STR_UndoObjSetText),aObjName); + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + { + XubString aObjName; + pTEObj->TakeObjNameSingul(aObjName); + BegUndo(ImpGetResStr(STR_UndoObjSetText),aObjName); + } pTEObj->EndTextEdit(*pTEOutliner); @@ -922,25 +927,43 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(sal_Bool bDontDeleteReally) if(pTEObj->IsInserted() && bDelObj && pTextObj->GetObjInventor()==SdrInventor && !bDontDeleteReally) { SdrObjKind eIdent=(SdrObjKind)pTextObj->GetObjIdentifier(); - if (eIdent==OBJ_TEXT || eIdent==OBJ_TEXTEXT) + if(eIdent==OBJ_TEXT || eIdent==OBJ_TEXTEXT) { pDelUndo= GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pTEObj); } } } - if (pTxtUndo!=NULL) { AddUndo(pTxtUndo); eRet=SDRENDTEXTEDIT_CHANGED; } - if (pDelUndo!=NULL) { - AddUndo(pDelUndo); + if (pTxtUndo!=NULL) + { + if( bUndo ) + AddUndo(pTxtUndo); + eRet=SDRENDTEXTEDIT_CHANGED; + } + if (pDelUndo!=NULL) + { + if( bUndo ) + { + AddUndo(pDelUndo); + } + else + { + delete pDelUndo; + } eRet=SDRENDTEXTEDIT_DELETED; DBG_ASSERT(pTEObj->GetObjList()!=NULL,"SdrObjEditView::SdrEndTextEdit(): Fatal: Editiertes Objekt hat keine ObjList!"); - if (pTEObj->GetObjList()!=NULL) { + if (pTEObj->GetObjList()!=NULL) + { pTEObj->GetObjList()->RemoveObject(pTEObj->GetOrdNum()); CheckMarked(); // und gleich die Maekierung entfernen... } - } else if (bDelObj) { // Fuer den Writer: Loeschen muss die App nachholen. + } + else if (bDelObj) + { // Fuer den Writer: Loeschen muss die App nachholen. eRet=SDRENDTEXTEDIT_SHOULDBEDELETED; } - EndUndo(); // EndUndo hinter Remove, falls der UndoStack gleich weggehaun' wird + + if( bUndo ) + EndUndo(); // EndUndo hinter Remove, falls der UndoStack gleich weggehaun' wird // #111096# // Switch on evtl. TextAnimation again after TextEdit @@ -955,14 +978,16 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(sal_Bool bDontDeleteReally) AdjustMarkHdl(); } // alle OutlinerViews loeschen - for (ULONG i=pTEOutliner->GetViewCount(); i>0;) { + for (ULONG i=pTEOutliner->GetViewCount(); i>0;) + { i--; OutlinerView* pOLV=pTEOutliner->GetView(i); USHORT nMorePix=pOLV->GetInvalidateMore() + 10; // solaris aw033 test #i# Window* pWin=pOLV->GetWindow(); Rectangle aRect(pOLV->GetOutputArea()); pTEOutliner->RemoveView(i); - if (!bTextEditDontDelete || i!=0) { + if (!bTextEditDontDelete || i!=0) + { // die nullte gehoert mir u.U. nicht. delete pOLV; } @@ -1564,21 +1589,26 @@ BOOL SdrObjEditView::SetAttributes(const SfxItemSet& rSet, BOOL bReplaceAll) if( !bRet ) { - String aStr; - ImpTakeDescriptionStr(STR_EditSetAttributes,aStr); - BegUndo(aStr); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get())); - - // #i43537# - // If this is a text object also rescue the OutlinerParaObject since - // applying attributes to the object may change text layout when - // multiple portions exist with multiple formats. If a OutlinerParaObject - // really exists and needs to be rescued is evaluated in the undo - // implementation itself. - sal_Bool bRescueText(mxTextEditObj->ISA(SdrTextObj)); - - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*mxTextEditObj.get(),false,!bNoEEItems || bRescueText)); - EndUndo(); + const bool bUndo = IsUndoEnabled(); + + if( bUndo ) + { + String aStr; + ImpTakeDescriptionStr(STR_EditSetAttributes,aStr); + BegUndo(aStr); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get())); + + // #i43537# + // If this is a text object also rescue the OutlinerParaObject since + // applying attributes to the object may change text layout when + // multiple portions exist with multiple formats. If a OutlinerParaObject + // really exists and needs to be rescued is evaluated in the undo + // implementation itself. + bool bRescueText = dynamic_cast< SdrTextObj* >(mxTextEditObj.get()); + + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*mxTextEditObj.get(),false,!bNoEEItems || bRescueText)); + EndUndo(); + } mxTextEditObj->SetMergedItemSetAndBroadcast(*pSet, bReplaceAll); @@ -1610,12 +1640,15 @@ BOOL SdrObjEditView::SetAttributes(const SfxItemSet& rSet, BOOL bReplaceAll) if( !bRet ) { - String aStr; - ImpTakeDescriptionStr(STR_EditSetAttributes,aStr); - BegUndo(aStr); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get())); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*mxTextEditObj.get(),false,false)); - EndUndo(); + if( IsUndoEnabled() ) + { + String aStr; + ImpTakeDescriptionStr(STR_EditSetAttributes,aStr); + BegUndo(aStr); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get())); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*mxTextEditObj.get(),false,false)); + EndUndo(); + } mxTextEditObj->SetMergedItemSetAndBroadcast(aSet, bReplaceAll); @@ -1645,7 +1678,8 @@ BOOL SdrObjEditView::SetAttributes(const SfxItemSet& rSet, BOOL bReplaceAll) } bRet=TRUE; } - if (pModifiedSet!=NULL) delete pModifiedSet; + if (pModifiedSet!=NULL) + delete pModifiedSet; return bRet; } diff --git a/svx/source/svdraw/svdglev.cxx b/svx/source/svdraw/svdglev.cxx index dfc4fe171850..ac33106d3555 100644 --- a/svx/source/svdraw/svdglev.cxx +++ b/svx/source/svdraw/svdglev.cxx @@ -76,12 +76,17 @@ void SdrGlueEditView::ImpDoMarkedGluePoints(PGlueDoFunc pDoFunc, BOOL bConst, co } else { pGPL=pObj->ForceGluePointList(); } - if (pGPL!=NULL) { - if (!bConst) AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); - for (ULONG nPtNum=0; nPtNum<nPtAnz; nPtNum++) { + if (pGPL!=NULL) + { + if(!bConst && IsUndoEnabled() ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); + + for (ULONG nPtNum=0; nPtNum<nPtAnz; nPtNum++) + { USHORT nPtId=pPts->GetObject(nPtNum); USHORT nGlueIdx=pGPL->FindGluePoint(nPtId); - if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND) { + if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND) + { SdrGluePoint& rGP=(*pGPL)[nGlueIdx]; (*pDoFunc)(rGP,pObj,p1,p2,p3,p4,p5); } @@ -240,21 +245,31 @@ void SdrGlueEditView::DeleteMarkedGluePoints() { BrkAction(); ForceUndirtyMrkPnt(); - BegUndo(ImpGetResStr(STR_EditDelete),GetDescriptionOfMarkedGluePoints(),SDRREPFUNC_OBJ_DELETE); + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(ImpGetResStr(STR_EditDelete),GetDescriptionOfMarkedGluePoints(),SDRREPFUNC_OBJ_DELETE); + ULONG nMarkAnz=GetMarkedObjectCount(); - for (ULONG nm=0; nm<nMarkAnz; nm++) { + for (ULONG nm=0; nm<nMarkAnz; nm++) + { SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pObj=pM->GetMarkedSdrObj(); const SdrUShortCont* pPts=pM->GetMarkedGluePoints(); ULONG nPtAnz=pPts==NULL ? 0 : pPts->GetCount(); - if (nPtAnz!=0) { + if (nPtAnz!=0) + { SdrGluePointList* pGPL=pObj->ForceGluePointList(); - if (pGPL!=NULL) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); - for (ULONG nPtNum=0; nPtNum<nPtAnz; nPtNum++) { + if (pGPL!=NULL) + { + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); + + for (ULONG nPtNum=0; nPtNum<nPtAnz; nPtNum++) + { USHORT nPtId=pPts->GetObject(nPtNum); USHORT nGlueIdx=pGPL->FindGluePoint(nPtId); - if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND) { + if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND) + { pGPL->Delete(nGlueIdx); } } @@ -263,29 +278,41 @@ void SdrGlueEditView::DeleteMarkedGluePoints() } } } - EndUndo(); + if( bUndo ) + EndUndo(); UnmarkAllGluePoints(); - if (nMarkAnz!=0) pMod->SetChanged(); + if (nMarkAnz!=0) + pMod->SetChanged(); } //////////////////////////////////////////////////////////////////////////////////////////////////// void SdrGlueEditView::ImpCopyMarkedGluePoints() { - BegUndo(); + const bool bUndo = IsUndoEnabled(); + + if( bUndo ) + BegUndo(); + ULONG nMarkAnz=GetMarkedObjectCount(); - for (ULONG nm=0; nm<nMarkAnz; nm++) { + for (ULONG nm=0; nm<nMarkAnz; nm++) + { SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pObj=pM->GetMarkedSdrObj(); SdrUShortCont* pPts=pM->GetMarkedGluePoints(); SdrGluePointList* pGPL=pObj->ForceGluePointList(); ULONG nPtAnz=pPts==NULL ? 0 : pPts->GetCount(); - if (nPtAnz!=0 && pGPL!=NULL) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); - for (ULONG nPtNum=0; nPtNum<nPtAnz; nPtNum++) { + if (nPtAnz!=0 && pGPL!=NULL) + { + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); + + for (ULONG nPtNum=0; nPtNum<nPtAnz; nPtNum++) + { USHORT nPtId=pPts->GetObject(nPtNum); USHORT nGlueIdx=pGPL->FindGluePoint(nPtId); - if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND) { + if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND) + { SdrGluePoint aNewGP((*pGPL)[nGlueIdx]); // GluePoint klonen USHORT nNewIdx=pGPL->Insert(aNewGP); // und einfuegen USHORT nNewId=(*pGPL)[nNewIdx].GetId(); // Id des neuen GluePoints ermitteln @@ -294,8 +321,11 @@ void SdrGlueEditView::ImpCopyMarkedGluePoints() } } } - EndUndo(); - if (nMarkAnz!=0) pMod->SetChanged(); + if( bUndo ) + EndUndo(); + + if (nMarkAnz!=0) + pMod->SetChanged(); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -310,8 +340,11 @@ void SdrGlueEditView::ImpTransformMarkedGluePoints(PGlueTrFunc pTrFunc, const vo ULONG nPtAnz=pPts==NULL ? 0 : pPts->GetCount(); if (nPtAnz!=0) { SdrGluePointList* pGPL=pObj->ForceGluePointList(); - if (pGPL!=NULL) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); + if (pGPL!=NULL) + { + if( IsUndoEnabled() ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); + for (ULONG nPtNum=0; nPtNum<nPtAnz; nPtNum++) { USHORT nPtId=pPts->GetObject(nPtNum); USHORT nGlueIdx=pGPL->FindGluePoint(nPtId); diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx index c338d9845c21..2157c1052192 100644 --- a/svx/source/svdraw/svdhdl.cxx +++ b/svx/source/svdraw/svdhdl.cxx @@ -1250,7 +1250,7 @@ void SdrHdlGradient::FromIAOToItem(SdrObject* _pObj, BOOL bSetItemOnObject, BOOL aNewSet.Put(aNewTransItem); } - if(bUndo) + if(bUndo && pModel->IsUndoEnabled()) { pModel->BegUndo(SVX_RESSTR(IsGradient() ? SIP_XA_FILLGRADIENT : SIP_XA_FILLTRANSPARENCE)); pModel->AddUndo(pModel->GetSdrUndoFactory().CreateUndoAttrObject(*_pObj)); diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index 60761a2d3557..28435b26ff9f 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -144,6 +144,7 @@ void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbe nMaxUndoCount=16; pAktUndoGroup=NULL; nUndoLevel=0; + mbUndoEnabled=true; nProgressPercent=0; nLoadVersion=0; bExtColorTable=FALSE; @@ -461,10 +462,13 @@ FASTBOOL SdrModel::Undo() SfxUndoAction* pDo=(SfxUndoAction*)GetUndoAction(0); if(pDo!=NULL) { + const bool bWasUndoEnabled = mbUndoEnabled; + mbUndoEnabled = false; pDo->Undo(); if(pRedoStack==NULL) pRedoStack=new Container(1024,16,16); pRedoStack->Insert(pUndoStack->Remove((ULONG)0),(ULONG)0); + mbUndoEnabled = bWasUndoEnabled; } } return bRet; @@ -482,10 +486,13 @@ FASTBOOL SdrModel::Redo() SfxUndoAction* pDo=(SfxUndoAction*)GetRedoAction(0); if(pDo!=NULL) { + const bool bWasUndoEnabled = mbUndoEnabled; + mbUndoEnabled = false; pDo->Redo(); if(pUndoStack==NULL) pUndoStack=new Container(1024,16,16); pUndoStack->Insert(pRedoStack->Remove((ULONG)0),(ULONG)0); + mbUndoEnabled = bWasUndoEnabled; } } return bRet; @@ -516,15 +523,28 @@ FASTBOOL SdrModel::Repeat(SfxRepeatTarget& rView) void SdrModel::ImpPostUndoAction(SdrUndoAction* pUndo) { DBG_ASSERT( mpImpl->mpUndoManager == 0, "svx::SdrModel::ImpPostUndoAction(), method not supported with application undo manager!" ); - if (aUndoLink.IsSet()) { - aUndoLink.Call(pUndo); - } else { - if (pUndoStack==NULL) pUndoStack=new Container(1024,16,16); - pUndoStack->Insert(pUndo,(ULONG)0); - while (pUndoStack->Count()>nMaxUndoCount) { - delete (SfxUndoAction*) pUndoStack->Remove(pUndoStack->Count()-1); + if( IsUndoEnabled() ) + { + if (aUndoLink.IsSet()) + { + aUndoLink.Call(pUndo); } - if (pRedoStack!=NULL) pRedoStack->Clear(); + else + { + if (pUndoStack==NULL) + pUndoStack=new Container(1024,16,16); + pUndoStack->Insert(pUndo,(ULONG)0); + while (pUndoStack->Count()>nMaxUndoCount) + { + delete (SfxUndoAction*)pUndoStack->Remove(pUndoStack->Count()-1); + } + if (pRedoStack!=NULL) + pRedoStack->Clear(); + } + } + else + { + delete pUndo; } } @@ -536,7 +556,7 @@ void SdrModel::BegUndo() mpImpl->mpUndoManager->EnterListAction(aEmpty,aEmpty); nUndoLevel++; } - else + else if( IsUndoEnabled() ) { if(pAktUndoGroup==NULL) { @@ -558,7 +578,7 @@ void SdrModel::BegUndo(const XubString& rComment) mpImpl->mpUndoManager->EnterListAction( rComment, aEmpty ); nUndoLevel++; } - else + else if( IsUndoEnabled() ) { BegUndo(); if (nUndoLevel==1) @@ -582,7 +602,7 @@ void SdrModel::BegUndo(const XubString& rComment, const XubString& rObjDescr, Sd mpImpl->mpUndoManager->EnterListAction( aComment,aEmpty ); nUndoLevel++; } - else + else if( IsUndoEnabled() ) { BegUndo(); if (nUndoLevel==1) @@ -601,7 +621,7 @@ void SdrModel::BegUndo(SdrUndoGroup* pUndoGrp) DBG_ERROR("svx::SdrModel::BegUndo(), method not supported with application undo manager!" ); nUndoLevel++; } - else + else if( IsUndoEnabled() ) { if (pAktUndoGroup==NULL) { @@ -614,6 +634,10 @@ void SdrModel::BegUndo(SdrUndoGroup* pUndoGrp) nUndoLevel++; } } + else + { + delete pUndoGrp; + } } void SdrModel::EndUndo() @@ -629,7 +653,7 @@ void SdrModel::EndUndo() } else { - if(pAktUndoGroup!=NULL) + if(pAktUndoGroup!=NULL && IsUndoEnabled()) { nUndoLevel--; if(nUndoLevel==0) @@ -659,7 +683,7 @@ void SdrModel::SetUndoComment(const XubString& rComment) { DBG_ERROR("svx::SdrModel::SetUndoComment(), method not supported with application undo manager!" ); } - else + else if( IsUndoEnabled() ) { if(nUndoLevel==1) { @@ -691,6 +715,10 @@ void SdrModel::AddUndo(SdrUndoAction* pUndo) { mpImpl->mpUndoManager->AddUndoAction( pUndo ); } + else if( !IsUndoEnabled() ) + { + delete pUndo; + } else { if (pAktUndoGroup!=NULL) @@ -704,6 +732,30 @@ void SdrModel::AddUndo(SdrUndoAction* pUndo) } } +void SdrModel::EnableUndo( bool bEnable ) +{ + if( mpImpl->mpUndoManager ) + { + mpImpl->mpUndoManager->EnableUndo( bEnable ); + } + else + { + mbUndoEnabled = bEnable; + } +} + +bool SdrModel::IsUndoEnabled() const +{ + if( mpImpl->mpUndoManager ) + { + return mpImpl->mpUndoManager->IsUndoEnabled(); + } + else + { + return mbUndoEnabled; + } +} + //////////////////////////////////////////////////////////////////////////////////////////////////// void SdrModel::ImpCreateTables() @@ -1568,53 +1620,77 @@ void SdrModel::CopyPages(USHORT nFirstPageNum, USHORT nLastPageNum, USHORT nDestPos, FASTBOOL bUndo, FASTBOOL bMoveNoCopy) { - if (bUndo) { + if( bUndo && !IsUndoEnabled() ) + bUndo = false; + + if( bUndo ) BegUndo(ImpGetResStr(STR_UndoMergeModel)); - } + USHORT nPageAnz=GetPageCount(); - USHORT nMaxPage=nPageAnz; if (nMaxPage!=0) nMaxPage--; - if (nFirstPageNum>nMaxPage) nFirstPageNum=nMaxPage; - if (nLastPageNum>nMaxPage) nLastPageNum =nMaxPage; + USHORT nMaxPage=nPageAnz; + + if (nMaxPage!=0) + nMaxPage--; + if (nFirstPageNum>nMaxPage) + nFirstPageNum=nMaxPage; + if (nLastPageNum>nMaxPage) + nLastPageNum =nMaxPage; FASTBOOL bReverse=nLastPageNum<nFirstPageNum; - if (nDestPos>nPageAnz) nDestPos=nPageAnz; + if (nDestPos>nPageAnz) + nDestPos=nPageAnz; // Zunaechst die Zeiger der betroffenen Seiten in einem Array sichern USHORT nPageNum=nFirstPageNum; USHORT nCopyAnz=((!bReverse)?(nLastPageNum-nFirstPageNum):(nFirstPageNum-nLastPageNum))+1; SdrPage** pPagePtrs=new SdrPage*[nCopyAnz]; USHORT nCopyNum; - for (nCopyNum=0; nCopyNum<nCopyAnz; nCopyNum++) { + for(nCopyNum=0; nCopyNum<nCopyAnz; nCopyNum++) + { pPagePtrs[nCopyNum]=GetPage(nPageNum); - if (bReverse) nPageNum--; - else nPageNum++; + if (bReverse) + nPageNum--; + else + nPageNum++; } // Jetzt die Seiten kopieren USHORT nDestNum=nDestPos; - for (nCopyNum=0; nCopyNum<nCopyAnz; nCopyNum++) { + for (nCopyNum=0; nCopyNum<nCopyAnz; nCopyNum++) + { SdrPage* pPg=pPagePtrs[nCopyNum]; USHORT nPageNum2=pPg->GetPageNum(); - if (!bMoveNoCopy) { + if (!bMoveNoCopy) + { const SdrPage* pPg1=GetPage(nPageNum2); pPg=pPg1->Clone(); InsertPage(pPg,nDestNum); - if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoCopyPage(*pPg)); + if (bUndo) + AddUndo(GetSdrUndoFactory().CreateUndoCopyPage(*pPg)); nDestNum++; - } else { + } + else + { // Move ist nicht getestet! - if (nDestNum>nPageNum2) nDestNum--; - if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*GetPage(nPageNum2),nPageNum2,nDestNum)); + if (nDestNum>nPageNum2) + nDestNum--; + + if(bUndo) + AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*GetPage(nPageNum2),nPageNum2,nDestNum)); + pPg=RemovePage(nPageNum2); InsertPage(pPg,nDestNum); nDestNum++; } - if (bReverse) nPageNum2--; - else nPageNum2++; + if(bReverse) + nPageNum2--; + else + nPageNum2++; } delete[] pPagePtrs; - if (bUndo) EndUndo(); + if(bUndo) + EndUndo(); } void SdrModel::Merge(SdrModel& rSourceModel, @@ -1623,13 +1699,18 @@ void SdrModel::Merge(SdrModel& rSourceModel, FASTBOOL bMergeMasterPages, FASTBOOL bAllMasterPages, FASTBOOL bUndo, FASTBOOL bTreadSourceAsConst) { - if (&rSourceModel==this) { // #48289# + if (&rSourceModel==this) + { // #48289# CopyPages(nFirstPageNum,nLastPageNum,nDestPos,bUndo,!bTreadSourceAsConst); return; } - if (bUndo) { + + if( bUndo && !IsUndoEnabled() ) + bUndo = false; + + if (bUndo) BegUndo(ImpGetResStr(STR_UndoMergeModel)); - } + USHORT nSrcPageAnz=rSourceModel.GetPageCount(); USHORT nSrcMasterPageAnz=rSourceModel.GetMasterPageCount(); USHORT nDstMasterPageAnz=GetMasterPageCount(); diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index 6499708c6186..805b56eb207f 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -970,9 +970,12 @@ void SdrMarkView::AddDragModeHdl(SdrDragMode eMode) aNewItem.SetGradientValue(aGrad); // add undo to allow user to take back this step - pModel->BegUndo(SVX_RESSTR(SIP_XA_FILLTRANSPARENCE)); - pModel->AddUndo(pModel->GetSdrUndoFactory().CreateUndoAttrObject(*pObj)); - pModel->EndUndo(); + if( pModel->IsUndoEnabled() ) + { + pModel->BegUndo(SVX_RESSTR(SIP_XA_FILLTRANSPARENCE)); + pModel->AddUndo(pModel->GetSdrUndoFactory().CreateUndoAttrObject(*pObj)); + pModel->EndUndo(); + } //pObj->SetItemAndBroadcast(aNewItem); SfxItemSet aNewSet(pModel->GetItemPool()); diff --git a/svx/source/svdraw/svdpoev.cxx b/svx/source/svdraw/svdpoev.cxx index 483fb829d8b6..3b5100f9c278 100644 --- a/svx/source/svdraw/svdpoev.cxx +++ b/svx/source/svdraw/svdpoev.cxx @@ -213,7 +213,10 @@ void SdrPolyEditView::SetMarkedPointsSmooth(SdrPathSmoothKind eKind) if(HasMarkedPoints()) { SortMarkedObjects(); - BegUndo(ImpGetResStr(STR_EditSetPointsSmooth), GetDescriptionOfMarkedPoints()); + + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(ImpGetResStr(STR_EditSetPointsSmooth), GetDescriptionOfMarkedPoints()); ULONG nMarkAnz(GetMarkedObjectCount()); for(ULONG nMarkNum(nMarkAnz); nMarkNum > 0L;) @@ -228,13 +231,15 @@ void SdrPolyEditView::SetMarkedPointsSmooth(SdrPathSmoothKind eKind) PolyPolygonEditor aEditor( pPath->GetPathPoly(), pPath->IsClosed() ); if(aEditor.SetPointsSmooth( eFlags, pPts->getContainer() ) ) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath)); pPath->SetPathPoly(aEditor.GetPolyPolygon()); } } } - EndUndo(); + if( bUndo ) + EndUndo(); } } @@ -243,7 +248,10 @@ void SdrPolyEditView::SetMarkedSegmentsKind(SdrPathSegmentKind eKind) if(HasMarkedPoints()) { SortMarkedObjects(); - BegUndo(ImpGetResStr(STR_EditSetSegmentsKind), GetDescriptionOfMarkedPoints()); + + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(ImpGetResStr(STR_EditSetSegmentsKind), GetDescriptionOfMarkedPoints()); ULONG nMarkAnz(GetMarkedObjectCount()); for(ULONG nMarkNum(nMarkAnz); nMarkNum > 0L;) @@ -258,13 +266,15 @@ void SdrPolyEditView::SetMarkedSegmentsKind(SdrPathSegmentKind eKind) PolyPolygonEditor aEditor( pPath->GetPathPoly(), pPath->IsClosed() ); if(aEditor.SetSegmentsKind( eKind, pPts->getContainer()) ) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath)); pPath->SetPathPoly(aEditor.GetPolyPolygon()); } } } - EndUndo(); + if( bUndo ) + EndUndo(); } } @@ -305,8 +315,12 @@ void SdrPolyEditView::DeleteMarkedPoints() SortMarkedObjects(); ULONG nMarkAnz=GetMarkedObjectCount(); - // Description - BegUndo(ImpGetResStr(STR_EditDelete),GetDescriptionOfMarkedPoints(),SDRREPFUNC_OBJ_DELETE); + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + { + // Description + BegUndo(ImpGetResStr(STR_EditDelete),GetDescriptionOfMarkedPoints(),SDRREPFUNC_OBJ_DELETE); + } for (ULONG nMarkNum=nMarkAnz; nMarkNum>0;) { @@ -322,19 +336,27 @@ void SdrPolyEditView::DeleteMarkedPoints() { if( aEditor.GetPolyPolygon().count() ) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath )); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath )); pPath->SetPathPoly( aEditor.GetPolyPolygon() ); } else { - AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pPath ) ); + if( bUndo ) + AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pPath ) ); pM->GetPageView()->GetObjList()->RemoveObject(pPath->GetOrdNum()); + if( !bUndo ) + { + SdrObject* pObj = pPath; + SdrObject::Free(pObj); + } } } } } - EndUndo(); + if( bUndo ) + EndUndo(); UnmarkAllPoints(); MarkListHasChanged(); } @@ -346,7 +368,10 @@ void SdrPolyEditView::RipUpAtMarkedPoints() { SortMarkedObjects(); sal_uInt32 nMarkAnz(GetMarkedObjectCount()); - BegUndo(ImpGetResStr(STR_EditRipUp), GetDescriptionOfMarkedPoints()); + + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(ImpGetResStr(STR_EditRipUp), GetDescriptionOfMarkedPoints()); for(sal_uInt32 nMarkNum(nMarkAnz); nMarkNum > 0L;) { @@ -358,7 +383,8 @@ void SdrPolyEditView::RipUpAtMarkedPoints() if(pPts && pObj) { pPts->ForceSort(); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); sal_Bool bKorregFlag(sal_False); sal_Bool bInsAny(sal_False); sal_uInt32 nMarkPtsAnz(pPts->GetCount()); @@ -375,7 +401,8 @@ void SdrPolyEditView::RipUpAtMarkedPoints() bInsAny = sal_True; SdrInsertReason aReason(SDRREASON_VIEWCALL, pObj); pM->GetPageView()->GetObjList()->InsertObject(pNeuObj, pObj->GetOrdNum() + 1, &aReason); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNeuObj)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNeuObj)); MarkObj(pNeuObj, pM->GetPageView(), FALSE, TRUE); } @@ -408,7 +435,8 @@ void SdrPolyEditView::RipUpAtMarkedPoints() } UnmarkAllPoints(); - EndUndo(); + if( bUndo ) + EndUndo(); MarkListHasChanged(); } } @@ -532,24 +560,36 @@ void SdrPolyEditView::ShutMarkedObjects() void SdrPolyEditView::CloseMarkedObjects(BOOL bToggle, BOOL bOpen) // , long nOpenDistance) { - if (AreObjectsMarked()) { - BegUndo(ImpGetResStr(STR_EditShut),GetDescriptionOfMarkedPoints()); - BOOL bChg=FALSE; + if (AreObjectsMarked()) + { + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(ImpGetResStr(STR_EditShut),GetDescriptionOfMarkedPoints()); + + bool bChg=false; ULONG nMarkAnz=GetMarkedObjectCount(); - for (ULONG nm=0; nm<nMarkAnz; nm++) { + for (ULONG nm=0; nm<nMarkAnz; nm++) + { SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pO=pM->GetMarkedSdrObj(); BOOL bClosed=pO->IsClosedObj(); - if (pO->IsPolyObj() && (bClosed==bOpen) || bToggle) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); - if (pO->ISA(SdrPathObj)) { - ((SdrPathObj*)pO)->ToggleClosed(); // nOpenDistance); - } - bChg=TRUE; + if (pO->IsPolyObj() && (bClosed==bOpen) || bToggle) + { + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO)); + + SdrPathObj* pPathObj = dynamic_cast< SdrPathObj* >( pO ); + if(pPathObj) + pPathObj->ToggleClosed(); + bChg=true; } } - EndUndo(); - if (bChg) { + + if( bUndo ) + EndUndo(); + + if (bChg) + { UnmarkAllPoints(); MarkListHasChanged(); } @@ -566,8 +606,11 @@ void SdrPolyEditView::ImpCopyMarkedPoints() void SdrPolyEditView::ImpTransformMarkedPoints(PPolyTrFunc pTrFunc, const void* p1, const void* p2, const void* p3, const void* p4, const void* p5) { + const bool bUndo = IsUndoEnabled(); + ULONG nMarkAnz=GetMarkedObjectCount(); - for (ULONG nm=0; nm<nMarkAnz; nm++) { + for (ULONG nm=0; nm<nMarkAnz; nm++) + { SdrMark* pM=GetSdrMarkByIndex(nm); SdrObject* pObj=pM->GetMarkedSdrObj(); const SdrUShortCont* pPts=pM->GetMarkedPoints(); @@ -575,7 +618,9 @@ void SdrPolyEditView::ImpTransformMarkedPoints(PPolyTrFunc pTrFunc, const void* SdrPathObj* pPath=PTR_CAST(SdrPathObj,pObj); if (nPtAnz!=0 && pPath!=NULL) { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); + basegfx::B2DPolyPolygon aXPP(pPath->GetPathPoly()); for(sal_uInt32 nPtNum(0L); nPtNum < nPtAnz; nPtNum++) diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx index eb52bfb62c9e..b49d087d0251 100644 --- a/svx/source/svdraw/svdundo.cxx +++ b/svx/source/svdraw/svdundo.cxx @@ -1179,9 +1179,15 @@ void SdrUndoObjSetText::SdrRepeat(SdrView& rView) if (bNewTextAvailable && rView.AreObjectsMarked()) { const SdrMarkList& rML=rView.GetMarkedObjectList(); - XubString aStr; - ImpTakeDescriptionStr(STR_UndoObjSetText,aStr); - rView.BegUndo(aStr); + + const bool bUndo = rView.IsUndoEnabled(); + if( bUndo ) + { + XubString aStr; + ImpTakeDescriptionStr(STR_UndoObjSetText,aStr); + rView.BegUndo(aStr); + } + ULONG nAnz=rML.GetMarkCount(); for (ULONG nm=0; nm<nAnz; nm++) { @@ -1189,14 +1195,18 @@ void SdrUndoObjSetText::SdrRepeat(SdrView& rView) SdrTextObj* pTextObj=PTR_CAST(SdrTextObj,pObj2); if (pTextObj!=NULL) { - rView.AddUndo(new SdrUndoObjSetText(*pTextObj,0)); + if( bUndo ) + rView.AddUndo(new SdrUndoObjSetText(*pTextObj,0)); + OutlinerParaObject* pText1=pNewText; if (pText1!=NULL) pText1 = new OutlinerParaObject(*pText1); pTextObj->SetOutlinerParaObject(pText1); } } - rView.EndUndo(); + + if( bUndo ) + rView.EndUndo(); } } diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx index 58ef0c2e9743..9a6958b34c4d 100644 --- a/svx/source/svdraw/svdxcgv.cxx +++ b/svx/source/svdraw/svdxcgv.cxx @@ -305,13 +305,18 @@ BOOL SdrExchangeView::Paste(SvStream& rInput, const String& rBaseURL, USHORT eFo BOOL SdrExchangeView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst, UINT32 nOptions) { const SdrModel* pSrcMod=&rMod; - if (pSrcMod==pMod) return FALSE; // na so geht's ja nun nicht + if (pSrcMod==pMod) + return FALSE; // na so geht's ja nun nicht - BegUndo(ImpGetResStr(STR_ExchangePaste)); + const bool bUndo = IsUndoEnabled(); + + if( bUndo ) + BegUndo(ImpGetResStr(STR_ExchangePaste)); if( mxSelectionController.is() && mxSelectionController->PasteObjModel( rMod ) ) { - EndUndo(); + if( bUndo ) + EndUndo(); return TRUE; } @@ -327,9 +332,12 @@ BOOL SdrExchangeView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* } ImpLimitToWorkArea( aPos ); - if (pLst==NULL) return FALSE; + if (pLst==NULL) + return FALSE; + BOOL bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit(); - if (bUnmark) UnmarkAllObj(); + if (bUnmark) + UnmarkAllObj(); // evtl. umskalieren bei unterschiedlicher MapUnit am Model // Dafuer erstmal die Faktoren berechnen @@ -338,20 +346,23 @@ BOOL SdrExchangeView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* BOOL bResize=eSrcUnit!=eDstUnit; Fraction xResize,yResize; Point aPt0; - if (bResize) { + if (bResize) + { FrPair aResize(GetMapFactor(eSrcUnit,eDstUnit)); xResize=aResize.X(); yResize=aResize.Y(); } SdrObjList* pDstLst=pLst; USHORT nPg,nPgAnz=pSrcMod->GetPageCount(); - for (nPg=0; nPg<nPgAnz; nPg++) { + for (nPg=0; nPg<nPgAnz; nPg++) + { const SdrPage* pSrcPg=pSrcMod->GetPage(nPg); // #104148# Use SnapRect, not BoundRect here Rectangle aR=pSrcPg->GetAllObjSnapRect(); - if (bResize) ResizeRect(aR,aPt0,xResize,yResize); + if (bResize) + ResizeRect(aR,aPt0,xResize,yResize); Point aDist(aPos-aR.Center()); Size aSiz(aDist.X(),aDist.Y()); //ULONG nDstObjAnz0=pDstLst->GetObjCount(); @@ -363,7 +374,8 @@ BOOL SdrExchangeView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* // New mechanism to re-create the connections of cloned connectors CloneList aCloneList; - for (nOb=0; nOb<nObAnz; nOb++) { + for (nOb=0; nOb<nObAnz; nOb++) + { const SdrObject* pSrcOb=pSrcPg->GetObj(nOb); // #116235# @@ -413,7 +425,9 @@ BOOL SdrExchangeView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* SdrInsertReason aReason(SDRREASON_VIEWCALL); pDstLst->InsertObject(pNeuObj,CONTAINER_APPEND,&aReason); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNeuObj)); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNeuObj)); + if (bMark) { // Markhandles noch nicht sofort setzen! // Das erledigt das ModelHasChanged der MarkView. @@ -455,7 +469,10 @@ BOOL SdrExchangeView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* #endif } } - EndUndo(); + + if( bUndo ) + EndUndo(); + return TRUE; } @@ -497,17 +514,22 @@ void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Po pObj->SetLogicRect(aR); SdrInsertReason aReason(SDRREASON_VIEWCALL); rLst.InsertObject(pObj,CONTAINER_APPEND,&aReason); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj)); + + if( IsUndoEnabled() ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj)); + SdrPageView* pMarkPV=NULL; SdrPageView* pPV = GetSdrPageView(); if(pPV) { - if (pPV->GetObjList()==&rLst) pMarkPV=pPV; + if (pPV->GetObjList()==&rLst) + pMarkPV=pPV; } BOOL bMark=pMarkPV!=NULL && !IsTextEdit() && (nOptions&SDRINSERT_DONTMARK)==0; - if (bMark) { // Obj in der ersten gefundenen PageView markieren + if (bMark) + { // Obj in der ersten gefundenen PageView markieren MarkObj(pObj,pMarkPV); } } |