crashtesting: assert on reimport of docx export of ooo102874-2.doc
[LibreOffice.git] / slideshow / source / inc / smilfunctionparser.hxx
blobd2ef96abf52cc356d291e92da5f5b156c21dbbd9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
25 #include <basegfx/range/b2drectangle.hxx>
26 #include <rtl/ustring.hxx>
28 #include <memory>
31 /* Definition of SmilFunctionParser class */
33 namespace slideshow::internal
35 class SmilFunctionParser
37 public:
38 SmilFunctionParser() = delete;
39 SmilFunctionParser(const SmilFunctionParser&) = delete;
40 SmilFunctionParser& operator=(const SmilFunctionParser&) = delete;
42 /** Parse a string containing a SMIL value.
44 This method parses a string representing
45 a fixed value (i.e. a value that does not
46 change by time). Due to the dynamic view
47 capabilities of the presentation engine,
48 this value can sometimes only be determined
49 during runtime of the animation (because
50 e.g. mixed screen/view coordinates are
51 involved), and is thus still returned as an
52 ExpressionNode object. An example for
53 such a case is the "Width+1.0" string, which
54 contains the width of the shape in user
55 coordinate space, and the screen width
56 in device coordinate space.
58 The following grammar is accepted by this method:
59 <code>
60 identifier = 'pi'|'e'|'X'|'Y'|'Width'|'Height'
62 function = 'abs'|'sqrt'|'sin'|'cos'|'tan'|'atan'|'acos'|'asin'|'exp'|'log'
64 basic_expression =
65 number |
66 identifier |
67 function '(' additive_expression ')' |
68 '(' additive_expression ')'
70 unary_expression =
71 '-' basic_expression |
72 basic_expression
74 multiplicative_expression =
75 unary_expression ( ( '*' unary_expression )* |
76 ( '/' unary_expression )* )
78 additive_expression =
79 multiplicative_expression ( ( '+' multiplicative_expression )* |
80 ( '-' multiplicative_expression )* )
82 </code>
84 @param rSmilValue
85 The string to parse
87 @param rRelativeShapeBounds
88 The bounds of the shape this SMIL value is to be
89 evaluated for. The bounds must be <em>relative</em> to
90 the page the shape is part of, i.e. within the [0,1]
91 range. This is necessary, since the string might
92 contain symbolic references to the shape bounding box.
94 @throws ParseError if an invalid expression is given.
96 @return the generated function object.
98 static std::shared_ptr<ExpressionNode> const & parseSmilValue( const OUString& rSmilValue,
99 const ::basegfx::B2DRectangle& rRelativeShapeBounds ); // throw ParseError
101 /** Parse a string containing a SMIL function.
103 This method parses a string representing
104 a possibly time-varying SMIL function.
106 The following grammar is accepted by this method:
107 <code>
108 identifier = 't'|'pi'|'e'|'X'|'Y'|'Width'|'Height'
110 function = 'abs'|'sqrt'|'sin'|'cos'|'tan'|'atan'|'acos'|'asin'|'exp'|'log'
112 basic_expression =
113 number |
114 identifier |
115 function '(' additive_expression ')' |
116 '(' additive_expression ')'
118 unary_expression =
119 '-' basic_expression |
120 basic_expression
122 multiplicative_expression =
123 unary_expression ( ( '*' unary_expression )* |
124 ( '/' unary_expression )* )
126 additive_expression =
127 multiplicative_expression ( ( '+' multiplicative_expression )* |
128 ( '-' multiplicative_expression )* )
130 </code>
132 @param rSmilFunction
133 The string to parse
135 @param rRelativeShapeBounds
136 The bounds of the shape this SMIL value is to be
137 evaluated for. The bounds must be <em>relative</em> to
138 the page the shape is part of, i.e. within the [0,1]
139 range. This is necessary, since the string might
140 contain symbolic references to the shape bounding box.
142 @throws ParseError if an invalid expression is given.
144 @return the generated function object.
146 static std::shared_ptr<ExpressionNode> const & parseSmilFunction( const OUString& rSmilFunction,
147 const ::basegfx::B2DRectangle& rRelativeShapeBounds ); // throw ParseError
153 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_SMILFUNCTIONPARSER_HXX
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */