xlsxconditionalformatting.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /****************************************************************************
  2. ** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
  3. ** All right reserved.
  4. **
  5. ** Permission is hereby granted, free of charge, to any person obtaining
  6. ** a copy of this software and associated documentation files (the
  7. ** "Software"), to deal in the Software without restriction, including
  8. ** without limitation the rights to use, copy, modify, merge, publish,
  9. ** distribute, sublicense, and/or sell copies of the Software, and to
  10. ** permit persons to whom the Software is furnished to do so, subject to
  11. ** the following conditions:
  12. **
  13. ** The above copyright notice and this permission notice shall be
  14. ** included in all copies or substantial portions of the Software.
  15. **
  16. ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  17. ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18. ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19. ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  20. ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  21. ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  22. ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. **
  24. ****************************************************************************/
  25. #ifndef QXLSX_XLSXCONDITIONALFORMATTING_H
  26. #define QXLSX_XLSXCONDITIONALFORMATTING_H
  27. #include "xlsxglobal.h"
  28. #include "xlsxcellrange.h"
  29. #include "xlsxcellreference.h"
  30. #include <QSharedDataPointer>
  31. #include <QString>
  32. #include <QList>
  33. class QXmlStreamReader;
  34. class QXmlStreamWriter;
  35. class QColor;
  36. class ConditionalFormattingTest;
  37. QT_BEGIN_NAMESPACE_XLSX
  38. class Format;
  39. class Worksheet;
  40. class Styles;
  41. class ConditionalFormattingPrivate;
  42. class Q_XLSX_EXPORT ConditionalFormatting
  43. {
  44. public:
  45. enum HighlightRuleType {
  46. Highlight_LessThan,
  47. Highlight_LessThanOrEqual,
  48. Highlight_Equal,
  49. Highlight_NotEqual,
  50. Highlight_GreaterThanOrEqual,
  51. Highlight_GreaterThan,
  52. Highlight_Between,
  53. Highlight_NotBetween,
  54. Highlight_ContainsText,
  55. Highlight_NotContainsText,
  56. Highlight_BeginsWith,
  57. Highlight_EndsWith,
  58. Highlight_TimePeriod,
  59. Highlight_Duplicate,
  60. Highlight_Unique,
  61. Highlight_Blanks,
  62. Highlight_NoBlanks,
  63. Highlight_Errors,
  64. Highlight_NoErrors,
  65. Highlight_Top,
  66. Highlight_TopPercent,
  67. Highlight_Bottom,
  68. Highlight_BottomPercent,
  69. Highlight_AboveAverage,
  70. Highlight_AboveOrEqualAverage,
  71. Highlight_AboveStdDev1,
  72. Highlight_AboveStdDev2,
  73. Highlight_AboveStdDev3,
  74. Highlight_BelowAverage,
  75. Highlight_BelowOrEqualAverage,
  76. Highlight_BelowStdDev1,
  77. Highlight_BelowStdDev2,
  78. Highlight_BelowStdDev3,
  79. Highlight_Expression
  80. };
  81. enum ValueObjectType
  82. {
  83. VOT_Formula,
  84. VOT_Max,
  85. VOT_Min,
  86. VOT_Num,
  87. VOT_Percent,
  88. VOT_Percentile
  89. };
  90. ConditionalFormatting();
  91. ConditionalFormatting(const ConditionalFormatting &other);
  92. ~ConditionalFormatting();
  93. bool addHighlightCellsRule(HighlightRuleType type, const Format &format, bool stopIfTrue=false);
  94. bool addHighlightCellsRule(HighlightRuleType type, const QString &formula1, const Format &format, bool stopIfTrue=false);
  95. bool addHighlightCellsRule(HighlightRuleType type, const QString &formula1, const QString &formula2, const Format &format, bool stopIfTrue=false);
  96. bool addDataBarRule(const QColor &color, bool showData=true, bool stopIfTrue=false);
  97. bool addDataBarRule(const QColor &color, ValueObjectType type1, const QString &val1, ValueObjectType type2, const QString &val2, bool showData=true, bool stopIfTrue=false);
  98. bool add2ColorScaleRule(const QColor &minColor, const QColor &maxColor, bool stopIfTrue=false);
  99. bool add3ColorScaleRule(const QColor &minColor, const QColor &midColor, const QColor &maxColor, bool stopIfTrue=false);
  100. QList<CellRange> ranges() const;
  101. void addCell(const CellReference &cell);
  102. void addCell(int row, int col);
  103. void addRange(int firstRow, int firstCol, int lastRow, int lastCol);
  104. void addRange(const CellRange &range);
  105. //needed by QSharedDataPointer!!
  106. ConditionalFormatting &operator=(const ConditionalFormatting &other);
  107. private:
  108. friend class Worksheet;
  109. friend class ::ConditionalFormattingTest;
  110. bool saveToXml(QXmlStreamWriter &writer) const;
  111. bool loadFromXml(QXmlStreamReader &reader, Styles *styles=0);
  112. QSharedDataPointer<ConditionalFormattingPrivate> d;
  113. };
  114. QT_END_NAMESPACE_XLSX
  115. #endif // QXLSX_XLSXCONDITIONALFORMATTING_H