xlsxchart_p.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. // xlsxchart_p.h
  2. #ifndef QXLSX_CHART_P_H
  3. #define QXLSX_CHART_P_H
  4. #include <QtGlobal>
  5. #include <QObject>
  6. #include <QString>
  7. #include <QSharedPointer>
  8. #include <QVector>
  9. #include <QMap>
  10. #include <QList>
  11. #include <QXmlStreamReader>
  12. #include <QXmlStreamWriter>
  13. #include "xlsxabstractooxmlfile_p.h"
  14. #include "xlsxchart.h"
  15. QT_BEGIN_NAMESPACE_XLSX
  16. class XlsxSeries
  17. {
  18. public:
  19. //At present, we care about number cell ranges only!
  20. QString numberDataSource_numRef; // yval, val
  21. QString axDataSource_numRef; // xval, cat
  22. QString headerH_numRef;
  23. QString headerV_numRef;
  24. bool swapHeader = false;
  25. };
  26. class XlsxAxis
  27. {
  28. public:
  29. enum Type { T_None = (-1), T_Cat, T_Val, T_Date, T_Ser };
  30. enum AxisPos { None = (-1), Left, Right, Top, Bottom };
  31. public:
  32. XlsxAxis(){}
  33. XlsxAxis( Type t,
  34. XlsxAxis::AxisPos p,
  35. int id,
  36. int crossId,
  37. QString axisTitle = QString())
  38. {
  39. type = t;
  40. axisPos = p;
  41. axisId = id;
  42. crossAx = crossId;
  43. if ( !axisTitle.isEmpty() )
  44. {
  45. axisNames[ p ] = axisTitle;
  46. }
  47. }
  48. public:
  49. Type type;
  50. XlsxAxis::AxisPos axisPos;
  51. int axisId;
  52. int crossAx;
  53. QMap< XlsxAxis::AxisPos, QString > axisNames;
  54. };
  55. class ChartPrivate : public AbstractOOXmlFilePrivate
  56. {
  57. Q_DECLARE_PUBLIC(Chart)
  58. public:
  59. ChartPrivate(Chart *q, Chart::CreateFlag flag);
  60. ~ChartPrivate();
  61. public:
  62. bool loadXmlChart(QXmlStreamReader &reader);
  63. bool loadXmlPlotArea(QXmlStreamReader &reader);
  64. protected:
  65. bool loadXmlPlotAreaElement(QXmlStreamReader &reader);
  66. public:
  67. bool loadXmlXxxChart(QXmlStreamReader &reader);
  68. bool loadXmlSer(QXmlStreamReader &reader);
  69. QString loadXmlNumRef(QXmlStreamReader &reader);
  70. QString loadXmlStrRef(QXmlStreamReader &reader);
  71. bool loadXmlChartTitle(QXmlStreamReader &reader);
  72. bool loadXmlChartLegend(QXmlStreamReader &reader);
  73. protected:
  74. bool loadXmlChartTitleTx(QXmlStreamReader &reader);
  75. bool loadXmlChartTitleTxRich(QXmlStreamReader &reader);
  76. bool loadXmlChartTitleTxRichP(QXmlStreamReader &reader);
  77. bool loadXmlChartTitleTxRichP_R(QXmlStreamReader &reader);
  78. protected:
  79. bool loadXmlAxisCatAx(QXmlStreamReader &reader);
  80. bool loadXmlAxisDateAx(QXmlStreamReader &reader);
  81. bool loadXmlAxisSerAx(QXmlStreamReader &reader);
  82. bool loadXmlAxisValAx(QXmlStreamReader &reader);
  83. bool loadXmlAxisEG_AxShared(QXmlStreamReader &reader, XlsxAxis* axis);
  84. bool loadXmlAxisEG_AxShared_Scaling(QXmlStreamReader &reader, XlsxAxis* axis);
  85. bool loadXmlAxisEG_AxShared_Title(QXmlStreamReader &reader, XlsxAxis* axis);
  86. bool loadXmlAxisEG_AxShared_Title_Overlay(QXmlStreamReader &reader, XlsxAxis* axis);
  87. bool loadXmlAxisEG_AxShared_Title_Tx(QXmlStreamReader &reader, XlsxAxis* axis);
  88. bool loadXmlAxisEG_AxShared_Title_Tx_Rich(QXmlStreamReader &reader, XlsxAxis* axis);
  89. bool loadXmlAxisEG_AxShared_Title_Tx_Rich_P(QXmlStreamReader &reader, XlsxAxis* axis);
  90. bool loadXmlAxisEG_AxShared_Title_Tx_Rich_P_pPr(QXmlStreamReader &reader, XlsxAxis* axis);
  91. bool loadXmlAxisEG_AxShared_Title_Tx_Rich_P_R(QXmlStreamReader &reader, XlsxAxis* axis);
  92. QString readSubTree(QXmlStreamReader &reader);
  93. public:
  94. void saveXmlChart(QXmlStreamWriter &writer) const;
  95. void saveXmlChartTitle(QXmlStreamWriter &writer) const;
  96. void saveXmlPieChart(QXmlStreamWriter &writer) const;
  97. void saveXmlBarChart(QXmlStreamWriter &writer) const;
  98. void saveXmlLineChart(QXmlStreamWriter &writer) const;
  99. void saveXmlScatterChart(QXmlStreamWriter &writer) const;
  100. void saveXmlAreaChart(QXmlStreamWriter &writer) const;
  101. void saveXmlDoughnutChart(QXmlStreamWriter &writer) const;
  102. void saveXmlSer(QXmlStreamWriter &writer, XlsxSeries *ser, int id) const;
  103. void saveXmlAxis(QXmlStreamWriter &writer) const;
  104. void saveXmlChartLegend(QXmlStreamWriter &writer) const;
  105. protected:
  106. void saveXmlAxisCatAx(QXmlStreamWriter &writer, XlsxAxis* axis) const;
  107. void saveXmlAxisDateAx(QXmlStreamWriter &writer, XlsxAxis* axis) const;
  108. void saveXmlAxisSerAx(QXmlStreamWriter &writer, XlsxAxis* axis) const;
  109. void saveXmlAxisValAx(QXmlStreamWriter &writer, XlsxAxis* axis) const;
  110. void saveXmlAxisEG_AxShared(QXmlStreamWriter &writer, XlsxAxis* axis) const;
  111. void saveXmlAxisEG_AxShared_Title(QXmlStreamWriter &writer, XlsxAxis* axis) const;
  112. QString GetAxisPosString( XlsxAxis::AxisPos axisPos ) const;
  113. QString GetAxisName(XlsxAxis* ptrXlsxAxis) const;
  114. public:
  115. Chart::ChartType chartType;
  116. QList< QSharedPointer<XlsxSeries> > seriesList;
  117. QList< QSharedPointer<XlsxAxis> > axisList;
  118. QMap< XlsxAxis::AxisPos, QString > axisNames;
  119. QString chartTitle;
  120. AbstractSheet* sheet;
  121. Chart::ChartAxisPos legendPos;
  122. bool legendOverlay;
  123. bool majorGridlinesEnabled;
  124. bool minorGridlinesEnabled;
  125. QString layout; // only for storing a readed file
  126. };
  127. QT_END_NAMESPACE_XLSX
  128. #endif // QXLSX_CHART_P_H