[Libreoffice-commits] core.git: Branch 'libreoffice-3-6' - svx/inc svx/source
David Tardon
dtardon at redhat.com
Tue Feb 19 04:08:04 PST 2013
svx/inc/svx/svdundo.hxx | 9 ++++++
svx/source/svdraw/svdundo.cxx | 62 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 70 insertions(+), 1 deletion(-)
New commits:
commit 156d6552ce70ed387668d20e9000b5e725bda45f
Author: David Tardon <dtardon at redhat.com>
Date: Wed Feb 13 08:52:52 2013 +0100
fdo#34548 don't crash on undoing text frame removal
Change-Id: I48b95c6c0cbfb2f4c4b09cc90b254b96de40b3e9
(cherry picked from commit 115054fef08998c56cba8f14472df1d15007f635)
Reviewed-on: https://gerrit.libreoffice.org/2233
Tested-by: Caolán McNamara <caolanm at redhat.com>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/svx/inc/svx/svdundo.hxx b/svx/inc/svx/svdundo.hxx
index 3b0436a..ba3a4b7 100644
--- a/svx/inc/svx/svdundo.hxx
+++ b/svx/inc/svx/svdundo.hxx
@@ -260,6 +260,10 @@ public:
//************************************************************
class SVX_DLLPUBLIC SdrUndoObjList : public SdrUndoObj {
+ class ObjListListener;
+ friend class ObjListListener;
+
+private:
bool bOwner;
protected:
@@ -269,6 +273,7 @@ protected:
sal_uInt32 nOrdNum;
// Bei einem Undo/Redo findet moeglicherweise Uebereignung des Objektes
// statt. Im Dtor wird das Obj deleted, wenn bOwner==TRUE
+ ObjListListener* m_pListener;
protected:
SdrUndoObjList(SdrObject& rNewObj, bool bOrdNumDirect = false);
@@ -277,6 +282,10 @@ protected:
void SetView(SdrView* pView1, SdrPageView* pPageView1) { pView=pView1; pPageView=pPageView1; }
bool IsOwner() { return bOwner; }
void SetOwner(bool bNew);
+
+private:
+ sal_uInt32 GetOrdNum() const;
+ void SetOrdNum(sal_uInt32 nOrdNum_);
};
//************************************************************
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
index b3fca80..52e4f11 100644
--- a/svx/source/svdraw/svdundo.cxx
+++ b/svx/source/svdraw/svdundo.cxx
@@ -27,6 +27,8 @@
************************************************************************/
+#include <svl/lstner.hxx>
+
#include <svx/svdundo.hxx>
#include "svx/svditext.hxx"
#include <svx/svdotext.hxx>
@@ -673,11 +675,55 @@ rtl::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) {
@@ -685,10 +731,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
@@ -704,6 +754,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()
More information about the Libreoffice-commits
mailing list