Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[layouts] Prevent atlas export to a single-file GeoPDF file
Instead show a warning the GeoPDF exports are only available when
the "export as single file" options is turned off.

Fixes #34024
  • Loading branch information
nyalldawson committed Jun 8, 2020
1 parent 834204f commit da904fb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Expand Up @@ -3082,7 +3082,7 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf()
showForceVectorWarning();
}

bool singleFile = mLayout->customProperty( QStringLiteral( "singleFile" ), true ).toBool();
const bool singleFile = mLayout->customProperty( QStringLiteral( "singleFile" ), true ).toBool();

QString outputFileName;
QString dir;
Expand Down Expand Up @@ -3170,8 +3170,16 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf()
outputFileName = QDir( dir ).filePath( QStringLiteral( "atlas" ) ); // filename is overridden by atlas
}

bool allowGeoPdfExport = true;
QString geoPdfReason;
if ( singleFile )
{
allowGeoPdfExport = false;
geoPdfReason = tr( "GeoPDF export is not available when exporting an atlas to a single PDF file." );
}

QgsLayoutExporter::PdfExportSettings pdfSettings;
if ( !getPdfExportSettings( pdfSettings ) )
if ( !getPdfExportSettings( pdfSettings, allowGeoPdfExport, geoPdfReason ) )
return;

mView->setPaintingEnabled( false );
Expand Down Expand Up @@ -4320,7 +4328,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
return true;
}

bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExportSettings &settings )
bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExportSettings &settings, bool allowGeoPdfExport, const QString &geoPdfReason )
{
QgsRenderContext::TextRenderFormat prevTextRenderFormat = mMasterLayout->layoutProject()->labelingEngineSettings().defaultTextRenderFormat();
bool forceVector = false;
Expand Down Expand Up @@ -4353,30 +4361,29 @@ bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExport
}

// open options dialog

QString dialogGeoPdfReason = geoPdfReason;
QList< QgsLayoutItemMap * > maps;
if ( mLayout )
mLayout->layoutItems( maps );
bool allowGeoPdfExport = true;
QString geoPdfReason;

for ( const QgsLayoutItemMap *map : maps )
{
if ( !map->crs().isValid() )
{
allowGeoPdfExport = false;
geoPdfReason = tr( "One or more map items do not have a valid CRS set. This is required for GeoPDF export." );
dialogGeoPdfReason = tr( "One or more map items do not have a valid CRS set. This is required for GeoPDF export." );
break;
}

if ( map->mapRotation() != 0 || map->itemRotation() != 0 )
if ( map->mapRotation() != 0 || map->itemRotation() != 0 || map->dataDefinedProperties().isActive( QgsLayoutObject::MapRotation ) )
{
allowGeoPdfExport = false;
geoPdfReason = tr( "One or more map items are rotated. This is not supported for GeoPDF export." );
dialogGeoPdfReason = tr( "One or more map items are rotated. This is not supported for GeoPDF export." );
break;
}
}

QgsLayoutPdfExportOptionsDialog dialog( this, allowGeoPdfExport, geoPdfReason );
QgsLayoutPdfExportOptionsDialog dialog( this, allowGeoPdfExport, dialogGeoPdfReason );

dialog.setTextRenderFormat( prevTextRenderFormat );
dialog.setForceVector( forceVector );
Expand Down
2 changes: 1 addition & 1 deletion src/app/layout/qgslayoutdesignerdialog.h
Expand Up @@ -524,7 +524,7 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB
bool showFileSizeWarning();
bool getRasterExportSettings( QgsLayoutExporter::ImageExportSettings &settings, QSize &imageSize );
bool getSvgExportSettings( QgsLayoutExporter::SvgExportSettings &settings );
bool getPdfExportSettings( QgsLayoutExporter::PdfExportSettings &settings );
bool getPdfExportSettings( QgsLayoutExporter::PdfExportSettings &settings, bool allowGeoPdfExport = true, const QString &geoPdfReason = QString() );

void toggleAtlasActions( bool enabled );

Expand Down

0 comments on commit da904fb

Please sign in to comment.