ReportEngine.Outline.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using FastReport.Utils;
  2. using System;
  3. namespace FastReport.Engine
  4. {
  5. public partial class ReportEngine
  6. {
  7. #region Properties
  8. /// <summary>
  9. /// Gets xml containing outline nodes.
  10. /// </summary>
  11. public XmlItem OutlineXml
  12. {
  13. get { return PreparedPages.Outline.Xml; }
  14. }
  15. #endregion Properties
  16. #region Private Methods
  17. private void AddOutline(string name, int pageNo, float curY)
  18. {
  19. PreparedPages.Outline.Add(name, pageNo, curY);
  20. }
  21. private void AddBandOutline(BandBase band)
  22. {
  23. if (band.Visible && !String.IsNullOrEmpty(band.OutlineExpression) && !band.Repeated)
  24. {
  25. AddOutline(Converter.ToString(Report.Calc(band.OutlineExpression)), CurPage, CurY);
  26. if (!(band is DataBand) && !(band is GroupHeaderBand))
  27. OutlineUp();
  28. }
  29. }
  30. private void AddPageOutline()
  31. {
  32. if (!String.IsNullOrEmpty(page.OutlineExpression))
  33. AddOutline(Converter.ToString(Report.Calc(page.OutlineExpression)), CurPage, 0);
  34. }
  35. private void OutlineUp(BandBase band)
  36. {
  37. if (band is DataBand || band is GroupHeaderBand)
  38. {
  39. if (!String.IsNullOrEmpty(band.OutlineExpression))
  40. OutlineUp();
  41. }
  42. }
  43. #endregion Private Methods
  44. #region Public Methods
  45. /// <summary>
  46. /// Creates a new outline element with specified text.
  47. /// </summary>
  48. /// <param name="text">Text of element.</param>
  49. /// <remarks>
  50. /// After you call this method, the element will be added to the current position in the outline.
  51. /// The next call to <b>AddOutline</b> will add new element as a child of this element.
  52. /// To shift the position, use the <see cref="OutlineRoot"/> or
  53. /// <see cref="OutlineUp()">OutlineUp</see> methods.
  54. /// </remarks>
  55. public void AddOutline(string text)
  56. {
  57. AddOutline(text, CurPage, CurY);
  58. }
  59. /// <summary>
  60. /// Sets the current outline position to root.
  61. /// </summary>
  62. public void OutlineRoot()
  63. {
  64. PreparedPages.Outline.LevelRoot();
  65. }
  66. /// <summary>
  67. /// Shifts the current outline position one level up.
  68. /// </summary>
  69. public void OutlineUp()
  70. {
  71. PreparedPages.Outline.LevelUp();
  72. }
  73. /// <summary>
  74. /// Creates a new bookmark with specified name at current position.
  75. /// </summary>
  76. /// <param name="name"></param>
  77. public void AddBookmark(string name)
  78. {
  79. if (!String.IsNullOrEmpty(name))
  80. PreparedPages.Bookmarks.Add(name, CurPage, CurY);
  81. }
  82. /// <summary>
  83. /// Gets a page number for the specified bookmark name.
  84. /// </summary>
  85. /// <param name="name">Name of bookmark.</param>
  86. /// <returns>Page number if bookmark with such name found; 0 otherwise.</returns>
  87. /// <remarks>
  88. /// Use this method to print the table of contents in your report. Normally it can be done
  89. /// using bookmarks.
  90. /// <note type="caution">
  91. /// You must set your report to double pass to use this method.
  92. /// </note>
  93. /// </remarks>
  94. public int GetBookmarkPage(string name)
  95. {
  96. return PreparedPages.Bookmarks.GetPageNo(name);
  97. }
  98. #endregion Public Methods
  99. }
  100. }