andre@1: /**************************************************************************** andre@1: ** Copyright (c) 2013-2014 Debao Zhang andre@1: ** All right reserved. andre@1: ** andre@1: ** Permission is hereby granted, free of charge, to any person obtaining andre@1: ** a copy of this software and associated documentation files (the andre@1: ** "Software"), to deal in the Software without restriction, including andre@1: ** without limitation the rights to use, copy, modify, merge, publish, andre@1: ** distribute, sublicense, and/or sell copies of the Software, and to andre@1: ** permit persons to whom the Software is furnished to do so, subject to andre@1: ** the following conditions: andre@1: ** andre@1: ** The above copyright notice and this permission notice shall be andre@1: ** included in all copies or substantial portions of the Software. andre@1: ** andre@1: ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, andre@1: ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF andre@1: ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND andre@1: ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE andre@1: ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION andre@1: ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION andre@1: ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. andre@1: ** andre@1: ****************************************************************************/ andre@1: #include "xlsxabstractsheet.h" andre@1: #include "xlsxabstractsheet_p.h" andre@1: #include "xlsxworkbook.h" andre@1: andre@1: QT_BEGIN_NAMESPACE_XLSX andre@1: andre@1: AbstractSheetPrivate::AbstractSheetPrivate(AbstractSheet *p, AbstractSheet::CreateFlag flag) andre@1: : AbstractOOXmlFilePrivate(p, flag) andre@1: { andre@1: type = AbstractSheet::ST_WorkSheet; andre@1: sheetState = AbstractSheet::SS_Visible; andre@1: } andre@1: andre@1: AbstractSheetPrivate::~AbstractSheetPrivate() andre@1: { andre@1: } andre@1: andre@1: /*! andre@1: \class AbstractSheet andre@1: \inmodule QtXlsx andre@1: \brief Base class for worksheet, chartsheet, etc. andre@1: */ andre@1: andre@1: /*! andre@1: \enum AbstractSheet::SheetType andre@1: andre@1: \value ST_WorkSheet andre@1: \value ST_ChartSheet andre@1: \omitvalue ST_DialogSheet andre@1: \omitvalue ST_MacroSheet andre@1: */ andre@1: andre@1: /*! andre@1: \enum AbstractSheet::SheetState andre@1: andre@1: \value SS_Visible andre@1: \value SS_Hidden andre@1: \value SS_VeryHidden User cann't make a veryHidden sheet visible in normal way. andre@1: */ andre@1: andre@1: /*! andre@1: \fn AbstractSheet::copy(const QString &distName, int distId) const andre@1: andre@1: Copies the current sheet to a sheet called \a distName with \a distId. andre@1: Returns the new sheet. andre@1: */ andre@1: andre@1: /*! andre@1: * \internal andre@1: */ andre@1: AbstractSheet::AbstractSheet(const QString &name, int id, Workbook *workbook, AbstractSheetPrivate *d) : andre@1: AbstractOOXmlFile(d) andre@1: { andre@1: d_func()->name = name; andre@1: d_func()->id = id; andre@1: d_func()->workbook = workbook; andre@1: } andre@1: andre@1: andre@1: /*! andre@1: * Returns the name of the sheet. andre@1: */ andre@1: QString AbstractSheet::sheetName() const andre@1: { andre@1: Q_D(const AbstractSheet); andre@1: return d->name; andre@1: } andre@1: andre@1: /*! andre@1: * \internal andre@1: */ andre@1: void AbstractSheet::setSheetName(const QString &sheetName) andre@1: { andre@1: Q_D(AbstractSheet); andre@1: d->name = sheetName; andre@1: } andre@1: andre@1: /*! andre@1: * Returns the type of the sheet. andre@1: */ andre@1: AbstractSheet::SheetType AbstractSheet::sheetType() const andre@1: { andre@1: Q_D(const AbstractSheet); andre@1: return d->type; andre@1: } andre@1: andre@1: /*! andre@1: * \internal andre@1: */ andre@1: void AbstractSheet::setSheetType(SheetType type) andre@1: { andre@1: Q_D(AbstractSheet); andre@1: d->type = type; andre@1: } andre@1: andre@1: /*! andre@1: * Returns the state of the sheet. andre@1: * andre@1: * \sa isHidden(), isVisible(), setSheetState() andre@1: */ andre@1: AbstractSheet::SheetState AbstractSheet::sheetState() const andre@1: { andre@1: Q_D(const AbstractSheet); andre@1: return d->sheetState; andre@1: } andre@1: andre@1: /*! andre@1: * Set the state of the sheet to \a state. andre@1: */ andre@1: void AbstractSheet::setSheetState(SheetState state) andre@1: { andre@1: Q_D(AbstractSheet); andre@1: d->sheetState = state; andre@1: } andre@1: andre@1: /*! andre@1: * Returns true if the sheet is not visible, otherwise false will be returned. andre@1: * andre@1: * \sa sheetState(), setHidden() andre@1: */ andre@1: bool AbstractSheet::isHidden() const andre@1: { andre@1: Q_D(const AbstractSheet); andre@1: return d->sheetState != SS_Visible; andre@1: } andre@1: andre@1: /*! andre@1: * Returns true if the sheet is visible. andre@1: */ andre@1: bool AbstractSheet::isVisible() const andre@1: { andre@1: return !isHidden(); andre@1: } andre@1: andre@1: /*! andre@1: * Make the sheet hiden or visible based on \a hidden. andre@1: */ andre@1: void AbstractSheet::setHidden(bool hidden) andre@1: { andre@1: Q_D(AbstractSheet); andre@1: if (hidden == isHidden()) andre@1: return; andre@1: andre@1: d->sheetState = hidden ? SS_Hidden : SS_Visible; andre@1: } andre@1: andre@1: /*! andre@1: * Convenience function, equivalent to setHidden(! \a visible). andre@1: */ andre@1: void AbstractSheet::setVisible(bool visible) andre@1: { andre@1: setHidden(!visible); andre@1: } andre@1: andre@1: /*! andre@1: * \internal andre@1: */ andre@1: int AbstractSheet::sheetId() const andre@1: { andre@1: Q_D(const AbstractSheet); andre@1: return d->id; andre@1: } andre@1: andre@1: /*! andre@1: * \internal andre@1: */ andre@1: Drawing *AbstractSheet::drawing() const andre@1: { andre@1: Q_D(const AbstractSheet); andre@1: return d->drawing.data(); andre@1: } andre@1: andre@1: /*! andre@1: * Return the workbook andre@1: */ andre@1: Workbook *AbstractSheet::workbook() const andre@1: { andre@1: Q_D(const AbstractSheet); andre@1: return d->workbook; andre@1: } andre@1: andre@1: QT_END_NAMESPACE_XLSX