diff options
-rw-r--r-- | formula/inc/formula/FormulaCompiler.hxx | 3 | ||||
-rw-r--r-- | formula/inc/formula/intruref.hxx | 10 | ||||
-rw-r--r-- | formula/inc/formula/tokenarray.hxx | 20 | ||||
-rw-r--r-- | formula/prj/CVS/Entries | 4 | ||||
-rw-r--r-- | formula/prj/CVS/Repository | 1 | ||||
-rw-r--r-- | formula/prj/CVS/Root | 1 | ||||
-rw-r--r-- | formula/prj/CVS/Tag | 1 | ||||
-rw-r--r-- | formula/prj/CVS/Template | 42 | ||||
-rw-r--r-- | formula/source/core/api/token.cxx | 219 |
9 files changed, 123 insertions, 178 deletions
diff --git a/formula/inc/formula/FormulaCompiler.hxx b/formula/inc/formula/FormulaCompiler.hxx index 120772265056..1fc77e2db01e 100644 --- a/formula/inc/formula/FormulaCompiler.hxx +++ b/formula/inc/formula/FormulaCompiler.hxx @@ -89,10 +89,11 @@ public: FormulaCompiler(FormulaTokenArray& _rArr); virtual ~FormulaCompiler(); - // SUNWS7 needs a forward declared friend, otherwise members of the outer + // SUNWS8 needs a forward declared friend, otherwise members of the outer // class are not accessible. class OpCodeMap; friend class FormulaCompiler::OpCodeMap; + /** Mappings from strings to OpCodes and vice versa. */ class FORMULA_DLLPUBLIC OpCodeMap { diff --git a/formula/inc/formula/intruref.hxx b/formula/inc/formula/intruref.hxx index e51f37f424ce..08d369084226 100644 --- a/formula/inc/formula/intruref.hxx +++ b/formula/inc/formula/intruref.hxx @@ -31,8 +31,8 @@ #ifndef FORMULA_INTRUREF_HXX #define FORMULA_INTRUREF_HXX -namespace formula
-{
+namespace formula +{ /** A simple intrusive refcounting template, not thread safe, but therefore also a bit faster than boost's smart_ptr or uno::Reference equivalents, and @@ -96,9 +96,9 @@ public: inline operator T*() const { return p; } inline T* get() const { return p; } }; -// =============================================================================
-} // formula
-// =============================================================================
+// ============================================================================= +} // formula +// ============================================================================= #endif // SC_INTRUREF_HXX diff --git a/formula/inc/formula/tokenarray.hxx b/formula/inc/formula/tokenarray.hxx index 5ba055156c80..d5a70db8ac53 100644 --- a/formula/inc/formula/tokenarray.hxx +++ b/formula/inc/formula/tokenarray.hxx @@ -74,30 +74,30 @@ class FORMULA_DLLPUBLIC FormulaTokenArray friend class FormulaMissingContext; protected: - FormulaToken** pCode; // Token code array - FormulaToken** pRPN; // RPN array + FormulaToken** pCode; // Token code array + FormulaToken** pRPN; // RPN array USHORT nLen; // Length of token array USHORT nRPN; // Length of RPN array USHORT nIndex; // Current step index USHORT nError; // Error code short nRefs; // Count of cell references ScRecalcMode nMode; // Flags to indicate when to recalc this code - BOOL bHyperLink; // If HYPERLINK() occurs in the formula. + BOOL bHyperLink; // If HYPERLINK() occurs in the formula. protected: void Assign( const FormulaTokenArray& ); /// Also used by the compiler. The token MUST had been allocated with new! - FormulaToken* Add( FormulaToken* ); + FormulaToken* Add( FormulaToken* ); inline void SetCombinedBitsRecalcMode( ScRecalcMode nBits ) - { nMode |= (nBits & ~RECALCMODE_EMASK); } + { nMode |= (nBits & ~RECALCMODE_EMASK); } inline ScRecalcMode GetCombinedBitsRecalcMode() const - { return nMode & ~RECALCMODE_EMASK; } + { return nMode & ~RECALCMODE_EMASK; } /** Exclusive bits already set in nMode are zero'ed, nVal may contain combined bits, but only one exclusive bit may be set! */ inline void SetMaskedRecalcMode( ScRecalcMode nBits ) - { nMode = GetCombinedBitsRecalcMode() | nBits; } + { nMode = GetCombinedBitsRecalcMode() | nBits; } public: FormulaTokenArray(); @@ -222,14 +222,14 @@ public: /** Determines if this formula needs any changes to convert it to something previous versions of OOo could consume (Plain Old Formula). */ - bool NeedsPofRewrite(const MissingConvention & rConv); + bool NeedsPofRewrite(const MissingConvention & rConv); /** Rewrites to Plain Old Formula, substituting missing parameters. The FormulaTokenArray* returned is new'ed. */ - FormulaTokenArray* RewriteMissingToPof(const MissingConvention & rConv); + FormulaTokenArray* RewriteMissingToPof(const MissingConvention & rConv); /** Determines if this formula may be followed by a reference. */ - bool MayReferenceFollow(); + bool MayReferenceFollow(); }; inline OpCode FormulaTokenArray::GetOuterFuncOpCode() diff --git a/formula/prj/CVS/Entries b/formula/prj/CVS/Entries deleted file mode 100644 index 3ae75e3153ff..000000000000 --- a/formula/prj/CVS/Entries +++ /dev/null @@ -1,4 +0,0 @@ -/build.lst/1.10/Wed Aug 20 14:15:04 2008//Tcws_dev300_frmdlg
-/d.lst/1.6/Fri Aug 17 11:27:10 2007//Tcws_dev300_frmdlg
-/rpt.xml/1.2/Mon Jul 09 11:56:12 2007//Tcws_dev300_frmdlg
-D
diff --git a/formula/prj/CVS/Repository b/formula/prj/CVS/Repository deleted file mode 100644 index 573341612fc8..000000000000 --- a/formula/prj/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -/cvs/dba/reportdesign/prj diff --git a/formula/prj/CVS/Root b/formula/prj/CVS/Root deleted file mode 100644 index ed0df2a21830..000000000000 --- a/formula/prj/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:pserver:oj@so-cvs-tunnel.germany.sun.com:/cvs
diff --git a/formula/prj/CVS/Tag b/formula/prj/CVS/Tag deleted file mode 100644 index 9ff93ee1efdd..000000000000 --- a/formula/prj/CVS/Tag +++ /dev/null @@ -1 +0,0 @@ -Tcws_dev300_frmdlg diff --git a/formula/prj/CVS/Template b/formula/prj/CVS/Template deleted file mode 100644 index eec9bab36d48..000000000000 --- a/formula/prj/CVS/Template +++ /dev/null @@ -1,42 +0,0 @@ -Issue number: -Submitted by: -Reviewed by: -CVS: ---------------------------------------------------------------------- -CVS: Issue number: -CVS: If this change addresses one or more issues, -CVS: then enter the issue number(s) here. -CVS: Submitted by: -CVS: If this code has been contributed to the project by someone else; i.e., -CVS: they sent us a patch or a set of diffs, then include their name/email -CVS: address here. If this is your work then delete this line. -CVS: Reviewed by: -CVS: If we are doing pre-commit code reviews and someone else has -CVS: reviewed your changes, include their name(s) here. -CVS: If you have not had it reviewed then delete this line. -CVS: ---------------------------------------------------------------------- -CVS: Committers, -CVS: -CVS: Please follow these protocols: -CVS: -CVS: * Please include in the log message -CVS: reference(s) by ID / number and/or URL -CVS: to any and all relevant OpenOffice.org issue(s). -CVS: -CVS: * If the code is contributed from outside Sun -CVS: then please verify using the list at the following URL -CVS: http://www.openoffice.org/copyright/copyrightapproved.html -CVS: that Sun has received a signed Copyright Assignment Form -CVS: from the submitter. -CVS: -CVS: Otherwise, -CVS: please send an email TO: the submitter; and CC: OOCRequest@eng.sun.com -CVS: the letter (CopyRightRequest.txt) to request assignment of copyright to Sun -CVS: (http://www.openoffice.org/copyright/assign_copyright.html). -CVS: -CVS: Please do NOT commit code until you have verified (as detailed above) that -CVS: Sun has received a signed Copyright Assignment Form from the submitter. -CVS: -CVS: * Please send an email TO: the submitter -CVS: (particularly, if from outside Sun) -CVS: advising that the code has been committed, -CVS: and gratefully recognizing the contribution. diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index d80591c58abb..3cb3eb10f1eb 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -880,11 +880,6 @@ BOOL FormulaTokenArray::HasMatrixDoubleRefOps() // --- POF (plain old formula) rewrite of a token array --------------------- -/* TODO: When both POF OOoXML and ODFF are to be supported differently, the - * FormulaMissingContext and FormulaTokenArray::*Pof* methods should go to a convention - * on its own. - */ - #if 0 // static function can't be compiled if not used (warning) //#if OSL_DEBUG_LEVEL > 0 @@ -898,65 +893,65 @@ static void DumpTokArr( FormulaTokenArray *pCode ) } #endif -inline bool MissingConvention::isRewriteNeeded( OpCode eOp ) const
-{
- switch (eOp)
- {
- case ocGammaDist:
- case ocPoissonDist:
- return true;
- case ocMissing:
- case ocLog:
- case ocAddress:
- return !isODFF(); // rewrite only for PODF
- default:
- return false;
- }
+inline bool MissingConvention::isRewriteNeeded( OpCode eOp ) const +{ + switch (eOp) + { + case ocGammaDist: + case ocPoissonDist: + case ocAddress: + return true; + case ocMissing: + case ocLog: + return !isODFF(); // rewrite only for PODF + default: + return false; + } } class FormulaMissingContext { public: - const FormulaToken* mpFunc; - int mnCurArg; + const FormulaToken* mpFunc; + int mnCurArg; void Clear() { mpFunc = NULL; mnCurArg = 0; } inline bool AddDefaultArg( FormulaTokenArray* pNewArr, int nArg, double f ) const; - static inline bool IsRewriteNeeded( OpCode eOp ); bool AddMissingExternal( FormulaTokenArray* pNewArr ) const; bool AddMissing( FormulaTokenArray *pNewArr, const MissingConvention & rConv ) const; void AddMoreArgs( FormulaTokenArray *pNewArr, const MissingConvention & rConv ) const; }; + void FormulaMissingContext::AddMoreArgs( FormulaTokenArray *pNewArr, const MissingConvention & rConv ) const { - if ( !mpFunc )
- return;
-
- switch (mpFunc->GetOpCode())
- {
- case ocGammaDist:
- if (mnCurArg == 2)
- {
- pNewArr->AddOpCode( ocSep );
- pNewArr->AddDouble( 1.0 ); // 4th, Cumulative=TRUE()
- }
- break;
- case ocPoissonDist:
- if (mnCurArg == 1)
- {
- pNewArr->AddOpCode( ocSep );
- pNewArr->AddDouble( 1.0 ); // 3rd, Cumulative=TRUE()
- }
- break;
- case ocLog:
- if ( !rConv.isODFF() && mnCurArg == 0 )
- {
- pNewArr->AddOpCode( ocSep );
- pNewArr->AddDouble( 10.0 ); // 2nd, basis 10
- }
- break;
- default:
- break;
+ if ( !mpFunc ) + return; + + switch (mpFunc->GetOpCode()) + { + case ocGammaDist: + if (mnCurArg == 2) + { + pNewArr->AddOpCode( ocSep ); + pNewArr->AddDouble( 1.0 ); // 4th, Cumulative=TRUE() + } + break; + case ocPoissonDist: + if (mnCurArg == 1) + { + pNewArr->AddOpCode( ocSep ); + pNewArr->AddDouble( 1.0 ); // 3rd, Cumulative=TRUE() + } + break; + case ocLog: + if ( !rConv.isODFF() && mnCurArg == 0 ) + { + pNewArr->AddOpCode( ocSep ); + pNewArr->AddDouble( 10.0 ); // 2nd, basis 10 + } + break; + default: + break; } } @@ -970,21 +965,10 @@ inline bool FormulaMissingContext::AddDefaultArg( FormulaTokenArray* pNewArr, in return false; } -inline bool FormulaMissingContext::IsRewriteNeeded( OpCode eOp ) -{ - switch (eOp) - { - case ocMissing: - case ocLog: - case ocAddress: - return true; - default: - return false; - } -} - bool FormulaMissingContext::AddMissingExternal( FormulaTokenArray *pNewArr ) const { + // Only called for PODF, not ODFF. No need to distinguish. + const String &rName = mpFunc->GetExternal(); // initial (fast) check: @@ -1007,54 +991,63 @@ bool FormulaMissingContext::AddMissingExternal( FormulaTokenArray *pNewArr ) con bool FormulaMissingContext::AddMissing( FormulaTokenArray *pNewArr, const MissingConvention & rConv ) const { - if ( !mpFunc )
- return false;
-
- bool bRet = false;
- if (rConv.isODFF())
- {
- }
- else
- {
- switch ( mpFunc->GetOpCode() )
- {
- case ocFixed:
- return AddDefaultArg( pNewArr, 1, 2.0 );
- //break;
- case ocBetaDist:
- case ocBetaInv:
- case ocRMZ: // PMT
- return AddDefaultArg( pNewArr, 3, 0.0 );
- //break;
- case ocZinsZ: // IPMT
- case ocKapz: // PPMT
- return AddDefaultArg( pNewArr, 4, 0.0 );
- //break;
- case ocBW: // PV
- case ocZW: // FV
- bRet |= AddDefaultArg( pNewArr, 2, 0.0 ); // pmt
- bRet |= AddDefaultArg( pNewArr, 3, 0.0 ); // [fp]v
- break;
- case ocZins: // RATE
- bRet |= AddDefaultArg( pNewArr, 1, 0.0 ); // pmt
- bRet |= AddDefaultArg( pNewArr, 3, 0.0 ); // fv
- bRet |= AddDefaultArg( pNewArr, 4, 0.0 ); // type
- break;
- case ocExternal:
- return AddMissingExternal( pNewArr );
- //break;
-
- // --- more complex cases ---
-
- case ocOffset:
- // FIXME: rather tough.
- // if arg 3 (height) ommitted, export arg1 (rows)
- break;
- default:
- break;
- }
- }
-
+ if ( !mpFunc ) + return false; + + bool bRet = false; + const OpCode eOp = mpFunc->GetOpCode(); + + // Add for both, PODF and ODFF + switch (eOp) + { + case ocAddress: + return AddDefaultArg( pNewArr, 2, 1.0 ); // abs + default: + break; + } + + if (rConv.isODFF()) + { + // Add for ODFF + } + else + { + // Add for PODF + switch (eOp) + { + case ocFixed: + return AddDefaultArg( pNewArr, 1, 2.0 ); + case ocBetaDist: + case ocBetaInv: + case ocRMZ: // PMT + return AddDefaultArg( pNewArr, 3, 0.0 ); + case ocZinsZ: // IPMT + case ocKapz: // PPMT + return AddDefaultArg( pNewArr, 4, 0.0 ); + case ocBW: // PV + case ocZW: // FV + bRet |= AddDefaultArg( pNewArr, 2, 0.0 ); // pmt + bRet |= AddDefaultArg( pNewArr, 3, 0.0 ); // [fp]v + break; + case ocZins: // RATE + bRet |= AddDefaultArg( pNewArr, 1, 0.0 ); // pmt + bRet |= AddDefaultArg( pNewArr, 3, 0.0 ); // fv + bRet |= AddDefaultArg( pNewArr, 4, 0.0 ); // type + break; + case ocExternal: + return AddMissingExternal( pNewArr ); + + // --- more complex cases --- + + case ocOffset: + // FIXME: rather tough. + // if arg 3 (height) ommitted, export arg1 (rows) + break; + default: + break; + } + } + return bRet; } @@ -1113,8 +1106,8 @@ FormulaTokenArray * FormulaTokenArray::RewriteMissingToPof( const MissingConvent ++nFn; // all following operations on _that_ function pCtx[ nFn ].mpFunc = PeekPrevNoSpaces(); pCtx[ nFn ].mnCurArg = 0; - if (pCtx[ nFn ].mpFunc && pCtx[ nFn ].mpFunc->GetOpCode() == ocAddress) - pOcas[ nOcas++ ] = nFn; // entering ADDRESS() + if (pCtx[ nFn ].mpFunc && pCtx[ nFn ].mpFunc->GetOpCode() == ocAddress && !rConv.isODFF()) + pOcas[ nOcas++ ] = nFn; // entering ADDRESS() if PODF break; case ocClose: pCtx[ nFn ].AddMoreArgs( pNewArr, rConv ); |