From af0c93da33f2bf39a673c2dc29fb44b90322d137 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Mon, 24 Sep 2012 23:19:41 +0200 Subject: kill O(N^2) algorithm generating cond format render information, fdo#54396 Change-Id: I63536625eaf9b73c8e63d3cf88b6b798a6bf017b --- sc/inc/conditio.hxx | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'sc/inc/conditio.hxx') 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 + #include #include +#include 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 +{ +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 StringCacheType; + StringCacheType maStrings; + typedef std::map ValueCacheType; + ValueCacheType maValues; + }; + + mutable boost::scoped_ptr 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 -- cgit