summaryrefslogtreecommitdiff
path: root/sc/inc/conditio.hxx
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-09-24 23:19:41 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-09-24 23:23:23 +0200
commitaf0c93da33f2bf39a673c2dc29fb44b90322d137 (patch)
tree7b37ab9cadac2b3b30a022142b5305bdb2b35aa1 /sc/inc/conditio.hxx
parentbc63efc586c1a3b9ba5af7087093174b0d6aeb97 (diff)
kill O(N^2) algorithm generating cond format render information, fdo#54396
Change-Id: I63536625eaf9b73c8e63d3cf88b6b798a6bf017b
Diffstat (limited to 'sc/inc/conditio.hxx')
-rw-r--r--sc/inc/conditio.hxx41
1 files changed, 41 insertions, 0 deletions
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 7b1cf170ebe7..ae16d6b7785a 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -35,8 +35,11 @@
#include "scdllapi.h"
#include "rangelst.hxx"
+#include <rtl/math.hxx>
+
#include <boost/ptr_container/ptr_set.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
+#include <boost/scoped_ptr.hpp>
class ScBaseCell;
class ScFormulaCell;
@@ -116,11 +119,26 @@ public:
#if DUMP_FORMAT_INFO
virtual void dumpInfo(rtl::OUStringBuffer& rBuf) const = 0;
#endif
+
+ virtual void startRendering();
+ virtual void endRendering();
protected:
ScDocument* mpDoc;
};
+class approx_less : public std::binary_function<double, double, bool>
+{
+public:
+ bool operator() (double nVal1, double nVal2)
+ {
+ if(nVal1 < nVal2 && !rtl::math::approxEqual(nVal1, nVal2))
+ return true;
+
+ return false;
+ }
+};
+
class SC_DLLPUBLIC ScConditionEntry : public ScFormatEntry
{
// stored data:
@@ -216,10 +234,27 @@ public:
virtual void dumpInfo(rtl::OUStringBuffer& ) const {}
#endif
+ virtual void endRendering();
+ virtual void startRendering();
+
protected:
virtual void DataChanged( const ScRange* pModified ) const;
ScDocument* GetDocument() const { return mpDoc; }
ScConditionalFormat* pCondFormat;
+
+private:
+
+ bool IsDuplicate(double nArg, const rtl::OUString& rStr, const ScAddress& rAddr, const ScRangeList& rRanges) const;
+
+ struct ScConditionEntryCache
+ {
+ typedef std::map<rtl::OUString, sal_Int32> StringCacheType;
+ StringCacheType maStrings;
+ typedef std::map<double, sal_Int32, approx_less> ValueCacheType;
+ ValueCacheType maValues;
+ };
+
+ mutable boost::scoped_ptr<ScConditionEntryCache> mpCache;
};
//
@@ -326,6 +361,9 @@ public:
// operator== only for sorting
bool operator ==( const ScConditionalFormat& r ) const { return nKey == r.nKey; }
bool operator < ( const ScConditionalFormat& r ) const { return nKey < r.nKey; }
+
+ void startRendering();
+ void endRendering();
};
//
@@ -371,6 +409,9 @@ public:
size_t size() const;
void erase(sal_uLong nIndex);
+
+ void startRendering();
+ void endRendering();
};
// see http://www.boost.org/doc/libs/1_49_0/libs/ptr_container/doc/tutorial.html#cloneability