MetricsGetter.cs 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071
  1. // Copyright (c) Microsoft. All rights reserved.
  2. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.IO.Packaging;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Xml.Linq;
  11. using DocumentFormat.OpenXml.Packaging;
  12. using DocumentFormat.OpenXml.Validation;
  13. using System.Globalization;
  14. namespace OpenXmlPowerTools
  15. {
  16. public class MetricsGetterSettings
  17. {
  18. public bool IncludeTextInContentControls;
  19. public bool IncludeXlsxTableCellData;
  20. public bool RetrieveNamespaceList;
  21. public bool RetrieveContentTypeList;
  22. }
  23. public class MetricsGetter
  24. {
  25. private static Lazy<Graphics> Graphics { get; } = new Lazy<Graphics>(() =>
  26. {
  27. Image image = new Bitmap(1, 1);
  28. return System.Drawing.Graphics.FromImage(image);
  29. });
  30. public static XElement GetMetrics(string fileName, MetricsGetterSettings settings)
  31. {
  32. FileInfo fi = new FileInfo(fileName);
  33. if (!fi.Exists)
  34. throw new FileNotFoundException("{0} does not exist.", fi.FullName);
  35. if (Util.IsWordprocessingML(fi.Extension))
  36. {
  37. WmlDocument wmlDoc = new WmlDocument(fi.FullName, true);
  38. return GetDocxMetrics(wmlDoc, settings);
  39. }
  40. if (Util.IsSpreadsheetML(fi.Extension))
  41. {
  42. SmlDocument smlDoc = new SmlDocument(fi.FullName, true);
  43. return GetXlsxMetrics(smlDoc, settings);
  44. }
  45. if (Util.IsPresentationML(fi.Extension))
  46. {
  47. PmlDocument pmlDoc = new PmlDocument(fi.FullName, true);
  48. return GetPptxMetrics(pmlDoc, settings);
  49. }
  50. return null;
  51. }
  52. public static XElement GetDocxMetrics(WmlDocument wmlDoc, MetricsGetterSettings settings)
  53. {
  54. try
  55. {
  56. using (MemoryStream ms = new MemoryStream())
  57. {
  58. ms.Write(wmlDoc.DocumentByteArray, 0, wmlDoc.DocumentByteArray.Length);
  59. using (WordprocessingDocument document = WordprocessingDocument.Open(ms, true))
  60. {
  61. bool hasTrackedRevisions = RevisionAccepter.HasTrackedRevisions(document);
  62. if (hasTrackedRevisions)
  63. RevisionAccepter.AcceptRevisions(document);
  64. XElement metrics1 = GetWmlMetrics(wmlDoc.FileName, false, document, settings);
  65. if (hasTrackedRevisions)
  66. metrics1.Add(new XElement(H.RevisionTracking, new XAttribute(H.Val, true)));
  67. return metrics1;
  68. }
  69. }
  70. }
  71. catch (OpenXmlPowerToolsException e)
  72. {
  73. if (e.ToString().Contains("Invalid Hyperlink"))
  74. {
  75. using (MemoryStream ms = new MemoryStream())
  76. {
  77. ms.Write(wmlDoc.DocumentByteArray, 0, wmlDoc.DocumentByteArray.Length);
  78. #if !NET35
  79. UriFixer.FixInvalidUri(ms, brokenUri => FixUri(brokenUri));
  80. #endif
  81. wmlDoc = new WmlDocument("dummy.docx", ms.ToArray());
  82. }
  83. using (MemoryStream ms = new MemoryStream())
  84. {
  85. ms.Write(wmlDoc.DocumentByteArray, 0, wmlDoc.DocumentByteArray.Length);
  86. using (WordprocessingDocument document = WordprocessingDocument.Open(ms, true))
  87. {
  88. bool hasTrackedRevisions = RevisionAccepter.HasTrackedRevisions(document);
  89. if (hasTrackedRevisions)
  90. RevisionAccepter.AcceptRevisions(document);
  91. XElement metrics2 = GetWmlMetrics(wmlDoc.FileName, true, document, settings);
  92. if (hasTrackedRevisions)
  93. metrics2.Add(new XElement(H.RevisionTracking, new XAttribute(H.Val, true)));
  94. return metrics2;
  95. }
  96. }
  97. }
  98. }
  99. var metrics = new XElement(H.Metrics,
  100. new XAttribute(H.FileName, wmlDoc.FileName),
  101. new XAttribute(H.FileType, "WordprocessingML"),
  102. new XAttribute(H.Error, "Unknown error, metrics not determined"));
  103. return metrics;
  104. }
  105. private static int _getTextWidth(FontFamily ff, FontStyle fs, decimal sz, string text)
  106. {
  107. try
  108. {
  109. using (var f = new Font(ff, (float)sz / 2f, fs))
  110. {
  111. var proposedSize = new Size(int.MaxValue, int.MaxValue);
  112. var sf = Graphics.Value.MeasureString(text, f, proposedSize);
  113. return (int) sf.Width;
  114. }
  115. }
  116. catch
  117. {
  118. return 0;
  119. }
  120. }
  121. public static int GetTextWidth(FontFamily ff, FontStyle fs, decimal sz, string text)
  122. {
  123. try
  124. {
  125. return _getTextWidth(ff, fs, sz, text);
  126. }
  127. catch (ArgumentException)
  128. {
  129. try
  130. {
  131. const FontStyle fs2 = FontStyle.Regular;
  132. return _getTextWidth(ff, fs2, sz, text);
  133. }
  134. catch (ArgumentException)
  135. {
  136. const FontStyle fs2 = FontStyle.Bold;
  137. try
  138. {
  139. return _getTextWidth(ff, fs2, sz, text);
  140. }
  141. catch (ArgumentException)
  142. {
  143. // if both regular and bold fail, then get metrics for Times New Roman
  144. // use the original FontStyle (in fs)
  145. var ff2 = new FontFamily("Times New Roman");
  146. return _getTextWidth(ff2, fs, sz, text);
  147. }
  148. }
  149. }
  150. catch (OverflowException)
  151. {
  152. // This happened on Azure but interestingly enough not while testing locally.
  153. return 0;
  154. }
  155. }
  156. private static Uri FixUri(string brokenUri)
  157. {
  158. return new Uri("http://broken-link/");
  159. }
  160. private static XElement GetWmlMetrics(string fileName, bool invalidHyperlink, WordprocessingDocument wDoc, MetricsGetterSettings settings)
  161. {
  162. var parts = new XElement(H.Parts,
  163. wDoc.GetAllParts().Select(part =>
  164. {
  165. return GetMetricsForWmlPart(part, settings);
  166. }));
  167. if (!parts.HasElements)
  168. parts = null;
  169. var metrics = new XElement(H.Metrics,
  170. new XAttribute(H.FileName, fileName),
  171. new XAttribute(H.FileType, "WordprocessingML"),
  172. GetStyleHierarchy(wDoc),
  173. GetMiscWmlMetrics(wDoc, invalidHyperlink),
  174. parts,
  175. settings.RetrieveNamespaceList ? RetrieveNamespaceList(wDoc) : null,
  176. settings.RetrieveContentTypeList ? RetrieveContentTypeList(wDoc) : null
  177. );
  178. return metrics;
  179. }
  180. private static XElement RetrieveContentTypeList(OpenXmlPackage oxPkg)
  181. {
  182. Package pkg = oxPkg.Package;
  183. var nonRelationshipParts = pkg.GetParts().Cast<ZipPackagePart>().Where(p => p.ContentType != "application/vnd.openxmlformats-package.relationships+xml");
  184. var contentTypes = nonRelationshipParts
  185. .Select(p => p.ContentType)
  186. .OrderBy(t => t)
  187. .Distinct();
  188. var xe = new XElement(H.ContentTypes,
  189. contentTypes.Select(ct => new XElement(H.ContentType, new XAttribute(H.Val, ct))));
  190. return xe;
  191. }
  192. private static XElement RetrieveNamespaceList(OpenXmlPackage oxPkg)
  193. {
  194. Package pkg = oxPkg.Package;
  195. var nonRelationshipParts = pkg.GetParts().Cast<ZipPackagePart>().Where(p => p.ContentType != "application/vnd.openxmlformats-package.relationships+xml");
  196. var xmlParts = nonRelationshipParts
  197. .Where(p => p.ContentType.ToLower().EndsWith("xml"));
  198. var uniqueNamespaces = new HashSet<string>();
  199. foreach (var xp in xmlParts)
  200. {
  201. using (Stream st = xp.GetStream())
  202. {
  203. try
  204. {
  205. XDocument xdoc = XDocument.Load(st);
  206. var namespaces = xdoc
  207. .Descendants()
  208. .Attributes()
  209. .Where(a => a.IsNamespaceDeclaration)
  210. .Select(a => string.Format("{0}|{1}", a.Name.LocalName, a.Value))
  211. .OrderBy(t => t)
  212. .Distinct()
  213. .ToList();
  214. foreach (var item in namespaces)
  215. uniqueNamespaces.Add(item);
  216. }
  217. // if catch exception, forget about it. Just trying to get a most complete survey possible of all namespaces in all documents.
  218. // if caught exception, chances are the document is bad anyway.
  219. catch (Exception)
  220. {
  221. continue;
  222. }
  223. }
  224. }
  225. var xe = new XElement(H.Namespaces,
  226. uniqueNamespaces.OrderBy(t => t).Select(n =>
  227. {
  228. var spl = n.Split('|');
  229. return new XElement(H.Namespace,
  230. new XAttribute(H.NamespacePrefix, spl[0]),
  231. new XAttribute(H.NamespaceName, spl[1]));
  232. }));
  233. return xe;
  234. }
  235. private static List<XElement> GetMiscWmlMetrics(WordprocessingDocument document, bool invalidHyperlink)
  236. {
  237. List<XElement> metrics = new List<XElement>();
  238. List<string> notes = new List<string>();
  239. Dictionary<XName, int> elementCountDictionary = new Dictionary<XName, int>();
  240. if (invalidHyperlink)
  241. metrics.Add(new XElement(H.InvalidHyperlink, new XAttribute(H.Val, invalidHyperlink)));
  242. bool valid = ValidateWordprocessingDocument(document, metrics, notes, elementCountDictionary);
  243. if (invalidHyperlink)
  244. valid = false;
  245. return metrics;
  246. }
  247. private static bool ValidateWordprocessingDocument(WordprocessingDocument wDoc, List<XElement> metrics, List<string> notes, Dictionary<XName, int> metricCountDictionary)
  248. {
  249. bool valid = ValidateAgainstSpecificVersion(wDoc, metrics, DocumentFormat.OpenXml.FileFormatVersions.Office2007, H.SdkValidationError2007);
  250. valid |= ValidateAgainstSpecificVersion(wDoc, metrics, DocumentFormat.OpenXml.FileFormatVersions.Office2010, H.SdkValidationError2010);
  251. #if !NET35
  252. valid |= ValidateAgainstSpecificVersion(wDoc, metrics, DocumentFormat.OpenXml.FileFormatVersions.Office2013, H.SdkValidationError2013);
  253. #endif
  254. int elementCount = 0;
  255. int paragraphCount = 0;
  256. int textCount = 0;
  257. foreach (var part in wDoc.ContentParts())
  258. {
  259. XDocument xDoc = part.GetXDocument();
  260. foreach (var e in xDoc.Descendants())
  261. {
  262. if (e.Name == W.txbxContent)
  263. IncrementMetric(metricCountDictionary, H.TextBox);
  264. else if (e.Name == W.sdt)
  265. IncrementMetric(metricCountDictionary, H.ContentControl);
  266. else if (e.Name == W.customXml)
  267. IncrementMetric(metricCountDictionary, H.CustomXmlMarkup);
  268. else if (e.Name == W.fldChar)
  269. IncrementMetric(metricCountDictionary, H.ComplexField);
  270. else if (e.Name == W.fldSimple)
  271. IncrementMetric(metricCountDictionary, H.SimpleField);
  272. else if (e.Name == W.altChunk)
  273. IncrementMetric(metricCountDictionary, H.AltChunk);
  274. else if (e.Name == W.tbl)
  275. IncrementMetric(metricCountDictionary, H.Table);
  276. else if (e.Name == W.hyperlink)
  277. IncrementMetric(metricCountDictionary, H.Hyperlink);
  278. else if (e.Name == W.framePr)
  279. IncrementMetric(metricCountDictionary, H.LegacyFrame);
  280. else if (e.Name == W.control)
  281. IncrementMetric(metricCountDictionary, H.ActiveX);
  282. else if (e.Name == W.subDoc)
  283. IncrementMetric(metricCountDictionary, H.SubDocument);
  284. else if (e.Name == VML.imagedata || e.Name == VML.fill || e.Name == VML.stroke || e.Name == A.blip)
  285. {
  286. var relId = (string)e.Attribute(R.embed);
  287. if (relId != null)
  288. ValidateImageExists(part, relId, metricCountDictionary);
  289. relId = (string)e.Attribute(R.pict);
  290. if (relId != null)
  291. ValidateImageExists(part, relId, metricCountDictionary);
  292. relId = (string)e.Attribute(R.id);
  293. if (relId != null)
  294. ValidateImageExists(part, relId, metricCountDictionary);
  295. }
  296. if (part.Uri == wDoc.MainDocumentPart.Uri)
  297. {
  298. elementCount++;
  299. if (e.Name == W.p)
  300. paragraphCount++;
  301. if (e.Name == W.t)
  302. textCount += ((string)e).Length;
  303. }
  304. }
  305. }
  306. foreach (var item in metricCountDictionary)
  307. {
  308. metrics.Add(
  309. new XElement(item.Key, new XAttribute(H.Val, item.Value)));
  310. }
  311. metrics.Add(new XElement(H.ElementCount, new XAttribute(H.Val, elementCount)));
  312. metrics.Add(new XElement(H.AverageParagraphLength, new XAttribute(H.Val, (int)((double)textCount / (double)paragraphCount))));
  313. if (wDoc.GetAllParts().Any(part => part.ContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
  314. metrics.Add(new XElement(H.EmbeddedXlsx, new XAttribute(H.Val, true)));
  315. NumberingFormatListAssembly(wDoc, metrics);
  316. XDocument wxDoc = wDoc.MainDocumentPart.GetXDocument();
  317. foreach (var d in wxDoc.Descendants())
  318. {
  319. if (d.Name == W.saveThroughXslt)
  320. {
  321. string rid = (string)d.Attribute(R.id);
  322. var tempExternalRelationship = wDoc
  323. .MainDocumentPart
  324. .DocumentSettingsPart
  325. .ExternalRelationships
  326. .FirstOrDefault(h => h.Id == rid);
  327. if (tempExternalRelationship == null)
  328. metrics.Add(new XElement(H.InvalidSaveThroughXslt, new XAttribute(H.Val, true)));
  329. valid = false;
  330. }
  331. else if (d.Name == W.trackRevisions)
  332. metrics.Add(new XElement(H.TrackRevisionsEnabled, new XAttribute(H.Val, true)));
  333. else if (d.Name == W.documentProtection)
  334. metrics.Add(new XElement(H.DocumentProtection, new XAttribute(H.Val, true)));
  335. }
  336. FontAndCharSetAnalysis(wDoc, metrics, notes);
  337. return valid;
  338. }
  339. private static bool ValidateAgainstSpecificVersion(WordprocessingDocument wDoc, List<XElement> metrics, DocumentFormat.OpenXml.FileFormatVersions versionToValidateAgainst, XName versionSpecificMetricName)
  340. {
  341. OpenXmlValidator validator = new OpenXmlValidator(versionToValidateAgainst);
  342. var errors = validator.Validate(wDoc);
  343. bool valid = errors.Count() == 0;
  344. if (!valid)
  345. {
  346. if (!metrics.Any(e => e.Name == H.SdkValidationError))
  347. metrics.Add(new XElement(H.SdkValidationError, new XAttribute(H.Val, true)));
  348. metrics.Add(new XElement(versionSpecificMetricName, new XAttribute(H.Val, true),
  349. errors.Take(3).Select(err =>
  350. {
  351. StringBuilder sb = new StringBuilder();
  352. if (err.Description.Length > 300)
  353. sb.Append(PtUtils.MakeValidXml(err.Description.Substring(0, 300) + " ... elided ...") + Environment.NewLine);
  354. else
  355. sb.Append(PtUtils.MakeValidXml(err.Description) + Environment.NewLine);
  356. sb.Append(" in part " + PtUtils.MakeValidXml(err.Part.Uri.ToString()) + Environment.NewLine);
  357. sb.Append(" at " + PtUtils.MakeValidXml(err.Path.XPath) + Environment.NewLine);
  358. return sb.ToString();
  359. })));
  360. }
  361. return valid;
  362. }
  363. private static bool ValidateAgainstSpecificVersion(SpreadsheetDocument sDoc, List<XElement> metrics, DocumentFormat.OpenXml.FileFormatVersions versionToValidateAgainst, XName versionSpecificMetricName)
  364. {
  365. OpenXmlValidator validator = new OpenXmlValidator(versionToValidateAgainst);
  366. var errors = validator.Validate(sDoc);
  367. bool valid = errors.Count() == 0;
  368. if (!valid)
  369. {
  370. if (!metrics.Any(e => e.Name == H.SdkValidationError))
  371. metrics.Add(new XElement(H.SdkValidationError, new XAttribute(H.Val, true)));
  372. metrics.Add(new XElement(versionSpecificMetricName, new XAttribute(H.Val, true),
  373. errors.Take(3).Select(err =>
  374. {
  375. StringBuilder sb = new StringBuilder();
  376. if (err.Description.Length > 300)
  377. sb.Append(PtUtils.MakeValidXml(err.Description.Substring(0, 300) + " ... elided ...") + Environment.NewLine);
  378. else
  379. sb.Append(PtUtils.MakeValidXml(err.Description) + Environment.NewLine);
  380. sb.Append(" in part " + PtUtils.MakeValidXml(err.Part.Uri.ToString()) + Environment.NewLine);
  381. sb.Append(" at " + PtUtils.MakeValidXml(err.Path.XPath) + Environment.NewLine);
  382. return sb.ToString();
  383. })));
  384. }
  385. return valid;
  386. }
  387. private static bool ValidateAgainstSpecificVersion(PresentationDocument pDoc, List<XElement> metrics, DocumentFormat.OpenXml.FileFormatVersions versionToValidateAgainst, XName versionSpecificMetricName)
  388. {
  389. OpenXmlValidator validator = new OpenXmlValidator(versionToValidateAgainst);
  390. var errors = validator.Validate(pDoc);
  391. bool valid = errors.Count() == 0;
  392. if (!valid)
  393. {
  394. if (!metrics.Any(e => e.Name == H.SdkValidationError))
  395. metrics.Add(new XElement(H.SdkValidationError, new XAttribute(H.Val, true)));
  396. metrics.Add(new XElement(versionSpecificMetricName, new XAttribute(H.Val, true),
  397. errors.Take(3).Select(err =>
  398. {
  399. StringBuilder sb = new StringBuilder();
  400. if (err.Description.Length > 300)
  401. sb.Append(PtUtils.MakeValidXml(err.Description.Substring(0, 300) + " ... elided ...") + Environment.NewLine);
  402. else
  403. sb.Append(PtUtils.MakeValidXml(err.Description) + Environment.NewLine);
  404. sb.Append(" in part " + PtUtils.MakeValidXml(err.Part.Uri.ToString()) + Environment.NewLine);
  405. sb.Append(" at " + PtUtils.MakeValidXml(err.Path.XPath) + Environment.NewLine);
  406. return sb.ToString();
  407. })));
  408. }
  409. return valid;
  410. }
  411. private static void IncrementMetric(Dictionary<XName, int> metricCountDictionary, XName xName)
  412. {
  413. if (metricCountDictionary.ContainsKey(xName))
  414. metricCountDictionary[xName] = metricCountDictionary[xName] + 1;
  415. else
  416. metricCountDictionary.Add(xName, 1);
  417. }
  418. private static void ValidateImageExists(OpenXmlPart part, string relId, Dictionary<XName, int> metrics)
  419. {
  420. var imagePart = part.Parts.FirstOrDefault(ipp => ipp.RelationshipId == relId);
  421. if (imagePart == null)
  422. IncrementMetric(metrics, H.ReferenceToNullImage);
  423. }
  424. private static void NumberingFormatListAssembly(WordprocessingDocument wDoc, List<XElement> metrics)
  425. {
  426. List<string> numFmtList = new List<string>();
  427. foreach (var part in wDoc.ContentParts())
  428. {
  429. var xDoc = part.GetXDocument();
  430. numFmtList = numFmtList.Concat(xDoc
  431. .Descendants(W.p)
  432. .Select(p =>
  433. {
  434. ListItemRetriever.RetrieveListItem(wDoc, p, null);
  435. ListItemRetriever.ListItemInfo lif = p.Annotation<ListItemRetriever.ListItemInfo>();
  436. if (lif != null && lif.IsListItem && lif.Lvl(ListItemRetriever.GetParagraphLevel(p)) != null)
  437. {
  438. string numFmtForLevel = (string)lif.Lvl(ListItemRetriever.GetParagraphLevel(p)).Elements(W.numFmt).Attributes(W.val).FirstOrDefault();
  439. if (numFmtForLevel == null)
  440. {
  441. var numFmtElement = lif.Lvl(ListItemRetriever.GetParagraphLevel(p)).Elements(MC.AlternateContent).Elements(MC.Choice).Elements(W.numFmt).FirstOrDefault();
  442. if (numFmtElement != null && (string)numFmtElement.Attribute(W.val) == "custom")
  443. numFmtForLevel = (string)numFmtElement.Attribute(W.format);
  444. }
  445. return numFmtForLevel;
  446. }
  447. return null;
  448. })
  449. .Where(s => s != null)
  450. .Distinct())
  451. .ToList();
  452. }
  453. if (numFmtList.Any())
  454. {
  455. var nfls = numFmtList.StringConcatenate(s => s + ",").TrimEnd(',');
  456. metrics.Add(new XElement(H.NumberingFormatList, new XAttribute(H.Val, PtUtils.MakeValidXml(nfls))));
  457. }
  458. }
  459. class FormattingMetrics
  460. {
  461. public int RunCount;
  462. public int RunWithoutRprCount;
  463. public int ZeroLengthText;
  464. public int MultiFontRun;
  465. public int AsciiCharCount;
  466. public int CSCharCount;
  467. public int EastAsiaCharCount;
  468. public int HAnsiCharCount;
  469. public int AsciiRunCount;
  470. public int CSRunCount;
  471. public int EastAsiaRunCount;
  472. public int HAnsiRunCount;
  473. public List<string> Languages;
  474. public FormattingMetrics()
  475. {
  476. Languages = new List<string>();
  477. }
  478. }
  479. private static void FontAndCharSetAnalysis(WordprocessingDocument wDoc, List<XElement> metrics, List<string> notes)
  480. {
  481. FormattingAssemblerSettings settings = new FormattingAssemblerSettings
  482. {
  483. RemoveStyleNamesFromParagraphAndRunProperties = false,
  484. ClearStyles = true,
  485. RestrictToSupportedNumberingFormats = false,
  486. RestrictToSupportedLanguages = false,
  487. };
  488. FormattingAssembler.AssembleFormatting(wDoc, settings);
  489. var formattingMetrics = new FormattingMetrics();
  490. foreach (var part in wDoc.ContentParts())
  491. {
  492. var xDoc = part.GetXDocument();
  493. foreach (var run in xDoc.Descendants(W.r))
  494. {
  495. formattingMetrics.RunCount++;
  496. AnalyzeRun(run, metrics, notes, formattingMetrics, part.Uri.ToString());
  497. }
  498. }
  499. metrics.Add(new XElement(H.RunCount, new XAttribute(H.Val, formattingMetrics.RunCount)));
  500. if (formattingMetrics.RunWithoutRprCount > 0)
  501. metrics.Add(new XElement(H.RunWithoutRprCount, new XAttribute(H.Val, formattingMetrics.RunWithoutRprCount)));
  502. if (formattingMetrics.ZeroLengthText > 0)
  503. metrics.Add(new XElement(H.ZeroLengthText, new XAttribute(H.Val, formattingMetrics.ZeroLengthText)));
  504. if (formattingMetrics.MultiFontRun > 0)
  505. metrics.Add(new XElement(H.MultiFontRun, new XAttribute(H.Val, formattingMetrics.MultiFontRun)));
  506. if (formattingMetrics.AsciiCharCount > 0)
  507. metrics.Add(new XElement(H.AsciiCharCount, new XAttribute(H.Val, formattingMetrics.AsciiCharCount)));
  508. if (formattingMetrics.CSCharCount > 0)
  509. metrics.Add(new XElement(H.CSCharCount, new XAttribute(H.Val, formattingMetrics.CSCharCount)));
  510. if (formattingMetrics.EastAsiaCharCount > 0)
  511. metrics.Add(new XElement(H.EastAsiaCharCount, new XAttribute(H.Val, formattingMetrics.EastAsiaCharCount)));
  512. if (formattingMetrics.HAnsiCharCount > 0)
  513. metrics.Add(new XElement(H.HAnsiCharCount, new XAttribute(H.Val, formattingMetrics.HAnsiCharCount)));
  514. if (formattingMetrics.AsciiRunCount > 0)
  515. metrics.Add(new XElement(H.AsciiRunCount, new XAttribute(H.Val, formattingMetrics.AsciiRunCount)));
  516. if (formattingMetrics.CSRunCount > 0)
  517. metrics.Add(new XElement(H.CSRunCount, new XAttribute(H.Val, formattingMetrics.CSRunCount)));
  518. if (formattingMetrics.EastAsiaRunCount > 0)
  519. metrics.Add(new XElement(H.EastAsiaRunCount, new XAttribute(H.Val, formattingMetrics.EastAsiaRunCount)));
  520. if (formattingMetrics.HAnsiRunCount > 0)
  521. metrics.Add(new XElement(H.HAnsiRunCount, new XAttribute(H.Val, formattingMetrics.HAnsiRunCount)));
  522. if (formattingMetrics.Languages.Any())
  523. {
  524. var uls = formattingMetrics.Languages.StringConcatenate(s => s + ",").TrimEnd(',');
  525. metrics.Add(new XElement(H.Languages, new XAttribute(H.Val, PtUtils.MakeValidXml(uls))));
  526. }
  527. }
  528. private static void AnalyzeRun(XElement run, List<XElement> attList, List<string> notes, FormattingMetrics formattingMetrics, string uri)
  529. {
  530. var runText = run.Elements()
  531. .Where(e => e.Name == W.t || e.Name == W.delText)
  532. .Select(t => (string)t)
  533. .StringConcatenate();
  534. if (runText.Length == 0)
  535. {
  536. formattingMetrics.ZeroLengthText++;
  537. return;
  538. }
  539. var rPr = run.Element(W.rPr);
  540. if (rPr == null)
  541. {
  542. formattingMetrics.RunWithoutRprCount++;
  543. notes.Add(PtUtils.MakeValidXml(string.Format("Error in part {0}: run without rPr at {1}", uri, run.GetXPath())));
  544. rPr = new XElement(W.rPr);
  545. }
  546. FormattingAssembler.CharStyleAttributes csa = new FormattingAssembler.CharStyleAttributes(null, rPr);
  547. var fontTypeArray = runText
  548. .Select(ch => FormattingAssembler.DetermineFontTypeFromCharacter(ch, csa))
  549. .ToArray();
  550. var distinctFontTypeArray = fontTypeArray
  551. .Distinct()
  552. .ToArray();
  553. var distinctFonts = distinctFontTypeArray
  554. .Select(ft =>
  555. {
  556. return GetFontFromFontType(csa, ft);
  557. })
  558. .Distinct();
  559. var languages = distinctFontTypeArray
  560. .Select(ft =>
  561. {
  562. if (ft == FormattingAssembler.FontType.Ascii)
  563. return csa.LatinLang;
  564. if (ft == FormattingAssembler.FontType.CS)
  565. return csa.BidiLang;
  566. if (ft == FormattingAssembler.FontType.EastAsia)
  567. return csa.EastAsiaLang;
  568. //if (ft == FormattingAssembler.FontType.HAnsi)
  569. return csa.LatinLang;
  570. })
  571. .Select(l =>
  572. {
  573. if (l == "" || l == null)
  574. return /* "Dflt:" + */ CultureInfo.CurrentCulture.Name;
  575. return l;
  576. })
  577. //.Where(l => l != null && l != "")
  578. .Distinct();
  579. if (languages.Any(l => !formattingMetrics.Languages.Contains(l)))
  580. formattingMetrics.Languages = formattingMetrics.Languages.Concat(languages).Distinct().ToList();
  581. var multiFontRun = distinctFonts.Count() > 1;
  582. if (multiFontRun)
  583. {
  584. formattingMetrics.MultiFontRun++;
  585. formattingMetrics.AsciiCharCount += fontTypeArray.Where(ft => ft == FormattingAssembler.FontType.Ascii).Count();
  586. formattingMetrics.CSCharCount += fontTypeArray.Where(ft => ft == FormattingAssembler.FontType.CS).Count();
  587. formattingMetrics.EastAsiaCharCount += fontTypeArray.Where(ft => ft == FormattingAssembler.FontType.EastAsia).Count();
  588. formattingMetrics.HAnsiCharCount += fontTypeArray.Where(ft => ft == FormattingAssembler.FontType.HAnsi).Count();
  589. }
  590. else
  591. {
  592. switch (fontTypeArray[0])
  593. {
  594. case FormattingAssembler.FontType.Ascii:
  595. formattingMetrics.AsciiCharCount += runText.Length;
  596. formattingMetrics.AsciiRunCount++;
  597. break;
  598. case FormattingAssembler.FontType.CS:
  599. formattingMetrics.CSCharCount += runText.Length;
  600. formattingMetrics.CSRunCount++;
  601. break;
  602. case FormattingAssembler.FontType.EastAsia:
  603. formattingMetrics.EastAsiaCharCount += runText.Length;
  604. formattingMetrics.EastAsiaRunCount++;
  605. break;
  606. case FormattingAssembler.FontType.HAnsi:
  607. formattingMetrics.HAnsiCharCount += runText.Length;
  608. formattingMetrics.HAnsiRunCount++;
  609. break;
  610. }
  611. }
  612. }
  613. private static string GetFontFromFontType(FormattingAssembler.CharStyleAttributes csa, FormattingAssembler.FontType ft)
  614. {
  615. switch (ft)
  616. {
  617. case FormattingAssembler.FontType.Ascii:
  618. return csa.AsciiFont;
  619. case FormattingAssembler.FontType.CS:
  620. return csa.CsFont;
  621. case FormattingAssembler.FontType.EastAsia:
  622. return csa.EastAsiaFont;
  623. case FormattingAssembler.FontType.HAnsi:
  624. return csa.HAnsiFont;
  625. default: // dummy
  626. return csa.AsciiFont;
  627. }
  628. }
  629. public static XElement GetXlsxMetrics(SmlDocument smlDoc, MetricsGetterSettings settings)
  630. {
  631. using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(smlDoc))
  632. {
  633. using (SpreadsheetDocument sDoc = streamDoc.GetSpreadsheetDocument())
  634. {
  635. List<XElement> metrics = new List<XElement>();
  636. bool valid = ValidateAgainstSpecificVersion(sDoc, metrics, DocumentFormat.OpenXml.FileFormatVersions.Office2007, H.SdkValidationError2007);
  637. valid |= ValidateAgainstSpecificVersion(sDoc, metrics, DocumentFormat.OpenXml.FileFormatVersions.Office2010, H.SdkValidationError2010);
  638. #if !NET35
  639. valid |= ValidateAgainstSpecificVersion(sDoc, metrics, DocumentFormat.OpenXml.FileFormatVersions.Office2013, H.SdkValidationError2013);
  640. #endif
  641. return new XElement(H.Metrics,
  642. new XAttribute(H.FileName, smlDoc.FileName),
  643. new XAttribute(H.FileType, "SpreadsheetML"),
  644. metrics,
  645. GetTableInfoForWorkbook(sDoc, settings),
  646. settings.RetrieveNamespaceList ? RetrieveNamespaceList(sDoc) : null,
  647. settings.RetrieveContentTypeList ? RetrieveContentTypeList(sDoc) : null);
  648. }
  649. }
  650. }
  651. private static XElement GetTableInfoForWorkbook(SpreadsheetDocument spreadsheet, MetricsGetterSettings settings)
  652. {
  653. var workbookPart = spreadsheet.WorkbookPart;
  654. var xd = workbookPart.GetXDocument();
  655. var partInformation =
  656. new XElement(H.Sheets,
  657. xd.Root
  658. .Element(S.sheets)
  659. .Elements(S.sheet)
  660. .Select(sh =>
  661. {
  662. var rid = (string)sh.Attribute(R.id);
  663. var sheetName = (string)sh.Attribute("name");
  664. WorksheetPart worksheetPart = (WorksheetPart)workbookPart.GetPartById(rid);
  665. return GetTableInfoForSheet(spreadsheet, worksheetPart, sheetName, settings);
  666. }));
  667. return partInformation;
  668. }
  669. public static XElement GetTableInfoForSheet(SpreadsheetDocument spreadsheetDocument, WorksheetPart sheetPart, string sheetName,
  670. MetricsGetterSettings settings)
  671. {
  672. var xd = sheetPart.GetXDocument();
  673. XElement sheetInformation = new XElement(H.Sheet,
  674. new XAttribute(H.Name, sheetName),
  675. xd.Root.Elements(S.tableParts).Elements(S.tablePart).Select(tp =>
  676. {
  677. string rId = (string)tp.Attribute(R.id);
  678. TableDefinitionPart tablePart = (TableDefinitionPart)sheetPart.GetPartById(rId);
  679. var txd = tablePart.GetXDocument();
  680. var tableName = (string)txd.Root.Attribute("displayName");
  681. XElement tableCellData = null;
  682. if (settings.IncludeXlsxTableCellData)
  683. {
  684. var xlsxTable = spreadsheetDocument.Table(tableName);
  685. tableCellData = new XElement(H.TableData,
  686. xlsxTable.TableRows()
  687. .Select(row =>
  688. {
  689. var rowElement = new XElement(H.Row,
  690. xlsxTable.TableColumns().Select(col =>
  691. {
  692. var cellElement = new XElement(H.Cell,
  693. new XAttribute(H.Name, col.Name),
  694. new XAttribute(H.Val, (string)row[col.Name]));
  695. return cellElement;
  696. }));
  697. return rowElement;
  698. }));
  699. }
  700. var table = new XElement(H.Table,
  701. new XAttribute(H.Name, (string)txd.Root.Attribute("name")),
  702. new XAttribute(H.DisplayName, tableName),
  703. new XElement(H.Columns,
  704. txd.Root.Element(S.tableColumns).Elements(S.tableColumn)
  705. .Select(tc => new XElement(H.Column,
  706. new XAttribute(H.Name, (string)tc.Attribute("name"))))),
  707. tableCellData
  708. );
  709. return table;
  710. })
  711. );
  712. if (!sheetInformation.HasElements)
  713. return null;
  714. return sheetInformation;
  715. }
  716. public static XElement GetPptxMetrics(PmlDocument pmlDoc, MetricsGetterSettings settings)
  717. {
  718. using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(pmlDoc))
  719. {
  720. using (PresentationDocument pDoc = streamDoc.GetPresentationDocument())
  721. {
  722. List<XElement> metrics = new List<XElement>();
  723. bool valid = ValidateAgainstSpecificVersion(pDoc, metrics, DocumentFormat.OpenXml.FileFormatVersions.Office2007, H.SdkValidationError2007);
  724. valid |= ValidateAgainstSpecificVersion(pDoc, metrics, DocumentFormat.OpenXml.FileFormatVersions.Office2010, H.SdkValidationError2010);
  725. #if !NET35
  726. valid |= ValidateAgainstSpecificVersion(pDoc, metrics, DocumentFormat.OpenXml.FileFormatVersions.Office2013, H.SdkValidationError2013);
  727. #endif
  728. return new XElement(H.Metrics,
  729. new XAttribute(H.FileName, pmlDoc.FileName),
  730. new XAttribute(H.FileType, "PresentationML"),
  731. metrics,
  732. settings.RetrieveNamespaceList ? RetrieveNamespaceList(pDoc) : null,
  733. settings.RetrieveContentTypeList ? RetrieveContentTypeList(pDoc) : null);
  734. }
  735. }
  736. }
  737. private static object GetStyleHierarchy(WordprocessingDocument document)
  738. {
  739. var stylePart = document.MainDocumentPart.StyleDefinitionsPart;
  740. if (stylePart == null)
  741. return null;
  742. var xd = stylePart.GetXDocument();
  743. var stylesWithPath = xd.Root
  744. .Elements(W.style)
  745. .Select(s =>
  746. {
  747. var styleString = (string)s.Attribute(W.styleId);
  748. var thisStyle = s;
  749. while (true)
  750. {
  751. var baseStyle = (string)thisStyle.Elements(W.basedOn).Attributes(W.val).FirstOrDefault();
  752. if (baseStyle == null)
  753. break;
  754. styleString = baseStyle + "/" + styleString;
  755. thisStyle = xd.Root.Elements(W.style).FirstOrDefault(ts => ts.Attribute(W.styleId).Value == baseStyle);
  756. if (thisStyle == null)
  757. break;
  758. }
  759. return styleString;
  760. })
  761. .OrderBy(n => n)
  762. .ToList();
  763. XElement styleHierarchy = new XElement(H.StyleHierarchy);
  764. foreach (var item in stylesWithPath)
  765. {
  766. var styleChain = item.Split('/');
  767. XElement elementToAddTo = styleHierarchy;
  768. foreach (var inChain in styleChain.PtSkipLast(1))
  769. elementToAddTo = elementToAddTo.Elements(H.Style).FirstOrDefault(z => z.Attribute(H.Id).Value == inChain);
  770. var styleToAdd = styleChain.Last();
  771. elementToAddTo.Add(
  772. new XElement(H.Style,
  773. new XAttribute(H.Id, styleChain.Last()),
  774. new XAttribute(H.Type, (string)xd.Root.Elements(W.style).First(z => z.Attribute(W.styleId).Value == styleToAdd).Attribute(W.type))));
  775. }
  776. return styleHierarchy;
  777. }
  778. private static XElement GetMetricsForWmlPart(OpenXmlPart part, MetricsGetterSettings settings)
  779. {
  780. XElement contentControls = null;
  781. if (part is MainDocumentPart ||
  782. part is HeaderPart ||
  783. part is FooterPart ||
  784. part is FootnotesPart ||
  785. part is EndnotesPart)
  786. {
  787. var xd = part.GetXDocument();
  788. contentControls = (XElement)GetContentControlsTransform(xd.Root, settings);
  789. if (!contentControls.HasElements)
  790. contentControls = null;
  791. }
  792. var partMetrics = new XElement(H.Part,
  793. new XAttribute(H.ContentType, part.ContentType),
  794. new XAttribute(H.Uri, part.Uri.ToString()),
  795. contentControls);
  796. if (partMetrics.HasElements)
  797. return partMetrics;
  798. return null;
  799. }
  800. private static object GetContentControlsTransform(XNode node, MetricsGetterSettings settings)
  801. {
  802. XElement element = node as XElement;
  803. if (element != null)
  804. {
  805. if (element == element.Document.Root)
  806. return new XElement(H.ContentControls,
  807. element.Nodes().Select(n => GetContentControlsTransform(n, settings)));
  808. if (element.Name == W.sdt)
  809. {
  810. var tag = (string)element.Elements(W.sdtPr).Elements(W.tag).Attributes(W.val).FirstOrDefault();
  811. XAttribute tagAttr = tag != null ? new XAttribute(H.Tag, tag) : null;
  812. var alias = (string)element.Elements(W.sdtPr).Elements(W.alias).Attributes(W.val).FirstOrDefault();
  813. XAttribute aliasAttr = alias != null ? new XAttribute(H.Alias, alias) : null;
  814. var xPathAttr = new XAttribute(H.XPath, element.GetXPath());
  815. var isText = element.Elements(W.sdtPr).Elements(W.text).Any();
  816. var isBibliography = element.Elements(W.sdtPr).Elements(W.bibliography).Any();
  817. var isCitation = element.Elements(W.sdtPr).Elements(W.citation).Any();
  818. var isComboBox = element.Elements(W.sdtPr).Elements(W.comboBox).Any();
  819. var isDate = element.Elements(W.sdtPr).Elements(W.date).Any();
  820. var isDocPartList = element.Elements(W.sdtPr).Elements(W.docPartList).Any();
  821. var isDocPartObj = element.Elements(W.sdtPr).Elements(W.docPartObj).Any();
  822. var isDropDownList = element.Elements(W.sdtPr).Elements(W.dropDownList).Any();
  823. var isEquation = element.Elements(W.sdtPr).Elements(W.equation).Any();
  824. var isGroup = element.Elements(W.sdtPr).Elements(W.group).Any();
  825. var isPicture = element.Elements(W.sdtPr).Elements(W.picture).Any();
  826. var isRichText = element.Elements(W.sdtPr).Elements(W.richText).Any() ||
  827. (! isText &&
  828. ! isBibliography &&
  829. ! isCitation &&
  830. ! isComboBox &&
  831. ! isDate &&
  832. ! isDocPartList &&
  833. ! isDocPartObj &&
  834. ! isDropDownList &&
  835. ! isEquation &&
  836. ! isGroup &&
  837. ! isPicture);
  838. string type = null;
  839. if (isText ) type = "Text";
  840. if (isBibliography) type = "Bibliography";
  841. if (isCitation ) type = "Citation";
  842. if (isComboBox ) type = "ComboBox";
  843. if (isDate ) type = "Date";
  844. if (isDocPartList ) type = "DocPartList";
  845. if (isDocPartObj ) type = "DocPartObj";
  846. if (isDropDownList) type = "DropDownList";
  847. if (isEquation ) type = "Equation";
  848. if (isGroup ) type = "Group";
  849. if (isPicture ) type = "Picture";
  850. if (isRichText ) type = "RichText";
  851. var typeAttr = new XAttribute(H.Type, type);
  852. return new XElement(H.ContentControl,
  853. typeAttr,
  854. tagAttr,
  855. aliasAttr,
  856. xPathAttr,
  857. element.Nodes().Select(n => GetContentControlsTransform(n, settings)));
  858. }
  859. return element.Nodes().Select(n => GetContentControlsTransform(n, settings));
  860. }
  861. if (settings.IncludeTextInContentControls)
  862. return node;
  863. return null;
  864. }
  865. }
  866. public static class H
  867. {
  868. public static XName ActiveX = "ActiveX";
  869. public static XName Alias = "Alias";
  870. public static XName AltChunk = "AltChunk";
  871. public static XName Arguments = "Arguments";
  872. public static XName AsciiCharCount = "AsciiCharCount";
  873. public static XName AsciiRunCount = "AsciiRunCount";
  874. public static XName AverageParagraphLength = "AverageParagraphLength";
  875. public static XName BaselineReport = "BaselineReport";
  876. public static XName Batch = "Batch";
  877. public static XName BatchName = "BatchName";
  878. public static XName BatchSelector = "BatchSelector";
  879. public static XName CSCharCount = "CSCharCount";
  880. public static XName CSRunCount = "CSRunCount";
  881. public static XName Catalog = "Catalog";
  882. public static XName CatalogList = "CatalogList";
  883. public static XName CatalogListFile = "CatalogListFile";
  884. public static XName CaughtException = "CaughtException";
  885. public static XName Cell = "Cell";
  886. public static XName Column = "Column";
  887. public static XName Columns = "Columns";
  888. public static XName ComplexField = "ComplexField";
  889. public static XName Computer = "Computer";
  890. public static XName Computers = "Computers";
  891. public static XName ContentControl = "ContentControl";
  892. public static XName ContentControls = "ContentControls";
  893. public static XName ContentType = "ContentType";
  894. public static XName ContentTypes = "ContentTypes";
  895. public static XName CustomXmlMarkup = "CustomXmlMarkup";
  896. public static XName DLL = "DLL";
  897. public static XName DefaultDialogValuesFile = "DefaultDialogValuesFile";
  898. public static XName DefaultValues = "DefaultValues";
  899. public static XName Dependencies = "Dependencies";
  900. public static XName DestinationDir = "DestinationDir";
  901. public static XName Directory = "Directory";
  902. public static XName DirectoryPattern = "DirectoryPattern";
  903. public static XName DisplayName = "DisplayName";
  904. public static XName DoJobQueueName = "DoJobQueueName";
  905. public static XName Document = "Document";
  906. public static XName DocumentProtection = "DocumentProtection";
  907. public static XName DocumentSelector = "DocumentSelector";
  908. public static XName DocumentType = "DocumentType";
  909. public static XName Documents = "Documents";
  910. public static XName EastAsiaCharCount = "EastAsiaCharCount";
  911. public static XName EastAsiaRunCount = "EastAsiaRunCount";
  912. public static XName ElementCount = "ElementCount";
  913. public static XName EmbeddedXlsx = "EmbeddedXlsx";
  914. public static XName Error = "Error";
  915. public static XName Exception = "Exception";
  916. public static XName Exe = "Exe";
  917. public static XName ExeRoot = "ExeRoot";
  918. public static XName Extension = "Extension";
  919. public static XName File = "File";
  920. public static XName FileLength = "FileLength";
  921. public static XName FileName = "FileName";
  922. public static XName FilePattern = "FilePattern";
  923. public static XName FileType = "FileType";
  924. public static XName Guid = "Guid";
  925. public static XName HAnsiCharCount = "HAnsiCharCount";
  926. public static XName HAnsiRunCount = "HAnsiRunCount";
  927. public static XName RevisionTracking = "RevisionTracking";
  928. public static XName Hyperlink = "Hyperlink";
  929. public static XName IPAddress = "IPAddress";
  930. public static XName Id = "Id";
  931. public static XName Invalid = "Invalid";
  932. public static XName InvalidHyperlink = "InvalidHyperlink";
  933. public static XName InvalidHyperlinkException = "InvalidHyperlinkException";
  934. public static XName InvalidSaveThroughXslt = "InvalidSaveThroughXslt";
  935. public static XName JobComplete = "JobComplete";
  936. public static XName JobExe = "JobExe";
  937. public static XName JobName = "JobName";
  938. public static XName JobSpec = "JobSpec";
  939. public static XName Languages = "Languages";
  940. public static XName LegacyFrame = "LegacyFrame";
  941. public static XName LocalDoJobQueue = "LocalDoJobQueue";
  942. public static XName MachineName = "MachineName";
  943. public static XName MaxConcurrentJobs = "MaxConcurrentJobs";
  944. public static XName MaxDocumentsInJob = "MaxDocumentsInJob";
  945. public static XName MaxParagraphLength = "MaxParagraphLength";
  946. public static XName Message = "Message";
  947. public static XName Metrics = "Metrics";
  948. public static XName MultiDirectory = "MultiDirectory";
  949. public static XName MultiFontRun = "MultiFontRun";
  950. public static XName MultiServerQueue = "MultiServerQueue";
  951. public static XName Name = "Name";
  952. public static XName Namespaces = "Namespaces";
  953. public static XName Namespace = "Namespace";
  954. public static XName NamespaceName = "NamespaceName";
  955. public static XName NamespacePrefix = "NamespacePrefix";
  956. public static XName Note = "Note";
  957. public static XName NumberingFormatList = "NumberingFormatList";
  958. public static XName ObjectDisposedException = "ObjectDisposedException";
  959. public static XName ParagraphCount = "ParagraphCount";
  960. public static XName Part = "Part";
  961. public static XName Parts = "Parts";
  962. public static XName PassedDocuments = "PassedDocuments";
  963. public static XName Path = "Path";
  964. public static XName ProduceCatalog = "ProduceCatalog";
  965. public static XName ReferenceToNullImage = "ReferenceToNullImage";
  966. public static XName Report = "Report";
  967. public static XName Root = "Root";
  968. public static XName RootDirectory = "RootDirectory";
  969. public static XName Row = "Row";
  970. public static XName RunCount = "RunCount";
  971. public static XName RunWithoutRprCount = "RunWithoutRprCount";
  972. public static XName SdkValidationError = "SdkValidationError";
  973. public static XName SdkValidationError2007 = "SdkValidationError2007";
  974. public static XName SdkValidationError2010 = "SdkValidationError2010";
  975. public static XName SdkValidationError2013 = "SdkValidationError2013";
  976. public static XName Sheet = "Sheet";
  977. public static XName Sheets = "Sheets";
  978. public static XName SimpleField = "SimpleField";
  979. public static XName Skip = "Skip";
  980. public static XName SmartTag = "SmartTag";
  981. public static XName SourceRootDir = "SourceRootDir";
  982. public static XName SpawnerJobExeLocation = "SpawnerJobExeLocation";
  983. public static XName SpawnerReady = "SpawnerReady";
  984. public static XName Style = "Style";
  985. public static XName StyleHierarchy = "StyleHierarchy";
  986. public static XName SubDocument = "SubDocument";
  987. public static XName Table = "Table";
  988. public static XName TableData = "TableData";
  989. public static XName Tag = "Tag";
  990. public static XName Take = "Take";
  991. public static XName TextBox = "TextBox";
  992. public static XName TrackRevisionsEnabled = "TrackRevisionsEnabled";
  993. public static XName Type = "Type";
  994. public static XName Uri = "Uri";
  995. public static XName Val = "Val";
  996. public static XName Valid = "Valid";
  997. public static XName WindowStyle = "WindowStyle";
  998. public static XName XPath = "XPath";
  999. public static XName ZeroLengthText = "ZeroLengthText";
  1000. public static XName custDataLst = "custDataLst";
  1001. public static XName custShowLst = "custShowLst";
  1002. public static XName kinsoku = "kinsoku";
  1003. public static XName modifyVerifier = "modifyVerifier";
  1004. public static XName photoAlbum = "photoAlbum";
  1005. }
  1006. }