Skip to content

Commit 153caf3

Browse files
committed
Changes per feedback on PR #164
updated the code changes for PR #164 according to peer feedback.
1 parent bab693f commit 153caf3

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

DocumentFormat.OpenXml/src/Framework/OpenXmlPackage.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,9 +1384,9 @@ internal class PartUriHelper
13841384
private Dictionary<string, int> _sequenceNumbers = new Dictionary<string, int>(20);
13851385
private Dictionary<string, int> _reservedUri = new Dictionary<string, int>();
13861386

1387-
//Added for issue #123, some contentTypes need to have a 1 appended to the name
1387+
//List of contentTypes that need to have a 1 appended to the name
13881388
//for the first item in the package
1389-
private List<string> _numberedContentTypes = new List<string>
1389+
private static readonly HashSet<string> _numberedContentTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
13901390
{
13911391
//11.3 WordprocessingML Parts
13921392
"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml",
@@ -1465,8 +1465,6 @@ internal Uri GetUniquePartUri(string contentType, Uri parentUri, string targetPa
14651465
string sequenceNumber = this.GetNextSequenceNumber(contentType);
14661466
string path = Path.Combine(targetPath, targetName + sequenceNumber + targetExt);
14671467

1468-
1469-
14701468
Uri uri = new Uri(path, UriKind.RelativeOrAbsolute);
14711469
partUri = PackUriHelper.ResolvePartUri(parentUri, uri);
14721470
// partUri = PackUriHelper.GetNormalizedPartUri(PackUriHelper.CreatePartUri(uri));
@@ -1516,17 +1514,9 @@ private string GetNextSequenceNumber(string contentType)
15161514
else
15171515
{
15181516
this._sequenceNumbers.Add(contentType, 1);
1519-
//return "";
15201517

1521-
//Certain types need to contain an initial 1 value. Issue #123
1522-
if (_numberedContentTypes.Contains(contentType))
1523-
{
1524-
return "1";
1525-
}
1526-
else
1527-
{
1528-
return "";
1529-
}
1518+
//Certain contentTypes need to be numbered starting with 1.
1519+
return _numberedContentTypes.Contains(contentType) ? "1" : "";
15301520
}
15311521
}
15321522
}

0 commit comments

Comments
 (0)