diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-03-02 10:01:45 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-03-02 15:47:49 +0100 |
commit | 0ab136c65ee184bf1cd790ee7347cd572fdf56aa (patch) | |
tree | 3495e03202d6ac3c025a230c9364790d47614dd8 /sc | |
parent | 052423984614911c7b711dba106315b1b67e7047 (diff) |
forcepoint #15 notify FormatsContext if Format deleted
Change-Id: Icb7b0c3b1fc3d38e2d7e44e0a8bdb03529c5b41d
Reviewed-on: https://gerrit.libreoffice.org/50621
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/conditio.hxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/conditio.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcondformat.cxx | 9 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcondformat.hxx | 3 |
4 files changed, 18 insertions, 4 deletions
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx index 77a066740ebd..072e6e328d5a 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -35,6 +35,7 @@ #include <rtl/math.hxx> #include <tools/date.hxx> +#include <tools/link.hxx> #include <map> #include <memory> @@ -604,10 +605,11 @@ public: /** * Checks that all cond formats have a non empty range. - * Deletes empty cond formats. + * Deletes empty cond formats. Optionall call rLink + * on the empty format before deleting it. * @return true if all cond formats were valid */ - bool CheckAllEntries(); + bool CheckAllEntries(const Link<ScConditionalFormat*,void>& rLink = Link<ScConditionalFormat*,void>()); ScConditionalFormat* GetFormat( sal_uInt32 nKey ); const ScConditionalFormat* GetFormat( sal_uInt32 nKey ) const; diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index eb86f3e4bc61..c09e5e90b250 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -2146,7 +2146,7 @@ void ScConditionalFormatList::RenameCellStyle( const OUString& rOld, const OUStr } } -bool ScConditionalFormatList::CheckAllEntries() +bool ScConditionalFormatList::CheckAllEntries(const Link<ScConditionalFormat*,void>& rLink) { bool bValid = true; @@ -2157,6 +2157,8 @@ bool ScConditionalFormatList::CheckAllEntries() if ((*itr)->GetRange().empty()) { bValid = false; + if (rLink.IsSet()) + rLink.Call(itr->get()); itr = m_ConditionalFormats.erase(itr); } else diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx index f7b43c5cced4..be215df81d72 100644 --- a/sc/source/filter/xml/xmlcondformat.cxx +++ b/sc/source/filter/xml/xmlcondformat.cxx @@ -49,13 +49,20 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL ScXMLConditio return pContext; } +IMPL_LINK(ScXMLConditionalFormatsContext, FormatDeletedHdl, ScConditionalFormat*, pFormat, void) +{ + mvCondFormatData.erase(std::remove_if(mvCondFormatData.begin(), mvCondFormatData.end(), + [pFormat](CondFormatData& r){ return r.mpFormat == pFormat; }), + mvCondFormatData.end()); +} + void SAL_CALL ScXMLConditionalFormatsContext::endFastElement( sal_Int32 /*nElement*/ ) { ScDocument* pDoc = GetScImport().GetDocument(); SCTAB nTab = GetScImport().GetTables().GetCurrentSheet(); ScConditionalFormatList* pCondFormatList = pDoc->GetCondFormList(nTab); - bool bDeleted = !pCondFormatList->CheckAllEntries(); + bool bDeleted = !pCondFormatList->CheckAllEntries(LINK(this, ScXMLConditionalFormatsContext, FormatDeletedHdl)); SAL_WARN_IF(bDeleted, "sc", "conditional formats have been deleted because they contained empty range info"); diff --git a/sc/source/filter/xml/xmlcondformat.hxx b/sc/source/filter/xml/xmlcondformat.hxx index fc253081ff0d..ed979d273985 100644 --- a/sc/source/filter/xml/xmlcondformat.hxx +++ b/sc/source/filter/xml/xmlcondformat.hxx @@ -12,6 +12,7 @@ #include <array> #include <memory> +#include <tools/link.hxx> #include <xmloff/xmlictxt.hxx> #include "xmlimprt.hxx" #include "importcontext.hxx" @@ -41,6 +42,8 @@ private: SCTAB mnTab; }; + DECL_LINK(FormatDeletedHdl, ScConditionalFormat*, void); + public: ScXMLConditionalFormatsContext( ScXMLImport& rImport ); |