Skip to content

Commit

Permalink
More resize mode fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Aug 19, 2012
1 parent 5d18483 commit cb3a08e
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions src/core/composer/qgscomposermultiframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,32 +89,53 @@ void QgsComposerMultiFrame::recalculateFrameSizes()
}

//at end of frames but there is still content left. Add other pages if ResizeMode ==
if ( mResizeMode == RepeatUntilFinished || mResizeMode == ExtendToNextPage )
if ( mResizeMode != UseExistingFrames )
{
while ( currentY < totalHeight )
while (( mResizeMode == RepeatOnEveryPage ) || 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 ) )
if ( mResizeMode == RepeatOnEveryPage )
{
mComposition->setNumPages( page + 2 );
if ( page > mComposition->numPages() - 2 )
{
break;
}
}
else
{
if ( mComposition->numPages() < ( page + 2 ) )
{
mComposition->setNumPages( page + 2 );
}
}

double frameHeight = 0;
if ( mResizeMode == RepeatUntilFinished )
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->transform().dy() - page * ( mComposition->paperHeight() + mComposition->spaceBetweenPages() );
}
QgsComposerFrame* newFrame = new QgsComposerFrame( mComposition, this, currentItem->transform().dx(),
( mComposition->numPages() - 1 ) * ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ),
newFrameY,
currentItem->rect().width(), frameHeight );
newFrame->setContentSection( QRectF( 0, currentY, newFrame->rect().width(), newFrame->rect().height() ) );
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 );
Expand Down

0 comments on commit cb3a08e

Please sign in to comment.