File indexing completed on 2025-04-20 09:32:50

0001 // xlsxabstractsheet.cpp
0002 
0003 #include <QtGlobal>
0004 
0005 #include "xlsxabstractsheet.h"
0006 #include "xlsxabstractsheet_p.h"
0007 #include "xlsxworkbook.h"
0008 
0009 QT_BEGIN_NAMESPACE_XLSX
0010 
0011 AbstractSheetPrivate::AbstractSheetPrivate(AbstractSheet *p, AbstractSheet::CreateFlag flag)
0012     : AbstractOOXmlFilePrivate(p, flag)
0013 {
0014     type = AbstractSheet::ST_WorkSheet;
0015     sheetState = AbstractSheet::SS_Visible;
0016 }
0017 
0018 AbstractSheetPrivate::~AbstractSheetPrivate()
0019 {
0020 }
0021 
0022 /*!
0023   \class AbstractSheet
0024   \inmodule QtXlsx
0025   \brief Base class for worksheet, chartsheet, etc.
0026 */
0027 
0028 /*!
0029   \enum AbstractSheet::SheetType
0030 
0031   \value ST_WorkSheet
0032   \value ST_ChartSheet
0033   \omitvalue ST_DialogSheet
0034   \omitvalue ST_MacroSheet
0035 */
0036 
0037 /*!
0038   \enum AbstractSheet::SheetState
0039 
0040   \value SS_Visible
0041   \value SS_Hidden
0042   \value SS_VeryHidden User cann't make a veryHidden sheet visible in normal way.
0043 */
0044 
0045 /*!
0046   \fn AbstractSheet::copy(const QString &distName, int distId) const
0047 
0048   Copies the current sheet to a sheet called \a distName with \a distId.
0049   Returns the new sheet.
0050  */
0051 
0052 /*!
0053  * \internal
0054  */
0055 AbstractSheet::AbstractSheet(const QString &name, int id, Workbook *workbook, AbstractSheetPrivate *d) :
0056     AbstractOOXmlFile(d)
0057 {
0058     d_func()->name = name;
0059     d_func()->id = id;
0060     d_func()->workbook = workbook;
0061 }
0062 
0063 
0064 /*!
0065  * Returns the name of the sheet.
0066  */
0067 QString AbstractSheet::sheetName() const
0068 {
0069     Q_D(const AbstractSheet);
0070     return d->name;
0071 }
0072 
0073 /*!
0074  * \internal
0075  */
0076 void AbstractSheet::setSheetName(const QString &sheetName)
0077 {
0078     Q_D(AbstractSheet);
0079     d->name = sheetName;
0080 }
0081 
0082 /*!
0083  * Returns the type of the sheet.
0084  */
0085 AbstractSheet::SheetType AbstractSheet::sheetType() const
0086 {
0087     Q_D(const AbstractSheet);
0088     return d->type;
0089 }
0090 
0091 /*!
0092  * \internal
0093  */
0094 void AbstractSheet::setSheetType(SheetType type)
0095 {
0096     Q_D(AbstractSheet);
0097     d->type = type;
0098 }
0099 
0100 /*!
0101  * Returns the state of the sheet.
0102  *
0103  * \sa isHidden(), isVisible(), setSheetState()
0104  */
0105 AbstractSheet::SheetState AbstractSheet::sheetState() const
0106 {
0107     Q_D(const AbstractSheet);
0108     return d->sheetState;
0109 }
0110 
0111 /*!
0112  * Set the state of the sheet to \a state.
0113  */
0114 void AbstractSheet::setSheetState(SheetState state)
0115 {
0116     Q_D(AbstractSheet);
0117     d->sheetState = state;
0118 }
0119 
0120 /*!
0121  * Returns true if the sheet is not visible, otherwise false will be returned.
0122  *
0123  * \sa sheetState(), setHidden()
0124  */
0125 bool AbstractSheet::isHidden() const
0126 {
0127     Q_D(const AbstractSheet);
0128     return d->sheetState != SS_Visible;
0129 }
0130 
0131 /*!
0132  * Returns true if the sheet is visible.
0133  */
0134 bool AbstractSheet::isVisible() const
0135 {
0136     return !isHidden();
0137 }
0138 
0139 /*!
0140  * Make the sheet hiden or visible based on \a hidden.
0141  */
0142 void AbstractSheet::setHidden(bool hidden)
0143 {
0144     Q_D(AbstractSheet);
0145     if (hidden == isHidden())
0146         return;
0147 
0148     d->sheetState = hidden ? SS_Hidden : SS_Visible;
0149 }
0150 
0151 /*!
0152  * Convenience function, equivalent to setHidden(! \a visible).
0153  */
0154 void AbstractSheet::setVisible(bool visible)
0155 {
0156     setHidden(!visible);
0157 }
0158 
0159 /*!
0160  * \internal
0161  */
0162 int AbstractSheet::sheetId() const
0163 {
0164     Q_D(const AbstractSheet);
0165     return d->id;
0166 }
0167 
0168 /*!
0169  * \internal
0170  */
0171 Drawing *AbstractSheet::drawing() const
0172 {
0173     Q_D(const AbstractSheet);
0174     return d->drawing.get();
0175 }
0176 
0177 /*!
0178  * Return the workbook
0179  */
0180 Workbook *AbstractSheet::workbook() const
0181 {
0182     Q_D(const AbstractSheet);
0183     return d->workbook;
0184 }
0185 
0186 QT_END_NAMESPACE_XLSX