Kaydet (Commit) e27fbbcd authored tarafından Noel Grandin's avatar Noel Grandin

convert ExpressionFunct to scoped enum

and drop the trivial subset of it EnumFunc

Change-Id: I9ee7de829121f04e97c167b133cdc78c5ffd0822
üst 2c86c131
...@@ -194,23 +194,7 @@ class SVX_DLLPUBLIC EnhancedCustomShape2d : public SfxItemSet ...@@ -194,23 +194,7 @@ class SVX_DLLPUBLIC EnhancedCustomShape2d : public SfxItemSet
EnhancedCustomShape2d( SdrObject* pSdrObjCustomShape ); EnhancedCustomShape2d( SdrObject* pSdrObjCustomShape );
virtual ~EnhancedCustomShape2d(); virtual ~EnhancedCustomShape2d();
enum SAL_DLLPRIVATE EnumFunc SAL_DLLPRIVATE double GetEnumFunc( const EnhancedCustomShape::ExpressionFunct eVal ) const;
{
ENUM_FUNC_PI,
ENUM_FUNC_LEFT,
ENUM_FUNC_TOP,
ENUM_FUNC_RIGHT,
ENUM_FUNC_BOTTOM,
ENUM_FUNC_XSTRETCH,
ENUM_FUNC_YSTRETCH,
ENUM_FUNC_HASSTROKE,
ENUM_FUNC_HASFILL,
ENUM_FUNC_WIDTH,
ENUM_FUNC_HEIGHT,
ENUM_FUNC_LOGWIDTH,
ENUM_FUNC_LOGHEIGHT
};
SAL_DLLPRIVATE double GetEnumFunc( const EnumFunc eVal ) const;
SAL_DLLPRIVATE double GetAdjustValueAsDouble( const sal_Int32 nIndex ) const; SAL_DLLPRIVATE double GetAdjustValueAsDouble( const sal_Int32 nIndex ) const;
SAL_DLLPRIVATE double GetEquationValueAsDouble( const sal_Int32 nIndex ) const; SAL_DLLPRIVATE double GetEquationValueAsDouble( const sal_Int32 nIndex ) const;
......
...@@ -44,43 +44,43 @@ class EnhancedCustomShape2d; ...@@ -44,43 +44,43 @@ class EnhancedCustomShape2d;
namespace EnhancedCustomShape { namespace EnhancedCustomShape {
enum ExpressionFunct enum class ExpressionFunct
{ {
FUNC_CONST, Const,
ENUM_FUNC_PI, EnumPi,
ENUM_FUNC_LEFT, EnumLeft,
ENUM_FUNC_TOP, EnumTop,
ENUM_FUNC_RIGHT, EnumRight,
ENUM_FUNC_BOTTOM, EnumBottom,
ENUM_FUNC_XSTRETCH, EnumXStretch,
ENUM_FUNC_YSTRETCH, EnumYStretch,
ENUM_FUNC_HASSTROKE, EnumHasStroke,
ENUM_FUNC_HASFILL, EnumHasFill,
ENUM_FUNC_WIDTH, EnumWidth,
ENUM_FUNC_HEIGHT, EnumHeight,
ENUM_FUNC_LOGWIDTH, EnumLogWidth,
ENUM_FUNC_LOGHEIGHT, EnumLogHeight,
ENUM_FUNC_ADJUSTMENT, EnumAdjustment,
ENUM_FUNC_EQUATION, EnumEquation,
UNARY_FUNC_ABS, UnaryAbs,
UNARY_FUNC_SQRT, UnarySqrt,
UNARY_FUNC_SIN, UnarySin,
UNARY_FUNC_COS, UnaryCos,
UNARY_FUNC_TAN, UnaryTan,
UNARY_FUNC_ATAN, UnaryAtan,
UNARY_FUNC_NEG, UnaryNeg,
BINARY_FUNC_PLUS, BinaryPlus,
BINARY_FUNC_MINUS, BinaryMinus,
BINARY_FUNC_MUL, BinaryMul,
BINARY_FUNC_DIV, BinaryDiv,
BINARY_FUNC_MIN, BinaryMin,
BINARY_FUNC_MAX, BinaryMax,
BINARY_FUNC_ATAN2, BinaryAtan2,
TERNARY_FUNC_IF TernaryIf
}; };
#define EXPRESSION_FLAG_SUMANGLE_MODE 1 #define EXPRESSION_FLAG_SUMANGLE_MODE 1
......
...@@ -810,24 +810,28 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) : ...@@ -810,24 +810,28 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) :
} }
} }
} }
double EnhancedCustomShape2d::GetEnumFunc( const EnumFunc eFunc ) const
using EnhancedCustomShape::ExpressionFunct;
double EnhancedCustomShape2d::GetEnumFunc( const ExpressionFunct eFunc ) const
{ {
double fRet = 0.0; double fRet = 0.0;
switch( eFunc ) switch( eFunc )
{ {
case ENUM_FUNC_PI : fRet = F_PI; break; case ExpressionFunct::EnumPi : fRet = F_PI; break;
case ENUM_FUNC_LEFT : fRet = 0.0; break; case ExpressionFunct::EnumLeft : fRet = 0.0; break;
case ENUM_FUNC_TOP : fRet = 0.0; break; case ExpressionFunct::EnumTop : fRet = 0.0; break;
case ENUM_FUNC_RIGHT : fRet = (double)nCoordWidth * fXRatio; break; case ExpressionFunct::EnumRight : fRet = (double)nCoordWidth * fXRatio; break;
case ENUM_FUNC_BOTTOM : fRet = (double)nCoordHeight * fYRatio; break; case ExpressionFunct::EnumBottom : fRet = (double)nCoordHeight * fYRatio; break;
case ENUM_FUNC_XSTRETCH : fRet = nXRef; break; case ExpressionFunct::EnumXStretch : fRet = nXRef; break;
case ENUM_FUNC_YSTRETCH : fRet = nYRef; break; case ExpressionFunct::EnumYStretch : fRet = nYRef; break;
case ENUM_FUNC_HASSTROKE : fRet = bStroked ? 1.0 : 0.0; break; case ExpressionFunct::EnumHasStroke : fRet = bStroked ? 1.0 : 0.0; break;
case ENUM_FUNC_HASFILL : fRet = bFilled ? 1.0 : 0.0; break; case ExpressionFunct::EnumHasFill : fRet = bFilled ? 1.0 : 0.0; break;
case ENUM_FUNC_WIDTH : fRet = nCoordWidth; break; case ExpressionFunct::EnumWidth : fRet = nCoordWidth; break;
case ENUM_FUNC_HEIGHT : fRet = nCoordHeight; break; case ExpressionFunct::EnumHeight : fRet = nCoordHeight; break;
case ENUM_FUNC_LOGWIDTH : fRet = aLogicRect.GetWidth(); break; case ExpressionFunct::EnumLogWidth : fRet = aLogicRect.GetWidth(); break;
case ENUM_FUNC_LOGHEIGHT : fRet = aLogicRect.GetHeight(); break; case ExpressionFunct::EnumLogHeight : fRet = aLogicRect.GetHeight(); break;
default: break;
} }
return fRet; return fRet;
} }
......
...@@ -111,7 +111,7 @@ public: ...@@ -111,7 +111,7 @@ public:
} }
virtual ExpressionFunct getType() const override virtual ExpressionFunct getType() const override
{ {
return FUNC_CONST; return ExpressionFunct::Const;
} }
virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& rEquations, ExpressionNode* /* pOptionalArg */, sal_uInt32 /* nFlags */ ) override virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& rEquations, ExpressionNode* /* pOptionalArg */, sal_uInt32 /* nFlags */ ) override
{ {
...@@ -166,7 +166,7 @@ public: ...@@ -166,7 +166,7 @@ public:
} }
virtual ExpressionFunct getType() const override virtual ExpressionFunct getType() const override
{ {
return ENUM_FUNC_ADJUSTMENT; return ExpressionFunct::EnumAdjustment;
} }
virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& /*rEquations*/, ExpressionNode* /*pOptionalArg*/, sal_uInt32 /*nFlags*/ ) override virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& /*rEquations*/, ExpressionNode* /*pOptionalArg*/, sal_uInt32 /*nFlags*/ ) override
{ {
...@@ -199,7 +199,7 @@ public: ...@@ -199,7 +199,7 @@ public:
} }
virtual ExpressionFunct getType() const override virtual ExpressionFunct getType() const override
{ {
return ENUM_FUNC_EQUATION; return ExpressionFunct::EnumEquation;
} }
virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& /*rEquations*/, ExpressionNode* /*pOptionalArg*/, sal_uInt32 /*nFlags*/ ) override virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& /*rEquations*/, ExpressionNode* /*pOptionalArg*/, sal_uInt32 /*nFlags*/ ) override
{ {
...@@ -222,57 +222,33 @@ public: ...@@ -222,57 +222,33 @@ public:
, mrCustoShape ( rCustoShape ) , mrCustoShape ( rCustoShape )
{ {
} }
static double getValue( const EnhancedCustomShape2d& rCustoShape, const ExpressionFunct eFunc )
{
EnhancedCustomShape2d::EnumFunc eF;
switch( eFunc )
{
case ENUM_FUNC_PI : eF = EnhancedCustomShape2d::ENUM_FUNC_PI; break;
case ENUM_FUNC_LEFT : eF = EnhancedCustomShape2d::ENUM_FUNC_LEFT; break;
case ENUM_FUNC_TOP : eF = EnhancedCustomShape2d::ENUM_FUNC_TOP; break;
case ENUM_FUNC_RIGHT : eF = EnhancedCustomShape2d::ENUM_FUNC_RIGHT; break;
case ENUM_FUNC_BOTTOM : eF = EnhancedCustomShape2d::ENUM_FUNC_BOTTOM; break;
case ENUM_FUNC_XSTRETCH : eF = EnhancedCustomShape2d::ENUM_FUNC_XSTRETCH; break;
case ENUM_FUNC_YSTRETCH : eF = EnhancedCustomShape2d::ENUM_FUNC_YSTRETCH; break;
case ENUM_FUNC_HASSTROKE : eF = EnhancedCustomShape2d::ENUM_FUNC_HASSTROKE; break;
case ENUM_FUNC_HASFILL : eF = EnhancedCustomShape2d::ENUM_FUNC_HASFILL; break;
case ENUM_FUNC_WIDTH : eF = EnhancedCustomShape2d::ENUM_FUNC_WIDTH; break;
case ENUM_FUNC_HEIGHT : eF = EnhancedCustomShape2d::ENUM_FUNC_HEIGHT; break;
case ENUM_FUNC_LOGWIDTH : eF = EnhancedCustomShape2d::ENUM_FUNC_LOGWIDTH; break;
case ENUM_FUNC_LOGHEIGHT : eF = EnhancedCustomShape2d::ENUM_FUNC_LOGHEIGHT; break;
default :
return 0.0;
}
return rCustoShape.GetEnumFunc( eF );
}
virtual double operator()() const override virtual double operator()() const override
{ {
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
const char *funcName; const char *funcName;
switch (meFunct) { switch (meFunct) {
case ENUM_FUNC_PI : funcName = "pi"; break; case ExpressionFunct::EnumPi : funcName = "pi"; break;
case ENUM_FUNC_LEFT : funcName = "left"; break; case ExpressionFunct::EnumLeft : funcName = "left"; break;
case ENUM_FUNC_TOP : funcName = "top"; break; case ExpressionFunct::EnumTop : funcName = "top"; break;
case ENUM_FUNC_RIGHT : funcName = "right"; break; case ExpressionFunct::EnumRight : funcName = "right"; break;
case ENUM_FUNC_BOTTOM : funcName = "bottom"; break; case ExpressionFunct::EnumBottom : funcName = "bottom"; break;
case ENUM_FUNC_XSTRETCH : funcName = "xstretch"; break; case ExpressionFunct::EnumXStretch : funcName = "xstretch"; break;
case ENUM_FUNC_YSTRETCH : funcName = "ystretch"; break; case ExpressionFunct::EnumYStretch : funcName = "ystretch"; break;
case ENUM_FUNC_HASSTROKE : funcName = "hasstroke"; break; case ExpressionFunct::EnumHasStroke : funcName = "hasstroke"; break;
case ENUM_FUNC_HASFILL : funcName = "hasfill"; break; case ExpressionFunct::EnumHasFill : funcName = "hasfill"; break;
case ENUM_FUNC_WIDTH : funcName = "width"; break; case ExpressionFunct::EnumWidth : funcName = "width"; break;
case ENUM_FUNC_HEIGHT : funcName = "height"; break; case ExpressionFunct::EnumHeight : funcName = "height"; break;
case ENUM_FUNC_LOGWIDTH : funcName = "logwidth"; break; case ExpressionFunct::EnumLogWidth : funcName = "logwidth"; break;
case ENUM_FUNC_LOGHEIGHT : funcName = "logheight"; break; case ExpressionFunct::EnumLogHeight : funcName = "logheight"; break;
default: funcName = "???"; break; default: funcName = "???"; break;
} }
SAL_INFO("svx", funcName << " --> " << getValue(mrCustoShape, meFunct) << "(angle: " << SAL_INFO("svx", funcName << " --> " << mrCustoShape.GetEnumFunc(meFunct) << "(angle: " <<
180.0*getValue(mrCustoShape, meFunct)/10800000.0 << ")"); 180.0 * mrCustoShape.GetEnumFunc(meFunct) / 10800000.0 << ")");
#endif #endif
return getValue( mrCustoShape, meFunct ); return mrCustoShape.GetEnumFunc( meFunct );
} }
virtual bool isConstant() const override virtual bool isConstant() const override
{ {
...@@ -291,26 +267,26 @@ public: ...@@ -291,26 +267,26 @@ public:
switch( meFunct ) switch( meFunct )
{ {
case ENUM_FUNC_WIDTH : // TODO: do not use this as constant value case ExpressionFunct::EnumWidth : // TODO: do not use this as constant value
case ENUM_FUNC_HEIGHT : case ExpressionFunct::EnumHeight :
case ENUM_FUNC_LOGWIDTH : case ExpressionFunct::EnumLogWidth :
case ENUM_FUNC_LOGHEIGHT : case ExpressionFunct::EnumLogHeight :
case ENUM_FUNC_PI : case ExpressionFunct::EnumPi :
{ {
ConstantValueExpression aConstantValue( getValue( mrCustoShape, meFunct ) ); ConstantValueExpression aConstantValue( mrCustoShape.GetEnumFunc( meFunct ) );
aRet = aConstantValue.fillNode( rEquations, nullptr, nFlags ); aRet = aConstantValue.fillNode( rEquations, nullptr, nFlags );
} }
break; break;
case ENUM_FUNC_LEFT : aRet.Type = EnhancedCustomShapeParameterType::LEFT; break; case ExpressionFunct::EnumLeft : aRet.Type = EnhancedCustomShapeParameterType::LEFT; break;
case ENUM_FUNC_TOP : aRet.Type = EnhancedCustomShapeParameterType::TOP; break; case ExpressionFunct::EnumTop : aRet.Type = EnhancedCustomShapeParameterType::TOP; break;
case ENUM_FUNC_RIGHT : aRet.Type = EnhancedCustomShapeParameterType::RIGHT; break; case ExpressionFunct::EnumRight : aRet.Type = EnhancedCustomShapeParameterType::RIGHT; break;
case ENUM_FUNC_BOTTOM : aRet.Type = EnhancedCustomShapeParameterType::BOTTOM; break; case ExpressionFunct::EnumBottom : aRet.Type = EnhancedCustomShapeParameterType::BOTTOM; break;
// not implemented so far // not implemented so far
case ENUM_FUNC_XSTRETCH : case ExpressionFunct::EnumXStretch :
case ENUM_FUNC_YSTRETCH : case ExpressionFunct::EnumYStretch :
case ENUM_FUNC_HASSTROKE : case ExpressionFunct::EnumHasStroke :
case ENUM_FUNC_HASFILL : aRet.Type = EnhancedCustomShapeParameterType::NORMAL; break; case ExpressionFunct::EnumHasFill : aRet.Type = EnhancedCustomShapeParameterType::NORMAL; break;
default: default:
break; break;
...@@ -338,13 +314,13 @@ public: ...@@ -338,13 +314,13 @@ public:
double fRet = 0; double fRet = 0;
switch( eFunct ) switch( eFunct )
{ {
case UNARY_FUNC_ABS : fRet = fabs( (*rArg)() ); break; case ExpressionFunct::UnaryAbs : fRet = fabs( (*rArg)() ); break;
case UNARY_FUNC_SQRT: fRet = sqrt( (*rArg)() ); break; case ExpressionFunct::UnarySqrt: fRet = sqrt( (*rArg)() ); break;
case UNARY_FUNC_SIN : fRet = sin( (*rArg)() ); break; case ExpressionFunct::UnarySin : fRet = sin( (*rArg)() ); break;
case UNARY_FUNC_COS : fRet = cos( (*rArg)() ); break; case ExpressionFunct::UnaryCos : fRet = cos( (*rArg)() ); break;
case UNARY_FUNC_TAN : fRet = tan( (*rArg)() ); break; case ExpressionFunct::UnaryTan : fRet = tan( (*rArg)() ); break;
case UNARY_FUNC_ATAN: fRet = atan( (*rArg)() ); break; case ExpressionFunct::UnaryAtan: fRet = atan( (*rArg)() ); break;
case UNARY_FUNC_NEG : fRet = ::std::negate<double>()( (*rArg)() ); break; case ExpressionFunct::UnaryNeg : fRet = ::std::negate<double>()( (*rArg)() ); break;
default: default:
break; break;
} }
...@@ -367,7 +343,7 @@ public: ...@@ -367,7 +343,7 @@ public:
EnhancedCustomShapeParameter aRet; EnhancedCustomShapeParameter aRet;
switch( meFunct ) switch( meFunct )
{ {
case UNARY_FUNC_ABS : case ExpressionFunct::UnaryAbs :
{ {
EnhancedCustomShapeEquation aEquation; EnhancedCustomShapeEquation aEquation;
aEquation.nOperation |= 3; aEquation.nOperation |= 3;
...@@ -377,7 +353,7 @@ public: ...@@ -377,7 +353,7 @@ public:
rEquations.push_back( aEquation ); rEquations.push_back( aEquation );
} }
break; break;
case UNARY_FUNC_SQRT: case ExpressionFunct::UnarySqrt:
{ {
EnhancedCustomShapeEquation aEquation; EnhancedCustomShapeEquation aEquation;
aEquation.nOperation |= 13; aEquation.nOperation |= 13;
...@@ -387,7 +363,7 @@ public: ...@@ -387,7 +363,7 @@ public:
rEquations.push_back( aEquation ); rEquations.push_back( aEquation );
} }
break; break;
case UNARY_FUNC_SIN : case ExpressionFunct::UnarySin :
{ {
EnhancedCustomShapeEquation aEquation; EnhancedCustomShapeEquation aEquation;
aEquation.nOperation |= 9; aEquation.nOperation |= 9;
...@@ -412,7 +388,7 @@ public: ...@@ -412,7 +388,7 @@ public:
rEquations.push_back( aEquation ); rEquations.push_back( aEquation );
} }
break; break;
case UNARY_FUNC_COS : case ExpressionFunct::UnaryCos :
{ {
EnhancedCustomShapeEquation aEquation; EnhancedCustomShapeEquation aEquation;
aEquation.nOperation |= 10; aEquation.nOperation |= 10;
...@@ -437,7 +413,7 @@ public: ...@@ -437,7 +413,7 @@ public:
rEquations.push_back( aEquation ); rEquations.push_back( aEquation );
} }
break; break;
case UNARY_FUNC_TAN : case ExpressionFunct::UnaryTan :
{ {
EnhancedCustomShapeEquation aEquation; EnhancedCustomShapeEquation aEquation;
aEquation.nOperation |= 16; aEquation.nOperation |= 16;
...@@ -462,13 +438,13 @@ public: ...@@ -462,13 +438,13 @@ public:
rEquations.push_back( aEquation ); rEquations.push_back( aEquation );
} }
break; break;
case UNARY_FUNC_ATAN: case ExpressionFunct::UnaryAtan:
{ {
// TODO: // TODO:
aRet.Type = EnhancedCustomShapeParameterType::NORMAL; aRet.Type = EnhancedCustomShapeParameterType::NORMAL;
} }
break; break;
case UNARY_FUNC_NEG: case ExpressionFunct::UnaryNeg:
{ {
EnhancedCustomShapeEquation aEquation; EnhancedCustomShapeEquation aEquation;
aEquation.nOperation |= 1; aEquation.nOperation |= 1;
...@@ -509,13 +485,13 @@ public: ...@@ -509,13 +485,13 @@ public:
double fRet = 0; double fRet = 0;
switch( eFunct ) switch( eFunct )
{ {
case BINARY_FUNC_PLUS : fRet = (*rFirstArg)() + (*rSecondArg)(); break; case ExpressionFunct::BinaryPlus : fRet = (*rFirstArg)() + (*rSecondArg)(); break;
case BINARY_FUNC_MINUS: fRet = (*rFirstArg)() - (*rSecondArg)(); break; case ExpressionFunct::BinaryMinus: fRet = (*rFirstArg)() - (*rSecondArg)(); break;
case BINARY_FUNC_MUL : fRet = (*rFirstArg)() * (*rSecondArg)(); break; case ExpressionFunct::BinaryMul : fRet = (*rFirstArg)() * (*rSecondArg)(); break;
case BINARY_FUNC_DIV : fRet = (*rFirstArg)() / (*rSecondArg)(); break; case ExpressionFunct::BinaryDiv : fRet = (*rFirstArg)() / (*rSecondArg)(); break;
case BINARY_FUNC_MIN : fRet = ::std::min( (*rFirstArg)(), (*rSecondArg)() ); break; case ExpressionFunct::BinaryMin : fRet = ::std::min( (*rFirstArg)(), (*rSecondArg)() ); break;
case BINARY_FUNC_MAX : fRet = ::std::max( (*rFirstArg)(), (*rSecondArg)() ); break; case ExpressionFunct::BinaryMax : fRet = ::std::max( (*rFirstArg)(), (*rSecondArg)() ); break;
case BINARY_FUNC_ATAN2: fRet = atan2( (*rFirstArg)(), (*rSecondArg)() ); break; case ExpressionFunct::BinaryAtan2: fRet = atan2( (*rFirstArg)(), (*rSecondArg)() ); break;
default: default:
break; break;
} }
...@@ -538,11 +514,11 @@ public: ...@@ -538,11 +514,11 @@ public:
EnhancedCustomShapeParameter aRet; EnhancedCustomShapeParameter aRet;
switch( meFunct ) switch( meFunct )
{ {
case BINARY_FUNC_PLUS : case ExpressionFunct::BinaryPlus :
{ {
if ( nFlags & EXPRESSION_FLAG_SUMANGLE_MODE ) if ( nFlags & EXPRESSION_FLAG_SUMANGLE_MODE )
{ {
if ( mpFirstArg->getType() == ENUM_FUNC_ADJUSTMENT ) if ( mpFirstArg->getType() == ExpressionFunct::EnumAdjustment )
{ {
EnhancedCustomShapeEquation aEquation; EnhancedCustomShapeEquation aEquation;
aEquation.nOperation |= 0xe; // sumangle aEquation.nOperation |= 0xe; // sumangle
...@@ -552,7 +528,7 @@ public: ...@@ -552,7 +528,7 @@ public:
aRet.Value <<= (sal_Int32)rEquations.size(); aRet.Value <<= (sal_Int32)rEquations.size();
rEquations.push_back( aEquation ); rEquations.push_back( aEquation );
} }
else if ( mpSecondArg->getType() == ENUM_FUNC_ADJUSTMENT ) else if ( mpSecondArg->getType() == ExpressionFunct::EnumAdjustment )
{ {
EnhancedCustomShapeEquation aEquation; EnhancedCustomShapeEquation aEquation;
aEquation.nOperation |= 0xe; // sumangle aEquation.nOperation |= 0xe; // sumangle
...@@ -609,7 +585,7 @@ public: ...@@ -609,7 +585,7 @@ public:
} }
} }
break; break;
case BINARY_FUNC_MINUS: case ExpressionFunct::BinaryMinus:
{ {
EnhancedCustomShapeEquation aEquation; EnhancedCustomShapeEquation aEquation;
aEquation.nOperation |= 0; aEquation.nOperation |= 0;
...@@ -620,13 +596,13 @@ public: ...@@ -620,13 +596,13 @@ public:
rEquations.push_back( aEquation ); rEquations.push_back( aEquation );
} }
break; break;
case BINARY_FUNC_MUL : case ExpressionFunct::BinaryMul :
{ {
// in the dest. format the cos function is using integer as result :-( // in the dest. format the cos function is using integer as result :-(
// so we can't use the generic algorithm // so we can't use the generic algorithm
if ( ( mpFirstArg->getType() == UNARY_FUNC_SIN ) || ( mpFirstArg->getType() == UNARY_FUNC_COS ) || ( mpFirstArg->getType() == UNARY_FUNC_TAN ) ) if ( ( mpFirstArg->getType() == ExpressionFunct::UnarySin ) || ( mpFirstArg->getType() == ExpressionFunct::UnaryCos ) || ( mpFirstArg->getType() == ExpressionFunct::UnaryTan ) )
aRet = mpFirstArg->fillNode( rEquations, mpSecondArg.get(), nFlags ); aRet = mpFirstArg->fillNode( rEquations, mpSecondArg.get(), nFlags );
else if ( ( mpSecondArg->getType() == UNARY_FUNC_SIN ) || ( mpSecondArg->getType() == UNARY_FUNC_COS ) || ( mpSecondArg->getType() == UNARY_FUNC_TAN ) ) else if ( ( mpSecondArg->getType() == ExpressionFunct::UnarySin ) || ( mpSecondArg->getType() == ExpressionFunct::UnaryCos ) || ( mpSecondArg->getType() == ExpressionFunct::UnaryTan ) )
aRet = mpSecondArg->fillNode( rEquations, mpFirstArg.get(), nFlags ); aRet = mpSecondArg->fillNode( rEquations, mpFirstArg.get(), nFlags );
else else
{ {
...@@ -634,15 +610,15 @@ public: ...@@ -634,15 +610,15 @@ public:
aRet = mpSecondArg->fillNode( rEquations, nullptr, nFlags ); aRet = mpSecondArg->fillNode( rEquations, nullptr, nFlags );
else if ( mpSecondArg->isConstant() && (*mpSecondArg)() == 1 ) else if ( mpSecondArg->isConstant() && (*mpSecondArg)() == 1 )
aRet = mpFirstArg->fillNode( rEquations, nullptr, nFlags ); aRet = mpFirstArg->fillNode( rEquations, nullptr, nFlags );
else if ( ( mpFirstArg->getType() == BINARY_FUNC_DIV ) // don't care of (pi/180) else if ( ( mpFirstArg->getType() == ExpressionFunct::BinaryDiv ) // don't care of (pi/180)
&& ( static_cast<BinaryFunctionExpression*>(mpFirstArg.get())->mpFirstArg.get()->getType() == ENUM_FUNC_PI ) && ( static_cast<BinaryFunctionExpression*>(mpFirstArg.get())->mpFirstArg.get()->getType() == ExpressionFunct::EnumPi )
&& ( static_cast<BinaryFunctionExpression*>(mpFirstArg.get())->mpSecondArg.get()->getType() == FUNC_CONST ) ) && ( static_cast<BinaryFunctionExpression*>(mpFirstArg.get())->mpSecondArg.get()->getType() == ExpressionFunct::Const ) )
{ {
aRet = mpSecondArg->fillNode( rEquations, nullptr, nFlags ); aRet = mpSecondArg->fillNode( rEquations, nullptr, nFlags );
} }
else if ( ( mpSecondArg->getType() == BINARY_FUNC_DIV ) // don't care of (pi/180) else if ( ( mpSecondArg->getType() == ExpressionFunct::BinaryDiv ) // don't care of (pi/180)
&& ( static_cast<BinaryFunctionExpression*>(mpSecondArg.get())->mpFirstArg.get()->getType() == ENUM_FUNC_PI ) && ( static_cast<BinaryFunctionExpression*>(mpSecondArg.get())->mpFirstArg.get()->getType() == ExpressionFunct::EnumPi )
&& ( static_cast<BinaryFunctionExpression*>(mpSecondArg.get())->mpSecondArg.get()->getType() == FUNC_CONST ) ) && ( static_cast<BinaryFunctionExpression*>(mpSecondArg.get())->mpSecondArg.get()->getType() == ExpressionFunct::Const ) )
{ {
aRet = mpFirstArg->fillNode( rEquations, nullptr, nFlags ); aRet = mpFirstArg->fillNode( rEquations, nullptr, nFlags );
} }
...@@ -660,7 +636,7 @@ public: ...@@ -660,7 +636,7 @@ public:
} }
} }
break; break;
case BINARY_FUNC_DIV : case ExpressionFunct::BinaryDiv :
{ {
EnhancedCustomShapeEquation aEquation; EnhancedCustomShapeEquation aEquation;
aEquation.nOperation |= 1; aEquation.nOperation |= 1;
...@@ -672,7 +648,7 @@ public: ...@@ -672,7 +648,7 @@ public:
rEquations.push_back( aEquation ); rEquations.push_back( aEquation );
} }
break; break;
case BINARY_FUNC_MIN : case ExpressionFunct::BinaryMin :
{ {
EnhancedCustomShapeEquation aEquation; EnhancedCustomShapeEquation aEquation;
aEquation.nOperation |= 4; aEquation.nOperation |= 4;
...@@ -683,7 +659,7 @@ public: ...@@ -683,7 +659,7 @@ public:
rEquations.push_back( aEquation ); rEquations.push_back( aEquation );
} }
break; break;
case BINARY_FUNC_MAX : case ExpressionFunct::BinaryMax :
{ {
EnhancedCustomShapeEquation aEquation; EnhancedCustomShapeEquation aEquation;
aEquation.nOperation |= 5; aEquation.nOperation |= 5;
...@@ -694,7 +670,7 @@ public: ...@@ -694,7 +670,7 @@ public:
rEquations.push_back( aEquation ); rEquations.push_back( aEquation );
} }
break; break;
case BINARY_FUNC_ATAN2: case ExpressionFunct::BinaryAtan2:
{ {
EnhancedCustomShapeEquation aEquation; EnhancedCustomShapeEquation aEquation;
aEquation.nOperation |= 8; aEquation.nOperation |= 8;
...@@ -741,7 +717,7 @@ public: ...@@ -741,7 +717,7 @@ public:
} }
virtual ExpressionFunct getType() const override virtual ExpressionFunct getType() const override
{ {
return TERNARY_FUNC_IF; return ExpressionFunct::TernaryIf;
} }
virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& rEquations, ExpressionNode* /*pOptionalArg*/, sal_uInt32 nFlags ) override virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& rEquations, ExpressionNode* /*pOptionalArg*/, sal_uInt32 nFlags ) override
{ {
...@@ -817,13 +793,13 @@ public: ...@@ -817,13 +793,13 @@ public:
/*double nVal = mnValue;*/ /*double nVal = mnValue;*/
switch( meFunct ) switch( meFunct )
{ {
case ENUM_FUNC_ADJUSTMENT : case ExpressionFunct::EnumAdjustment :
{ {
OUString aVal( rFirst + 1, rSecond - rFirst, RTL_TEXTENCODING_UTF8 ); OUString aVal( rFirst + 1, rSecond - rFirst, RTL_TEXTENCODING_UTF8 );
mxContext->maOperandStack.push( std::shared_ptr<ExpressionNode>( new AdjustmentExpression( *mxContext->mpCustoShape, aVal.toInt32() ) ) ); mxContext->maOperandStack.push( std::shared_ptr<ExpressionNode>( new AdjustmentExpression( *mxContext->mpCustoShape, aVal.toInt32() ) ) );
} }
break; break;
case ENUM_FUNC_EQUATION : case ExpressionFunct::EnumEquation :
{ {
OUString aVal( rFirst + 1, rSecond - rFirst, RTL_TEXTENCODING_UTF8 ); OUString aVal( rFirst + 1, rSecond - rFirst, RTL_TEXTENCODING_UTF8 );
mxContext->maOperandStack.push( std::shared_ptr<ExpressionNode>( new EquationExpression( *mxContext->mpCustoShape, aVal.toInt32() ) ) ); mxContext->maOperandStack.push( std::shared_ptr<ExpressionNode>( new EquationExpression( *mxContext->mpCustoShape, aVal.toInt32() ) ) );
...@@ -1019,34 +995,34 @@ public: ...@@ -1019,34 +995,34 @@ public:
using ::boost::spirit::real_parser; using ::boost::spirit::real_parser;
identifier = identifier =
str_p( "pi" )[ EnumFunctor(ENUM_FUNC_PI, self.getContext() ) ] str_p( "pi" )[ EnumFunctor(ExpressionFunct::EnumPi, self.getContext() ) ]
| str_p( "left" )[ EnumFunctor(ENUM_FUNC_LEFT, self.getContext() ) ] | str_p( "left" )[ EnumFunctor(ExpressionFunct::EnumLeft, self.getContext() ) ]
| str_p( "top" )[ EnumFunctor(ENUM_FUNC_TOP, self.getContext() ) ] | str_p( "top" )[ EnumFunctor(ExpressionFunct::EnumTop, self.getContext() ) ]
| str_p( "right" )[ EnumFunctor(ENUM_FUNC_RIGHT, self.getContext() ) ] | str_p( "right" )[ EnumFunctor(ExpressionFunct::EnumRight, self.getContext() ) ]
| str_p( "bottom" )[ EnumFunctor(ENUM_FUNC_BOTTOM, self.getContext() ) ] | str_p( "bottom" )[ EnumFunctor(ExpressionFunct::EnumBottom, self.getContext() ) ]
| str_p( "xstretch" )[ EnumFunctor(ENUM_FUNC_XSTRETCH, self.getContext() ) ] | str_p( "xstretch" )[ EnumFunctor(ExpressionFunct::EnumXStretch, self.getContext() ) ]
| str_p( "ystretch" )[ EnumFunctor(ENUM_FUNC_YSTRETCH, self.getContext() ) ] | str_p( "ystretch" )[ EnumFunctor(ExpressionFunct::EnumYStretch, self.getContext() ) ]
| str_p( "hasstroke" )[ EnumFunctor(ENUM_FUNC_HASSTROKE, self.getContext() ) ] | str_p( "hasstroke" )[ EnumFunctor(ExpressionFunct::EnumHasStroke, self.getContext() ) ]
| str_p( "hasfill" )[ EnumFunctor(ENUM_FUNC_HASFILL, self.getContext() ) ] | str_p( "hasfill" )[ EnumFunctor(ExpressionFunct::EnumHasFill, self.getContext() ) ]
| str_p( "width" )[ EnumFunctor(ENUM_FUNC_WIDTH, self.getContext() ) ] | str_p( "width" )[ EnumFunctor(ExpressionFunct::EnumWidth, self.getContext() ) ]
| str_p( "height" )[ EnumFunctor(ENUM_FUNC_HEIGHT, self.getContext() ) ] | str_p( "height" )[ EnumFunctor(ExpressionFunct::EnumHeight, self.getContext() ) ]
| str_p( "logwidth" )[ EnumFunctor(ENUM_FUNC_LOGWIDTH, self.getContext() ) ] | str_p( "logwidth" )[ EnumFunctor(ExpressionFunct::EnumLogWidth, self.getContext() ) ]
| str_p( "logheight" )[ EnumFunctor(ENUM_FUNC_LOGHEIGHT, self.getContext() ) ] | str_p( "logheight" )[ EnumFunctor(ExpressionFunct::EnumLogHeight, self.getContext() ) ]
; ;
unaryFunction = unaryFunction =
(str_p( "abs" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_ABS, self.getContext()) ] (str_p( "abs" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( ExpressionFunct::UnaryAbs, self.getContext()) ]
| (str_p( "sqrt" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_SQRT, self.getContext()) ] | (str_p( "sqrt" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( ExpressionFunct::UnarySqrt, self.getContext()) ]
| (str_p( "sin" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_SIN, self.getContext()) ] | (str_p( "sin" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( ExpressionFunct::UnarySin, self.getContext()) ]
| (str_p( "cos" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_COS, self.getContext()) ] | (str_p( "cos" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( ExpressionFunct::UnaryCos, self.getContext()) ]
| (str_p( "tan" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_TAN, self.getContext()) ] | (str_p( "tan" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( ExpressionFunct::UnaryTan, self.getContext()) ]
| (str_p( "atan" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_ATAN, self.getContext()) ] | (str_p( "atan" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( ExpressionFunct::UnaryAtan, self.getContext()) ]
; ;
binaryFunction = binaryFunction =
(str_p( "min" ) >> '(' >> additiveExpression >> ',' >> additiveExpression >> ')' )[ BinaryFunctionFunctor( BINARY_FUNC_MIN, self.getContext()) ] (str_p( "min" ) >> '(' >> additiveExpression >> ',' >> additiveExpression >> ')' )[ BinaryFunctionFunctor( ExpressionFunct::BinaryMin, self.getContext()) ]
| (str_p( "max" ) >> '(' >> additiveExpression >> ',' >> additiveExpression >> ')' )[ BinaryFunctionFunctor( BINARY_FUNC_MAX, self.getContext()) ] | (str_p( "max" ) >> '(' >> additiveExpression >> ',' >> additiveExpression >> ')' )[ BinaryFunctionFunctor( ExpressionFunct::BinaryMax, self.getContext()) ]
| (str_p( "atan2") >> '(' >> additiveExpression >> ',' >> additiveExpression >> ')' )[ BinaryFunctionFunctor( BINARY_FUNC_ATAN2,self.getContext()) ] | (str_p( "atan2") >> '(' >> additiveExpression >> ',' >> additiveExpression >> ')' )[ BinaryFunctionFunctor( ExpressionFunct::BinaryAtan2,self.getContext()) ]
; ;
ternaryFunction = ternaryFunction =
...@@ -1057,13 +1033,13 @@ public: ...@@ -1057,13 +1033,13 @@ public:
lexeme_d[ +( range_p('a','z') | range_p('A','Z') | range_p('0','9') ) ]; lexeme_d[ +( range_p('a','z') | range_p('A','Z') | range_p('0','9') ) ];
functionReference = functionReference =
(str_p( "?" ) >> funcRef_decl )[ EnumFunctor( ENUM_FUNC_EQUATION, self.getContext() ) ]; (str_p( "?" ) >> funcRef_decl )[ EnumFunctor( ExpressionFunct::EnumEquation, self.getContext() ) ];
modRef_decl = modRef_decl =
lexeme_d[ +( range_p('0','9') ) ]; lexeme_d[ +( range_p('0','9') ) ];
modifierReference = modifierReference =
(str_p( "$" ) >> modRef_decl )[ EnumFunctor( ENUM_FUNC_ADJUSTMENT, self.getContext() ) ]; (str_p( "$" ) >> modRef_decl )[ EnumFunctor( ExpressionFunct::EnumAdjustment, self.getContext() ) ];
basicExpression = basicExpression =
real_parser<double, custom_real_parser_policies<double> >()[ DoubleConstantFunctor(self.getContext()) ] real_parser<double, custom_real_parser_policies<double> >()[ DoubleConstantFunctor(self.getContext()) ]
...@@ -1077,21 +1053,21 @@ public: ...@@ -1077,21 +1053,21 @@ public:
; ;
unaryExpression = unaryExpression =
('-' >> basicExpression)[ UnaryFunctionFunctor( UNARY_FUNC_NEG, self.getContext()) ] ('-' >> basicExpression)[ UnaryFunctionFunctor( ExpressionFunct::UnaryNeg, self.getContext()) ]
| basicExpression | basicExpression
; ;
multiplicativeExpression = multiplicativeExpression =
unaryExpression unaryExpression
>> *( ('*' >> unaryExpression)[ BinaryFunctionFunctor( BINARY_FUNC_MUL, self.getContext()) ] >> *( ('*' >> unaryExpression)[ BinaryFunctionFunctor( ExpressionFunct::BinaryMul, self.getContext()) ]
| ('/' >> unaryExpression)[ BinaryFunctionFunctor( BINARY_FUNC_DIV, self.getContext()) ] | ('/' >> unaryExpression)[ BinaryFunctionFunctor( ExpressionFunct::BinaryDiv, self.getContext()) ]
) )
; ;
additiveExpression = additiveExpression =
multiplicativeExpression multiplicativeExpression
>> *( ('+' >> multiplicativeExpression)[ BinaryFunctionFunctor( BINARY_FUNC_PLUS, self.getContext()) ] >> *( ('+' >> multiplicativeExpression)[ BinaryFunctionFunctor( ExpressionFunct::BinaryPlus, self.getContext()) ]
| ('-' >> multiplicativeExpression)[ BinaryFunctionFunctor( BINARY_FUNC_MINUS, self.getContext()) ] | ('-' >> multiplicativeExpression)[ BinaryFunctionFunctor( ExpressionFunct::BinaryMinus, self.getContext()) ]
) )
; ;
......
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