Skip to content

Commit

Permalink
Fix replacement in style attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jun 29, 2011
1 parent 66c009f commit 7e274d8
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions src/core/symbology-ng/qgssvgcache.cpp
Expand Up @@ -157,7 +157,7 @@ QgsSvgCacheEntry* QgsSvgCache::insertSVG( const QString& file, double size, cons
}

void QgsSvgCache::containsParams( const QString& path, bool& hasFillParam, QColor& defaultFillColor, bool& hasOutlineParam, QColor& defaultOutlineColor,
bool& hasOutlineWidthParam, double& defaultOutlineWidth ) const
bool& hasOutlineWidthParam, double& defaultOutlineWidth ) const
{
/*hasFillParam = false;
hasOutlineParam = false;
Expand Down Expand Up @@ -191,7 +191,7 @@ void QgsSvgCache::containsParams( const QString& path, bool& hasFillParam, QColo
}*/

defaultFillColor = QColor( Qt::black );
defaultOutlineColor= QColor( Qt::black );
defaultOutlineColor = QColor( Qt::black );
defaultOutlineWidth = 1.0;

QFile svgFile( path );
Expand Down Expand Up @@ -398,15 +398,15 @@ void QgsSvgCache::replaceElemParams( QDomElement& elem, const QColor& fill, cons
}

void QgsSvgCache::containsElemParams( const QDomElement& elem, bool& hasFillParam, QColor& defaultFill, bool& hasOutlineParam, QColor& defaultOutline,
bool& hasOutlineWidthParam, double& defaultOutlineWidth ) const
bool& hasOutlineWidthParam, double& defaultOutlineWidth ) const
{
if( elem.isNull() )
if ( elem.isNull() )
{
return;
}

//we already have all the information, no need to go deeper
if( hasFillParam && hasOutlineParam && hasOutlineWidthParam )
if ( hasFillParam && hasOutlineParam && hasOutlineWidthParam )
{
return;
}
Expand All @@ -426,27 +426,34 @@ void QgsSvgCache::containsElemParams( const QDomElement& elem, bool& hasFillPara
QStringList::const_iterator entryIt = entryList.constBegin();
for ( ; entryIt != entryList.constEnd(); ++entryIt )
{
valueSplit = entryIt->split(" ");
if( !hasFillParam && entryIt->startsWith( "param(fill)" ) )
QStringList keyValueSplit = entryIt->split( ':' );
if ( keyValueSplit.size() < 2 )
{
continue;
}
QString key = keyValueSplit.at( 0 );
QString value = keyValueSplit.at( 1 );
valueSplit = value.split( " " );
if ( !hasFillParam && value.startsWith( "param(fill)" ) )
{
hasFillParam = true;
if( valueSplit.size() > 1 )
if ( valueSplit.size() > 1 )
{
defaultFill = QColor( valueSplit.at( 1 ) );
}
}
else if( !hasOutlineParam && entryIt->startsWith( "param(outline)" ) )
else if ( !hasOutlineParam && value.startsWith( "param(outline)" ) )
{
hasOutlineParam = true;
if( valueSplit.size() > 1 )
if ( valueSplit.size() > 1 )
{
defaultOutline = QColor( valueSplit.at( 1 ) );
}
}
else if( !hasOutlineWidthParam && entryIt->startsWith( "param(outlineWidth)" ) )
else if ( !hasOutlineWidthParam && value.startsWith( "param(outlineWidth)" ) )
{
hasOutlineWidthParam = true;
if( valueSplit.size() > 1 )
if ( valueSplit.size() > 1 )
{
defaultOutlineWidth = valueSplit.at( 1 ).toDouble();
}
Expand All @@ -456,27 +463,27 @@ void QgsSvgCache::containsElemParams( const QDomElement& elem, bool& hasFillPara
else
{
QString value = attribute.value();
valueSplit = value.split(" ");
valueSplit = value.split( " " );
if ( !hasFillParam && value.startsWith( "param(fill)" ) )
{
hasFillParam = true;
if( valueSplit.size() > 1 )
if ( valueSplit.size() > 1 )
{
defaultFill = QColor( valueSplit.at( 1 ) );
}
}
else if( !hasOutlineParam && value.startsWith( "param(outline)" ) )
else if ( !hasOutlineParam && value.startsWith( "param(outline)" ) )
{
hasOutlineParam = true;
if( valueSplit.size() > 1 )
if ( valueSplit.size() > 1 )
{
defaultOutline = QColor( valueSplit.at( 1 ) );
}
}
else if( !hasOutlineWidthParam && value.startsWith( "param(outlineWidth)" ) )
else if ( !hasOutlineWidthParam && value.startsWith( "param(outlineWidth)" ) )
{
hasOutlineWidthParam = true;
if( valueSplit.size() > 1 )
if ( valueSplit.size() > 1 )
{
defaultOutlineWidth = valueSplit.at( 1 ).toDouble();
}
Expand Down

0 comments on commit 7e274d8

Please sign in to comment.