summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-07-01 16:04:35 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-07-01 18:55:53 -0400
commited76237e41ecdb58f524e14ea6b8866f8dacf6a9 (patch)
treea33661b0686eb87e203b5c9f329867eb91c6ce0e
parent83f77ab0661df992f241e5f9ecb1aa8f8eaeafec (diff)
Reduce dependency on the matrix header.
Change-Id: Iade09d108aec78f8cbe92f9103f206d0c99fab8e
-rw-r--r--sc/Library_sc.mk1
-rw-r--r--sc/inc/addincol.hxx4
-rw-r--r--sc/inc/externalrefmgr.hxx2
-rw-r--r--sc/inc/queryparam.hxx2
-rw-r--r--sc/inc/rangeseq.hxx2
-rw-r--r--sc/inc/scmatrix.hxx8
-rw-r--r--sc/inc/token.hxx56
-rw-r--r--sc/inc/tokenarray.hxx1
-rw-r--r--sc/inc/types.hxx8
-rw-r--r--sc/source/core/data/column2.cxx1
-rw-r--r--sc/source/core/data/dociter.cxx1
-rw-r--r--sc/source/core/data/documen4.cxx1
-rw-r--r--sc/source/core/data/table1.cxx1
-rw-r--r--sc/source/core/data/validat.cxx6
-rw-r--r--sc/source/core/inc/ddelink.hxx8
-rw-r--r--sc/source/core/inc/doubleref.hxx2
-rw-r--r--sc/source/core/inc/interpre.hxx2
-rw-r--r--sc/source/core/inc/jumpmatrix.hxx179
-rw-r--r--sc/source/core/tool/addincol.cxx8
-rw-r--r--sc/source/core/tool/compiler.cxx1
-rw-r--r--sc/source/core/tool/ddelink.cxx15
-rw-r--r--sc/source/core/tool/doubleref.cxx1
-rw-r--r--sc/source/core/tool/formulagroup.cxx2
-rw-r--r--sc/source/core/tool/formularesult.cxx1
-rw-r--r--sc/source/core/tool/jumpmatrix.cxx173
-rw-r--r--sc/source/core/tool/queryparam.cxx1
-rw-r--r--sc/source/core/tool/rangenam.cxx2
-rw-r--r--sc/source/core/tool/token.cxx40
-rw-r--r--sc/source/filter/excel/excform.cxx2
-rw-r--r--sc/source/filter/excel/xeformula.cxx1
-rw-r--r--sc/source/filter/excel/xehelper.cxx1
-rw-r--r--sc/source/filter/excel/xihelper.cxx8
-rw-r--r--sc/source/filter/excel/xilink.cxx3
-rw-r--r--sc/source/filter/inc/xihelper.hxx7
-rw-r--r--sc/source/filter/inc/xilink.hxx2
-rw-r--r--sc/source/filter/xml/xmlcelli.cxx1
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx1
-rw-r--r--sc/source/ui/unoobj/chart2uno.cxx1
-rw-r--r--sc/source/ui/unoobj/linkuno.cxx1
39 files changed, 332 insertions, 225 deletions
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 836f87faa170..5815fd0a303d 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -225,6 +225,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/tool/interpr5 \
sc/source/core/tool/interpr6 \
sc/source/core/tool/interpr7 \
+ sc/source/core/tool/jumpmatrix \
sc/source/core/tool/lookupcache \
sc/source/core/tool/navicfg \
sc/source/core/tool/odffmap \
diff --git a/sc/inc/addincol.hxx b/sc/inc/addincol.hxx
index 15abd4c7bce5..4b440a258652 100644
--- a/sc/inc/addincol.hxx
+++ b/sc/inc/addincol.hxx
@@ -32,7 +32,7 @@
#include "scdllapi.h"
#include <rtl/ustring.hxx>
-#include "scmatrix.hxx"
+#include "types.hxx"
#include <boost/unordered_map.hpp>
@@ -233,7 +233,7 @@ public:
bool HasVarRes() const { return ( xVarRes.is() ); }
double GetValue() const { return fValue; }
const OUString& GetString() const { return aString; }
- ScMatrixRef GetMatrix() const { return xMatrix; }
+ ScMatrixRef GetMatrix() const;
com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult>
GetVarRes() const { return xVarRes; }
};
diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index 0a115c057bf3..4e39a5d027c9 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -29,7 +29,7 @@
#include "vcl/timer.hxx"
#include "svl/zforlist.hxx"
#include "svl/lstner.hxx"
-#include "scmatrix.hxx"
+#include "types.hxx"
#include "rangelst.hxx"
#include "formula/token.hxx"
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index 26d2d1b2a087..0d814cd0d9b5 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -21,7 +21,7 @@
#define SC_QUERYPARAM_HXX
#include "global.hxx"
-#include "scmatrix.hxx"
+#include "types.hxx"
#include <boost/ptr_container/ptr_vector.hpp>
diff --git a/sc/inc/rangeseq.hxx b/sc/inc/rangeseq.hxx
index bd8a90026cdb..b13233d2705d 100644
--- a/sc/inc/rangeseq.hxx
+++ b/sc/inc/rangeseq.hxx
@@ -22,7 +22,7 @@
#include <tools/solar.h>
#include <com/sun/star/uno/Any.h>
-#include "scmatrix.hxx"
+#include "types.hxx"
class SvNumberFormatter;
class ScDocument;
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index ccb989f438f4..47231b3ca2ed 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -34,14 +34,6 @@ class ScInterpreter;
class SvNumberFormatter;
class ScMatrixImpl;
-typedef sal_uInt8 ScMatValType;
-const ScMatValType SC_MATVAL_VALUE = 0x00;
-const ScMatValType SC_MATVAL_BOOLEAN = 0x01;
-const ScMatValType SC_MATVAL_STRING = 0x02;
-const ScMatValType SC_MATVAL_EMPTY = SC_MATVAL_STRING | 0x04; // STRING plus flag
-const ScMatValType SC_MATVAL_EMPTYPATH = SC_MATVAL_EMPTY | 0x08; // EMPTY plus flag
-const ScMatValType SC_MATVAL_NONVALUE = SC_MATVAL_EMPTYPATH; // mask of all non-value bits
-
/**
* Try NOT to use this struct. This struct should go away in a hopefully
* not so distant futture.
diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx
index 109980fce92a..116022a6a9a9 100644
--- a/sc/inc/token.hxx
+++ b/sc/inc/token.hxx
@@ -26,7 +26,6 @@
#include "formula/opcode.hxx"
#include "refdata.hxx"
-#include "scmatrix.hxx"
#include <tools/mempool.hxx>
#include "scdllapi.h"
#include "formula/IFunctionDescription.hxx"
@@ -163,10 +162,9 @@ class ScMatrixToken : public ScToken
private:
ScMatrixRef pMatrix;
public:
- ScMatrixToken( ScMatrixRef p ) :
- ScToken( formula::svMatrix ), pMatrix( p ) {}
- ScMatrixToken( const ScMatrixToken& r ) :
- ScToken( r ), pMatrix( r.pMatrix ) {}
+ ScMatrixToken( const ScMatrixRef& p );
+ ScMatrixToken( const ScMatrixToken& r );
+
virtual const ScMatrix* GetMatrix() const;
virtual ScMatrix* GetMatrix();
virtual bool operator==( const formula::FormulaToken& rToken ) const;
@@ -311,15 +309,11 @@ class SC_DLLPUBLIC ScMatrixCellResultToken : public ScToken
virtual ScMatrix* GetMatrix();
protected:
- ScConstMatrixRef xMatrix;
- formula::FormulaConstTokenRef xUpperLeft;
+ ScConstMatrixRef xMatrix;
+ formula::FormulaConstTokenRef xUpperLeft;
public:
- ScMatrixCellResultToken( const ScConstMatrixRef& pMat, formula::FormulaToken* pUL ) :
- ScToken( formula::svMatrixCell ),
- xMatrix( pMat), xUpperLeft( pUL) {}
- ScMatrixCellResultToken( const ScMatrixCellResultToken& r ) :
- ScToken( r ), xMatrix( r.xMatrix ),
- xUpperLeft( r.xUpperLeft ) {}
+ ScMatrixCellResultToken( const ScConstMatrixRef& pMat, formula::FormulaToken* pUL );
+ ScMatrixCellResultToken( const ScMatrixCellResultToken& r );
virtual double GetDouble() const;
virtual const String & GetString() const;
virtual const ScMatrix* GetMatrix() const;
@@ -332,11 +326,7 @@ public:
static_cast<formula::StackVar>(formula::svUnknown);
}
inline formula::FormulaConstTokenRef GetUpperLeftToken() const { return xUpperLeft; }
- void Assign( const ScMatrixCellResultToken & r )
- {
- xMatrix = r.xMatrix;
- xUpperLeft = r.xUpperLeft;
- }
+ void Assign( const ScMatrixCellResultToken & r );
};
@@ -348,22 +338,10 @@ private:
SCROW nRows;
SCCOL nCols;
public:
- ScMatrixFormulaCellToken( SCCOL nC, SCROW nR, const ScConstMatrixRef& pMat, formula::FormulaToken* pUL ) :
- ScMatrixCellResultToken(pMat, pUL),
- nRows(nR), nCols(nC) {}
-
- ScMatrixFormulaCellToken( SCCOL nC, SCROW nR ) :
- ScMatrixCellResultToken( NULL, NULL ),
- nRows( nR ), nCols( nC ) {}
- ScMatrixFormulaCellToken( const ScMatrixFormulaCellToken& r ) :
- ScMatrixCellResultToken( r ),
- nRows( r.nRows ), nCols( r.nCols )
- {
- // xUpperLeft is modifiable through
- // SetUpperLeftDouble(), so clone it.
- if (xUpperLeft)
- xUpperLeft = xUpperLeft->Clone();
- }
+ ScMatrixFormulaCellToken( SCCOL nC, SCROW nR, const ScConstMatrixRef& pMat, formula::FormulaToken* pUL );
+ ScMatrixFormulaCellToken( SCCOL nC, SCROW nR );
+ ScMatrixFormulaCellToken( const ScMatrixFormulaCellToken& r );
+
virtual bool operator==( const formula::FormulaToken& rToken ) const;
virtual FormulaToken* Clone() const { return new ScMatrixFormulaCellToken(*this); }
void SetMatColsRows( SCCOL nC, SCROW nR )
@@ -399,13 +377,9 @@ public:
nothing if xUpperLeft is of different type! */
void SetUpperLeftDouble( double f);
- /** Reset matrix and upper left, keep matrix
- formula dimension. */
- void ResetResult()
- {
- xMatrix = NULL;
- xUpperLeft = NULL;
- }
+ /** Reset matrix and upper left, keep matrix
+ formula dimension. */
+ void ResetResult();
};
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 32a266d91fc7..4582c968ec8e 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -21,7 +21,6 @@
#define SC_TOKENARRAY_HXX
#include "formula/token.hxx"
-#include "scmatrix.hxx"
#include <tools/solar.h>
#include "scdllapi.h"
#include "types.hxx"
diff --git a/sc/inc/types.hxx b/sc/inc/types.hxx
index 629ab720f728..487afcd09676 100644
--- a/sc/inc/types.hxx
+++ b/sc/inc/types.hxx
@@ -20,6 +20,14 @@ typedef ::boost::intrusive_ptr<const ScMatrix> ScConstMatrixRef;
class ScToken;
typedef ::boost::intrusive_ptr<ScToken> ScTokenRef;
+typedef sal_uInt8 ScMatValType;
+const ScMatValType SC_MATVAL_VALUE = 0x00;
+const ScMatValType SC_MATVAL_BOOLEAN = 0x01;
+const ScMatValType SC_MATVAL_STRING = 0x02;
+const ScMatValType SC_MATVAL_EMPTY = SC_MATVAL_STRING | 0x04; // STRING plus flag
+const ScMatValType SC_MATVAL_EMPTYPATH = SC_MATVAL_EMPTY | 0x08; // EMPTY plus flag
+const ScMatValType SC_MATVAL_NONVALUE = SC_MATVAL_EMPTYPATH; // mask of all non-value bits
+
struct ScFormulaCellGroup;
typedef ::boost::intrusive_ptr<ScFormulaCellGroup> ScFormulaCellGroupRef;
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index ae20e44ed755..abe2806d3a53 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -42,6 +42,7 @@
#include "formulagroup.hxx"
#include "listenercontext.hxx"
#include "mtvcellfunc.hxx"
+#include "scmatrix.hxx"
#include <math.h>
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 60696df7e344..02cb39bb3bc4 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -37,6 +37,7 @@
#include "globstr.hrc"
#include "editutil.hxx"
#include "cellvalue.hxx"
+#include "scmatrix.hxx"
#include "tools/fract.hxx"
#include "editeng/editobj.hxx"
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index f59c119f5cc5..9211db8ac420 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -43,6 +43,7 @@
#include "attrib.hxx"
#include "formulacell.hxx"
#include "tokenarray.hxx"
+#include "scmatrix.hxx"
using namespace formula;
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 02c895237bb0..9b1ea3d87fce 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -46,6 +46,7 @@
#include "conditio.hxx"
#include "globalnames.hxx"
#include "cellvalue.hxx"
+#include "scmatrix.hxx"
#include <vector>
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index f910083a46ba..175c3dbd822b 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -17,7 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "scitems.hxx"
+#include "validat.hxx"
+
#include <sfx2/app.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/objsh.hxx>
@@ -31,7 +32,7 @@
#include <vcl/msgbox.hxx>
#include <rtl/math.hxx>
-#include "validat.hxx"
+#include "scitems.hxx"
#include "document.hxx"
#include "formulacell.hxx"
#include "patattr.hxx"
@@ -43,6 +44,7 @@
#include "dociter.hxx"
#include "editutil.hxx"
#include "tokenarray.hxx"
+#include "scmatrix.hxx"
#include <math.h>
#include <memory>
diff --git a/sc/source/core/inc/ddelink.hxx b/sc/source/core/inc/ddelink.hxx
index 967daae20b80..f6ceba393b7f 100644
--- a/sc/source/core/inc/ddelink.hxx
+++ b/sc/source/core/inc/ddelink.hxx
@@ -23,7 +23,7 @@
#include "address.hxx"
#include <sfx2/lnkbase.hxx>
#include <svl/broadcast.hxx>
-#include "scmatrix.hxx"
+#include "types.hxx"
class ScDocument;
class ScMultipleReadHeader;
@@ -67,11 +67,11 @@ public:
// for interpreter:
- const ScMatrix* GetResult() const { return pResult.get(); }
- void SetResult( ScMatrixRef pRes ) { pResult = pRes; }
+ const ScMatrix* GetResult() const;
+ void SetResult( const ScMatrixRef& pRes );
// XML and Excel import after NewData()
- ScMatrixRef GetModifiableResult() { return pResult; }
+ ScMatrixRef GetModifiableResult();
const String& GetAppl() const { return aAppl; }
const String& GetTopic() const { return aTopic; }
diff --git a/sc/source/core/inc/doubleref.hxx b/sc/source/core/inc/doubleref.hxx
index 1782f443d3cb..5de9c978d3eb 100644
--- a/sc/source/core/inc/doubleref.hxx
+++ b/sc/source/core/inc/doubleref.hxx
@@ -21,7 +21,7 @@
#define SC_DOUBLEREF_HXX
#include "address.hxx"
-#include "scmatrix.hxx"
+#include "types.hxx"
class ScDocument;
struct ScDBQueryParamBase;
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 75947d6ddcaa..37923838df4b 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -26,7 +26,7 @@
#include "formula/errorcodes.hxx"
#include "formula/tokenarray.hxx"
#include "scdll.hxx"
-#include "scmatrix.hxx"
+#include "types.hxx"
#include "externalrefmgr.hxx"
#include "calcconfig.hxx"
#include "token.hxx"
diff --git a/sc/source/core/inc/jumpmatrix.hxx b/sc/source/core/inc/jumpmatrix.hxx
index ccd0b669fce5..30391f94b016 100644
--- a/sc/source/core/inc/jumpmatrix.hxx
+++ b/sc/source/core/inc/jumpmatrix.hxx
@@ -24,7 +24,8 @@
#include "formula/errorcodes.hxx"
#include <tools/solar.h>
#include <vector>
-#include "scmatrix.hxx"
+#include "types.hxx"
+#include "address.hxx"
typedef ::std::vector< formula::FormulaToken*> ScTokenVec;
@@ -55,159 +56,35 @@ struct ScJumpMatrixEntry
class ScJumpMatrix
{
- ScJumpMatrixEntry* pJump; // the jumps
- ScMatrixRef pMat; // the results
- ScTokenVec* pParams; // parameter stack
- SCSIZE nCols;
- SCSIZE nRows;
- SCSIZE nCurCol;
- SCSIZE nCurRow;
- SCSIZE nResMatCols;
- SCSIZE nResMatRows;
- bool bStarted;
+ ScJumpMatrixEntry* pJump; // the jumps
+ ScMatrixRef pMat; // the results
+ ScTokenVec* pParams; // parameter stack
+ SCSIZE nCols;
+ SCSIZE nRows;
+ SCSIZE nCurCol;
+ SCSIZE nCurRow;
+ SCSIZE nResMatCols;
+ SCSIZE nResMatRows;
+ bool bStarted;
- // not implemented, prevent usage
- ScJumpMatrix( const ScJumpMatrix& );
- ScJumpMatrix& operator=( const ScJumpMatrix& );
+ // not implemented, prevent usage
+ ScJumpMatrix( const ScJumpMatrix& );
+ ScJumpMatrix& operator=( const ScJumpMatrix& );
public:
- ScJumpMatrix( SCSIZE nColsP, SCSIZE nRowsP )
- : pJump( new ScJumpMatrixEntry[ nColsP * nRowsP ] )
- , pMat( new ScMatrix( nColsP, nRowsP) )
- , pParams( NULL )
- , nCols( nColsP )
- , nRows( nRowsP )
- , nCurCol( 0 )
- , nCurRow( 0 )
- , nResMatCols( nColsP )
- , nResMatRows( nRowsP )
- , bStarted( false )
- {
- // Initialize result matrix in case of
- // a premature end of the interpreter
- // due to errors.
- pMat->FillDouble( CreateDoubleError(
- NOTAVAILABLE), 0, 0, nCols-1,
- nRows-1);
- /*! pJump not initialized */
- }
- ~ScJumpMatrix()
- {
- if ( pParams )
- {
- for ( ScTokenVec::iterator i =
- pParams->begin(); i !=
- pParams->end(); ++i )
- {
- (*i)->DecRef();
- }
- delete pParams;
- }
- delete [] pJump;
- }
- void GetDimensions( SCSIZE& rCols, SCSIZE& rRows ) const
- {
- rCols = nCols;
- rRows = nRows;
- }
- void SetJump( SCSIZE nCol, SCSIZE nRow, double fBool,
- short nStart, short nNext,
- short nStop = SHRT_MAX )
- {
- pJump[ (sal_uLong)nCol * nRows + nRow ].
- SetJump( fBool, nStart, nNext, nStop);
- }
- void GetJump( SCSIZE nCol, SCSIZE nRow, double& rBool,
- short& rStart, short& rNext,
- short& rStop ) const
- {
- if (nCols == 1 && nRows == 1)
- {
- nCol = 0;
- nRow = 0;
- }
- else if (nCols == 1 && nRow < nRows)
- nCol = 0;
- else if (nRows == 1 && nCol < nCols)
- nRow = 0;
- else if (nCols <= nCol || nRows <= nRow)
- {
- OSL_FAIL("ScJumpMatrix::GetJump: dimension error");
- nCol = 0;
- nRow = 0;
- }
- pJump[ (sal_uLong)nCol * nRows + nRow ].
- GetJump( rBool, rStart, rNext, rStop);
- }
- void SetAllJumps( double fBool,
- short nStart, short nNext,
- short nStop = SHRT_MAX )
- {
- sal_uLong n = (sal_uLong)nCols * nRows;
- for ( sal_uLong j=0; j<n; ++j )
- {
- pJump[ j ].SetJump( fBool, nStart,
- nNext, nStop);
- }
- }
- void SetJumpParameters( ScTokenVec* p )
- { pParams = p; }
- const ScTokenVec* GetJumpParameters() const { return pParams; }
- ScMatrix* GetResultMatrix() const { return pMat.get(); }
- void GetPos( SCSIZE& rCol, SCSIZE& rRow ) const
- {
- rCol = nCurCol;
- rRow = nCurRow;
- }
- bool Next( SCSIZE& rCol, SCSIZE& rRow )
- {
- if ( !bStarted )
- {
- bStarted = true;
- nCurCol = nCurRow = 0;
- }
- else
- {
- if ( ++nCurRow >= nResMatRows )
- {
- nCurRow = 0;
- ++nCurCol;
- }
- }
- GetPos( rCol, rRow );
- return nCurCol < nResMatCols;
- }
- void GetResMatDimensions( SCSIZE& rCols, SCSIZE& rRows )
- {
- rCols = nResMatCols;
- rRows = nResMatRows;
- }
- void SetNewResMat( SCSIZE nNewCols, SCSIZE nNewRows )
- {
- if ( nNewCols > nResMatCols || nNewRows > nResMatRows )
- {
- pMat = pMat->CloneAndExtend(nNewCols, nNewRows);
- if ( nResMatCols < nNewCols )
- {
- pMat->FillDouble( CreateDoubleError(
- NOTAVAILABLE), nResMatCols, 0, nNewCols-1,
- nResMatRows-1);
- }
- if ( nResMatRows < nNewRows )
- {
- pMat->FillDouble( CreateDoubleError(
- NOTAVAILABLE), 0, nResMatRows, nNewCols-1,
- nNewRows-1);
- }
- if ( nRows == 1 && nCurCol != 0 )
- {
- nCurCol = 0;
- nCurRow = nResMatRows - 1;
- }
- nResMatCols = nNewCols;
- nResMatRows = nNewRows;
- }
- }
+ ScJumpMatrix( SCSIZE nColsP, SCSIZE nRowsP );
+ ~ScJumpMatrix();
+ void GetDimensions( SCSIZE& rCols, SCSIZE& rRows ) const;
+ void SetJump( SCSIZE nCol, SCSIZE nRow, double fBool, short nStart, short nNext, short nStop = SHRT_MAX );
+ void GetJump( SCSIZE nCol, SCSIZE nRow, double& rBool, short& rStart, short& rNext, short& rStop ) const;
+ void SetAllJumps( double fBool, short nStart, short nNext, short nStop = SHRT_MAX );
+ void SetJumpParameters( ScTokenVec* p );
+ const ScTokenVec* GetJumpParameters() const;
+ ScMatrix* GetResultMatrix() const;
+ void GetPos( SCSIZE& rCol, SCSIZE& rRow ) const;
+ bool Next( SCSIZE& rCol, SCSIZE& rRow );
+ void GetResMatDimensions( SCSIZE& rCols, SCSIZE& rRows );
+ void SetNewResMat( SCSIZE nNewCols, SCSIZE nNewRows );
};
#endif // SC_JUMPMATRIX_HXX
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index d5c5401317ad..20ab937d556d 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -1700,9 +1700,9 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes )
}
}
-
-
-//------------------------------------------------------------------------
-
+ScMatrixRef ScUnoAddInCall::GetMatrix() const
+{
+ return xMatrix;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 3d6806cfbfcf..9b4c4d1df290 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -63,6 +63,7 @@
#include "tokenuno.hxx"
#include "formulaparserpool.hxx"
#include "tokenarray.hxx"
+#include "scmatrix.hxx"
using namespace formula;
using namespace ::com::sun::star;
diff --git a/sc/source/core/tool/ddelink.cxx b/sc/source/core/tool/ddelink.cxx
index bd6eb92347a4..76e7616ffcef 100644
--- a/sc/source/core/tool/ddelink.cxx
+++ b/sc/source/core/tool/ddelink.cxx
@@ -239,6 +239,21 @@ void ScDdeLink::ListenersGone()
bIsInUpdate = bWas;
}
+const ScMatrix* ScDdeLink::GetResult() const
+{
+ return pResult.get();
+}
+
+void ScDdeLink::SetResult( const ScMatrixRef& pRes )
+{
+ pResult = pRes;
+}
+
+ScMatrixRef ScDdeLink::GetModifiableResult()
+{
+ return pResult;
+}
+
void ScDdeLink::TryUpdate()
{
if (bIsInUpdate)
diff --git a/sc/source/core/tool/doubleref.cxx b/sc/source/core/tool/doubleref.cxx
index f7d873cb61a8..5b0920ae8767 100644
--- a/sc/source/core/tool/doubleref.cxx
+++ b/sc/source/core/tool/doubleref.cxx
@@ -24,6 +24,7 @@
#include "queryparam.hxx"
#include "queryentry.hxx"
#include "globstr.hrc"
+#include "scmatrix.hxx"
#include <memory>
#include <vector>
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index f9d251bbada3..4a04f79a5401 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -14,6 +14,8 @@
#include "tokenarray.hxx"
#include "compiler.hxx"
#include "interpre.hxx"
+#include "scmatrix.hxx"
+
#include "formula/vectortoken.hxx"
namespace sc {
diff --git a/sc/source/core/tool/formularesult.cxx b/sc/source/core/tool/formularesult.cxx
index a106e5f9db76..a20963bbde80 100644
--- a/sc/source/core/tool/formularesult.cxx
+++ b/sc/source/core/tool/formularesult.cxx
@@ -11,6 +11,7 @@
*/
#include "formularesult.hxx"
+#include "scmatrix.hxx"
ScFormulaResult::ScFormulaResult() :
mpToken(NULL), mnError(0), mbToken(true),
diff --git a/sc/source/core/tool/jumpmatrix.cxx b/sc/source/core/tool/jumpmatrix.cxx
new file mode 100644
index 000000000000..6a8b4a72fb2d
--- /dev/null
+++ b/sc/source/core/tool/jumpmatrix.cxx
@@ -0,0 +1,173 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "jumpmatrix.hxx"
+#include "scmatrix.hxx"
+
+ScJumpMatrix::ScJumpMatrix(SCSIZE nColsP, SCSIZE nRowsP)
+ : pJump(new ScJumpMatrixEntry[nColsP * nRowsP])
+ , pMat(new ScMatrix(nColsP, nRowsP))
+ , pParams(NULL)
+ , nCols(nColsP)
+ , nRows(nRowsP)
+ , nCurCol(0)
+ , nCurRow(0)
+ , nResMatCols(nColsP)
+ , nResMatRows(nRowsP)
+ , bStarted(false)
+{
+ // Initialize result matrix in case of
+ // a premature end of the interpreter
+ // due to errors.
+ pMat->FillDouble(CreateDoubleError(NOTAVAILABLE), 0, 0, nCols - 1, nRows - 1);
+ /*! pJump not initialized */
+}
+
+ScJumpMatrix::~ScJumpMatrix()
+{
+ if (pParams)
+ {
+ for (ScTokenVec::iterator i =
+ pParams->begin(); i !=
+ pParams->end(); ++i)
+ {
+ (*i)->DecRef();
+ }
+ delete pParams;
+ }
+ delete[] pJump;
+}
+
+void ScJumpMatrix::GetDimensions(SCSIZE& rCols, SCSIZE& rRows) const
+{
+ rCols = nCols;
+ rRows = nRows;
+}
+
+void ScJumpMatrix::SetJump(SCSIZE nCol, SCSIZE nRow, double fBool,
+ short nStart, short nNext, short nStop)
+{
+ pJump[(sal_uLong)nCol * nRows + nRow].SetJump(fBool, nStart, nNext, nStop);
+}
+
+void ScJumpMatrix::GetJump(
+ SCSIZE nCol, SCSIZE nRow, double& rBool, short& rStart, short& rNext, short& rStop) const
+{
+ if (nCols == 1 && nRows == 1)
+ {
+ nCol = 0;
+ nRow = 0;
+ }
+ else if (nCols == 1 && nRow < nRows) nCol = 0;
+ else if (nRows == 1 && nCol < nCols) nRow = 0;
+ else if (nCols <= nCol || nRows <= nRow)
+ {
+ OSL_FAIL("ScJumpMatrix::GetJump: dimension error");
+ nCol = 0;
+ nRow = 0;
+ }
+ pJump[(sal_uLong)nCol * nRows + nRow].
+ GetJump(rBool, rStart, rNext, rStop);
+}
+
+void ScJumpMatrix::SetAllJumps(double fBool, short nStart, short nNext, short nStop)
+{
+ sal_uLong n = (sal_uLong)nCols * nRows;
+ for (sal_uLong j = 0; j < n; ++j)
+ {
+ pJump[j].SetJump(fBool, nStart,
+ nNext, nStop);
+ }
+}
+
+void ScJumpMatrix::SetJumpParameters(ScTokenVec* p)
+{
+ pParams = p;
+}
+
+const ScTokenVec* ScJumpMatrix::GetJumpParameters() const
+{
+ return pParams;
+}
+
+ScMatrix* ScJumpMatrix::GetResultMatrix() const
+{
+ return pMat.get();
+}
+
+void ScJumpMatrix::GetPos(SCSIZE& rCol, SCSIZE& rRow) const
+{
+ rCol = nCurCol;
+ rRow = nCurRow;
+}
+
+bool ScJumpMatrix::Next(SCSIZE& rCol, SCSIZE& rRow)
+{
+ if (!bStarted)
+ {
+ bStarted = true;
+ nCurCol = nCurRow = 0;
+ }
+ else
+ {
+ if (++nCurRow >= nResMatRows)
+ {
+ nCurRow = 0;
+ ++nCurCol;
+ }
+ }
+ GetPos(rCol, rRow);
+ return nCurCol < nResMatCols;
+}
+
+void ScJumpMatrix::GetResMatDimensions(SCSIZE& rCols, SCSIZE& rRows)
+{
+ rCols = nResMatCols;
+ rRows = nResMatRows;
+}
+
+void ScJumpMatrix::SetNewResMat(SCSIZE nNewCols, SCSIZE nNewRows)
+{
+ if (nNewCols > nResMatCols || nNewRows > nResMatRows)
+ {
+ pMat = pMat->CloneAndExtend(nNewCols, nNewRows);
+ if (nResMatCols < nNewCols)
+ {
+ pMat->FillDouble(CreateDoubleError(
+ NOTAVAILABLE), nResMatCols, 0, nNewCols - 1,
+ nResMatRows - 1);
+ }
+ if (nResMatRows < nNewRows)
+ {
+ pMat->FillDouble(CreateDoubleError(
+ NOTAVAILABLE), 0, nResMatRows, nNewCols - 1,
+ nNewRows - 1);
+ }
+ if (nRows == 1 && nCurCol != 0)
+ {
+ nCurCol = 0;
+ nCurRow = nResMatRows - 1;
+ }
+ nResMatCols = nNewCols;
+ nResMatRows = nNewRows;
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index 826ea3e3981e..b202432b6156 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -19,6 +19,7 @@
#include "queryparam.hxx"
#include "queryentry.hxx"
+#include "scmatrix.hxx"
namespace {
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index b833fecb889c..4d81099692c7 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -34,6 +34,8 @@
#include "refupdat.hxx"
#include "document.hxx"
+#include "formula/errorcodes.hxx"
+
using namespace formula;
using ::std::pair;
using ::std::unary_function;
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 3dff6a930804..55c051df9644 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -37,6 +37,7 @@
#include "rangeseq.hxx"
#include "externalrefmgr.hxx"
#include "document.hxx"
+#include "scmatrix.hxx"
using ::std::vector;
@@ -795,6 +796,11 @@ bool ScRefListToken::operator==( const FormulaToken& r ) const
return FormulaToken::operator==( r ) && &aRefList == static_cast<const ScToken&>(r).GetRefList();
}
+ScMatrixToken::ScMatrixToken( const ScMatrixRef& p ) :
+ ScToken(formula::svMatrix), pMatrix(p) {}
+
+ScMatrixToken::ScMatrixToken( const ScMatrixToken& r ) :
+ ScToken(r), pMatrix(r.pMatrix) {}
const ScMatrix* ScMatrixToken::GetMatrix() const { return pMatrix.get(); }
ScMatrix* ScMatrixToken::GetMatrix() { return pMatrix.get(); }
@@ -1031,6 +1037,11 @@ bool ScEmptyCellToken::operator==( const FormulaToken& r ) const
bDisplayedAsString == static_cast< const ScEmptyCellToken & >(r).IsDisplayedAsString();
}
+ScMatrixCellResultToken::ScMatrixCellResultToken( const ScConstMatrixRef& pMat, formula::FormulaToken* pUL ) :
+ ScToken(formula::svMatrixCell), xMatrix(pMat), xUpperLeft(pUL) {}
+
+ScMatrixCellResultToken::ScMatrixCellResultToken( const ScMatrixCellResultToken& r ) :
+ ScToken(r), xMatrix(r.xMatrix), xUpperLeft(r.xUpperLeft) {}
double ScMatrixCellResultToken::GetDouble() const { return xUpperLeft->GetDouble(); }
const String & ScMatrixCellResultToken::GetString() const { return xUpperLeft->GetString(); }
@@ -1041,6 +1052,7 @@ ScMatrix* ScMatrixCellResultToken::GetMatrix()
{
return const_cast<ScMatrix*>(xMatrix.get());
}
+
bool ScMatrixCellResultToken::operator==( const FormulaToken& r ) const
{
return FormulaToken::operator==( r ) &&
@@ -1048,6 +1060,27 @@ bool ScMatrixCellResultToken::operator==( const FormulaToken& r ) const
xMatrix == static_cast<const ScMatrixCellResultToken &>(r).xMatrix;
}
+void ScMatrixCellResultToken::Assign( const ScMatrixCellResultToken & r )
+{
+ xMatrix = r.xMatrix;
+ xUpperLeft = r.xUpperLeft;
+}
+
+ScMatrixFormulaCellToken::ScMatrixFormulaCellToken(
+ SCCOL nC, SCROW nR, const ScConstMatrixRef& pMat, formula::FormulaToken* pUL ) :
+ ScMatrixCellResultToken(pMat, pUL), nRows(nR), nCols(nC) {}
+
+ScMatrixFormulaCellToken::ScMatrixFormulaCellToken( SCCOL nC, SCROW nR ) :
+ ScMatrixCellResultToken(NULL, NULL), nRows(nR), nCols(nC) {}
+
+ScMatrixFormulaCellToken::ScMatrixFormulaCellToken( const ScMatrixFormulaCellToken& r ) :
+ ScMatrixCellResultToken(r), nRows(r.nRows), nCols(r.nCols)
+{
+ // xUpperLeft is modifiable through
+ // SetUpperLeftDouble(), so clone it.
+ if (xUpperLeft)
+ xUpperLeft = xUpperLeft->Clone();
+}
bool ScMatrixFormulaCellToken::operator==( const FormulaToken& r ) const
{
@@ -1077,6 +1110,7 @@ void ScMatrixFormulaCellToken::Assign( const formula::FormulaToken& r )
}
}
}
+
void ScMatrixFormulaCellToken::SetUpperLeftDouble( double f )
{
switch (GetUpperLeftType())
@@ -1098,6 +1132,12 @@ void ScMatrixFormulaCellToken::SetUpperLeftDouble( double f )
}
}
+void ScMatrixFormulaCellToken::ResetResult()
+{
+ xMatrix = NULL;
+ xUpperLeft = NULL;
+}
+
double ScHybridCellToken::GetDouble() const { return mfDouble; }
const String& ScHybridCellToken::GetString() const { return maString; }
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx
index 10b95f77da07..269c66f0e87b 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -24,6 +24,8 @@
#include "document.hxx"
#include "rangenam.hxx"
#include "global.hxx"
+#include "scmatrix.hxx"
+
#include "formula/errorcodes.hxx"
#include "imp_op.hxx"
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index 5265bd1fd4cd..7065d10db88d 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -27,6 +27,7 @@
#include "rangelst.hxx"
#include "token.hxx"
#include "tokenarray.hxx"
+#include "scmatrix.hxx"
#include "xeformula.hxx"
#include "xehelper.hxx"
#include "xelink.hxx"
diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx
index a13b7fe3c51b..2a2e2dc46fd6 100644
--- a/sc/source/filter/excel/xehelper.cxx
+++ b/sc/source/filter/excel/xehelper.cxx
@@ -40,6 +40,7 @@
#include "formulacell.hxx"
#include "editutil.hxx"
#include "patattr.hxx"
+#include "scmatrix.hxx"
#include "xestyle.hxx"
#include "fprogressbar.hxx"
#include "xltracer.hxx"
diff --git a/sc/source/filter/excel/xihelper.cxx b/sc/source/filter/excel/xihelper.cxx
index c002ae9b5197..824f4c4d50a0 100644
--- a/sc/source/filter/excel/xihelper.cxx
+++ b/sc/source/filter/excel/xihelper.cxx
@@ -33,6 +33,7 @@
#include "xistyle.hxx"
#include "excform.hxx"
#include "stringutil.hxx"
+#include "scmatrix.hxx"
// Excel->Calc cell address/range conversion ==================================
@@ -798,7 +799,7 @@ XclImpCachedValue::XclImpCachedValue( XclImpStream& rStrm ) :
rStrm >> mfValue;
break;
case EXC_CACHEDVAL_STRING:
- mxStr.reset( new String( rStrm.ReadUniString() ) );
+ maStr = rStrm.ReadUniString();
break;
case EXC_CACHEDVAL_BOOL:
case EXC_CACHEDVAL_ERROR:
@@ -822,6 +823,11 @@ XclImpCachedValue::~XclImpCachedValue()
{
}
+const OUString& XclImpCachedValue::GetString() const
+{
+ return maStr;
+}
+
sal_uInt16 XclImpCachedValue::GetScError() const
{
return (mnType == EXC_CACHEDVAL_ERROR) ? XclTools::GetScErrorCode( mnBoolErr ) : 0;
diff --git a/sc/source/filter/excel/xilink.cxx b/sc/source/filter/excel/xilink.cxx
index a89d36625b5a..7ccc4ae80f3e 100644
--- a/sc/source/filter/excel/xilink.cxx
+++ b/sc/source/filter/excel/xilink.cxx
@@ -28,6 +28,7 @@
#include "excform.hxx"
#include "tokenarray.hxx"
#include "externalrefmgr.hxx"
+#include "scmatrix.hxx"
#include <vector>
#include <boost/ptr_container/ptr_vector.hpp>
@@ -599,7 +600,7 @@ void XclImpSupbookTab::LoadCachedValues(ScExternalRefCache::TableTypeRef pCacheT
break;
case EXC_CACHEDVAL_STRING:
{
- const String& rStr = pCrn->GetString();
+ const OUString& rStr = pCrn->GetString();
ScExternalRefCache::TokenRef pToken(new formula::FormulaStringToken(rStr));
pCacheTable->setCell(rAddr.mnCol, rAddr.mnRow, pToken, 0, false);
}
diff --git a/sc/source/filter/inc/xihelper.hxx b/sc/source/filter/inc/xihelper.hxx
index 52f7d255a26e..ed6426d1ac90 100644
--- a/sc/source/filter/inc/xihelper.hxx
+++ b/sc/source/filter/inc/xihelper.hxx
@@ -24,7 +24,7 @@
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
-#include "scmatrix.hxx"
+#include "types.hxx"
#include "xladdress.hxx"
#include "xiroot.hxx"
#include "xistring.hxx"
@@ -301,7 +301,7 @@ public:
/** Returns the type of the cached value (EXC_CACHEDVAL_*). */
inline sal_uInt8 GetType() const { return mnType; }
/** Returns the cached string value, if this value is a string, else an empty string. */
- inline const String& GetString() const { return mxStr.get() ? *mxStr : EMPTY_STRING; }
+ const OUString& GetString() const;
/** Returns the cached number, if this value has number type, else 0.0. */
inline double GetValue() const { return mfValue; }
/** Returns the cached Boolean value, if this value has Boolean type, else false. */
@@ -312,10 +312,9 @@ public:
sal_uInt16 GetScError() const;
protected:
- typedef ::std::auto_ptr< String > StringPtr;
typedef ::std::auto_ptr< const ScTokenArray > ScTokenArrayPtr;
- StringPtr mxStr; /// Cached value is a string.
+ OUString maStr; /// Cached value is a string.
double mfValue; /// Cached value is a double.
ScTokenArrayPtr mxTokArr; /// Cached value is a formula or error code or Boolean.
sal_uInt8 mnBoolErr; /// Boolean value or Excel error code.
diff --git a/sc/source/filter/inc/xilink.hxx b/sc/source/filter/inc/xilink.hxx
index 09b009869600..985e6ee3e819 100644
--- a/sc/source/filter/inc/xilink.hxx
+++ b/sc/source/filter/inc/xilink.hxx
@@ -23,7 +23,7 @@
#include <map>
#include "xllink.hxx"
#include "xiroot.hxx"
-#include "scmatrix.hxx"
+#include "types.hxx"
/* ============================================================================
Classes for import of different kinds of internal/external references.
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 4ab9d9820492..445766e04343 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -50,6 +50,7 @@
#include "editattributemap.hxx"
#include "stringutil.hxx"
#include "tokenarray.hxx"
+#include "scmatrix.hxx"
#include <xmloff/xmltkmap.hxx>
#include <xmloff/xmltoken.hxx>
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index b6f847b15237..87a9b16c84fa 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -51,6 +51,7 @@
#include "unotools/localfilehelper.hxx"
#include "vcl/msgbox.hxx"
#include "stringutil.hxx"
+#include "scmatrix.hxx"
#include <memory>
#include <algorithm>
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 81e4953c2bcb..6ec562d2a548 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -37,6 +37,7 @@
#include "docsh.hxx"
#include "cellvalue.hxx"
#include "tokenarray.hxx"
+#include "scmatrix.hxx"
#include "formula/opcode.hxx"
diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx
index 897d4aa18b60..0531ff96dd06 100644
--- a/sc/source/ui/unoobj/linkuno.cxx
+++ b/sc/source/ui/unoobj/linkuno.cxx
@@ -32,6 +32,7 @@
#include "unonames.hxx"
#include "rangeseq.hxx"
#include "token.hxx"
+#include "scmatrix.hxx"
#include <vector>
#include <climits>