//replace html url Q_FOREACH ( const QgsComposerHtml *currentHtml, composerHtmls ) { QgsComposerHtml * html = const_cast<QgsComposerHtml *>( currentHtml ); QgsComposerFrame *htmlFrame = html->frame( 0 ); QString htmlId = htmlFrame->id(); QString url = parameterMap.value( htmlId.toUpper() ); if ( url.isEmpty() ) { //remove exported Htmls referenced in the request //but with empty string if ( parameterMap.contains( htmlId.toUpper() ) ) { c->removeMultiFrame( html ); delete currentHtml; } else { html->update(); } continue; } QUrl newUrl( url ); html->setUrl( newUrl ); html->update(); }
bool QgsComposerMultiFrame::_readXML( const QDomElement& itemElem, const QDomDocument& doc, bool ignoreFrames ) { mResizeMode = ( ResizeMode )itemElem.attribute( "resizeMode", "0" ).toInt(); if ( !ignoreFrames ) { QDomNodeList frameList = itemElem.elementsByTagName( "ComposerFrame" ); for ( int i = 0; i < frameList.size(); ++i ) { QDomElement frameElem = frameList.at( i ).toElement(); QgsComposerFrame* newFrame = new QgsComposerFrame( mComposition, this, 0, 0, 0, 0 ); newFrame->readXML( frameElem, doc ); addFrame( newFrame ); } } return true; }
QgsComposerItemCommand::QgsComposerItemCommand( QgsComposerItem* item, const QString& text, QUndoCommand* parent ) : QUndoCommand( text, parent ) , mItem( item ) , mMultiFrame( 0 ) , mFrameNumber( 0 ) , mFirstRun( true ) { //is item a frame? QgsComposerFrame* frame = dynamic_cast<QgsComposerFrame*>( mItem ); if ( frame ) { //store parent multiframe and frame index mMultiFrame = frame->multiFrame(); mFrameNumber = mMultiFrame->frameIndex( frame ); } }
void QgsComposerMultiFrame::handlePageChange() { if ( mComposition->numPages() < 1 ) { return; } if ( mResizeMode != RepeatOnEveryPage ) { return; } //remove items beginning on non-existing pages for ( int i = mFrameItems.size() - 1; i >= 0; --i ) { QgsComposerFrame* frame = mFrameItems[i]; int page = frame->pos().y() / ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ); if ( page > ( mComposition->numPages() - 1 ) ) { removeFrame( i ); } } //page number of the last item QgsComposerFrame* lastFrame = mFrameItems.last(); int lastItemPage = lastFrame->pos().y() / ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ); for ( int i = lastItemPage + 1; i < mComposition->numPages(); ++i ) { //copy last frame to current page QgsComposerFrame* newFrame = new QgsComposerFrame( mComposition, this, lastFrame->pos().x(), lastFrame->pos().y() + mComposition->paperHeight() + mComposition->spaceBetweenPages(), lastFrame->rect().width(), lastFrame->rect().height() ); addFrame( newFrame, false ); lastFrame = newFrame; } recalculateFrameSizes(); update(); }
void QgsComposerView::mouseReleaseEvent( QMouseEvent* e ) { if ( !composition() ) { return; } QPoint mousePressStopPoint = e->pos(); int diffX = mousePressStopPoint.x() - mMousePressStartPos.x(); int diffY = mousePressStopPoint.y() - mMousePressStartPos.y(); //was this just a click? or a click and drag? bool clickOnly = false; if ( qAbs( diffX ) < 2 && qAbs( diffY ) < 2 ) { clickOnly = true; } QPointF scenePoint = mapToScene( e->pos() ); if ( mPanning ) { mPanning = false; if ( clickOnly && e->button() == Qt::MidButton ) { //middle mouse button click = recenter on point //get current visible part of scene QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() ); QgsRectangle visibleRect = QgsRectangle( mapToScene( viewportRect ).boundingRect() ); visibleRect.scale( 1, scenePoint.x(), scenePoint.y() ); QRectF boundsRect = visibleRect.toRectF(); //zoom view to fit desired bounds fitInView( boundsRect, Qt::KeepAspectRatio ); } //set new cursor if ( mCurrentTool == Pan ) { viewport()->setCursor( Qt::OpenHandCursor ); } else { if ( composition() ) { //allow composer items to change cursor composition()->setPreventCursorChange( false ); } viewport()->setCursor( Qt::ArrowCursor ); } } if ( mMarqueeSelect ) { endMarqueeSelect( e ); return; } switch ( mCurrentTool ) { case Select: { QGraphicsView::mouseReleaseEvent( e ); break; } case Zoom: { if ( mMarqueeZoom ) { endMarqueeZoom( e ); } break; } case MoveItemContent: { if ( mMoveContentItem ) { //update map preview if composer map QgsComposerMap* composerMap = dynamic_cast<QgsComposerMap *>( mMoveContentItem ); if ( composerMap ) { composerMap->setOffset( 0, 0 ); } double moveX = scenePoint.x() - mMoveContentStartPos.x(); double moveY = scenePoint.y() - mMoveContentStartPos.y(); composition()->beginCommand( mMoveContentItem, tr( "Move item content" ) ); mMoveContentItem->moveContent( -moveX, -moveY ); composition()->endCommand(); mMoveContentItem = 0; } break; } case AddArrow: if ( composition() ) { QPointF scenePoint = mapToScene( e->pos() ); QPointF snappedScenePoint = composition()->snapPointToGrid( scenePoint ); QgsComposerArrow* composerArrow = new QgsComposerArrow( mRubberBandStartPos, QPointF( snappedScenePoint.x(), snappedScenePoint.y() ), composition() ); composition()->addComposerArrow( composerArrow ); composition()->clearSelection(); composerArrow->setSelected( true ); emit selectedItemChanged( composerArrow ); scene()->removeItem( mRubberBandLineItem ); delete mRubberBandLineItem; mRubberBandLineItem = 0; emit actionFinished(); composition()->pushAddRemoveCommand( composerArrow, tr( "Arrow added" ) ); } break; case AddRectangle: case AddTriangle: case AddEllipse: addShape( mCurrentTool ); break; case AddMap: if ( !mRubberBandItem || ( mRubberBandItem->rect().width() < 0.1 && mRubberBandItem->rect().height() < 0.1 ) ) { removeRubberBand(); return; } if ( composition() ) { QgsComposerMap* composerMap = new QgsComposerMap( composition(), mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), mRubberBandItem->rect().height() ); composition()->addComposerMap( composerMap ); composition()->clearSelection(); composerMap->setSelected( true ); emit selectedItemChanged( composerMap ); removeRubberBand(); emit actionFinished(); composition()->pushAddRemoveCommand( composerMap, tr( "Map added" ) ); } break; case AddHtml: if ( composition() ) { QgsComposerHtml* composerHtml = new QgsComposerHtml( composition(), true ); QgsAddRemoveMultiFrameCommand* command = new QgsAddRemoveMultiFrameCommand( QgsAddRemoveMultiFrameCommand::Added, composerHtml, composition(), tr( "Html item added" ) ); composition()->undoStack()->push( command ); QgsComposerFrame* frame = new QgsComposerFrame( composition(), composerHtml, mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), mRubberBandItem->rect().height() ); composition()->beginMultiFrameCommand( composerHtml, tr( "Html frame added" ) ); composerHtml->addFrame( frame ); composition()->endMultiFrameCommand(); composition()->clearSelection(); frame->setSelected( true ); emit selectedItemChanged( frame ); removeRubberBand(); emit actionFinished(); } default: break; } }
void QgsComposerMultiFrame::recalculateFrameSizes() { if ( mFrameItems.size() < 1 ) { return; } QSizeF size = totalSize(); double totalHeight = size.height(); if ( totalHeight < 1 ) { return; } double currentY = 0; double currentHeight = 0; QgsComposerFrame* currentItem = 0; for ( int i = 0; i < mFrameItems.size(); ++i ) { if ( currentY >= totalHeight ) { if ( mResizeMode == ExtendToNextPage ) //remove unneeded frames in extent mode { for ( int j = mFrameItems.size(); j > i; --j ) { removeFrame( j - 1 ); } } return; } currentItem = mFrameItems.value( i ); currentHeight = currentItem->rect().height(); currentItem->setContentSection( QRectF( 0, currentY, currentItem->rect().width(), currentHeight ) ); currentItem->update(); currentY += currentHeight; } //at end of frames but there is still content left. Add other pages if ResizeMode == if ( mResizeMode == ExtendToNextPage ) { while ( currentY < totalHeight ) { //find out on which page the lower left point of the last frame is int page = currentItem->transform().dy() / ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ); //add new pages if necessary if ( mComposition->numPages() < ( page + 2 ) ) { mComposition->setNumPages( page + 2 ); } //copy last frame QgsComposerFrame* newFrame = new QgsComposerFrame( mComposition, this, currentItem->transform().dx(), currentItem->transform().dy() + mComposition->paperHeight() + mComposition->spaceBetweenPages(), currentItem->rect().width(), currentItem->rect().height() ); newFrame->setContentSection( QRectF( 0, currentY, newFrame->rect().width(), newFrame->rect().height() ) ); currentY += newFrame->rect().height(); currentItem = newFrame; addFrame( newFrame, false ); } } }
void QgsComposition::sendItemAddedSignal( QgsComposerItem* item ) { //cast and send proper signal item->setSelected( true ); QgsComposerArrow* arrow = dynamic_cast<QgsComposerArrow*>( item ); if ( arrow ) { emit composerArrowAdded( arrow ); emit selectedItemChanged( arrow ); return; } QgsComposerLabel* label = dynamic_cast<QgsComposerLabel*>( item ); if ( label ) { emit composerLabelAdded( label ); emit selectedItemChanged( label ); return; } QgsComposerMap* map = dynamic_cast<QgsComposerMap*>( item ); if ( map ) { emit composerMapAdded( map ); emit selectedItemChanged( map ); return; } QgsComposerScaleBar* scalebar = dynamic_cast<QgsComposerScaleBar*>( item ); if ( scalebar ) { emit composerScaleBarAdded( scalebar ); emit selectedItemChanged( scalebar ); return; } QgsComposerLegend* legend = dynamic_cast<QgsComposerLegend*>( item ); if ( legend ) { emit composerLegendAdded( legend ); emit selectedItemChanged( legend ); return; } QgsComposerPicture* picture = dynamic_cast<QgsComposerPicture*>( item ); if ( picture ) { emit composerPictureAdded( picture ); emit selectedItemChanged( picture ); return; } QgsComposerShape* shape = dynamic_cast<QgsComposerShape*>( item ); if ( shape ) { emit composerShapeAdded( shape ); emit selectedItemChanged( shape ); return; } QgsComposerAttributeTable* table = dynamic_cast<QgsComposerAttributeTable*>( item ); if ( table ) { emit composerTableAdded( table ); emit selectedItemChanged( table ); return; } QgsComposerFrame* frame = dynamic_cast<QgsComposerFrame*>( item ); if ( frame ) { //emit composerFrameAdded( multiframe, frame, ); QgsComposerMultiFrame* mf = frame->multiFrame(); QgsComposerHtml* html = dynamic_cast<QgsComposerHtml*>( mf ); if ( html ) { emit composerHtmlFrameAdded( html, frame ); } emit selectedItemChanged( frame ); return; } }
void QgsComposerMultiFrame::recalculateFrameSizes() { if ( mFrameItems.empty() ) { return; } QSizeF size = totalSize(); double totalHeight = size.height(); if ( totalHeight < 1 ) { return; } double currentY = 0; double currentHeight = 0; QgsComposerFrame *currentItem = nullptr; for ( int i = 0; i < mFrameItems.size(); ++i ) { if ( mResizeMode != RepeatOnEveryPage && currentY >= totalHeight ) { if ( mResizeMode == RepeatUntilFinished || mResizeMode == ExtendToNextPage ) //remove unneeded frames in extent mode { bool removingPages = true; for ( int j = mFrameItems.size(); j > i; --j ) { int numPagesBefore = mComposition->numPages(); removeFrame( j - 1, removingPages ); //if removing the frame didn't also remove the page, then stop removing pages removingPages = removingPages && ( mComposition->numPages() < numPagesBefore ); } return; } } currentItem = mFrameItems.value( i ); currentHeight = currentItem->rect().height(); if ( mResizeMode == RepeatOnEveryPage ) { currentItem->setContentSection( QRectF( 0, 0, currentItem->rect().width(), currentHeight ) ); } else { currentHeight = findNearbyPageBreak( currentY + currentHeight ) - currentY; currentItem->setContentSection( QRectF( 0, currentY, currentItem->rect().width(), currentHeight ) ); } currentItem->update(); currentY += currentHeight; } //at end of frames but there is still content left. Add other pages if ResizeMode == if ( mResizeMode != UseExistingFrames ) { while ( ( mResizeMode == RepeatOnEveryPage ) || currentY < totalHeight ) { //find out on which page the lower left point of the last frame is int page = std::floor( ( currentItem->pos().y() + currentItem->rect().height() ) / ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ) ) + 1; if ( mResizeMode == RepeatOnEveryPage ) { if ( page >= mComposition->numPages() ) { break; } } else { //add an extra page if required if ( mComposition->numPages() < ( page + 1 ) ) { mComposition->setNumPages( page + 1 ); } } double frameHeight = 0; if ( mResizeMode == RepeatUntilFinished || mResizeMode == RepeatOnEveryPage ) { frameHeight = currentItem->rect().height(); } else //mResizeMode == ExtendToNextPage { frameHeight = ( currentY + mComposition->paperHeight() ) > totalHeight ? totalHeight - currentY : mComposition->paperHeight(); } double newFrameY = page * ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ); if ( mResizeMode == RepeatUntilFinished || mResizeMode == RepeatOnEveryPage ) { newFrameY += currentItem->pos().y() - ( page - 1 ) * ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ); } //create new frame QgsComposerFrame *newFrame = createNewFrame( currentItem, QPointF( currentItem->pos().x(), newFrameY ), QSizeF( currentItem->rect().width(), frameHeight ) ); if ( mResizeMode == RepeatOnEveryPage ) { newFrame->setContentSection( QRectF( 0, 0, newFrame->rect().width(), newFrame->rect().height() ) ); currentY += frameHeight; } else { double contentHeight = findNearbyPageBreak( currentY + newFrame->rect().height() ) - currentY; newFrame->setContentSection( QRectF( 0, currentY, newFrame->rect().width(), contentHeight ) ); currentY += contentHeight; } currentItem = newFrame; } } }
void QgsComposerView::mouseReleaseEvent( QMouseEvent* e ) { if ( !composition() ) { return; } if ( e->button() != Qt::LeftButton && ( composition()->selectionHandles()->isDragging() || composition()->selectionHandles()->isResizing() ) ) { //ignore clicks while dragging/resizing items return; } QPoint mousePressStopPoint = e->pos(); int diffX = mousePressStopPoint.x() - mMousePressStartPos.x(); int diffY = mousePressStopPoint.y() - mMousePressStartPos.y(); //was this just a click? or a click and drag? bool clickOnly = false; if ( qAbs( diffX ) < 2 && qAbs( diffY ) < 2 ) { clickOnly = true; } QPointF scenePoint = mapToScene( e->pos() ); if ( mMousePanning || mToolPanning ) { mMousePanning = false; mToolPanning = false; if ( clickOnly && e->button() == Qt::MidButton ) { //middle mouse button click = recenter on point //get current visible part of scene QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() ); QgsRectangle visibleRect = QgsRectangle( mapToScene( viewportRect ).boundingRect() ); visibleRect.scale( 1, scenePoint.x(), scenePoint.y() ); QRectF boundsRect = visibleRect.toRectF(); //zoom view to fit desired bounds fitInView( boundsRect, Qt::KeepAspectRatio ); } //set new cursor if ( mCurrentTool != Pan ) { if ( composition() ) { //allow composer items to change cursor composition()->setPreventCursorChange( false ); } } viewport()->setCursor( defaultCursorForTool( mCurrentTool ) ); } //for every other tool, ignore clicks of non-left button if ( e->button() != Qt::LeftButton ) { return; } if ( mMarqueeSelect ) { endMarqueeSelect( e ); return; } switch ( mCurrentTool ) { case Select: { QGraphicsView::mouseReleaseEvent( e ); break; } case Zoom: { if ( mMarqueeZoom ) { endMarqueeZoom( e ); } break; } case MoveItemContent: { if ( mMoveContentItem ) { //update map preview if composer map QgsComposerMap* composerMap = dynamic_cast<QgsComposerMap *>( mMoveContentItem ); if ( composerMap ) { composerMap->setOffset( 0, 0 ); } double moveX = scenePoint.x() - mMoveContentStartPos.x(); double moveY = scenePoint.y() - mMoveContentStartPos.y(); composition()->beginCommand( mMoveContentItem, tr( "Move item content" ) ); mMoveContentItem->moveContent( -moveX, -moveY ); composition()->endCommand(); mMoveContentItem = 0; mMovingItemContent = false; } break; } case AddArrow: if ( !composition() || !mRubberBandLineItem ) { scene()->removeItem( mRubberBandLineItem ); delete mRubberBandLineItem; mRubberBandLineItem = 0; return; } else { QgsComposerArrow* composerArrow = new QgsComposerArrow( mRubberBandLineItem->line().p1(), mRubberBandLineItem->line().p2(), composition() ); composition()->addComposerArrow( composerArrow ); composition()->clearSelection(); composerArrow->setSelected( true ); emit selectedItemChanged( composerArrow ); scene()->removeItem( mRubberBandLineItem ); delete mRubberBandLineItem; mRubberBandLineItem = 0; emit actionFinished(); composition()->pushAddRemoveCommand( composerArrow, tr( "Arrow added" ) ); } break; case AddRectangle: case AddTriangle: case AddEllipse: addShape( mCurrentTool ); break; case AddMap: if ( !composition() || !mRubberBandItem || ( mRubberBandItem->rect().width() < 0.1 && mRubberBandItem->rect().height() < 0.1 ) ) { removeRubberBand(); return; } else { QgsComposerMap* composerMap = new QgsComposerMap( composition(), mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), mRubberBandItem->rect().height() ); composition()->addComposerMap( composerMap ); composition()->clearSelection(); composerMap->setSelected( true ); emit selectedItemChanged( composerMap ); removeRubberBand(); emit actionFinished(); composition()->pushAddRemoveCommand( composerMap, tr( "Map added" ) ); } break; case AddPicture: if ( !composition() || !mRubberBandItem || ( mRubberBandItem->rect().width() < 0.1 && mRubberBandItem->rect().height() < 0.1 ) ) { removeRubberBand(); return; } else { QgsComposerPicture* newPicture = new QgsComposerPicture( composition() ); newPicture->setSceneRect( QRectF( mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), mRubberBandItem->rect().height() ) ); composition()->addComposerPicture( newPicture ); composition()->clearSelection(); newPicture->setSelected( true ); emit selectedItemChanged( newPicture ); removeRubberBand(); emit actionFinished(); composition()->pushAddRemoveCommand( newPicture, tr( "Picture added" ) ); } break; case AddLabel: if ( !composition() || !mRubberBandItem ) { removeRubberBand(); return; } else { QgsComposerLabel* newLabelItem = new QgsComposerLabel( composition() ); newLabelItem->setText( tr( "QGIS" ) ); newLabelItem->adjustSizeToText(); //make sure label size is sufficient to fit text double labelWidth = qMax( mRubberBandItem->rect().width(), newLabelItem->rect().width() ); double labelHeight = qMax( mRubberBandItem->rect().height(), newLabelItem->rect().height() ); newLabelItem->setSceneRect( QRectF( mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), labelWidth, labelHeight ) ); composition()->addComposerLabel( newLabelItem ); composition()->clearSelection(); newLabelItem->setSelected( true ); emit selectedItemChanged( newLabelItem ); removeRubberBand(); emit actionFinished(); composition()->pushAddRemoveCommand( newLabelItem, tr( "Label added" ) ); } break; case AddLegend: if ( !composition() || !mRubberBandItem ) { removeRubberBand(); return; } else { QgsComposerLegend* newLegend = new QgsComposerLegend( composition() ); newLegend->setSceneRect( QRectF( mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), mRubberBandItem->rect().height() ) ); composition()->addComposerLegend( newLegend ); newLegend->updateLegend(); composition()->clearSelection(); newLegend->setSelected( true ); emit selectedItemChanged( newLegend ); removeRubberBand(); emit actionFinished(); composition()->pushAddRemoveCommand( newLegend, tr( "Legend added" ) ); } break; case AddTable: if ( !composition() || !mRubberBandItem ) { removeRubberBand(); return; } else { QgsComposerAttributeTable* newTable = new QgsComposerAttributeTable( composition() ); newTable->setSceneRect( QRectF( mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), qMax( mRubberBandItem->rect().height(), 15.0 ) ) ); QList<const QgsComposerMap*> mapItemList = composition()->composerMapItems(); if ( mapItemList.size() > 0 ) { newTable->setComposerMap( mapItemList.at( 0 ) ); } composition()->addComposerTable( newTable ); composition()->clearSelection(); newTable->setSelected( true ); emit selectedItemChanged( newTable ); removeRubberBand(); emit actionFinished(); composition()->pushAddRemoveCommand( newTable, tr( "Table added" ) ); } break; case AddHtml: if ( !composition() || !mRubberBandItem || ( mRubberBandItem->rect().width() < 0.1 && mRubberBandItem->rect().height() < 0.1 ) ) { removeRubberBand(); return; } else { QgsComposerHtml* composerHtml = new QgsComposerHtml( composition(), true ); QgsAddRemoveMultiFrameCommand* command = new QgsAddRemoveMultiFrameCommand( QgsAddRemoveMultiFrameCommand::Added, composerHtml, composition(), tr( "Html item added" ) ); composition()->undoStack()->push( command ); QgsComposerFrame* frame = new QgsComposerFrame( composition(), composerHtml, mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), mRubberBandItem->rect().height() ); composition()->beginMultiFrameCommand( composerHtml, tr( "Html frame added" ) ); composerHtml->addFrame( frame ); composition()->endMultiFrameCommand(); composition()->clearSelection(); frame->setSelected( true ); emit selectedItemChanged( frame ); removeRubberBand(); emit actionFinished(); } default: break; } }
void QgsComposerMultiFrame::recalculateFrameSizes() { if ( mFrameItems.size() < 1 ) { return; } QSizeF size = totalSize(); double totalHeight = size.height(); if ( totalHeight < 1 ) { return; } double currentY = 0; double currentHeight = 0; QgsComposerFrame* currentItem = 0; for ( int i = 0; i < mFrameItems.size(); ++i ) { if ( mResizeMode != RepeatOnEveryPage && currentY >= totalHeight ) { if ( mResizeMode == RepeatUntilFinished || mResizeMode == ExtendToNextPage ) //remove unneeded frames in extent mode { for ( int j = mFrameItems.size(); j > i; --j ) { removeFrame( j - 1 ); } } return; } currentItem = mFrameItems.value( i ); currentHeight = currentItem->rect().height(); if ( mResizeMode == RepeatOnEveryPage ) { currentItem->setContentSection( QRectF( 0, 0, currentItem->rect().width(), currentHeight ) ); } else { currentItem->setContentSection( QRectF( 0, currentY, currentItem->rect().width(), currentHeight ) ); } currentItem->update(); currentY += currentHeight; } //at end of frames but there is still content left. Add other pages if ResizeMode == if ( mResizeMode != UseExistingFrames ) { while (( mResizeMode == RepeatOnEveryPage ) || currentY < totalHeight ) { //find out on which page the lower left point of the last frame is int page = currentItem->pos().y() / ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ); if ( mResizeMode == RepeatOnEveryPage ) { if ( page > mComposition->numPages() - 2 ) { break; } } else { if ( mComposition->numPages() < ( page + 2 ) ) { mComposition->setNumPages( page + 2 ); } } double frameHeight = 0; if ( mResizeMode == RepeatUntilFinished || mResizeMode == RepeatOnEveryPage ) { frameHeight = currentItem->rect().height(); } else //mResizeMode == ExtendToNextPage { frameHeight = ( currentY + mComposition->paperHeight() ) > totalHeight ? totalHeight - currentY : mComposition->paperHeight(); } double newFrameY = ( page + 1 ) * ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ); if ( mResizeMode == RepeatUntilFinished || mResizeMode == RepeatOnEveryPage ) { newFrameY += currentItem->pos().y() - page * ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ); } QgsComposerFrame* newFrame = new QgsComposerFrame( mComposition, this, currentItem->pos().x(), newFrameY, currentItem->rect().width(), frameHeight ); if ( mResizeMode == RepeatOnEveryPage ) { newFrame->setContentSection( QRectF( 0, 0, newFrame->rect().width(), newFrame->rect().height() ) ); } else { newFrame->setContentSection( QRectF( 0, currentY, newFrame->rect().width(), newFrame->rect().height() ) ); } currentY += frameHeight; currentItem = newFrame; addFrame( newFrame, false ); } } }