WmlComparer.Private.Fields.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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.Xml.Linq;
  5. namespace OpenXmlPowerTools
  6. {
  7. public static partial class WmlComparer
  8. {
  9. #pragma warning disable 414
  10. private static readonly bool False = false;
  11. private static readonly bool True = true;
  12. private static readonly bool SaveIntermediateFilesForDebugging = false;
  13. #pragma warning restore 414
  14. private static readonly string NewLine = Environment.NewLine;
  15. private static readonly XAttribute[] NamespaceAttributes =
  16. {
  17. new XAttribute(XNamespace.Xmlns + "wpc", WPC.wpc),
  18. new XAttribute(XNamespace.Xmlns + "mc", MC.mc),
  19. new XAttribute(XNamespace.Xmlns + "o", O.o),
  20. new XAttribute(XNamespace.Xmlns + "r", R.r),
  21. new XAttribute(XNamespace.Xmlns + "m", M.m),
  22. new XAttribute(XNamespace.Xmlns + "v", VML.vml),
  23. new XAttribute(XNamespace.Xmlns + "wp14", WP14.wp14),
  24. new XAttribute(XNamespace.Xmlns + "wp", WP.wp),
  25. new XAttribute(XNamespace.Xmlns + "w10", W10.w10),
  26. new XAttribute(XNamespace.Xmlns + "w", W.w),
  27. new XAttribute(XNamespace.Xmlns + "w14", W14.w14),
  28. new XAttribute(XNamespace.Xmlns + "wpg", WPG.wpg),
  29. new XAttribute(XNamespace.Xmlns + "wpi", WPI.wpi),
  30. new XAttribute(XNamespace.Xmlns + "wne", WNE.wne),
  31. new XAttribute(XNamespace.Xmlns + "wps", WPS.wps),
  32. new XAttribute(MC.Ignorable, "w14 wp14")
  33. };
  34. private static readonly XName[] RevElementsWithNoText =
  35. {
  36. M.oMath,
  37. M.oMathPara,
  38. W.drawing
  39. };
  40. private static readonly XName[] AttributesToTrimWhenCloning =
  41. {
  42. WP14.anchorId,
  43. WP14.editId,
  44. "ObjectID",
  45. "ShapeID",
  46. "id",
  47. "type"
  48. };
  49. private static int _maxId;
  50. private static readonly XName[] WordBreakElements =
  51. {
  52. W.pPr,
  53. W.tab,
  54. W.br,
  55. W.continuationSeparator,
  56. W.cr,
  57. W.dayLong,
  58. W.dayShort,
  59. W.drawing,
  60. W.pict,
  61. W.endnoteRef,
  62. W.footnoteRef,
  63. W.monthLong,
  64. W.monthShort,
  65. W.noBreakHyphen,
  66. W._object,
  67. W.ptab,
  68. W.separator,
  69. W.sym,
  70. W.yearLong,
  71. W.yearShort,
  72. M.oMathPara,
  73. M.oMath,
  74. W.footnoteReference,
  75. W.endnoteReference
  76. };
  77. private static readonly XName[] AllowableRunChildren =
  78. {
  79. W.br,
  80. W.drawing,
  81. W.cr,
  82. W.dayLong,
  83. W.dayShort,
  84. W.footnoteReference,
  85. W.endnoteReference,
  86. W.monthLong,
  87. W.monthShort,
  88. W.noBreakHyphen,
  89. //W._object,
  90. W.pgNum,
  91. W.ptab,
  92. W.softHyphen,
  93. W.sym,
  94. W.tab,
  95. W.yearLong,
  96. W.yearShort,
  97. M.oMathPara,
  98. M.oMath,
  99. W.fldChar,
  100. W.instrText
  101. };
  102. private static readonly XName[] ElementsToThrowAway =
  103. {
  104. W.bookmarkStart,
  105. W.bookmarkEnd,
  106. W.commentRangeStart,
  107. W.commentRangeEnd,
  108. W.lastRenderedPageBreak,
  109. W.proofErr,
  110. W.tblPr,
  111. W.sectPr,
  112. W.permEnd,
  113. W.permStart,
  114. W.footnoteRef,
  115. W.endnoteRef,
  116. W.separator,
  117. W.continuationSeparator
  118. };
  119. private static readonly XName[] ElementsToHaveSha1Hash =
  120. {
  121. W.p,
  122. W.tbl,
  123. W.tr,
  124. W.tc,
  125. W.drawing,
  126. W.pict,
  127. W.txbxContent
  128. };
  129. private static readonly XName[] InvalidElements =
  130. {
  131. W.altChunk,
  132. W.customXml,
  133. W.customXmlDelRangeEnd,
  134. W.customXmlDelRangeStart,
  135. W.customXmlInsRangeEnd,
  136. W.customXmlInsRangeStart,
  137. W.customXmlMoveFromRangeEnd,
  138. W.customXmlMoveFromRangeStart,
  139. W.customXmlMoveToRangeEnd,
  140. W.customXmlMoveToRangeStart,
  141. W.moveFrom,
  142. W.moveFromRangeStart,
  143. W.moveFromRangeEnd,
  144. W.moveTo,
  145. W.moveToRangeStart,
  146. W.moveToRangeEnd,
  147. W.subDoc
  148. };
  149. private static readonly RecursionInfo[] RecursionElements =
  150. {
  151. new RecursionInfo
  152. {
  153. ElementName = W.del,
  154. ChildElementPropertyNames = null
  155. },
  156. new RecursionInfo
  157. {
  158. ElementName = W.ins,
  159. ChildElementPropertyNames = null
  160. },
  161. new RecursionInfo
  162. {
  163. ElementName = W.tbl,
  164. ChildElementPropertyNames = new[] { W.tblPr, W.tblGrid, W.tblPrEx }
  165. },
  166. new RecursionInfo
  167. {
  168. ElementName = W.tr,
  169. ChildElementPropertyNames = new[] { W.trPr, W.tblPrEx }
  170. },
  171. new RecursionInfo
  172. {
  173. ElementName = W.tc,
  174. ChildElementPropertyNames = new[] { W.tcPr, W.tblPrEx }
  175. },
  176. new RecursionInfo
  177. {
  178. ElementName = W.pict,
  179. ChildElementPropertyNames = new[] { VML.shapetype }
  180. },
  181. new RecursionInfo
  182. {
  183. ElementName = VML.group,
  184. ChildElementPropertyNames = null
  185. },
  186. new RecursionInfo
  187. {
  188. ElementName = VML.shape,
  189. ChildElementPropertyNames = null
  190. },
  191. new RecursionInfo
  192. {
  193. ElementName = VML.rect,
  194. ChildElementPropertyNames = null
  195. },
  196. new RecursionInfo
  197. {
  198. ElementName = VML.textbox,
  199. ChildElementPropertyNames = null
  200. },
  201. new RecursionInfo
  202. {
  203. ElementName = O._lock,
  204. ChildElementPropertyNames = null
  205. },
  206. new RecursionInfo
  207. {
  208. ElementName = W.txbxContent,
  209. ChildElementPropertyNames = null
  210. },
  211. new RecursionInfo
  212. {
  213. ElementName = W10.wrap,
  214. ChildElementPropertyNames = null
  215. },
  216. new RecursionInfo
  217. {
  218. ElementName = W.sdt,
  219. ChildElementPropertyNames = new[] { W.sdtPr, W.sdtEndPr }
  220. },
  221. new RecursionInfo
  222. {
  223. ElementName = W.sdtContent,
  224. ChildElementPropertyNames = null
  225. },
  226. new RecursionInfo
  227. {
  228. ElementName = W.hyperlink,
  229. ChildElementPropertyNames = null
  230. },
  231. new RecursionInfo
  232. {
  233. ElementName = W.fldSimple,
  234. ChildElementPropertyNames = null
  235. },
  236. new RecursionInfo
  237. {
  238. ElementName = VML.shapetype,
  239. ChildElementPropertyNames = null
  240. },
  241. new RecursionInfo
  242. {
  243. ElementName = W.smartTag,
  244. ChildElementPropertyNames = new[] { W.smartTagPr }
  245. },
  246. new RecursionInfo
  247. {
  248. ElementName = W.ruby,
  249. ChildElementPropertyNames = new[] { W.rubyPr }
  250. }
  251. };
  252. private static readonly XName[] ComparisonGroupingElements =
  253. {
  254. W.p,
  255. W.tbl,
  256. W.tr,
  257. W.tc,
  258. W.txbxContent
  259. };
  260. }
  261. }