xlsxabstractsheet.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. // xlsxabstractsheet.cpp
  2. #include <QtGlobal>
  3. #include "xlsxabstractsheet.h"
  4. #include "xlsxabstractsheet_p.h"
  5. #include "xlsxworkbook.h"
  6. QT_BEGIN_NAMESPACE_XLSX
  7. AbstractSheetPrivate::AbstractSheetPrivate(AbstractSheet *p, AbstractSheet::CreateFlag flag)
  8. : AbstractOOXmlFilePrivate(p, flag)
  9. {
  10. type = AbstractSheet::ST_WorkSheet;
  11. sheetState = AbstractSheet::SS_Visible;
  12. }
  13. AbstractSheetPrivate::~AbstractSheetPrivate()
  14. {
  15. }
  16. /*!
  17. \class AbstractSheet
  18. \inmodule QtXlsx
  19. \brief Base class for worksheet, chartsheet, etc.
  20. */
  21. /*!
  22. \enum AbstractSheet::SheetType
  23. \value ST_WorkSheet
  24. \value ST_ChartSheet
  25. \omitvalue ST_DialogSheet
  26. \omitvalue ST_MacroSheet
  27. */
  28. /*!
  29. \enum AbstractSheet::SheetState
  30. \value SS_Visible
  31. \value SS_Hidden
  32. \value SS_VeryHidden User cann't make a veryHidden sheet visible in normal way.
  33. */
  34. /*!
  35. \fn AbstractSheet::copy(const QString &distName, int distId) const
  36. Copies the current sheet to a sheet called \a distName with \a distId.
  37. Returns the new sheet.
  38. */
  39. /*!
  40. * \internal
  41. */
  42. AbstractSheet::AbstractSheet(const QString &name, int id, Workbook *workbook, AbstractSheetPrivate *d) :
  43. AbstractOOXmlFile(d)
  44. {
  45. d_func()->name = name;
  46. d_func()->id = id;
  47. d_func()->workbook = workbook;
  48. }
  49. /*!
  50. * Returns the name of the sheet.
  51. */
  52. QString AbstractSheet::sheetName() const
  53. {
  54. Q_D(const AbstractSheet);
  55. return d->name;
  56. }
  57. /*!
  58. * \internal
  59. */
  60. void AbstractSheet::setSheetName(const QString &sheetName)
  61. {
  62. Q_D(AbstractSheet);
  63. d->name = sheetName;
  64. }
  65. /*!
  66. * Returns the type of the sheet.
  67. */
  68. AbstractSheet::SheetType AbstractSheet::sheetType() const
  69. {
  70. Q_D(const AbstractSheet);
  71. return d->type;
  72. }
  73. /*!
  74. * \internal
  75. */
  76. void AbstractSheet::setSheetType(SheetType type)
  77. {
  78. Q_D(AbstractSheet);
  79. d->type = type;
  80. }
  81. /*!
  82. * Returns the state of the sheet.
  83. *
  84. * \sa isHidden(), isVisible(), setSheetState()
  85. */
  86. AbstractSheet::SheetState AbstractSheet::sheetState() const
  87. {
  88. Q_D(const AbstractSheet);
  89. return d->sheetState;
  90. }
  91. /*!
  92. * Set the state of the sheet to \a state.
  93. */
  94. void AbstractSheet::setSheetState(SheetState state)
  95. {
  96. Q_D(AbstractSheet);
  97. d->sheetState = state;
  98. }
  99. /*!
  100. * Returns true if the sheet is not visible, otherwise false will be returned.
  101. *
  102. * \sa sheetState(), setHidden()
  103. */
  104. bool AbstractSheet::isHidden() const
  105. {
  106. Q_D(const AbstractSheet);
  107. return d->sheetState != SS_Visible;
  108. }
  109. /*!
  110. * Returns true if the sheet is visible.
  111. */
  112. bool AbstractSheet::isVisible() const
  113. {
  114. return !isHidden();
  115. }
  116. /*!
  117. * Make the sheet hiden or visible based on \a hidden.
  118. */
  119. void AbstractSheet::setHidden(bool hidden)
  120. {
  121. Q_D(AbstractSheet);
  122. if (hidden == isHidden())
  123. return;
  124. d->sheetState = hidden ? SS_Hidden : SS_Visible;
  125. }
  126. /*!
  127. * Convenience function, equivalent to setHidden(! \a visible).
  128. */
  129. void AbstractSheet::setVisible(bool visible)
  130. {
  131. setHidden(!visible);
  132. }
  133. /*!
  134. * \internal
  135. */
  136. int AbstractSheet::sheetId() const
  137. {
  138. Q_D(const AbstractSheet);
  139. return d->id;
  140. }
  141. /*!
  142. * \internal
  143. */
  144. Drawing *AbstractSheet::drawing() const
  145. {
  146. Q_D(const AbstractSheet);
  147. return d->drawing.data();
  148. }
  149. /*!
  150. * Return the workbook
  151. */
  152. Workbook *AbstractSheet::workbook() const
  153. {
  154. Q_D(const AbstractSheet);
  155. return d->workbook;
  156. }
  157. QT_END_NAMESPACE_XLSX