@@ -32,17 +32,19 @@ public sealed class ExcelPicture : ExcelDrawing, IPictureContainer
32
32
{
33
33
#region "Constructors"
34
34
internal ExcelPicture ( ExcelDrawings drawings , XmlNode node , Uri hyperlink , ePictureType type ) :
35
- base ( drawings , node , "xdr:pic" , "xdr:nvPicPr/xdr:cNvPr" )
35
+ base ( drawings , node , "xdr:pic/ " , "xdr:nvPicPr/xdr:cNvPr" )
36
36
{
37
+ Init ( ) ;
37
38
CreatePicNode ( node , type ) ;
38
39
Hyperlink = hyperlink ;
39
40
Image = new ExcelImage ( this ) ;
40
41
}
41
42
42
43
internal ExcelPicture ( ExcelDrawings drawings , XmlNode node , ExcelGroupShape shape = null ) :
43
- base ( drawings , node , "xdr:pic" , "xdr:nvPicPr/xdr:cNvPr" , shape )
44
+ base ( drawings , node , shape == null ? "xdr:pic/" : " ", "xdr:nvPicPr/xdr:cNvPr" , shape )
44
45
{
45
- XmlNode picNode = node . SelectSingleNode ( "xdr:pic/xdr:blipFill/a:blip" , drawings . NameSpaceManager ) ;
46
+ Init ( ) ;
47
+ XmlNode picNode = node . SelectSingleNode ( $ "{ _topPath } xdr:blipFill/a:blip", drawings . NameSpaceManager ) ;
46
48
if ( picNode != null && picNode . Attributes [ "embed" , ExcelPackage . schemaRelationships ] != null )
47
49
{
48
50
IPictureContainer container = this ;
@@ -78,14 +80,20 @@ internal ExcelPicture(ExcelDrawings drawings, XmlNode node, ExcelGroupShape shap
78
80
container . ImageHash = ii . Hash ;
79
81
}
80
82
}
83
+ private void Init ( )
84
+ {
85
+ _lockAspectRatioPath = $ "{ _topPath } xdr:nvPicPr/xdr:cNvPicPr/a:picLocks/@noChangeAspect";
86
+ _preferRelativeResizePath = $ "{ _topPath } xdr:nvPicPr/xdr:cNvPicPr/@preferRelativeResize";
87
+ }
88
+
81
89
private void SetRelId ( XmlNode node , ePictureType type , string relID )
82
90
{
83
91
//Create relationship
84
- node . SelectSingleNode ( "xdr:pic/ xdr:blipFill/a:blip/@r:embed", NameSpaceManager ) . Value = relID ;
92
+ node . SelectSingleNode ( $ " { _topPath } xdr:blipFill/a:blip/@r:embed", NameSpaceManager ) . Value = relID ;
85
93
86
94
if ( type == ePictureType . Svg )
87
95
{
88
- node . SelectSingleNode ( "xdr:pic/ xdr:blipFill/a:blip/a:extLst/a:ext/asvg:svgBlip/@r:embed", NameSpaceManager ) . Value = relID ;
96
+ node . SelectSingleNode ( $ " { _topPath } xdr:blipFill/a:blip/a:extLst/a:ext/asvg:svgBlip/@r:embed", NameSpaceManager ) . Value = relID ;
89
97
}
90
98
}
91
99
@@ -269,7 +277,7 @@ public ExcelDrawingFill Fill
269
277
{
270
278
if ( _fill == null )
271
279
{
272
- _fill = new ExcelDrawingFill ( _drawings , NameSpaceManager , TopNode , "xdr:pic/ xdr:spPr", SchemaNodeOrder ) ;
280
+ _fill = new ExcelDrawingFill ( _drawings , NameSpaceManager , TopNode , $ " { _topPath } xdr:spPr", SchemaNodeOrder ) ;
273
281
}
274
282
return _fill ;
275
283
}
@@ -284,7 +292,7 @@ public ExcelDrawingBorder Border
284
292
{
285
293
if ( _border == null )
286
294
{
287
- _border = new ExcelDrawingBorder ( _drawings , NameSpaceManager , TopNode , "xdr:pic/ xdr:spPr/a:ln", SchemaNodeOrder ) ;
295
+ _border = new ExcelDrawingBorder ( _drawings , NameSpaceManager , TopNode , $ " { _topPath } xdr:spPr/a:ln", SchemaNodeOrder ) ;
288
296
}
289
297
return _border ;
290
298
}
@@ -299,12 +307,12 @@ public ExcelDrawingEffectStyle Effect
299
307
{
300
308
if ( _effect == null )
301
309
{
302
- _effect = new ExcelDrawingEffectStyle ( _drawings , NameSpaceManager , TopNode , "xdr:pic/ xdr:spPr/a:effectLst", SchemaNodeOrder ) ;
310
+ _effect = new ExcelDrawingEffectStyle ( _drawings , NameSpaceManager , TopNode , $ " { _topPath } xdr:spPr/a:effectLst", SchemaNodeOrder ) ;
303
311
}
304
312
return _effect ;
305
313
}
306
314
}
307
- const string _preferRelativeResizePath = "xdr:pic/xdr:nvPicPr/xdr:cNvPicPr/@preferRelativeResize" ;
315
+ string _preferRelativeResizePath ;
308
316
/// <summary>
309
317
/// Relative to original picture size
310
318
/// </summary>
@@ -319,7 +327,7 @@ public bool PreferRelativeResize
319
327
SetXmlNodeBool ( _preferRelativeResizePath , value ) ;
320
328
}
321
329
}
322
- const string _lockAspectRatioPath = "xdr:pic/xdr:nvPicPr/xdr:cNvPicPr/a:picLocks/@noChangeAspect" ;
330
+ string _lockAspectRatioPath ;
323
331
/// <summary>
324
332
/// Lock aspect ratio
325
333
/// </summary>
@@ -380,10 +388,10 @@ void IPictureContainer.RemoveImage()
380
388
void IPictureContainer . SetNewImage ( )
381
389
{
382
390
var relId = ( ( IPictureContainer ) this ) . RelPic . Id ;
383
- TopNode . SelectSingleNode ( "xdr:pic/ xdr:blipFill/a:blip/@r:embed", NameSpaceManager ) . Value = relId ;
391
+ TopNode . SelectSingleNode ( $ " { _topPath } xdr:blipFill/a:blip/@r:embed", NameSpaceManager ) . Value = relId ;
384
392
if ( Image . Type == ePictureType . Svg )
385
393
{
386
- TopNode . SelectSingleNode ( "xdr:pic/ xdr:blipFill/a:blip/a:extLst/a:ext/asvg:svgBlip/@r:embed", NameSpaceManager ) . Value = relId ;
394
+ TopNode . SelectSingleNode ( $ " { _topPath } xdr:blipFill/a:blip/a:extLst/a:ext/asvg:svgBlip/@r:embed", NameSpaceManager ) . Value = relId ;
387
395
}
388
396
}
389
397
0 commit comments