kspread Library API Documentation

kspread_format.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999  Torben Weis <weis@kde.org>
00003    Copyright (C) 2000 - 2003 The KSpread Team
00004                               www.koffice.org/kspread
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.
00020 */
00021 
00022 #ifndef __kspread_format_h__
00023 #define __kspread_format_h__
00024 
00025 class KSpreadSheet;
00026 class KSpreadCanvas;
00027 
00028 class QDomElement;
00029 class QDomDocument;
00030 class DCOPObject;
00031 class KoOasisStyles;
00032 class KoGenStyles;
00033 
00034 #include <qbrush.h>
00035 #include <qpen.h>
00036 #include <qcolor.h>
00037 #include <qfont.h>
00038 
00039 #include "kspread_global.h"
00040 #include <koffice_export.h>
00041 class KLocale;
00042 class KSpreadCurrency;
00043 class KSpreadStyle;
00044 class KoStyleStack;
00045 class KoGenStyle;
00046 
00049 class KSPREAD_EXPORT KSpreadFormat
00050 {
00051 public:
00052     enum Align { Left = 1, Center = 2, Right = 3, Undefined = 4 };
00053     enum AlignY { Top = 1, Middle = 2, Bottom = 3, UndefinedY = 4 };
00054     enum FloatFormat { AlwaysSigned = 1, AlwaysUnsigned = 2, OnlyNegSigned = 3 };
00055     enum FloatColor { NegRed = 1, AllBlack = 2, NegBrackets = 3, NegRedBrackets = 4 };
00056 
00057     enum Properties{ PAlign  = 0x01,
00058              PAlignY = 0x02,
00059          //PFactor was here
00060          PPrefix = 0x08,
00061              PPostfix = 0x10,
00062              PLeftBorder = 0x20,
00063              PRightBorder = 0x40,
00064              PTopBorder = 0x80,
00065              PBottomBorder = 0x100,
00066              PFallDiagonal = 0x200,
00067              PGoUpDiagonal = 0x400,
00068              PBackgroundBrush = 0x800,
00069              PFont = 0x1000,
00070              PTextPen = 0x2000,
00071              PBackgroundColor = 0x4000,
00072              PFloatFormat = 0x8000,
00073              PFloatColor = 0x10000,
00074              PMultiRow = 0x20000,
00075              PVerticalText = 0x40000,
00076                      PPrecision = 0x80000,
00077                      PFormatType = 0x100000,
00078                      PAngle = 0x200000,
00079                      PComment = 0x400000,
00080                      PIndent = 0x800000,
00081              PDontPrintText = 0x1000000,
00082                      PCustomFormat = 0x2000000,
00083                      PNotProtected = 0x4000000,
00084                      PHideAll = 0x8000000,
00085                      PHideFormula = 0x10000000 };
00086 
00087     struct Currency
00088     {
00089       int type;
00090       QString symbol;
00091     };
00092 
00096     KSpreadFormat( KSpreadSheet * _sheet, KSpreadStyle * _style );
00097     virtual ~KSpreadFormat();
00098 
00099     void copy( const KSpreadFormat & _l );
00100 
00101     void defaultStyleFormat();
00102 
00104     //
00105     // Loading and saving
00106     //
00108 
00109     bool load( const QDomElement & f, PasteMode pm, bool paste = false );
00110     bool loadFormat( const QDomElement & f, PasteMode pm = Normal, bool paste = false );
00111     QDomElement save( QDomDocument& doc,int _col, int _row,bool force = false, bool copy = false ) const;
00112     QDomElement saveFormat( QDomDocument& doc, bool force = false, bool copy = false ) const;
00113     QDomElement saveFormat( QDomDocument& doc, int _col, int _row, bool force = false, bool copy = false ) const;
00114     virtual bool loadOasisStyleProperties(KoStyleStack & styleStack, const KoOasisStyles& oasisStyles );
00115     virtual QString saveOasisCellStyle( KoGenStyle &currentCellStyle, KoGenStyles &mainStyle ,int _col, int _row , bool force = false, bool copy = false);
00116     virtual QString saveOasisCellStyle( KoGenStyle &currentCellStyle, KoGenStyles &mainStyle );
00117     void saveOasisFontCellStyle( KoGenStyle &currentCellStyle, const QFont &_font );
00118 
00119     bool loadFontOasisStyle( KoStyleStack & font );
00121     //
00122     // Properties
00123     //
00125     uint propertiesMask() { return m_mask; } // For the cell inspector only.
00126     void clearProperties();
00127     void clearProperty( Properties p );
00128 
00129     void clearNoFallBackProperties(  ) ;
00130     void clearNoFallBackProperties( Properties p ) ;
00131     void setNoFallBackProperties(Properties p);
00132     bool hasNoFallBackProperties( Properties p ) const ;
00133 
00135     //
00136     // Flags
00137     //
00139     enum FormatFlags{ Flag_MultiRow      = 0x00000001,
00140                       Flag_VerticalText  = 0x00000002,
00141                       Flag_DontPrintText = 0x00000004,
00142                       Flag_HideAll       = 0x00000008,
00143                       Flag_HideFormula   = 0x00000010,
00144                       Flag_NotProtected  = 0x00000020
00145                       /* reserve the bits 0xFFFF0000 for subclasses to use */
00146                     };
00147     void clearFlag( FormatFlags flag );
00148     void setFlag( FormatFlags flag );
00149     bool testFlag( FormatFlags flag ) const;
00150 
00151 
00153     //
00154     // Methods for setting format stuff.
00155     //
00157 
00158     static void setGlobalColWidth( double width );
00159     static void setGlobalRowHeight( double height );
00160     static double globalRowHeight();
00161     static double globalColWidth();
00162 
00163 
00164     virtual void setKSpreadStyle( KSpreadStyle * style );
00165 
00169     virtual void setFormatString( QString const & format );
00170 
00171     virtual void setAlign( Align _align );
00172     virtual void setAlignY( AlignY _alignY );
00173     virtual void setPrefix( const QString& _prefix );
00174     virtual void setPostfix( const QString& _postfix );
00175     virtual void setPrecision( int _p );
00176 
00177     virtual void setLeftBorderPen( const QPen& _p );
00178     void setLeftBorderStyle( Qt::PenStyle s );
00179     void setLeftBorderColor( const QColor & _c );
00180     void setLeftBorderWidth( int _w );
00181 
00182     virtual void setTopBorderPen( const QPen& _p );
00183     void setTopBorderStyle( Qt::PenStyle s );
00184     void setTopBorderColor( const QColor & _c );
00185     void setTopBorderWidth( int _w );
00186 
00187     virtual void setRightBorderPen( const QPen& p );
00188     void setRightBorderStyle( Qt::PenStyle _s );
00189     void setRightBorderColor( const QColor & _c );
00190     void setRightBorderWidth( int _w );
00191 
00192     virtual void setBottomBorderPen( const QPen& p );
00193     void setBottomBorderStyle( Qt::PenStyle _s );
00194     void setBottomBorderColor( const QColor & _c );
00195     void setBottomBorderWidth( int _w );
00196 
00197     virtual void setFallDiagonalPen( const QPen& _p );
00198     void setFallDiagonalStyle( Qt::PenStyle s );
00199     void setFallDiagonalColor( const QColor & _c );
00200     void setFallDiagonalWidth( int _w );
00201 
00202     virtual void setGoUpDiagonalPen( const QPen& _p );
00203     void setGoUpDiagonalStyle( Qt::PenStyle s );
00204     void setGoUpDiagonalColor( const QColor & _c );
00205     void setGoUpDiagonalWidth( int _w );
00206 
00207     virtual void setBackGroundBrush( const QBrush& _p);
00208     void setBackGroundBrushStyle( Qt::BrushStyle s);
00209     void setBackGroundBrushColor( const QColor & _c);
00210 
00211     virtual void setTextFont( const QFont& _f );
00212     void setTextFontSize( int _s );
00213     void setTextFontFamily( const QString& _f );
00214     void setTextFontBold( bool _b );
00215     void setTextFontItalic( bool _i );
00216     void setTextFontUnderline( bool _i );
00217     void setTextFontStrike( bool _i );
00218 
00219     virtual void setTextPen( const QPen& _p );
00220     void setTextColor( const QColor & _c );
00221 
00222     virtual void setBgColor( const QColor & _c );
00223 
00224     virtual void setFloatFormat( FloatFormat _f );
00225     virtual void setFloatColor( FloatColor _c );
00226 
00227     virtual void setMultiRow( bool _b );
00228 
00229     virtual void setVerticalText( bool _b );
00230 
00231     virtual void setFormatType(FormatType _format);
00232 
00233     virtual void setAngle(int _angle);
00234 
00235     virtual void setComment( const QString& c );
00236 
00237     virtual void setIndent( double _indent );
00238 
00239     virtual void setDontPrintText ( bool _b );
00240     virtual void setNotProtected ( bool _b );
00241     virtual void setHideAll( bool _b );
00242     virtual void setHideFormula( bool _b );
00243 
00244     virtual void setCurrency( Currency const & c );
00245     virtual void setCurrency( int type, QString const & symbol );
00246 
00248     //
00249     // Methods for querying format stuff.
00250     //
00252 
00253     QString const & getFormatString( int col, int row ) const;
00254 
00255     virtual const QPen& leftBorderPen( int col, int row ) const;
00256     int leftBorderWidth( int col, int row ) const;
00257     Qt::PenStyle leftBorderStyle( int col, int row ) const;
00258     const QColor& leftBorderColor( int col, int row ) const;
00259 
00260     virtual const QPen& topBorderPen( int col, int row ) const;
00261     int topBorderWidth( int col, int row ) const;
00262     Qt::PenStyle topBorderStyle( int col, int row ) const;
00263     const QColor& topBorderColor( int col, int row ) const;
00264 
00265     virtual const QPen& rightBorderPen( int col, int row ) const;
00266     int rightBorderWidth( int col, int row ) const;
00267     Qt::PenStyle rightBorderStyle( int col, int row ) const;
00268     const QColor& rightBorderColor( int col, int row ) const;
00269 
00270     virtual const QPen& bottomBorderPen( int col, int row ) const;
00271     int bottomBorderWidth( int col, int row ) const;
00272     Qt::PenStyle bottomBorderStyle( int col, int row ) const;
00273     const QColor& bottomBorderColor( int col, int row ) const;
00274 
00275     virtual const QPen& fallDiagonalPen( int col, int row ) const;
00276     int fallDiagonalWidth( int col, int row ) const;
00277     Qt::PenStyle fallDiagonalStyle( int col, int row ) const;
00278     const QColor& fallDiagonalColor( int col, int row ) const;
00279 
00280     virtual const QPen& goUpDiagonalPen( int col, int row ) const;
00281     int goUpDiagonalWidth( int col, int row ) const;
00282     Qt::PenStyle goUpDiagonalStyle( int col, int row ) const;
00283     const QColor& goUpDiagonalColor( int col, int row ) const;
00284 
00285     virtual const QBrush& backGroundBrush( int col, int row ) const;
00286     Qt::BrushStyle backGroundBrushStyle( int col, int row ) const;
00287     const QColor& backGroundBrushColor(int col, int row ) const;
00288 
00289     virtual uint bottomBorderValue( int col, int row ) const;
00290     virtual uint rightBorderValue( int col, int row ) const;
00291     virtual uint leftBorderValue( int col, int row ) const;
00292     virtual uint topBorderValue( int col, int row ) const;
00293 
00297     virtual int precision( int col, int row ) const;
00301     virtual QString prefix( int col, int row ) const;
00305     virtual QString postfix( int col, int row ) const;
00309     virtual FloatFormat floatFormat( int col, int row ) const;
00313     virtual FloatColor floatColor( int col, int row ) const;
00314 
00315     virtual const QPen& textPen( int col, int row ) const;
00319     const QColor& textColor( int col, int row ) const;
00320 
00327     virtual const QColor& bgColor( int col, int row ) const;
00328 
00329     virtual const QFont textFont( int col, int row ) const;
00330     int textFontSize( int col, int row ) const;
00331     QString const & textFontFamily( int col, int row ) const;
00332     bool textFontBold( int col, int row ) const;
00333     bool textFontItalic( int col, int row ) const;
00334     bool textFontUnderline( int col, int row ) const;
00335     bool textFontStrike( int col, int row ) const;
00336 
00337     virtual Align align( int col, int row ) const;
00338     virtual AlignY alignY( int col, int row ) const;
00339 
00340     virtual bool multiRow( int col, int row ) const;
00341 
00342     virtual bool verticalText( int col, int row ) const;
00343 
00344     virtual FormatType getFormatType(int col, int row )const ;
00345 
00346     virtual int getAngle(int col, int row) const;
00347 
00348     virtual QString comment(int col, int row) const;
00349     virtual QString * commentP( int col, int row ) const;
00350 
00351     virtual double getIndent(int col, int row) const;
00352 
00353     virtual bool getDontprintText( int col, int row) const;
00354     virtual bool notProtected( int col, int row) const;
00355     virtual bool isHideAll( int col, int row) const;
00356     virtual bool isHideFormula( int col, int row) const;
00357     virtual bool isProtected( int col, int row ) const;
00358 
00359     KSpreadStyle * kspreadStyle() const { return m_pStyle; }
00360     KSpreadSheet* sheet() { return m_pSheet; }
00361     const KSpreadSheet* sheet() const { return m_pSheet; }
00362 
00363     virtual bool hasProperty( Properties p, bool withoutParent = false ) const;
00364 
00369     virtual bool currencyInfo( Currency & currency) const;
00370 
00371     QString getCurrencySymbol() const;
00372     QFont font() const;
00373 
00374 protected:
00375     virtual const QPen& rightBorderPen() const;
00376     virtual const QPen& bottomBorderPen() const;
00377 
00381     virtual void formatChanged();
00382 
00386     virtual KSpreadFormat* fallbackFormat( int col, int row );
00390     virtual const KSpreadFormat* fallbackFormat( int col, int row ) const;
00391 
00395     virtual bool isDefault() const;
00396 
00397     KSpreadSheet * m_pSheet;
00398     KSpreadStyle * m_pStyle;
00399 
00400     uint m_mask;
00401 
00406     uint m_bNoFallBack;
00407 
00408     Q_UINT32 m_flagsMask;
00409 
00413     QString * m_strComment;
00414 
00415 private:
00416     void setProperty( Properties p );
00417 
00421     const QPen & leftBorderPen() const;
00422     const QPen & topBorderPen() const;
00423     const QPen & fallDiagonalPen() const;
00424     const QPen & goUpDiagonalPen() const;
00425     const QBrush & backGroundBrush() const;
00426     const QFont textFont() const;
00427     const QPen  & textPen() const;
00428 };
00429 
00432 class KSPREAD_EXPORT RowFormat : public KSpreadFormat
00433 {
00434 public:
00435     RowFormat( KSpreadSheet * _sheet, int _row );
00436     ~RowFormat();
00437 
00438     virtual DCOPObject* dcopObject();
00439 
00440     virtual QDomElement save( QDomDocument&, int yshift = 0, bool copy = false ) const;
00441     virtual bool load( const QDomElement& row, int yshift = 0, PasteMode sp = Normal, bool paste = false );
00442     virtual bool loadOasis( const QDomElement& row, QDomElement * rowStyle );
00443 
00449     int height( const KSpreadCanvas *_canvas = 0L ) const;
00456     double dblHeight( const KSpreadCanvas *_canvas = 0L ) const;
00460     double mmHeight() const;
00467     void setHeight( int _h, const KSpreadCanvas *_canvas = 0L );
00475     void setDblHeight( double _h, const KSpreadCanvas *_canvas = 0L );
00481     void setMMHeight( double _h );
00482 
00486     void setDefault() { m_bDefault = TRUE; }
00490     bool isDefault() const;
00491 
00497     int row() const { return m_iRow; }
00498 
00499     void setRow( int _r ) { m_iRow = _r; }
00500 
00501     void setDisplayDirtyFlag() { m_bDisplayDirtyFlag = true; }
00502     void clearDisplayDirtyFlag() { m_bDisplayDirtyFlag = false; }
00503 
00504     RowFormat* next() const { return m_next; }
00505     RowFormat* previous() const { return m_prev; }
00506     void setNext( RowFormat* c ) { m_next = c; }
00507     void setPrevious( RowFormat* c ) { m_prev = c; }
00508 
00512     const QPen& bottomBorderPen( int col, int row ) const;
00516     void setBottomBorderPen( const QPen& p );
00520     const QPen& topBorderPen( int col, int row ) const;
00524     void setTopBorderPen( const QPen& p );
00525 
00529     void setHide( bool _hide );
00530     bool isHide()const { return m_bHide;}
00531 
00532 protected:
00536     KSpreadFormat* fallbackFormat( int col, int row );
00540     const KSpreadFormat* fallbackFormat( int col, int row ) const;
00541 
00545     double m_fHeight;
00546 
00553     bool m_bDefault;
00560     int m_iRow;
00561 
00562     bool m_bDisplayDirtyFlag;
00563     bool m_bHide;
00564     RowFormat* m_next;
00565     RowFormat* m_prev;
00566     DCOPObject*m_dcop;
00567 };
00568 
00571 class KSPREAD_EXPORT ColumnFormat : public KSpreadFormat
00572 {
00573 public:
00574     ColumnFormat( KSpreadSheet *_sheet, int _column );
00575     ~ColumnFormat();
00576 
00577     virtual QDomElement save( QDomDocument&, int xshift = 0, bool copy = false ) const;
00578     virtual bool load( const QDomElement& row, int xshift = 0,PasteMode sp = Normal, bool paste = false );
00579     virtual DCOPObject* dcopObject();
00580 
00586     int width( const KSpreadCanvas *_canvas = 0L ) const;
00594     double dblWidth( const KSpreadCanvas *_canvas = 0L ) const;
00598     double mmWidth() const;
00606     void setWidth( int _w, const KSpreadCanvas *_canvas = 0L );
00615     void setDblWidth( double _w, const KSpreadCanvas *_canvas = 0L );
00621     void setMMWidth( double _w );
00622 
00626     void setDefault() { m_bDefault = TRUE; }
00630     bool isDefault() const;
00631 
00637     int column() const { return m_iColumn; }
00638 
00639     void setColumn( int _c ) { m_iColumn = _c; }
00640 
00641     void setDisplayDirtyFlag() { m_bDisplayDirtyFlag = true; }
00642     void clearDisplayDirtyFlag() { m_bDisplayDirtyFlag = false; }
00643 
00644     ColumnFormat* next() const { return m_next; }
00645     ColumnFormat* previous() const { return m_prev; }
00646     void setNext( ColumnFormat* c ) { m_next = c; }
00647     void setPrevious( ColumnFormat* c ) { m_prev = c; }
00648 
00652     const QPen& rightBorderPen( int col, int row ) const;
00656     void setRightBorderPen( const QPen& p );
00660     const QPen& leftBorderPen( int col, int row ) const;
00664     void setLeftBorderPen( const QPen& p );
00665 
00666     void setHide( bool _hide );
00667     bool isHide()const { return m_bHide;}
00668 
00669 
00670 protected:
00674     KSpreadFormat* fallbackFormat( int col, int row );
00678     const KSpreadFormat* fallbackFormat( int col, int row ) const;
00679 
00683     double m_fWidth;
00684 
00691     bool m_bDefault;
00698     int m_iColumn;
00699 
00700     bool m_bDisplayDirtyFlag;
00701 
00702     bool m_bHide;
00703 
00704     ColumnFormat* m_next;
00705     ColumnFormat* m_prev;
00706     DCOPObject*m_dcop;
00707 };
00708 
00709 class KSPREAD_EXPORT KSpreadCurrency
00710 {
00711  public:
00712 
00713   enum currencyFormat { Gnumeric, OpenCalc, ApplixSpread,
00714                         GobeProductiveSpread, HancomSheet };
00715 
00716   KSpreadCurrency();
00717   ~KSpreadCurrency();
00718 
00719   KSpreadCurrency(int index);
00720 
00724   KSpreadCurrency(int index, QString const & code);
00725 
00732   KSpreadCurrency(QString const & code, currencyFormat format);
00733   KSpreadCurrency & operator=(int type);
00734   KSpreadCurrency & operator=(char const * code);
00735   bool operator==(KSpreadCurrency const & cur) const;
00736   bool operator==(int type) const;
00737   operator int() const;
00738 
00739   QString getCode() const;
00740   QString getCountry() const;
00741   QString getName() const;
00742   QString getDisplayCode() const;
00743   int     getIndex() const;
00744 
00745   static QString getChooseString(int type, bool & ok);
00746   static QString getDisplaySymbol(int type);
00747   static QString getCurrencyCode( int type);
00748 
00752   QString getExportCode(currencyFormat format) const;
00753 
00754  private:
00755   int     m_type;
00756   QString m_code;
00757 };
00758 
00759 #endif
KDE Logo
This file is part of the documentation for kspread Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:43:09 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003