ソースを参照

Merge pull request #100 from malickf/master

fix AddImage bug  : recursive loop
master
PrzemyslawKlys 9年前
コミット
95530ee77b
2個のファイルの変更15行の追加17行の削除
  1. 14
    16
      DocX/DocX.cs
  2. 1
    1
      UnitTests/DocXUnitTests.cs

+ 14
- 16
DocX/DocX.cs ファイルの表示

@@ -2932,27 +2932,25 @@ namespace Novacode
/// </example>
/// <seealso cref="AddImage(Stream, string)"/>
/// <seealso cref="Paragraph.InsertPicture"/>
public Image AddImage(string filename, string contentType = "image/jpeg")
public Image AddImage(string filename)
{
if (string.IsNullOrEmpty(contentType))
string contentType = "";
// The extension this file has will be taken to be its format.
switch (Path.GetExtension(filename))
{
// The extension this file has will be taken to be its format.
switch (Path.GetExtension(filename))
{
case ".tiff": contentType = "image/tif"; break;
case ".tif": contentType = "image/tif"; break;
case ".png": contentType = "image/png"; break;
case ".bmp": contentType = "image/png"; break;
case ".gif": contentType = "image/gif"; break;
case ".jpg": contentType = "image/jpg"; break;
case ".jpeg": contentType = "image/jpeg"; break;
default: contentType = "image/jpg"; break;
}
case ".tiff": contentType = "image/tif"; break;
case ".tif": contentType = "image/tif"; break;
case ".png": contentType = "image/png"; break;
case ".bmp": contentType = "image/png"; break;
case ".gif": contentType = "image/gif"; break;
case ".jpg": contentType = "image/jpg"; break;
case ".jpeg": contentType = "image/jpeg"; break;
default: contentType = "image/jpg"; break;
}
return AddImage(filename, contentType);
return AddImage(filename as object, contentType);
}
/// <summary>
/// Add an Image into this document from a Stream.
/// </summary>

+ 1
- 1
UnitTests/DocXUnitTests.cs ファイルの表示

@@ -91,7 +91,7 @@ namespace UnitTests
// Check file size
FileInfo f = new FileInfo( temporaryFilePath );
Assert.IsTrue( f.Length == 9659 );
Assert.IsTrue( f.Length == 9658 );
}
// Delete the tempory file.

読み込み中…
キャンセル
保存