Skip to content
Permalink
Browse files

[composer] Ensure that data defined page size and orientation is corr…

…ectly set when printing directly from an atlas. (Note that mixed orientation prints are unsupported on some platforms/print drivers)
  • Loading branch information
nyalldawson committed Aug 12, 2014
1 parent ffd3f88 commit 692d0f5cb7c263bb8c51b6b98cdc07b7afa84630
Showing with 15 additions and 7 deletions.
  1. +2 −2 src/app/composer/qgscomposer.cpp
  2. +11 −3 src/core/composer/qgscomposition.cpp
  3. +2 −2 src/core/composer/qgscomposition.h
@@ -1590,12 +1590,12 @@ void QgsComposer::printComposition( QgsComposer::OutputMode mode )
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
if ( mode == QgsComposer::Single )
{
mComposition->print( mPrinter );
mComposition->print( mPrinter, true );
}
else
{

mComposition->beginPrint( mPrinter );
mComposition->beginPrint( mPrinter, true );
QPainter painter( &mPrinter );

loadAtlasPredefinedScalesFromProject();
@@ -2507,19 +2507,27 @@ void QgsComposition::doPrint( QPrinter& printer, QPainter& p, bool startNewPage
}
}

void QgsComposition::beginPrint( QPrinter &printer )
void QgsComposition::beginPrint( QPrinter &printer, const bool evaluateDDPageSize )
{
//set resolution based on composer setting
printer.setFullPage( true );
printer.setColorMode( QPrinter::Color );

//set user-defined resolution
printer.setResolution( printResolution() );

if ( evaluateDDPageSize )
{
//set data defined page size
refreshPageSize();
printer.setPaperSize( QSizeF( paperWidth(), paperHeight() ), QPrinter::Millimeter );
printer.setOrientation( paperWidth() > paperHeight() ? QPrinter::Landscape : QPrinter::Portrait );
}
}

bool QgsComposition::print( QPrinter &printer )
bool QgsComposition::print( QPrinter &printer, const bool evaluateDDPageSize )
{
beginPrint( printer );
beginPrint( printer, evaluateDDPageSize );
QPainter p;
bool ready = p.begin( &printer );
if ( !ready )
@@ -489,7 +489,7 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
//printing

/** Prepare the printer for printing */
void beginPrint( QPrinter& printer );
void beginPrint( QPrinter& printer, const bool evaluateDDPageSize = false );
/** Prepare the printer for printing in a PDF */
void beginPrintAsPDF( QPrinter& printer, const QString& file );

@@ -503,7 +503,7 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
/**Convenience function that prepares the printer and prints
* @returns true if print was successful
*/
bool print( QPrinter &printer );
bool print( QPrinter &printer, const bool evaluateDDPageSize = false );

/**Convenience function that prepares the printer for printing in PDF and prints
* @returns true if export was successful

0 comments on commit 692d0f5

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