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 
00068     KChartPart * part() const { return m_part; }
00069 
00070     // ----------------------------------------------------------------
00071     // Reimplementation of selected KDChartParams methods
00072     ChartType  chartType() const            { return m_chartType; }
00073     void       setChartType( ChartType _type ) {
00074     m_chartType = _type;
00075     KDChartParams::setChartType( (KDChartParams::ChartType) _type );
00076     }
00077 
00078     // Data in rows or columns.
00079     DataDirection  dataDirection() const    { return m_dataDirection; }
00080     void           setDataDirection( DataDirection _dir ) {
00081     m_dataDirection = _dir;
00082     }
00083 
00084     QString    chartTypeToString( ChartType _type) const;
00085     ChartType  stringToChartType( const QString& string );
00086 
00087 
00088     bool       firstRowAsLabel() const { return m_firstRowAsLabel; }
00089     void       setFirstRowAsLabel( bool _val );
00090     bool       firstColAsLabel() const { return m_firstColAsLabel; }
00091     void       setFirstColAsLabel( bool _val );
00092 
00093     // Data area
00094     QString    dataArea() const    { return m_dataArea; }
00095     void       setDataArea( QString dataArea ) {
00096     m_dataArea = dataArea;
00097     }
00098 
00099 
00100     // ----------------------------------------------------------------
00101     // BAR CHART EXTENSIONS TO SUPPORT OPENDOCUMENT
00102 
00103 public slots:
00104 
00105     void setBarNumLines( int _numLines ) {
00106     m_barNumLines = _numLines;
00107     emit changed();
00108     }
00109 
00110     int barNumLines() const {
00111     return m_barNumLines;
00112     }
00113 
00114     // ----------------------------------------------------------------
00115 
00116  public:
00117 
00118     DCOPObject  *dcopObject();
00119 
00120     bool loadOasis( const QDomElement     &chartElem,
00121             KoOasisLoadingContext &loadingContext,
00122                     QString               &errorMessage,
00123             KoStore               *store );
00124     void saveOasis( KoXmlWriter* bodyWriter, KoGenStyles& mainStyles ) const;
00125 
00126  private:
00127     bool loadOasisPlotarea( const QDomElement     &plotareaElem,
00128                 KoOasisLoadingContext &loadingContext,
00129                 QString               &errorMessage );
00130     bool loadOasisAxis( const QDomElement         &axisElem,
00131             KoOasisLoadingContext     &loadingContext,
00132             QString                   &errorMessage,
00133             KDChartAxisParams::AxisPos axisPos );
00134     void loadOasisFont( KoOasisLoadingContext& context, QFont& font, QColor& color );
00135 
00136     void saveOasisPlotArea( KoXmlWriter* bodyWriter, KoGenStyles& mainStyles ) const;
00137     void saveOasisAxis( KoXmlWriter* bodyWriter, KoGenStyles& mainStyles,
00138                         KDChartAxisParams::AxisPos axisPos, 
00139             const char* axisName ) const;
00140     QString saveOasisFont( KoGenStyles& mainStyles, const QFont& font, 
00141                const QColor& color ) const;
00142     
00143  private:
00144     KChartPart    *m_part;
00145 
00146     // Info about the chart itself.
00147     ChartType      m_chartType;
00148 
00149     // Info about the data.
00150     DataDirection  m_dataDirection; // Rows or Columns
00151     bool           m_firstRowAsLabel;
00152     bool           m_firstColAsLabel;
00153 
00154     QString        m_dataArea;
00155 
00156     // Extensions to support OpenDocument
00157     int            m_barNumLines; // Number of lines in a bar chart.
00158 
00159     DCOPObject    *m_dcop;
00160 };
00161 
00162 }  //KChart namespace
00163 
00164 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys