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 XLSXSTYLES_H andre@1: #define XLSXSTYLES_H andre@1: andre@1: // andre@1: // W A R N I N G andre@1: // ------------- andre@1: // andre@1: // This file is not part of the Qt Xlsx API. It exists for the convenience andre@1: // of the Qt Xlsx. This header file may change from andre@1: // version to version without notice, or even be removed. andre@1: // andre@1: // We mean it. andre@1: // andre@1: andre@1: #include "xlsxglobal.h" andre@1: #include "xlsxformat.h" andre@1: #include "xlsxabstractooxmlfile.h" andre@1: #include andre@1: #include andre@1: #include andre@1: #include andre@1: #include andre@1: #include andre@1: andre@1: class QXmlStreamWriter; andre@1: class QXmlStreamReader; andre@1: class QIODevice; andre@1: class StylesTest; andre@1: andre@1: namespace QXlsx { andre@1: andre@1: class Format; andre@1: class XlsxColor; andre@1: andre@1: struct XlsxFormatNumberData andre@1: { andre@1: XlsxFormatNumberData() : formatIndex(0) {} andre@1: andre@1: int formatIndex; andre@1: QString formatString; andre@1: }; andre@1: andre@1: class XLSX_AUTOTEST_EXPORT Styles : public AbstractOOXmlFile andre@1: { andre@1: public: andre@1: Styles(CreateFlag flag); andre@1: ~Styles(); andre@1: void addXfFormat(const Format &format, bool force=false); andre@1: Format xfFormat(int idx) const; andre@1: void addDxfFormat(const Format &format, bool force=false); andre@1: Format dxfFormat(int idx) const; andre@1: andre@1: void saveToXmlFile(QIODevice *device) const; andre@1: bool loadFromXmlFile(QIODevice *device); andre@1: andre@1: QColor getColorByIndex(int idx); andre@1: andre@1: private: andre@1: friend class Format; andre@1: friend class ::StylesTest; andre@1: andre@1: void fixNumFmt(const Format &format); andre@1: andre@1: void writeNumFmts(QXmlStreamWriter &writer) const; andre@1: void writeFonts(QXmlStreamWriter &writer) const; andre@1: void writeFont(QXmlStreamWriter &writer, const Format &font, bool isDxf = false) const; andre@1: void writeFills(QXmlStreamWriter &writer) const; andre@1: void writeFill(QXmlStreamWriter &writer, const Format &fill, bool isDxf = false) const; andre@1: void writeBorders(QXmlStreamWriter &writer) const; andre@1: void writeBorder(QXmlStreamWriter &writer, const Format &border, bool isDxf = false) const; andre@1: void writeSubBorder(QXmlStreamWriter &writer, const QString &type, int style, const XlsxColor &color) const; andre@1: void writeCellXfs(QXmlStreamWriter &writer) const; andre@1: void writeDxfs(QXmlStreamWriter &writer) const; andre@1: void writeDxf(QXmlStreamWriter &writer, const Format &format) const; andre@1: void writeColors(QXmlStreamWriter &writer) const; andre@1: andre@1: bool readNumFmts(QXmlStreamReader &reader); andre@1: bool readFonts(QXmlStreamReader &reader); andre@1: bool readFont(QXmlStreamReader &reader, Format &format); andre@1: bool readFills(QXmlStreamReader &reader); andre@1: bool readFill(QXmlStreamReader &reader, Format &format); andre@1: bool readBorders(QXmlStreamReader &reader); andre@1: bool readBorder(QXmlStreamReader &reader, Format &format); andre@1: bool readSubBorder(QXmlStreamReader &reader, const QString &name, Format::BorderStyle &style, XlsxColor &color); andre@1: bool readCellXfs(QXmlStreamReader &reader); andre@1: bool readDxfs(QXmlStreamReader &reader); andre@1: bool readDxf(QXmlStreamReader &reader); andre@1: bool readColors(QXmlStreamReader &reader); andre@1: bool readIndexedColors(QXmlStreamReader &reader); andre@1: andre@1: QHash m_builtinNumFmtsHash; andre@1: QMap > m_customNumFmtIdMap; andre@1: QHash > m_customNumFmtsHash; andre@1: int m_nextCustomNumFmtId; andre@1: QList m_fontsList; andre@1: QList m_fillsList; andre@1: QList m_bordersList; andre@1: QHash m_fontsHash; andre@1: QHash m_fillsHash; andre@1: QHash m_bordersHash; andre@1: andre@1: QVector m_indexedColors; andre@1: bool m_isIndexedColorsDefault; andre@1: andre@1: QList m_xf_formatsList; andre@1: QHash m_xf_formatsHash; andre@1: andre@1: QList m_dxf_formatsList; andre@1: QHash m_dxf_formatsHash; andre@1: andre@1: bool m_emptyFormatAdded; andre@1: }; andre@1: andre@1: } andre@1: #endif // XLSXSTYLES_H