LibreOffice Module svx (master) 1
EnhancedCustomShapeFunctionParser.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_SVX_ENHANCEDCUSTOMSHAPEFUNCTIONPARSER_HXX
21#define INCLUDED_SVX_ENHANCEDCUSTOMSHAPEFUNCTIONPARSER_HXX
22
23#include <config_options.h>
24#include <sal/config.h>
25#include <com/sun/star/drawing/EnhancedCustomShapeParameter.hpp>
26#include <memory>
27#include <ostream>
28#include <string_view>
29#include <vector>
30
31#include <svx/svxdllapi.h>
32
34{
35 sal_Int32 nOperation;
36 sal_Int32 nPara[ 3 ];
37
39 nOperation ( 0 )
40 {
41 nPara[ 0 ] = nPara[ 1 ] = nPara[ 2 ] = 0;
42 }
43};
44
46
47namespace EnhancedCustomShape {
48
50{
51 Const,
52
53 EnumPi,
55 EnumTop,
68
76
84
86};
87
88template< typename charT, typename traits >
89inline std::basic_ostream<charT, traits> & operator <<(
90 std::basic_ostream<charT, traits> & stream, const ExpressionFunct& eFunc )
91{
92 switch (eFunc)
93 {
94 case ExpressionFunct::Const : return stream << "const";
95
96 case ExpressionFunct::EnumPi : return stream << "pi";
97 case ExpressionFunct::EnumLeft : return stream << "left";
98 case ExpressionFunct::EnumTop : return stream << "top";
99 case ExpressionFunct::EnumRight : return stream << "right";
100 case ExpressionFunct::EnumBottom : return stream << "bottom";
101 case ExpressionFunct::EnumXStretch : return stream << "xstretch";
102 case ExpressionFunct::EnumYStretch : return stream << "ystretch";
103 case ExpressionFunct::EnumHasStroke : return stream << "hasstroke";
104 case ExpressionFunct::EnumHasFill : return stream << "hasfill";
105 case ExpressionFunct::EnumWidth : return stream << "width";
106 case ExpressionFunct::EnumHeight : return stream << "height";
107 case ExpressionFunct::EnumLogWidth : return stream << "logwidth";
108 case ExpressionFunct::EnumLogHeight : return stream << "logheight";
109 case ExpressionFunct::EnumAdjustment : return stream << "adjustment";
110 case ExpressionFunct::EnumEquation : return stream << "equation";
111
112 case ExpressionFunct::UnaryAbs : return stream << "abs";
113 case ExpressionFunct::UnarySqrt : return stream << "sqrt";
114 case ExpressionFunct::UnarySin : return stream << "sin";
115 case ExpressionFunct::UnaryCos : return stream << "cos";
116 case ExpressionFunct::UnaryTan : return stream << "tan";
117 case ExpressionFunct::UnaryAtan : return stream << "atan";
118 case ExpressionFunct::UnaryNeg : return stream << "neg";
119
120 case ExpressionFunct::BinaryPlus : return stream << "plus";
121 case ExpressionFunct::BinaryMinus : return stream << "minus";
122 case ExpressionFunct::BinaryMul : return stream << "mul";
123 case ExpressionFunct::BinaryDiv : return stream << "div";
124 case ExpressionFunct::BinaryMin : return stream << "min";
125 case ExpressionFunct::BinaryMax : return stream << "max";
126 case ExpressionFunct::BinaryAtan2 : return stream << "atan2";
127
128 case ExpressionFunct::TernaryIf : return stream << "if";
129
130 default: return stream << "?(" << static_cast<int>(eFunc) << ")";
131 }
132}
133
134#define EXPRESSION_FLAG_SUMANGLE_MODE 1
135
136SVXCORE_DLLPUBLIC void FillEquationParameter( const css::drawing::EnhancedCustomShapeParameter&, const sal_Int32, EnhancedCustomShapeEquation& );
137
138class SAL_DLLPUBLIC_RTTI ExpressionNode
139{
140public:
141 virtual ~ExpressionNode();
142
153 virtual bool isConstant() const = 0;
154
159 virtual double operator()() const = 0;
160
163 virtual ExpressionFunct getType() const = 0;
164
167 virtual css::drawing::EnhancedCustomShapeParameter fillNode(
168 std::vector< EnhancedCustomShapeEquation >& rEquations, ExpressionNode* pOptionalArg, sal_uInt32 nFlags ) = 0;
169};
170
175{
176 ParseError( const char* ) {}
177};
178
180{
181public:
182
237 UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) static std::shared_ptr<ExpressionNode> const & parseFunction( std::u16string_view rFunction, const EnhancedCustomShape2d& rCustoShape );
238
239 // this is a singleton
240 FunctionParser() = delete;
243};
244
245}
246
247#endif // INCLUDED_SVX_ENHANCEDCUSTOMSHAPEFUNCTIONPARSER_HXX
248
249/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::drawing::EnhancedCustomShapeParameter fillNode(std::vector< EnhancedCustomShapeEquation > &rEquations, ExpressionNode *pOptionalArg, sal_uInt32 nFlags)=0
Operator to retrieve the ms version of expression.
virtual double operator()() const =0
Operator to calculate function value.
virtual bool isConstant() const =0
Predicate whether this node is constant.
virtual ExpressionFunct getType() const =0
Operator to retrieve the type of expression node.
UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) static std FunctionParser()=delete
Parse a string.
FunctionParser & operator=(const FunctionParser &)=delete
FunctionParser(const FunctionParser &)=delete
Reference< XOutputStream > stream
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, const ExpressionFunct &eFunc)
SVXCORE_DLLPUBLIC void FillEquationParameter(const css::drawing::EnhancedCustomShapeParameter &, const sal_Int32, EnhancedCustomShapeEquation &)
ExpressionFunct
class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) OLocalExchange class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) OLocalExchangeHelper
a helper for navigator windows (SvTreeListBox'es) which allow DnD within themself
Definition: fmexch.hxx:86
This exception is thrown, when the arithmetic expression parser failed to parse a string.
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35