diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-11-19 12:42:36 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-11-24 17:41:30 +0100 |
commit | 02226081592e47b0c42489258ed688b9ebb7a939 (patch) | |
tree | 6e243aced9d1b2a53fcf113b48aaeaa43cf8a20d /sc | |
parent | 708ef6a08dfcd357845c37dbe03fd1ebca5ba587 (diff) |
sc: Introduce Abstract Base Class for ScMatrix, for a future rework.
We want to introduce another type of ScMatrix that will directly contain
DoubleVectorRefToken and operate on that. The idea is that it is pointless to
construct a ScMatrix via lots of copying around, when we already have a nice
array of doubles.
Change-Id: I3e5d7b9e2e0f9b9bf350336a8582cfd852586b3f
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/scmatrix.hxx | 389 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 16 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/validat.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/addincol.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/tool/ddelink.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/tool/formulagroup.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/tool/interpr5.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/tool/jumpmatrix.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/rangeseq.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/scmatrix.cxx | 287 | ||||
-rw-r--r-- | sc/source/core/tool/token.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/tokstack.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/xihelper.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/xilink.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/inc/xihelper.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLDDELinksContext.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcelli.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/docshell/externalrefmgr.cxx | 6 |
20 files changed, 488 insertions, 260 deletions
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx index 883550d77b80..1f5d4383100d 100644 --- a/sc/inc/scmatrix.hxx +++ b/sc/inc/scmatrix.hxx @@ -106,24 +106,18 @@ struct ScMatrixValue } }; -/** - * Matrix data type that can store values of mixed types. Each element can - * be one of the following types: numeric, string, boolean, empty, and empty - * path. - */ +/// Abstract base class for ScFullMatrix and ScSubMatrix implementations. class SC_DLLPUBLIC ScMatrix { - friend class ScMatrixImpl; - - std::unique_ptr<ScMatrixImpl> pImpl; mutable size_t nRefCnt; // reference count - - // only delete via Delete() - ~ScMatrix(); + bool mbCloneIfConst; // Whether the matrix is cloned with a CloneIfConst() call. ScMatrix( const ScMatrix& ) = delete; ScMatrix& operator=( const ScMatrix&) = delete; +protected: + virtual ~ScMatrix() {} + public: enum Op { Add, Sub, Mul, Div }; @@ -202,13 +196,10 @@ public: return (nType & SC_MATVAL_NONVALUE) == SC_MATVAL_EMPTYPATH; } - ScMatrix(SCSIZE nC, SCSIZE nR); - ScMatrix(SCSIZE nC, SCSIZE nR, double fInitVal); - - ScMatrix( size_t nC, size_t nR, const std::vector<double>& rInitVals ); + ScMatrix() : nRefCnt(0), mbCloneIfConst(true) {} /** Clone the matrix. */ - ScMatrix* Clone() const; + virtual ScMatrix* Clone() const = 0; /** Clone the matrix if mbCloneIfConst (immutable) is set, otherwise return _this_ matrix, to be assigned to a ScMatrixRef. */ @@ -221,21 +212,21 @@ public: /** * Resize the matrix to specified new dimension. */ - void Resize( SCSIZE nC, SCSIZE nR); + virtual void Resize(SCSIZE nC, SCSIZE nR) = 0; - void Resize(SCSIZE nC, SCSIZE nR, double fVal); + virtual void Resize(SCSIZE nC, SCSIZE nR, double fVal) = 0; /** Clone the matrix and extend it to the new size. nNewCols and nNewRows MUST be at least of the size of the original matrix. */ - ScMatrix* CloneAndExtend(SCSIZE nNewCols, SCSIZE nNewRows) const; + virtual ScMatrix* CloneAndExtend(SCSIZE nNewCols, SCSIZE nNewRows) const = 0; void IncRef() const; void DecRef() const; - void SetErrorInterpreter( ScInterpreter* p); - void GetDimensions( SCSIZE& rC, SCSIZE& rR) const; - SCSIZE GetElementCount() const; - bool ValidColRow( SCSIZE nC, SCSIZE nR) const; + virtual void SetErrorInterpreter( ScInterpreter* p) = 0; + virtual void GetDimensions( SCSIZE& rC, SCSIZE& rR) const = 0; + virtual SCSIZE GetElementCount() const = 0; + virtual bool ValidColRow( SCSIZE nC, SCSIZE nR) const = 0; /** For a row vector or column vector, if the position does not point into the vector but is a valid column or row offset it is adapted such that @@ -243,7 +234,7 @@ public: vector, same row column 0 for a column vector. Else, for a 2D matrix, returns false. */ - bool ValidColRowReplicated( SCSIZE & rC, SCSIZE & rR ) const; + virtual bool ValidColRowReplicated( SCSIZE & rC, SCSIZE & rR ) const = 0; /** Checks if the matrix position is within the matrix. If it is not, for a row vector or column vector the position is adapted such that it points @@ -251,47 +242,47 @@ public: same row column 0 for a column vector. Else, for a 2D matrix and position not within matrix, returns false. */ - bool ValidColRowOrReplicated( SCSIZE & rC, SCSIZE & rR ) const; + virtual bool ValidColRowOrReplicated( SCSIZE & rC, SCSIZE & rR ) const = 0; - void PutDouble( double fVal, SCSIZE nC, SCSIZE nR); - void PutDouble( double fVal, SCSIZE nIndex); - void PutDouble(const double* pArray, size_t nLen, SCSIZE nC, SCSIZE nR); + virtual void PutDouble( double fVal, SCSIZE nC, SCSIZE nR) = 0; + virtual void PutDouble( double fVal, SCSIZE nIndex) = 0; + virtual void PutDouble(const double* pArray, size_t nLen, SCSIZE nC, SCSIZE nR) = 0; - void PutString( const svl::SharedString& rStr, SCSIZE nC, SCSIZE nR); - void PutString( const svl::SharedString& rStr, SCSIZE nIndex); - void PutString( const svl::SharedString* pArray, size_t nLen, SCSIZE nC, SCSIZE nR); + virtual void PutString( const svl::SharedString& rStr, SCSIZE nC, SCSIZE nR) = 0; + virtual void PutString( const svl::SharedString& rStr, SCSIZE nIndex) = 0; + virtual void PutString( const svl::SharedString* pArray, size_t nLen, SCSIZE nC, SCSIZE nR) = 0; - void PutEmpty( SCSIZE nC, SCSIZE nR); + virtual void PutEmpty( SCSIZE nC, SCSIZE nR) = 0; /// Jump sal_False without path - void PutEmptyPath( SCSIZE nC, SCSIZE nR); - void PutError( sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR ); - void PutBoolean( bool bVal, SCSIZE nC, SCSIZE nR); + virtual void PutEmptyPath( SCSIZE nC, SCSIZE nR) = 0; + virtual void PutError( sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR ) = 0; + virtual void PutBoolean( bool bVal, SCSIZE nC, SCSIZE nR) = 0; - void FillDouble( double fVal, - SCSIZE nC1, SCSIZE nR1, SCSIZE nC2, SCSIZE nR2 ); + virtual void FillDouble( double fVal, + SCSIZE nC1, SCSIZE nR1, SCSIZE nC2, SCSIZE nR2 ) = 0; /** Put a column vector of doubles, starting at row nR, must fit into dimensions. */ - void PutDoubleVector( const ::std::vector< double > & rVec, SCSIZE nC, SCSIZE nR ); + virtual void PutDoubleVector( const ::std::vector< double > & rVec, SCSIZE nC, SCSIZE nR ) = 0; /** Put a column vector of strings, starting at row nR, must fit into dimensions. */ - void PutStringVector( const ::std::vector< svl::SharedString > & rVec, SCSIZE nC, SCSIZE nR ); + virtual void PutStringVector( const ::std::vector< svl::SharedString > & rVec, SCSIZE nC, SCSIZE nR ) = 0; /** Put a column vector of empties, starting at row nR, must fit into dimensions. */ - void PutEmptyVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ); + virtual void PutEmptyVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) = 0; /** Put a column vector of empty results, starting at row nR, must fit into dimensions. */ - void PutEmptyResultVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ); + virtual void PutEmptyResultVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) = 0; /** Put a column vector of empty paths, starting at row nR, must fit into dimensions. */ - void PutEmptyPathVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ); + virtual void PutEmptyPathVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) = 0; /** May be used before obtaining the double value of an element to avoid passing its NAN around. @ATTENTION: MUST NOT be used if the element is a string! Use GetErrorIfNotString() instead if not sure. @returns 0 if no error, else one of err... constants */ - sal_uInt16 GetError( SCSIZE nC, SCSIZE nR) const; + virtual sal_uInt16 GetError( SCSIZE nC, SCSIZE nR) const = 0; /** Use in ScInterpreter to obtain the error code, if any. @returns 0 if no error or string element, else one of err... constants */ @@ -299,85 +290,291 @@ public: { return IsValue( nC, nR) ? GetError( nC, nR) : 0; } /// @return 0.0 if empty or empty path, else value or DoubleError. - double GetDouble( SCSIZE nC, SCSIZE nR) const; + virtual double GetDouble( SCSIZE nC, SCSIZE nR) const = 0; + /// @return 0.0 if empty or empty path, else value or DoubleError. + virtual double GetDouble( SCSIZE nIndex) const = 0; + + /// @return empty string if empty or empty path, else string content. + virtual svl::SharedString GetString( SCSIZE nC, SCSIZE nR) const = 0; + /// @return empty string if empty or empty path, else string content. + virtual svl::SharedString GetString( SCSIZE nIndex) const = 0; + + /** @returns the matrix element's string if one is present, otherwise the + numerical value formatted as string, or in case of an error the error + string is returned; an empty string for empty, a "FALSE" string for + empty path. */ + virtual svl::SharedString GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const = 0; + + /// @ATTENTION: If bString the ScMatrixValue->pS may still be NULL to indicate + /// an empty string! + virtual ScMatrixValue Get( SCSIZE nC, SCSIZE nR) const = 0; + + /// @return <TRUE/> if string or empty or empty path, in fact non-value. + virtual bool IsString( SCSIZE nIndex ) const = 0; + + /// @return <TRUE/> if string or empty or empty path, in fact non-value. + virtual bool IsString( SCSIZE nC, SCSIZE nR ) const = 0; + + /// @return <TRUE/> if empty or empty cell or empty result, not empty path. + virtual bool IsEmpty( SCSIZE nC, SCSIZE nR ) const = 0; + + /// @return <TRUE/> if empty cell, not empty or empty result or empty path. + virtual bool IsEmptyCell( SCSIZE nC, SCSIZE nR ) const = 0; + + /// @return <TRUE/> if empty result, not empty or empty cell or empty path. + virtual bool IsEmptyResult( SCSIZE nC, SCSIZE nR ) const = 0; + + /// @return <TRUE/> if empty path, not empty or empty cell or empty result. + virtual bool IsEmptyPath( SCSIZE nC, SCSIZE nR ) const = 0; + + /// @return <TRUE/> if value or boolean. + virtual bool IsValue( SCSIZE nIndex ) const = 0; + + /// @return <TRUE/> if value or boolean. + virtual bool IsValue( SCSIZE nC, SCSIZE nR ) const = 0; + + /// @return <TRUE/> if value or boolean or empty or empty path. + virtual bool IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const = 0; + + /// @return <TRUE/> if boolean. + virtual bool IsBoolean( SCSIZE nC, SCSIZE nR ) const = 0; + + /// @return <TRUE/> if entire matrix is numeric, including booleans, with no strings or empties + virtual bool IsNumeric() const = 0; + + virtual void MatTrans( ScMatrix& mRes) const = 0; + virtual void MatCopy ( ScMatrix& mRes) const = 0; + + // Convert ScInterpreter::CompareMat values (-1,0,1) to boolean values + virtual void CompareEqual() = 0; + virtual void CompareNotEqual() = 0; + virtual void CompareLess() = 0; + virtual void CompareGreater() = 0; + virtual void CompareLessEqual() = 0; + virtual void CompareGreaterEqual() = 0; + + virtual double And() const = 0; // logical AND of all matrix values, or NAN + virtual double Or() const = 0; // logical OR of all matrix values, or NAN + virtual double Xor() const = 0; // logical XOR of all matrix values, or NAN + + virtual IterateResult Sum(bool bTextAsZero) const = 0; + virtual IterateResult SumSquare(bool bTextAsZero) const = 0; + virtual IterateResult Product(bool bTextAsZero) const = 0; + virtual size_t Count(bool bCountStrings) const = 0; + virtual size_t MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const = 0; + virtual size_t MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, size_t nCol2) const = 0; + + virtual double GetMaxValue( bool bTextAsZero ) const = 0; + virtual double GetMinValue( bool bTextAsZero ) const = 0; + + virtual ScMatrixRef CompareMatrix( + sc::Compare& rComp, size_t nMatPos, sc::CompareOptions* pOptions = nullptr ) const = 0; + + /** + * Convert the content of matrix into a linear array of numeric values. + * String elements are mapped to NaN's and empty elements are mapped to + * either NaN or zero values. + * + * @param bEmptyAsZero if true empty elements are mapped to zero values, + * otherwise they become NaN values. + */ + virtual void GetDoubleArray( std::vector<double>& rArray, bool bEmptyAsZero = true ) const = 0; + virtual void MergeDoubleArray( std::vector<double>& rArray, Op eOp ) const = 0; + + virtual void NotOp(ScMatrix& rMat) = 0; + virtual void NegOp(ScMatrix& rMat) = 0; + virtual void AddOp(double fVal, ScMatrix& rMat) = 0; + virtual void SubOp(bool bFlag, double fVal, ScMatrix& rMat) = 0; + virtual void MulOp(double fVal, ScMatrix& rMat) = 0; + virtual void DivOp(bool bFlag, double fVal, ScMatrix& rMat) = 0; + virtual void PowOp(bool bFlag, double fVal, ScMatrix& rMat) = 0; + + virtual std::vector<ScMatrix::IterateResult> Collect(bool bTextAsZero, const std::vector<std::unique_ptr<sc::op::Op>>& aOp) = 0; + +#if DEBUG_MATRIX + void Dump() const; +#endif +}; + +/** + * Matrix data type that can store values of mixed types. Each element can + * be one of the following types: numeric, string, boolean, empty, and empty + * path. + */ +class SC_DLLPUBLIC ScFullMatrix : public ScMatrix +{ + friend class ScMatrixImpl; + + std::unique_ptr<ScMatrixImpl> pImpl; + + // only delete via Delete() + virtual ~ScFullMatrix(); + + ScFullMatrix( const ScFullMatrix& ) = delete; + ScFullMatrix& operator=( const ScFullMatrix&) = delete; + +public: + + ScFullMatrix(SCSIZE nC, SCSIZE nR); + ScFullMatrix(SCSIZE nC, SCSIZE nR, double fInitVal); + + ScFullMatrix( size_t nC, size_t nR, const std::vector<double>& rInitVals ); + + /** Clone the matrix. */ + virtual ScMatrix* Clone() const override; + + /** + * Resize the matrix to specified new dimension. + */ + virtual void Resize( SCSIZE nC, SCSIZE nR) override; + + virtual void Resize(SCSIZE nC, SCSIZE nR, double fVal) override; + + /** Clone the matrix and extend it to the new size. nNewCols and nNewRows + MUST be at least of the size of the original matrix. */ + virtual ScMatrix* CloneAndExtend(SCSIZE nNewCols, SCSIZE nNewRows) const override; + + virtual void SetErrorInterpreter( ScInterpreter* p) override; + virtual void GetDimensions( SCSIZE& rC, SCSIZE& rR) const override; + virtual SCSIZE GetElementCount() const override; + virtual bool ValidColRow( SCSIZE nC, SCSIZE nR) const override; + + /** For a row vector or column vector, if the position does not point into + the vector but is a valid column or row offset it is adapted such that + it points to an element to be replicated, same column row 0 for a row + vector, same row column 0 for a column vector. Else, for a 2D matrix, + returns false. + */ + virtual bool ValidColRowReplicated( SCSIZE & rC, SCSIZE & rR ) const override; + + /** Checks if the matrix position is within the matrix. If it is not, for a + row vector or column vector the position is adapted such that it points + to an element to be replicated, same column row 0 for a row vector, + same row column 0 for a column vector. Else, for a 2D matrix and + position not within matrix, returns false. + */ + virtual bool ValidColRowOrReplicated( SCSIZE & rC, SCSIZE & rR ) const override; + + virtual void PutDouble( double fVal, SCSIZE nC, SCSIZE nR) override; + virtual void PutDouble( double fVal, SCSIZE nIndex) override; + virtual void PutDouble(const double* pArray, size_t nLen, SCSIZE nC, SCSIZE nR) override; + + virtual void PutString( const svl::SharedString& rStr, SCSIZE nC, SCSIZE nR) override; + virtual void PutString( const svl::SharedString& rStr, SCSIZE nIndex) override; + virtual void PutString( const svl::SharedString* pArray, size_t nLen, SCSIZE nC, SCSIZE nR) override; + + virtual void PutEmpty( SCSIZE nC, SCSIZE nR) override; + + /// Jump sal_False without path + virtual void PutEmptyPath( SCSIZE nC, SCSIZE nR) override; + virtual void PutError( sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR ) override; + virtual void PutBoolean( bool bVal, SCSIZE nC, SCSIZE nR) override; + + virtual void FillDouble( double fVal, + SCSIZE nC1, SCSIZE nR1, SCSIZE nC2, SCSIZE nR2 ) override; + + /** Put a column vector of doubles, starting at row nR, must fit into dimensions. */ + virtual void PutDoubleVector( const ::std::vector< double > & rVec, SCSIZE nC, SCSIZE nR ) override; + + /** Put a column vector of strings, starting at row nR, must fit into dimensions. */ + virtual void PutStringVector( const ::std::vector< svl::SharedString > & rVec, SCSIZE nC, SCSIZE nR ) override; + + /** Put a column vector of empties, starting at row nR, must fit into dimensions. */ + virtual void PutEmptyVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) override; + + /** Put a column vector of empty results, starting at row nR, must fit into dimensions. */ + virtual void PutEmptyResultVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) override; + + /** Put a column vector of empty paths, starting at row nR, must fit into dimensions. */ + virtual void PutEmptyPathVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) override; + + /** May be used before obtaining the double value of an element to avoid + passing its NAN around. + @ATTENTION: MUST NOT be used if the element is a string! + Use GetErrorIfNotString() instead if not sure. + @returns 0 if no error, else one of err... constants */ + virtual sal_uInt16 GetError( SCSIZE nC, SCSIZE nR) const override; + + /// @return 0.0 if empty or empty path, else value or DoubleError. + virtual double GetDouble( SCSIZE nC, SCSIZE nR) const override; /// @return 0.0 if empty or empty path, else value or DoubleError. - double GetDouble( SCSIZE nIndex) const; + virtual double GetDouble( SCSIZE nIndex) const override; /// @return empty string if empty or empty path, else string content. - svl::SharedString GetString( SCSIZE nC, SCSIZE nR) const; + virtual svl::SharedString GetString( SCSIZE nC, SCSIZE nR) const override; /// @return empty string if empty or empty path, else string content. - svl::SharedString GetString( SCSIZE nIndex) const; + virtual svl::SharedString GetString( SCSIZE nIndex) const override; /** @returns the matrix element's string if one is present, otherwise the numerical value formatted as string, or in case of an error the error string is returned; an empty string for empty, a "FALSE" string for empty path. */ - svl::SharedString GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const; + virtual svl::SharedString GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const override; /// @ATTENTION: If bString the ScMatrixValue->pS may still be NULL to indicate /// an empty string! - ScMatrixValue Get( SCSIZE nC, SCSIZE nR) const; + virtual ScMatrixValue Get( SCSIZE nC, SCSIZE nR) const override; /// @return <TRUE/> if string or empty or empty path, in fact non-value. - bool IsString( SCSIZE nIndex ) const; + virtual bool IsString( SCSIZE nIndex ) const override; /// @return <TRUE/> if string or empty or empty path, in fact non-value. - bool IsString( SCSIZE nC, SCSIZE nR ) const; + virtual bool IsString( SCSIZE nC, SCSIZE nR ) const override; /// @return <TRUE/> if empty or empty cell or empty result, not empty path. - bool IsEmpty( SCSIZE nC, SCSIZE nR ) const; + virtual bool IsEmpty( SCSIZE nC, SCSIZE nR ) const override; /// @return <TRUE/> if empty cell, not empty or empty result or empty path. - bool IsEmptyCell( SCSIZE nC, SCSIZE nR ) const; + virtual bool IsEmptyCell( SCSIZE nC, SCSIZE nR ) const override; /// @return <TRUE/> if empty result, not empty or empty cell or empty path. - bool IsEmptyResult( SCSIZE nC, SCSIZE nR ) const; + virtual bool IsEmptyResult( SCSIZE nC, SCSIZE nR ) const override; /// @return <TRUE/> if empty path, not empty or empty cell or empty result. - bool IsEmptyPath( SCSIZE nC, SCSIZE nR ) const; + virtual bool IsEmptyPath( SCSIZE nC, SCSIZE nR ) const override; /// @return <TRUE/> if value or boolean. - bool IsValue( SCSIZE nIndex ) const; + virtual bool IsValue( SCSIZE nIndex ) const override; /// @return <TRUE/> if value or boolean. - bool IsValue( SCSIZE nC, SCSIZE nR ) const; + virtual bool IsValue( SCSIZE nC, SCSIZE nR ) const override; /// @return <TRUE/> if value or boolean or empty or empty path. - bool IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const; + virtual bool IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const override; /// @return <TRUE/> if boolean. - bool IsBoolean( SCSIZE nC, SCSIZE nR ) const; + virtual bool IsBoolean( SCSIZE nC, SCSIZE nR ) const override; /// @return <TRUE/> if entire matrix is numeric, including booleans, with no strings or empties - bool IsNumeric() const; + virtual bool IsNumeric() const override; - void MatTrans( ScMatrix& mRes) const; - void MatCopy ( ScMatrix& mRes) const; + virtual void MatTrans( ScMatrix& mRes) const override; + virtual void MatCopy ( ScMatrix& mRes) const override; // Convert ScInterpreter::CompareMat values (-1,0,1) to boolean values - void CompareEqual(); - void CompareNotEqual(); - void CompareLess(); - void CompareGreater(); - void CompareLessEqual(); - void CompareGreaterEqual(); - - double And() const; // logical AND of all matrix values, or NAN - double Or() const; // logical OR of all matrix values, or NAN - double Xor() const; // logical XOR of all matrix values, or NAN - - IterateResult Sum(bool bTextAsZero) const; - IterateResult SumSquare(bool bTextAsZero) const; - IterateResult Product(bool bTextAsZero) const; - size_t Count(bool bCountStrings) const; - size_t MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const; - size_t MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, size_t nCol2) const; - - double GetMaxValue( bool bTextAsZero ) const; - double GetMinValue( bool bTextAsZero ) const; - - ScMatrixRef CompareMatrix( - sc::Compare& rComp, size_t nMatPos, sc::CompareOptions* pOptions = nullptr ) const; + virtual void CompareEqual() override; + virtual void CompareNotEqual() override; + virtual void CompareLess() override; + virtual void CompareGreater() override; + virtual void CompareLessEqual() override; + virtual void CompareGreaterEqual() override; + + virtual double And() const override; // logical AND of all matrix values, or NAN + virtual double Or() const override; // logical OR of all matrix values, or NAN + virtual double Xor() const override; // logical XOR of all matrix values, or NAN + + virtual IterateResult Sum(bool bTextAsZero) const override; + virtual IterateResult SumSquare(bool bTextAsZero) const override; + virtual IterateResult Product(bool bTextAsZero) const override; + virtual size_t Count(bool bCountStrings) const override; + virtual size_t MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const override; + virtual size_t MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, size_t nCol2) const override; + + virtual double GetMaxValue( bool bTextAsZero ) const override; + virtual double GetMinValue( bool bTextAsZero ) const override; + + virtual ScMatrixRef CompareMatrix( + sc::Compare& rComp, size_t nMatPos, sc::CompareOptions* pOptions = nullptr ) const override; /** * Convert the content of matrix into a linear array of numeric values. @@ -387,20 +584,20 @@ public: * @param bEmptyAsZero if true empty elements are mapped to zero values, * otherwise they become NaN values. */ - void GetDoubleArray( std::vector<double>& rArray, bool bEmptyAsZero = true ) const; - void MergeDoubleArray( std::vector<double>& rArray, Op eOp ) const; + virtual void GetDoubleArray( std::vector<double>& rArray, bool bEmptyAsZero = true ) const override; + virtual void MergeDoubleArray( std::vector<double>& rArray, Op eOp ) const override; - void NotOp(ScMatrix& rMat); - void NegOp(ScMatrix& rMat); - void AddOp(double fVal, ScMatrix& rMat); - void SubOp(bool bFlag, double fVal, ScMatrix& rMat); - void MulOp(double fVal, ScMatrix& rMat); - void DivOp(bool bFlag, double fVal, ScMatrix& rMat); - void PowOp(bool bFlag, double fVal, ScMatrix& rMat); + virtual void NotOp(ScMatrix& rMat) override; + virtual void NegOp(ScMatrix& rMat) override; + virtual void AddOp(double fVal, ScMatrix& rMat) override; + virtual void SubOp(bool bFlag, double fVal, ScMatrix& rMat) override; + virtual void MulOp(double fVal, ScMatrix& rMat) override; + virtual void DivOp(bool bFlag, double fVal, ScMatrix& rMat) override; + virtual void PowOp(bool bFlag, double fVal, ScMatrix& rMat) override; - std::vector<ScMatrix::IterateResult> Collect(bool bTextAsZero, const std::vector<std::unique_ptr<sc::op::Op>>& aOp); + virtual std::vector<ScMatrix::IterateResult> Collect(bool bTextAsZero, const std::vector<std::unique_ptr<sc::op::Op>>& aOp) override; - ScMatrix& operator+= ( const ScMatrix& r ); + ScFullMatrix& operator+= ( const ScFullMatrix& r ); #if DEBUG_MATRIX void Dump() const; diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 3fc85a679f38..bf22802d95db 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -1889,7 +1889,7 @@ void Test::testMatrix() ScMatrixRef pMat, pMat2; // First, test the zero matrix type. - pMat = new ScMatrix(0, 0, 0.0); + pMat = new ScFullMatrix(0, 0, 0.0); SCSIZE nC, nR; pMat->GetDimensions(nC, nR); CPPUNIT_ASSERT_MESSAGE("matrix is not empty", nC == 0 && nR == 0); @@ -1912,7 +1912,7 @@ void Test::testMatrix() pMat->And() && pMat->Or()); // Test the AND and OR evaluations. - pMat = new ScMatrix(2, 2, 0.0); + pMat = new ScFullMatrix(2, 2, 0.0); // Only some of the elements are non-zero. pMat->PutBoolean(true, 0, 0); @@ -1927,7 +1927,7 @@ void Test::testMatrix() CPPUNIT_ASSERT_MESSAGE("incorrect AND result", pMat->And()); // Now test the emtpy matrix type. - pMat = new ScMatrix(10, 20); + pMat = new ScFullMatrix(10, 20); pMat->GetDimensions(nC, nR); CPPUNIT_ASSERT_MESSAGE("matrix size is not as expected", nC == 10 && nR == 20); checkMatrixElements<AllEmptyMatrix>(*pMat); @@ -1939,7 +1939,7 @@ void Test::testMatrix() checkMatrixElements<PartiallyFilledEmptyMatrix>(*pMat); // Test resizing. - pMat = new ScMatrix(0, 0); + pMat = new ScFullMatrix(0, 0); pMat->Resize(2, 2, 1.5); pMat->PutEmpty(1, 1); @@ -1949,7 +1949,7 @@ void Test::testMatrix() CPPUNIT_ASSERT_MESSAGE("PutEmpty() call failed.", pMat->IsEmpty(1, 1)); // Max and min values. - pMat = new ScMatrix(2, 2, 0.0); + pMat = new ScFullMatrix(2, 2, 0.0); pMat->PutDouble(-10, 0, 0); pMat->PutDouble(-12, 0, 1); pMat->PutDouble(-8, 1, 0); @@ -1961,7 +1961,7 @@ void Test::testMatrix() CPPUNIT_ASSERT_EQUAL(-8.0, pMat->GetMaxValue(false)); // ignore text. pMat->PutBoolean(true, 0, 0); CPPUNIT_ASSERT_EQUAL(1.0, pMat->GetMaxValue(false)); - pMat = new ScMatrix(2, 2, 10.0); + pMat = new ScFullMatrix(2, 2, 10.0); pMat->PutBoolean(false, 0, 0); pMat->PutDouble(12.5, 1, 1); CPPUNIT_ASSERT_EQUAL(0.0, pMat->GetMinValue(false)); @@ -1969,7 +1969,7 @@ void Test::testMatrix() // Convert matrix into a linear double array. String elements become NaN // and empty elements become 0. - pMat = new ScMatrix(3, 3); + pMat = new ScFullMatrix(3, 3); pMat->PutDouble(2.5, 0, 0); pMat->PutDouble(1.2, 0, 1); pMat->PutString(rPool.intern("A"), 1, 1); @@ -1994,7 +1994,7 @@ void Test::testMatrix() } } - pMat2 = new ScMatrix(3, 3, 10.0); + pMat2 = new ScFullMatrix(3, 3, 10.0); pMat2->PutString(rPool.intern("B"), 1, 0); pMat2->MergeDoubleArray(aDoubles, ScMatrix::Mul); diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 655954e21bb7..df05e2284411 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -2169,7 +2169,7 @@ formula::FormulaTokenRef ScTable::ResolveStaticReference( SCCOL nCol1, SCROW nRo if (!ValidCol(nCol1) || !ValidCol(nCol2) || !ValidRow(nRow1) || !ValidRow(nRow2)) return formula::FormulaTokenRef(); - ScMatrixRef pMat(new ScMatrix(nCol2-nCol1+1, nRow2-nRow1+1, 0.0)); + ScMatrixRef pMat(new ScFullMatrix(nCol2-nCol1+1, nRow2-nRow1+1, 0.0)); for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol) { if (!aCol[nCol].ResolveStaticReference(*pMat, nCol2-nCol1, nRow1, nRow2)) diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index 37a1bc94f9b1..437434a3f221 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -643,7 +643,7 @@ bool ScValidationData::GetSelectionFromFormula( // is stored as a single value. // Use an interim matrix to create the TypedStrData below. - xMatRef = new ScMatrix(1, 1, 0.0); + xMatRef = new ScFullMatrix(1, 1, 0.0); sal_uInt16 nErrCode = aValidationSrc.GetErrCode(); if (nErrCode) diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx index 2618a5104bce..ff9aaaca8f5b 100644 --- a/sc/source/core/tool/addincol.cxx +++ b/sc/source/core/tool/addincol.cxx @@ -1576,7 +1576,7 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes ) } if ( nMaxColCount && nRowCount ) { - xMatrix = new ScMatrix( + xMatrix = new ScFullMatrix( static_cast<SCSIZE>(nMaxColCount), static_cast<SCSIZE>(nRowCount), 0.0); for (long nRow=0; nRow<nRowCount; nRow++) @@ -1617,7 +1617,7 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes ) } if ( nMaxColCount && nRowCount ) { - xMatrix = new ScMatrix( + xMatrix = new ScFullMatrix( static_cast<SCSIZE>(nMaxColCount), static_cast<SCSIZE>(nRowCount), 0.0); for (long nRow=0; nRow<nRowCount; nRow++) @@ -1658,7 +1658,7 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes ) } if ( nMaxColCount && nRowCount ) { - xMatrix = new ScMatrix( + xMatrix = new ScFullMatrix( static_cast<SCSIZE>(nMaxColCount), static_cast<SCSIZE>(nRowCount), 0.0); for (long nRow=0; nRow<nRowCount; nRow++) diff --git a/sc/source/core/tool/ddelink.cxx b/sc/source/core/tool/ddelink.cxx index 22f05e4e672a..8a785546e583 100644 --- a/sc/source/core/tool/ddelink.cxx +++ b/sc/source/core/tool/ddelink.cxx @@ -89,7 +89,7 @@ ScDdeLink::ScDdeLink( ScDocument* pD, SvStream& rStream, ScMultipleReadHeader& r bool bHasValue; rStream.ReadCharAsBool( bHasValue ); if ( bHasValue ) - pResult = new ScMatrix(0, 0); + pResult = new ScFullMatrix(0, 0); if (rHdr.BytesLeft()) // neu in 388b und der 364w (RealTime-Client) Version rStream.ReadUChar( nMode ); @@ -155,7 +155,7 @@ sfx2::SvBaseLink::UpdateResult ScDdeLink::DataChanged( else // Daten aufteilen { // Matrix immer neu anlegen, damit bIsString nicht durcheinanderkommt - pResult = new ScMatrix(nCols, nRows, 0.0); + pResult = new ScFullMatrix(nCols, nRows, 0.0); SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); svl::SharedStringPool& rPool = pDoc->GetSharedStringPool(); diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index 085dc0f99afa..a9f8a61d6922 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -376,7 +376,7 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres if (!p2->IsEndFixed()) nRowEnd += i; size_t nRowSize = nRowEnd - nRowStart + 1; - ScMatrixRef pMat(new ScMatrix(nColSize, nRowSize)); + ScMatrixRef pMat(new ScFullMatrix(nColSize, nRowSize)); size_t nDataRowEnd = p2->GetArrayLength() - 1; if (nRowStart > nDataRowEnd) diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 5517f48bb7a0..bf3c0e2d5e43 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -4651,7 +4651,7 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) break; case svExternalSingleRef: { - pSumExtraMatrix = new ScMatrix(1, 1, 0.0); + pSumExtraMatrix = new ScFullMatrix(1, 1, 0.0); ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); if (!pToken) @@ -5903,7 +5903,7 @@ void ScInterpreter::ScLookup() ScMatrixRef pDataMat2; if (bVertical) { - ScMatrixRef pTempMat(new ScMatrix(1, nR, 0.0)); + ScMatrixRef pTempMat(new ScFullMatrix(1, nR, 0.0)); for (SCSIZE i = 0; i < nR; ++i) if (pDataMat->IsValue(0, i)) pTempMat->PutDouble(pDataMat->GetDouble(0, i), 0, i); @@ -5913,7 +5913,7 @@ void ScInterpreter::ScLookup() } else { - ScMatrixRef pTempMat(new ScMatrix(nC, 1, 0.0)); + ScMatrixRef pTempMat(new ScFullMatrix(nC, 1, 0.0)); for (SCSIZE i = 0; i < nC; ++i) if (pDataMat->IsValue(i, 0)) pTempMat->PutDouble(pDataMat->GetDouble(i, 0), i, 0); diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index eb9852e6261f..a0933c0b93e9 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -319,9 +319,9 @@ ScMatrixRef ScInterpreter::GetNewMat(SCSIZE nC, SCSIZE nR, bool bEmpty) { ScMatrixRef pMat; if (bEmpty) - pMat = new ScMatrix(nC, nR); + pMat = new ScFullMatrix(nC, nR); else - pMat = new ScMatrix(nC, nR, 0.0); + pMat = new ScFullMatrix(nC, nR, 0.0); pMat->SetErrorInterpreter( this); // A temporary matrix is mutable and ScMatrix::CloneIfConst() returns the @@ -463,17 +463,17 @@ ScMatrixRef ScInterpreter::GetMatrix() } if (pToken->GetType() == svDouble) { - pMat = new ScMatrix(1, 1, 0.0); + pMat = new ScFullMatrix(1, 1, 0.0); pMat->PutDouble(pToken->GetDouble(), 0, 0); } else if (pToken->GetType() == svString) { - pMat = new ScMatrix(1, 1, 0.0); + pMat = new ScFullMatrix(1, 1, 0.0); pMat->PutString(pToken->GetString(), 0, 0); } else { - pMat = new ScMatrix(1, 1); + pMat = new ScFullMatrix(1, 1); } } break; diff --git a/sc/source/core/tool/jumpmatrix.cxx b/sc/source/core/tool/jumpmatrix.cxx index ea27b972afdf..f02612c2d5ab 100644 --- a/sc/source/core/tool/jumpmatrix.cxx +++ b/sc/source/core/tool/jumpmatrix.cxx @@ -29,7 +29,7 @@ const SCSIZE kBufferThreshhold = 128; ScJumpMatrix::ScJumpMatrix(SCSIZE nColsP, SCSIZE nRowsP) : pJump(new ScJumpMatrixEntry[nColsP * nRowsP]) - , pMat(new ScMatrix(nColsP, nRowsP)) + , pMat(new ScFullMatrix(nColsP, nRowsP)) , pParams(nullptr) , nCols(nColsP) , nRows(nRowsP) diff --git a/sc/source/core/tool/rangeseq.cxx b/sc/source/core/tool/rangeseq.cxx index 6ec7e71c3686..20b94191f1d2 100644 --- a/sc/source/core/tool/rangeseq.cxx +++ b/sc/source/core/tool/rangeseq.cxx @@ -372,7 +372,7 @@ ScMatrixRef ScSequenceToMatrix::CreateMixedMatrix( const css::uno::Any & rAny ) if ( nMaxColCount && nRowCount ) { OUString aUStr; - xMatrix = new ScMatrix( + xMatrix = new ScFullMatrix( static_cast<SCSIZE>(nMaxColCount), static_cast<SCSIZE>(nRowCount), 0.0); SCSIZE nCols, nRows; diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 2af2df361e50..e3823bdd915e 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -208,7 +208,6 @@ class ScMatrixImpl: private boost::noncopyable MatrixImplType maMat; MatrixImplType maMatFlag; ScInterpreter* pErrorInterpreter; - bool mbCloneIfConst; // Whether the matrix is cloned with a CloneIfConst() call. public: ScMatrixImpl(SCSIZE nC, SCSIZE nR); @@ -219,8 +218,6 @@ public: ~ScMatrixImpl(); void Clear(); - void SetImmutable(bool bVal); - bool IsImmutable() const { return mbCloneIfConst;} void Resize(SCSIZE nC, SCSIZE nR); void Resize(SCSIZE nC, SCSIZE nR, double fVal); void SetErrorInterpreter( ScInterpreter* p); @@ -282,9 +279,9 @@ public: double Or() const; double Xor() const; - ScMatrix::IterateResult Sum(bool bTextAsZero) const; - ScMatrix::IterateResult SumSquare(bool bTextAsZero) const; - ScMatrix::IterateResult Product(bool bTextAsZero) const; + ScFullMatrix::IterateResult Sum(bool bTextAsZero) const; + ScFullMatrix::IterateResult SumSquare(bool bTextAsZero) const; + ScFullMatrix::IterateResult Product(bool bTextAsZero) const; size_t Count(bool bCountStrings) const; size_t MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const; size_t MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, size_t nCol2) const; @@ -295,14 +292,14 @@ public: ScMatrixRef CompareMatrix( sc::Compare& rComp, size_t nMatPos, sc::CompareOptions* pOptions ) const; void GetDoubleArray( std::vector<double>& rArray, bool bEmptyAsZero ) const; - void MergeDoubleArray( std::vector<double>& rArray, ScMatrix::Op eOp ) const; + void MergeDoubleArray( std::vector<double>& rArray, ScFullMatrix::Op eOp ) const; void AddValues( const ScMatrixImpl& rMat ); template<typename T> void ApplyOperation(T aOp, ScMatrixImpl& rMat); template<typename T> - std::vector<ScMatrix::IterateResult> ApplyCollectOperation(bool bTextAsZero, const std::vector<std::unique_ptr<T>>& aOp); + std::vector<ScFullMatrix::IterateResult> ApplyCollectOperation(bool bTextAsZero, const std::vector<std::unique_ptr<T>>& aOp); #if DEBUG_MATRIX void Dump() const; @@ -313,13 +310,13 @@ private: }; ScMatrixImpl::ScMatrixImpl(SCSIZE nC, SCSIZE nR) : - maMat(nR, nC), maMatFlag(nR, nC, SC_MATFLAG_EMPTYCELL), pErrorInterpreter(nullptr), mbCloneIfConst(true) {} + maMat(nR, nC), maMatFlag(nR, nC, SC_MATFLAG_EMPTYCELL), pErrorInterpreter(nullptr) {} ScMatrixImpl::ScMatrixImpl(SCSIZE nC, SCSIZE nR, double fInitVal) : - maMat(nR, nC, fInitVal), maMatFlag(nR, nC), pErrorInterpreter(nullptr), mbCloneIfConst(true) {} + maMat(nR, nC, fInitVal), maMatFlag(nR, nC), pErrorInterpreter(nullptr) {} ScMatrixImpl::ScMatrixImpl( size_t nC, size_t nR, const std::vector<double>& rInitVals ) : - maMat(nR, nC, rInitVals.begin(), rInitVals.end()), maMatFlag(nR, nC), pErrorInterpreter(nullptr), mbCloneIfConst(true) {} + maMat(nR, nC, rInitVals.begin(), rInitVals.end()), maMatFlag(nR, nC), pErrorInterpreter(nullptr) {} ScMatrixImpl::~ScMatrixImpl() { @@ -332,11 +329,6 @@ void ScMatrixImpl::Clear() maMatFlag.clear(); } -void ScMatrixImpl::SetImmutable(bool bVal) -{ - mbCloneIfConst = bVal; -} - void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR) { maMat.resize(nR, nC); @@ -1007,13 +999,13 @@ template<typename _Op> class WalkElementBlocks { _Op maOp; - ScMatrix::IterateResult maRes; + ScFullMatrix::IterateResult maRes; bool mbFirst:1; bool mbTextAsZero:1; public: WalkElementBlocks(bool bTextAsZero) : maRes(_Op::InitVal, _Op::InitVal, 0), mbFirst(true), mbTextAsZero(bTextAsZero) {} - const ScMatrix::IterateResult& getResult() const { return maRes; } + const ScFullMatrix::IterateResult& getResult() const { return maRes; } void operator() (const MatrixImplType::element_block_node_type& node) { @@ -1076,7 +1068,7 @@ template<typename _Op> class WalkElementBlocksMultipleValues { const std::vector<std::unique_ptr<_Op>>& maOp; - std::vector<ScMatrix::IterateResult> maRes; + std::vector<ScFullMatrix::IterateResult> maRes; bool mbFirst:1; bool mbTextAsZero:1; public: @@ -1090,7 +1082,7 @@ public: maRes.emplace_back(0.0, 0.0, 0); // count } - const std::vector<ScMatrix::IterateResult>& getResult() const { return maRes; } + const std::vector<ScFullMatrix::IterateResult>& getResult() const { return maRes; } void operator() (const MatrixImplType::element_block_node_type& node) { @@ -1760,7 +1752,7 @@ public: namespace { template<typename TOp> -ScMatrix::IterateResult GetValueWithCount(bool bTextAsZero, const MatrixImplType& maMat) +ScFullMatrix::IterateResult GetValueWithCount(bool bTextAsZero, const MatrixImplType& maMat) { WalkElementBlocks<TOp> aFunc(bTextAsZero); maMat.walk(aFunc); @@ -1769,17 +1761,17 @@ ScMatrix::IterateResult GetValueWithCount(bool bTextAsZero, const MatrixImplType } -ScMatrix::IterateResult ScMatrixImpl::Sum(bool bTextAsZero) const +ScFullMatrix::IterateResult ScMatrixImpl::Sum(bool bTextAsZero) const { return GetValueWithCount<sc::op::Sum>(bTextAsZero, maMat); } -ScMatrix::IterateResult ScMatrixImpl::SumSquare(bool bTextAsZero) const +ScFullMatrix::IterateResult ScMatrixImpl::SumSquare(bool bTextAsZero) const { return GetValueWithCount<sc::op::SumSquare>(bTextAsZero, maMat); } -ScMatrix::IterateResult ScMatrixImpl::Product(bool bTextAsZero) const +ScFullMatrix::IterateResult ScMatrixImpl::Product(bool bTextAsZero) const { return GetValueWithCount<sc::op::Product>(bTextAsZero, maMat); } @@ -1839,7 +1831,7 @@ ScMatrixRef ScMatrixImpl::CompareMatrix( if (nSize != rResVal.size()) ScMatrixRef(); - return ScMatrixRef(new ScMatrix(aSize.column, aSize.row, rResVal)); + return ScMatrixRef(new ScFullMatrix(aSize.column, aSize.row, rResVal)); } } @@ -1851,7 +1843,7 @@ ScMatrixRef ScMatrixImpl::CompareMatrix( if (nSize != rResVal.size()) ScMatrixRef(); - return ScMatrixRef(new ScMatrix(aSize.column, aSize.row, rResVal)); + return ScMatrixRef(new ScFullMatrix(aSize.column, aSize.row, rResVal)); } void ScMatrixImpl::GetDoubleArray( std::vector<double>& rArray, bool bEmptyAsZero ) const @@ -1862,7 +1854,7 @@ void ScMatrixImpl::GetDoubleArray( std::vector<double>& rArray, bool bEmptyAsZer aFunc.swap(rArray); } -void ScMatrixImpl::MergeDoubleArray( std::vector<double>& rArray, ScMatrix::Op eOp ) const +void ScMatrixImpl::MergeDoubleArray( std::vector<double>& rArray, ScFullMatrix::Op eOp ) const { MatrixImplType::size_pair_type aSize = maMat.size(); size_t nSize = aSize.row*aSize.column; @@ -1871,7 +1863,7 @@ void ScMatrixImpl::MergeDoubleArray( std::vector<double>& rArray, ScMatrix::Op e switch (eOp) { - case ScMatrix::Mul: + case ScFullMatrix::Mul: { MergeDoubleArrayFunc<ArrayMul> aFunc(rArray); maMat.walk(aFunc); @@ -2168,7 +2160,7 @@ void ScMatrixImpl::ApplyOperation(T aOp, ScMatrixImpl& rMat) } template<typename T> -std::vector<ScMatrix::IterateResult> ScMatrixImpl::ApplyCollectOperation(bool bTextAsZero, const std::vector<std::unique_ptr<T>>& aOp) +std::vector<ScFullMatrix::IterateResult> ScMatrixImpl::ApplyCollectOperation(bool bTextAsZero, const std::vector<std::unique_ptr<T>>& aOp) { WalkElementBlocksMultipleValues<T> aFunc(bTextAsZero, aOp); maMat.walk(aFunc); @@ -2231,36 +2223,39 @@ void ScMatrix::DecRef() const delete this; } -ScMatrix::ScMatrix( SCSIZE nC, SCSIZE nR) : - pImpl(new ScMatrixImpl(nC, nR)), nRefCnt(0) +ScFullMatrix::ScFullMatrix( SCSIZE nC, SCSIZE nR) : + ScMatrix(), + pImpl(new ScMatrixImpl(nC, nR)) { SAL_WARN_IF( !nC, "sc", "ScMatrix with 0 columns!"); SAL_WARN_IF( !nR, "sc", "ScMatrix with 0 rows!"); } -ScMatrix::ScMatrix(SCSIZE nC, SCSIZE nR, double fInitVal) : - pImpl(new ScMatrixImpl(nC, nR, fInitVal)), nRefCnt(0) +ScFullMatrix::ScFullMatrix(SCSIZE nC, SCSIZE nR, double fInitVal) : + ScMatrix(), + pImpl(new ScMatrixImpl(nC, nR, fInitVal)) { SAL_WARN_IF( !nC, "sc", "ScMatrix with 0 columns!"); SAL_WARN_IF( !nR, "sc", "ScMatrix with 0 rows!"); } -ScMatrix::ScMatrix( size_t nC, size_t nR, const std::vector<double>& rInitVals ) : - pImpl(new ScMatrixImpl(nC, nR, rInitVals)), nRefCnt(0) +ScFullMatrix::ScFullMatrix( size_t nC, size_t nR, const std::vector<double>& rInitVals ) : + ScMatrix(), + pImpl(new ScMatrixImpl(nC, nR, rInitVals)) { SAL_WARN_IF( !nC, "sc", "ScMatrix with 0 columns!"); SAL_WARN_IF( !nR, "sc", "ScMatrix with 0 rows!"); } -ScMatrix::~ScMatrix() +ScFullMatrix::~ScFullMatrix() { } -ScMatrix* ScMatrix::Clone() const +ScMatrix* ScFullMatrix::Clone() const { SCSIZE nC, nR; pImpl->GetDimensions(nC, nR); - ScMatrix* pScMat = new ScMatrix(nC, nR); + ScMatrix* pScMat = new ScFullMatrix(nC, nR); MatCopy(*pScMat); pScMat->SetErrorInterpreter(pImpl->GetErrorInterpreter()); // TODO: really? return pScMat; @@ -2268,339 +2263,345 @@ ScMatrix* ScMatrix::Clone() const ScMatrix* ScMatrix::CloneIfConst() { - return pImpl->IsImmutable() ? Clone() : this; + return mbCloneIfConst ? Clone() : this; } void ScMatrix::SetImmutable( bool bVal ) { - pImpl->SetImmutable(bVal); + mbCloneIfConst = bVal; } -void ScMatrix::Resize( SCSIZE nC, SCSIZE nR) +void ScFullMatrix::Resize( SCSIZE nC, SCSIZE nR) { pImpl->Resize(nC, nR); } -void ScMatrix::Resize(SCSIZE nC, SCSIZE nR, double fVal) +void ScFullMatrix::Resize(SCSIZE nC, SCSIZE nR, double fVal) { pImpl->Resize(nC, nR, fVal); } -ScMatrix* ScMatrix::CloneAndExtend(SCSIZE nNewCols, SCSIZE nNewRows) const +ScMatrix* ScFullMatrix::CloneAndExtend(SCSIZE nNewCols, SCSIZE nNewRows) const { - ScMatrix* pScMat = new ScMatrix(nNewCols, nNewRows); + ScMatrix* pScMat = new ScFullMatrix(nNewCols, nNewRows); MatCopy(*pScMat); pScMat->SetErrorInterpreter(pImpl->GetErrorInterpreter()); return pScMat; } -void ScMatrix::SetErrorInterpreter( ScInterpreter* p) +void ScFullMatrix::SetErrorInterpreter( ScInterpreter* p) { pImpl->SetErrorInterpreter(p); } -void ScMatrix::GetDimensions( SCSIZE& rC, SCSIZE& rR) const +void ScFullMatrix::GetDimensions( SCSIZE& rC, SCSIZE& rR) const { pImpl->GetDimensions(rC, rR); } -SCSIZE ScMatrix::GetElementCount() const +SCSIZE ScFullMatrix::GetElementCount() const { return pImpl->GetElementCount(); } -bool ScMatrix::ValidColRow( SCSIZE nC, SCSIZE nR) const +bool ScFullMatrix::ValidColRow( SCSIZE nC, SCSIZE nR) const { return pImpl->ValidColRow(nC, nR); } -bool ScMatrix::ValidColRowReplicated( SCSIZE & rC, SCSIZE & rR ) const +bool ScFullMatrix::ValidColRowReplicated( SCSIZE & rC, SCSIZE & rR ) const { return pImpl->ValidColRowReplicated(rC, rR); } -bool ScMatrix::ValidColRowOrReplicated( SCSIZE & rC, SCSIZE & rR ) const +bool ScFullMatrix::ValidColRowOrReplicated( SCSIZE & rC, SCSIZE & rR ) const { return ValidColRow( rC, rR) || ValidColRowReplicated( rC, rR); } -void ScMatrix::PutDouble(double fVal, SCSIZE nC, SCSIZE nR) +void ScFullMatrix::PutDouble(double fVal, SCSIZE nC, SCSIZE nR) { pImpl->PutDouble(fVal, nC, nR); } -void ScMatrix::PutDouble( double fVal, SCSIZE nIndex) +void ScFullMatrix::PutDouble( double fVal, SCSIZE nIndex) { pImpl->PutDouble(fVal, nIndex); } -void ScMatrix::PutDouble(const double* pArray, size_t nLen, SCSIZE nC, SCSIZE nR) +void ScFullMatrix::PutDouble(const double* pArray, size_t nLen, SCSIZE nC, SCSIZE nR) { pImpl->PutDouble(pArray, nLen, nC, nR); } -void ScMatrix::PutString(const svl::SharedString& rStr, SCSIZE nC, SCSIZE nR) +void ScFullMatrix::PutString(const svl::SharedString& rStr, SCSIZE nC, SCSIZE nR) { pImpl->PutString(rStr, nC, nR); } -void ScMatrix::PutString(const svl::SharedString& rStr, SCSIZE nIndex) +void ScFullMatrix::PutString(const svl::SharedString& rStr, SCSIZE nIndex) { pImpl->PutString(rStr, nIndex); } -void ScMatrix::PutString(const svl::SharedString* pArray, size_t nLen, SCSIZE nC, SCSIZE nR) +void ScFullMatrix::PutString(const svl::SharedString* pArray, size_t nLen, SCSIZE nC, SCSIZE nR) { pImpl->PutString(pArray, nLen, nC, nR); } -void ScMatrix::PutEmpty(SCSIZE nC, SCSIZE nR) +void ScFullMatrix::PutEmpty(SCSIZE nC, SCSIZE nR) { pImpl->PutEmpty(nC, nR); } -void ScMatrix::PutEmptyPath(SCSIZE nC, SCSIZE nR) +void ScFullMatrix::PutEmptyPath(SCSIZE nC, SCSIZE nR) { pImpl->PutEmptyPath(nC, nR); } -void ScMatrix::PutError( sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR ) +void ScFullMatrix::PutError( sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR ) { pImpl->PutError(nErrorCode, nC, nR); } -void ScMatrix::PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR) +void ScFullMatrix::PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR) { pImpl->PutBoolean(bVal, nC, nR); } -sal_uInt16 ScMatrix::GetError( SCSIZE nC, SCSIZE nR) const +sal_uInt16 ScFullMatrix::GetError( SCSIZE nC, SCSIZE nR) const { return pImpl->GetError(nC, nR); } -double ScMatrix::GetDouble(SCSIZE nC, SCSIZE nR) const +double ScFullMatrix::GetDouble(SCSIZE nC, SCSIZE nR) const { return pImpl->GetDouble(nC, nR); } -double ScMatrix::GetDouble( SCSIZE nIndex) const +double ScFullMatrix::GetDouble( SCSIZE nIndex) const { return pImpl->GetDouble(nIndex); } -svl::SharedString ScMatrix::GetString(SCSIZE nC, SCSIZE nR) const +svl::SharedString ScFullMatrix::GetString(SCSIZE nC, SCSIZE nR) const { return pImpl->GetString(nC, nR); } -svl::SharedString ScMatrix::GetString( SCSIZE nIndex) const +svl::SharedString ScFullMatrix::GetString( SCSIZE nIndex) const { return pImpl->GetString(nIndex); } -svl::SharedString ScMatrix::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const +svl::SharedString ScFullMatrix::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const { return pImpl->GetString(rFormatter, nC, nR); } -ScMatrixValue ScMatrix::Get(SCSIZE nC, SCSIZE nR) const +ScMatrixValue ScFullMatrix::Get(SCSIZE nC, SCSIZE nR) const { return pImpl->Get(nC, nR); } -bool ScMatrix::IsString( SCSIZE nIndex ) const +bool ScFullMatrix::IsString( SCSIZE nIndex ) const { return pImpl->IsString(nIndex); } -bool ScMatrix::IsString( SCSIZE nC, SCSIZE nR ) const +bool ScFullMatrix::IsString( SCSIZE nC, SCSIZE nR ) const { return pImpl->IsString(nC, nR); } -bool ScMatrix::IsEmpty( SCSIZE nC, SCSIZE nR ) const +bool ScFullMatrix::IsEmpty( SCSIZE nC, SCSIZE nR ) const { return pImpl->IsEmpty(nC, nR); } -bool ScMatrix::IsEmptyCell( SCSIZE nC, SCSIZE nR ) const +bool ScFullMatrix::IsEmptyCell( SCSIZE nC, SCSIZE nR ) const { return pImpl->IsEmptyCell(nC, nR); } -bool ScMatrix::IsEmptyResult( SCSIZE nC, SCSIZE nR ) const +bool ScFullMatrix::IsEmptyResult( SCSIZE nC, SCSIZE nR ) const { return pImpl->IsEmptyResult(nC, nR); } -bool ScMatrix::IsEmptyPath( SCSIZE nC, SCSIZE nR ) const +bool ScFullMatrix::IsEmptyPath( SCSIZE nC, SCSIZE nR ) const { return pImpl->IsEmptyPath(nC, nR); } -bool ScMatrix::IsValue( SCSIZE nIndex ) const +bool ScFullMatrix::IsValue( SCSIZE nIndex ) const { return pImpl->IsValue(nIndex); } -bool ScMatrix::IsValue( SCSIZE nC, SCSIZE nR ) const +bool ScFullMatrix::IsValue( SCSIZE nC, SCSIZE nR ) const { return pImpl->IsValue(nC, nR); } -bool ScMatrix::IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const +bool ScFullMatrix::IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const { return pImpl->IsValueOrEmpty(nC, nR); } -bool ScMatrix::IsBoolean( SCSIZE nC, SCSIZE nR ) const +bool ScFullMatrix::IsBoolean( SCSIZE nC, SCSIZE nR ) const { return pImpl->IsBoolean(nC, nR); } -bool ScMatrix::IsNumeric() const +bool ScFullMatrix::IsNumeric() const { return pImpl->IsNumeric(); } -void ScMatrix::MatCopy(ScMatrix& mRes) const +void ScFullMatrix::MatCopy(ScMatrix& mRes) const { - pImpl->MatCopy(*mRes.pImpl); + // FIXME + ScFullMatrix* pMatrix = dynamic_cast<ScFullMatrix*>(&mRes); + assert(pMatrix); + pImpl->MatCopy(*pMatrix->pImpl); } -void ScMatrix::MatTrans(ScMatrix& mRes) const +void ScFullMatrix::MatTrans(ScMatrix& mRes) const { - pImpl->MatTrans(*mRes.pImpl); + // FIXME + ScFullMatrix* pMatrix = dynamic_cast<ScFullMatrix*>(&mRes); + assert(pMatrix); + pImpl->MatTrans(*pMatrix->pImpl); } -void ScMatrix::FillDouble( double fVal, SCSIZE nC1, SCSIZE nR1, SCSIZE nC2, SCSIZE nR2 ) +void ScFullMatrix::FillDouble( double fVal, SCSIZE nC1, SCSIZE nR1, SCSIZE nC2, SCSIZE nR2 ) { pImpl->FillDouble(fVal, nC1, nR1, nC2, nR2); } -void ScMatrix::PutDoubleVector( const ::std::vector< double > & rVec, SCSIZE nC, SCSIZE nR ) +void ScFullMatrix::PutDoubleVector( const ::std::vector< double > & rVec, SCSIZE nC, SCSIZE nR ) { pImpl->PutDoubleVector(rVec, nC, nR); } -void ScMatrix::PutStringVector( const ::std::vector< svl::SharedString > & rVec, SCSIZE nC, SCSIZE nR ) +void ScFullMatrix::PutStringVector( const ::std::vector< svl::SharedString > & rVec, SCSIZE nC, SCSIZE nR ) { pImpl->PutStringVector(rVec, nC, nR); } -void ScMatrix::PutEmptyVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) +void ScFullMatrix::PutEmptyVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) { pImpl->PutEmptyVector(nCount, nC, nR); } -void ScMatrix::PutEmptyResultVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) +void ScFullMatrix::PutEmptyResultVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) { pImpl->PutEmptyResultVector(nCount, nC, nR); } -void ScMatrix::PutEmptyPathVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) +void ScFullMatrix::PutEmptyPathVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) { pImpl->PutEmptyPathVector(nCount, nC, nR); } -void ScMatrix::CompareEqual() +void ScFullMatrix::CompareEqual() { pImpl->CompareEqual(); } -void ScMatrix::CompareNotEqual() +void ScFullMatrix::CompareNotEqual() { pImpl->CompareNotEqual(); } -void ScMatrix::CompareLess() +void ScFullMatrix::CompareLess() { pImpl->CompareLess(); } -void ScMatrix::CompareGreater() +void ScFullMatrix::CompareGreater() { pImpl->CompareGreater(); } -void ScMatrix::CompareLessEqual() +void ScFullMatrix::CompareLessEqual() { pImpl->CompareLessEqual(); } -void ScMatrix::CompareGreaterEqual() +void ScFullMatrix::CompareGreaterEqual() { pImpl->CompareGreaterEqual(); } -double ScMatrix::And() const +double ScFullMatrix::And() const { return pImpl->And(); } -double ScMatrix::Or() const +double ScFullMatrix::Or() const { return pImpl->Or(); } -double ScMatrix::Xor() const +double ScFullMatrix::Xor() const { return pImpl->Xor(); } -ScMatrix::IterateResult ScMatrix::Sum(bool bTextAsZero) const +ScFullMatrix::IterateResult ScFullMatrix::Sum(bool bTextAsZero) const { return pImpl->Sum(bTextAsZero); } -ScMatrix::IterateResult ScMatrix::SumSquare(bool bTextAsZero) const +ScFullMatrix::IterateResult ScFullMatrix::SumSquare(bool bTextAsZero) const { return pImpl->SumSquare(bTextAsZero); } -ScMatrix::IterateResult ScMatrix::Product(bool bTextAsZero) const +ScFullMatrix::IterateResult ScFullMatrix::Product(bool bTextAsZero) const { return pImpl->Product(bTextAsZero); } -size_t ScMatrix::Count(bool bCountStrings) const +size_t ScFullMatrix::Count(bool bCountStrings) const { return pImpl->Count(bCountStrings); } -size_t ScMatrix::MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const +size_t ScFullMatrix::MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const { return pImpl->MatchDoubleInColumns(fValue, nCol1, nCol2); } -size_t ScMatrix::MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, size_t nCol2) const +size_t ScFullMatrix::MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, size_t nCol2) const { return pImpl->MatchStringInColumns(rStr, nCol1, nCol2); } -double ScMatrix::GetMaxValue( bool bTextAsZero ) const +double ScFullMatrix::GetMaxValue( bool bTextAsZero ) const { return pImpl->GetMaxValue(bTextAsZero); } -double ScMatrix::GetMinValue( bool bTextAsZero ) const +double ScFullMatrix::GetMinValue( bool bTextAsZero ) const { return pImpl->GetMinValue(bTextAsZero); } -ScMatrixRef ScMatrix::CompareMatrix( +ScMatrixRef ScFullMatrix::CompareMatrix( sc::Compare& rComp, size_t nMatPos, sc::CompareOptions* pOptions ) const { return pImpl->CompareMatrix(rComp, nMatPos, pOptions); } -void ScMatrix::GetDoubleArray( std::vector<double>& rArray, bool bEmptyAsZero ) const +void ScFullMatrix::GetDoubleArray( std::vector<double>& rArray, bool bEmptyAsZero ) const { pImpl->GetDoubleArray(rArray, bEmptyAsZero); } -void ScMatrix::MergeDoubleArray( std::vector<double>& rArray, Op eOp ) const +void ScFullMatrix::MergeDoubleArray( std::vector<double>& rArray, Op eOp ) const { pImpl->MergeDoubleArray(rArray, eOp); } @@ -2708,95 +2709,125 @@ public: } -void ScMatrix::NotOp( ScMatrix& rMat) +void ScFullMatrix::NotOp( ScMatrix& rMat) { auto not_ = [](double a, double){return double(a == 0.0);}; matop::MatOp<decltype(not_), double> aOp(not_, pImpl->GetErrorInterpreter()); - pImpl->ApplyOperation(aOp, *rMat.pImpl); + // FIXME + ScFullMatrix* pMatrix = dynamic_cast<ScFullMatrix*>(&rMat); + assert(pMatrix); + pImpl->ApplyOperation(aOp, *pMatrix->pImpl); } -void ScMatrix::NegOp( ScMatrix& rMat) +void ScFullMatrix::NegOp( ScMatrix& rMat) { auto neg_ = [](double a, double){return -a;}; matop::MatOp<decltype(neg_), double> aOp(neg_, pImpl->GetErrorInterpreter()); - pImpl->ApplyOperation(aOp, *rMat.pImpl); + // FIXME + ScFullMatrix* pMatrix = dynamic_cast<ScFullMatrix*>(&rMat); + assert(pMatrix); + pImpl->ApplyOperation(aOp, *pMatrix->pImpl); } -void ScMatrix::AddOp( double fVal, ScMatrix& rMat) +void ScFullMatrix::AddOp( double fVal, ScMatrix& rMat) { auto add_ = [](double a, double b){return a + b;}; matop::MatOp<decltype(add_)> aOp(add_, pImpl->GetErrorInterpreter(), fVal); - pImpl->ApplyOperation(aOp, *rMat.pImpl); + // FIXME + ScFullMatrix* pMatrix = dynamic_cast<ScFullMatrix*>(&rMat); + assert(pMatrix); + pImpl->ApplyOperation(aOp, *pMatrix->pImpl); } -void ScMatrix::SubOp( bool bFlag, double fVal, ScMatrix& rMat) +void ScFullMatrix::SubOp( bool bFlag, double fVal, ScMatrix& rMat) { if (bFlag) { auto sub_ = [](double a, double b){return b - a;}; matop::MatOp<decltype(sub_)> aOp(sub_, pImpl->GetErrorInterpreter(), fVal); - pImpl->ApplyOperation(aOp, *rMat.pImpl); + // FIXME + ScFullMatrix* pMatrix = dynamic_cast<ScFullMatrix*>(&rMat); + assert(pMatrix); + pImpl->ApplyOperation(aOp, *pMatrix->pImpl); } else { auto sub_ = [](double a, double b){return a - b;}; matop::MatOp<decltype(sub_)> aOp(sub_, pImpl->GetErrorInterpreter(), fVal); - pImpl->ApplyOperation(aOp, *rMat.pImpl); + // FIXME + ScFullMatrix* pMatrix = dynamic_cast<ScFullMatrix*>(&rMat); + assert(pMatrix); + pImpl->ApplyOperation(aOp, *pMatrix->pImpl); } } -void ScMatrix::MulOp( double fVal, ScMatrix& rMat) +void ScFullMatrix::MulOp( double fVal, ScMatrix& rMat) { auto mul_ = [](double a, double b){return a * b;}; matop::MatOp<decltype(mul_)> aOp(mul_, pImpl->GetErrorInterpreter(), fVal); - pImpl->ApplyOperation(aOp, *rMat.pImpl); + // FIXME + ScFullMatrix* pMatrix = dynamic_cast<ScFullMatrix*>(&rMat); + assert(pMatrix); + pImpl->ApplyOperation(aOp, *pMatrix->pImpl); } -void ScMatrix::DivOp( bool bFlag, double fVal, ScMatrix& rMat) +void ScFullMatrix::DivOp( bool bFlag, double fVal, ScMatrix& rMat) { if (bFlag) { auto div_ = [](double a, double b){return sc::div(b, a);}; matop::MatOp<decltype(div_)> aOp(div_, pImpl->GetErrorInterpreter(), fVal); - pImpl->ApplyOperation(aOp, *rMat.pImpl); + // FIXME + ScFullMatrix* pMatrix = dynamic_cast<ScFullMatrix*>(&rMat); + assert(pMatrix); + pImpl->ApplyOperation(aOp, *pMatrix->pImpl); } else { auto div_ = [](double a, double b){return sc::div(a, b);}; matop::MatOp<decltype(div_)> aOp(div_, pImpl->GetErrorInterpreter(), fVal); - pImpl->ApplyOperation(aOp, *rMat.pImpl); + // FIXME + ScFullMatrix* pMatrix = dynamic_cast<ScFullMatrix*>(&rMat); + assert(pMatrix); + pImpl->ApplyOperation(aOp, *pMatrix->pImpl); } } -void ScMatrix::PowOp( bool bFlag, double fVal, ScMatrix& rMat) +void ScFullMatrix::PowOp( bool bFlag, double fVal, ScMatrix& rMat) { if (bFlag) { auto pow_ = [](double a, double b){return pow(b, a);}; matop::MatOp<decltype(pow_)> aOp(pow_, pImpl->GetErrorInterpreter(), fVal); - pImpl->ApplyOperation(aOp, *rMat.pImpl); + // FIXME + ScFullMatrix* pMatrix = dynamic_cast<ScFullMatrix*>(&rMat); + assert(pMatrix); + pImpl->ApplyOperation(aOp, *pMatrix->pImpl); } else { auto pow_ = [](double a, double b){return pow(a, b);}; matop::MatOp<decltype(pow_)> aOp(pow_, pImpl->GetErrorInterpreter(), fVal); - pImpl->ApplyOperation(aOp, *rMat.pImpl); + // FIXME + ScFullMatrix* pMatrix = dynamic_cast<ScFullMatrix*>(&rMat); + assert(pMatrix); + pImpl->ApplyOperation(aOp, *pMatrix->pImpl); } } -std::vector<ScMatrix::IterateResult> ScMatrix::Collect(bool bTextAsZero, const std::vector<std::unique_ptr<sc::op::Op>>& aOp) +std::vector<ScFullMatrix::IterateResult> ScFullMatrix::Collect(bool bTextAsZero, const std::vector<std::unique_ptr<sc::op::Op>>& aOp) { return pImpl->ApplyCollectOperation(bTextAsZero, aOp); } -ScMatrix& ScMatrix::operator+= ( const ScMatrix& r ) +ScFullMatrix& ScFullMatrix::operator+= ( const ScFullMatrix& r ) { pImpl->AddValues(*r.pImpl); return *this; } #if DEBUG_MATRIX -void ScMatrix::Dump() const +void ScFullMatrix::Dump() const { pImpl->Dump(); } diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 498ba94c0c5d..3f978c448693 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -1940,7 +1940,7 @@ FormulaToken* ScTokenArray::MergeArray( ) return nullptr; int nSign = 1; - ScMatrix* pArray = new ScMatrix(nCol, nRow, 0.0); + ScMatrix* pArray = new ScFullMatrix(nCol, nRow, 0.0); for ( i = nStart, nCol = 0, nRow = 0 ; i < nLen ; i++ ) { t = pCode[i]; diff --git a/sc/source/filter/excel/tokstack.cxx b/sc/source/filter/excel/tokstack.cxx index 4bc6ba0e24fe..1a8a399f8b62 100644 --- a/sc/source/filter/excel/tokstack.cxx +++ b/sc/source/filter/excel/tokstack.cxx @@ -786,7 +786,7 @@ const TokenId TokenPool::StoreMatrix() pElement[ nElementAkt ] = nP_MatrixAkt; pType[ nElementAkt ] = T_Matrix; - pM = new ScMatrix( 0, 0 ); + pM = new ScFullMatrix( 0, 0 ); pM->IncRef( ); ppP_Matrix[ nP_MatrixAkt ] = pM; diff --git a/sc/source/filter/excel/xihelper.cxx b/sc/source/filter/excel/xihelper.cxx index 62c1504a390f..6b1bc9497ddc 100644 --- a/sc/source/filter/excel/xihelper.cxx +++ b/sc/source/filter/excel/xihelper.cxx @@ -864,7 +864,7 @@ ScMatrixRef XclImpCachedMatrix::CreateScMatrix( svl::SharedStringPool& rPool ) c OSL_ENSURE( mnScCols * mnScRows == maValueList.size(), "XclImpCachedMatrix::CreateScMatrix - element count mismatch" ); if( mnScCols && mnScRows && static_cast< sal_uLong >( mnScCols * mnScRows ) <= maValueList.size() ) { - xScMatrix = new ScMatrix(mnScCols, mnScRows, 0.0); + xScMatrix = new ScFullMatrix(mnScCols, mnScRows, 0.0); XclImpValueList::const_iterator itValue = maValueList.begin(); for( SCSIZE nScRow = 0; nScRow < mnScRows; ++nScRow ) { diff --git a/sc/source/filter/excel/xilink.cxx b/sc/source/filter/excel/xilink.cxx index 6c212371d423..7b7ec4bc3563 100644 --- a/sc/source/filter/excel/xilink.cxx +++ b/sc/source/filter/excel/xilink.cxx @@ -270,7 +270,7 @@ sal_uInt16 XclImpTabInfo::GetCurrentIndex( sal_uInt16 nCreatedId, sal_uInt16 nMa // External names ============================================================= XclImpExtName::MOper::MOper(svl::SharedStringPool& rPool, XclImpStream& rStrm) : - mxCached(new ScMatrix(0,0)) + mxCached(new ScFullMatrix(0,0)) { SCSIZE nLastCol = rStrm.ReaduInt8(); SCSIZE nLastRow = rStrm.ReaduInt16(); diff --git a/sc/source/filter/inc/xihelper.hxx b/sc/source/filter/inc/xihelper.hxx index e6b90127c7ff..4e54d7c3ab2d 100644 --- a/sc/source/filter/inc/xihelper.hxx +++ b/sc/source/filter/inc/xihelper.hxx @@ -329,7 +329,7 @@ public: explicit XclImpCachedMatrix( XclImpStream& rStrm ); ~XclImpCachedMatrix(); - /** Creates a new ScMatrix object and fills it with the contained values. */ + /** Creates a new ScFullMatrix object and fills it with the contained values. */ ScMatrixRef CreateScMatrix( svl::SharedStringPool& rPool ) const; private: diff --git a/sc/source/filter/xml/XMLDDELinksContext.cxx b/sc/source/filter/xml/XMLDDELinksContext.cxx index 5216fa02c232..43425db63388 100644 --- a/sc/source/filter/xml/XMLDDELinksContext.cxx +++ b/sc/source/filter/xml/XMLDDELinksContext.cxx @@ -153,7 +153,7 @@ void ScXMLDDELinkContext::EndElement() OSL_ENSURE( static_cast<size_t>(nColumns * nRows) == aDDELinkTable.size(), "ScXMLDDELinkContext::EndElement: adapted matrix dimension doesn't match either"); } - ScMatrixRef pMatrix = new ScMatrix(static_cast<SCSIZE>(nColumns), static_cast<SCSIZE>(nRows), 0.0); + ScMatrixRef pMatrix = new ScFullMatrix(static_cast<SCSIZE>(nColumns), static_cast<SCSIZE>(nRows), 0.0); sal_Int32 nCol(0); sal_Int32 nRow(-1); sal_Int32 nIndex(0); diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index ded2e1941fd0..f55e570aec17 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -1439,7 +1439,7 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos ) ScFormulaCell* pFCell = rXMLImport.GetDocument()->GetFormulaCell(rCellPos); if (pFCell) { - ScMatrixRef pMat(new ScMatrix(nMatrixCols, nMatrixRows)); + ScMatrixRef pMat(new ScFullMatrix(nMatrixCols, nMatrixRows)); if (bFormulaTextResult && maStringValue) { if (!IsPossibleErrorString()) diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index d2fa8d6f93b0..90b570327876 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -616,7 +616,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData( return TokenArrayRef(); } - ScMatrixRef xMat = new ScMatrix( + ScMatrixRef xMat = new ScFullMatrix( static_cast<SCSIZE>(nDataCol2-nDataCol1+1), static_cast<SCSIZE>(nDataRow2-nDataRow1+1)); // Only fill non-empty cells, for better performance. @@ -1502,7 +1502,7 @@ static std::unique_ptr<ScTokenArray> convertToTokenArray( else pUsedRange.reset(new ScRange(nDataCol1, nDataRow1, 0, nDataCol2, nDataRow2, 0)); - ScMatrixRef xMat = new ScMatrix( + ScMatrixRef xMat = new ScFullMatrix( static_cast<SCSIZE>(nCol2-nCol1+1), static_cast<SCSIZE>(nRow2-nRow1+1)); ColumnBatch<svl::SharedString> aStringBatch(pHostDoc, pSrcDoc, CELLTYPE_STRING, CELLTYPE_EDIT); @@ -1584,7 +1584,7 @@ static std::unique_ptr<ScTokenArray> lcl_fillEmptyMatrix(const ScRange& rRange) { SCSIZE nC = static_cast<SCSIZE>(rRange.aEnd.Col()-rRange.aStart.Col()+1); SCSIZE nR = static_cast<SCSIZE>(rRange.aEnd.Row()-rRange.aStart.Row()+1); - ScMatrixRef xMat = new ScMatrix(nC, nR); + ScMatrixRef xMat = new ScFullMatrix(nC, nR); ScMatrixToken aToken(xMat); unique_ptr<ScTokenArray> pArray(new ScTokenArray); |