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 XLSXWORKSHEET_P_H andre@1: #define XLSXWORKSHEET_P_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 "xlsxworksheet.h" andre@1: #include "xlsxabstractsheet_p.h" andre@1: #include "xlsxcell.h" andre@1: #include "xlsxdatavalidation.h" andre@1: #include "xlsxconditionalformatting.h" andre@1: #include "xlsxcellformula.h" andre@1: andre@1: #include andre@1: #include andre@1: #include andre@1: andre@1: class QXmlStreamWriter; andre@1: class QXmlStreamReader; andre@1: andre@1: namespace QXlsx { andre@1: andre@1: const int XLSX_ROW_MAX = 1048576; andre@1: const int XLSX_COLUMN_MAX = 16384; andre@1: const int XLSX_STRING_MAX = 32767; andre@1: andre@1: class SharedStrings; andre@1: andre@1: struct XlsxHyperlinkData andre@1: { andre@1: enum LinkType andre@1: { andre@1: External, andre@1: Internal andre@1: }; andre@1: andre@1: XlsxHyperlinkData(LinkType linkType=External, const QString &target=QString(), const QString &location=QString() andre@1: , const QString &display=QString(), const QString &tip=QString()) andre@1: :linkType(linkType), target(target), location(location), display(display), tooltip(tip) andre@1: { andre@1: andre@1: } andre@1: andre@1: LinkType linkType; andre@1: QString target; //For External link andre@1: QString location; andre@1: QString display; andre@1: QString tooltip; andre@1: }; andre@1: andre@1: // ECMA-376 Part1 18.3.1.81 andre@1: struct XlsxSheetFormatProps andre@1: { andre@1: XlsxSheetFormatProps(int baseColWidth = 8, andre@1: bool customHeight = false, andre@1: double defaultColWidth = 0.0, andre@1: double defaultRowHeight = 15, andre@1: quint8 outlineLevelCol = 0, andre@1: quint8 outlineLevelRow = 0, andre@1: bool thickBottom = false, andre@1: bool thickTop = false, andre@1: bool zeroHeight = false) : andre@1: baseColWidth(baseColWidth), andre@1: customHeight(customHeight), andre@1: defaultColWidth(defaultColWidth), andre@1: defaultRowHeight(defaultRowHeight), andre@1: outlineLevelCol(outlineLevelCol), andre@1: outlineLevelRow(outlineLevelRow), andre@1: thickBottom(thickBottom), andre@1: thickTop(thickTop), andre@1: zeroHeight(zeroHeight) { andre@1: } andre@1: andre@1: int baseColWidth; andre@1: bool customHeight; andre@1: double defaultColWidth; andre@1: double defaultRowHeight; andre@1: quint8 outlineLevelCol; andre@1: quint8 outlineLevelRow; andre@1: bool thickBottom; andre@1: bool thickTop; andre@1: bool zeroHeight; andre@1: }; andre@1: andre@1: struct XlsxRowInfo andre@1: { andre@1: XlsxRowInfo(double height=0, const Format &format=Format(), bool hidden=false) : andre@1: customHeight(false), height(height), format(format), hidden(hidden), outlineLevel(0) andre@1: , collapsed(false) andre@1: { andre@1: andre@1: } andre@1: andre@1: bool customHeight; andre@1: double height; andre@1: Format format; andre@1: bool hidden; andre@1: int outlineLevel; andre@1: bool collapsed; andre@1: }; andre@1: andre@1: struct XlsxColumnInfo andre@1: { andre@1: XlsxColumnInfo(int firstColumn=0, int lastColumn=1, double width=0, const Format &format=Format(), bool hidden=false) : andre@1: firstColumn(firstColumn), lastColumn(lastColumn), customWidth(false), width(width), format(format), hidden(hidden) andre@1: , outlineLevel(0), collapsed(false) andre@1: { andre@1: andre@1: } andre@1: int firstColumn; andre@1: int lastColumn; andre@1: bool customWidth; andre@1: double width; andre@1: Format format; andre@1: bool hidden; andre@1: int outlineLevel; andre@1: bool collapsed; andre@1: }; andre@1: andre@1: class XLSX_AUTOTEST_EXPORT WorksheetPrivate : public AbstractSheetPrivate andre@1: { andre@1: Q_DECLARE_PUBLIC(Worksheet) andre@1: public: andre@1: WorksheetPrivate(Worksheet *p, Worksheet::CreateFlag flag); andre@1: ~WorksheetPrivate(); andre@1: int checkDimensions(int row, int col, bool ignore_row=false, bool ignore_col=false); andre@1: Format cellFormat(int row, int col) const; andre@1: QString generateDimensionString() const; andre@1: void calculateSpans() const; andre@1: void splitColsInfo(int colFirst, int colLast); andre@1: void validateDimension(); andre@1: andre@1: void saveXmlSheetData(QXmlStreamWriter &writer) const; andre@1: void saveXmlCellData(QXmlStreamWriter &writer, int row, int col, QSharedPointer cell) const; andre@1: void saveXmlMergeCells(QXmlStreamWriter &writer) const; andre@1: void saveXmlHyperlinks(QXmlStreamWriter &writer) const; andre@1: void saveXmlDrawings(QXmlStreamWriter &writer) const; andre@1: void saveXmlDataValidations(QXmlStreamWriter &writer) const; andre@1: int rowPixelsSize(int row) const; andre@1: int colPixelsSize(int col) const; andre@1: andre@1: void loadXmlSheetData(QXmlStreamReader &reader); andre@1: void loadXmlColumnsInfo(QXmlStreamReader &reader); andre@1: void loadXmlMergeCells(QXmlStreamReader &reader); andre@1: void loadXmlDataValidations(QXmlStreamReader &reader); andre@1: void loadXmlSheetFormatProps(QXmlStreamReader &reader); andre@1: void loadXmlSheetViews(QXmlStreamReader &reader); andre@1: void loadXmlHyperlinks(QXmlStreamReader &reader); andre@1: andre@1: QList > getRowInfoList(int rowFirst, int rowLast); andre@1: QList > getColumnInfoList(int colFirst, int colLast); andre@1: QList getColumnIndexes(int colFirst, int colLast); andre@1: bool isColumnRangeValid(int colFirst, int colLast); andre@1: andre@1: SharedStrings *sharedStrings() const; andre@1: andre@1: QMap > > cellTable; andre@1: QMap > comments; andre@1: QMap > > urlTable; andre@1: QList merges; andre@1: QMap > rowsInfo; andre@1: QMap > colsInfo; andre@1: QMap > colsInfoHelper; andre@1: andre@1: QList dataValidationsList; andre@1: QList conditionalFormattingList; andre@1: QMap sharedFormulaMap; andre@1: andre@1: CellRange dimension; andre@1: int previous_row; andre@1: andre@1: mutable QMap row_spans; andre@1: QMap row_sizes; andre@1: QMap col_sizes; andre@1: andre@1: int outline_row_level; andre@1: int outline_col_level; andre@1: andre@1: int default_row_height; andre@1: bool default_row_zeroed; andre@1: andre@1: XlsxSheetFormatProps sheetFormatProps; andre@1: andre@1: bool windowProtection; andre@1: bool showFormulas; andre@1: bool showGridLines; andre@1: bool showRowColHeaders; andre@1: bool showZeros; andre@1: bool rightToLeft; andre@1: bool tabSelected; andre@1: bool showRuler; andre@1: bool showOutlineSymbols; andre@1: bool showWhiteSpace; andre@1: andre@1: QRegularExpression urlPattern; andre@1: private: andre@1: static double calculateColWidth(int characters); andre@1: }; andre@1: andre@1: } andre@1: #endif // XLSXWORKSHEET_P_H