andre@1: /**************************************************************************** andre@1: ** Copyright (c) 2013-2014 Debao Zhang andre@1: ** All right reserved. andre@1: ** andre@1: ** Permission is hereby granted, free of charge, to any person obtaining andre@1: ** a copy of this software and associated documentation files (the andre@1: ** "Software"), to deal in the Software without restriction, including andre@1: ** without limitation the rights to use, copy, modify, merge, publish, andre@1: ** distribute, sublicense, and/or sell copies of the Software, and to andre@1: ** permit persons to whom the Software is furnished to do so, subject to andre@1: ** the following conditions: andre@1: ** andre@1: ** The above copyright notice and this permission notice shall be andre@1: ** included in all copies or substantial portions of the Software. andre@1: ** andre@1: ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, andre@1: ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF andre@1: ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND andre@1: ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE andre@1: ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION andre@1: ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION andre@1: ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. andre@1: ** andre@1: ****************************************************************************/ andre@1: andre@1: #ifndef QXLSX_XLSXDRAWINGANCHOR_P_H andre@1: #define QXLSX_XLSXDRAWINGANCHOR_P_H andre@1: andre@1: #include "xlsxglobal.h" andre@1: andre@1: #include andre@1: #include andre@1: #include andre@1: #include andre@1: andre@1: class QXmlStreamReader; andre@1: class QXmlStreamWriter; andre@1: andre@1: namespace QXlsx { andre@1: andre@1: class Drawing; andre@1: class MediaFile; andre@1: class Chart; andre@1: andre@1: //Helper class andre@1: struct XlsxMarker andre@1: { andre@1: XlsxMarker(){} andre@1: XlsxMarker(int row, int column, int rowOffset, int colOffset) andre@1: :cell(QPoint(row, column)), offset(rowOffset, colOffset) andre@1: { andre@1: andre@1: } andre@1: andre@1: int row() const {return cell.x();} andre@1: int col() const {return cell.y();} andre@1: int rowOff() const {return offset.width();} andre@1: int colOff() const {return offset.height();} andre@1: andre@1: QPoint cell; andre@1: QSize offset; andre@1: }; andre@1: andre@1: class DrawingAnchor andre@1: { andre@1: public: andre@1: enum ObjectType { andre@1: GraphicFrame, andre@1: Shape, andre@1: GroupShape, andre@1: ConnectionShape, andre@1: Picture, andre@1: Unknown andre@1: }; andre@1: andre@1: DrawingAnchor(Drawing *drawing, ObjectType objectType); andre@1: virtual ~DrawingAnchor(); andre@1: void setObjectPicture(const QImage &img); andre@1: void setObjectGraphicFrame(QSharedPointer chart); andre@1: andre@1: virtual bool loadFromXml(QXmlStreamReader &reader) = 0; andre@1: virtual void saveToXml(QXmlStreamWriter &writer) const = 0; andre@1: andre@1: protected: andre@1: QPoint loadXmlPos(QXmlStreamReader &reader); andre@1: QSize loadXmlExt(QXmlStreamReader &reader); andre@1: XlsxMarker loadXmlMarker(QXmlStreamReader &reader, const QString &node); andre@1: void loadXmlObject(QXmlStreamReader &reader); andre@1: void loadXmlObjectShape(QXmlStreamReader &reader); andre@1: void loadXmlObjectGroupShape(QXmlStreamReader &reader); andre@1: void loadXmlObjectGraphicFrame(QXmlStreamReader &reader); andre@1: void loadXmlObjectConnectionShape(QXmlStreamReader &reader); andre@1: void loadXmlObjectPicture(QXmlStreamReader &reader); andre@1: andre@1: void saveXmlPos(QXmlStreamWriter &writer, const QPoint &pos) const; andre@1: void saveXmlExt(QXmlStreamWriter &writer, const QSize &ext) const; andre@1: void saveXmlMarker(QXmlStreamWriter &writer, const XlsxMarker &marker, const QString &node) const; andre@1: void saveXmlObject(QXmlStreamWriter &writer) const; andre@1: void saveXmlObjectShape(QXmlStreamWriter &writer) const; andre@1: void saveXmlObjectGroupShape(QXmlStreamWriter &writer) const; andre@1: void saveXmlObjectGraphicFrame(QXmlStreamWriter &writer) const; andre@1: void saveXmlObjectConnectionShape(QXmlStreamWriter &writer) const; andre@1: void saveXmlObjectPicture(QXmlStreamWriter &writer) const; andre@1: andre@1: Drawing *m_drawing; andre@1: ObjectType m_objectType; andre@1: QSharedPointer m_pictureFile; andre@1: QSharedPointer m_chartFile; andre@1: andre@1: int m_id; andre@1: }; andre@1: andre@1: class DrawingAbsoluteAnchor : public DrawingAnchor andre@1: { andre@1: public: andre@1: DrawingAbsoluteAnchor(Drawing *drawing, ObjectType objectType=Unknown); andre@1: andre@1: QPoint pos; andre@1: QSize ext; andre@1: andre@1: bool loadFromXml(QXmlStreamReader &reader); andre@1: void saveToXml(QXmlStreamWriter &writer) const; andre@1: }; andre@1: andre@1: class DrawingOneCellAnchor : public DrawingAnchor andre@1: { andre@1: public: andre@1: DrawingOneCellAnchor(Drawing *drawing, ObjectType objectType=Unknown); andre@1: andre@1: XlsxMarker from; andre@1: QSize ext; andre@1: andre@1: bool loadFromXml(QXmlStreamReader &reader); andre@1: void saveToXml(QXmlStreamWriter &writer) const; andre@1: }; andre@1: andre@1: class DrawingTwoCellAnchor : public DrawingAnchor andre@1: { andre@1: public: andre@1: DrawingTwoCellAnchor(Drawing *drawing, ObjectType objectType=Unknown); andre@1: andre@1: XlsxMarker from; andre@1: XlsxMarker to; andre@1: andre@1: bool loadFromXml(QXmlStreamReader &reader); andre@1: void saveToXml(QXmlStreamWriter &writer) const; andre@1: }; andre@1: andre@1: } // namespace QXlsx andre@1: andre@1: #endif // QXLSX_XLSXDRAWINGANCHOR_P_H