xlsxchart_p.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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_CHART_P_H
  26. #define QXLSX_CHART_P_H
  27. //
  28. // W A R N I N G
  29. // -------------
  30. //
  31. // This file is not part of the Qt Xlsx API. It exists for the convenience
  32. // of the Qt Xlsx. This header file may change from
  33. // version to version without notice, or even be removed.
  34. //
  35. // We mean it.
  36. //
  37. #include "xlsxabstractooxmlfile_p.h"
  38. #include "xlsxchart.h"
  39. #include <QSharedPointer>
  40. class QXmlStreamReader;
  41. class QXmlStreamWriter;
  42. namespace QXlsx {
  43. class XlsxSeries
  44. {
  45. public:
  46. //At present, we care about number cell ranges only!
  47. QString numberDataSource_numRef; //yval, val
  48. QString axDataSource_numRef; //xval, cat
  49. };
  50. class XlsxAxis
  51. {
  52. public:
  53. enum Type
  54. {
  55. T_Cat,
  56. T_Val,
  57. T_Date,
  58. T_Ser
  59. };
  60. enum Pos
  61. {
  62. Left,
  63. Right,
  64. Top,
  65. Bottom
  66. };
  67. XlsxAxis(){}
  68. XlsxAxis(Type t, Pos p, int id, int crossId)
  69. :type(t), axisPos(p), axisId(id), crossAx(crossId)
  70. {
  71. }
  72. Type type;
  73. Pos axisPos; //l,r,b,t
  74. int axisId;
  75. int crossAx;
  76. };
  77. class ChartPrivate : public AbstractOOXmlFilePrivate
  78. {
  79. Q_DECLARE_PUBLIC(Chart)
  80. public:
  81. ChartPrivate(Chart *q, Chart::CreateFlag flag);
  82. ~ChartPrivate();
  83. bool loadXmlChart(QXmlStreamReader &reader);
  84. bool loadXmlPlotArea(QXmlStreamReader &reader);
  85. bool loadXmlXxxChart(QXmlStreamReader &reader);
  86. bool loadXmlSer(QXmlStreamReader &reader);
  87. QString loadXmlNumRef(QXmlStreamReader &reader);
  88. bool loadXmlAxis(QXmlStreamReader &reader);
  89. void saveXmlChart(QXmlStreamWriter &writer) const;
  90. void saveXmlPieChart(QXmlStreamWriter &writer) const;
  91. void saveXmlBarChart(QXmlStreamWriter &writer) const;
  92. void saveXmlLineChart(QXmlStreamWriter &writer) const;
  93. void saveXmlScatterChart(QXmlStreamWriter &writer) const;
  94. void saveXmlAreaChart(QXmlStreamWriter &writer) const;
  95. void saveXmlDoughnutChart(QXmlStreamWriter &writer) const;
  96. void saveXmlSer(QXmlStreamWriter &writer, XlsxSeries *ser, int id) const;
  97. void saveXmlAxes(QXmlStreamWriter &writer) const;
  98. Chart::ChartType chartType;
  99. QList<QSharedPointer<XlsxSeries> > seriesList;
  100. QList<QSharedPointer<XlsxAxis> > axisList;
  101. AbstractSheet *sheet;
  102. };
  103. } // namespace QXlsx
  104. #endif // QXLSX_CHART_P_H