Skip to content

Commit d6735d1

Browse files
author
mhugent
committedSep 22, 2009
Fix for bug 1931, removed some code parts for Qt<4.3 and some changes in svg export (but not yet enough)
git-svn-id: http://svn.osgeo.org/qgis/trunk@11701 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 071ac3b commit d6735d1

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed
 

‎src/app/composer/qgscomposer.cpp

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,12 @@ void QgsComposer::on_mActionExportAsImage_triggered()
641641
QgsDebugMsg( QString( "Selected filter: %1" ).arg( myFilterString ) );
642642
QgsDebugMsg( QString( "Image type: %1" ).arg( myFilterMap[myFilterString] ) );
643643

644+
// Add the file type suffix to the fileName if required
645+
if ( !myOutputFileNameQString.endsWith( myFilterMap[myFilterString] ) )
646+
{
647+
myOutputFileNameQString += "." + myFilterMap[myFilterString];
648+
}
649+
644650
myQSettings.setValue( "/UI/lastSaveAsImageFormat", myFilterMap[myFilterString] );
645651
myQSettings.setValue( "/UI/lastSaveAsImageFile", myOutputFileNameQString );
646652

@@ -687,16 +693,9 @@ void QgsComposer::on_mActionExportAsSVG_triggered()
687693
m->setCheckBoxQSettingsLabel( myQSettingsLabel );
688694
m->setMessageAsHtml( tr( "<p>The SVG export function in Qgis has several "
689695
"problems due to bugs and deficiencies in the " )
690-
#if QT_VERSION < 0x040300
691-
+ tr( "Qt4 svg code. Of note, text does not "
692-
"appear in the SVG file and there are problems "
693-
"with the map bounding box clipping other items "
694-
"such as the legend or scale bar.</p>" )
695-
#else
696696
+ tr( "Qt4 svg code. In particular, there are problems "
697697
"with layers not being clipped to the map "
698698
"bounding box.</p>" )
699-
#endif
700699
+ tr( "If you require a vector-based output file from "
701700
"Qgis it is suggested that you try printing "
702701
"to PostScript if the SVG output is not "
@@ -724,30 +723,26 @@ void QgsComposer::on_mActionExportAsSVG_triggered()
724723
//mView->setScene(0);//don't redraw the scene on the display while we render
725724
mComposition->setPlotStyle( QgsComposition::Print );
726725

727-
#if QT_VERSION < 0x040300
728-
Q3Picture pic;
729-
QPainter p( &pic );
730-
QRectF renderArea( 0, 0, ( mComposition->paperWidth() * mComposition->scale() ), ( mComposition->paperHeight() * mComposition->scale() ) );
731-
#else
732726
QSvgGenerator generator;
727+
generator.setTitle( QgsProject::instance()->title() );
733728
generator.setFileName( myOutputFileNameQString );
734-
generator.setSize( QSize(( int )mComposition->paperWidth(), ( int )mComposition->paperHeight() ) );
735-
generator.setResolution( 25.4 ); //because the rendering is done in mm, convert the dpi
729+
//width in pixel
730+
int width = ( int )( mComposition->paperWidth() * mComposition->printResolution() / 25.4 );
731+
//height in pixel
732+
int height = ( int )( mComposition->paperHeight() * mComposition->printResolution() / 25.4 );
733+
generator.setSize( QSize( width, height ) );
734+
generator.setResolution( mComposition->printResolution() ); //because the rendering is done in mm, convert the dpi
736735

737736
QPainter p( &generator );
738-
QRectF renderArea( 0, 0, mComposition->paperWidth(), mComposition->paperHeight() );
739-
#endif
740-
mComposition->render( &p, renderArea, renderArea );
737+
738+
QRectF sourceArea( 0, 0, mComposition->paperWidth(), mComposition->paperHeight() );
739+
QRectF targetArea( 0, 0, width, height );
740+
mComposition->render( &p, targetArea, sourceArea );
741+
741742
p.end();
742743

743744
mComposition->setPlotStyle( QgsComposition::Preview );
744745
//mView->setScene(mComposition->canvas()); //now that we're done, set the view to show the scene again
745-
746-
#if QT_VERSION < 0x040300
747-
QRect br = pic.boundingRect();
748-
749-
pic.save( myOutputFileNameQString, "svg" );
750-
#endif
751746
}
752747

753748
void QgsComposer::on_mActionSelectMoveItem_triggered()

0 commit comments

Comments
 (0)
Please sign in to comment.