kformula/flake

AttributeManager.h

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2006 Martin Pfeiffer <hubipete@gmx.net> 
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef ATTRIBUTEMANAGER_H
00021 #define ATTRIBUTEMANAGER_H
00022 
00023 #include <QFont>
00024 #include "kformula_export.h"
00025 
00026 class KoViewConverter;
00027 class BasicElement;
00028 
00030 enum Align {
00031     Left ,
00032     Center ,
00033     Right ,
00034     Top ,
00035     Bottom ,
00036     BaseLine ,
00037     Axis ,
00038     InvalidAlign
00039 };
00040 
00041 class Length {
00042   public:
00043     enum Unit {
00044         Em, 
00045         Ex,     
00046         Px,     
00047         In,     
00048         Cm,     
00049         Mm,     
00050         Pt,     
00051         Pc,     
00052         Percentage, 
00053         None    
00054     };
00055 
00056     enum UnitType {
00057         NoType,
00058         Relative,
00059         Absolute,
00060         Pixel
00061     };
00062 
00063     Length() : value(0), unit(None), type(NoType) {};
00064     qreal value;
00065     Unit unit;
00066     UnitType type;
00067 };
00068 
00085 class KOFORMULA_EXPORT AttributeManager {
00086 public:
00088     AttributeManager();
00089 
00091     ~AttributeManager();
00092 
00099     QColor colorOf( const QString& attribute, const BasicElement* element  ) const;
00100 
00107     bool boolOf( const QString& attribute, const BasicElement* element ) const;
00108 
00115     double doubleOf( const QString& attribute, const BasicElement* element ) const;
00116 
00123     QList<double> doubleListOf( const QString& attribute,
00124                                 const BasicElement* element ) const;
00125 
00132     QString stringOf( const QString& attribute, const BasicElement* element ) const;
00133 
00140     Align alignOf( const QString& attribute, const BasicElement* element ) const;
00141 
00148     QList<Align> alignListOf( const QString& attribute, const BasicElement* element ) const;
00149 
00156     Qt::PenStyle penStyleOf( const QString& attribute, const BasicElement* element ) const;
00157 
00164     QList<Qt::PenStyle> penStyleListOf( const QString& attribute,
00165                                         const BasicElement* element ) const;
00166 
00176     int scriptLevel( const BasicElement* parent, int index ) const;
00177     
00179     double lineThickness( const BasicElement* element ) const;
00180 
00182     double layoutSpacing( const BasicElement* element ) const;
00183 
00189     double maxHeightOfChildren( const BasicElement* element ) const;
00190 
00196     double maxWidthOfChildren( const BasicElement* element ) const;
00197 
00199     Align parseAlign( const QString& value ) const;
00200 
00202     QFont font( const BasicElement* element ) const;
00203 
00205     void setViewConverter( KoViewConverter* converter );
00206 
00208     Qt::PenStyle parsePenStyle( const QString& value ) const;
00209 
00211     Length parseUnit( const QString& value, const BasicElement* element ) const;
00212 
00214     double lengthToPixels( Length length, const BasicElement* element, const QString &attribute) const;
00215 
00217     QString findValue( const QString& attribute, const BasicElement* element ) const;
00218 
00220     double parseMathSpace( const QString& value, const BasicElement *element ) const;
00221 
00223     KoViewConverter* m_viewConverter;
00224 };
00225 
00226 #endif // ATTRIBUTEMANAGER_H