[Libreoffice-commits] core.git: sc/inc sc/source

Caolán McNamara caolanm at redhat.com
Fri Mar 2 14:48:16 UTC 2018


 sc/inc/conditio.hxx                    |    6 ++++--
 sc/source/core/data/conditio.cxx       |    4 +++-
 sc/source/filter/xml/xmlcondformat.cxx |    9 ++++++++-
 sc/source/filter/xml/xmlcondformat.hxx |    3 +++
 4 files changed, 18 insertions(+), 4 deletions(-)

New commits:
commit 0ab136c65ee184bf1cd790ee7347cd572fdf56aa
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Mar 2 10:01:45 2018 +0000

    forcepoint #15 notify FormatsContext if Format deleted
    
    Change-Id: Icb7b0c3b1fc3d38e2d7e44e0a8bdb03529c5b41d
    Reviewed-on: https://gerrit.libreoffice.org/50621
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

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 );
 


More information about the Libreoffice-commits mailing list