Skip to content
Permalink
Browse files

More resize mode fixes

  • Loading branch information
mhugent committed Aug 19, 2012
1 parent 5d18483 commit cb3a08e6efe193c8bd9fe9d3675678f9e5466975
Showing with 30 additions and 9 deletions.
  1. +30 −9 src/core/composer/qgscomposermultiframe.cpp
@@ -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 );

0 comments on commit cb3a08e

Please sign in to comment.
You can’t perform that action at this time.