kchart

kchart_params.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001,2002,2003,2004 Laurent Montel <montel@kde.org>
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 
00021 #ifndef KCHART_PARAMS_H
00022 #define KCHART_PARAMS_H
00023 
00024 
00025 class KoXmlWriter;
00026 class KoGenStyles;
00027 class KoOasisLoadingContext;
00028 class KoStore;
00029 class KDChartParams;
00030 class DCOPObject;
00031 
00032 
00033 #include "kdchart/KDChartParams.h"
00034 
00035 
00036 namespace KChart
00037 {
00038 
00039 class KChartPart;
00040 
00041 class KChartParams : public KDChartParams
00042 {
00043   public:
00044     typedef enum {
00045     // From KDChart
00046     NoType     = KDChartParams::NoType,
00047     Bar        = KDChartParams::Bar,
00048     Line       = KDChartParams::Line,
00049     Area       = KDChartParams::Area,
00050     Pie        = KDChartParams::Pie,
00051     HiLo       = KDChartParams::HiLo,
00052     Ring       = KDChartParams::Ring,
00053     Polar      = KDChartParams::Polar,
00054     BoxWhisker = KDChartParams::BoxWhisker
00055 
00056     } ChartType;
00057 
00058     // Data direction
00059     typedef  enum {
00060     DataRows    = 0,
00061     DataColumns = 1
00062     } DataDirection;
00063 
00064 
00065     KChartParams( KChartPart *_part );
00066     ~KChartParams();
00067     // Reimplementation of selected KDChartParams methods
00068     ChartType  chartType() const            { return m_chartType; }
00069     void       setChartType( ChartType _type ) {
00070     m_chartType = _type;
00071     KDChartParams::setChartType( (KDChartParams::ChartType) _type );
00072     }
00073 
00074     // Data in rows or columns.
00075     DataDirection  dataDirection() const    { return m_dataDirection; }
00076     void           setDataDirection( DataDirection _dir ) {
00077     m_dataDirection = _dir;
00078     }
00079 
00080     QString    chartTypeToString( ChartType _type) const;
00081     ChartType  stringToChartType( const QString& string );
00082 
00083 
00084     bool       firstRowAsLabel() const { return m_firstRowAsLabel; }
00085     void       setFirstRowAsLabel( bool _val );
00086     bool       firstColAsLabel() const { return m_firstColAsLabel; }
00087     void       setFirstColAsLabel( bool _val );
00088 
00089     // ----------------------------------------------------------------
00090     // BAR CHART EXTENSIONS TO SUPPORT OPENDOCUMENT
00091 
00092 public slots:
00093 
00094     void setBarNumLines( int _numLines ) {
00095     m_barNumLines = _numLines;
00096     emit changed();
00097     }
00098 
00099     int barNumLines() const {
00100     return m_barNumLines;
00101     }
00102 
00103     // ----------------------------------------------------------------
00104 
00105  public:
00106 
00107     DCOPObject  *dcopObject();
00108 
00109     bool loadOasis( const QDomElement     &chartElem,
00110             KoOasisLoadingContext &loadingContext,
00111                     QString               &errorMessage,
00112             KoStore               *store );
00113     void saveOasis( KoXmlWriter* bodyWriter, KoGenStyles& mainStyles ) const;
00114 
00115  private:
00116     bool loadOasisPlotarea( const QDomElement     &plotareaElem,
00117                 KoOasisLoadingContext &loadingContext,
00118                 QString               &errorMessage );
00119     bool loadOasisAxis( const QDomElement         &axisElem,
00120             KoOasisLoadingContext     &loadingContext,
00121             QString                   &errorMessage,
00122             KDChartAxisParams::AxisPos axisPos );
00123     void loadOasisFont( KoOasisLoadingContext& context, QFont& font, QColor& color );
00124 
00125     void saveOasisPlotArea( KoXmlWriter* bodyWriter, KoGenStyles& mainStyles ) const;
00126     void saveOasisAxis( KoXmlWriter* bodyWriter, KoGenStyles& mainStyles,
00127                         KDChartAxisParams::AxisPos axisPos, const char* axisName ) const;
00128 
00129     QString saveOasisFont( KoGenStyles& mainStyles, const QFont& font, const QColor& color ) const;
00130     
00131  private:
00132     KChartPart    *m_part;
00133 
00134     // Info about the chart itself.
00135     ChartType      m_chartType;
00136 
00137     // Info about the data.
00138     DataDirection  m_dataDirection; // Rows or Columns
00139     bool           m_firstRowAsLabel;
00140     bool           m_firstColAsLabel;
00141 
00142     // Extensions to support OpenDocument
00143     int            m_barNumLines; // Number of lines in a bar chart.
00144 
00145     DCOPObject    *m_dcop;
00146 };
00147 
00148 }  //KChart namespace
00149 
00150 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys