kspread Library API Documentation

kspread_sheetprint.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>,
00003    2003 Philipp Müller <philipp.mueller@gmx.de>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #ifndef __kspread_sheetprint_h__
00022 #define __kspread_sheetprint_h__
00023 
00024 class KSpreadDoc;
00025 class KSpreadSelection;
00026 class KSpreadPrintNewPageEntry;
00027 class KoGenStyles;
00028 
00029 #include <qobject.h>
00030 #include <koUnit.h>
00031 #include <koffice_export.h>
00032 
00033 class KSPREAD_EXPORT KSpreadSheetPrint : public QObject
00034 {
00035     Q_OBJECT
00036 
00037 public:
00038 
00039     KSpreadSheetPrint( KSpreadSheet *sheet );
00040     ~KSpreadSheetPrint();
00041 
00042     QString saveOasisSheetStyleLayout( KoGenStyles &mainStyles );
00043 
00047     bool print( QPainter &painter, KPrinter *_printer );
00048 
00052     float prinsheetWidth()const { return m_paperWidth - m_leftBorder - m_rightBorder; }
00053 
00057     float prinsheetWidthPts()const { return MM_TO_POINT( prinsheetWidth() / m_dZoom ); }
00058 
00062     float prinsheetHeight()const { return m_paperHeight - m_topBorder - m_bottomBorder; }
00063 
00067     float prinsheetHeightPts()const { return MM_TO_POINT( prinsheetHeight() / m_dZoom ); }
00068 
00072     float paperHeight()const { return m_paperHeight; }
00076     float paperHeightPts()const { return MM_TO_POINT( m_paperHeight / m_dZoom ); }
00080     float paperWidth()const { return m_paperWidth; }
00084     float paperWidthPts()const { return MM_TO_POINT( m_paperWidth / m_dZoom ); }
00085 
00086     void setPaperHeight(float _val) { m_paperHeight=_val; }
00087     void setPaperWidth(float _val) { m_paperWidth=_val; }
00088 
00092     float leftBorder()const { return m_leftBorder; }
00096     float leftBorderPts()const { return MM_TO_POINT( m_leftBorder / m_dZoom ); }
00100     float rightBorder()const { return m_rightBorder; }
00104     float rightBorderPts()const { return MM_TO_POINT( m_rightBorder / m_dZoom ); }
00108     float topBorder()const { return m_topBorder; }
00112     float topBorderPts()const { return MM_TO_POINT( m_topBorder / m_dZoom ); }
00116     float bottomBorder()const { return m_bottomBorder; }
00120     float bottomBorderPts()const { return MM_TO_POINT( m_bottomBorder / m_dZoom ); }
00121 
00125     KoOrientation orientation()const { return m_orientation; }
00129     const char* orientationString() const;
00130 
00134     KoFormat paperFormat()const { return m_paperFormat; }
00138     QString paperFormatString()const;
00139 
00140     void setPaperFormat(KoFormat _format) {m_paperFormat=_format;}
00141 
00142     void setPaperOrientation(KoOrientation _orient);
00143 
00147     KoPageLayout paperLayout() const;
00148 
00152     void setPaperLayout( float _leftBorder, float _topBorder, float _rightBorder, float _bottomBoder,
00153                          KoFormat _paper, KoOrientation orientation );
00157     void setPaperLayout( float _leftBorder, float _topBorder, float _rightBorder, float _bottomBoder,
00158                          const QString& _paper, const QString& _orientation );
00159 
00160     QString headLeft( int _p, const QString &_t  )const { if ( m_headLeft.isNull() ) return "";
00161     return completeHeading( m_headLeft, _p, _t ); }
00162     QString headMid( int _p, const QString &_t )const { if ( m_headMid.isNull() ) return "";
00163     return completeHeading( m_headMid, _p, _t ); }
00164     QString headRight( int _p, const QString &_t )const { if ( m_headRight.isNull() ) return "";
00165     return completeHeading( m_headRight, _p, _t ); }
00166     QString footLeft( int _p, const QString &_t )const { if ( m_footLeft.isNull() ) return "";
00167     return completeHeading( m_footLeft, _p, _t ); }
00168     QString footMid( int _p, const QString &_t )const { if ( m_footMid.isNull() ) return "";
00169     return completeHeading( m_footMid, _p, _t ); }
00170     QString footRight( int _p, const QString &_t )const { if ( m_footRight.isNull() ) return "";
00171     return completeHeading( m_footRight, _p, _t ); }
00172 
00173     QString headLeft()const { if ( m_headLeft.isNull() ) return ""; return m_headLeft; }
00174     QString headMid()const { if ( m_headMid.isNull() ) return ""; return m_headMid; }
00175     QString headRight()const { if ( m_headRight.isNull() ) return ""; return m_headRight; }
00176     QString footLeft()const { if ( m_footLeft.isNull() ) return ""; return m_footLeft; }
00177     QString footMid()const { if ( m_footMid.isNull() ) return ""; return m_footMid; }
00178     QString footRight()const { if ( m_footRight.isNull() ) return ""; return m_footRight; }
00179 
00184     QRect printRange() const { return m_printRange; }
00189     void setPrintRange( const QRect &_printRange );
00190 
00195     int pageLimitX() const { return m_iPageLimitX; }
00196 
00201     int pageLimitY() const { return m_iPageLimitY; }
00202 
00208     void setPageLimitX( int pages );
00209 
00215     void setPageLimitY( int pages );
00216 
00220     void calculateZoomForPageLimitX();
00221 
00225     void calculateZoomForPageLimitY();
00226 
00231     QPair<int, int> printRepeatColumns() const { return m_printRepeatColumns; }
00237     void setPrintRepeatColumns( QPair<int, int> _printRepeatColumns );
00238 
00243     QPair<int, int> printRepeatRows() const { return m_printRepeatRows; }
00249     void setPrintRepeatRows( QPair<int, int> _printRepeatRows );
00250 
00256     bool isOnNewPageX( int _column );
00257 
00261     void updateNewPageX( int _column );
00262 
00268     bool isOnNewPageY( int _row );
00269 
00273     void updateNewPageY( int _row );
00274 
00278     void updateNewPageListX( int _col );
00279 
00283     void updateNewPageListY( int _row );
00284 
00291     void replaceHeadFootLineMacro ( QString &_text, const QString &_search, const QString &_replace );
00295     QString localizeHeadFootLine ( const QString &_text );
00299     QString delocalizeHeadFootLine ( const QString &_text );
00300 
00304     KoHeadFoot headFootLine() const;
00305 
00309     void setHeadFootLine( const QString &_headl, const QString &_headm, const QString &_headr,
00310                           const QString &_footl, const QString &_footm, const QString &_footr );
00311 
00315     bool printGrid() const { return m_bPrintGrid; }
00316 
00320     void setPrintGrid( bool _printGrid );
00321 
00325     bool printCommentIndicator() const { return m_bPrintCommentIndicator; }
00326 
00330     void setPrintCommentIndicator( bool _printCommentIndicator );
00331 
00335     bool printFormulaIndicator() const { return m_bPrintFormulaIndicator; }
00336 
00340     void setPrintFormulaIndicator( bool _printFormulaIndicator );
00341 
00345     void updatePrintRepeatColumnsWidth();
00346 
00350     void updatePrintRepeatRowsHeight();
00351 
00355     void definePrintRange(KSpreadSelection* selectionInfo);
00359     void resetPrintRange();
00360 
00364     void insertColumn( int col, int nbCol );
00368     void removeColumn( int col, int nbCol );
00372     void insertRow( int row, int nbRow );
00376     void removeRow( int row, int nbRow );
00377 
00383     void setZoom( double _zoom, bool checkPageLimit = true );
00384 
00388     double zoom() const { return m_dZoom; }
00389 
00393     bool pageNeedsPrinting( QRect& page_range );
00394 
00395 signals:
00396     void sig_updateView( KSpreadSheet *_sheet );
00397 
00398 private:
00399 
00400     KSpreadSheet * m_pSheet;
00401     KSpreadDoc * m_pDoc;
00402 
00418     void printPage( QPainter &_painter, const QRect& page_range,
00419                     const KoRect& view, const KoPoint _childOffset );
00420 
00424     void printRect( QPainter &painter, const KoPoint& topLeft,
00425                     const QRect& printRect, const KoRect& view,
00426                     QRegion &clipRegion );
00427 
00431     void printHeaderFooter( QPainter &painter, int pageNo );
00432 
00436     void calcPaperSize();
00437 
00441     QValueList<KSpreadPrintNewPageEntry>::iterator findNewPageColumn( int col );
00442 
00446     QValueList<KSpreadPrintNewPageEntry>::iterator findNewPageRow( int row );
00447 
00455     QString completeHeading( const QString &_data, int _page, const QString &_sheet ) const ;
00456 
00461     QRect cellsPrintRange();
00462 
00466     int pagesX( const QRect& cellsPrintRange );
00467 
00471     int pagesY( const QRect& cellsPrintRange );
00472 
00476     KoOrientation m_orientation;
00480     KoFormat m_paperFormat;
00485     float m_paperWidth;
00490     float m_paperHeight;
00494     float m_leftBorder;
00498     float m_rightBorder;
00502     float m_topBorder;
00506     float m_bottomBorder;
00507 
00512     QString m_headLeft;
00517     QString m_headRight;
00522     QString m_headMid;
00527     QString m_footLeft;
00532     QString m_footRight;
00537     QString m_footMid;
00538 
00542     uint m_uprintPages;
00543 
00547     QRect m_printRange;
00548 
00552     QPair<int, int> m_printRepeatColumns;
00553 
00557     QPair<int, int> m_printRepeatRows;
00558 
00562     bool m_bPrintGrid;
00563 
00567     bool m_bPrintFormulaIndicator;
00568 
00572     bool m_bPrintCommentIndicator;
00573 
00577     double m_dPrintRepeatColumnsWidth;
00581     double m_dPrintRepeatRowsHeight;
00582 
00586      QValueList<KSpreadPrintNewPageEntry> m_lnewPageListX;
00587 
00591      QValueList<KSpreadPrintNewPageEntry> m_lnewPageListY;
00592 
00596      int m_maxCheckedNewPageX;
00597 
00601      int m_maxCheckedNewPageY;
00602 
00606     double m_dZoom;
00607 
00612     int m_iPageLimitX;
00616     int m_iPageLimitY;
00617 };
00618 
00619 
00620 class KSpreadPrintNewPageEntry
00621 {
00622 public:
00623     KSpreadPrintNewPageEntry() :
00624         m_iStartItem( 0 ), m_iEndItem( 0 ), m_dSize( 0 ),
00625         m_dOffset( 0 ){}
00626 
00627     KSpreadPrintNewPageEntry( int startItem, int endItem = 0, double size = 0,
00628                               double offset = 0 ) :
00629         m_iStartItem( startItem ), m_iEndItem( endItem ), m_dSize( size ),
00630         m_dOffset( offset ) {}
00631 
00632     int startItem() const { return m_iStartItem; }
00633     void setStartItem( int startItem ) { m_iStartItem = startItem; }
00634 
00635     int endItem() const { return m_iEndItem; }
00636     void setEndItem( int endItem ) { m_iEndItem = endItem; }
00637 
00638     double size() const { return m_dSize; }
00639     void setSize( double size ) { m_dSize = size; }
00640 
00641     double offset() const { return m_dOffset; }
00642     void setOffset( double offset ) { m_dOffset = offset; }
00643 
00644     bool operator==( KSpreadPrintNewPageEntry const & entry ) const;
00645 
00646 
00647 private:
00648     int m_iStartItem;
00649     int m_iEndItem;
00650     double m_dSize;
00651     double m_dOffset;
00652 };
00653 
00654 #endif
00655 
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:24 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003