xlsxdrawinganchor_p.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // xlsxdrawinganchor_p.h
  2. #ifndef QXLSX_XLSXDRAWINGANCHOR_P_H
  3. #define QXLSX_XLSXDRAWINGANCHOR_P_H
  4. #include <QPoint>
  5. #include <QSize>
  6. #include <QString>
  7. #include <QSharedPointer>
  8. #include <QXmlStreamReader>
  9. #include <QXmlStreamWriter>
  10. #include "xlsxglobal.h"
  11. QT_BEGIN_NAMESPACE_XLSX
  12. class Drawing;
  13. class MediaFile;
  14. class Chart;
  15. //Helper class
  16. struct XlsxMarker
  17. {
  18. XlsxMarker(){}
  19. XlsxMarker(int row, int column, int rowOffset, int colOffset)
  20. :cell(QPoint(row, column)), offset(rowOffset, colOffset)
  21. {
  22. }
  23. int row() const {return cell.x();}
  24. int col() const {return cell.y();}
  25. int rowOff() const {return offset.width();}
  26. int colOff() const {return offset.height();}
  27. QPoint cell;
  28. QSize offset;
  29. };
  30. class DrawingAnchor
  31. {
  32. public:
  33. enum ObjectType {
  34. GraphicFrame,
  35. Shape,
  36. GroupShape,
  37. ConnectionShape,
  38. Picture,
  39. Unknown
  40. };
  41. DrawingAnchor(Drawing *drawing, ObjectType objectType);
  42. virtual ~DrawingAnchor();
  43. void setObjectPicture(const QImage &img);
  44. bool getObjectPicture(QImage &img);
  45. void setObjectGraphicFrame(QSharedPointer<Chart> chart);
  46. virtual bool loadFromXml(QXmlStreamReader &reader) = 0;
  47. virtual void saveToXml(QXmlStreamWriter &writer) const = 0;
  48. virtual int row();
  49. virtual int col();
  50. protected:
  51. QPoint loadXmlPos(QXmlStreamReader &reader);
  52. QSize loadXmlExt(QXmlStreamReader &reader);
  53. XlsxMarker loadXmlMarker(QXmlStreamReader &reader, const QString &node);
  54. void loadXmlObject(QXmlStreamReader &reader);
  55. void loadXmlObjectShape(QXmlStreamReader &reader);
  56. void loadXmlObjectGroupShape(QXmlStreamReader &reader);
  57. void loadXmlObjectGraphicFrame(QXmlStreamReader &reader);
  58. void loadXmlObjectConnectionShape(QXmlStreamReader &reader);
  59. void loadXmlObjectPicture(QXmlStreamReader &reader);
  60. void saveXmlPos(QXmlStreamWriter &writer, const QPoint &pos) const;
  61. void saveXmlExt(QXmlStreamWriter &writer, const QSize &ext) const;
  62. void saveXmlMarker(QXmlStreamWriter &writer, const XlsxMarker &marker, const QString &node) const;
  63. void saveXmlObject(QXmlStreamWriter &writer) const;
  64. void saveXmlObjectShape(QXmlStreamWriter &writer) const;
  65. void saveXmlObjectGroupShape(QXmlStreamWriter &writer) const;
  66. void saveXmlObjectGraphicFrame(QXmlStreamWriter &writer) const;
  67. void saveXmlObjectConnectionShape(QXmlStreamWriter &writer) const;
  68. void saveXmlObjectPicture(QXmlStreamWriter &writer) const;
  69. Drawing *m_drawing;
  70. ObjectType m_objectType;
  71. QSharedPointer<MediaFile> m_pictureFile;
  72. QSharedPointer<Chart> m_chartFile;
  73. int m_id;
  74. public:
  75. int getm_id();
  76. protected:
  77. // liufeij {{
  78. void setObjectShape(const QImage &img); // liufeij
  79. QString editASName;
  80. // below only for twocellanchor shape
  81. QPoint posTA; // for shape liufeij 20181024
  82. QSize extTA; // for shape liufeij 20181024
  83. int rotWithShapeTA; //// for shape liufeij 20181024
  84. int dpiTA; //// for shape liufeij 20181024
  85. QString sp_textlink,sp_macro,sp_blip_cstate,sp_blip_rembed;
  86. // BELOW only for cxnSp shape
  87. QString cxnSp_filpV,cxnSp_macro;
  88. // belwo for cxnsp and sp
  89. QString xsp_cNvPR_name,xsp_cNvPR_id; //x measns shape and cxnSp together using
  90. QString xbwMode; // same as above
  91. QString xIn_algn,xIn_cmpd,xIn_cap,xIn_w; //cxnSp only need xIn_w
  92. QString xprstGeom_prst;
  93. QString x_headEnd_w,x_headEnd_len,x_headEnd_tyep;
  94. QString x_tailEnd_w,x_tailEnd_len,x_tailEnd_tyep;
  95. QString Style_inref_idx,style_fillref_idx,style_effectref_idx,style_forntref_idx;
  96. QString Style_inref_val,style_fillref_val,style_effectref_val,style_forntref_val;
  97. // liufeij }}
  98. };
  99. class DrawingAbsoluteAnchor : public DrawingAnchor
  100. {
  101. public:
  102. DrawingAbsoluteAnchor(Drawing *drawing, ObjectType objectType=Unknown);
  103. QPoint pos;
  104. QSize ext;
  105. bool loadFromXml(QXmlStreamReader &reader);
  106. void saveToXml(QXmlStreamWriter &writer) const;
  107. };
  108. class DrawingOneCellAnchor : public DrawingAnchor
  109. {
  110. public:
  111. DrawingOneCellAnchor(Drawing *drawing, ObjectType objectType=Unknown);
  112. XlsxMarker from;
  113. QSize ext;
  114. virtual int row();
  115. virtual int col();
  116. bool loadFromXml(QXmlStreamReader &reader);
  117. void saveToXml(QXmlStreamWriter &writer) const;
  118. };
  119. class DrawingTwoCellAnchor : public DrawingAnchor
  120. {
  121. public:
  122. DrawingTwoCellAnchor(Drawing *drawing, ObjectType objectType=Unknown);
  123. XlsxMarker from;
  124. XlsxMarker to;
  125. virtual int row();
  126. virtual int col();
  127. bool loadFromXml(QXmlStreamReader &reader);
  128. void saveToXml(QXmlStreamWriter &writer) const;
  129. };
  130. QT_END_NAMESPACE_XLSX
  131. #endif // QXLSX_XLSXDRAWINGANCHOR_P_H