1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SLIDESHOW_SOURCE_INC_SMILFUNCTIONPARSER_HXX
21 #define INCLUDED_SLIDESHOW_SOURCE_INC_SMILFUNCTIONPARSER_HXX
23 #include "expressionnode.hxx"
24 #include "slideshowexceptions.hxx"
26 #include <basegfx/range/b2drectangle.hxx>
28 #include <boost/noncopyable.hpp>
31 /* Definition of SmilFunctionParser class */
37 class SmilFunctionParser
: private boost::noncopyable
40 /** Parse a string containing a SMIL value.
42 This method parses a string representing
43 a fixed value (i.e. a value that does not
44 change by time). Due to the dynamic view
45 capabilities of the presentation engine,
46 this value can sometimes only be determined
47 during runtime of the animation (because
48 e.g. mixed screen/view coordinates are
49 involved), and is thus still returned as an
50 ExpressionNode object. An example for
51 such a case is the "Width+1.0" string, which
52 contains the width of the shape in user
53 coordinate space, and the screen width
54 in device coordinate space.
56 The following grammar is accepted by this method:
58 identifier = 'pi'|'e'|'X'|'Y'|'Width'|'Height'
60 function = 'abs'|'sqrt'|'sin'|'cos'|'tan'|'atan'|'acos'|'asin'|'exp'|'log'
65 function '(' additive_expression ')' |
66 '(' additive_expression ')'
69 '-' basic_expression |
72 multiplicative_expression =
73 unary_expression ( ( '*' unary_expression )* |
74 ( '/' unary_expression )* )
77 multiplicative_expression ( ( '+' multiplicative_expression )* |
78 ( '-' multiplicative_expression )* )
85 @param rRelativeShapeBounds
86 The bounds of the shape this SMIL value is to be
87 evaluated for. The bounds must be <em>relative</em> to
88 the page the shape is part of, i.e. within the [0,1]
89 range. This is necessary, since the string might
90 contain symbolic references to the shape bounding box.
92 @throws ParseError if an invalid expression is given.
94 @return the generated function object.
96 static ExpressionNodeSharedPtr
parseSmilValue( const OUString
& rSmilValue
,
97 const ::basegfx::B2DRectangle
& rRelativeShapeBounds
); // throw ParseError
99 /** Parse a string containing a SMIL function.
101 This method parses a string representing
102 a possibly time-varying SMIL function.
104 The following grammar is accepted by this method:
106 identifier = 't'|'pi'|'e'|'X'|'Y'|'Width'|'Height'
108 function = 'abs'|'sqrt'|'sin'|'cos'|'tan'|'atan'|'acos'|'asin'|'exp'|'log'
113 function '(' additive_expression ')' |
114 '(' additive_expression ')'
117 '-' basic_expression |
120 multiplicative_expression =
121 unary_expression ( ( '*' unary_expression )* |
122 ( '/' unary_expression )* )
124 additive_expression =
125 multiplicative_expression ( ( '+' multiplicative_expression )* |
126 ( '-' multiplicative_expression )* )
133 @param rRelativeShapeBounds
134 The bounds of the shape this SMIL value is to be
135 evaluated for. The bounds must be <em>relative</em> to
136 the page the shape is part of, i.e. within the [0,1]
137 range. This is necessary, since the string might
138 contain symbolic references to the shape bounding box.
140 @throws ParseError if an invalid expression is given.
142 @return the generated function object.
144 static ExpressionNodeSharedPtr
parseSmilFunction( const OUString
& rSmilFunction
,
145 const ::basegfx::B2DRectangle
& rRelativeShapeBounds
); // throw ParseError
148 // disabled constructor/destructor, since this is
149 // supposed to be a singleton
150 SmilFunctionParser();
155 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_SMILFUNCTIONPARSER_HXX
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */