1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: smilfunctionparser.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_SLIDESHOW_SMILFUNCTIONPARSER_HXX
32 #define INCLUDED_SLIDESHOW_SMILFUNCTIONPARSER_HXX
34 #include "expressionnode.hxx"
35 #include "slideshowexceptions.hxx"
37 #include <basegfx/range/b2drectangle.hxx>
39 #include <boost/noncopyable.hpp>
46 /* Definition of SmilFunctionParser class */
52 class SmilFunctionParser
: private boost::noncopyable
55 /** Parse a string containing a SMIL value.
57 This method parses a string representing
58 a fixed value (i.e. a value that does not
59 change by time). Due to the dynamic view
60 capabilities of the presentation engine,
61 this value can sometimes only be determined
62 during runtime of the animation (because
63 e.g. mixed screen/view coordinates are
64 involved), and is thus still returned as an
65 ExpressionNode object. An example for
66 such a case is the "Width+1.0" string, which
67 contains the width of the shape in user
68 coordinate space, and the screen width
69 in device coordinate space.
71 The following grammar is accepted by this method:
73 identifier = 'pi'|'e'|'X'|'Y'|'Width'|'Height'
75 function = 'abs'|'sqrt'|'sin'|'cos'|'tan'|'atan'|'acos'|'asin'|'exp'|'log'
80 function '(' additive_expression ')' |
81 '(' additive_expression ')'
84 '-' basic_expression |
87 multiplicative_expression =
88 unary_expression ( ( '*' unary_expression )* |
89 ( '/' unary_expression )* )
92 multiplicative_expression ( ( '+' multiplicative_expression )* |
93 ( '-' multiplicative_expression )* )
100 @param rRelativeShapeBounds
101 The bounds of the shape this SMIL value is to be
102 evaluated for. The bounds must be <em>relative</em> to
103 the page the shape is part of, i.e. within the [0,1]
104 range. This is necessary, since the string might
105 contain symbolic references to the shape bounding box.
107 @throws ParseError if an invalid expression is given.
109 @return the generated function object.
111 static ExpressionNodeSharedPtr
parseSmilValue( const ::rtl::OUString
& rSmilValue
,
112 const ::basegfx::B2DRectangle
& rRelativeShapeBounds
); // throw ParseError
114 /** Parse a string containing a SMIL function.
116 This method parses a string representing
117 a possibly time-varying SMIL function.
119 The following grammar is accepted by this method:
121 identifier = 't'|'pi'|'e'|'X'|'Y'|'Width'|'Height'
123 function = 'abs'|'sqrt'|'sin'|'cos'|'tan'|'atan'|'acos'|'asin'|'exp'|'log'
128 function '(' additive_expression ')' |
129 '(' additive_expression ')'
132 '-' basic_expression |
135 multiplicative_expression =
136 unary_expression ( ( '*' unary_expression )* |
137 ( '/' unary_expression )* )
139 additive_expression =
140 multiplicative_expression ( ( '+' multiplicative_expression )* |
141 ( '-' multiplicative_expression )* )
148 @param rRelativeShapeBounds
149 The bounds of the shape this SMIL value is to be
150 evaluated for. The bounds must be <em>relative</em> to
151 the page the shape is part of, i.e. within the [0,1]
152 range. This is necessary, since the string might
153 contain symbolic references to the shape bounding box.
155 @throws ParseError if an invalid expression is given.
157 @return the generated function object.
159 static ExpressionNodeSharedPtr
parseSmilFunction( const ::rtl::OUString
& rSmilFunction
,
160 const ::basegfx::B2DRectangle
& rRelativeShapeBounds
); // throw ParseError
163 // disabled constructor/destructor, since this is
164 // supposed to be a singleton
165 SmilFunctionParser();
170 #endif /* INCLUDED_SLIDESHOW_SMILFUNCTIONPARSER_HXX */