Kaydet (Commit) 14aabee5 authored tarafından Eike Rathke's avatar Eike Rathke

simplify RewriteMissing() and switch in Add...(), fdo#81596 related

Change-Id: If2ca37e1fda87ce56282fc2d2fc57a0784851139
üst 3dd241c5
...@@ -1737,19 +1737,19 @@ void FormulaCompiler::CreateStringFromTokenArray( OUStringBuffer& rBuffer ) ...@@ -1737,19 +1737,19 @@ void FormulaCompiler::CreateStringFromTokenArray( OUStringBuffer& rBuffer )
FormulaTokenArray* pSaveArr = pArr; FormulaTokenArray* pSaveArr = pArr;
bool bODFF = FormulaGrammar::isODFF( meGrammar); bool bODFF = FormulaGrammar::isODFF( meGrammar);
MissingConventionPOF aConv( bODFF);
if (bODFF || FormulaGrammar::isPODF( meGrammar) ) if (bODFF || FormulaGrammar::isPODF( meGrammar) )
{ {
// Scan token array for missing args and re-write if present. // Scan token array for missing args and re-write if present.
if (pArr->NeedsPofRewrite( aConv)) MissingConventionODF aConv( bODFF);
pArr = pArr->RewriteMissing( false, aConv ); if (pArr->NeedsPodfRewrite( aConv))
pArr = pArr->RewriteMissing( aConv );
} }
else if ( FormulaGrammar::isOOXML( meGrammar ) ) else if ( FormulaGrammar::isOOXML( meGrammar ) )
{ {
// fdo#81596
// Scan token array for missing args and rewrite if present. // Scan token array for missing args and rewrite if present.
if ( pArr->NeedsOOXMLRewrite() ) MissingConventionOOXML aConv;
pArr = pArr->RewriteMissing( true, aConv ); if (pArr->NeedsOoxmlRewrite( aConv))
pArr = pArr->RewriteMissing( aConv );
} }
// At least one character per token, plus some are references, some are // At least one character per token, plus some are references, some are
......
...@@ -53,14 +53,41 @@ typedef sal_uInt8 ScRecalcMode; ...@@ -53,14 +53,41 @@ typedef sal_uInt8 ScRecalcMode;
class FormulaMissingContext; class FormulaMissingContext;
class FORMULA_DLLPUBLIC MissingConventionPOF class FORMULA_DLLPUBLIC MissingConvention
{ {
bool mbODFF; /// TRUE: ODFF, FALSE: PODF
public: public:
explicit MissingConventionPOF( bool bODFF ) : mbODFF(bODFF) {} enum Convention
{
FORMULA_MISSING_CONVENTION_PODF,
FORMULA_MISSING_CONVENTION_ODFF,
FORMULA_MISSING_CONVENTION_OOXML
};
explicit MissingConvention( Convention eConvention ) : meConvention(eConvention) {}
inline bool isPODF() const { return meConvention == FORMULA_MISSING_CONVENTION_PODF; }
inline Convention getConvention() const { return meConvention; }
private:
Convention meConvention;
};
class FORMULA_DLLPUBLIC MissingConventionODF : public MissingConvention
{
public:
explicit MissingConventionODF( bool bODFF ) :
MissingConvention( bODFF ?
MissingConvention::FORMULA_MISSING_CONVENTION_ODFF :
MissingConvention::FORMULA_MISSING_CONVENTION_PODF)
{
}
// Implementation and usage only in token.cxx
inline bool isRewriteNeeded( OpCode eOp ) const;
};
class FORMULA_DLLPUBLIC MissingConventionOOXML : public MissingConvention
{
public:
explicit MissingConventionOOXML() : MissingConvention( MissingConvention::FORMULA_MISSING_CONVENTION_OOXML) {}
// Implementation and usage only in token.cxx // Implementation and usage only in token.cxx
inline bool isRewriteNeeded( OpCode eOp ) const; inline bool isRewriteNeeded( OpCode eOp ) const;
inline bool isODFF() const { return mbODFF; }
}; };
class FORMULA_DLLPUBLIC FormulaTokenArray class FORMULA_DLLPUBLIC FormulaTokenArray
...@@ -238,18 +265,19 @@ public: ...@@ -238,18 +265,19 @@ public:
FormulaTokenArray& operator=( const FormulaTokenArray& ); FormulaTokenArray& operator=( const FormulaTokenArray& );
/** Determines if this formula needs any changes to convert it to something /** Determines if this formula needs any changes to convert it to something
previous versions of OOo could consume (Plain Old Formula). */ previous versions of OOo could consume (Plain Old Formula, pre-ODFF, or
bool NeedsPofRewrite(const MissingConventionPOF & rConv); also ODFF) */
bool NeedsPodfRewrite( const MissingConventionODF & rConv );
/** Determines if this formula needs any changes to convert it to OOXML */ /** Determines if this formula needs any changes to convert it to OOXML. */
bool NeedsOOXMLRewrite(); bool NeedsOoxmlRewrite( const MissingConventionOOXML & rConv );
/** Rewrites to Plain Old Formula or OOXML, substituting missing parameters. The /** Rewrites to Plain Old Formula or OOXML, substituting missing parameters. The
FormulaTokenArray* returned is new'ed. */ FormulaTokenArray* returned is new'ed. */
FormulaTokenArray* RewriteMissing( bool bIsOOXML, const MissingConventionPOF & rConv ); FormulaTokenArray* RewriteMissing( const MissingConvention & rConv );
/** Determines if this formula may be followed by a reference. */ /** Determines if this formula may be followed by a reference. */
bool MayReferenceFollow(); bool MayReferenceFollow();
}; };
inline OpCode FormulaTokenArray::GetOuterFuncOpCode() inline OpCode FormulaTokenArray::GetOuterFuncOpCode()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment