diff options
author | Jakub Trzebiatowski <ubap.dev@gmail.com> | 2016-06-07 21:57:49 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-06-13 10:48:55 +0000 |
commit | 3464befb48ccf1bf9ad4c8f321c7342db43c4019 (patch) | |
tree | 3575268ef66e0490cde203d5162a31002fb7ed64 /sw/source/core/doc | |
parent | 8d51397bfd98615e74e116582a50e29846ecb76e (diff) |
GSoC Table Styles, CellStyle
- insertByName
- replaceByName
- removeByName
Change-Id: I964aa0dc2e7f5a5be9eaec719b8944e847eb9d6a
Reviewed-on: https://gerrit.libreoffice.org/26037
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw/source/core/doc')
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 1 | ||||
-rw-r--r-- | sw/source/core/doc/tblafmt.cxx | 86 |
2 files changed, 87 insertions, 0 deletions
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index a136c3576b4a..68734cff5298 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -257,6 +257,7 @@ SwDoc::SwDoc() mpLayoutCache( nullptr ), mpGrammarContact(createGrammarContact()), mpTableStyles(new SwTableAutoFormatTable), + mpCellStyles(new SwCellStyleTable), m_pXmlIdRegistry(), mReferenceCount(0), mbDtor(false), diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index 95088b7aed76..6b18c2e6403b 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -1324,4 +1324,90 @@ bool SwTableAutoFormatTable::Save( SvStream& rStream ) const return bRet; } +SwCellStyleTable::SwCellStyleTable() +{ } + +SwCellStyleTable::~SwCellStyleTable() +{ + for (size_t i=0; i < m_aCellStyles.size(); ++i) + delete m_aCellStyles[i].second; +} + +size_t SwCellStyleTable::size() const +{ + return m_aCellStyles.size(); +} + +void SwCellStyleTable::clear() +{ + for (size_t i=0; i < m_aCellStyles.size(); ++i) + delete m_aCellStyles[i].second; + + m_aCellStyles.clear(); +} + +SwCellStyleDescriptor SwCellStyleTable::operator[](size_t i) const +{ + return SwCellStyleDescriptor(m_aCellStyles[i]); +} + +void SwCellStyleTable::AddBoxFormat(const SwBoxAutoFormat& rBoxFormat, const OUString& sName) +{ + m_aCellStyles.push_back(std::make_pair(sName, new SwBoxAutoFormat(rBoxFormat))); +} + +void SwCellStyleTable::RemoveBoxFormat(const OUString& sName) +{ + for (size_t i=0; i < m_aCellStyles.size(); ++i) + { + if (m_aCellStyles[i].first == sName) + { + m_aCellStyles.erase(m_aCellStyles.begin() + i); + return; + } + } + SAL_INFO("sw.core", "SwCellStyleTable::RemoveBoxFormat, format with given name doesn't exists"); +} + +OUString SwCellStyleTable::GetBoxFormatName(const SwBoxAutoFormat& rBoxFormat) const +{ + for (size_t i=0; i < m_aCellStyles.size(); ++i) + { + if (m_aCellStyles[i].second == &rBoxFormat) + return m_aCellStyles[i].first; + } + + // box format not found + return OUString(); +} + +SwBoxAutoFormat* SwCellStyleTable::GetBoxFormat(const OUString& sName) const +{ + for (size_t i=0; i < m_aCellStyles.size(); ++i) + { + if (m_aCellStyles[i].first == sName) + return m_aCellStyles[i].second; + } + + return nullptr; +} + +void SwCellStyleTable::ChangeBoxFormatName(const OUString& sFromName, const OUString& sToName) +{ + if (!GetBoxFormat(sToName)) + { + SAL_INFO("sw.core", "SwCellStyleTable::ChangeBoxName, box with given name already exists"); + return; + } + for (size_t i=0; i < m_aCellStyles.size(); ++i) + { + if (m_aCellStyles[i].first == sFromName) + { + m_aCellStyles[i].first = sToName; + // changed succesfully + return; + } + } + SAL_INFO("sw.core", "SwCellStyleTable::ChangeBoxName, box with given name not found"); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |