diff --git a/.gitignore b/.gitignore index 66540a8..b34e284 100644 --- a/.gitignore +++ b/.gitignore @@ -262,3 +262,6 @@ pkg/ pkgobj/ /Code/Npoi.Samples.CreateNewSpreadsheet/newbook.core.xlsx *.ppt +*.opc +*.zip +*.ole2 diff --git a/src/Npoi.Core.Ooxml/XSSF/UserModel/XSSFTextParagraph.cs b/src/Npoi.Core.Ooxml/XSSF/UserModel/XSSFTextParagraph.cs index 685f397..928ff47 100644 --- a/src/Npoi.Core.Ooxml/XSSF/UserModel/XSSFTextParagraph.cs +++ b/src/Npoi.Core.Ooxml/XSSF/UserModel/XSSFTextParagraph.cs @@ -358,6 +358,13 @@ namespace Npoi.Core.XSSF.UserModel } } + + public int GetLevel() { + CT_TextParagraphProperties pr = _p.pPr; + if (pr == null) return 0; + return pr.lvl; + } + /** * * @return the color of bullet characters within a given paragraph. @@ -368,19 +375,6 @@ namespace Npoi.Core.XSSF.UserModel { get { - //ParagraphPropertyFetcher fetcher = new ParagraphPropertyFetcher(getLevel()){ - // public bool fetch(CTTextParagraphProperties props){ - // if(props.IsSetBuClr()){ - // if(props.GetBuClr().IsSetSrgbClr()){ - // CTSRgbColor clr = props.GetBuClr().GetSrgbClr(); - // byte[] rgb = clr.GetVal(); - // SetValue(new Color(0xFF & rgb[0], 0xFF & rgb[1], 0xFF & rgb[2])); - // return true; - // } - // } - // return false; - // } - //}; ParagraphPropertyFetcherBulletFontColor fetcher = new ParagraphPropertyFetcherBulletFontColor(Level); fetchParagraphProperty(fetcher); return fetcher.GetValue(); diff --git a/test/Npoi.Core.Ooxml.TestCases/SS/Formula/Eval/TestXSSFCircularReferences.cs b/test/Npoi.Core.Ooxml.TestCases/SS/Formula/Eval/TestXSSFCircularReferences.cs index 583ed0f..1b66ef8 100644 --- a/test/Npoi.Core.Ooxml.TestCases/SS/Formula/Eval/TestXSSFCircularReferences.cs +++ b/test/Npoi.Core.Ooxml.TestCases/SS/Formula/Eval/TestXSSFCircularReferences.cs @@ -26,7 +26,6 @@ namespace Npoi.Core.SS.Formula.Eval * * @author Josh Micich */ - [TestFixture] public class TestXSSFCircularReferences : BaseTestCircularReferences { diff --git a/test/Npoi.Core.Ooxml.TestCases/appsettings.json b/test/Npoi.Core.Ooxml.TestCases/appsettings.json new file mode 100644 index 0000000..0ce719b --- /dev/null +++ b/test/Npoi.Core.Ooxml.TestCases/appsettings.json @@ -0,0 +1,3 @@ +{ + "POI.testdata.path": "..\\test-data" +} \ No newline at end of file diff --git a/test/Npoi.Core.Ooxml.TestCases/project.json b/test/Npoi.Core.Ooxml.TestCases/project.json index fe647f8..40c29ec 100644 --- a/test/Npoi.Core.Ooxml.TestCases/project.json +++ b/test/Npoi.Core.Ooxml.TestCases/project.json @@ -7,7 +7,9 @@ "Npoi.Core.Ooxml": "1.1.0-*", "SharpZipLib.NETStandard": "0.86.0.1", "NUnit": "3.5.0", - "dotnet-test-nunit": "3.4.0-beta-3" + "dotnet-test-nunit": "3.4.0-beta-3", + "Microsoft.Extensions.Configuration": "1.1.0", + "Microsoft.Extensions.Configuration.Json": "1.1.0" }, "frameworks": { diff --git a/test/Npoi.Core.OpenXml4Net.Tests/appsettings.json b/test/Npoi.Core.OpenXml4Net.Tests/appsettings.json index 9466f3f..0ce719b 100644 --- a/test/Npoi.Core.OpenXml4Net.Tests/appsettings.json +++ b/test/Npoi.Core.OpenXml4Net.Tests/appsettings.json @@ -1,3 +1,3 @@ { - "POI.testdata.path": "..\\..\\..\\Npoi.Core.OpenXml4Net.Tests\\test-data" + "POI.testdata.path": "..\\test-data" } \ No newline at end of file diff --git a/test/Npoi.Core.OpenXml4Net.Tests/project.json b/test/Npoi.Core.OpenXml4Net.Tests/project.json index 7ef1a07..9951f3b 100644 --- a/test/Npoi.Core.OpenXml4Net.Tests/project.json +++ b/test/Npoi.Core.OpenXml4Net.Tests/project.json @@ -2,7 +2,6 @@ "version": "1.1.0-*", "buildOptions": { "nowarn": [ "CS0168", "CS0618", "CS0162" ] }, "dependencies": { - "Microsoft.Extensions.Configuration": "1.1.0", "Npoi.Core": "1.1.0-*", "Npoi.Core.Ooxml": "1.1.0-*", "Npoi.Core.OpenXml4Net": "1.1.0-*", @@ -10,6 +9,7 @@ "NUnit": "3.5.0", "dotnet-test-nunit": "3.4.0-beta-3", "System.Xml.XmlDocument": "4.3.0", + "Microsoft.Extensions.Configuration": "1.1.0", "Microsoft.Extensions.Configuration.Json": "1.1.0" }, diff --git a/test/Npoi.Core.TestCases/POIDataSamples.cs b/test/Npoi.Core.TestCases/POIDataSamples.cs index fe43419..d0e7f00 100644 --- a/test/Npoi.Core.TestCases/POIDataSamples.cs +++ b/test/Npoi.Core.TestCases/POIDataSamples.cs @@ -115,7 +115,7 @@ namespace TestCases // Some of the tests are depending on the american culture. TestCases.CultureShim.SetCurrentCulture("en-US"); - string dataDirName = TestCases.AppSettingsShim.GetSetting(TEST_PROPERTY); + string dataDirName = AppSettingsShim.GetSetting(TEST_PROPERTY); if (dataDirName == null) throw new Exception("Must set system property '" diff --git a/test/Npoi.Core.TestCases/Shim/CultureShim.cs b/test/Npoi.Core.TestCases/Shim/CultureShim.cs index 856eed4..cf90c8a 100644 --- a/test/Npoi.Core.TestCases/Shim/CultureShim.cs +++ b/test/Npoi.Core.TestCases/Shim/CultureShim.cs @@ -1,5 +1,7 @@ -using System; +using Microsoft.Extensions.Configuration; +using System; using System.Globalization; +using System.IO; using System.Text; namespace TestCases @@ -8,20 +10,27 @@ namespace TestCases { public static StringComparison InvariantCultureIgnoreCase => StringComparison.OrdinalIgnoreCase; } + + public class EncodingShim { public static Encoding Default => Encoding.UTF8; } + + public class AppSettingsShim { public static string GetSetting(string name) { - if ("POI.testdata.path" == name) { - return AppContext.BaseDirectory; - } - throw new NotImplementedException(); + var build = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json").Build(); + + return build.GetSection("POI.testdata.path").Value; } } + + public class CultureShim { public static CultureInfo InstalledUICulture => CultureInfo.CurrentUICulture; diff --git a/test/Npoi.Core.TestCases/appsettings.json b/test/Npoi.Core.TestCases/appsettings.json new file mode 100644 index 0000000..0ce719b --- /dev/null +++ b/test/Npoi.Core.TestCases/appsettings.json @@ -0,0 +1,3 @@ +{ + "POI.testdata.path": "..\\test-data" +} \ No newline at end of file diff --git a/test/Npoi.Core.TestCases/project.json b/test/Npoi.Core.TestCases/project.json index 102f939..9353913 100644 --- a/test/Npoi.Core.TestCases/project.json +++ b/test/Npoi.Core.TestCases/project.json @@ -7,9 +7,9 @@ "dependencies": { "NUnit": "3.5.0", "dotnet-test-nunit": "3.4.0-beta-3", - // "NETStandard.Library": "1.6.0", - "Npoi.Core": "1.1.0-*" - //"nunit": "3.2.1" + "Npoi.Core": "1.1.0-*", + "Microsoft.Extensions.Configuration": "1.1.0", + "Microsoft.Extensions.Configuration.Json": "1.1.0" }, "frameworks": {