@@ -23,7 +23,7 @@ public SvgFileType()
23
23
{
24
24
}
25
25
26
- // Dont change this text! It's used by a PSD import plugin to keep photoshop folder strure .
26
+ // Dont change this text! It's used by a PSD import plugin to keep photoshop folder structure .
27
27
public const string LayerGroupBegin = "Layer Group: {0}" ;
28
28
public const string LayerGroupEnd = "End Layer Group: {0}" ;
29
29
@@ -248,7 +248,7 @@ private static void RenderElements( List<SvgVisualElement> elements, Document ou
248
248
{
249
249
if ( element is PaintGroupBoundaries )
250
250
{
251
- // Render empty boundary and continue
251
+ // Render empty group boundary and continue
252
252
var pdnLayer = new BitmapLayer ( outputDocument . Width , outputDocument . Height ) ;
253
253
pdnLayer . Name = ( ( PaintGroupBoundaries ) element ) . ID ;
254
254
outputDocument . Layers . Add ( pdnLayer ) ;
@@ -262,6 +262,7 @@ private static void RenderElements( List<SvgVisualElement> elements, Document ou
262
262
}
263
263
264
264
bool itemShouldBeIgnored = false ;
265
+
265
266
// Turn on visibility from node to parent
266
267
var toCheck = ( SvgElement ) element ;
267
268
while ( toCheck != null )
@@ -413,10 +414,31 @@ private static string GetLayerTitle(SvgElement element)
413
414
layerName = getter . Invoke ( element , null ) as string ;
414
415
}
415
416
416
- if ( string . IsNullOrEmpty ( layerName ) )
417
+ if ( string . IsNullOrEmpty ( layerName ) )
417
418
{
418
419
layerName = element . GetType ( ) . Name ;
419
420
}
421
+
422
+ // Generate more meanfull name for a svg use node. Add reference element name in a case if it's local document.
423
+ var useElement = element as SvgUse ;
424
+ if ( useElement != null && useElement . ReferencedElement != null && ! string . IsNullOrEmpty ( useElement . ReferencedElement . OriginalString ) )
425
+ {
426
+ var str = useElement . ReferencedElement . OriginalString . Trim ( ) ;
427
+ if ( str . StartsWith ( "#" ) )
428
+ {
429
+ layerName += str . Replace ( '#' , ' ' ) ;
430
+ }
431
+ }
432
+
433
+ // Genearte more meanfull name for a svg text.
434
+ var text = element as SvgTextBase ;
435
+ if ( text != null && ! string . IsNullOrEmpty ( text . Text ) )
436
+ {
437
+ var textToUse = text . Text ;
438
+ if ( text . Text . Length > 35 )
439
+ textToUse = text . Text . Substring ( 0 , 35 ) ;
440
+ layerName += " " + textToUse ;
441
+ }
420
442
}
421
443
422
444
return layerName ;
@@ -435,12 +457,6 @@ private static IEnumerable<SvgElement> PrepareFlatElements(SvgElementCollection
435
457
continue ;
436
458
}
437
459
438
- // Dont prepare def lists for a separate rendering.
439
- if ( toRender is SvgDefinitionList )
440
- {
441
- continue ;
442
- }
443
-
444
460
var isGroup = toRender is SvgGroup ;
445
461
if ( isGroup )
446
462
{
@@ -489,6 +505,11 @@ private static IEnumerable<SvgElement> PrepareFlatElements(SvgElementCollection
489
505
yield return new PaintGroupBoundaries ( ) { ID = string . Format ( LayerGroupBegin , groupName ) , IsStart = true } ;
490
506
}
491
507
508
+ // Skip text with empty content. But keep all children nodes.
509
+ var textNode = toRender as SvgTextBase ;
510
+ if ( textNode != null && string . IsNullOrEmpty ( textNode . Text ) )
511
+ continue ;
512
+
492
513
yield return toRender ;
493
514
}
494
515
}
0 commit comments