xlsxconditionalformatting.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // xlsxconditionalformatting.h
  2. #ifndef QXLSX_XLSXCONDITIONALFORMATTING_H
  3. #define QXLSX_XLSXCONDITIONALFORMATTING_H
  4. #include <QtGlobal>
  5. #include <QString>
  6. #include <QList>
  7. #include <QColor>
  8. #include <QXmlStreamReader>
  9. #include <QXmlStreamWriter>
  10. #include <QSharedDataPointer>
  11. #include "xlsxglobal.h"
  12. #include "xlsxcellrange.h"
  13. #include "xlsxcellreference.h"
  14. class ConditionalFormattingTest;
  15. QT_BEGIN_NAMESPACE_XLSX
  16. class Format;
  17. class Worksheet;
  18. class Styles;
  19. class ConditionalFormattingPrivate;
  20. class ConditionalFormatting
  21. {
  22. public:
  23. enum HighlightRuleType {
  24. Highlight_LessThan,
  25. Highlight_LessThanOrEqual,
  26. Highlight_Equal,
  27. Highlight_NotEqual,
  28. Highlight_GreaterThanOrEqual,
  29. Highlight_GreaterThan,
  30. Highlight_Between,
  31. Highlight_NotBetween,
  32. Highlight_ContainsText,
  33. Highlight_NotContainsText,
  34. Highlight_BeginsWith,
  35. Highlight_EndsWith,
  36. Highlight_TimePeriod,
  37. Highlight_Duplicate,
  38. Highlight_Unique,
  39. Highlight_Blanks,
  40. Highlight_NoBlanks,
  41. Highlight_Errors,
  42. Highlight_NoErrors,
  43. Highlight_Top,
  44. Highlight_TopPercent,
  45. Highlight_Bottom,
  46. Highlight_BottomPercent,
  47. Highlight_AboveAverage,
  48. Highlight_AboveOrEqualAverage,
  49. Highlight_AboveStdDev1,
  50. Highlight_AboveStdDev2,
  51. Highlight_AboveStdDev3,
  52. Highlight_BelowAverage,
  53. Highlight_BelowOrEqualAverage,
  54. Highlight_BelowStdDev1,
  55. Highlight_BelowStdDev2,
  56. Highlight_BelowStdDev3,
  57. Highlight_Expression
  58. };
  59. enum ValueObjectType
  60. {
  61. VOT_Formula,
  62. VOT_Max,
  63. VOT_Min,
  64. VOT_Num,
  65. VOT_Percent,
  66. VOT_Percentile
  67. };
  68. public:
  69. ConditionalFormatting();
  70. ConditionalFormatting(const ConditionalFormatting &other);
  71. ~ConditionalFormatting();
  72. public:
  73. bool addHighlightCellsRule(HighlightRuleType type, const Format &format, bool stopIfTrue=false);
  74. bool addHighlightCellsRule(HighlightRuleType type, const QString &formula1, const Format &format, bool stopIfTrue=false);
  75. bool addHighlightCellsRule(HighlightRuleType type, const QString &formula1, const QString &formula2, const Format &format, bool stopIfTrue=false);
  76. bool addDataBarRule(const QColor &color, bool showData=true, bool stopIfTrue=false);
  77. bool addDataBarRule(const QColor &color, ValueObjectType type1, const QString &val1, ValueObjectType type2, const QString &val2, bool showData=true, bool stopIfTrue=false);
  78. bool add2ColorScaleRule(const QColor &minColor, const QColor &maxColor, bool stopIfTrue=false);
  79. bool add3ColorScaleRule(const QColor &minColor, const QColor &midColor, const QColor &maxColor, bool stopIfTrue=false);
  80. QList<CellRange> ranges() const;
  81. void addCell(const CellReference &cell);
  82. void addCell(int row, int col);
  83. void addRange(int firstRow, int firstCol, int lastRow, int lastCol);
  84. void addRange(const CellRange &range);
  85. //needed by QSharedDataPointer!!
  86. ConditionalFormatting &operator=(const ConditionalFormatting &other);
  87. private:
  88. friend class Worksheet;
  89. friend class ::ConditionalFormattingTest;
  90. private:
  91. bool saveToXml(QXmlStreamWriter &writer) const;
  92. bool loadFromXml(QXmlStreamReader &reader, Styles* styles = NULL);
  93. QSharedDataPointer<ConditionalFormattingPrivate> d;
  94. };
  95. QT_END_NAMESPACE_XLSX
  96. #endif // QXLSX_XLSXCONDITIONALFORMATTING_H