summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-07-24 10:26:15 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-07-24 12:46:55 +0100
commit183bde5bf5aa048792880292ac77777577fcd13b (patch)
treea6005359c8a1f354760ac388fa5dba4ad84caafc
parent11fab6b705638359b2ca0e3e85590aa7cc70a03a (diff)
Related: fdo#81641 implement undo of Conditional Text style creation
and deletion Change-Id: I694ae8f917c74305cd30037c3c3833a980354948
-rw-r--r--sw/source/core/doc/docfmt.cxx18
-rw-r--r--sw/source/core/inc/SwUndoFmt.hxx15
-rw-r--r--sw/source/core/undo/SwUndoFmt.cxx22
3 files changed, 53 insertions, 2 deletions
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 605349703348..d70b4602026f 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -907,6 +907,13 @@ SwConditionTxtFmtColl* SwDoc::MakeCondTxtFmtColl( const OUString &rFmtName,
pFmtColl->SetAuto( false );
SetModified();
+ if (GetIDocumentUndoRedo().DoesUndo())
+ {
+ SwUndo * pUndo = new SwUndoCondTxtFmtCollCreate(pFmtColl, pDerivedFrom,
+ this);
+ GetIDocumentUndoRedo().AppendUndo(pUndo);
+ }
+
if (bBroadcast)
BroadcastStyleOperation(rFmtName, SFX_STYLE_FAMILY_PARA,
SFX_STYLESHEET_CREATED);
@@ -942,8 +949,15 @@ void SwDoc::DelTxtFmtColl(sal_uInt16 nFmtColl, bool bBroadcast)
if (GetIDocumentUndoRedo().DoesUndo())
{
- SwUndoTxtFmtCollDelete * pUndo =
- new SwUndoTxtFmtCollDelete(pDel, this);
+ SwUndoTxtFmtCollDelete * pUndo;
+ if (RES_CONDTXTFMTCOLL == pDel->Which())
+ {
+ pUndo = new SwUndoCondTxtFmtCollDelete(pDel, this);
+ }
+ else
+ {
+ pUndo = new SwUndoTxtFmtCollDelete(pDel, this);
+ }
GetIDocumentUndoRedo().AppendUndo(pUndo);
}
diff --git a/sw/source/core/inc/SwUndoFmt.hxx b/sw/source/core/inc/SwUndoFmt.hxx
index 81289cd3690a..cb20d7fa3003 100644
--- a/sw/source/core/inc/SwUndoFmt.hxx
+++ b/sw/source/core/inc/SwUndoFmt.hxx
@@ -26,6 +26,7 @@
class SwDoc;
class SwTxtFmtColl;
+class SwConditionTxtFmtColl;
class SwRewriter;
class SfxItemSet;
@@ -120,6 +121,20 @@ public:
virtual SwFmt * Find(const OUString & rName) const SAL_OVERRIDE;
};
+class SwUndoCondTxtFmtCollCreate : public SwUndoTxtFmtCollCreate
+{
+public:
+ SwUndoCondTxtFmtCollCreate(SwConditionTxtFmtColl * pNew, SwTxtFmtColl * pDerivedFrom, SwDoc * pDoc);
+ virtual SwFmt * Create(SwFmt * pDerivedFrom) SAL_OVERRIDE;
+};
+
+class SwUndoCondTxtFmtCollDelete : public SwUndoTxtFmtCollDelete
+{
+public:
+ SwUndoCondTxtFmtCollDelete(SwTxtFmtColl * pOld, SwDoc * pDoc);
+ virtual SwFmt * Create(SwFmt * pDerivedFrom) SAL_OVERRIDE;
+};
+
class SwUndoRenameFmtColl : public SwUndoRenameFmt
{
public:
diff --git a/sw/source/core/undo/SwUndoFmt.cxx b/sw/source/core/undo/SwUndoFmt.cxx
index 96cbde736cc1..626f1a5cc23f 100644
--- a/sw/source/core/undo/SwUndoFmt.cxx
+++ b/sw/source/core/undo/SwUndoFmt.cxx
@@ -232,6 +232,28 @@ SwFmt * SwUndoTxtFmtCollDelete::Find(const OUString & rName) const
return pDoc->FindTxtFmtCollByName(rName);
}
+SwUndoCondTxtFmtCollCreate::SwUndoCondTxtFmtCollCreate(SwConditionTxtFmtColl *_pNew,
+ SwTxtFmtColl *_pDerivedFrom, SwDoc *_pDoc)
+ : SwUndoTxtFmtCollCreate(_pNew, _pDerivedFrom, _pDoc)
+{
+}
+
+SwFmt * SwUndoCondTxtFmtCollCreate::Create(SwFmt * pDerivedFrom)
+{
+ return pDoc->MakeCondTxtFmtColl(sNewName, (SwTxtFmtColl *)pDerivedFrom, true);
+}
+
+SwUndoCondTxtFmtCollDelete::SwUndoCondTxtFmtCollDelete(SwTxtFmtColl * _pOld,
+ SwDoc * _pDoc)
+ : SwUndoTxtFmtCollDelete(_pOld, _pDoc)
+{
+}
+
+SwFmt * SwUndoCondTxtFmtCollDelete::Create(SwFmt * pDerivedFrom)
+{
+ return pDoc->MakeCondTxtFmtColl(sOldName, (SwTxtFmtColl *) pDerivedFrom, true);
+}
+
SwUndoRenameFmtColl::SwUndoRenameFmtColl(const OUString & sInitOldName,
const OUString & sInitNewName,
SwDoc * _pDoc)