diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-17 19:23:01 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-18 23:22:41 -0400 |
commit | e09cedd92259d8fdb98a7591b46a813685f0df96 (patch) | |
tree | ce3df7ef5fd361550b1b5fc2f4d85ca6030663be /sc/inc/scmatrix.hxx | |
parent | 0b9b668502de35a5077477d7e47a8f1ca7969ba6 (diff) |
Initial attempt to speed up matrix comparison.
And move the value compare code to somewhere public. I'll be using it
from the ScMatrix internal.
This change requires mdds 0.9.1 which is yet to be released.
Change-Id: I942133c85b614b3404006fa38af111ace9361fd4
Diffstat (limited to 'sc/inc/scmatrix.hxx')
-rw-r--r-- | sc/inc/scmatrix.hxx | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx index b9975063e756..edd8cbdd41df 100644 --- a/sc/inc/scmatrix.hxx +++ b/sc/inc/scmatrix.hxx @@ -25,8 +25,10 @@ #include "formula/errorcodes.hxx" #include "scdllapi.h" #include <rtl/ustring.hxx> +#include "svl/sharedstring.hxx" #include <boost/intrusive_ptr.hpp> +#include <boost/interprocess/smart_ptr/unique_ptr.hpp> #define DEBUG_MATRIX 0 @@ -34,8 +36,6 @@ class ScInterpreter; class SvNumberFormatter; class ScMatrixImpl; -namespace svl { class SharedString; } - /** * Try NOT to use this struct. This struct should go away in a hopefully * not so distant futture. @@ -43,11 +43,11 @@ namespace svl { class SharedString; } struct ScMatrixValue { double fVal; - OUString aStr; + svl::SharedString aStr; ScMatValType nType; /// Only valid if ScMatrix methods indicate so! - const OUString& GetString() const { return aStr; } + OUString GetString() const { return aStr.getString(); } /// Only valid if ScMatrix methods indicate that this is no string! sal_uInt16 GetError() const { return GetDoubleErrorValue( fVal); } @@ -137,6 +137,31 @@ public: mfFirst(r.mfFirst), mfRest(r.mfRest), mnCount(r.mnCount) {} }; + struct Pos; + struct ConstPos; + + static void DeletePosition( const Pos* p ); + static void DeletePosition( const ConstPos* p ); + + struct PosDeleter : std::unary_function<const Pos*, void> + { + void operator() (const Pos* p) + { + DeletePosition(p); + } + }; + + struct ConstPosDeleter : std::unary_function<const ConstPos*, void> + { + void operator() (const ConstPos* p) + { + DeletePosition(p); + } + }; + + typedef boost::interprocess::unique_ptr<Pos, PosDeleter> PosRef; + typedef boost::interprocess::unique_ptr<ConstPos, PosDeleter> ConstPosRef; + /// The maximum number of elements a matrix may have at runtime. inline static size_t GetElementsMax() { @@ -289,6 +314,8 @@ public: /// @ATTENTION: If bString the ScMatrixValue->pS may still be NULL to indicate /// an empty string! ScMatrixValue Get( SCSIZE nC, SCSIZE nR) const; + ScMatrixValue Get( const Pos& rPos ) const; + ScMatrixValue Get( const ConstPos& rPos ) const; /// @return <TRUE/> if string or empty or empty path, in fact non-value. sal_Bool IsString( SCSIZE nIndex ) const; @@ -317,6 +344,31 @@ public: /// @return <TRUE/> if entire matrix is numeric, including booleans, with no strings or empties sal_Bool IsNumeric() const; + Pos* GetPosition( size_t nC, size_t nR ); + ConstPos* GetConstPosition( size_t nC, size_t nR ) const; + + bool NextPosition( Pos& rPos ); + bool NextPosition( ConstPos& rPos ) const; + + bool IsValue( const Pos& rPos ) const; + bool IsValue( const ConstPos& rPos ) const; + + bool IsEmpty( const Pos& rPos ) const; + bool IsEmpty( const ConstPos& rPos ) const; + + double GetDouble( const Pos& rPos ) const; + double GetDouble( const ConstPos& rPos ) const; + + svl::SharedString GetString( const Pos& rPos ) const; + svl::SharedString GetString( const ConstPos& rPos ) const; + + void PutDouble( double fVal, Pos& rPos ); + void PutString( const svl::SharedString& rStr, Pos& rPos ); + void PutEmpty( Pos& rPos ); + void PutEmptyPath( Pos& rPos ); + void PutError( sal_uInt16 nErr, Pos& rPos ); + void PutBoolean( bool bVal, Pos& rPos ); + void MatTrans( ScMatrix& mRes) const; void MatCopy ( ScMatrix& mRes) const; |