diff options
author | Jan Holesovsky <kendy@suse.cz> | 2011-05-27 20:46:20 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2011-05-27 20:46:20 +0200 |
commit | 9df8682ced86258da76a730ecf354c788fffc1f2 (patch) | |
tree | 590af31bfe3d5cfd0d4de4812a0bd696b9415d2b /formula | |
parent | fdo#37001 - updated license information (diff) | |
parent | vbahelper builds after the m106 merge. (diff) | |
download | core-9df8682ced86258da76a730ecf354c788fffc1f2.tar.gz core-9df8682ced86258da76a730ecf354c788fffc1f2.zip |
Merge remote-tracking branch 'origin/integration/dev300_m106'
Conflicts:
basic/source/classes/sbunoobj.cxx
basic/source/inc/runtime.hxx
basic/source/runtime/step1.cxx
desktop/source/deployment/dp_services.cxx
drawinglayer/prj/d.lst
drawinglayer/source/primitive2d/makefile.mk
sfx2/source/appl/appinit.cxx
sfx2/source/appl/appquit.cxx
sfx2/source/inc/appdata.hxx
sfx2/source/view/viewfrm.cxx
svx/source/fmcomp/gridctrl.cxx
vbahelper/source/vbahelper/vbahelper.cxx
Diffstat (limited to 'formula')
-rwxr-xr-x | formula/inc/formula/compiler.hrc | 126 | ||||
-rw-r--r-- | formula/inc/formula/opcode.hxx | 4 | ||||
-rw-r--r-- | formula/inc/formula/token.hxx | 20 | ||||
-rw-r--r-- | formula/inc/formula/tokenarray.hxx | 4 | ||||
-rw-r--r-- | formula/source/core/api/token.cxx | 67 | ||||
-rw-r--r-- | formula/source/core/resource/core_resource.src | 24 |
6 files changed, 169 insertions, 76 deletions
diff --git a/formula/inc/formula/compiler.hrc b/formula/inc/formula/compiler.hrc index e4dc05aca4e9..5c58d9d3e068 100755 --- a/formula/inc/formula/compiler.hrc +++ b/formula/inc/formula/compiler.hrc @@ -130,67 +130,71 @@ #define SC_OPCODE_ARC_COS_HYP 95 #define SC_OPCODE_ARC_TAN_HYP 96 #define SC_OPCODE_ARC_COT_HYP 97 -#define SC_OPCODE_EXP 98 -#define SC_OPCODE_LN 99 -#define SC_OPCODE_SQRT 100 -#define SC_OPCODE_FACT 101 -#define SC_OPCODE_GET_YEAR 102 /* date and time */ -#define SC_OPCODE_GET_MONTH 103 -#define SC_OPCODE_GET_DAY 104 -#define SC_OPCODE_GET_HOUR 105 -#define SC_OPCODE_GET_MIN 106 -#define SC_OPCODE_GET_SEC 107 -#define SC_OPCODE_PLUS_MINUS 108 /* miscellaneous */ -#define SC_OPCODE_ABS 109 -#define SC_OPCODE_INT 110 -#define SC_OPCODE_PHI 111 -#define SC_OPCODE_GAUSS 112 -#define SC_OPCODE_IS_EMPTY 113 /* obtain type */ -#define SC_OPCODE_IS_STRING 114 -#define SC_OPCODE_IS_NON_STRING 115 -#define SC_OPCODE_IS_LOGICAL 116 -#define SC_OPCODE_TYPE 117 -#define SC_OPCODE_IS_REF 118 -#define SC_OPCODE_IS_VALUE 119 -#define SC_OPCODE_IS_FORMULA 120 -#define SC_OPCODE_IS_NV 121 -#define SC_OPCODE_IS_ERR 122 -#define SC_OPCODE_IS_ERROR 123 -#define SC_OPCODE_IS_EVEN 124 -#define SC_OPCODE_IS_ODD 125 -#define SC_OPCODE_N 126 -#define SC_OPCODE_GET_DATE_VALUE 127 /* string functions */ -#define SC_OPCODE_GET_TIME_VALUE 128 -#define SC_OPCODE_CODE 129 -#define SC_OPCODE_TRIM 130 -#define SC_OPCODE_UPPER 131 -#define SC_OPCODE_PROPPER 132 -#define SC_OPCODE_LOWER 133 -#define SC_OPCODE_LEN 134 -#define SC_OPCODE_T 135 /* miscellaneous, part 21 */ -#define SC_OPCODE_VALUE 136 -#define SC_OPCODE_CLEAN 137 -#define SC_OPCODE_CHAR 138 -#define SC_OPCODE_LOG10 139 -#define SC_OPCODE_EVEN 140 -#define SC_OPCODE_ODD 141 -#define SC_OPCODE_STD_NORM_DIST 142 -#define SC_OPCODE_FISHER 143 -#define SC_OPCODE_FISHER_INV 144 -#define SC_OPCODE_S_NORM_INV 145 -#define SC_OPCODE_GAMMA_LN 146 -#define SC_OPCODE_ERROR_TYPE 147 -#define SC_OPCODE_ERR_CELL 148 -#define SC_OPCODE_FORMULA 149 -#define SC_OPCODE_ARABIC 150 -#define SC_OPCODE_INFO 151 -#define SC_OPCODE_BAHTTEXT 152 -#define SC_OPCODE_JIS 153 -#define SC_OPCODE_ASC 154 -#define SC_OPCODE_UNICODE 155 -#define SC_OPCODE_UNICHAR 156 -#define SC_OPCODE_GAMMA 157 -#define SC_OPCODE_STOP_1_PAR 158 +#define SC_OPCODE_COSECANT 98 +#define SC_OPCODE_SECANT 99 +#define SC_OPCODE_COSECANT_HYP 100 +#define SC_OPCODE_SECANT_HYP 101 +#define SC_OPCODE_EXP 102 +#define SC_OPCODE_LN 103 +#define SC_OPCODE_SQRT 104 +#define SC_OPCODE_FACT 105 +#define SC_OPCODE_GET_YEAR 106 /* date and time */ +#define SC_OPCODE_GET_MONTH 107 +#define SC_OPCODE_GET_DAY 108 +#define SC_OPCODE_GET_HOUR 109 +#define SC_OPCODE_GET_MIN 110 +#define SC_OPCODE_GET_SEC 111 +#define SC_OPCODE_PLUS_MINUS 112 /* miscellaneous */ +#define SC_OPCODE_ABS 113 +#define SC_OPCODE_INT 114 +#define SC_OPCODE_PHI 115 +#define SC_OPCODE_GAUSS 116 +#define SC_OPCODE_IS_EMPTY 117 /* obtain type */ +#define SC_OPCODE_IS_STRING 118 +#define SC_OPCODE_IS_NON_STRING 119 +#define SC_OPCODE_IS_LOGICAL 120 +#define SC_OPCODE_TYPE 121 +#define SC_OPCODE_IS_REF 122 +#define SC_OPCODE_IS_VALUE 123 +#define SC_OPCODE_IS_FORMULA 124 +#define SC_OPCODE_IS_NV 125 +#define SC_OPCODE_IS_ERR 126 +#define SC_OPCODE_IS_ERROR 127 +#define SC_OPCODE_IS_EVEN 128 +#define SC_OPCODE_IS_ODD 129 +#define SC_OPCODE_N 130 +#define SC_OPCODE_GET_DATE_VALUE 131 /* string functions */ +#define SC_OPCODE_GET_TIME_VALUE 132 +#define SC_OPCODE_CODE 133 +#define SC_OPCODE_TRIM 134 +#define SC_OPCODE_UPPER 135 +#define SC_OPCODE_PROPPER 136 +#define SC_OPCODE_LOWER 137 +#define SC_OPCODE_LEN 138 +#define SC_OPCODE_T 139 /* miscellaneous, part 21 */ +#define SC_OPCODE_VALUE 140 +#define SC_OPCODE_CLEAN 141 +#define SC_OPCODE_CHAR 142 +#define SC_OPCODE_LOG10 143 +#define SC_OPCODE_EVEN 144 +#define SC_OPCODE_ODD 145 +#define SC_OPCODE_STD_NORM_DIST 146 +#define SC_OPCODE_FISHER 147 +#define SC_OPCODE_FISHER_INV 148 +#define SC_OPCODE_S_NORM_INV 149 +#define SC_OPCODE_GAMMA_LN 150 +#define SC_OPCODE_ERROR_TYPE 151 +#define SC_OPCODE_ERR_CELL 152 +#define SC_OPCODE_FORMULA 153 +#define SC_OPCODE_ARABIC 154 +#define SC_OPCODE_INFO 155 +#define SC_OPCODE_BAHTTEXT 156 +#define SC_OPCODE_JIS 157 +#define SC_OPCODE_ASC 158 +#define SC_OPCODE_UNICODE 159 +#define SC_OPCODE_UNICHAR 160 +#define SC_OPCODE_GAMMA 161 +#define SC_OPCODE_STOP_1_PAR 162 /*** Functions with more than one parameters ***/ #define SC_OPCODE_START_2_PAR 201 diff --git a/formula/inc/formula/opcode.hxx b/formula/inc/formula/opcode.hxx index 240f97401314..fc9a9b7cf525 100644 --- a/formula/inc/formula/opcode.hxx +++ b/formula/inc/formula/opcode.hxx @@ -122,6 +122,10 @@ enum OpCodeEnum ocArcCosHyp = SC_OPCODE_ARC_COS_HYP, ocArcTanHyp = SC_OPCODE_ARC_TAN_HYP, ocArcCotHyp = SC_OPCODE_ARC_COT_HYP, + ocCosecant = SC_OPCODE_COSECANT, + ocSecant = SC_OPCODE_SECANT, + ocCosecantHyp = SC_OPCODE_COSECANT_HYP, + ocSecantHyp = SC_OPCODE_SECANT_HYP, ocExp = SC_OPCODE_EXP, ocLn = SC_OPCODE_LN, ocSqrt = SC_OPCODE_SQRT, diff --git a/formula/inc/formula/token.hxx b/formula/inc/formula/token.hxx index b47147d833e8..bc6cfc2c2793 100644 --- a/formula/inc/formula/token.hxx +++ b/formula/inc/formula/token.hxx @@ -70,6 +70,7 @@ enum StackVarEnum svExternalSingleRef, svExternalDoubleRef, svExternalName, + svSubroutine, // A token with a subroutine token array. svError, // error token svMissing = 0x70, // 0 or "" svSep, // separator, ocSep, ocOpen, ocClose @@ -89,6 +90,8 @@ class FormulaToken; typedef ::boost::intrusive_ptr<FormulaToken> FormulaTokenRef; typedef ::boost::intrusive_ptr<const FormulaToken> FormulaConstTokenRef; +class FormulaTokenArray; + class FORMULA_DLLPUBLIC FormulaToken : public IFormulaToken { OpCode eOp; @@ -374,6 +377,23 @@ public: }; +class FORMULA_DLLPUBLIC FormulaSubroutineToken : public FormulaToken +{ +public: + /** Takes ownership of pArray and deletes it upon destruction! */ + FormulaSubroutineToken( const FormulaTokenArray* pArray ) : + FormulaToken( svSubroutine, ocCall ), mpArray( pArray) {} + FormulaSubroutineToken( const FormulaSubroutineToken& r ); + virtual ~FormulaSubroutineToken(); + virtual FormulaToken* Clone() const { return new FormulaSubroutineToken(*this); } + virtual bool operator==( const FormulaToken& rToken ) const; + const FormulaTokenArray* GetTokenArray() const; + +private: + const FormulaTokenArray* mpArray; +}; + + class FORMULA_DLLPUBLIC FormulaUnknownToken : public FormulaToken { public: diff --git a/formula/inc/formula/tokenarray.hxx b/formula/inc/formula/tokenarray.hxx index 626c958471ad..8ec6a56f9f0f 100644 --- a/formula/inc/formula/tokenarray.hxx +++ b/formula/inc/formula/tokenarray.hxx @@ -259,6 +259,7 @@ public: void Reset(); const FormulaToken* First(); const FormulaToken* Next(); + const FormulaToken* PeekNextOperator(); bool IsEndOfPath() const; /// if a jump or subroutine path is done bool HasStacked() const { return pCur->pNext != 0; } short GetPC() const { return pCur->nPC; } @@ -279,6 +280,9 @@ public: void Jump( short nStart, short nNext, short nStop = SHRT_MAX ); void Push( const FormulaTokenArray* ); void Pop(); + +private: + const FormulaToken* GetNonEndOfPathToken( short nIdx ) const; }; // ============================================================================= } // formula diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index 8b8148d035ac..de9258d4c8ea 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -1263,15 +1263,7 @@ const FormulaToken* FormulaTokenIterator::First() const FormulaToken* FormulaTokenIterator::Next() { - const FormulaToken* t = NULL; - ++pCur->nPC; - if( pCur->nPC < pCur->pArr->nRPN && pCur->nPC < pCur->nStop ) - { - t = pCur->pArr->pRPN[ pCur->nPC ]; - // such an OpCode ends an IF() or CHOOSE() path - if( t->GetOpCode() == ocSep || t->GetOpCode() == ocClose ) - t = NULL; - } + const FormulaToken* t = GetNonEndOfPathToken( ++pCur->nPC ); if( !t && pCur->pNext ) { Pop(); @@ -1280,6 +1272,25 @@ const FormulaToken* FormulaTokenIterator::Next() return t; } +const FormulaToken* FormulaTokenIterator::PeekNextOperator() +{ + const FormulaToken* t = NULL; + short nIdx = pCur->nPC; + while (!t && ((t = GetNonEndOfPathToken( ++nIdx)) != NULL)) + { + if (t->GetOpCode() == ocPush) + t = NULL; // ignore operands + } + if (!t && pCur->pNext) + { + ImpTokenIterator* pHere = pCur; + pCur = pCur->pNext; + t = PeekNextOperator(); + pCur = pHere; + } + return t; +} + //! The nPC counts after a Push() are -1 void FormulaTokenIterator::Jump( short nStart, short nNext, short nStop ) @@ -1293,17 +1304,22 @@ void FormulaTokenIterator::Jump( short nStart, short nNext, short nStop ) } } -bool FormulaTokenIterator::IsEndOfPath() const +const FormulaToken* FormulaTokenIterator::GetNonEndOfPathToken( short nIdx ) const { - sal_uInt16 nTest = pCur->nPC + 1; - if( nTest < pCur->pArr->nRPN && nTest < pCur->nStop ) + if (nIdx < pCur->pArr->nRPN && nIdx < pCur->nStop) { - const FormulaToken* t = pCur->pArr->pRPN[ nTest ]; + const FormulaToken* t = pCur->pArr->pRPN[ nIdx ]; // such an OpCode ends an IF() or CHOOSE() path - return t->GetOpCode() == ocSep || t->GetOpCode() == ocClose; + return (t->GetOpCode() == ocSep || t->GetOpCode() == ocClose) ? NULL : t; } - return true; + return NULL; } + +bool FormulaTokenIterator::IsEndOfPath() const +{ + return GetNonEndOfPathToken( pCur->nPC + 1) != NULL; +} + // ----------------------------------------------------------------------------- // ========================================================================== // real implementations of virtual functions @@ -1365,6 +1381,27 @@ bool FormulaMissingToken::operator==( const FormulaToken& r ) const } +FormulaSubroutineToken::FormulaSubroutineToken( const FormulaSubroutineToken& r ) : + FormulaToken( r ), + mpArray( r.mpArray->Clone()) +{ +} +FormulaSubroutineToken::~FormulaSubroutineToken() +{ + delete mpArray; +} +const FormulaTokenArray* FormulaSubroutineToken::GetTokenArray() const +{ + return mpArray; +} +bool FormulaSubroutineToken::operator==( const FormulaToken& r ) const +{ + // Arrays don't equal.. + return FormulaToken::operator==( r ) && + (mpArray == static_cast<const FormulaSubroutineToken&>(r).mpArray); +} + + bool FormulaUnknownToken::operator==( const FormulaToken& r ) const { return FormulaToken::operator==( r ); diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src index d2996e78fba7..b8a5f1250941 100644 --- a/formula/source/core/resource/core_resource.src +++ b/formula/source/core/resource/core_resource.src @@ -88,6 +88,10 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF String SC_OPCODE_ARC_COS_HYP { Text = "ACOSH" ; }; String SC_OPCODE_ARC_TAN_HYP { Text = "ATANH" ; }; String SC_OPCODE_ARC_COT_HYP { Text = "ACOTH" ; }; + String SC_OPCODE_COSECANT { Text = "CSC" ; }; + String SC_OPCODE_SECANT { Text = "SEC" ; }; + String SC_OPCODE_COSECANT_HYP { Text = "CSCH" ; }; + String SC_OPCODE_SECANT_HYP { Text = "SECH" ; }; String SC_OPCODE_EXP { Text = "EXP" ; }; String SC_OPCODE_LN { Text = "LN" ; }; String SC_OPCODE_SQRT { Text = "SQRT" ; }; @@ -412,6 +416,10 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH String SC_OPCODE_ARC_COS_HYP { Text = "ACOSH" ; }; String SC_OPCODE_ARC_TAN_HYP { Text = "ATANH" ; }; String SC_OPCODE_ARC_COT_HYP { Text = "ACOTH" ; }; + String SC_OPCODE_COSECANT { Text = "CSC" ; }; + String SC_OPCODE_SECANT { Text = "SEC" ; }; + String SC_OPCODE_COSECANT_HYP { Text = "CSCH" ; }; + String SC_OPCODE_SECANT_HYP { Text = "SECH" ; }; String SC_OPCODE_EXP { Text = "EXP" ; }; String SC_OPCODE_LN { Text = "LN" ; }; String SC_OPCODE_SQRT { Text = "SQRT" ; }; @@ -830,6 +838,22 @@ Resource RID_STRLIST_FUNCTION_NAMES { Text [ en-US ] = "ACOTH" ; }; + String SC_OPCODE_COSECANT + { + Text = "CSC" ; + }; + String SC_OPCODE_SECANT + { + Text = "SEC" ; + }; + String SC_OPCODE_COSECANT_HYP + { + Text = "CSCH" ; + }; + String SC_OPCODE_SECANT_HYP + { + Text = "SECH" ; + }; String SC_OPCODE_EXP { Text [ en-US ] = "EXP"; |