Pārlūkot izejas kodu

In certain cases CreatePicture resulted in a corrupted document when opened in Word 2013/2010. The reason was that the docPr id="" attribute was duplicated. A bookmark already had id="7".

Patch provided by Source2702
master
MadBoy_cp pirms 10 gadiem
vecāks
revīzija
1d8b7da0b1
2 mainītis faili ar 6 papildinājumiem un 5 dzēšanām
  1. 4
    3
      DocX/Paragraph.cs
  2. 2
    2
      DocX/Properties/AssemblyInfo.cs

+ 4
- 3
DocX/Paragraph.cs Parādīt failu

int newDocPrId = 1; int newDocPrId = 1;
List<string> existingIds = new List<string>(); List<string> existingIds = new List<string>();
foreach (var docPrId in document.Xml.Descendants(XName.Get("docPr", DocX.wp.NamespaceName)))
foreach (var bookmarkId in document.Xml.Descendants(XName.Get("bookmarkStart", DocX.w.NamespaceName)))
{ {
existingIds.Add(docPrId.Attributes().FirstOrDefault(x => x.Name == "id").Value);
var idAtt = bookmarkId.Attributes().FirstOrDefault(x => x.Name.LocalName == "id");
if (idAtt != null)
existingIds.Add(idAtt.Value);
} }
while (existingIds.Contains(newDocPrId.ToString())) while (existingIds.Contains(newDocPrId.ToString()))

+ 2
- 2
DocX/Properties/AssemblyInfo.cs Parādīt failu

// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.16")]
[assembly: AssemblyFileVersion("1.0.0.16")]
[assembly: AssemblyVersion("1.0.0.17")]
[assembly: AssemblyFileVersion("1.0.0.17")]

Notiek ielāde…
Atcelt
Saglabāt