summaryrefslogtreecommitdiff
path: root/sw/source/core/docnode
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/docnode
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/docnode')
-rw-r--r--sw/source/core/docnode/ndtbl.cxx58
1 files changed, 58 insertions, 0 deletions
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 074f1601a412..c9c9511c3dea 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -4613,4 +4613,62 @@ bool SwDoc::HasTableAnyProtection( const SwPosition* pPos,
return bHasProtection;
}
+SwTableAutoFormat* SwDoc::MakeTableStyle(const OUString& rName, bool bBroadcast)
+{
+ SwTableAutoFormat aTableFormat(rName);
+ GetTableStyles().AddAutoFormat(aTableFormat);
+ SwTableAutoFormat* pTableFormat = GetTableStyles().FindAutoFormat(rName);
+
+ getIDocumentState().SetModified();
+
+ if (GetIDocumentUndoRedo().DoesUndo())
+ {
+ SwUndo * pUndo = new SwUndoTableStyleMake(rName, this);
+
+ GetIDocumentUndoRedo().AppendUndo(pUndo);
+ }
+
+ if (bBroadcast)
+ BroadcastStyleOperation(rName, SfxStyleFamily::Table, SfxStyleSheetHintId::CREATED);
+
+ return pTableFormat;
+}
+
+std::unique_ptr<SwTableAutoFormat> SwDoc::DelTableStyle(const OUString& rName, bool bBroadcast, std::vector<SwTable*>* pAffectedTables)
+{
+ if (bBroadcast)
+ BroadcastStyleOperation(rName, SfxStyleFamily::Table, SfxStyleSheetHintId::ERASED);
+
+ std::unique_ptr<SwTableAutoFormat> pReleasedFormat = GetTableStyles().ReleaseAutoFormat(rName);
+
+ std::vector<SwTable*> vAffectedTables;
+ if (pReleasedFormat.get())
+ {
+ size_t nTableCount = GetTableFrameFormatCount(true);
+ for (size_t i=0; i < nTableCount; ++i)
+ {
+ SwFrameFormat* pFrameFormat = &GetTableFrameFormat(i, true);
+ SwTable* pTable = SwTable::FindTable(pFrameFormat);
+ if (pTable->GetTableStyleName() == pReleasedFormat->GetName())
+ {
+ pTable->SetTableStyleName("");
+ vAffectedTables.push_back(pTable);
+ }
+ }
+
+ getIDocumentState().SetModified();
+
+ if (GetIDocumentUndoRedo().DoesUndo())
+ {
+ SwUndo * pUndo = new SwUndoTableStyleDelete(std::move(pReleasedFormat), vAffectedTables, this);
+
+ GetIDocumentUndoRedo().AppendUndo(pUndo);
+ }
+ }
+
+ if (pAffectedTables)
+ *pAffectedTables = vAffectedTables;
+ return pReleasedFormat;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */