1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef INCLUDED_SLIDESHOW_SMILFUNCTIONPARSER_HXX 25*b1cdbd2cSJim Jagielski #define INCLUDED_SLIDESHOW_SMILFUNCTIONPARSER_HXX 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include "expressionnode.hxx" 28*b1cdbd2cSJim Jagielski #include "slideshowexceptions.hxx" 29*b1cdbd2cSJim Jagielski 30*b1cdbd2cSJim Jagielski #include <basegfx/range/b2drectangle.hxx> 31*b1cdbd2cSJim Jagielski 32*b1cdbd2cSJim Jagielski #include <boost/noncopyable.hpp> 33*b1cdbd2cSJim Jagielski 34*b1cdbd2cSJim Jagielski namespace rtl 35*b1cdbd2cSJim Jagielski { 36*b1cdbd2cSJim Jagielski class OUString; 37*b1cdbd2cSJim Jagielski } 38*b1cdbd2cSJim Jagielski 39*b1cdbd2cSJim Jagielski /* Definition of SmilFunctionParser class */ 40*b1cdbd2cSJim Jagielski 41*b1cdbd2cSJim Jagielski namespace slideshow 42*b1cdbd2cSJim Jagielski { 43*b1cdbd2cSJim Jagielski namespace internal 44*b1cdbd2cSJim Jagielski { 45*b1cdbd2cSJim Jagielski class SmilFunctionParser : private boost::noncopyable 46*b1cdbd2cSJim Jagielski { 47*b1cdbd2cSJim Jagielski public: 48*b1cdbd2cSJim Jagielski /** Parse a string containing a SMIL value. 49*b1cdbd2cSJim Jagielski 50*b1cdbd2cSJim Jagielski This method parses a string representing 51*b1cdbd2cSJim Jagielski a fixed value (i.e. a value that does not 52*b1cdbd2cSJim Jagielski change by time). Due to the dynamic view 53*b1cdbd2cSJim Jagielski capabilities of the presentation engine, 54*b1cdbd2cSJim Jagielski this value can sometimes only be determined 55*b1cdbd2cSJim Jagielski during runtime of the animation (because 56*b1cdbd2cSJim Jagielski e.g. mixed screen/view coordinates are 57*b1cdbd2cSJim Jagielski involved), and is thus still returned as an 58*b1cdbd2cSJim Jagielski ExpressionNode object. An example for 59*b1cdbd2cSJim Jagielski such a case is the "Width+1.0" string, which 60*b1cdbd2cSJim Jagielski contains the width of the shape in user 61*b1cdbd2cSJim Jagielski coordinate space, and the screen width 62*b1cdbd2cSJim Jagielski in device coordinate space. 63*b1cdbd2cSJim Jagielski 64*b1cdbd2cSJim Jagielski The following grammar is accepted by this method: 65*b1cdbd2cSJim Jagielski <code> 66*b1cdbd2cSJim Jagielski identifier = 'pi'|'e'|'X'|'Y'|'Width'|'Height' 67*b1cdbd2cSJim Jagielski 68*b1cdbd2cSJim Jagielski function = 'abs'|'sqrt'|'sin'|'cos'|'tan'|'atan'|'acos'|'asin'|'exp'|'log' 69*b1cdbd2cSJim Jagielski 70*b1cdbd2cSJim Jagielski basic_expression = 71*b1cdbd2cSJim Jagielski number | 72*b1cdbd2cSJim Jagielski identifier | 73*b1cdbd2cSJim Jagielski function '(' additive_expression ')' | 74*b1cdbd2cSJim Jagielski '(' additive_expression ')' 75*b1cdbd2cSJim Jagielski 76*b1cdbd2cSJim Jagielski unary_expression = 77*b1cdbd2cSJim Jagielski '-' basic_expression | 78*b1cdbd2cSJim Jagielski basic_expression 79*b1cdbd2cSJim Jagielski 80*b1cdbd2cSJim Jagielski multiplicative_expression = 81*b1cdbd2cSJim Jagielski unary_expression ( ( '*' unary_expression )* | 82*b1cdbd2cSJim Jagielski ( '/' unary_expression )* ) 83*b1cdbd2cSJim Jagielski 84*b1cdbd2cSJim Jagielski additive_expression = 85*b1cdbd2cSJim Jagielski multiplicative_expression ( ( '+' multiplicative_expression )* | 86*b1cdbd2cSJim Jagielski ( '-' multiplicative_expression )* ) 87*b1cdbd2cSJim Jagielski 88*b1cdbd2cSJim Jagielski </code> 89*b1cdbd2cSJim Jagielski 90*b1cdbd2cSJim Jagielski @param rSmilValue 91*b1cdbd2cSJim Jagielski The string to parse 92*b1cdbd2cSJim Jagielski 93*b1cdbd2cSJim Jagielski @param rRelativeShapeBounds 94*b1cdbd2cSJim Jagielski The bounds of the shape this SMIL value is to be 95*b1cdbd2cSJim Jagielski evaluated for. The bounds must be <em>relative</em> to 96*b1cdbd2cSJim Jagielski the page the shape is part of, i.e. within the [0,1] 97*b1cdbd2cSJim Jagielski range. This is necessary, since the string might 98*b1cdbd2cSJim Jagielski contain symbolic references to the shape bounding box. 99*b1cdbd2cSJim Jagielski 100*b1cdbd2cSJim Jagielski @throws ParseError if an invalid expression is given. 101*b1cdbd2cSJim Jagielski 102*b1cdbd2cSJim Jagielski @return the generated function object. 103*b1cdbd2cSJim Jagielski */ 104*b1cdbd2cSJim Jagielski static ExpressionNodeSharedPtr parseSmilValue( const ::rtl::OUString& rSmilValue, 105*b1cdbd2cSJim Jagielski const ::basegfx::B2DRectangle& rRelativeShapeBounds ); // throw ParseError 106*b1cdbd2cSJim Jagielski 107*b1cdbd2cSJim Jagielski /** Parse a string containing a SMIL function. 108*b1cdbd2cSJim Jagielski 109*b1cdbd2cSJim Jagielski This method parses a string representing 110*b1cdbd2cSJim Jagielski a possibly time-varying SMIL function. 111*b1cdbd2cSJim Jagielski 112*b1cdbd2cSJim Jagielski The following grammar is accepted by this method: 113*b1cdbd2cSJim Jagielski <code> 114*b1cdbd2cSJim Jagielski identifier = 't'|'pi'|'e'|'X'|'Y'|'Width'|'Height' 115*b1cdbd2cSJim Jagielski 116*b1cdbd2cSJim Jagielski function = 'abs'|'sqrt'|'sin'|'cos'|'tan'|'atan'|'acos'|'asin'|'exp'|'log' 117*b1cdbd2cSJim Jagielski 118*b1cdbd2cSJim Jagielski basic_expression = 119*b1cdbd2cSJim Jagielski number | 120*b1cdbd2cSJim Jagielski identifier | 121*b1cdbd2cSJim Jagielski function '(' additive_expression ')' | 122*b1cdbd2cSJim Jagielski '(' additive_expression ')' 123*b1cdbd2cSJim Jagielski 124*b1cdbd2cSJim Jagielski unary_expression = 125*b1cdbd2cSJim Jagielski '-' basic_expression | 126*b1cdbd2cSJim Jagielski basic_expression 127*b1cdbd2cSJim Jagielski 128*b1cdbd2cSJim Jagielski multiplicative_expression = 129*b1cdbd2cSJim Jagielski unary_expression ( ( '*' unary_expression )* | 130*b1cdbd2cSJim Jagielski ( '/' unary_expression )* ) 131*b1cdbd2cSJim Jagielski 132*b1cdbd2cSJim Jagielski additive_expression = 133*b1cdbd2cSJim Jagielski multiplicative_expression ( ( '+' multiplicative_expression )* | 134*b1cdbd2cSJim Jagielski ( '-' multiplicative_expression )* ) 135*b1cdbd2cSJim Jagielski 136*b1cdbd2cSJim Jagielski </code> 137*b1cdbd2cSJim Jagielski 138*b1cdbd2cSJim Jagielski @param rSmilFunction 139*b1cdbd2cSJim Jagielski The string to parse 140*b1cdbd2cSJim Jagielski 141*b1cdbd2cSJim Jagielski @param rRelativeShapeBounds 142*b1cdbd2cSJim Jagielski The bounds of the shape this SMIL value is to be 143*b1cdbd2cSJim Jagielski evaluated for. The bounds must be <em>relative</em> to 144*b1cdbd2cSJim Jagielski the page the shape is part of, i.e. within the [0,1] 145*b1cdbd2cSJim Jagielski range. This is necessary, since the string might 146*b1cdbd2cSJim Jagielski contain symbolic references to the shape bounding box. 147*b1cdbd2cSJim Jagielski 148*b1cdbd2cSJim Jagielski @throws ParseError if an invalid expression is given. 149*b1cdbd2cSJim Jagielski 150*b1cdbd2cSJim Jagielski @return the generated function object. 151*b1cdbd2cSJim Jagielski */ 152*b1cdbd2cSJim Jagielski static ExpressionNodeSharedPtr parseSmilFunction( const ::rtl::OUString& rSmilFunction, 153*b1cdbd2cSJim Jagielski const ::basegfx::B2DRectangle& rRelativeShapeBounds ); // throw ParseError 154*b1cdbd2cSJim Jagielski 155*b1cdbd2cSJim Jagielski private: 156*b1cdbd2cSJim Jagielski // disabled constructor/destructor, since this is 157*b1cdbd2cSJim Jagielski // supposed to be a singleton 158*b1cdbd2cSJim Jagielski SmilFunctionParser(); 159*b1cdbd2cSJim Jagielski }; 160*b1cdbd2cSJim Jagielski } 161*b1cdbd2cSJim Jagielski } 162*b1cdbd2cSJim Jagielski 163*b1cdbd2cSJim Jagielski #endif /* INCLUDED_SLIDESHOW_SMILFUNCTIONPARSER_HXX */ 164