Skip to content

Commit

Permalink
Fix for wms server print. Add composer pictures after the composer maps
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15020 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jan 12, 2011
1 parent a8c4ad3 commit 645c69f
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/mapserver/qgsprojectparser.cpp
Expand Up @@ -846,8 +846,6 @@ QgsComposition* QgsProjectParser::initComposition( const QString& composerTempla
return 0;
}

QList<QDomElement> scaleBarElemList;

//go through all the item elements and add them to the composition (and to the lists)
QDomNodeList itemNodes = composerElem.childNodes();
for ( int i = 0; i < itemNodes.size(); ++i )
Expand All @@ -874,17 +872,6 @@ QgsComposition* QgsProjectParser::initComposition( const QString& composerTempla
legend->readXML( currentElem, *mXMLDoc );
composition->addItem( legend );
}
else if ( elemName == "ComposerPicture" )
{
QgsComposerPicture* picture = new QgsComposerPicture( composition );
picture->readXML( currentElem, *mXMLDoc );
composition->addItem( picture );
}
else if ( elemName == "ComposerScaleBar" )
{
//scalebars need to be loaded after the composer maps
scaleBarElemList.push_back( currentElem );
}
else if ( elemName == "ComposerShape" )
{
QgsComposerShape* shape = new QgsComposerShape( composition );
Expand All @@ -905,13 +892,23 @@ QgsComposition* QgsProjectParser::initComposition( const QString& composerTempla
}
}

//scalebars need to be loaded after the composer maps to receive the correct size
QList<QDomElement>::const_iterator scaleBarIt = scaleBarElemList.constBegin();
for ( ; scaleBarIt != scaleBarElemList.constEnd(); ++scaleBarIt )
//scalebars and pictures need to be loaded after the maps to receive the correct size / rotation
for ( int i = 0; i < itemNodes.size(); ++i )
{
QgsComposerScaleBar* bar = new QgsComposerScaleBar( composition );
bar->readXML( *scaleBarIt, *mXMLDoc );
composition->addItem( bar );
QDomElement currentElem = itemNodes.at( i ).toElement();
QString elemName = currentElem.tagName();
if ( elemName == "ComposerPicture" )
{
QgsComposerPicture* picture = new QgsComposerPicture( composition );
picture->readXML( currentElem, *mXMLDoc );
composition->addItem( picture );
}
else if ( elemName == "ComposerScaleBar" )
{
QgsComposerScaleBar* bar = new QgsComposerScaleBar( composition );
bar->readXML( currentElem, *mXMLDoc );
composition->addItem( bar );
}
}

return composition;
Expand Down

0 comments on commit 645c69f

Please sign in to comment.