22#ifndef __kspread_format_h__
23#define __kspread_format_h__
30#include <koffice_export.h>
32#include "kspread_global.h"
40class KoOasisLoadingContext;
54class KSPREAD_EXPORT Format
57 enum Align { Left = 1, Center = 2, Right = 3, Undefined = 4 };
58 enum AlignY { Top = 1, Middle = 2, Bottom = 3, UndefinedY = 4 };
59 enum FloatFormat { AlwaysSigned = 1, AlwaysUnsigned = 2, OnlyNegSigned = 3 };
60 enum FloatColor { NegRed = 1, AllBlack = 2, NegBrackets = 3, NegRedBrackets = 4 };
63 enum Properties{ PAlign = 0x01,
71 PBottomBorder = 0x100,
72 PFallDiagonal = 0x200,
73 PGoUpDiagonal = 0x400,
74 PBackgroundBrush = 0x800,
77 PBackgroundColor = 0x4000,
78 PFloatFormat = 0x8000,
79 PFloatColor = 0x10000,
81 PVerticalText = 0x40000,
83 PFormatType = 0x100000,
87 PDontPrintText = 0x1000000,
88 PCustomFormat = 0x2000000,
89 PNotProtected = 0x4000000,
91 PHideFormula = 0x10000000 };
108 Format( Sheet* sheet, Style* style );
116 void copy( const Format& other );
118 void defaultStyleFormat();
126 bool load( const TQDomElement & f, Paste::Mode pm, bool paste = false );
127 bool loadFormat( const TQDomElement & f, Paste::Mode pm = Paste::Normal, bool paste = false );
128 TQDomElement save( TQDomDocument& doc, int _col, int _row, bool force = false, bool copy = false ) const;
129 TQDomElement saveFormat( TQDomDocument& doc, bool force = false, bool copy = false ) const;
130 TQDomElement saveFormat( TQDomDocument& doc, int _col, int _row, bool force = false, bool copy = false ) const;
132 void loadOasisStyle( KoOasisLoadingContext& context );
133 bool loadOasisStyleProperties(KoStyleStack & styleStack, const KoOasisStyles& oasisStyles );
134 bool loadFontOasisStyle( KoStyleStack & font );
138 TQString saveOasisCellStyle( KoGenStyle ¤tCellStyle, KoGenStyles &mainStyle );
145 uint propertiesMask() { return m_mask; }
146 void clearProperties();
147 void clearProperty( Properties p );
149 void clearNoFallBackProperties( ) ;
150 void clearNoFallBackProperties( Properties p ) ;
151 void setNoFallBackProperties(Properties p);
152 bool hasNoFallBackProperties( Properties p ) const ;
159 enum FormatFlags{ Flag_MultiRow = 0x00000001,
160 Flag_VerticalText = 0x00000002,
161 Flag_DontPrintText = 0x00000004,
162 Flag_HideAll = 0x00000008,
163 Flag_HideFormula = 0x00000010,
164 Flag_NotProtected = 0x00000020
167 void clearFlag( FormatFlags flag );
168 void setFlag( FormatFlags flag );
169 bool testFlag( FormatFlags flag ) const;
178 static void setGlobalColWidth( double width );
179 static void setGlobalRowHeight( double height );
180 static double globalRowHeight();
181 static double globalColWidth();
184 void setStyle( Style * style );
185 void setCell( Cell* cell ) { m_pCell = cell; }
190 void setFormatString( TQString const & format );
192 void setAlign( Align _align );
193 void setAlignY( AlignY _alignY );
194 void setPrefix( const TQString& _prefix );
195 void setPostfix( const TQString& _postfix );
196 void setPrecision( int _p );
198 virtual void setLeftBorderPen( const TQPen& _p );
199 void setLeftBorderStyle( TQt::PenStyle s );
200 void setLeftBorderColor( const TQColor & _c );
201 void setLeftBorderWidth( int _w );
203 virtual void setTopBorderPen( const TQPen& _p );
204 void setTopBorderStyle( TQt::PenStyle s );
205 void setTopBorderColor( const TQColor & _c );
206 void setTopBorderWidth( int _w );
208 virtual void setRightBorderPen( const TQPen& p );
209 void setRightBorderStyle( TQt::PenStyle _s );
210 void setRightBorderColor( const TQColor & _c );
211 void setRightBorderWidth( int _w );
213 virtual void setBottomBorderPen( const TQPen& p );
214 void setBottomBorderStyle( TQt::PenStyle _s );
215 void setBottomBorderColor( const TQColor & _c );
216 void setBottomBorderWidth( int _w );
218 void setFallDiagonalPen( const TQPen& _p );
219 void setFallDiagonalStyle( TQt::PenStyle s );
220 void setFallDiagonalColor( const TQColor & _c );
221 void setFallDiagonalWidth( int _w );
223 void setGoUpDiagonalPen( const TQPen& _p );
224 void setGoUpDiagonalStyle( TQt::PenStyle s );
225 void setGoUpDiagonalColor( const TQColor & _c );
226 void setGoUpDiagonalWidth( int _w );
228 void setBackGroundBrush( const TQBrush& _p);
229 void setBackGroundBrushStyle( TQt::BrushStyle s);
230 void setBackGroundBrushColor( const TQColor & _c);
232 void setTextFont( const TQFont& _f );
233 void setTextFontSize( int _s );
234 void setTextFontFamily( const TQString& _f );
235 void setTextFontBold( bool _b );
236 void setTextFontItalic( bool _i );
237 void setTextFontUnderline( bool _i );
238 void setTextFontStrike( bool _i );
240 void setTextPen( const TQPen& _p );
241 void setTextColor( const TQColor & _c );
243 void setBgColor( const TQColor & _c );
245 void setFloatFormat( FloatFormat _f );
246 void setFloatColor( FloatColor _c );
248 void setMultiRow( bool _b );
250 void setVerticalText( bool _b );
252 void setFormatType(FormatType _format);
254 void setAngle( int _angle);
256 void setComment( const TQString& c );
258 void setIndent( double _indent );
260 void setDontPrintText( bool _b );
261 void setNotProtected( bool _b );
262 void setHideAll( bool _b );
263 void setHideFormula( bool _b );
265 void setCurrency( Currency const & c );
266 void setCurrency( int type, TQString const & symbol );
274 TQString const & getFormatString( int col, int row ) const;
276 virtual const TQPen& leftBorderPen( int col, int row ) const;
277 int leftBorderWidth( int col, int row ) const;
278 TQt::PenStyle leftBorderStyle( int col, int row ) const;
279 const TQColor& leftBorderColor( int col, int row ) const;
281 virtual const TQPen& topBorderPen( int col, int row ) const;
282 int topBorderWidth( int col, int row ) const;
283 TQt::PenStyle topBorderStyle( int col, int row ) const;
284 const TQColor& topBorderColor( int col, int row ) const;
286 virtual const TQPen& rightBorderPen( int col, int row ) const;
287 int rightBorderWidth( int col, int row ) const;
288 TQt::PenStyle rightBorderStyle( int col, int row ) const;
289 const TQColor& rightBorderColor( int col, int row ) const;
291 virtual const TQPen& bottomBorderPen( int col, int row ) const;
292 int bottomBorderWidth( int col, int row ) const;
293 TQt::PenStyle bottomBorderStyle( int col, int row ) const;
294 const TQColor& bottomBorderColor( int col, int row ) const;
296 const TQPen& fallDiagonalPen( int col, int row ) const;
297 int fallDiagonalWidth( int col, int row ) const;
298 TQt::PenStyle fallDiagonalStyle( int col, int row ) const;
299 const TQColor& fallDiagonalColor( int col, int row ) const;
301 const TQPen& goUpDiagonalPen( int col, int row ) const;
302 int goUpDiagonalWidth( int col, int row ) const;
303 TQt::PenStyle goUpDiagonalStyle( int col, int row ) const;
304 const TQColor& goUpDiagonalColor( int col, int row ) const;
306 const TQBrush& backGroundBrush( int col, int row ) const;
307 TQt::BrushStyle backGroundBrushStyle( int col, int row ) const;
308 const TQColor& backGroundBrushColor( int col, int row ) const;
310 uint bottomBorderValue( int col, int row ) const;
311 uint rightBorderValue( int col, int row ) const;
312 uint leftBorderValue( int col, int row ) const;
313 uint topBorderValue( int col, int row ) const;
318 int precision( int col, int row ) const;
322 TQString prefix( int col, int row ) const;
326 TQString postfix( int col, int row ) const;
330 FloatFormat floatFormat( int col, int row ) const;
334 FloatColor floatColor( int col, int row ) const;
336 const TQPen& textPen( int col, int row ) const;
340 const TQColor& textColor( int col, int row ) const;
348 const TQColor& bgColor( int col, int row ) const;
350 const TQFont textFont( int col, int row ) const;
351 int textFontSize( int col, int row ) const;
352 TQString const & textFontFamily( int col, int row ) const;
353 bool textFontBold( int col, int row ) const;
354 bool textFontItalic( int col, int row ) const;
355 bool textFontUnderline( int col, int row ) const;
356 bool textFontStrike( int col, int row ) const;
358 Align align( int col, int row ) const;
359 AlignY alignY( int col, int row ) const;
361 bool multiRow( int col, int row ) const;
363 bool verticalText( int col, int row ) const;
365 FormatType getFormatType( int col, int row ) const ;
367 int getAngle( int col, int row) const;
369 const TQString* comment() const { return m_strComment; };
370 TQString comment( int col, int row) const;
371 TQString * commentP( int col, int row ) const;
373 double getIndent( int col, int row) const;
375 bool getDontprintText( int col, int row) const;
376 bool notProtected( int col, int row) const;
377 bool isHideAll( int col, int row) const;
378 bool isHideFormula( int col, int row) const;
379 bool isProtected( int col, int row ) const;
381 Style* style() const { return m_pStyle; }
382 Sheet* sheet() { return m_pSheet; }
383 const Sheet* sheet() const { return m_pSheet; }
385 bool hasProperty( Properties p, bool withoutParent = false ) const;
391 bool currencyInfo( Currency & currency) const;
393 TQString getCurrencySymbol() const;
396 bool operator==( const Format& other ) const;
397 inline bool operator!=( const Format& other ) const { return !operator==( other ); }
400 const TQPen& rightBorderPen() const;
401 const TQPen& bottomBorderPen() const;
406 void formatChanged();
411 virtual Format* fallbackFormat( int col, int row );
415 virtual const Format* fallbackFormat( int col, int row ) const;
420 virtual bool isDefault() const;
433 TQ_UINT32 m_flagsMask;
438 TQString * m_strComment;
441 static double s_columnWidth;
442 static double s_rowHeight;
445 void setProperty( Properties p );
450 const TQPen & leftBorderPen() const;
451 const TQPen & topBorderPen() const;
452 const TQPen & fallDiagonalPen() const;
453 const TQPen & goUpDiagonalPen() const;
454 const TQBrush & backGroundBrush() const;
455 const TQFont textFont() const;
456 const TQPen & textPen() const;
463class KSPREAD_EXPORT RowFormat : public Format
466 RowFormat( Sheet * _sheet, int _row );
469 DCOPObject* dcopObject();
471 TQDomElement save( TQDomDocument&, int yshift = 0, bool copy = false ) const;
472 bool load( const TQDomElement& row, int yshift = 0, Paste::Mode sp = Paste::Normal, bool paste = false );
473 bool loadOasis( const TQDomElement& row, TQDomElement * rowStyle );
480 int height( const Canvas *_canvas = 0L ) const;
487 double dblHeight( const Canvas *_canvas = 0L ) const;
491 double mmHeight() const;
498 void setHeight( int _h, const Canvas *_canvas = 0L );
506 void setDblHeight( double _h, const Canvas *_canvas = 0L );
512 void setMMHeight( double _h );
517 void setDefault() { m_bDefault = true; }
521 virtual bool isDefault() const;
528 int row() const { return m_iRow; }
530 void setRow( int _r ) { m_iRow = _r; }
532 void setDisplayDirtyFlag() { m_bDisplayDirtyFlag = true; }
533 void clearDisplayDirtyFlag() { m_bDisplayDirtyFlag = false; }
535 RowFormat* next() const { return m_next; }
536 RowFormat* previous() const { return m_prev; }
537 void setNext( RowFormat* c ) { m_next = c; }
538 void setPrevious( RowFormat* c ) { m_prev = c; }
543 const TQPen& bottomBorderPen( int col, int row ) const;
547 void setBottomBorderPen( const TQPen& p );
551 const TQPen& topBorderPen( int col, int row ) const;
555 void setTopBorderPen( const TQPen& p );
560 void setHide( bool _hide, bool repaint = true );
561 bool isHide() const { return m_bHide;}
563 bool operator==( const RowFormat& other ) const;
564 inline bool operator!=( const RowFormat& other ) const { return !operator==( other ); }
570 virtual Format* fallbackFormat( int col, int row );
574 virtual const Format* fallbackFormat( int col, int row ) const;
596 bool m_bDisplayDirtyFlag;
605class KSPREAD_EXPORT ColumnFormat : public Format
608 ColumnFormat( Sheet *_sheet, int _column );
611 TQDomElement save( TQDomDocument&, int xshift = 0, bool copy = false ) const;
612 bool load( const TQDomElement& row, int xshift = 0,Paste::Mode sp = Paste::Normal, bool paste = false );
613 DCOPObject* dcopObject();
620 int width( const Canvas *_canvas = 0L ) const;
628 double dblWidth( const Canvas *_canvas = 0L ) const;
632 double mmWidth() const;
640 void setWidth( int _w, const Canvas *_canvas = 0L );
649 void setDblWidth( double _w, const Canvas *_canvas = 0L );
655 void setMMWidth( double _w );
660 void setDefault() { m_bDefault = true; }
664 virtual bool isDefault() const;
671 int column() const { return m_iColumn; }
673 void setColumn( int _c ) { m_iColumn = _c; }
675 void setDisplayDirtyFlag() { m_bDisplayDirtyFlag = true; }
676 void clearDisplayDirtyFlag() { m_bDisplayDirtyFlag = false; }
678 ColumnFormat* next() const { return m_next; }
679 ColumnFormat* previous() const { return m_prev; }
680 void setNext( ColumnFormat* c ) { m_next = c; }
681 void setPrevious( ColumnFormat* c ) { m_prev = c; }
686 virtual const TQPen& rightBorderPen( int col, int row ) const;
690 virtual void setRightBorderPen( const TQPen& p );
694 virtual const TQPen& leftBorderPen( int col, int row ) const;
698 virtual void setLeftBorderPen( const TQPen& p );
700 void setHide( bool _hide );
701 bool isHide() const { return m_bHide;}
703 bool operator==( const ColumnFormat& other ) const;
704 inline bool operator!=( const ColumnFormat& other ) const { return !operator==( other ); }
710 Format* fallbackFormat( int col, int row );
714 const Format* fallbackFormat( int col, int row ) const;
736 bool m_bDisplayDirtyFlag;
740 ColumnFormat* m_next;
741 ColumnFormat* m_prev;
745class KSPREAD_EXPORT Currency
749 enum currencyFormat { Native, Gnumeric, OpenCalc, ApplixSpread,
750 GobeProductiveSpread, HancomSheet };
760 Currency( int index, TQString const & code);
768 Currency(TQString const & code, currencyFormat format = Native);
769 Currency & operator=( int type);
770 Currency & operator=( char const * code);
771 bool operator==(Currency const & cur) const;
772 bool operator==( int type) const;
773 operator int() const;
775 TQString getCode() const;
776 TQString getCountry() const;
777 TQString getName() const;
778 TQString getDisplayCode() const;
779 int getIndex() const;
781 static TQString getChooseString( int type, bool & ok);
782 static TQString getDisplaySymbol( int type);
783 static TQString getCurrencyCode( int type);
788 TQString getExportCode(currencyFormat format) const;
The canvas builds a part of the GUI of KSpread.
For every cell in the spread sheet there is a Cell object.
The Style class represents a cell style.
|