You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. /*************************************************************************************
  2. DocX – DocX is the community edition of Xceed Words for .NET
  3. Copyright (C) 2009-2016 Xceed Software Inc.
  4. This program is provided to you under the terms of the Microsoft Public
  5. License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
  6. For more features and fast professional support,
  7. pick up Xceed Words for .NET at https://xceed.com/xceed-words-for-net/
  8. ***********************************************************************************/
  9. using System;
  10. using System.Linq;
  11. using System.Xml.Linq;
  12. using System.Drawing;
  13. using System.Globalization;
  14. namespace Xceed.Words.NET
  15. {
  16. /// <summary>
  17. /// A text formatting.
  18. /// </summary>
  19. public class Formatting : IComparable
  20. {
  21. #region Private Members
  22. private XElement _rPr;
  23. private bool? _hidden;
  24. private bool? _bold;
  25. private bool? _italic;
  26. private StrikeThrough? _strikethrough;
  27. private Script? _script;
  28. private Highlight? _highlight;
  29. private double? _size;
  30. private Color? _fontColor;
  31. private Color? _underlineColor;
  32. private UnderlineStyle? _underlineStyle;
  33. private Misc? _misc;
  34. private CapsStyle? _capsStyle;
  35. private Font _fontFamily;
  36. private int? _percentageScale;
  37. private int? _kerning;
  38. private int? _position;
  39. private double? _spacing;
  40. private CultureInfo _language;
  41. #endregion
  42. #region Constructors
  43. /// <summary>
  44. /// A text formatting.
  45. /// </summary>
  46. public Formatting()
  47. {
  48. _capsStyle = Xceed.Words.NET.CapsStyle.none;
  49. _strikethrough = Xceed.Words.NET.StrikeThrough.none;
  50. _script = Xceed.Words.NET.Script.none;
  51. _highlight = Xceed.Words.NET.Highlight.none;
  52. _underlineStyle = Xceed.Words.NET.UnderlineStyle.none;
  53. _misc = Xceed.Words.NET.Misc.none;
  54. // Use current culture by default
  55. _language = CultureInfo.CurrentCulture;
  56. _rPr = new XElement( XName.Get( "rPr", DocX.w.NamespaceName ) );
  57. }
  58. #endregion
  59. #region Public Properties
  60. /// <summary>
  61. /// Text language
  62. /// </summary>
  63. public CultureInfo Language
  64. {
  65. get
  66. {
  67. return _language;
  68. }
  69. set
  70. {
  71. _language = value;
  72. }
  73. }
  74. /// <summary>
  75. /// This formatting will apply Bold.
  76. /// </summary>
  77. public bool? Bold
  78. {
  79. get
  80. {
  81. return _bold;
  82. }
  83. set
  84. {
  85. _bold = value;
  86. }
  87. }
  88. /// <summary>
  89. /// This formatting will apply Italic.
  90. /// </summary>
  91. public bool? Italic
  92. {
  93. get
  94. {
  95. return _italic;
  96. }
  97. set
  98. {
  99. _italic = value;
  100. }
  101. }
  102. /// <summary>
  103. /// This formatting will apply StrickThrough.
  104. /// </summary>
  105. public StrikeThrough? StrikeThrough
  106. {
  107. get
  108. {
  109. return _strikethrough;
  110. }
  111. set
  112. {
  113. _strikethrough = value;
  114. }
  115. }
  116. /// <summary>
  117. /// The script that this formatting should be, normal, superscript or subscript.
  118. /// </summary>
  119. public Script? Script
  120. {
  121. get
  122. {
  123. return _script;
  124. }
  125. set
  126. {
  127. _script = value;
  128. }
  129. }
  130. /// <summary>
  131. /// The Size of this text, must be between 0 and 1638.
  132. /// </summary>
  133. public double? Size
  134. {
  135. get
  136. {
  137. return _size;
  138. }
  139. set
  140. {
  141. double? temp = value * 2;
  142. if( temp - ( int )temp == 0 )
  143. {
  144. if( value > 0 && value < 1639 )
  145. {
  146. _size = value;
  147. }
  148. else
  149. throw new ArgumentException( "Size", "Value must be in the range 0 - 1638" );
  150. }
  151. else
  152. throw new ArgumentException( "Size", "Value must be either a whole or half number, examples: 32, 32.5" );
  153. }
  154. }
  155. /// <summary>
  156. /// Percentage scale must be one of the following values 200, 150, 100, 90, 80, 66, 50 or 33.
  157. /// </summary>
  158. public int? PercentageScale
  159. {
  160. get
  161. {
  162. return _percentageScale;
  163. }
  164. set
  165. {
  166. if( ( new int?[] { 200, 150, 100, 90, 80, 66, 50, 33 } ).Contains( value ) )
  167. {
  168. _percentageScale = value;
  169. }
  170. else
  171. throw new ArgumentOutOfRangeException( "PercentageScale", "Value must be one of the following: 200, 150, 100, 90, 80, 66, 50 or 33" );
  172. }
  173. }
  174. /// <summary>
  175. /// The Kerning to apply to this text must be one of the following values 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72.
  176. /// </summary>
  177. public int? Kerning
  178. {
  179. get
  180. {
  181. return _kerning;
  182. }
  183. set
  184. {
  185. if( new int?[] { 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 }.Contains( value ) )
  186. _kerning = value;
  187. else
  188. throw new ArgumentOutOfRangeException( "Kerning", "Value must be one of the following: 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48 or 72" );
  189. }
  190. }
  191. /// <summary>
  192. /// Text position must be in the range (-1585 - 1585).
  193. /// </summary>
  194. public int? Position
  195. {
  196. get
  197. {
  198. return _position;
  199. }
  200. set
  201. {
  202. if( value > -1585 && value < 1585 )
  203. _position = value;
  204. else
  205. throw new ArgumentOutOfRangeException( "Position", "Value must be in the range -1585 - 1585" );
  206. }
  207. }
  208. /// <summary>
  209. /// Text spacing must be in the range (-1585 - 1585).
  210. /// </summary>
  211. public double? Spacing
  212. {
  213. get
  214. {
  215. return _spacing;
  216. }
  217. set
  218. {
  219. double? temp = value * 20;
  220. if( temp - ( int )temp == 0 )
  221. {
  222. if( value > -1585 && value < 1585 )
  223. _spacing = value;
  224. else
  225. throw new ArgumentException( "Spacing", "Value must be in the range: -1584 - 1584" );
  226. }
  227. else
  228. throw new ArgumentException( "Spacing", "Value must be either a whole or acurate to one decimal, examples: 32, 32.1, 32.2, 32.9" );
  229. }
  230. }
  231. /// <summary>
  232. /// The colour of the text.
  233. /// </summary>
  234. public Color? FontColor
  235. {
  236. get
  237. {
  238. return _fontColor;
  239. }
  240. set
  241. {
  242. _fontColor = value;
  243. }
  244. }
  245. /// <summary>
  246. /// Highlight colour.
  247. /// </summary>
  248. public Highlight? Highlight
  249. {
  250. get
  251. {
  252. return _highlight;
  253. }
  254. set
  255. {
  256. _highlight = value;
  257. }
  258. }
  259. /// <summary>
  260. /// The Underline style that this formatting applies.
  261. /// </summary>
  262. public UnderlineStyle? UnderlineStyle
  263. {
  264. get
  265. {
  266. return _underlineStyle;
  267. }
  268. set
  269. {
  270. _underlineStyle = value;
  271. }
  272. }
  273. /// <summary>
  274. /// The underline colour.
  275. /// </summary>
  276. public Color? UnderlineColor
  277. {
  278. get
  279. {
  280. return _underlineColor;
  281. }
  282. set
  283. {
  284. _underlineColor = value;
  285. }
  286. }
  287. /// <summary>
  288. /// Misc settings.
  289. /// </summary>
  290. public Misc? Misc
  291. {
  292. get
  293. {
  294. return _misc;
  295. }
  296. set
  297. {
  298. _misc = value;
  299. }
  300. }
  301. /// <summary>
  302. /// Is this text hidden or visible.
  303. /// </summary>
  304. public bool? Hidden
  305. {
  306. get
  307. {
  308. return _hidden;
  309. }
  310. set
  311. {
  312. _hidden = value;
  313. }
  314. }
  315. /// <summary>
  316. /// Capitalization style.
  317. /// </summary>
  318. public CapsStyle? CapsStyle
  319. {
  320. get
  321. {
  322. return _capsStyle;
  323. }
  324. set
  325. {
  326. _capsStyle = value;
  327. }
  328. }
  329. /// <summary>
  330. /// The font Family of this formatting.
  331. /// </summary>
  332. /// <!--
  333. /// Bug found and fixed by krugs525 on August 12 2009.
  334. /// Use TFS compare to see exact code change.
  335. /// -->
  336. public Font FontFamily
  337. {
  338. get
  339. {
  340. return _fontFamily;
  341. }
  342. set
  343. {
  344. _fontFamily = value;
  345. }
  346. }
  347. #endregion
  348. #region Internal Properties
  349. internal XElement Xml
  350. {
  351. get
  352. {
  353. _rPr = new XElement( XName.Get( "rPr", DocX.w.NamespaceName ) );
  354. if( _language != null )
  355. {
  356. _rPr.Add( new XElement( XName.Get( "lang", DocX.w.NamespaceName ), new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), _language.Name ) ) );
  357. }
  358. if( _spacing.HasValue )
  359. {
  360. _rPr.Add( new XElement( XName.Get( "spacing", DocX.w.NamespaceName ), new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), _spacing.Value * 20 ) ) );
  361. }
  362. if( _position.HasValue )
  363. {
  364. _rPr.Add( new XElement( XName.Get( "position", DocX.w.NamespaceName ), new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), _position.Value * 2 ) ) );
  365. }
  366. if( _kerning.HasValue )
  367. {
  368. _rPr.Add( new XElement( XName.Get( "kern", DocX.w.NamespaceName ), new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), _kerning.Value * 2 ) ) );
  369. }
  370. if( _percentageScale.HasValue )
  371. {
  372. _rPr.Add( new XElement( XName.Get( "w", DocX.w.NamespaceName ), new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), _percentageScale ) ) );
  373. }
  374. if( _fontFamily != null )
  375. {
  376. _rPr.Add
  377. (
  378. new XElement( XName.Get( "rFonts", DocX.w.NamespaceName ), new XAttribute( XName.Get( "ascii", DocX.w.NamespaceName ), _fontFamily.Name ),
  379. new XAttribute( XName.Get( "hAnsi", DocX.w.NamespaceName ), _fontFamily.Name ),
  380. new XAttribute( XName.Get( "cs", DocX.w.NamespaceName ), _fontFamily.Name ) )
  381. );
  382. }
  383. if( _hidden.HasValue && _hidden.Value )
  384. {
  385. _rPr.Add( new XElement( XName.Get( "vanish", DocX.w.NamespaceName ) ) );
  386. }
  387. if( _bold.HasValue && _bold.Value )
  388. {
  389. _rPr.Add( new XElement( XName.Get( "b", DocX.w.NamespaceName ) ) );
  390. }
  391. if( _italic.HasValue && _italic.Value )
  392. {
  393. _rPr.Add( new XElement( XName.Get( "i", DocX.w.NamespaceName ) ) );
  394. }
  395. if( _underlineStyle.HasValue )
  396. {
  397. switch( _underlineStyle )
  398. {
  399. case Xceed.Words.NET.UnderlineStyle.none:
  400. break;
  401. case Xceed.Words.NET.UnderlineStyle.singleLine:
  402. _rPr.Add( new XElement( XName.Get( "u", DocX.w.NamespaceName ), new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), "single" ) ) );
  403. break;
  404. case Xceed.Words.NET.UnderlineStyle.doubleLine:
  405. _rPr.Add( new XElement( XName.Get( "u", DocX.w.NamespaceName ), new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), "double" ) ) );
  406. break;
  407. default:
  408. _rPr.Add( new XElement( XName.Get( "u", DocX.w.NamespaceName ), new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), _underlineStyle.ToString() ) ) );
  409. break;
  410. }
  411. }
  412. if( _underlineColor.HasValue )
  413. {
  414. // If an underlineColor has been set but no underlineStyle has been set
  415. if( _underlineStyle == Xceed.Words.NET.UnderlineStyle.none )
  416. {
  417. // Set the underlineStyle to the default
  418. _underlineStyle = Xceed.Words.NET.UnderlineStyle.singleLine;
  419. _rPr.Add( new XElement( XName.Get( "u", DocX.w.NamespaceName ), new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), "single" ) ) );
  420. }
  421. _rPr.Element( XName.Get( "u", DocX.w.NamespaceName ) ).Add( new XAttribute( XName.Get( "color", DocX.w.NamespaceName ), _underlineColor.Value.ToHex() ) );
  422. }
  423. if( _strikethrough.HasValue )
  424. {
  425. switch( _strikethrough )
  426. {
  427. case Xceed.Words.NET.StrikeThrough.none:
  428. break;
  429. case Xceed.Words.NET.StrikeThrough.strike:
  430. _rPr.Add( new XElement( XName.Get( "strike", DocX.w.NamespaceName ) ) );
  431. break;
  432. case Xceed.Words.NET.StrikeThrough.doubleStrike:
  433. _rPr.Add( new XElement( XName.Get( "dstrike", DocX.w.NamespaceName ) ) );
  434. break;
  435. default:
  436. break;
  437. }
  438. }
  439. if( _script.HasValue )
  440. {
  441. switch( _script )
  442. {
  443. case Xceed.Words.NET.Script.none:
  444. break;
  445. default:
  446. _rPr.Add( new XElement( XName.Get( "vertAlign", DocX.w.NamespaceName ), new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), _script.ToString() ) ) );
  447. break;
  448. }
  449. }
  450. if( _size.HasValue )
  451. {
  452. _rPr.Add( new XElement( XName.Get( "sz", DocX.w.NamespaceName ), new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), ( _size * 2 ).ToString() ) ) );
  453. _rPr.Add( new XElement( XName.Get( "szCs", DocX.w.NamespaceName ), new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), ( _size * 2 ).ToString() ) ) );
  454. }
  455. if( _fontColor.HasValue )
  456. {
  457. _rPr.Add( new XElement( XName.Get( "color", DocX.w.NamespaceName ), new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), _fontColor.Value.ToHex() ) ) );
  458. }
  459. if( _highlight.HasValue )
  460. {
  461. switch( _highlight )
  462. {
  463. case Xceed.Words.NET.Highlight.none:
  464. break;
  465. default:
  466. _rPr.Add( new XElement( XName.Get( "highlight", DocX.w.NamespaceName ), new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), _highlight.ToString() ) ) );
  467. break;
  468. }
  469. }
  470. if( _capsStyle.HasValue )
  471. {
  472. switch( _capsStyle )
  473. {
  474. case Xceed.Words.NET.CapsStyle.none:
  475. break;
  476. default:
  477. _rPr.Add( new XElement( XName.Get( _capsStyle.ToString(), DocX.w.NamespaceName ) ) );
  478. break;
  479. }
  480. }
  481. if( _misc.HasValue )
  482. {
  483. switch( _misc )
  484. {
  485. case Xceed.Words.NET.Misc.none:
  486. break;
  487. case Xceed.Words.NET.Misc.outlineShadow:
  488. _rPr.Add( new XElement( XName.Get( "outline", DocX.w.NamespaceName ) ) );
  489. _rPr.Add( new XElement( XName.Get( "shadow", DocX.w.NamespaceName ) ) );
  490. break;
  491. case Xceed.Words.NET.Misc.engrave:
  492. _rPr.Add( new XElement( XName.Get( "imprint", DocX.w.NamespaceName ) ) );
  493. break;
  494. default:
  495. _rPr.Add( new XElement( XName.Get( _misc.ToString(), DocX.w.NamespaceName ) ) );
  496. break;
  497. }
  498. }
  499. return _rPr;
  500. }
  501. }
  502. #endregion
  503. #region Public Methods
  504. /// <summary>
  505. /// Returns a cloned instance of Formatting.
  506. /// </summary>
  507. /// <returns></returns>
  508. public Formatting Clone()
  509. {
  510. var clone = new Formatting();
  511. clone.Bold = _bold;
  512. clone.CapsStyle = _capsStyle;
  513. clone.FontColor = _fontColor;
  514. clone.FontFamily = _fontFamily;
  515. clone.Hidden = _hidden;
  516. clone.Highlight = _highlight;
  517. clone.Italic = _italic;
  518. if( _kerning.HasValue )
  519. {
  520. clone.Kerning = _kerning;
  521. }
  522. clone.Language = _language;
  523. clone.Misc = _misc;
  524. if( _percentageScale.HasValue )
  525. {
  526. clone.PercentageScale = _percentageScale;
  527. }
  528. if( _position.HasValue )
  529. {
  530. clone.Position = _position;
  531. }
  532. clone.Script = _script;
  533. if( _size.HasValue )
  534. {
  535. clone.Size = _size;
  536. }
  537. if( _spacing.HasValue )
  538. {
  539. clone.Spacing = _spacing;
  540. }
  541. clone.StrikeThrough = _strikethrough;
  542. clone.UnderlineColor = _underlineColor;
  543. clone.UnderlineStyle = _underlineStyle;
  544. return clone;
  545. }
  546. public static Formatting Parse( XElement rPr )
  547. {
  548. var formatting = new Formatting();
  549. // Build up the Formatting object.
  550. foreach( XElement option in rPr.Elements() )
  551. {
  552. switch( option.Name.LocalName )
  553. {
  554. case "lang":
  555. formatting.Language = new CultureInfo(option.GetAttribute(XName.Get("val", DocX.w.NamespaceName), null) ?? option.GetAttribute(XName.Get("eastAsia", DocX.w.NamespaceName), null) ?? option.GetAttribute(XName.Get("bidi", DocX.w.NamespaceName)));
  556. break;
  557. case "spacing":
  558. formatting.Spacing = Double.Parse(option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 20.0;
  559. break;
  560. case "position":
  561. formatting.Position = Int32.Parse(option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 2;
  562. break;
  563. case "kern":
  564. formatting.Position = Int32.Parse(option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 2;
  565. break;
  566. case "w":
  567. formatting.PercentageScale = Int32.Parse(option.GetAttribute(XName.Get("val", DocX.w.NamespaceName)));
  568. break;
  569. case "sz":
  570. formatting.Size = Int32.Parse(option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 2;
  571. break;
  572. case "rFonts":
  573. formatting.FontFamily = new Font(option.GetAttribute(XName.Get("cs", DocX.w.NamespaceName), null) ?? option.GetAttribute(XName.Get("ascii", DocX.w.NamespaceName), null) ?? option.GetAttribute(XName.Get("hAnsi", DocX.w.NamespaceName), null) ?? option.GetAttribute(XName.Get("eastAsia", DocX.w.NamespaceName)));
  574. break;
  575. case "color":
  576. try
  577. {
  578. var color = option.GetAttribute(XName.Get("val", DocX.w.NamespaceName));
  579. formatting.FontColor = System.Drawing.ColorTranslator.FromHtml(string.Format("#{0}", color));
  580. }
  581. catch (Exception)
  582. {
  583. // ignore
  584. }
  585. break;
  586. case "vanish":
  587. formatting._hidden = true;
  588. break;
  589. case "b":
  590. formatting.Bold = true;
  591. break;
  592. case "i":
  593. formatting.Italic = true;
  594. break;
  595. case "highlight":
  596. switch( option.GetAttribute( XName.Get( "val", DocX.w.NamespaceName ) ) )
  597. {
  598. case "yellow":
  599. formatting.Highlight = NET.Highlight.yellow;
  600. break;
  601. case "green":
  602. formatting.Highlight = NET.Highlight.green;
  603. break;
  604. case "cyan":
  605. formatting.Highlight = NET.Highlight.cyan;
  606. break;
  607. case "magenta":
  608. formatting.Highlight = NET.Highlight.magenta;
  609. break;
  610. case "blue":
  611. formatting.Highlight = NET.Highlight.blue;
  612. break;
  613. case "red":
  614. formatting.Highlight = NET.Highlight.red;
  615. break;
  616. case "darkBlue":
  617. formatting.Highlight = NET.Highlight.darkBlue;
  618. break;
  619. case "darkCyan":
  620. formatting.Highlight = NET.Highlight.darkCyan;
  621. break;
  622. case "darkGreen":
  623. formatting.Highlight = NET.Highlight.darkGreen;
  624. break;
  625. case "darkMagenta":
  626. formatting.Highlight = NET.Highlight.darkMagenta;
  627. break;
  628. case "darkRed":
  629. formatting.Highlight = NET.Highlight.darkRed;
  630. break;
  631. case "darkYellow":
  632. formatting.Highlight = NET.Highlight.darkYellow;
  633. break;
  634. case "darkGray":
  635. formatting.Highlight = NET.Highlight.darkGray;
  636. break;
  637. case "lightGray":
  638. formatting.Highlight = NET.Highlight.lightGray;
  639. break;
  640. case "black":
  641. formatting.Highlight = NET.Highlight.black;
  642. break;
  643. }
  644. break;
  645. case "strike":
  646. formatting.StrikeThrough = NET.StrikeThrough.strike;
  647. break;
  648. case "u":
  649. formatting.UnderlineStyle = HelperFunctions.GetUnderlineStyle(option.GetAttribute(XName.Get("val", DocX.w.NamespaceName)));
  650. break;
  651. case "vertAlign":
  652. var script = option.GetAttribute(XName.Get("val", DocX.w.NamespaceName), null);
  653. formatting.Script = (Script)Enum.Parse(typeof(Script), script);
  654. break;
  655. default:
  656. break;
  657. }
  658. }
  659. return formatting;
  660. }
  661. public int CompareTo( object obj )
  662. {
  663. Formatting other = ( Formatting )obj;
  664. if( other._hidden != _hidden )
  665. return -1;
  666. if( other._bold != _bold )
  667. return -1;
  668. if( other._italic != _italic )
  669. return -1;
  670. if( other._strikethrough != _strikethrough )
  671. return -1;
  672. if( other._script != _script )
  673. return -1;
  674. if( other._highlight != _highlight )
  675. return -1;
  676. if( other._size != _size )
  677. return -1;
  678. if( other._fontColor != _fontColor )
  679. return -1;
  680. if( other._underlineColor != _underlineColor )
  681. return -1;
  682. if( other._underlineStyle != _underlineStyle )
  683. return -1;
  684. if( other._misc != _misc )
  685. return -1;
  686. if( other._capsStyle != _capsStyle )
  687. return -1;
  688. if( other._fontFamily != _fontFamily )
  689. return -1;
  690. if( other._percentageScale != _percentageScale )
  691. return -1;
  692. if( other._kerning != _kerning )
  693. return -1;
  694. if( other._position != _position )
  695. return -1;
  696. if( other._spacing != _spacing )
  697. return -1;
  698. if( !other._language.Equals(_language) )
  699. return -1;
  700. return 0;
  701. }
  702. #endregion
  703. }
  704. }