1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef INCLUDED_SLIDESHOW_SMILFUNCTIONPARSER_HXX 29 #define INCLUDED_SLIDESHOW_SMILFUNCTIONPARSER_HXX 30 31 #include "expressionnode.hxx" 32 #include "slideshowexceptions.hxx" 33 34 #include <basegfx/range/b2drectangle.hxx> 35 36 #include <boost/noncopyable.hpp> 37 38 namespace rtl 39 { 40 class OUString; 41 } 42 43 /* Definition of SmilFunctionParser class */ 44 45 namespace slideshow 46 { 47 namespace internal 48 { 49 class SmilFunctionParser : private boost::noncopyable 50 { 51 public: 52 /** Parse a string containing a SMIL value. 53 54 This method parses a string representing 55 a fixed value (i.e. a value that does not 56 change by time). Due to the dynamic view 57 capabilities of the presentation engine, 58 this value can sometimes only be determined 59 during runtime of the animation (because 60 e.g. mixed screen/view coordinates are 61 involved), and is thus still returned as an 62 ExpressionNode object. An example for 63 such a case is the "Width+1.0" string, which 64 contains the width of the shape in user 65 coordinate space, and the screen width 66 in device coordinate space. 67 68 The following grammar is accepted by this method: 69 <code> 70 identifier = 'pi'|'e'|'X'|'Y'|'Width'|'Height' 71 72 function = 'abs'|'sqrt'|'sin'|'cos'|'tan'|'atan'|'acos'|'asin'|'exp'|'log' 73 74 basic_expression = 75 number | 76 identifier | 77 function '(' additive_expression ')' | 78 '(' additive_expression ')' 79 80 unary_expression = 81 '-' basic_expression | 82 basic_expression 83 84 multiplicative_expression = 85 unary_expression ( ( '*' unary_expression )* | 86 ( '/' unary_expression )* ) 87 88 additive_expression = 89 multiplicative_expression ( ( '+' multiplicative_expression )* | 90 ( '-' multiplicative_expression )* ) 91 92 </code> 93 94 @param rSmilValue 95 The string to parse 96 97 @param rRelativeShapeBounds 98 The bounds of the shape this SMIL value is to be 99 evaluated for. The bounds must be <em>relative</em> to 100 the page the shape is part of, i.e. within the [0,1] 101 range. This is necessary, since the string might 102 contain symbolic references to the shape bounding box. 103 104 @throws ParseError if an invalid expression is given. 105 106 @return the generated function object. 107 */ 108 static ExpressionNodeSharedPtr parseSmilValue( const ::rtl::OUString& rSmilValue, 109 const ::basegfx::B2DRectangle& rRelativeShapeBounds ); // throw ParseError 110 111 /** Parse a string containing a SMIL function. 112 113 This method parses a string representing 114 a possibly time-varying SMIL function. 115 116 The following grammar is accepted by this method: 117 <code> 118 identifier = 't'|'pi'|'e'|'X'|'Y'|'Width'|'Height' 119 120 function = 'abs'|'sqrt'|'sin'|'cos'|'tan'|'atan'|'acos'|'asin'|'exp'|'log' 121 122 basic_expression = 123 number | 124 identifier | 125 function '(' additive_expression ')' | 126 '(' additive_expression ')' 127 128 unary_expression = 129 '-' basic_expression | 130 basic_expression 131 132 multiplicative_expression = 133 unary_expression ( ( '*' unary_expression )* | 134 ( '/' unary_expression )* ) 135 136 additive_expression = 137 multiplicative_expression ( ( '+' multiplicative_expression )* | 138 ( '-' multiplicative_expression )* ) 139 140 </code> 141 142 @param rSmilFunction 143 The string to parse 144 145 @param rRelativeShapeBounds 146 The bounds of the shape this SMIL value is to be 147 evaluated for. The bounds must be <em>relative</em> to 148 the page the shape is part of, i.e. within the [0,1] 149 range. This is necessary, since the string might 150 contain symbolic references to the shape bounding box. 151 152 @throws ParseError if an invalid expression is given. 153 154 @return the generated function object. 155 */ 156 static ExpressionNodeSharedPtr parseSmilFunction( const ::rtl::OUString& rSmilFunction, 157 const ::basegfx::B2DRectangle& rRelativeShapeBounds ); // throw ParseError 158 159 private: 160 // disabled constructor/destructor, since this is 161 // supposed to be a singleton 162 SmilFunctionParser(); 163 }; 164 } 165 } 166 167 #endif /* INCLUDED_SLIDESHOW_SMILFUNCTIONPARSER_HXX */ 168