summaryrefslogtreecommitdiff
path: root/sw/source/core/undo/untbl.cxx
diff options
context:
space:
mode:
authorJakub Trzebiatowski <ubap.dev@gmail.com>2016-08-02 14:57:17 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-08-10 07:40:53 +0000
commit0943ee2decb8d5a1a2a5bf3b1c233934a89e9c97 (patch)
tree535b6bdbc808ab4119a5e6aa73d408645414c4b5 /sw/source/core/undo/untbl.cxx
parent1b482aec4e7b6aec86fb20bcda555c4060a80332 (diff)
GSoC Writer Table Styles; Create by example; fix undo
- Create style by example, tracked by undo; - Fixed delete style, now is tracked by undo Change-Id: Ic39b549b0b970b1b15001d527a82fb26e4a630aa Reviewed-on: https://gerrit.libreoffice.org/27990 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw/source/core/undo/untbl.cxx')
-rw-r--r--sw/source/core/undo/untbl.cxx63
1 files changed, 63 insertions, 0 deletions
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index ffabd817ef4c..be0801b6936e 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -3170,4 +3170,67 @@ void CheckTable( const SwTable& rTable )
}
#endif
+SwUndoTableStyleMake::SwUndoTableStyleMake(const OUString& rName, const SwDoc* pDoc)
+ : SwUndo(UNDO_TBLSTYLE_CREATE, pDoc),
+ m_sName(rName)
+{ }
+
+SwUndoTableStyleMake::~SwUndoTableStyleMake()
+{ }
+
+void SwUndoTableStyleMake::UndoImpl(::sw::UndoRedoContext & rContext)
+{
+ m_pAutoFormat = rContext.GetDoc().DelTableStyle(m_sName, true);
+}
+
+void SwUndoTableStyleMake::RedoImpl(::sw::UndoRedoContext & rContext)
+{
+ if (m_pAutoFormat.get())
+ {
+ SwTableAutoFormat* pFormat = rContext.GetDoc().MakeTableStyle(m_sName, true);
+ if (pFormat)
+ {
+ *pFormat = *m_pAutoFormat;
+ m_pAutoFormat.reset(nullptr);
+ }
+ }
+}
+
+SwRewriter SwUndoTableStyleMake::GetRewriter() const
+{
+ SwRewriter aResult;
+ aResult.AddRule(UndoArg1, m_sName);
+ return aResult;
+}
+
+SwUndoTableStyleDelete::SwUndoTableStyleDelete(std::unique_ptr<SwTableAutoFormat> pAutoFormat, const std::vector<SwTable*>& rAffectedTables, const SwDoc* pDoc)
+ : SwUndo(UNDO_TBLSTYLE_DELETE, pDoc),
+ m_pAutoFormat(std::move(pAutoFormat)),
+ m_rAffectedTables(rAffectedTables)
+{ }
+
+SwUndoTableStyleDelete::~SwUndoTableStyleDelete()
+{ }
+
+void SwUndoTableStyleDelete::UndoImpl(::sw::UndoRedoContext & rContext)
+{
+ SwTableAutoFormat* pNewFormat = rContext.GetDoc().MakeTableStyle(m_pAutoFormat->GetName(), true);
+ *pNewFormat = *m_pAutoFormat;
+ for (size_t i=0; i < m_rAffectedTables.size(); i++)
+ m_rAffectedTables[i]->SetTableStyleName(m_pAutoFormat->GetName());
+}
+
+void SwUndoTableStyleDelete::RedoImpl(::sw::UndoRedoContext & rContext)
+{
+ // Don't need to remember deleted table style nor affected tables, because they must be the same as these already known.
+ rContext.GetDoc().DelTableStyle(m_pAutoFormat->GetName());
+}
+
+SwRewriter SwUndoTableStyleDelete::GetRewriter() const
+{
+ SwRewriter aResult;
+ aResult.AddRule(UndoArg1, m_pAutoFormat->GetName());
+ return aResult;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */