Skip to content

Commit

Permalink
[composer] Correctly handle shape frame and backgrounds from pre 2.0 …
Browse files Browse the repository at this point in the history
…projects (fix #8597)
  • Loading branch information
nyalldawson committed Jun 7, 2014
1 parent 6b973e1 commit 476faee
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/core/composer/qgscomposershape.cpp 100755 → 100644
Expand Up @@ -337,6 +337,56 @@ bool QgsComposerShape::readXML( const QDomElement& itemElem, const QDomDocument&
}
properties.insert( "color_border", QgsSymbolLayerV2Utils::encodeColor( pen().color() ) );
properties.insert( "width_border", QString::number( pen().widthF() ) );

//for pre 2.0 projects, shape colour and outline were specified in a different element...
QDomNodeList outlineColorList = itemElem.elementsByTagName( "OutlineColor" );
if ( outlineColorList.size() > 0 )
{
QDomElement frameColorElem = outlineColorList.at( 0 ).toElement();
bool redOk, greenOk, blueOk, alphaOk, widthOk;
int penRed, penGreen, penBlue, penAlpha;
double penWidth;

penWidth = itemElem.attribute( "outlineWidth" ).toDouble( &widthOk );
penRed = frameColorElem.attribute( "red" ).toDouble( &redOk );
penGreen = frameColorElem.attribute( "green" ).toDouble( &greenOk );
penBlue = frameColorElem.attribute( "blue" ).toDouble( &blueOk );
penAlpha = frameColorElem.attribute( "alpha" ).toDouble( &alphaOk );

if ( redOk && greenOk && blueOk && alphaOk && widthOk )
{
properties.insert( "color_border", QgsSymbolLayerV2Utils::encodeColor( QColor( penRed, penGreen, penBlue, penAlpha ) ) );
properties.insert( "width_border", QString::number( penWidth ) );
}
}
QDomNodeList fillColorList = itemElem.elementsByTagName( "FillColor" );
if ( fillColorList.size() > 0 )
{
QDomElement fillColorElem = fillColorList.at( 0 ).toElement();
bool redOk, greenOk, blueOk, alphaOk;
int fillRed, fillGreen, fillBlue, fillAlpha;

fillRed = fillColorElem.attribute( "red" ).toDouble( &redOk );
fillGreen = fillColorElem.attribute( "green" ).toDouble( &greenOk );
fillBlue = fillColorElem.attribute( "blue" ).toDouble( &blueOk );
fillAlpha = fillColorElem.attribute( "alpha" ).toDouble( &alphaOk );

if ( redOk && greenOk && blueOk && alphaOk )
{
properties.insert( "color", QgsSymbolLayerV2Utils::encodeColor( QColor( fillRed, fillGreen, fillBlue, fillAlpha ) ) );
properties.insert( "style", "solid" );
}
}
if ( itemElem.hasAttribute( "transparentFill" ) )
{
//old style (pre 2.0) of specifying that shapes had no fill
bool hasOldTransparentFill = itemElem.attribute( "transparentFill", "0" ).toInt();
if ( hasOldTransparentFill )
{
properties.insert( "style", "no" );
}
}

mShapeStyleSymbol = QgsFillSymbolV2::createSimple( properties );
}
emit itemChanged();
Expand Down

0 comments on commit 476faee

Please sign in to comment.