summaryrefslogtreecommitdiff
path: root/svx/source/svdraw
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2013-02-13 08:52:52 +0100
committerThorsten Behrens <tbehrens@suse.com>2013-02-19 09:42:48 +0000
commit3432c63c0cdcdfe3e74702c16ce6c746d9c0fdf4 (patch)
treed2747959a559534efcb92fdb26e57f576c19bd2c /svx/source/svdraw
parentd35dd1dbd89e390eb1bcfa50e2f02e7c65bdb0ab (diff)
fdo#34548 don't crash on undoing text frame removal
Change-Id: I48b95c6c0cbfb2f4c4b09cc90b254b96de40b3e9 (cherry picked from commit 115054fef08998c56cba8f14472df1d15007f635) Reviewed-on: https://gerrit.libreoffice.org/2232 Reviewed-by: Thorsten Behrens <tbehrens@suse.com> Tested-by: Thorsten Behrens <tbehrens@suse.com>
Diffstat (limited to 'svx/source/svdraw')
-rw-r--r--svx/source/svdraw/svdundo.cxx62
1 files changed, 61 insertions, 1 deletions
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
index 452761dc8b57..c1e4b4dd1ff9 100644
--- a/svx/source/svdraw/svdundo.cxx
+++ b/svx/source/svdraw/svdundo.cxx
@@ -18,6 +18,8 @@
*/
+#include <svl/lstner.hxx>
+
#include <svx/svdundo.hxx>
#include "svx/svditext.hxx"
#include <svx/svdotext.hxx>
@@ -655,11 +657,55 @@ OUString SdrUndoGeoObj::GetComment() const
////////////////////////////////////////////////////////////////////////////////////////////////////
+class SdrUndoObjList::ObjListListener : public SfxListener
+{
+public:
+ ObjListListener(SdrUndoObjList& rThat, SdrObject& rObject, SfxBroadcaster& rBroadcaster);
+ ~ObjListListener();
+
+private:
+ virtual void Notify(SfxBroadcaster& rBroadcaster, const SfxHint& rHint);
+
+private:
+ SdrUndoObjList& m_rThat;
+ SdrObject& m_rObject;
+ SfxBroadcaster* m_pBroadcaster;
+};
+
+SdrUndoObjList::ObjListListener::ObjListListener(SdrUndoObjList& rThat, SdrObject& rObject, SfxBroadcaster& rBroadcaster)
+ : m_rThat(rThat)
+ , m_rObject(rObject)
+ , m_pBroadcaster(&rBroadcaster)
+{
+ StartListening(*m_pBroadcaster);
+}
+
+SdrUndoObjList::ObjListListener::~ObjListListener()
+{
+ if (m_pBroadcaster)
+ EndListening(*m_pBroadcaster);
+}
+
+void SdrUndoObjList::ObjListListener::Notify(SfxBroadcaster&, const SfxHint& rHint)
+{
+ const SdrHint* const pSdrHint(dynamic_cast<const SdrHint*>(&rHint));
+ if (pSdrHint)
+ {
+ if ((pSdrHint->GetObject() == &m_rObject) && (pSdrHint->GetKind() == HINT_OBJCHG))
+ {
+ const sal_uInt32 nNewOrdNum(m_rObject.GetOrdNum());
+ if (nNewOrdNum != m_rThat.GetOrdNum())
+ m_rThat.SetOrdNum(nNewOrdNum);
+ }
+ }
+}
+
SdrUndoObjList::SdrUndoObjList(SdrObject& rNewObj, bool bOrdNumDirect)
: SdrUndoObj(rNewObj),
bOwner(sal_False),
pView(NULL),
- pPageView(NULL)
+ pPageView(NULL),
+ m_pListener(NULL)
{
pObjList=pObj->GetObjList();
if (bOrdNumDirect) {
@@ -667,10 +713,14 @@ SdrUndoObjList::SdrUndoObjList(SdrObject& rNewObj, bool bOrdNumDirect)
} else {
nOrdNum=pObj->GetOrdNum();
}
+
+ m_pListener = new ObjListListener(*this, *pObj, *pObjList->GetModel());
}
SdrUndoObjList::~SdrUndoObjList()
{
+ delete m_pListener;
+
if (pObj!=NULL && IsOwner())
{
// Attribute have to go back to the regular Pool
@@ -686,6 +736,16 @@ void SdrUndoObjList::SetOwner(bool bNew)
bOwner = bNew;
}
+sal_uInt32 SdrUndoObjList::GetOrdNum() const
+{
+ return nOrdNum;
+}
+
+void SdrUndoObjList::SetOrdNum(sal_uInt32 nOrdNum_)
+{
+ nOrdNum = nOrdNum_;
+}
+
////////////////////////////////////////////////////////////////////////////////////////////////////
void SdrUndoRemoveObj::Undo()