xlsxabstractsheet.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /****************************************************************************
  2. ** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
  3. ** All right reserved.
  4. **
  5. ** Permission is hereby granted, free of charge, to any person obtaining
  6. ** a copy of this software and associated documentation files (the
  7. ** "Software"), to deal in the Software without restriction, including
  8. ** without limitation the rights to use, copy, modify, merge, publish,
  9. ** distribute, sublicense, and/or sell copies of the Software, and to
  10. ** permit persons to whom the Software is furnished to do so, subject to
  11. ** the following conditions:
  12. **
  13. ** The above copyright notice and this permission notice shall be
  14. ** included in all copies or substantial portions of the Software.
  15. **
  16. ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  17. ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18. ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19. ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  20. ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  21. ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  22. ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. **
  24. ****************************************************************************/
  25. #include "xlsxabstractsheet.h"
  26. #include "xlsxabstractsheet_p.h"
  27. #include "xlsxworkbook.h"
  28. QT_BEGIN_NAMESPACE_XLSX
  29. AbstractSheetPrivate::AbstractSheetPrivate(AbstractSheet *p, AbstractSheet::CreateFlag flag)
  30. : AbstractOOXmlFilePrivate(p, flag)
  31. {
  32. type = AbstractSheet::ST_WorkSheet;
  33. sheetState = AbstractSheet::SS_Visible;
  34. }
  35. AbstractSheetPrivate::~AbstractSheetPrivate()
  36. {
  37. }
  38. /*!
  39. \class AbstractSheet
  40. \inmodule QtXlsx
  41. \brief Base class for worksheet, chartsheet, etc.
  42. */
  43. /*!
  44. \enum AbstractSheet::SheetType
  45. \value ST_WorkSheet
  46. \value ST_ChartSheet
  47. \omitvalue ST_DialogSheet
  48. \omitvalue ST_MacroSheet
  49. */
  50. /*!
  51. \enum AbstractSheet::SheetState
  52. \value SS_Visible
  53. \value SS_Hidden
  54. \value SS_VeryHidden User cann't make a veryHidden sheet visible in normal way.
  55. */
  56. /*!
  57. \fn AbstractSheet::copy(const QString &distName, int distId) const
  58. Copies the current sheet to a sheet called \a distName with \a distId.
  59. Returns the new sheet.
  60. */
  61. /*!
  62. * \internal
  63. */
  64. AbstractSheet::AbstractSheet(const QString &name, int id, Workbook *workbook, AbstractSheetPrivate *d) :
  65. AbstractOOXmlFile(d)
  66. {
  67. d_func()->name = name;
  68. d_func()->id = id;
  69. d_func()->workbook = workbook;
  70. }
  71. /*!
  72. * Returns the name of the sheet.
  73. */
  74. QString AbstractSheet::sheetName() const
  75. {
  76. Q_D(const AbstractSheet);
  77. return d->name;
  78. }
  79. /*!
  80. * \internal
  81. */
  82. void AbstractSheet::setSheetName(const QString &sheetName)
  83. {
  84. Q_D(AbstractSheet);
  85. d->name = sheetName;
  86. }
  87. /*!
  88. * Returns the type of the sheet.
  89. */
  90. AbstractSheet::SheetType AbstractSheet::sheetType() const
  91. {
  92. Q_D(const AbstractSheet);
  93. return d->type;
  94. }
  95. /*!
  96. * \internal
  97. */
  98. void AbstractSheet::setSheetType(SheetType type)
  99. {
  100. Q_D(AbstractSheet);
  101. d->type = type;
  102. }
  103. /*!
  104. * Returns the state of the sheet.
  105. *
  106. * \sa isHidden(), isVisible(), setSheetState()
  107. */
  108. AbstractSheet::SheetState AbstractSheet::sheetState() const
  109. {
  110. Q_D(const AbstractSheet);
  111. return d->sheetState;
  112. }
  113. /*!
  114. * Set the state of the sheet to \a state.
  115. */
  116. void AbstractSheet::setSheetState(SheetState state)
  117. {
  118. Q_D(AbstractSheet);
  119. d->sheetState = state;
  120. }
  121. /*!
  122. * Returns true if the sheet is not visible, otherwise false will be returned.
  123. *
  124. * \sa sheetState(), setHidden()
  125. */
  126. bool AbstractSheet::isHidden() const
  127. {
  128. Q_D(const AbstractSheet);
  129. return d->sheetState != SS_Visible;
  130. }
  131. /*!
  132. * Returns true if the sheet is visible.
  133. */
  134. bool AbstractSheet::isVisible() const
  135. {
  136. return !isHidden();
  137. }
  138. /*!
  139. * Make the sheet hiden or visible based on \a hidden.
  140. */
  141. void AbstractSheet::setHidden(bool hidden)
  142. {
  143. Q_D(AbstractSheet);
  144. if (hidden == isHidden())
  145. return;
  146. d->sheetState = hidden ? SS_Hidden : SS_Visible;
  147. }
  148. /*!
  149. * Convenience function, equivalent to setHidden(! \a visible).
  150. */
  151. void AbstractSheet::setVisible(bool visible)
  152. {
  153. setHidden(!visible);
  154. }
  155. /*!
  156. * \internal
  157. */
  158. int AbstractSheet::sheetId() const
  159. {
  160. Q_D(const AbstractSheet);
  161. return d->id;
  162. }
  163. /*!
  164. * \internal
  165. */
  166. Drawing *AbstractSheet::drawing() const
  167. {
  168. Q_D(const AbstractSheet);
  169. return d->drawing.data();
  170. }
  171. /*!
  172. * Return the workbook
  173. */
  174. Workbook *AbstractSheet::workbook() const
  175. {
  176. Q_D(const AbstractSheet);
  177. return d->workbook;
  178. }
  179. QT_END_NAMESPACE_XLSX