kspread

kspread_sheetprint.h
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>,
3 2003 Philipp Mller <philipp.mueller@gmx.de>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef __kspread_sheetprint_h__
22#define __kspread_sheetprint_h__
23
24#include <tqobject.h>
25
26#include <koffice_export.h>
27#include <KoUnit.h>
28
29class KoGenStyles;
30
31namespace KSpread
32{
33class Doc;
34class Selection;
35class PrintNewPageEntry;
36class PrintObject;
37
38class KSPREAD_EXPORT SheetPrint : public TQObject
39{
40 TQ_OBJECT
41
42
43public:
44
45 SheetPrint( Sheet *sheet );
46 ~SheetPrint();
47
48 TQString saveOasisSheetStyleLayout( KoGenStyles &mainStyles );
49
53 bool print( TQPainter &painter, KPrinter *_printer );
54
58 float prinsheetWidth()const { return m_paperWidth - m_leftBorder - m_rightBorder; }
59
63 float prinsheetWidthPts()const { return MM_TO_POINT( prinsheetWidth() / m_dZoom ); }
64
68 float prinsheetHeight()const { return m_paperHeight - m_topBorder - m_bottomBorder; }
69
73 float prinsheetHeightPts()const { return MM_TO_POINT( prinsheetHeight() / m_dZoom ); }
74
78 float paperHeight()const { return m_paperHeight; }
82 float paperHeightPts()const { return MM_TO_POINT( m_paperHeight / m_dZoom ); }
86 float paperWidth()const { return m_paperWidth; }
90 float paperWidthPts()const { return MM_TO_POINT( m_paperWidth / m_dZoom ); }
91
92 void setPaperHeight(float _val) { m_paperHeight=_val; }
93 void setPaperWidth(float _val) { m_paperWidth=_val; }
94
98 float leftBorder()const { return m_leftBorder; }
102 float leftBorderPts()const { return MM_TO_POINT( m_leftBorder / m_dZoom ); }
106 float rightBorder()const { return m_rightBorder; }
110 float rightBorderPts()const { return MM_TO_POINT( m_rightBorder / m_dZoom ); }
114 float topBorder()const { return m_topBorder; }
118 float topBorderPts()const { return MM_TO_POINT( m_topBorder / m_dZoom ); }
122 float bottomBorder()const { return m_bottomBorder; }
126 float bottomBorderPts()const { return MM_TO_POINT( m_bottomBorder / m_dZoom ); }
127
131 KoOrientation orientation()const { return m_orientation; }
135 const char* orientationString() const;
136
140 KoFormat paperFormat()const { return m_paperFormat; }
144 TQString paperFormatString()const;
145
146 void setPaperFormat(KoFormat _format) {m_paperFormat=_format;}
147
148 void setPaperOrientation(KoOrientation _orient);
149
153 KoPageLayout paperLayout() const;
154
158 void setPaperLayout( float _leftBorder, float _topBorder, float _rightBorder, float _bottomBoder,
159 KoFormat _paper, KoOrientation orientation );
163 void setPaperLayout( float _leftBorder, float _topBorder, float _rightBorder, float _bottomBoder,
164 const TQString& _paper, const TQString& _orientation );
165
166 TQString headLeft( int _p, const TQString &_t )const { if ( m_headLeft.isNull() ) return "";
167 return completeHeading( m_headLeft, _p, _t ); }
168 TQString headMid( int _p, const TQString &_t )const { if ( m_headMid.isNull() ) return "";
169 return completeHeading( m_headMid, _p, _t ); }
170 TQString headRight( int _p, const TQString &_t )const { if ( m_headRight.isNull() ) return "";
171 return completeHeading( m_headRight, _p, _t ); }
172 TQString footLeft( int _p, const TQString &_t )const { if ( m_footLeft.isNull() ) return "";
173 return completeHeading( m_footLeft, _p, _t ); }
174 TQString footMid( int _p, const TQString &_t )const { if ( m_footMid.isNull() ) return "";
175 return completeHeading( m_footMid, _p, _t ); }
176 TQString footRight( int _p, const TQString &_t )const { if ( m_footRight.isNull() ) return "";
177 return completeHeading( m_footRight, _p, _t ); }
178
179 TQString headLeft()const { if ( m_headLeft.isNull() ) return ""; return m_headLeft; }
180 TQString headMid()const { if ( m_headMid.isNull() ) return ""; return m_headMid; }
181 TQString headRight()const { if ( m_headRight.isNull() ) return ""; return m_headRight; }
182 TQString footLeft()const { if ( m_footLeft.isNull() ) return ""; return m_footLeft; }
183 TQString footMid()const { if ( m_footMid.isNull() ) return ""; return m_footMid; }
184 TQString footRight()const { if ( m_footRight.isNull() ) return ""; return m_footRight; }
185
190 TQRect printRange() const { return m_printRange; }
195 void setPrintRange( const TQRect &_printRange );
196
201 int pageLimitX() const { return m_iPageLimitX; }
202
207 int pageLimitY() const { return m_iPageLimitY; }
208
214 void setPageLimitX( int pages );
215
221 void setPageLimitY( int pages );
222
226 void calculateZoomForPageLimitX();
227
231 void calculateZoomForPageLimitY();
232
237 TQPair<int, int> printRepeatColumns() const { return m_printRepeatColumns; }
243 void setPrintRepeatColumns( TQPair<int, int> _printRepeatColumns );
244
249 TQPair<int, int> printRepeatRows() const { return m_printRepeatRows; }
255 void setPrintRepeatRows( TQPair<int, int> _printRepeatRows );
256
262 bool isOnNewPageX( int _column );
263
267 void updateNewPageX( int _column );
268
274 bool isOnNewPageY( int _row );
275
279 void updateNewPageY( int _row );
280
284 void updateNewPageListX( int _col );
285
289 void updateNewPageListY( int _row );
290
297 void replaceHeadFootLineMacro ( TQString &_text, const TQString &_search, const TQString &_replace );
301 TQString localizeHeadFootLine ( const TQString &_text );
305 TQString delocalizeHeadFootLine ( const TQString &_text );
306
310 KoHeadFoot headFootLine() const;
311
315 void setHeadFootLine( const TQString &_headl, const TQString &_headm, const TQString &_headr,
316 const TQString &_footl, const TQString &_footm, const TQString &_footr );
317
321 bool printGrid() const { return m_bPrintGrid; }
322
326 void setPrintGrid( bool _printGrid );
327
331 bool printObjects() const { return m_bPrintObjects; }
332
336 void setPrintObjects( bool _printObjects );
337
341 bool printCharts() const { return m_bPrintCharts; }
342
346 void setPrintCharts( bool _printCharts );
347
351 bool printGraphics() const { return m_bPrintGraphics; }
352
356 void setPrintGraphics( bool _printGraphics );
357
361 bool printCommentIndicator() const { return m_bPrintCommentIndicator; }
362
366 void setPrintCommentIndicator( bool _printCommentIndicator );
367
371 bool printFormulaIndicator() const { return m_bPrintFormulaIndicator; }
372
376 void setPrintFormulaIndicator( bool _printFormulaIndicator );
377
381 void updatePrintRepeatColumnsWidth();
382
386 void updatePrintRepeatRowsHeight();
387
391 void definePrintRange(Selection* selectionInfo);
395 void resetPrintRange();
396
400 void insertColumn( int col, int nbCol );
404 void removeColumn( int col, int nbCol );
408 void insertRow( int row, int nbRow );
412 void removeRow( int row, int nbRow );
413
419 void setZoom( double _zoom, bool checkPageLimit = true );
420
424 double zoom() const { return m_dZoom; }
425
429 bool pageNeedsPrinting( TQRect& page_range );
430
431signals:
432 void sig_updateView( Sheet *_sheet );
433
434private:
435
436 Sheet * m_pSheet;
437 Doc * m_pDoc;
438
454 void printPage( TQPainter &_painter, const TQRect& page_range,
455 const KoRect& view, const KoPoint _childOffset );
456
460 void printRect( TQPainter &painter, const KoPoint& topLeft,
461 const TQRect& printRect, const KoRect& view,
462 TQRegion &clipRegion );
463
467 void printHeaderFooter( TQPainter &painter, int pageNo );
468
472 void calcPaperSize();
473
477 TQValueList<PrintNewPageEntry>::iterator findNewPageColumn( int col );
478
482 TQValueList<PrintNewPageEntry>::iterator findNewPageRow( int row );
483
491 TQString completeHeading( const TQString &_data, int _page, const TQString &_sheet ) const ;
492
497 TQRect cellsPrintRange();
498
502 int pagesX( const TQRect& cellsPrintRange );
503
507 int pagesY( const TQRect& cellsPrintRange );
508
512 KoOrientation m_orientation;
516 KoFormat m_paperFormat;
521 float m_paperWidth;
526 float m_paperHeight;
530 float m_leftBorder;
534 float m_rightBorder;
538 float m_topBorder;
542 float m_bottomBorder;
543
548 TQString m_headLeft;
553 TQString m_headRight;
558 TQString m_headMid;
563 TQString m_footLeft;
568 TQString m_footRight;
573 TQString m_footMid;
574
578 uint m_uprintPages;
579
583 TQRect m_printRange;
584
588 TQPair<int, int> m_printRepeatColumns;
589
593 TQPair<int, int> m_printRepeatRows;
594
598 bool m_bPrintGrid;
599
603 bool m_bPrintObjects;
604
608 bool m_bPrintCharts;
609
613 bool m_bPrintGraphics;
614
618 bool m_bPrintFormulaIndicator;
619
623 bool m_bPrintCommentIndicator;
624
628 double m_dPrintRepeatColumnsWidth;
632 double m_dPrintRepeatRowsHeight;
633
637 TQValueList<PrintNewPageEntry> m_lnewPageListX;
638
642 TQValueList<PrintNewPageEntry> m_lnewPageListY;
643
647 int m_maxCheckedNewPageX;
648
652 int m_maxCheckedNewPageY;
653
657 double m_dZoom;
658
663 int m_iPageLimitX;
667 int m_iPageLimitY;
668
669 TQValueList<PrintObject*> m_printObjects;
670};
671
672
673class PrintNewPageEntry
674{
675public:
676 PrintNewPageEntry() :
677 m_iStartItem( 0 ), m_iEndItem( 0 ), m_dSize( 0 ),
678 m_dOffset( 0 ){}
679
680 PrintNewPageEntry( int startItem, int endItem = 0, double size = 0,
681 double offset = 0 ) :
682 m_iStartItem( startItem ), m_iEndItem( endItem ), m_dSize( size ),
683 m_dOffset( offset ) {}
684
685 int startItem() const { return m_iStartItem; }
686 void setStartItem( int startItem ) { m_iStartItem = startItem; }
687
688 int endItem() const { return m_iEndItem; }
689 void setEndItem( int endItem ) { m_iEndItem = endItem; }
690
691 double size() const { return m_dSize; }
692 void setSize( double size ) { m_dSize = size; }
693
694 double offset() const { return m_dOffset; }
695 void setOffset( double offset ) { m_dOffset = offset; }
696
697 bool operator==( PrintNewPageEntry const & entry ) const;
698
699
700private:
701 int m_iStartItem;
702 int m_iEndItem;
703 double m_dSize;
704 double m_dOffset;
705};
706
707class PrintObject
708{
709 public:
710 PrintObject() : obj(0), p(0) {}
711
712 EmbeddedObject *obj;
713 TQPixmap *p;
714};
715
716} // namespace KSpread
717
718#endif
719
The KSpread namespace.
Definition commands.h:39