summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2009-06-04 16:21:29 +0000
committerKurt Zenker <kz@openoffice.org>2009-06-04 16:21:29 +0000
commit2dc34235a216d86471e459a42ab429e207436a20 (patch)
tree5bf7a3a1110dd6b5297ff42d89449e99629a942e
parent46ba9cbfdc49baeaba4037f8f1a679f1aefe0d5d (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()
-rw-r--r--svx/inc/svx/svdedtv.hxx1
-rw-r--r--svx/inc/svx/svdmodel.hxx12
-rw-r--r--svx/source/engine3d/dragmt3d.cxx16
-rw-r--r--svx/source/engine3d/view3d.cxx8
-rw-r--r--svx/source/form/fmpgeimp.cxx63
-rw-r--r--svx/source/form/fmshimp.cxx8
-rw-r--r--svx/source/form/fmundo.cxx28
-rw-r--r--svx/source/form/navigatortree.cxx24
-rw-r--r--svx/source/form/navigatortreemodel.cxx42
-rw-r--r--svx/source/inc/fmundo.hxx4
-rw-r--r--svx/source/svdraw/svddrgmt.cxx106
-rw-r--r--svx/source/svdraw/svddrgv.cxx16
-rw-r--r--svx/source/svdraw/svdedtv.cxx143
-rw-r--r--svx/source/svdraw/svdedtv1.cxx496
-rw-r--r--svx/source/svdraw/svdedtv2.cxx519
-rw-r--r--svx/source/svdraw/svdedxv.cxx104
-rw-r--r--svx/source/svdraw/svdglev.cxx79
-rw-r--r--svx/source/svdraw/svdhdl.cxx2
-rw-r--r--svx/source/svdraw/svdmodel.cxx151
-rw-r--r--svx/source/svdraw/svdmrkv.cxx9
-rw-r--r--svx/source/svdraw/svdpoev.cxx103
-rw-r--r--svx/source/svdraw/svdundo.cxx20
-rw-r--r--svx/source/svdraw/svdxcgv.cxx50
-rw-r--r--svx/source/table/cell.cxx2
-rw-r--r--svx/source/table/svdotable.cxx2
-rw-r--r--svx/source/table/tablecolumn.cxx12
-rw-r--r--svx/source/table/tablecontroller.cxx79
-rw-r--r--svx/source/table/tablelayouter.cxx42
-rw-r--r--svx/source/table/tablelayouter.hxx1
-rw-r--r--svx/source/table/tablemodel.cxx44
-rw-r--r--svx/source/table/tablerow.cxx15
-rw-r--r--svx/source/tbxctrls/grafctrl.cxx58
-rw-r--r--svx/source/toolbars/extrusionbar.cxx15
-rw-r--r--svx/source/toolbars/fontworkbar.cxx27
34 files changed, 1611 insertions, 690 deletions
diff --git a/svx/inc/svx/svdedtv.hxx b/svx/inc/svx/svdedtv.hxx
index d3259539d6..38b20ef276 100644
--- a/svx/inc/svx/svdedtv.hxx
+++ b/svx/inc/svx/svdedtv.hxx
@@ -232,6 +232,7 @@ public:
void SetUndoComment(const String& rComment);
void SetUndoComment(const String& rComment, const String& rObjDescr);
#endif
+ bool IsUndoEnabled() const;
std::vector< SdrUndoAction* > CreateConnectorUndo( SdrObject& rO );
void AddUndoActions( std::vector< SdrUndoAction* >& );
diff --git a/svx/inc/svx/svdmodel.hxx b/svx/inc/svx/svdmodel.hxx
index e8a201a08c..c8d132536e 100644
--- a/svx/inc/svx/svdmodel.hxx
+++ b/svx/inc/svx/svdmodel.hxx
@@ -220,6 +220,7 @@ protected:
Container* pRedoStack;
SdrUndoGroup* pAktUndoGroup; // Fuer mehrstufige
USHORT nUndoLevel; // Undo-Klammerung
+ bool mbUndoEnabled; // If false no undo is recorded or we are during the execution of an undo action
USHORT nProgressPercent; // fuer den ProgressBar-Handler
USHORT nLoadVersion; // Versionsnummer der geladenen Datei
FASTBOOL bExtColorTable; // Keinen eigenen ColorTable
@@ -728,6 +729,17 @@ public:
bool IsInDestruction() const;
static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelImplementationId();
+
+ /** enables (true) or disables (false) recording of undo actions
+ If undo actions are added while undo is disabled, they are deleted.
+ Disabling undo does not clear the current undo buffer! */
+ void EnableUndo( bool bEnable );
+
+ /** returns true if undo is currently enabled
+ This returns false if undo was disabled using EnableUndo( false ) and
+ also during the runtime of the Undo() and Redo() methods. */
+ bool IsUndoEnabled() const;
+
};
typedef tools::WeakReference< SdrModel > SdrModelWeakRef;
diff --git a/svx/source/engine3d/dragmt3d.cxx b/svx/source/engine3d/dragmt3d.cxx
index 03bb24ae09..7bbf9c6ca9 100644
--- a/svx/source/engine3d/dragmt3d.cxx
+++ b/svx/source/engine3d/dragmt3d.cxx
@@ -175,7 +175,9 @@ bool E3dDragMethod::EndSdrDrag(bool /*bCopy*/)
// Alle Transformationen anwenden und UnDo's anlegen
if(mbMovedAtAll)
{
- getSdrDragView().BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_ROTATE));
+ const bool bUndo = getSdrDragView().IsUndoEnabled();
+ if( bUndo )
+ getSdrDragView().BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_ROTATE));
sal_uInt32 nOb(0);
for(nOb=0;nOb<nCnt;nOb++)
@@ -183,11 +185,15 @@ bool E3dDragMethod::EndSdrDrag(bool /*bCopy*/)
E3dDragMethodUnit& rCandidate = maGrp[nOb];
E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
rCandidate.mp3DObj->SetTransform(rCandidate.maTransform);
- getSdrDragView().AddUndo(new E3dRotateUndoAction(rCandidate.mp3DObj->GetModel(),
- rCandidate.mp3DObj, rCandidate.maInitTransform,
- rCandidate.maTransform));
+ if( bUndo )
+ {
+ getSdrDragView().AddUndo(new E3dRotateUndoAction(rCandidate.mp3DObj->GetModel(),
+ rCandidate.mp3DObj, rCandidate.maInitTransform,
+ rCandidate.maTransform));
+ }
}
- getSdrDragView().EndUndo();
+ if( bUndo )
+ getSdrDragView().EndUndo();
}
return TRUE;
diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx
index 97998e032d..06eb512996 100644
--- a/svx/source/engine3d/view3d.cxx
+++ b/svx/source/engine3d/view3d.cxx
@@ -628,7 +628,8 @@ BOOL E3dView::ImpCloneAll3DObjectsToDestScene(E3dScene* pSrcScene, E3dScene* pDs
bRetval = TRUE;
// Undo anlegen
- AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNewCompoundObj));
+ if( GetModel()->IsUndoEnabled() )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNewCompoundObj));
}
}
}
@@ -714,7 +715,8 @@ void E3dView::ImpChangeSomeAttributesFor3DConversion(SdrObject* pObj)
pObj->SetMergedItem(SvxColorItem(RGB_Color(COL_BLACK), EE_CHAR_COLOR));
// add undo now
- AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj, false, false));
+ if( GetModel()->IsUndoEnabled() )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj, false, false));
}
pObj->SetMergedItem(SvxColorItem(RGB_Color(COL_GRAY), EE_CHAR_COLOR));
@@ -736,7 +738,7 @@ void E3dView::ImpChangeSomeAttributesFor3DConversion2(SdrObject* pObj)
&& !nLineWidth
&& eFillStyle != XFILL_NONE)
{
- if(pObj->GetPage())
+ if(pObj->GetPage() && GetModel()->IsUndoEnabled() )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj, false, false));
pObj->SetMergedItem(XLineStyleItem(XLINE_NONE));
pObj->SetMergedItem(XLineWidthItem(0L));
diff --git a/svx/source/form/fmpgeimp.cxx b/svx/source/form/fmpgeimp.cxx
index 58e345989d..21c0f39230 100644
--- a/svx/source/form/fmpgeimp.cxx
+++ b/svx/source/form/fmpgeimp.cxx
@@ -355,10 +355,14 @@ Reference< XForm > FmFormPageImpl::getDefaultForm()
if ( !xForm.is() )
{
SdrModel* pModel = pPage->GetModel();
- XubString aStr(SVX_RES(RID_STR_FORM));
- XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
- aUndoStr.SearchAndReplace('#', aStr);
- pModel->BegUndo(aUndoStr);
+
+ if( pModel->IsUndoEnabled() )
+ {
+ XubString aStr(SVX_RES(RID_STR_FORM));
+ XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
+ aUndoStr.SearchAndReplace('#', aStr);
+ pModel->BegUndo(aUndoStr);
+ }
try
{
@@ -373,11 +377,14 @@ Reference< XForm > FmFormPageImpl::getDefaultForm()
xFormProps->setPropertyValue( FM_PROP_NAME, makeAny( sName ) );
Reference< XIndexContainer > xContainer( xForms, UNO_QUERY );
- pModel->AddUndo(new FmUndoContainerAction(*(FmFormModel*)pModel,
- FmUndoContainerAction::Inserted,
- xContainer,
- xForm,
- xContainer->getCount()));
+ if( pModel->IsUndoEnabled() )
+ {
+ pModel->AddUndo(new FmUndoContainerAction(*(FmFormModel*)pModel,
+ FmUndoContainerAction::Inserted,
+ xContainer,
+ xForm,
+ xContainer->getCount()));
+ }
xForms->insertByName( sName, makeAny( xForm ) );
xCurrentForm = xForm;
}
@@ -387,7 +394,8 @@ Reference< XForm > FmFormPageImpl::getDefaultForm()
xForm.clear();
}
- pModel->EndUndo();
+ if( pModel->IsUndoEnabled() )
+ pModel->EndUndo();
}
return xForm;
@@ -429,10 +437,17 @@ Reference< ::com::sun::star::form::XForm > FmFormPageImpl::findPlaceInFormCompo
if (!xForm.is())
{
SdrModel* pModel = pPage->GetModel();
- XubString aStr(SVX_RES(RID_STR_FORM));
- XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
- aUndoStr.SearchAndReplace('#', aStr);
- pModel->BegUndo(aUndoStr);
+
+ const bool bUndo = pModel->IsUndoEnabled();
+
+ if( bUndo )
+ {
+ XubString aStr(SVX_RES(RID_STR_FORM));
+ XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
+ aUndoStr.SearchAndReplace('#', aStr);
+ pModel->BegUndo(aUndoStr);
+ }
+
xForm = Reference< ::com::sun::star::form::XForm >(::comphelper::getProcessServiceFactory()->createInstance(FM_SUN_COMPONENT_FORM), UNO_QUERY);
// a form should always have the command type table as default
Reference< ::com::sun::star::beans::XPropertySet > xFormProps(xForm, UNO_QUERY);
@@ -465,16 +480,20 @@ Reference< ::com::sun::star::form::XForm > FmFormPageImpl::findPlaceInFormCompo
xFormProps->setPropertyValue(FM_PROP_NAME, makeAny(aName));
- Reference< ::com::sun::star::container::XIndexContainer > xContainer( getForms(), UNO_QUERY );
- pModel->AddUndo(new FmUndoContainerAction(*(FmFormModel*)pModel,
- FmUndoContainerAction::Inserted,
- xContainer,
- xForm,
- xContainer->getCount()));
-
+ if( bUndo )
+ {
+ Reference< ::com::sun::star::container::XIndexContainer > xContainer( getForms(), UNO_QUERY );
+ pModel->AddUndo(new FmUndoContainerAction(*(FmFormModel*)pModel,
+ FmUndoContainerAction::Inserted,
+ xContainer,
+ xForm,
+ xContainer->getCount()));
+ }
getForms()->insertByName(aName, makeAny(xForm));
- pModel->EndUndo();
+
+ if( bUndo )
+ pModel->EndUndo();
}
xCurrentForm = xForm;
}
diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx
index b1bcef490e..a0b5d51928 100644
--- a/svx/source/form/fmshimp.cxx
+++ b/svx/source/form/fmshimp.cxx
@@ -1214,8 +1214,14 @@ bool FmXFormShell::executeControlConversionSlot( const Reference< XFormComponent
// create an undo action
FmFormModel* pModel = m_pShell->GetFormModel();
DBG_ASSERT(pModel != NULL, "FmXFormShell::executeControlConversionSlot: my shell has no model !");
- if (pModel)
+ if (pModel && pModel->IsUndoEnabled() )
+ {
pModel->AddUndo(new FmUndoModelReplaceAction(*pModel, pFormObject, xOldModel));
+ }
+ else
+ {
+ FmUndoModelReplaceAction::DisposeElement( xOldModel );
+ }
return true;
}
diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx
index 482da6ab7d..f2d959793b 100644
--- a/svx/source/form/fmundo.cxx
+++ b/svx/source/form/fmundo.cxx
@@ -569,9 +569,9 @@ void SAL_CALL FmXUndoEnvironment::propertyChange(const PropertyChangeEvent& evt)
// now we have access to the cached info about the property affected
// and are able to decide wether or not we need an undo action
- bool bAddUndoAction = true;
+ bool bAddUndoAction = rModel.IsUndoEnabled();
// no UNDO for transient/readonly properties
- if ( aPropertyPos->second.bIsTransientOrReadOnly )
+ if ( bAddUndoAction && aPropertyPos->second.bIsTransientOrReadOnly )
bAddUndoAction = false;
if ( bAddUndoAction && aPropertyPos->second.bIsValueProperty )
@@ -996,16 +996,23 @@ FmUndoContainerAction::FmUndoContainerAction(FmFormModel& _rMod,
FmUndoContainerAction::~FmUndoContainerAction()
{
// if we own the object ....
- Reference< XComponent > xComp( m_xOwnElement, UNO_QUERY );
+ DisposeElement( m_xOwnElement );
+ DBG_DTOR(FmUndoContainerAction,NULL);
+}
+
+//------------------------------------------------------------------------------
+
+void FmUndoContainerAction::DisposeElement( const Reference< XInterface > & xElem )
+{
+ Reference< XComponent > xComp( xElem, UNO_QUERY );
if ( xComp.is() )
{
// and the object does not have a parent
- Reference< XChild > xChild( m_xOwnElement, UNO_QUERY );
+ Reference< XChild > xChild( xElem, UNO_QUERY );
if ( xChild.is() && !xChild->getParent().is() )
// -> dispose it
xComp->dispose();
}
- DBG_DTOR(FmUndoContainerAction,NULL);
}
//------------------------------------------------------------------------------
@@ -1139,10 +1146,17 @@ FmUndoModelReplaceAction::FmUndoModelReplaceAction(FmFormModel& _rMod, SdrUnoObj
FmUndoModelReplaceAction::~FmUndoModelReplaceAction()
{
// dispose our element if nobody else is responsible for
- Reference< XComponent > xComp(m_xReplaced, UNO_QUERY);
+ DisposeElement(m_xReplaced);
+}
+
+//------------------------------------------------------------------------------
+
+void FmUndoModelReplaceAction::DisposeElement( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& xReplaced )
+{
+ Reference< XComponent > xComp(xReplaced, UNO_QUERY);
if (xComp.is())
{
- Reference< XChild > xChild(m_xReplaced, UNO_QUERY);
+ Reference< XChild > xChild(xReplaced, UNO_QUERY);
if (!xChild.is() || !xChild->getParent().is())
xComp->dispose();
}
diff --git a/svx/source/form/navigatortree.cxx b/svx/source/form/navigatortree.cxx
index 39d27ad983..1bfedbfdea 100644
--- a/svx/source/form/navigatortree.cxx
+++ b/svx/source/form/navigatortree.cxx
@@ -1161,9 +1161,13 @@ namespace svxform
return DND_ACTION_NONE;
// fuer's Undo
- XubString strUndoDescription(SVX_RES(RID_STR_UNDO_CONTAINER_REPLACE));
- // TODO : den ::rtl::OUString aussagekraeftiger machen
- pFormModel->BegUndo(strUndoDescription);
+ const bool bUndo = pFormModel->IsUndoEnabled();
+
+ if( bUndo )
+ {
+ XubString strUndoDescription(SVX_RES(RID_STR_UNDO_CONTAINER_REPLACE));
+ pFormModel->BegUndo(strUndoDescription);
+ }
// ich nehme vor dem Einfuegen eines Eintrages seine Selection raus, damit die Markierung dabei nicht flackert
// -> das Handeln des Select locken
@@ -1199,9 +1203,15 @@ namespace svxform
sal_Int32 nIndex = getElementPos(Reference< XIndexAccess > (xContainer, UNO_QUERY), xCurrentChild);
GetNavModel()->m_pPropChangeList->Lock();
// die Undo-Action fuer das Rausnehmen
- if (GetNavModel()->m_pPropChangeList->CanUndo())
+ if ( bUndo && GetNavModel()->m_pPropChangeList->CanUndo())
+ {
pFormModel->AddUndo(new FmUndoContainerAction(*pFormModel, FmUndoContainerAction::Removed,
xContainer, xCurrentChild, nIndex));
+ }
+ else if( !GetNavModel()->m_pPropChangeList->CanUndo() )
+ {
+ FmUndoContainerAction::DisposeElement( xCurrentChild );
+ }
// Events mitkopieren
Reference< XEventAttacherManager > xManager(xContainer, UNO_QUERY);
@@ -1226,7 +1236,7 @@ namespace svxform
nIndex = xContainer->getCount();
// UndoAction fuer das Einfuegen
- if (GetNavModel()->m_pPropChangeList->CanUndo())
+ if ( bUndo && GetNavModel()->m_pPropChangeList->CanUndo())
pFormModel->AddUndo(new FmUndoContainerAction(*pFormModel, FmUndoContainerAction::Inserted,
xContainer, xCurrentChild, nIndex));
@@ -1272,7 +1282,9 @@ namespace svxform
}
UnlockSelectionHandling();
- pFormModel->EndUndo();
+
+ if( bUndo )
+ pFormModel->EndUndo();
// During the move, the markings of the underlying view did not change (because the view is not affected by the logical
// hierarchy of the form/control models. But my selection changed - which means I have to adjust it according to the
diff --git a/svx/source/form/navigatortreemodel.cxx b/svx/source/form/navigatortreemodel.cxx
index 63e7592cfd..d19e75f923 100644
--- a/svx/source/form/navigatortreemodel.cxx
+++ b/svx/source/form/navigatortreemodel.cxx
@@ -323,20 +323,27 @@ namespace svxform
else
xContainer = Reference< XIndexContainer > (GetForms(), UNO_QUERY);
- XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
- aUndoStr.SearchAndReplace('#', aStr);
- m_pFormModel->BegUndo(aUndoStr);
+ bool bUndo = m_pFormModel->IsUndoEnabled();
+
+ if( bUndo )
+ {
+ XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
+ aUndoStr.SearchAndReplace('#', aStr);
+ m_pFormModel->BegUndo(aUndoStr);
+ }
if (nRelPos >= (sal_uInt32)xContainer->getCount())
nRelPos = (sal_uInt32)xContainer->getCount();
// UndoAction
- if (m_pPropChangeList->CanUndo())
+ if ( bUndo && m_pPropChangeList->CanUndo())
+ {
m_pFormModel->AddUndo(new FmUndoContainerAction(*m_pFormModel,
FmUndoContainerAction::Inserted,
xContainer,
xElement,
nRelPos));
+ }
// das Element muss den Typ haben, den der Container erwartet
if (xContainer->getElementType() ==
@@ -358,7 +365,8 @@ namespace svxform
DBG_ERROR("NavigatorTreeModel::Insert : the parent container needs an elementtype I don't know !");
}
- m_pFormModel->EndUndo();
+ if( bUndo )
+ m_pFormModel->EndUndo();
}
//////////////////////////////////////////////////////////////////////
@@ -403,6 +411,8 @@ namespace svxform
if (IsListening(*m_pFormModel))
EndListening(*m_pFormModel);
+ const bool bUndo = m_pFormModel->IsUndoEnabled();
+
m_pPropChangeList->Lock();
FmFormData* pFolder = (FmFormData*) pEntry->GetParent();
Reference< XChild > xElement ( pEntry->GetChildIFace() );
@@ -414,9 +424,12 @@ namespace svxform
else
aStr = SVX_RES(RID_STR_CONTROL);
- XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_REMOVE));
- aUndoStr.SearchAndReplace('#', aStr);
- m_pFormModel->BegUndo(aUndoStr);
+ if( bUndo )
+ {
+ XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_REMOVE));
+ aUndoStr.SearchAndReplace('#', aStr);
+ m_pFormModel->BegUndo(aUndoStr);
+ }
}
// jetzt die eigentliche Entfernung der Daten aus dem Model
@@ -434,14 +447,23 @@ namespace svxform
// UndoAction
if (nContainerIndex >= 0)
{
- if (m_pPropChangeList->CanUndo())
+ if ( bUndo && m_pPropChangeList->CanUndo())
+ {
m_pFormModel->AddUndo(new FmUndoContainerAction(*m_pFormModel,
FmUndoContainerAction::Removed,
xContainer,
xElement, nContainerIndex ));
+ }
+ else if( !m_pPropChangeList->CanUndo() )
+ {
+ FmUndoContainerAction::DisposeElement( xElement );
+ }
+
xContainer->removeByIndex(nContainerIndex );
}
- m_pFormModel->EndUndo();
+
+ if( bUndo )
+ m_pFormModel->EndUndo();
}
// beim Vater austragen
diff --git a/svx/source/inc/fmundo.hxx b/svx/source/inc/fmundo.hxx
index 61abb090b3..fab29dbba6 100644
--- a/svx/source/inc/fmundo.hxx
+++ b/svx/source/inc/fmundo.hxx
@@ -119,6 +119,8 @@ public:
virtual void Undo();
virtual void Redo();
+ static void DisposeElement( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xElem );
+
protected:
void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
@@ -140,6 +142,8 @@ public:
virtual void Redo() { Undo(); }
virtual String GetComment() const;
+
+ static void DisposeElement( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& xReplaced );
};
//========================================================================
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index 2056a6a6e1..f4a0f5225c 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().IsEndDragChangesGeoAndAttributes())
+ if (DragStat().IsEndDragChangesAttributes())
+ {
+ pUndo=getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj);
+
+ 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 ( pUndo )
+ {
+ getSdrDragView().AddUndo(pUndo);
+ }
- if ( pUndo2 )
- {
- getSdrDragView().AddUndo(pUndo2);
+ 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 4946ea6768..49c2038c52 100644
--- a/svx/source/svdraw/svddrgv.cxx
+++ b/svx/source/svdraw/svddrgv.cxx
@@ -564,15 +564,16 @@ BOOL SdrDragView::EndDragObj(BOOL bCopy)
nHdlAnzMerk=GetMarkablePointCount();
}
- if (IsInsertGluePoint())
+ const bool bUndo = IsUndoEnabled();
+ if (IsInsertGluePoint() && bUndo)
{
BegUndo(aInsPointUndoStr);
AddUndo(pInsPointUndo);
}
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 4e75949ca2..7b7881eaa3 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();
-
- // 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));
+ 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 );
+
+ 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 98970572c4..76c3c3f3ab 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 );
-
- AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
+ 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));
+ }
// 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)
@@ -297,12 +361,15 @@ 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 );
-
- AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
+
+ 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));
+ }
// 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 (eHor==SDRHALIGN_CENTER && eVert==SDRVALIGN_CENTER)
+ {
+ ImpTakeDescriptionStr(STR_EditAlignCenter,aStr);
}
- } 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
+ {
+ ImpTakeDescriptionStr(STR_EditAlign,aStr);
}
- } else if (eHor==SDRHALIGN_CENTER && eVert==SDRVALIGN_CENTER) {
- ImpTakeDescriptionStr(STR_EditAlignCenter,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 73b4aa24b3..89122decf4 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 e687a023c4..6c25af2441 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 ba12b6997d..8d879ca4e1 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 a365463b02..2a36ff870c 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 becf94e01e..e568e7ea93 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 6b4ec3ba0e..37a7140941 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 ae4e79cc8d..9f6fd4da5c 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 a148269343..ab9c73ef8e 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 0e19966481..af00499280 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);
}
}
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index e9e6a60da7..cdd55c9d62 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -743,7 +743,7 @@ void Cell::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
void Cell::AddUndo()
{
SdrObject& rObj = GetObject();
- if( rObj.IsInserted() && GetModel() )
+ if( rObj.IsInserted() && GetModel() && GetModel()->IsUndoEnabled() )
{
CellRef xCell( this );
GetModel()->AddUndo( new CellUndo( &rObj, xCell ) );
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 211afa5ff4..1a83e03611 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -2106,7 +2106,7 @@ void SdrTableObj::EndTextEdit(SdrOutliner& rOutl)
{
if(rOutl.IsModified())
{
- if( GetModel() )
+ if( GetModel() && GetModel()->IsUndoEnabled() )
GetModel()->AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*this) );
OutlinerParaObject* pNewText = 0;
diff --git a/svx/source/table/tablecolumn.cxx b/svx/source/table/tablecolumn.cxx
index 10a95a4095..024f858303 100644
--- a/svx/source/table/tablecolumn.cxx
+++ b/svx/source/table/tablecolumn.cxx
@@ -161,8 +161,10 @@ void SAL_CALL TableColumn::setFastPropertyValue( sal_Int32 nHandle, const Any& a
bool bOk = false;
bool bChange = false;
+ SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
+
TableColumnUndo* pUndo = 0;
- if( mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() )
+ if( mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() && pModel && pModel->IsUndoEnabled() )
{
TableColumnRef xThis( this );
pUndo = new TableColumnUndo( xThis );
@@ -228,12 +230,8 @@ void SAL_CALL TableColumn::setFastPropertyValue( sal_Int32 nHandle, const Any& a
{
if( pUndo )
{
- SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
- if( pModel )
- {
- pModel->AddUndo( pUndo );
- pUndo = 0;
- }
+ pModel->AddUndo( pUndo );
+ pUndo = 0;
}
mxTableModel->setModified(sal_True);
}
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index ab5d250ada..c07bb66512 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -520,13 +520,15 @@ void SvxTableController::onInsert( sal_uInt16 nSId )
const OUString sSize( RTL_CONSTASCII_USTRINGPARAM( "Size" ) );
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+
switch( nSId )
{
case SID_TABLE_INSERT_COL:
{
TableModelNotifyGuard aGuard( mxTable.get() );
- if( mpModel )
+ if( bUndo )
{
mpModel->BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
@@ -544,11 +546,11 @@ void SvxTableController::onInsert( sal_uInt16 nSId )
getPropertyValue( sSize ) );
}
- if( mpModel )
- {
+ if( bUndo )
mpModel->EndUndo();
+
+ if( mpModel )
mpModel->SetChanged();
- }
aStart.mnCol = aEnd.mnCol+1;
aStart.mnRow = 0;
@@ -561,7 +563,7 @@ void SvxTableController::onInsert( sal_uInt16 nSId )
{
TableModelNotifyGuard aGuard( mxTable.get() );
- if( mpModel )
+ if( bUndo )
{
mpModel->BegUndo( ImpGetResStr(STR_TABLE_INSROW ) );
mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
@@ -579,9 +581,12 @@ void SvxTableController::onInsert( sal_uInt16 nSId )
getPropertyValue( sSize ) );
}
- if( mpModel )
+ if( bUndo )
mpModel->EndUndo();
+ if( mpModel )
+ mpModel->SetChanged();
+
aStart.mnCol = 0;
aStart.mnRow = aEnd.mnRow+1;
aEnd.mnCol = mxTable->getColumnCount() - 1;
@@ -843,9 +848,13 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
// found table style with the same name
Reference< XIndexAccess > xNewTableStyle( xTableFamilyAccess->getByName( pArg->GetValue() ), UNO_QUERY_THROW );
- pModel->BegUndo( ImpGetResStr(STR_TABLE_STYLE) );
+ const bool bUndo = pModel->IsUndoEnabled();
- pModel->AddUndo( new TableStyleUndo( *pTableObj ) );
+ if( bUndo )
+ {
+ pModel->BegUndo( ImpGetResStr(STR_TABLE_STYLE) );
+ pModel->AddUndo( new TableStyleUndo( *pTableObj ) );
+ }
/*
const sal_Int32 nRowCount = mxTable->getRowCount();
@@ -857,7 +866,8 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
if( xCell.is() )
{
- xCell->AddUndo();
+ if( bUndo )
+ xCell->AddUndo();
xCell->setAllPropertiesToDefault();
}
}
@@ -870,7 +880,9 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
*/
pTableObj->setTableStyle( xNewTableStyle );
- pModel->EndUndo();
+
+ if( bUndo )
+ pModel->EndUndo();
}
}
catch( Exception& e )
@@ -913,10 +925,18 @@ void SvxTableController::SetTableStyleSettings( const SfxItemSet* pArgs )
if( aSettings == pTableObj->getTableStyleSettings() )
return;
- pModel->BegUndo( ImpGetResStr(STR_TABLE_STYLE_SETTINGS) );
- pModel->AddUndo( new TableStyleUndo( *pTableObj ) );
+ const bool bUndo = pModel->IsUndoEnabled();
+
+ if( bUndo )
+ {
+ pModel->BegUndo( ImpGetResStr(STR_TABLE_STYLE_SETTINGS) );
+ pModel->AddUndo( new TableStyleUndo( *pTableObj ) );
+ }
+
pTableObj->setTableStyleSettings( aSettings );
- pModel->EndUndo();
+
+ if( bUndo )
+ pModel->EndUndo();
}
void SvxTableController::SetVertical( sal_uInt16 nSId )
@@ -1000,7 +1020,8 @@ void SvxTableController::SplitMarkedCells()
{
TableModelNotifyGuard aGuard( mxTable.get() );
- if( mpModel )
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ if( bUndo )
{
mpModel->BegUndo( ImpGetResStr(STR_TABLE_SPLIT) );
mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
@@ -1015,11 +1036,11 @@ void SvxTableController::SplitMarkedCells()
xRange->split( nCount, 0 );
}
- if( mpModel )
- {
+ if( bUndo )
mpModel->EndUndo();
+
+ if( mpModel )
mpModel->SetChanged();
- }
}
aEnd.mnRow += mxTable->getRowCount() - nRowCount;
aEnd.mnCol += mxTable->getColumnCount() - nColCount;
@@ -1034,7 +1055,8 @@ void SvxTableController::DistributeColumns()
SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxTableObj.get() );
if( pTableObj )
{
- if( mpModel )
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ if( bUndo )
{
mpModel->BegUndo( ImpGetResStr(STR_TABLE_DISTRIBUTE_COLUMNS) );
mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
@@ -1044,7 +1066,7 @@ void SvxTableController::DistributeColumns()
getSelectedCells( aStart, aEnd );
pTableObj->DistributeColumns( aStart.mnCol, aEnd.mnCol );
- if( mpModel )
+ if( bUndo )
mpModel->EndUndo();
}
}
@@ -1054,7 +1076,8 @@ void SvxTableController::DistributeRows()
SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxTableObj.get() );
if( pTableObj )
{
- if( mpModel )
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ if( bUndo )
{
mpModel->BegUndo( ImpGetResStr(STR_TABLE_DISTRIBUTE_ROWS) );
mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
@@ -1064,7 +1087,7 @@ void SvxTableController::DistributeRows()
getSelectedCells( aStart, aEnd );
pTableObj->DistributeRows( aStart.mnRow, aEnd.mnRow );
- if( mpModel )
+ if( bUndo )
mpModel->EndUndo();
}
}
@@ -1543,7 +1566,8 @@ void SvxTableController::MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, s
Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( nFirstCol, nFirstRow,nLastCol, nLastRow ) ), UNO_QUERY_THROW );
if( xRange->isMergeable() )
{
- if( mpModel )
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ if( bUndo )
{
mpModel->BegUndo( ImpGetResStr(STR_TABLE_MERGE) );
mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*mxTableObj.get()) );
@@ -1551,7 +1575,7 @@ void SvxTableController::MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, s
xRange->merge();
- if( mpModel )
+ if( bUndo )
mpModel->EndUndo();
}
}
@@ -2257,7 +2281,9 @@ void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bR
{
if( mxTable.is() )
{
- if( mpModel )
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+
+ if( bUndo )
mpModel->BegUndo( ImpGetResStr(STR_TABLE_NUMFORMAT) );
CellPos aStart, aEnd;
@@ -2281,7 +2307,8 @@ void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bR
CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
if( xCell.is() )
{
- xCell->AddUndo();
+ if( bUndo )
+ xCell->AddUndo();
xCell->SetMergedItemSetAndBroadcast(aAttr, bReplaceAll);
}
}
@@ -2294,7 +2321,7 @@ void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bR
UpdateTableShape();
- if( mpModel )
+ if( bUndo )
mpModel->EndUndo();
}
diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx
index 2972fb0be5..06293ea226 100644
--- a/svx/source/table/tablelayouter.cxx
+++ b/svx/source/table/tablelayouter.cxx
@@ -98,19 +98,21 @@ basegfx::B2ITuple TableLayouter::getCellSize( const CellPos& rPos ) const
{
CellPos aPos( rPos );
- sal_Int32 nRowSpan = xCell->getRowSpan()-1;
- do
+ sal_Int32 nRowCount = getRowCount();
+ sal_Int32 nRowSpan = std::max( xCell->getRowSpan(), (sal_Int32)1 );
+ while( nRowSpan && (aPos.mnRow < nRowCount) )
{
height += maRows[aPos.mnRow++].mnSize;
+ nRowSpan--;
}
- while( nRowSpan-- );
- sal_Int32 nColSpan = xCell->getColumnSpan()-1;
- do
+ sal_Int32 nColCount = getColumnCount();
+ sal_Int32 nColSpan = std::max( xCell->getColumnSpan(), (sal_Int32)1 );
+ while( nColSpan && (aPos.mnCol < nColCount ) )
{
width += maColumns[aPos.mnCol++].mnSize;
+ nColSpan--;
}
- while( nColSpan-- );
}
}
catch( Exception& )
@@ -127,7 +129,7 @@ bool TableLayouter::getCellArea( const CellPos& rPos, basegfx::B2IRectangle& rAr
try
{
CellRef xCell( getCell( rPos ) );
- if( xCell.is() && !xCell->isMerged() )
+ if( xCell.is() && !xCell->isMerged() && isValid(rPos) )
{
const basegfx::B2ITuple aCellSize( getCellSize( rPos ) );
@@ -149,7 +151,7 @@ bool TableLayouter::getCellArea( const CellPos& rPos, basegfx::B2IRectangle& rAr
sal_Int32 TableLayouter::getRowHeight( sal_Int32 nRow )
{
- if( (nRow >= 0) && (nRow < getRowCount()) )
+ if( isValidRow(nRow) )
return maRows[nRow].mnSize;
else
return 0;
@@ -159,18 +161,21 @@ sal_Int32 TableLayouter::getRowHeight( sal_Int32 nRow )
void TableLayouter::setRowHeight( sal_Int32 nRow, sal_Int32 nHeight )
{
- const sal_Int32 nCount = getRowCount();
-
- DBG_ASSERT( (nRow >= 0) && (nRow < nCount), "TableLayouter::setRowHeight(), row out of range!" );
- if( (nRow >= 0) && (nRow < nCount) && (nHeight != maRows[nRow].mnSize) )
+ if( isValidRow(nRow) )
+ {
maRows[nRow].mnSize = nHeight;
+ }
+ else
+ {
+ DBG_ERROR( "TableLayouter::setRowHeight(), row out of range!" );
+ }
}
// -----------------------------------------------------------------------------
sal_Int32 TableLayouter::getColumnWidth( sal_Int32 nColumn )
{
- if( (nColumn >= 0) && (nColumn < getColumnCount()) )
+ if( isValidColumn(nColumn) )
return maColumns[nColumn].mnSize;
else
return 0;
@@ -180,11 +185,10 @@ sal_Int32 TableLayouter::getColumnWidth( sal_Int32 nColumn )
void TableLayouter::setColumnWidth( sal_Int32 nColumn, sal_Int32 nWidth )
{
- const sal_Int32 nCount = getColumnCount();
-
- DBG_ASSERT( (nColumn >= 0) && (nColumn < nCount), "TableLayouter::setColumnWidth(), column out of range!" );
- if( (nColumn >= 0) && (nColumn < nCount) )
+ if( isValidColumn(nColumn) )
maColumns[nColumn].mnSize = nWidth;
+ else
+ DBG_ERROR( "TableLayouter::setColumnWidth(), column out of range!" );
}
// -----------------------------------------------------------------------------
@@ -1149,7 +1153,7 @@ void TableLayouter::SetWritingMode( com::sun::star::text::WritingMode eWritingMo
sal_Int32 TableLayouter::getColumnStart( sal_Int32 nColumn ) const
{
- if( (nColumn >= 0) && (nColumn < getColumnCount()) )
+ if( isValidColumn(nColumn) )
return maColumns[nColumn].mnPos;
else
return 0;
@@ -1159,7 +1163,7 @@ sal_Int32 TableLayouter::getColumnStart( sal_Int32 nColumn ) const
sal_Int32 TableLayouter::getRowStart( sal_Int32 nRow ) const
{
- if( (nRow >= 0) && (nRow < getRowCount()) )
+ if( isValidRow(nRow) )
return maRows[nRow].mnPos;
else
return 0;
diff --git a/svx/source/table/tablelayouter.hxx b/svx/source/table/tablelayouter.hxx
index 0c7d146a78..f1bb421cbe 100644
--- a/svx/source/table/tablelayouter.hxx
+++ b/svx/source/table/tablelayouter.hxx
@@ -140,6 +140,7 @@ private:
inline bool isValidColumn( sal_Int32 nColumn ) const { return (nColumn >= 0) && (nColumn < static_cast<sal_Int32>( maColumns.size())); }
inline bool isValidRow( sal_Int32 nRow ) const { return (nRow >= 0) && (nRow < static_cast<sal_Int32>( maRows.size())); }
+ inline bool isValid( const CellPos& rPos ) const { return isValidColumn( rPos.mnCol ) && isValidRow( rPos.mnRow ); }
void ClearBorderLayout();
void ClearBorderLayout(BorderLineMap& rMap);
diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx
index d0400ff59b..d74147ce5c 100644
--- a/svx/source/table/tablemodel.cxx
+++ b/svx/source/table/tablemodel.cxx
@@ -749,7 +749,8 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
aNewColumns[nOffset] = xNewCol;
}
- if( pModel && mpTableObj->IsInserted() )
+ const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ if( bUndo )
{
pModel->BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
@@ -783,7 +784,7 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
// cell merges over newly created columns, so add the new columns to the merged cell
const sal_Int32 nRowSpan = xCell->getRowSpan();
nColSpan += nCount;
- if( pModel && mpTableObj->IsInserted() )
+ if( bUndo )
xCell->AddUndo();
xCell->merge( nColSpan, nRowSpan );
// set newly inserted cells to merged state
@@ -800,7 +801,7 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
}
}
- if( pModel && mpTableObj->IsInserted() )
+ if( bUndo )
pModel->EndUndo();
}
@@ -832,7 +833,9 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
sal_Int32 nRows = getRowCountImpl();
SdrModel* pModel = mpTableObj->GetModel();
- if( pModel && mpTableObj->IsInserted() )
+
+ const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ if( bUndo )
{
pModel->BegUndo( ImpGetResStr(STR_UNDO_COL_DELETE) );
pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
@@ -882,7 +885,8 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
CellRef xTargetCell( getCell( nIndex + nCount, nRow ) );
if( xTargetCell.is() )
{
- xTargetCell->AddUndo();
+ if( bUndo )
+ xTargetCell->AddUndo();
xTargetCell->merge( nColSpan - nRemove, xCell->getRowSpan() );
xTargetCell->replaceContentAndFormating( xCell );
}
@@ -892,7 +896,7 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
{
// current cells spans inside the removed columns, so adjust
const sal_Int32 nRemove = ::std::min( nCount, nCol + nColSpan - nIndex );
- if( mpTableObj->IsInserted() )
+ if( bUndo )
xCell->AddUndo();
xCell->merge( nColSpan - nRemove, xCell->getRowSpan() );
}
@@ -904,7 +908,7 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
while( nRows-- )
maRows[nRows]->removeColumns( nIndex, nCount );
- if( pModel && mpTableObj->IsInserted() )
+ if( bUndo )
pModel->EndUndo();
}
catch( Exception& )
@@ -924,7 +928,7 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
if( nCount && mpTableObj )
{
SdrModel* pModel = mpTableObj->GetModel();
- bool bBegUndo = false;
+ const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
try
{
TableModelNotifyGuard aGuard( this );
@@ -940,13 +944,12 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
aNewRows[nOffset] = xNewRow;
}
- if( pModel && mpTableObj->IsInserted() )
- {
+ if( bUndo )
+ {
pModel->BegUndo( ImpGetResStr(STR_TABLE_INSROW) );
pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
TableModelRef xThis( this );
pModel->AddUndo( new InsertRowUndo( xThis, nIndex, aNewRows ) );
- bBegUndo = true;
}
// check if cells merge over new columns
@@ -961,7 +964,8 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
// cell merges over newly created columns, so add the new columns to the merged cell
const sal_Int32 nColSpan = xCell->getColumnSpan();
nRowSpan += nCount;
- xCell->AddUndo();
+ if( bUndo )
+ xCell->AddUndo();
xCell->merge( nColSpan, nRowSpan );
// set newly inserted cells to merged state
@@ -982,7 +986,7 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
{
DBG_ERROR("sdr::table::TableModel::insertRows(), exception caught!");
}
- if( pModel && bBegUndo )
+ if( bUndo )
pModel->EndUndo();
updateRows();
@@ -998,6 +1002,9 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
if( mpTableObj && nCount && (nIndex >= 0) && (nIndex < nRowCount) )
{
+ SdrModel* pModel = mpTableObj->GetModel();
+ const bool bUndo = pModel && mpTableObj->IsInserted()&& pModel->IsUndoEnabled();
+
try
{
TableModelNotifyGuard aGuard( this );
@@ -1006,8 +1013,7 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
if( (nIndex + nCount) > nRowCount )
nCount = nRowCount - nIndex;
- SdrModel* pModel = mpTableObj->GetModel();
- if( pModel && mpTableObj->IsInserted() )
+ if( bUndo )
{
pModel->BegUndo( ImpGetResStr(STR_UNDO_ROW_DELETE) );
pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
@@ -1047,7 +1053,8 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
CellRef xTargetCell( getCell( nCol, nIndex + nCount ) );
if( xTargetCell.is() )
{
- xTargetCell->AddUndo();
+ if( bUndo )
+ xTargetCell->AddUndo();
xTargetCell->merge( xCell->getColumnSpan(), nRowSpan - nRemove );
xTargetCell->replaceContentAndFormating( xCell );
}
@@ -1057,7 +1064,8 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
{
// current cells spans inside the removed rows, so adjust
const sal_Int32 nRemove = ::std::min( nCount, nRow + nRowSpan - nIndex );
- xCell->AddUndo();
+ if( bUndo )
+ xCell->AddUndo();
xCell->merge( xCell->getColumnSpan(), nRowSpan - nRemove );
}
}
@@ -1066,7 +1074,7 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
// now remove the rows
remove_range<RowVector,RowVector::iterator>( maRows, nIndex, nCount );
- if( pModel )
+ if( bUndo )
pModel->EndUndo();
}
catch( Exception& )
diff --git a/svx/source/table/tablerow.cxx b/svx/source/table/tablerow.cxx
index 27f5b60438..df71084374 100644
--- a/svx/source/table/tablerow.cxx
+++ b/svx/source/table/tablerow.cxx
@@ -233,7 +233,12 @@ void SAL_CALL TableRow::setFastPropertyValue( sal_Int32 nHandle, const Any& aVal
bool bChange = false;
TableRowUndo* pUndo = 0;
- if( mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() )
+
+ SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
+
+ const bool bUndo = mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() && pModel && pModel->IsUndoEnabled();
+
+ if( bUndo )
{
TableRowRef xThis( this );
pUndo = new TableRowUndo( xThis );
@@ -300,12 +305,8 @@ void SAL_CALL TableRow::setFastPropertyValue( sal_Int32 nHandle, const Any& aVal
{
if( pUndo )
{
- SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
- if( pModel )
- {
- pModel->AddUndo( pUndo );
- pUndo = 0;
- }
+ pModel->AddUndo( pUndo );
+ pUndo = 0;
}
mxTableModel->setModified(sal_True);
}
diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx
index dd7faafe50..87e65ec556 100644
--- a/svx/source/tbxctrls/grafctrl.cxx
+++ b/svx/source/tbxctrls/grafctrl.cxx
@@ -861,16 +861,23 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView )
SfxItemPool& rPool = rView.GetModel()->GetItemPool();
SfxItemSet aSet( rPool, SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST );
- String aUndoStr( rView.GetDescriptionOfMarkedObjects() );
+ const bool bUndo = rView.IsUndoEnabled();
+
+ String aUndoStr;
+
+ if( bUndo )
+ {
+ aUndoStr = rView.GetDescriptionOfMarkedObjects();
+ aUndoStr.Append( sal_Unicode(' ') );
+ }
+
const SfxItemSet* pArgs = rReq.GetArgs();
const SfxPoolItem* pItem;
USHORT nSlot = rReq.GetSlot();
if( !pArgs || SFX_ITEM_SET != pArgs->GetItemState( nSlot, FALSE, &pItem ))
pItem = 0;
-
- aUndoStr.Append( sal_Unicode(' ') );
-
+
switch( nSlot )
{
case SID_ATTR_GRAF_RED:
@@ -878,7 +885,8 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView )
if( pItem )
{
aSet.Put( SdrGrafRedItem( ((SfxInt16Item*)pItem)->GetValue() ));
- aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFRED ) ) );
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFRED ) ) );
}
}
break;
@@ -888,7 +896,8 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView )
if( pItem )
{
aSet.Put( SdrGrafGreenItem( ((SfxInt16Item*)pItem)->GetValue() ));
- aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFGREEN ) ) );
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFGREEN ) ) );
}
}
break;
@@ -898,7 +907,8 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView )
if( pItem )
{
aSet.Put( SdrGrafBlueItem( ((SfxInt16Item*)pItem)->GetValue() ));
- aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFBLUE ) ) );
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFBLUE ) ) );
}
}
break;
@@ -908,7 +918,8 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView )
if( pItem )
{
aSet.Put( SdrGrafLuminanceItem( ((SfxInt16Item*)pItem)->GetValue() ));
- aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFLUMINANCE ) ) );
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFLUMINANCE ) ) );
}
}
break;
@@ -918,7 +929,8 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView )
if( pItem )
{
aSet.Put( SdrGrafContrastItem( ((SfxInt16Item*)pItem)->GetValue() ));
- aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFCONTRAST ) ) );
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFCONTRAST ) ) );
}
}
break;
@@ -928,7 +940,8 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView )
if( pItem )
{
aSet.Put( SdrGrafGamma100Item( ((SfxUInt32Item*)pItem)->GetValue() ));
- aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFGAMMA ) ) );
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFGAMMA ) ) );
}
}
break;
@@ -938,7 +951,8 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView )
if( pItem )
{
aSet.Put( SdrGrafTransparenceItem( ((SfxUInt16Item*)pItem)->GetValue() ));
- aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFTRANSPARENCY ) ) );
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFTRANSPARENCY ) ) );
}
}
break;
@@ -948,7 +962,8 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView )
if( pItem )
{
aSet.Put( SdrGrafModeItem( (GraphicDrawMode) ((SfxUInt16Item*)pItem)->GetValue() ));
- aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFMODE ) ) );
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFMODE ) ) );
}
}
break;
@@ -1075,11 +1090,16 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView )
rView.SetMarkedObjRect( aNewRect );
else
{
- rView.BegUndo( aUndoStr );
- rView.AddUndo( rView.GetModel()->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
+ if( bUndo )
+ {
+ rView.BegUndo( aUndoStr );
+ rView.AddUndo( rView.GetModel()->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
+ }
pObj->SetSnapRect( aNewRect );
rView.SetAttributes( aSet );
- rView.EndUndo();
+
+ if( bUndo )
+ rView.EndUndo();
aSet.ClearItem();
}
}
@@ -1106,9 +1126,13 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView )
if( aSet.Count() )
{
- rView.BegUndo( aUndoStr );
+ if( bUndo )
+ rView.BegUndo( aUndoStr );
+
rView.SetAttributes( aSet );
- rView.EndUndo();
+
+ if( bUndo )
+ rView.EndUndo();
}
}
diff --git a/svx/source/toolbars/extrusionbar.cxx b/svx/source/toolbars/extrusionbar.cxx
index 4becb5bbfb..2112510162 100644
--- a/svx/source/toolbars/extrusionbar.cxx
+++ b/svx/source/toolbars/extrusionbar.cxx
@@ -514,6 +514,9 @@ void ExtrusionBar::execute( SdrView* pSdrView, SfxRequest& rReq, SfxBindings& rB
{
sal_uInt16 nSID = rReq.GetSlot();
sal_uInt16 nStrResId = 0;
+
+ const bool bUndo = pSdrView && pSdrView->IsUndoEnabled();
+
switch( nSID )
{
case SID_EXTRUSION_TOOGLE:
@@ -584,14 +587,18 @@ void ExtrusionBar::execute( SdrView* pSdrView, SfxRequest& rReq, SfxBindings& rB
SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
if( pObj->ISA(SdrObjCustomShape) )
{
- String aStr( SVX_RES( nStrResId ) );
- pSdrView->BegUndo( aStr );
- pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
+ if( bUndo )
+ {
+ String aStr( SVX_RES( nStrResId ) );
+ pSdrView->BegUndo( aStr );
+ pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
+ }
SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
impl_execute( pSdrView, rReq, aGeometryItem, pObj );
pObj->SetMergedItem( aGeometryItem );
pObj->BroadcastObjectChange();
- pSdrView->EndUndo();
+ if( bUndo )
+ pSdrView->EndUndo();
// simulate a context change:
// force SelectionHasChanged() being called
diff --git a/svx/source/toolbars/fontworkbar.cxx b/svx/source/toolbars/fontworkbar.cxx
index 4044560e1f..11130e35c6 100644
--- a/svx/source/toolbars/fontworkbar.cxx
+++ b/svx/source/toolbars/fontworkbar.cxx
@@ -492,9 +492,14 @@ void FontworkBar::execute( SdrView* pSdrView, SfxRequest& rReq, SfxBindings& rBi
SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
if( pObj->ISA(SdrObjCustomShape) )
{
- String aStr( SVX_RES( RID_SVXSTR_UNDO_APPLY_FONTWORK_SHAPE ) );
- pSdrView->BegUndo( aStr );
- pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
+ const bool bUndo = pSdrView->IsUndoEnabled();
+
+ if( bUndo )
+ {
+ String aStr( SVX_RES( RID_SVXSTR_UNDO_APPLY_FONTWORK_SHAPE ) );
+ pSdrView->BegUndo( aStr );
+ pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
+ }
SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
GetGeometryForCustomShape( aGeometryItem, aCustomShape );
pObj->SetMergedItem( aGeometryItem );
@@ -508,7 +513,8 @@ void FontworkBar::execute( SdrView* pSdrView, SfxRequest& rReq, SfxBindings& rBi
}
pObj->BroadcastObjectChange();
- pSdrView->EndUndo();
+ if( bUndo )
+ pSdrView->EndUndo();
pSdrView->AdjustMarkHdl(); //HMH sal_True );
rBindings.Invalidate( SID_FONTWORK_SHAPE_TYPE );
}
@@ -562,14 +568,19 @@ void FontworkBar::execute( SdrView* pSdrView, SfxRequest& rReq, SfxBindings& rBi
SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
if( pObj->ISA(SdrObjCustomShape) )
{
- String aStr( SVX_RES( nStrResId ) );
- pSdrView->BegUndo( aStr );
- pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
+ const bool bUndo = pSdrView->IsUndoEnabled();
+ if( bUndo )
+ {
+ String aStr( SVX_RES( nStrResId ) );
+ pSdrView->BegUndo( aStr );
+ pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
+ }
SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
impl_execute( pSdrView, rReq, aGeometryItem, pObj );
pObj->SetMergedItem( aGeometryItem );
pObj->BroadcastObjectChange();
- pSdrView->EndUndo();
+ if( bUndo )
+ pSdrView->EndUndo();
}
}
}