Skip to content

Commit 7e274d8

Browse files
committedJun 29, 2011
Fix replacement in style attribute
1 parent 66c009f commit 7e274d8

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed
 

‎src/core/symbology-ng/qgssvgcache.cpp

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ QgsSvgCacheEntry* QgsSvgCache::insertSVG( const QString& file, double size, cons
157157
}
158158

159159
void QgsSvgCache::containsParams( const QString& path, bool& hasFillParam, QColor& defaultFillColor, bool& hasOutlineParam, QColor& defaultOutlineColor,
160-
bool& hasOutlineWidthParam, double& defaultOutlineWidth ) const
160+
bool& hasOutlineWidthParam, double& defaultOutlineWidth ) const
161161
{
162162
/*hasFillParam = false;
163163
hasOutlineParam = false;
@@ -191,7 +191,7 @@ void QgsSvgCache::containsParams( const QString& path, bool& hasFillParam, QColo
191191
}*/
192192

193193
defaultFillColor = QColor( Qt::black );
194-
defaultOutlineColor= QColor( Qt::black );
194+
defaultOutlineColor = QColor( Qt::black );
195195
defaultOutlineWidth = 1.0;
196196

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

400400
void QgsSvgCache::containsElemParams( const QDomElement& elem, bool& hasFillParam, QColor& defaultFill, bool& hasOutlineParam, QColor& defaultOutline,
401-
bool& hasOutlineWidthParam, double& defaultOutlineWidth ) const
401+
bool& hasOutlineWidthParam, double& defaultOutlineWidth ) const
402402
{
403-
if( elem.isNull() )
403+
if ( elem.isNull() )
404404
{
405405
return;
406406
}
407407

408408
//we already have all the information, no need to go deeper
409-
if( hasFillParam && hasOutlineParam && hasOutlineWidthParam )
409+
if ( hasFillParam && hasOutlineParam && hasOutlineWidthParam )
410410
{
411411
return;
412412
}
@@ -426,27 +426,34 @@ void QgsSvgCache::containsElemParams( const QDomElement& elem, bool& hasFillPara
426426
QStringList::const_iterator entryIt = entryList.constBegin();
427427
for ( ; entryIt != entryList.constEnd(); ++entryIt )
428428
{
429-
valueSplit = entryIt->split(" ");
430-
if( !hasFillParam && entryIt->startsWith( "param(fill)" ) )
429+
QStringList keyValueSplit = entryIt->split( ':' );
430+
if ( keyValueSplit.size() < 2 )
431+
{
432+
continue;
433+
}
434+
QString key = keyValueSplit.at( 0 );
435+
QString value = keyValueSplit.at( 1 );
436+
valueSplit = value.split( " " );
437+
if ( !hasFillParam && value.startsWith( "param(fill)" ) )
431438
{
432439
hasFillParam = true;
433-
if( valueSplit.size() > 1 )
440+
if ( valueSplit.size() > 1 )
434441
{
435442
defaultFill = QColor( valueSplit.at( 1 ) );
436443
}
437444
}
438-
else if( !hasOutlineParam && entryIt->startsWith( "param(outline)" ) )
445+
else if ( !hasOutlineParam && value.startsWith( "param(outline)" ) )
439446
{
440447
hasOutlineParam = true;
441-
if( valueSplit.size() > 1 )
448+
if ( valueSplit.size() > 1 )
442449
{
443450
defaultOutline = QColor( valueSplit.at( 1 ) );
444451
}
445452
}
446-
else if( !hasOutlineWidthParam && entryIt->startsWith( "param(outlineWidth)" ) )
453+
else if ( !hasOutlineWidthParam && value.startsWith( "param(outlineWidth)" ) )
447454
{
448455
hasOutlineWidthParam = true;
449-
if( valueSplit.size() > 1 )
456+
if ( valueSplit.size() > 1 )
450457
{
451458
defaultOutlineWidth = valueSplit.at( 1 ).toDouble();
452459
}
@@ -456,27 +463,27 @@ void QgsSvgCache::containsElemParams( const QDomElement& elem, bool& hasFillPara
456463
else
457464
{
458465
QString value = attribute.value();
459-
valueSplit = value.split(" ");
466+
valueSplit = value.split( " " );
460467
if ( !hasFillParam && value.startsWith( "param(fill)" ) )
461468
{
462469
hasFillParam = true;
463-
if( valueSplit.size() > 1 )
470+
if ( valueSplit.size() > 1 )
464471
{
465472
defaultFill = QColor( valueSplit.at( 1 ) );
466473
}
467474
}
468-
else if( !hasOutlineParam && value.startsWith( "param(outline)" ) )
475+
else if ( !hasOutlineParam && value.startsWith( "param(outline)" ) )
469476
{
470477
hasOutlineParam = true;
471-
if( valueSplit.size() > 1 )
478+
if ( valueSplit.size() > 1 )
472479
{
473480
defaultOutline = QColor( valueSplit.at( 1 ) );
474481
}
475482
}
476-
else if( !hasOutlineWidthParam && value.startsWith( "param(outlineWidth)" ) )
483+
else if ( !hasOutlineWidthParam && value.startsWith( "param(outlineWidth)" ) )
477484
{
478485
hasOutlineWidthParam = true;
479-
if( valueSplit.size() > 1 )
486+
if ( valueSplit.size() > 1 )
480487
{
481488
defaultOutlineWidth = valueSplit.at( 1 ).toDouble();
482489
}

0 commit comments

Comments
 (0)