22#include "kspread_sheet.h"
24#include "kspread_locale.h"
25#include "kspread_doc.h"
26#include "kspread_undo.h"
28#include "kspread_sheetprint.h"
31#include <KoDocumentInfo.h>
33#include <tdemessagebox.h>
42#include "kspread_sheetprint.moc"
44#define NO_MODIFICATION_POSSIBLE \
46 KMessageBox::error( 0, i18n ( "You cannot change a protected sheet" ) ); return; \
51SheetPrint::SheetPrint( Sheet* sheet )
54 m_pDoc = m_pSheet->doc();
57 m_bPrintCommentIndicator =
false;
58 m_bPrintFormulaIndicator =
false;
59 m_bPrintObjects =
true;
60 m_bPrintCharts =
true;
61 m_bPrintGraphics =
true;
66 m_bottomBorder = 20.0;
68 m_paperFormat = KoPageFormat::defaultFormat();
69 m_orientation = PG_PORTRAIT;
70 m_paperWidth = MM_TO_POINT( KoPageFormat::width( m_paperFormat, m_orientation ) );
71 m_paperHeight = MM_TO_POINT( KoPageFormat::height( m_paperFormat, m_orientation ) );
72 m_printRange = TQRect( TQPoint( 1, 1 ), TQPoint( KS_colMax, KS_rowMax ) );
73 m_lnewPageListX.append( 1 );
74 m_lnewPageListY.append( 1 );
75 m_maxCheckedNewPageX = 1;
76 m_maxCheckedNewPageY = 1;
77 m_dPrintRepeatColumnsWidth = 0.0;
78 m_dPrintRepeatRowsHeight = 0.0;
79 m_printRepeatColumns = qMakePair( 0, 0 );
80 m_printRepeatRows = qMakePair( 0, 0 );
88SheetPrint::~SheetPrint()
93TQString SheetPrint::saveOasisSheetStyleLayout( KoGenStyles &mainStyles )
95 KoGenStyle pageLayout( KoGenStyle::STYLE_PAGELAYOUT );
97 pageLayout.addPropertyPt(
"fo:page-width", MM_TO_POINT( paperWidth() ) );
98 pageLayout.addPropertyPt(
"fo:page-height", MM_TO_POINT( paperHeight() ) );
99 pageLayout.addProperty(
"style:print-orientation", orientation() == PG_LANDSCAPE ?
"landscape" :
"portrait" );
100 pageLayout.addPropertyPt(
"fo:margin-left", MM_TO_POINT(leftBorder() ) );
101 pageLayout.addPropertyPt(
"fo:margin-top", MM_TO_POINT(topBorder() ) );
102 pageLayout.addPropertyPt(
"fo:margin-right", MM_TO_POINT(rightBorder() ) );
103 pageLayout.addPropertyPt(
"fo:margin-bottom", MM_TO_POINT(bottomBorder() ) );
105 m_pSheet->saveOasisPrintStyleLayout( pageLayout );
107 return mainStyles.lookup( pageLayout,
"pm" );
111TQRect SheetPrint::cellsPrintRange()
115 cell_range.setCoords( 1, 1, 1, 1 );
117 Cell* c = m_pSheet->firstCell();
118 for( ;c; c = c->nextCell() )
122 if ( c->
column() > cell_range.right() )
123 cell_range.setRight( c->
column() );
124 if ( c->
row() > cell_range.bottom() )
125 cell_range.setBottom( c->
row() );
130 TQPtrListIterator<KoDocumentChild> cit( m_pDoc->children() );
133 for( ; cit.current(); ++cit )
136 TQRect bound = cit.current()->boundingRect();
138 i = m_pSheet->leftColumn( bound.right(), dummy );
139 if ( i > cell_range.right() )
140 cell_range.setRight( i );
142 i = m_pSheet->topRow( bound.bottom(), dummy );
143 if ( i > cell_range.bottom() )
144 cell_range.setBottom( i );
146 cell_range = cell_range.intersect( m_printRange );
151int SheetPrint::pagesX(
const TQRect& cellsPrintRange )
155 updateNewPageX( m_pSheet->rightColumn( m_pSheet->dblColumnPos( cellsPrintRange.right() ) + prinsheetWidthPts() ) );
157 for(
int i = cellsPrintRange.left(); i <= cellsPrintRange.right(); i++ )
159 if( isOnNewPageX( i ) )
165int SheetPrint::pagesY(
const TQRect& cellsPrintRange )
169 updateNewPageY( m_pSheet->bottomRow( m_pSheet->dblRowPos( cellsPrintRange.bottom() ) + prinsheetHeightPts() ) );
171 for(
int i = cellsPrintRange.top(); i <= cellsPrintRange.bottom(); i++ )
173 if( isOnNewPageY( i ) )
180bool SheetPrint::pageNeedsPrinting( TQRect& page_range )
185 for(
int r = page_range.top(); r <= page_range.bottom() ; ++r )
186 for(
int c = page_range.left(); c <= page_range.right() ; ++c )
187 if ( m_pSheet->cellAt( c, r )->needsPrinting() )
195 TQRect intView = TQRect( TQPoint( m_pDoc->zoomItX( m_pSheet->dblColumnPos( page_range.left() ) ),
196 m_pDoc->zoomItY( m_pSheet->dblRowPos( page_range.top() ) ) ),
197 TQPoint( m_pDoc->zoomItX( m_pSheet->dblColumnPos( page_range.right() ) +
198 m_pSheet->columnFormat( page_range.right() )->dblWidth() ),
199 m_pDoc->zoomItY( m_pSheet->dblRowPos( page_range.bottom() ) +
200 m_pSheet->rowFormat( page_range.bottom() )->dblHeight() ) ) );
202 TQPtrListIterator<KoDocumentChild> it( m_pDoc->children() );
203 for( ;it.current(); ++it )
205 TQRect bound = it.current()->boundingRect();
206 if ( bound.intersects( intView ) )
218bool SheetPrint::print( TQPainter &painter, KPrinter *_printer )
220 kdDebug(36001)<<
"PRINTING ...."<<endl;
224 bool oldShowGrid = m_pSheet->getShowGrid();
225 m_pSheet->setShowGrid( m_bPrintGrid );
228 gridPen = TQPen( m_pDoc->gridColor(), 1, TQt::SolidLine );
230 nopen.setStyle( TQt::NoPen );
231 m_pDoc->setGridColor( TQt::white );
236 if ( !m_pSheet->isShowPageBorders() && m_printRepeatColumns.first != 0 )
237 updatePrintRepeatColumnsWidth();
241 if ( !m_pSheet->isShowPageBorders() && m_printRepeatRows.first != 0 )
242 updatePrintRepeatRowsHeight();
245 TQRect cell_range = cellsPrintRange();
246 kdDebug()<<
"cellsPrintRange() :"<<cellsPrintRange()<<endl;
249 updateNewPageX( m_pSheet->rightColumn( m_pSheet->dblColumnPos( cell_range.right() ) + prinsheetWidthPts() ) );
250 updateNewPageY( m_pSheet->bottomRow( m_pSheet->dblRowPos( cell_range.bottom() ) + prinsheetHeightPts() ) );
254 TQValueList<TQRect> page_list;
255 TQValueList<KoRect> page_frame_list;
256 TQValueList<KoPoint> page_frame_list_offset;
258 TQValueList<PrintNewPageEntry>::iterator itX;
259 TQValueList<PrintNewPageEntry>::iterator itY;
260 for( itX = m_lnewPageListX.begin(); itX != m_lnewPageListX.end(); ++itX )
262 for( itY = m_lnewPageListY.begin(); itY != m_lnewPageListY.end(); ++itY )
264 TQRect page_range( TQPoint( (*itX).startItem(), (*itY).startItem() ),
265 TQPoint( (*itX).endItem(), (*itY).endItem() ) );
266 kdDebug()<<
" page_range :"<<page_range<<endl;
268 if ( pageNeedsPrinting( page_range ) )
270 KoRect view = KoRect( KoPoint( m_pSheet->dblColumnPos( page_range.left() ),
271 m_pSheet->dblRowPos( page_range.top() ) ),
272 KoPoint( m_pSheet->dblColumnPos( page_range.right() ) +
273 m_pSheet->columnFormat( page_range.right() )->dblWidth(),
274 m_pSheet->dblRowPos( page_range.bottom() ) +
275 m_pSheet->rowFormat( page_range.bottom() )->dblHeight() ) );
276 page_list.append( page_range );
277 page_frame_list.append( view );
278 page_frame_list_offset.append( KoPoint( (*itX).offset(), (*itY).offset() ) );
284 kdDebug(36001) <<
"PRINTING " << page_list.count() <<
" pages" << endl;
285 m_uprintPages = page_list.count();
289 TQPtrListIterator<EmbeddedObject> itObject( m_pDoc->embeddedObjects() );
290 for ( ; itObject.current(); ++itObject )
293 if ( obj->sheet() != m_pSheet ||
294 !( (( obj->getType() == OBJECT_KOFFICE_PART || obj->getType() == OBJECT_PICTURE ) && m_bPrintObjects) ||
295 ( obj->getType() == OBJECT_CHART && m_bPrintCharts ) ) )
298 TQRect zoomRect = m_pDoc->zoomRect( itObject.current()->geometry() );
299 TQPixmap *p =
new TQPixmap( zoomRect.size() );
300 TQPainter painter(p);
301 painter.fillRect( p->rect(), TQColor(
"white") );
302 painter.translate( -zoomRect.x(), -zoomRect.y() );
303 bool const isSelected = itObject.current()->isSelected();
304 itObject.current()->setSelected(
false );
305 itObject.current()->draw( &painter );
307 itObject.current()->setSelected( isSelected );
309 PrintObject *po =
new PrintObject();
310 m_printObjects.append( po );
311 po->obj = itObject.current();
315 if ( page_list.count() == 0 )
318 painter.setPen( TQPen( TQt::black, 1 ) );
319 painter.drawPoint( 1, 1 );
329 TQValueList<TQRect>::Iterator it = page_list.begin();
330 TQValueList<KoRect>::Iterator fit = page_frame_list.begin();
331 TQValueList<KoPoint>::Iterator fito = page_frame_list_offset.begin();
333 for( ; it != page_list.end(); ++it, ++fit, ++fito, ++pageNo )
335 painter.setClipRect( 0, 0, m_pDoc->zoomItX( paperWidthPts() ),
336 m_pDoc->zoomItY( paperHeightPts() ) );
337 printHeaderFooter( painter, pageNo );
339 painter.translate( m_pDoc->zoomItX( leftBorderPts() ),
340 m_pDoc->zoomItY( topBorderPts() ) );
343 printPage( painter, *it, *fit, *fito );
345 painter.translate( - m_pDoc->zoomItX( leftBorderPts() ),
346 - m_pDoc->zoomItY( topBorderPts() ) );
348 if ( pageNo < (
int)page_list.count() )
356 m_pDoc->setGridColor( gridPen.color() );
358 m_pSheet->setShowGrid( oldShowGrid );
360 TQValueList<PrintObject *>::iterator it;
361 for ( it = m_printObjects.begin(); it != m_printObjects.end(); ++it )
363 m_printObjects.clear();
365 return ( page_list.count() > 0 );
368void SheetPrint::printPage( TQPainter &_painter,
const TQRect& page_range,
369 const KoRect& view,
const KoPoint _childOffset )
371 kdDebug(36001) <<
"Rect x=" << page_range.left() <<
" y=" << page_range.top() <<
", r="
372 << page_range.right() <<
" b=" << page_range.bottom() <<
" offsetx: "<< _childOffset.x()
373 <<
" offsety: " << _childOffset.y() <<
" view-x: "<<view.x()<< endl;
376 TQRegion clipRegion( m_pDoc->zoomItX( leftBorderPts() ),
377 m_pDoc->zoomItY( topBorderPts() ),
378 m_pDoc->zoomItX( view.width() + _childOffset.x() ),
379 m_pDoc->zoomItY( view.height() + _childOffset.y() ) );
380 _painter.setClipRegion( clipRegion );
386 if ( ( _childOffset.x() != 0.0 ) && ( _childOffset.y() != 0.0 ) )
389 TQRect _printRect( m_printRepeatColumns.first, m_printRepeatRows.first,
390 m_printRepeatColumns.second - m_printRepeatColumns.first + 1,
391 m_printRepeatRows.second - m_printRepeatRows.first + 1);
392 KoPoint _topLeft( 0.0, 0.0 );
394 printRect( _painter, _topLeft, _printRect, view, clipRegion );
398 if ( _childOffset.y() != 0 )
400 TQRect _printRect( page_range.left(), m_printRepeatRows.first,
401 page_range.right() - page_range.left() + 1,
402 m_printRepeatRows.second - m_printRepeatRows.first + 1);
403 KoPoint _topLeft( _childOffset.x(), 0.0 );
405 printRect( _painter, _topLeft, _printRect, view, clipRegion );
409 if ( _childOffset.x() != 0 )
411 TQRect _printRect( m_printRepeatColumns.first, page_range.top(),
412 m_printRepeatColumns.second - m_printRepeatColumns.first + 1,
413 page_range.bottom() - page_range.top() + 1);
414 KoPoint _topLeft( 0.0, _childOffset.y() );
416 printRect( _painter, _topLeft, _printRect, view, clipRegion );
421 KoPoint _topLeft( _childOffset.x(), _childOffset.y() );
423 printRect( _painter, _topLeft, page_range, view, clipRegion );
427void SheetPrint::printRect( TQPainter& painter,
const KoPoint& topLeft,
428 const TQRect& printRect,
const KoRect& view,
429 TQRegion &clipRegion )
436 ColumnFormat *col_lay;
439 double ypos = topLeft.y();
441 int regionBottom = printRect.bottom();
442 int regionRight = printRect.right();
443 int regionLeft = printRect.left();
444 int regionTop = printRect.top();
447 KoPoint bottomRight( topLeft );
448 for (
int x = regionLeft; x <= regionRight; ++x )
449 bottomRight.setX( bottomRight.x()
450 + m_pSheet->columnFormat( x )->dblWidth() );
451 for (
int y = regionTop; y <= regionBottom; ++y )
452 bottomRight.setY( bottomRight.y()
453 + m_pSheet->rowFormat( y )->dblHeight() );
454 KoRect rect( topLeft, bottomRight );
456 TQValueList<TQPoint> mergedCellsPainted;
457 for (
int y = regionTop; y <= regionBottom; ++y )
459 row_lay = m_pSheet->rowFormat( y );
462 for (
int x = regionLeft; x <= regionRight; ++x )
464 col_lay = m_pSheet->columnFormat( x );
466 cell = m_pSheet->cellAt( x, y );
468 bool paintBordersBottom =
false;
469 bool paintBordersRight =
false;
470 bool paintBordersLeft =
false;
471 bool paintBordersTop =
false;
481 if ( x >= KS_colMax )
482 paintBordersRight =
true;
484 if ( x == regionRight )
486 paintBordersRight =
true;
487 if ( cell->
effRightBorderValue( x, y ) < m_pSheet->cellAt( x + 1, y )->effLeftBorderValue( x + 1, y ) )
488 rightPen = m_pSheet->cellAt( x + 1, y )->effLeftBorderPen( x + 1, y );
492 paintBordersRight =
true;
493 if ( cell->
effRightBorderValue( x, y ) < m_pSheet->cellAt( x + 1, y )->effLeftBorderValue( x + 1, y ) )
494 rightPen = m_pSheet->cellAt( x + 1, y )->effLeftBorderPen( x + 1, y );
499 if ( y >= KS_rowMax )
500 paintBordersBottom =
true;
502 if ( y == regionBottom )
504 paintBordersBottom =
true;
505 if ( cell->
effBottomBorderValue( x, y ) < m_pSheet->cellAt( x, y + 1 )->effTopBorderValue( x, y + 1) )
506 bottomPen = m_pSheet->cellAt( x, y + 1 )->effTopBorderPen( x, y + 1 );
510 paintBordersBottom =
true;
511 if ( cell->
effBottomBorderValue( x, y ) < m_pSheet->cellAt( x, y + 1 )->effTopBorderValue( x, y + 1) )
512 bottomPen = m_pSheet->cellAt( x, y + 1 )->effTopBorderPen( x, y + 1 );
517 paintBordersLeft =
true;
519 if ( x == regionLeft )
521 paintBordersLeft =
true;
522 if ( cell->
effLeftBorderValue( x, y ) < m_pSheet->cellAt( x - 1, y )->effRightBorderValue( x - 1, y ) )
523 leftPen = m_pSheet->cellAt( x - 1, y )->effRightBorderPen( x - 1, y );
527 paintBordersLeft =
true;
528 if ( cell->
effLeftBorderValue( x, y ) < m_pSheet->cellAt( x - 1, y )->effRightBorderValue( x - 1, y ) )
529 leftPen = m_pSheet->cellAt( x - 1, y )->effRightBorderPen( x - 1, y );
534 paintBordersTop =
true;
536 if ( y == regionTop )
538 paintBordersTop =
true;
539 if ( cell->
effTopBorderValue( x, y ) < m_pSheet->cellAt( x, y - 1 )->effBottomBorderValue( x, y - 1 ) )
540 topPen = m_pSheet->cellAt( x, y - 1 )->effBottomBorderPen( x, y - 1 );
544 paintBordersTop =
true;
545 if ( cell->
effTopBorderValue( x, y ) < m_pSheet->cellAt( x, y - 1 )->effBottomBorderValue( x, y - 1 ) )
546 topPen = m_pSheet->cellAt( x, y - 1 )->effBottomBorderPen( x, y - 1 );
549 int paintBorder=Cell::Border_None;
550 if (paintBordersLeft) paintBorder |= Cell::Border_Left;
551 if (paintBordersRight) paintBorder |= Cell::Border_Right;
552 if (paintBordersTop) paintBorder |= Cell::Border_Top;
553 if (paintBordersBottom) paintBorder |= Cell::Border_Bottom;
557 if ( m_pSheet->layoutDirection()==Sheet::RightToLeft )
559 KoPoint( view.width() - xpos -
560 col_lay->dblWidth(), ypos ), TQPoint( x, y ),
562 rightPen, bottomPen, leftPen, topPen,
566 KoPoint( xpos, ypos ), TQPoint( x, y ),
568 rightPen, bottomPen, leftPen, topPen,
571 xpos += col_lay->dblWidth();
574 ypos += row_lay->dblHeight();
580 TQRect zoomedView = m_pDoc->zoomRect( view );
584 TQValueList<PrintObject *>::iterator itObject;
585 for ( itObject = m_printObjects.begin(); itObject != m_printObjects.end(); ++itObject ) {
595 KoRect
const bound = obj->geometry();
596 TQRect zoomedBound = m_pDoc->zoomRect( KoRect(bound.left(), bound.top(),
609 if ( obj->sheet() == m_pSheet && zoomedBound.intersects( zoomedView ) )
613 painter.translate( -zoomedView.left() + m_pDoc->zoomItX( topLeft.x() ),
614 -zoomedView.top() + m_pDoc->zoomItY( topLeft.y() ) );
617 painter.drawPixmap( m_pDoc->zoomRect( obj->geometry() ).topLeft(), *(*itObject)->p );
625 clipRegion -= TQRegion ( m_pDoc->zoomItX( leftBorderPts() + topLeft.x() ),
626 m_pDoc->zoomItY( topBorderPts() + topLeft.y() ),
627 m_pDoc->zoomItX( xpos ),
628 m_pDoc->zoomItY( ypos ) );
629 painter.setClipRegion( clipRegion );
633void SheetPrint::printHeaderFooter( TQPainter &painter,
int pageNo )
636 double headFootDistance = MM_TO_POINT( 10.0 ) / m_dZoom;
637 TQFont font(
"Times" );
638 font.setPointSizeFloat( 0.01 * m_pDoc->zoom() *
640 painter.setFont( font );
641 TQFontMetrics fm = painter.fontMetrics();
644 w = fm.width( headLeft( pageNo, m_pSheet->sheetName() ) ) / m_dZoom;
646 painter.drawText( m_pDoc->zoomItX( leftBorderPts() ),
647 m_pDoc->zoomItY( headFootDistance ),
648 headLeft( pageNo, m_pSheet->sheetName() ) );
650 w = fm.width( headMid( pageNo, m_pSheet->sheetName() ) ) / m_dZoom;
652 painter.drawText( (
int) ( m_pDoc->zoomItX( leftBorderPts() ) +
653 ( m_pDoc->zoomItX( prinsheetWidthPts() ) -
655 m_pDoc->zoomItY( headFootDistance ),
656 headMid( pageNo, m_pSheet->sheetName() ) );
658 w = fm.width( headRight( pageNo, m_pSheet->sheetName() ) ) / m_dZoom;
660 painter.drawText( m_pDoc->zoomItX( leftBorderPts() +
661 prinsheetWidthPts() ) - (
int) w,
662 m_pDoc->zoomItY( headFootDistance ),
663 headRight( pageNo, m_pSheet->sheetName() ) );
666 w = fm.width( footLeft( pageNo, m_pSheet->sheetName() ) ) / m_dZoom;
668 painter.drawText( m_pDoc->zoomItX( leftBorderPts() ),
669 m_pDoc->zoomItY( paperHeightPts() - headFootDistance ),
670 footLeft( pageNo, m_pSheet->sheetName() ) );
672 w = fm.width( footMid( pageNo, m_pSheet->sheetName() ) ) / m_dZoom;
674 painter.drawText( (
int) ( m_pDoc->zoomItX( leftBorderPts() ) +
675 ( m_pDoc->zoomItX( prinsheetWidthPts() ) -
677 m_pDoc->zoomItY( paperHeightPts() - headFootDistance ),
678 footMid( pageNo, m_pSheet->sheetName() ) );
680 w = fm.width( footRight( pageNo, m_pSheet->sheetName() ) ) / m_dZoom;
682 painter.drawText( m_pDoc->zoomItX( leftBorderPts() +
683 prinsheetWidthPts() ) -
685 m_pDoc->zoomItY( paperHeightPts() - headFootDistance ),
686 footRight( pageNo, m_pSheet->sheetName() ) );
690bool SheetPrint::isOnNewPageX(
int _column )
692 if( _column > m_maxCheckedNewPageX )
693 updateNewPageX( _column );
696 if ( _column == m_printRange.left() || _column == m_printRange.right() + 1 )
702 if ( _column < m_printRange.left() || _column > m_printRange.right() )
708 if ( m_lnewPageListX.findIndex( _column ) != -1 )
710 if( _column > m_maxCheckedNewPageX )
711 m_maxCheckedNewPageX = _column;
718void SheetPrint::updateNewPageX(
int _column )
723 if ( _column == m_printRange.left() || _column == m_printRange.right() + 1 )
725 if( _column > m_maxCheckedNewPageX )
726 m_maxCheckedNewPageX = _column;
731 if ( _column < m_printRange.left() || _column > m_printRange.right() )
733 if( _column > m_maxCheckedNewPageX )
734 m_maxCheckedNewPageX = _column;
735 if ( _column > m_printRange.right() )
737 if ( m_lnewPageListX.last().endItem()==0 )
738 m_lnewPageListX.last().setEndItem( m_printRange.right() );
744 if ( m_lnewPageListX.empty() )
745 m_lnewPageListX.append( m_printRange.left() );
748 if ( _column > m_lnewPageListX.last().startItem() &&
749 _column > m_maxCheckedNewPageX )
751 int startCol = m_lnewPageListX.last().startItem();
753 double x = m_pSheet->columnFormat( col )->dblWidth();
756 if ( col > m_printRepeatColumns.first )
758 x += m_dPrintRepeatColumnsWidth;
759 offset = m_dPrintRepeatColumnsWidth;
762 while ( ( col <= _column ) && ( col < m_printRange.right() ) )
764 if ( x > prinsheetWidthPts() )
767 m_lnewPageListX.append( col );
770 TQValueList<PrintNewPageEntry>::iterator it;
771 it = findNewPageColumn( startCol );
772 (*it).setEndItem( col - 1 );
773 (*it).setSize( x - m_pSheet->columnFormat( col )->dblWidth() );
774 (*it).setOffset( offset );
778 if ( col == _column )
780 if( _column > m_maxCheckedNewPageX )
781 m_maxCheckedNewPageX = _column;
786 x = m_pSheet->columnFormat( col )->dblWidth();
787 if ( col >= m_printRepeatColumns.first )
789 x += m_dPrintRepeatColumnsWidth;
790 offset = m_dPrintRepeatColumnsWidth;
796 x += m_pSheet->columnFormat( col )->dblWidth();
800 if( _column > m_maxCheckedNewPageX )
801 m_maxCheckedNewPageX = _column;
805bool SheetPrint::isOnNewPageY(
int _row )
807 if( _row > m_maxCheckedNewPageY )
808 updateNewPageY( _row );
811 if ( _row == m_printRange.top() || _row == m_printRange.bottom() + 1 )
817 if ( _row < m_printRange.top() || _row > m_printRange.bottom() )
823 if ( m_lnewPageListY.findIndex( _row ) != -1 )
825 if( _row > m_maxCheckedNewPageY )
826 m_maxCheckedNewPageY = _row;
834void SheetPrint::updateNewPageY(
int _row )
839 if ( _row == m_printRange.top() || _row == m_printRange.bottom() + 1 )
841 if( _row > m_maxCheckedNewPageY )
842 m_maxCheckedNewPageY = _row;
847 if ( _row < m_printRange.top() || _row > m_printRange.bottom() )
849 if( _row > m_maxCheckedNewPageY )
850 m_maxCheckedNewPageY = _row;
851 if ( _row > m_printRange.bottom() )
853 if ( m_lnewPageListY.last().endItem()==0 )
854 m_lnewPageListY.last().setEndItem( m_printRange.bottom() );
860 if ( m_lnewPageListY.empty() )
861 m_lnewPageListY.append( m_printRange.top() );
864 if ( _row > m_lnewPageListY.last().startItem() &&
865 _row > m_maxCheckedNewPageY )
867 int startRow = m_lnewPageListY.last().startItem();
869 double y = m_pSheet->rowFormat( row )->dblHeight();
872 if ( row > m_printRepeatRows.first )
874 y += m_dPrintRepeatRowsHeight;
875 offset = m_dPrintRepeatRowsHeight;
878 while ( ( row <= _row ) && ( row < m_printRange.bottom() ) )
880 if ( y > prinsheetHeightPts() )
883 m_lnewPageListY.append( row );
886 TQValueList<PrintNewPageEntry>::iterator it;
887 it = findNewPageRow( startRow );
888 (*it).setEndItem( row - 1 );
889 (*it).setSize( y - m_pSheet->rowFormat( row )->dblHeight() );
890 (*it).setOffset( offset );
896 if( _row > m_maxCheckedNewPageY )
897 m_maxCheckedNewPageY = _row;
902 y = m_pSheet->rowFormat( row )->dblHeight();
903 if ( row >= m_printRepeatRows.first )
905 y += m_dPrintRepeatRowsHeight;
906 offset = m_dPrintRepeatRowsHeight;
912 y += m_pSheet->rowFormat( row )->dblHeight();
916 if( _row > m_maxCheckedNewPageY )
917 m_maxCheckedNewPageY = _row;
921void SheetPrint::updateNewPageListX(
int _col )
924 if ( m_lnewPageListX.first().startItem() != m_printRange.left() ||
927 m_lnewPageListX.clear();
928 m_maxCheckedNewPageX = m_printRange.left();
929 m_lnewPageListX.append( m_printRange.left() );
933 if ( _col < m_lnewPageListX.last().startItem() )
936 TQValueList<PrintNewPageEntry>::iterator it;
937 it = m_lnewPageListX.find( _col );
938 while ( ( it == m_lnewPageListX.end() ) && _col > 0 )
941 it = m_lnewPageListX.find( _col );
945 while ( it != m_lnewPageListX.end() )
946 it = m_lnewPageListX.remove( it );
949 if ( m_lnewPageListX.empty() )
950 m_lnewPageListX.append( m_printRange.left() );
953 m_maxCheckedNewPageX = _col;
956void SheetPrint::updateNewPageListY(
int _row )
959 if ( m_lnewPageListY.first().startItem() != m_printRange.top() ||
962 m_lnewPageListY.clear();
963 m_maxCheckedNewPageY = m_printRange.top();
964 m_lnewPageListY.append( m_printRange.top() );
968 if ( _row < m_lnewPageListY.last().startItem() )
971 TQValueList<PrintNewPageEntry>::iterator it;
972 it = m_lnewPageListY.find( _row );
973 while ( ( it == m_lnewPageListY.end() ) && _row > 0 )
976 it = m_lnewPageListY.find( _row );
980 while ( it != m_lnewPageListY.end() )
981 it = m_lnewPageListY.remove( it );
984 if ( m_lnewPageListY.empty() )
985 m_lnewPageListY.append( m_printRange.top() );
988 m_maxCheckedNewPageY = _row;
991void SheetPrint::definePrintRange( Selection* selectionInfo )
993 if ( !selectionInfo->isSingular() )
995 KCommand* command =
new DefinePrintRangeCommand( m_pSheet );
996 m_pDoc->addCommand( command );
997 setPrintRange( selectionInfo->selection() );
1001void SheetPrint::resetPrintRange ()
1003 KCommand* command =
new DefinePrintRangeCommand( m_pSheet );
1004 m_pDoc->addCommand( command );
1005 setPrintRange( TQRect( TQPoint( 1, 1 ), TQPoint( KS_colMax, KS_rowMax ) ) );
1008void SheetPrint::replaceHeadFootLineMacro ( TQString &_text,
const TQString &_search,
const TQString &_replace )
1010 if ( _search != _replace )
1011 _text.replace ( TQString(
"<" + _search +
">" ),
"<" + _replace +
">" );
1014TQString SheetPrint::localizeHeadFootLine (
const TQString &_text )
1016 TQString tmp = _text;
1023 replaceHeadFootLineMacro ( tmp,
"page", i18n(
"page") );
1024 replaceHeadFootLineMacro ( tmp,
"pages", i18n(
"pages") );
1025 replaceHeadFootLineMacro ( tmp,
"file", i18n(
"file") );
1026 replaceHeadFootLineMacro ( tmp,
"name", i18n(
"name") );
1027 replaceHeadFootLineMacro ( tmp,
"time", i18n(
"time") );
1028 replaceHeadFootLineMacro ( tmp,
"date", i18n(
"date") );
1029 replaceHeadFootLineMacro ( tmp,
"author", i18n(
"author") );
1030 replaceHeadFootLineMacro ( tmp,
"email", i18n(
"email") );
1031 replaceHeadFootLineMacro ( tmp,
"org", i18n(
"org") );
1032 replaceHeadFootLineMacro ( tmp,
"sheet", i18n(
"sheet") );
1038TQString SheetPrint::delocalizeHeadFootLine (
const TQString &_text )
1040 TQString tmp = _text;
1047 replaceHeadFootLineMacro ( tmp, i18n(
"page"),
"page" );
1048 replaceHeadFootLineMacro ( tmp, i18n(
"pages"),
"pages" );
1049 replaceHeadFootLineMacro ( tmp, i18n(
"file"),
"file" );
1050 replaceHeadFootLineMacro ( tmp, i18n(
"name"),
"name" );
1051 replaceHeadFootLineMacro ( tmp, i18n(
"time"),
"time" );
1052 replaceHeadFootLineMacro ( tmp, i18n(
"date"),
"date" );
1053 replaceHeadFootLineMacro ( tmp, i18n(
"author"),
"author" );
1054 replaceHeadFootLineMacro ( tmp, i18n(
"email"),
"email" );
1055 replaceHeadFootLineMacro ( tmp, i18n(
"org"),
"org" );
1056 replaceHeadFootLineMacro ( tmp, i18n(
"sheet"),
"sheet" );
1062KoHeadFoot SheetPrint::headFootLine()
const
1065 hf.headLeft = m_headLeft;
1066 hf.headRight = m_headRight;
1067 hf.headMid = m_headMid;
1068 hf.footLeft = m_footLeft;
1069 hf.footRight = m_footRight;
1070 hf.footMid = m_footMid;
1076void SheetPrint::setHeadFootLine(
const TQString &_headl,
const TQString &_headm,
const TQString &_headr,
1077 const TQString &_footl,
const TQString &_footm,
const TQString &_footr )
1079 if ( m_pSheet->isProtected() )
1080 NO_MODIFICATION_POSSIBLE;
1082 m_headLeft = _headl;
1083 m_headRight = _headr;
1085 m_footLeft = _footl;
1086 m_footRight = _footr;
1089 m_pDoc->setModified(
true );
1092void SheetPrint::setPaperOrientation( KoOrientation _orient )
1094 if ( m_pSheet->isProtected() )
1095 NO_MODIFICATION_POSSIBLE;
1097 m_orientation = _orient;
1099 updatePrintRepeatColumnsWidth();
1100 updatePrintRepeatRowsHeight();
1101 updateNewPageListX( m_printRange.left() );
1102 updateNewPageListY( m_printRange.top() );
1104 if( m_pSheet->isShowPageBorders() )
1105 emit sig_updateView( m_pSheet );
1109KoPageLayout SheetPrint::paperLayout()
const
1112 pl.format = m_paperFormat;
1113 pl.orientation = m_orientation;
1114 pl.ptWidth = m_paperWidth;
1115 pl.ptHeight = m_paperHeight;
1116 pl.ptLeft = m_leftBorder;
1117 pl.ptRight = m_rightBorder;
1118 pl.ptTop = m_topBorder;
1119 pl.ptBottom = m_bottomBorder;
1124void SheetPrint::setPaperLayout(
float _leftBorder,
float _topBorder,
1125 float _rightBorder,
float _bottomBorder,
1127 KoOrientation _orientation )
1129 if ( m_pSheet->isProtected() )
1130 NO_MODIFICATION_POSSIBLE;
1132 m_leftBorder = _leftBorder;
1133 m_rightBorder = _rightBorder;
1134 m_topBorder = _topBorder;
1135 m_bottomBorder = _bottomBorder;
1136 m_paperFormat = _paper;
1138 setPaperOrientation( _orientation );
1152 m_pDoc->setModified(
true );
1155void SheetPrint::setPaperLayout(
float _leftBorder,
float _topBorder,
1156 float _rightBorder,
float _bottomBorder,
1157 const TQString& _paper,
1158 const TQString& _orientation )
1160 if ( m_pSheet->isProtected() )
1161 NO_MODIFICATION_POSSIBLE;
1163 KoFormat f = paperFormat();
1164 KoOrientation newOrientation = orientation();
1166 if ( _orientation ==
"Portrait" )
1167 newOrientation = PG_PORTRAIT;
1168 else if ( _orientation ==
"Landscape" )
1169 newOrientation = PG_LANDSCAPE;
1172 TQString paper( _paper );
1173 if ( paper[0].isDigit() )
1175 const int i = paper.find(
'x' );
1184 m_paperWidth = paper.left(i).toFloat();
1185 m_paperHeight = paper.mid(i+1).toFloat();
1186 if ( m_paperWidth < 10.0 )
1187 m_paperWidth = KoPageFormat::width( PG_DIN_A4, newOrientation );
1188 if ( m_paperHeight < 10.0 )
1189 m_paperHeight = KoPageFormat::height( PG_DIN_A4, newOrientation );
1194 f = KoPageFormat::formatFromString( paper );
1195 if ( f == PG_CUSTOM )
1199 setPaperLayout( _leftBorder, _topBorder, _rightBorder, _bottomBorder, f, newOrientation );
1202void SheetPrint::calcPaperSize()
1204 if ( m_paperFormat != PG_CUSTOM )
1206 m_paperWidth = KoPageFormat::width( m_paperFormat, m_orientation );
1207 m_paperHeight = KoPageFormat::height( m_paperFormat, m_orientation );
1211TQValueList<PrintNewPageEntry>::iterator SheetPrint::findNewPageColumn(
int col )
1213 TQValueList<PrintNewPageEntry>::iterator it;
1214 for( it = m_lnewPageListX.begin(); it != m_lnewPageListX.end(); ++it )
1216 if( (*it).startItem() == col )
1224TQValueList<PrintNewPageEntry>::iterator SheetPrint::findNewPageRow(
int row )
1226 TQValueList<PrintNewPageEntry>::iterator it;
1227 for( it = m_lnewPageListY.begin(); it != m_lnewPageListY.end(); ++it )
1229 if( (*it).startItem() == row )
1236TQString SheetPrint::paperFormatString()
const
1238 if ( m_paperFormat == PG_CUSTOM )
1241 tmp.sprintf(
"%fx%f", m_paperWidth, m_paperHeight );
1245 return KoPageFormat::formatString( m_paperFormat );
1248const char* SheetPrint::orientationString()
const
1250 switch( m_orientation )
1252 case KPrinter::Portrait:
1254 case KPrinter::Landscape:
1258 kdWarning(36001)<<
"SheetPrint: Unknown orientation, using now portrait"<<endl;
1262TQString SheetPrint::completeHeading(
const TQString &_data,
int _page,
const TQString &_sheet )
const
1264 TQString page( TQString::number( _page) );
1265 TQString pages( TQString::number( m_uprintPages ) );
1267 TQString pathFileName(m_pDoc->url().path());
1268 if ( pathFileName.isNull() )
1271 TQString fileName(m_pDoc->url().fileName());
1272 if( fileName.isNull())
1275 TQString t(TQTime::currentTime().toString());
1276 TQString d(TQDate::currentDate().toString());
1278 if ( !_sheet.isEmpty() )
1281 KoDocumentInfo * info = m_pDoc->documentInfo();
1282 KoDocumentInfoAuthor * authorPage =
static_cast<KoDocumentInfoAuthor *
>(info->page(
"author" ));
1284 TQString email_addr;
1285 TQString organization;
1288 kdWarning() <<
"Author information not found in Document Info !" << endl;
1291 full_name = authorPage->fullName();
1292 email_addr = authorPage->email();
1293 organization = authorPage->company();
1299 p = getpwuid(getuid());
1300 gethostname(hostname,
sizeof(hostname));
1302 if(full_name.isEmpty())
1303 full_name=p->pw_gecos;
1305 if( email_addr.isEmpty())
1306 email_addr = TQString(
"%1@%2").arg(p->pw_name).arg(hostname);
1310 while ( ( pos = tmp.find(
"<page>", pos ) ) != -1 )
1311 tmp.replace( pos, 6, page );
1313 while ( ( pos = tmp.find(
"<pages>", pos ) ) != -1 )
1314 tmp.replace( pos, 7, pages );
1316 while ( ( pos = tmp.find(
"<file>", pos ) ) != -1 )
1317 tmp.replace( pos, 6, pathFileName );
1319 while ( ( pos = tmp.find(
"<name>", pos ) ) != -1 )
1320 tmp.replace( pos, 6, fileName );
1322 while ( ( pos = tmp.find(
"<time>", pos ) ) != -1 )
1323 tmp.replace( pos, 6, t );
1325 while ( ( pos = tmp.find(
"<date>", pos ) ) != -1 )
1326 tmp.replace( pos, 6, d );
1328 while ( ( pos = tmp.find(
"<author>", pos ) ) != -1 )
1329 tmp.replace( pos, 8, full_name );
1331 while ( ( pos = tmp.find(
"<email>", pos ) ) != -1 )
1332 tmp.replace( pos, 7, email_addr );
1334 while ( ( pos = tmp.find(
"<org>", pos ) ) != -1 )
1335 tmp.replace( pos, 5, organization );
1337 while ( ( pos = tmp.find(
"<sheet>", pos ) ) != -1 )
1338 tmp.replace( pos, 7, ta );
1343void SheetPrint::setPrintRange(
const TQRect &_printRange )
1345 if ( m_pSheet->isProtected() )
1346 NO_MODIFICATION_POSSIBLE;
1349 if ( m_printRange == _printRange )
1352 int oldLeft = m_printRange.left();
1353 int oldTop = m_printRange.top();
1354 m_printRange = _printRange;
1357 if ( oldLeft != _printRange.left() )
1358 updateNewPageListX( TQMIN( oldLeft, _printRange.left() ) );
1359 if ( oldTop != _printRange.top() )
1360 updateNewPageListY( TQMIN( oldTop, _printRange.top() ) );
1362 m_pDoc->setModified(
true );
1364 emit sig_updateView( m_pSheet );
1368void SheetPrint::setPageLimitX(
int pages )
1376 m_iPageLimitX = pages;
1381 calculateZoomForPageLimitX();
1384void SheetPrint::setPageLimitY(
int pages )
1392 m_iPageLimitY = pages;
1397 calculateZoomForPageLimitY();
1400void SheetPrint::calculateZoomForPageLimitX()
1402 kdDebug() <<
"Calculating zoom for X limit" << endl;
1403 if( m_iPageLimitX == 0 )
1406 double origZoom = m_dZoom;
1411 TQRect printRange = cellsPrintRange();
1412 updateNewPageX( m_pSheet->rightColumn( m_pSheet->dblColumnPos( printRange.right() ) + prinsheetWidthPts() ) );
1413 int currentPages = pagesX( printRange );
1415 if (currentPages <= m_iPageLimitX)
1419 double factor = (double)m_iPageLimitX/(
double)currentPages +
1420 1-(double)currentPages/((
double)currentPages+1);
1421 kdDebug() <<
"Calculated factor for scaling m_dZoom: " << factor << endl;
1422 m_dZoom = m_dZoom*factor;
1424 kdDebug() <<
"New exact zoom: " << m_dZoom << endl;
1431 m_dZoom = (((int)(m_dZoom*100 + 0.5))/100.0);
1433 kdDebug() <<
"New rounded zoom: " << m_dZoom << endl;
1435 updatePrintRepeatColumnsWidth();
1436 updateNewPageListX( 0 );
1437 updateNewPageX( m_pSheet->rightColumn( m_pSheet->dblColumnPos( printRange.right() ) + prinsheetWidthPts() ) );
1438 currentPages = pagesX( printRange );
1440 kdDebug() <<
"Number of pages with this zoom: " << currentPages << endl;
1442 while( ( currentPages > m_iPageLimitX ) && ( m_dZoom > 0.01 ) )
1445 updatePrintRepeatColumnsWidth();
1446 updateNewPageListX( 0 );
1447 updateNewPageX( m_pSheet->rightColumn( m_pSheet->dblColumnPos( printRange.right() ) + prinsheetWidthPts() ) );
1448 currentPages = pagesX( printRange );
1449 kdDebug() <<
"Looping -0.01; current zoom: " << m_dZoom << endl;
1452 if ( m_dZoom < origZoom )
1454 double newZoom = m_dZoom;
1456 setZoom( newZoom,
false );
1462void SheetPrint::calculateZoomForPageLimitY()
1464 kdDebug() <<
"Calculating zoom for Y limit" << endl;
1465 if( m_iPageLimitY == 0 )
1468 double origZoom = m_dZoom;
1473 TQRect printRange = cellsPrintRange();
1474 updateNewPageY( m_pSheet->bottomRow( m_pSheet->dblRowPos( printRange.bottom() ) + prinsheetHeightPts() ) );
1475 int currentPages = pagesY( printRange );
1477 if (currentPages <= m_iPageLimitY)
1480 double factor = (double)m_iPageLimitY/(
double)currentPages +
1481 1-(double)currentPages/((
double)currentPages+1);
1482 kdDebug() <<
"Calculated factor for scaling m_dZoom: " << factor << endl;
1483 m_dZoom = m_dZoom*factor;
1485 kdDebug() <<
"New exact zoom: " << m_dZoom << endl;
1492 m_dZoom = (((int)(m_dZoom*100 + 0.5))/100.0);
1494 kdDebug() <<
"New rounded zoom: " << m_dZoom << endl;
1496 updatePrintRepeatRowsHeight();
1497 updateNewPageListY( 0 );
1498 updateNewPageY( m_pSheet->bottomRow( m_pSheet->dblRowPos( printRange.bottom() ) + prinsheetHeightPts() ) );
1499 currentPages = pagesY( printRange );
1501 kdDebug() <<
"Number of pages with this zoom: " << currentPages << endl;
1503 while( ( currentPages > m_iPageLimitY ) && ( m_dZoom > 0.01 ) )
1506 updatePrintRepeatRowsHeight();
1507 updateNewPageListY( 0 );
1508 updateNewPageY( m_pSheet->bottomRow( m_pSheet->dblRowPos( printRange.bottom() ) + prinsheetHeightPts() ) );
1509 currentPages = pagesY( printRange );
1510 kdDebug() <<
"Looping -0.01; current zoom: " << m_dZoom << endl;
1513 if ( m_dZoom < origZoom )
1515 double newZoom = m_dZoom;
1517 setZoom( newZoom,
false );
1523void SheetPrint::setPrintGrid(
bool _printGrid )
1525 if ( m_bPrintGrid == _printGrid )
1528 m_bPrintGrid = _printGrid;
1529 m_pDoc->setModified(
true );
1532void SheetPrint::setPrintObjects(
bool _printObjects )
1534 if ( m_bPrintObjects == _printObjects )
1537 m_bPrintObjects = _printObjects;
1538 m_pDoc->setModified(
true );
1541void SheetPrint::setPrintCharts(
bool _printCharts )
1543 if ( m_bPrintCharts == _printCharts )
1546 m_bPrintCharts = _printCharts;
1547 m_pDoc->setModified(
true );
1550void SheetPrint::setPrintGraphics(
bool _printGraphics )
1552 if ( m_bPrintGraphics == _printGraphics )
1555 m_bPrintGraphics = _printGraphics;
1556 m_pDoc->setModified(
true );
1559void SheetPrint::setPrintCommentIndicator(
bool _printCommentIndicator )
1561 if ( m_bPrintCommentIndicator == _printCommentIndicator )
1564 m_bPrintCommentIndicator = _printCommentIndicator;
1565 m_pDoc->setModified(
true );
1568void SheetPrint::setPrintFormulaIndicator(
bool _printFormulaIndicator )
1570 if( m_bPrintFormulaIndicator == _printFormulaIndicator )
1573 m_bPrintFormulaIndicator = _printFormulaIndicator;
1574 m_pDoc->setModified(
true );
1576void SheetPrint::updatePrintRepeatColumnsWidth()
1578 m_dPrintRepeatColumnsWidth = 0.0;
1579 if( m_printRepeatColumns.first != 0 )
1581 for(
int i = m_printRepeatColumns.first; i <= m_printRepeatColumns.second; i++ )
1583 m_dPrintRepeatColumnsWidth += m_pSheet->columnFormat( i )->dblWidth();
1588void SheetPrint::updatePrintRepeatRowsHeight()
1590 m_dPrintRepeatRowsHeight = 0.0;
1591 if ( m_printRepeatRows.first != 0 )
1593 for (
int i = m_printRepeatRows.first; i <= m_printRepeatRows.second; i++)
1595 m_dPrintRepeatRowsHeight += m_pSheet->rowFormat( i )->dblHeight();
1601void SheetPrint::setPrintRepeatColumns( TQPair<int, int> _printRepeatColumns )
1604 if ( _printRepeatColumns.first > _printRepeatColumns.second )
1606 int tmp = _printRepeatColumns.first;
1607 _printRepeatColumns.first = _printRepeatColumns.second;
1608 _printRepeatColumns.second = tmp;
1612 if ( m_printRepeatColumns == _printRepeatColumns )
1615 int oldFirst = m_printRepeatColumns.first;
1616 m_printRepeatColumns = _printRepeatColumns;
1619 updatePrintRepeatColumnsWidth();
1622 updateNewPageListX( TQMIN( oldFirst, _printRepeatColumns.first ) );
1625 if ( m_pSheet->isShowPageBorders() )
1626 emit sig_updateView( m_pSheet );
1628 m_pDoc->setModified(
true );
1631void SheetPrint::setPrintRepeatRows( TQPair<int, int> _printRepeatRows )
1634 if ( _printRepeatRows.first > _printRepeatRows.second )
1636 int tmp = _printRepeatRows.first;
1637 _printRepeatRows.first = _printRepeatRows.second;
1638 _printRepeatRows.second = tmp;
1642 if ( m_printRepeatRows == _printRepeatRows )
1645 int oldFirst = m_printRepeatRows.first;
1646 m_printRepeatRows = _printRepeatRows;
1649 updatePrintRepeatRowsHeight();
1652 updateNewPageListY( TQMIN( oldFirst, _printRepeatRows.first ) );
1655 if ( m_pSheet->isShowPageBorders() )
1656 emit sig_updateView( m_pSheet );
1658 m_pDoc->setModified(
true );
1661void SheetPrint::insertColumn(
int col,
int nbCol )
1664 if ( m_printRange != TQRect( TQPoint(1, 1), TQPoint(KS_colMax, KS_rowMax) ) )
1666 int left = m_printRange.left();
1667 int right = m_printRange.right();
1669 for(
int i = 0; i <= nbCol; i++ )
1671 if ( left >= col ) left++;
1672 if ( right >= col ) right++;
1675 if ( left > KS_colMax ) left = KS_colMax;
1676 if ( right > KS_colMax ) right = KS_colMax;
1677 setPrintRange( TQRect( TQPoint( left, m_printRange.top() ),
1678 TQPoint( right, m_printRange.bottom() ) ) );
1682void SheetPrint::insertRow(
int row,
int nbRow )
1685 if ( m_printRange != TQRect( TQPoint(1, 1), TQPoint(KS_colMax, KS_rowMax) ) )
1687 int top = m_printRange.top();
1688 int bottom = m_printRange.bottom();
1690 for(
int i = 0; i <= nbRow; i++ )
1692 if ( top >= row ) top++;
1693 if ( bottom >= row ) bottom++;
1696 if ( top > KS_rowMax ) top = KS_rowMax;
1697 if ( bottom > KS_rowMax ) bottom = KS_rowMax;
1698 setPrintRange( TQRect( TQPoint( m_printRange.left(), top ),
1699 TQPoint( m_printRange.right(), bottom ) ) );
1703void SheetPrint::removeColumn(
int col,
int nbCol )
1706 if ( m_printRange != TQRect( TQPoint(1, 1), TQPoint(KS_colMax, KS_rowMax) ) )
1708 int left = m_printRange.left();
1709 int right = m_printRange.right();
1711 for(
int i = 0; i <= nbCol; i++ )
1713 if ( left > col ) left--;
1714 if ( right >= col ) right--;
1717 if ( left < 1 ) left = 1;
1718 if ( right < 1 ) right = 1;
1719 setPrintRange( TQRect( TQPoint( left, m_printRange.top() ),
1720 TQPoint( right, m_printRange.bottom() ) ) );
1724 if ( m_printRepeatColumns.first != 0 )
1726 int left = m_printRepeatColumns.first;
1727 int right = m_printRepeatColumns.second;
1729 for(
int i = 0; i <= nbCol; i++ )
1731 if ( left > col ) left--;
1732 if ( right >= col ) right--;
1735 if ( left < 1 ) left = 1;
1736 if ( right < 1 ) right = 1;
1737 setPrintRepeatColumns ( qMakePair( left, right ) );
1741void SheetPrint::removeRow(
int row,
int nbRow )
1744 if ( m_printRange != TQRect( TQPoint(1, 1), TQPoint(KS_colMax, KS_rowMax) ) )
1746 int top = m_printRange.top();
1747 int bottom = m_printRange.bottom();
1749 for(
int i = 0; i <= nbRow; i++ )
1751 if ( top > row ) top--;
1752 if ( bottom >= row ) bottom--;
1755 if ( top < 1 ) top = 1;
1756 if ( bottom < 1 ) bottom = 1;
1757 setPrintRange( TQRect( TQPoint( m_printRange.left(), top ),
1758 TQPoint( m_printRange.right(), bottom ) ) );
1762 if ( m_printRepeatRows.first != 0 )
1764 int top = m_printRepeatRows.first;
1765 int bottom = m_printRepeatRows.second;
1767 for(
int i = 0; i <= nbRow; i++ )
1769 if ( top > row ) top--;
1770 if ( bottom >= row ) bottom--;
1773 if ( top < 1 ) top = 1;
1774 if ( bottom < 1 ) bottom = 1;
1775 setPrintRepeatRows( qMakePair( top, bottom ) );
1779void SheetPrint::setZoom(
double _zoom,
bool checkPageLimit )
1781 if( m_dZoom == _zoom )
1787 updatePrintRepeatColumnsWidth();
1788 updatePrintRepeatRowsHeight();
1789 updateNewPageListX( 0 );
1790 updateNewPageListY( 0 );
1791 if( m_pSheet->isShowPageBorders() )
1792 emit sig_updateView( m_pSheet );
1794 if( checkPageLimit )
1796 calculateZoomForPageLimitX();
1797 calculateZoomForPageLimitY();
1800 m_pDoc->setModified(
true );
1803bool PrintNewPageEntry::operator==( PrintNewPageEntry
const & entry )
const
1805 return m_iStartItem == entry.m_iStartItem;
For every cell in the spread sheet there is a Cell object.
const TQPen & effBottomBorderPen(int col, int row) const
int row() const
Returns the cell's row.
int column() const
Returns the cell's column.
void paintCell(const KoRect &rect, TQPainter &painter, View *view, const KoPoint &coordinate, const TQPoint &cellRef, int paintBorder, TQPen &rightPen, TQPen &bottomPen, TQPen &leftPen, TQPen &topPen, TQValueList< TQPoint > &mergedCellsPainted, bool drawCursor=true)
Paints the cell.
uint effRightBorderValue(int col, int row) const
const TQPen & effTopBorderPen(int col, int row) const
const TQPen & effRightBorderPen(int col, int row) const
bool needsPrinting() const
uint effLeftBorderValue(int col, int row) const
uint effTopBorderValue(int col, int row) const
const TQPen & effLeftBorderPen(int col, int row) const
uint effBottomBorderValue(int col, int row) const
Contains basic information for every object.