File indexing completed on 2024-05-12 16:34:01

0001 /* This file is part of the KDE project
0002    Copyright (C) 2007 Martin Pfeiffer <hubipete@gmx.net>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008  
0009    This library is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013  
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LIB.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017    Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef DICTIONARY_H
0021 #define DICTIONARY_H
0022 
0023 #include <QString>
0024 #include <QChar>
0025 
0026 /** Enum encoding all states of  mo's form attribute */
0027 enum Form {
0028     Prefix /**< mo is a prefix*/,
0029     Infix /**< mo is a infix - used for all cases where it's not prefix or postfix*/,
0030     Postfix /**< mo is a postfix*/,
0031     InvalidForm
0032 };
0033 
0034 /**
0035  * @short Dictionary to look up operator attributes and entity mappings
0036  *
0037  * In section 3.2.5.2 of the MathML spec the numerous attributes for the mo element are
0038  * described. Further in section 3.2.5.7 the spec states that a MathML renderer should
0039  * have a dictionary to look up those attributes values. This class implements such a
0040  * dictionary by a script generated source file.
0041  * It also implements a lookup method for entities as MathML allows a number of them.
0042  * The method mapEntity maps a given "&...;" representation to the corresponding QChar.
0043  */
0044 class Dictionary {
0045 public:
0046     /// Standard constructor sets default values to operator attributes
0047     Dictionary();
0048 
0049     /// @return The mapped entity represented as a QChar
0050     QChar mapEntity( const QString& entity );
0051 
0052     bool queryOperator( const QString& queriedOperator, Form form );
0053 
0054     /// @return The form value of the currently queried operator
0055     Form form() const;
0056 
0057     /// @return The fence value of the currently queried operator
0058     bool fence() const;
0059 
0060     /// @return The separator value of the currently queried operator
0061     bool separator() const;
0062 
0063     /// @return The lspace value of the currently queried operator
0064     QString lSpace() const;
0065 
0066     /// @return The rspace value of the currently queried operator
0067     QString rSpace() const;
0068 
0069     /// @return The stretchy value of the currently queried operator
0070     bool stretchy() const;
0071 
0072     /// @return The symmetric value of the currently queried operator
0073     bool symmetric() const;
0074 
0075     /// @return The maxsize value of the currently queried operator
0076     qreal maxSize() const;
0077 
0078     /// @return The minsize value of the currently queried operator
0079     qreal minSize() const;
0080     bool largeOp() const;
0081     bool moveableLimits() const;
0082     bool accent() const;
0083 
0084 private:
0085     /// The queried operators form value
0086     Form m_form;
0087 
0088     /// The queried operators fence value
0089     bool m_fence;
0090 
0091     /// The queried operators separator value
0092     bool m_separator;
0093 
0094     /// The queried operators lspace value
0095     QString m_lspace;
0096 
0097     /// The queried operators rspace value
0098     QString m_rspace;
0099 
0100     /// The queried operators stretchy value
0101     bool m_stretchy;
0102 
0103     /// The queried operators symmetric value
0104     bool m_symmetric;
0105 
0106     /// The queried operators maxsize value
0107     QString m_maxsize;
0108 
0109     /// The queried operators minsize value
0110     QString m_minsize;
0111 
0112     /// The queried operators largeop value
0113     bool m_largeop;
0114 
0115     /// The queried operators movablelimits value
0116     bool m_movablelimits;
0117 
0118     /// The queried operators accent value
0119     bool m_accent;
0120 };
0121 
0122 #endif //DICTIONARY_H