Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

DocProperty.cs 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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.Xml.Linq;
  10. using System.Text.RegularExpressions;
  11. namespace Xceed.Words.NET
  12. {
  13. /// <summary>
  14. /// Represents a field of type document property. This field displays the value stored in a custom property.
  15. /// </summary>
  16. public class DocProperty : DocXElement
  17. {
  18. #region Internal Members
  19. internal Regex _extractName = new Regex( @"DOCPROPERTY (?<name>.*) " );
  20. #endregion
  21. #region Public Properties
  22. /// <summary>
  23. /// The custom property to display.
  24. /// </summary>
  25. public string Name
  26. {
  27. get;
  28. private set;
  29. }
  30. #endregion
  31. #region Constructors
  32. internal DocProperty( DocX document, XElement xml ) : base( document, xml )
  33. {
  34. var instr = Xml.Attribute( XName.Get( "instr", "http://schemas.openxmlformats.org/wordprocessingml/2006/main" ) ).Value;
  35. this.Name = _extractName.Match( instr.Trim() ).Groups[ "name" ].Value;
  36. }
  37. #endregion
  38. }
  39. }