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: #ifndef QXLSX_FORMAT_H andre@1: #define QXLSX_FORMAT_H andre@1: andre@1: #include "xlsxglobal.h" andre@1: #include andre@1: #include andre@1: #include andre@1: #include andre@1: #include andre@1: #include andre@1: andre@1: class FormatTest; andre@1: andre@1: QT_BEGIN_NAMESPACE_XLSX andre@1: andre@1: class Styles; andre@1: class Worksheet; andre@1: class WorksheetPrivate; andre@1: class RichStringPrivate; andre@1: class SharedStrings; andre@1: andre@1: class FormatPrivate; andre@1: class Q_XLSX_EXPORT Format andre@1: { andre@1: public: andre@1: enum FontScript andre@1: { andre@1: FontScriptNormal, andre@1: FontScriptSuper, andre@1: FontScriptSub andre@1: }; andre@1: andre@1: enum FontUnderline andre@1: { andre@1: FontUnderlineNone, andre@1: FontUnderlineSingle, andre@1: FontUnderlineDouble, andre@1: FontUnderlineSingleAccounting, andre@1: FontUnderlineDoubleAccounting andre@1: }; andre@1: andre@1: enum HorizontalAlignment andre@1: { andre@1: AlignHGeneral, andre@1: AlignLeft, andre@1: AlignHCenter, andre@1: AlignRight, andre@1: AlignHFill, andre@1: AlignHJustify, andre@1: AlignHMerge, andre@1: AlignHDistributed andre@1: }; andre@1: andre@1: enum VerticalAlignment andre@1: { andre@1: AlignTop, andre@1: AlignVCenter, andre@1: AlignBottom, andre@1: AlignVJustify, andre@1: AlignVDistributed andre@1: }; andre@1: andre@1: enum BorderStyle andre@1: { andre@1: BorderNone, andre@1: BorderThin, andre@1: BorderMedium, andre@1: BorderDashed, andre@1: BorderDotted, andre@1: BorderThick, andre@1: BorderDouble, andre@1: BorderHair, andre@1: BorderMediumDashed, andre@1: BorderDashDot, andre@1: BorderMediumDashDot, andre@1: BorderDashDotDot, andre@1: BorderMediumDashDotDot, andre@1: BorderSlantDashDot andre@1: }; andre@1: andre@1: enum DiagonalBorderType andre@1: { andre@1: DiagonalBorderNone, andre@1: DiagonalBorderDown, andre@1: DiagonalBorderUp, andre@1: DiagnoalBorderBoth andre@1: }; andre@1: andre@1: enum FillPattern andre@1: { andre@1: PatternNone, andre@1: PatternSolid, andre@1: PatternMediumGray, andre@1: PatternDarkGray, andre@1: PatternLightGray, andre@1: PatternDarkHorizontal, andre@1: PatternDarkVertical, andre@1: PatternDarkDown, andre@1: PatternDarkUp, andre@1: PatternDarkGrid, andre@1: PatternDarkTrellis, andre@1: PatternLightHorizontal, andre@1: PatternLightVertical, andre@1: PatternLightDown, andre@1: PatternLightUp, andre@1: PatternLightTrellis, andre@1: PatternGray125, andre@1: PatternGray0625, andre@1: PatternLightGrid andre@1: }; andre@1: andre@1: Format(); andre@1: Format(const Format &other); andre@1: Format &operator=(const Format &rhs); andre@1: ~Format(); andre@1: andre@1: int numberFormatIndex() const; andre@1: void setNumberFormatIndex(int format); andre@1: QString numberFormat() const; andre@1: void setNumberFormat(const QString &format); andre@1: void setNumberFormat(int id, const QString &format); andre@1: bool isDateTimeFormat() const; andre@1: andre@1: int fontSize() const; andre@1: void setFontSize(int size); andre@1: bool fontItalic() const; andre@1: void setFontItalic(bool italic); andre@1: bool fontStrikeOut() const; andre@1: void setFontStrikeOut(bool); andre@1: QColor fontColor() const; andre@1: void setFontColor(const QColor &); andre@1: bool fontBold() const; andre@1: void setFontBold(bool bold); andre@1: FontScript fontScript() const; andre@1: void setFontScript(FontScript); andre@1: FontUnderline fontUnderline() const; andre@1: void setFontUnderline(FontUnderline); andre@1: bool fontOutline() const; andre@1: void setFontOutline(bool outline); andre@1: QString fontName() const; andre@1: void setFontName(const QString &); andre@1: QFont font() const; andre@1: void setFont(const QFont &font); andre@1: andre@1: HorizontalAlignment horizontalAlignment() const; andre@1: void setHorizontalAlignment(HorizontalAlignment align); andre@1: VerticalAlignment verticalAlignment() const; andre@1: void setVerticalAlignment(VerticalAlignment align); andre@1: bool textWrap() const; andre@1: void setTextWarp(bool textWrap); andre@1: int rotation() const; andre@1: void setRotation(int rotation); andre@1: int indent() const; andre@1: void setIndent(int indent); andre@1: bool shrinkToFit() const; andre@1: void setShrinkToFit(bool shink); andre@1: andre@1: void setBorderStyle(BorderStyle style); andre@1: void setBorderColor(const QColor &color); andre@1: BorderStyle leftBorderStyle() const; andre@1: void setLeftBorderStyle(BorderStyle style); andre@1: QColor leftBorderColor() const; andre@1: void setLeftBorderColor(const QColor &color); andre@1: BorderStyle rightBorderStyle() const; andre@1: void setRightBorderStyle(BorderStyle style); andre@1: QColor rightBorderColor() const; andre@1: void setRightBorderColor(const QColor &color); andre@1: BorderStyle topBorderStyle() const; andre@1: void setTopBorderStyle(BorderStyle style); andre@1: QColor topBorderColor() const; andre@1: void setTopBorderColor(const QColor &color); andre@1: BorderStyle bottomBorderStyle() const; andre@1: void setBottomBorderStyle(BorderStyle style); andre@1: QColor bottomBorderColor() const; andre@1: void setBottomBorderColor(const QColor &color); andre@1: BorderStyle diagonalBorderStyle() const; andre@1: void setDiagonalBorderStyle(BorderStyle style); andre@1: DiagonalBorderType diagonalBorderType() const; andre@1: void setDiagonalBorderType(DiagonalBorderType style); andre@1: QColor diagonalBorderColor() const; andre@1: void setDiagonalBorderColor(const QColor &color); andre@1: andre@1: FillPattern fillPattern() const; andre@1: void setFillPattern(FillPattern pattern); andre@1: QColor patternForegroundColor() const; andre@1: void setPatternForegroundColor(const QColor &color); andre@1: QColor patternBackgroundColor() const; andre@1: void setPatternBackgroundColor(const QColor &color); andre@1: andre@1: bool locked() const; andre@1: void setLocked(bool locked); andre@1: bool hidden() const; andre@1: void setHidden(bool hidden); andre@1: andre@1: void mergeFormat(const Format &modifier); andre@1: bool isValid() const; andre@1: bool isEmpty() const; andre@1: andre@1: bool operator == (const Format &format) const; andre@1: bool operator != (const Format &format) const; andre@1: andre@1: QVariant property(int propertyId, const QVariant &defaultValue=QVariant()) const; andre@1: void setProperty(int propertyId, const QVariant &value, const QVariant &clearValue=QVariant(), bool detach=true); andre@1: void clearProperty(int propertyId); andre@1: bool hasProperty(int propertyId) const; andre@1: andre@1: bool boolProperty(int propertyId, bool defaultValue=false) const; andre@1: int intProperty(int propertyId, int defaultValue=0) const; andre@1: double doubleProperty(int propertyId, double defaultValue = 0.0) const; andre@1: QString stringProperty(int propertyId, const QString &defaultValue = QString()) const; andre@1: QColor colorProperty(int propertyId, const QColor &defaultValue = QColor()) const; andre@1: andre@1: bool hasNumFmtData() const; andre@1: bool hasFontData() const; andre@1: bool hasFillData() const; andre@1: bool hasBorderData() const; andre@1: bool hasAlignmentData() const; andre@1: bool hasProtectionData() const; andre@1: andre@1: bool fontIndexValid() const; andre@1: int fontIndex() const; andre@1: QByteArray fontKey() const; andre@1: bool borderIndexValid() const; andre@1: QByteArray borderKey() const; andre@1: int borderIndex() const; andre@1: bool fillIndexValid() const; andre@1: QByteArray fillKey() const; andre@1: int fillIndex() const; andre@1: andre@1: QByteArray formatKey() const; andre@1: bool xfIndexValid() const; andre@1: int xfIndex() const; andre@1: bool dxfIndexValid() const; andre@1: int dxfIndex() const; andre@1: andre@1: void fixNumberFormat(int id, const QString &format); andre@1: void setFontIndex(int index); andre@1: void setBorderIndex(int index); andre@1: void setFillIndex(int index); andre@1: void setXfIndex(int index); andre@1: void setDxfIndex(int index); andre@1: private: andre@1: friend class Styles; andre@1: friend class ::FormatTest; andre@1: friend Q_XLSX_EXPORT QDebug operator<<(QDebug, const Format &f); andre@1: andre@1: int theme() const; andre@1: andre@1: QExplicitlySharedDataPointer d; andre@1: }; andre@1: andre@1: #ifndef QT_NO_DEBUG_STREAM andre@1: Q_XLSX_EXPORT QDebug operator<<(QDebug dbg, const Format &f); andre@1: #endif andre@1: andre@1: QT_END_NAMESPACE_XLSX andre@1: andre@1: #endif // QXLSX_FORMAT_H