File indexing completed on 2024-06-23 03:45:56

0001 // xlsxcellrange.h
0002 
0003 #ifndef QXLSX_XLSXCELLRANGE_H
0004 #define QXLSX_XLSXCELLRANGE_H
0005 
0006 #include <QtGlobal>
0007 #include <QObject>
0008 
0009 #include "xlsxglobal.h"
0010 #include "xlsxcellreference.h"
0011 
0012 QT_BEGIN_NAMESPACE_XLSX
0013 
0014 // dev57
0015 class QXLSX_EXPORT CellRange
0016 {
0017 public:
0018     CellRange();
0019     CellRange(int firstRow, int firstColumn, int lastRow, int lastColumn);
0020     CellRange(const CellReference &topLeft, const CellReference &bottomRight);
0021     CellRange(const QString &range);
0022     CellRange(const char *range);
0023     CellRange(const CellRange &other);
0024     ~CellRange();
0025 
0026     QString toString(bool row_abs=false, bool col_abs=false) const;
0027     bool isValid() const;
0028     inline void setFirstRow(int row) { top = row; }
0029     inline void setLastRow(int row) { bottom = row; }
0030     inline void setFirstColumn(int col) { left = col; }
0031     inline void setLastColumn(int col) { right = col; }
0032     inline int firstRow() const { return top; }
0033     inline int lastRow() const { return bottom; }
0034     inline int firstColumn() const { return left; }
0035     inline int lastColumn() const { return right; }
0036     inline int rowCount() const { return bottom - top + 1; }
0037     inline int columnCount() const { return right - left + 1; }
0038     inline CellReference topLeft() const { return CellReference(top, left); }
0039     inline CellReference topRight() const { return CellReference(top, right); }
0040     inline CellReference bottomLeft() const { return CellReference(bottom, left); }
0041     inline CellReference bottomRight() const { return CellReference(bottom, right); }
0042 
0043     inline void operator =(const CellRange &other)
0044     {
0045         top = other.top;
0046         bottom = other.bottom;
0047         left = other.left;
0048         right = other.right;
0049     }
0050     inline bool operator ==(const CellRange &other) const
0051     {
0052         return top==other.top && bottom==other.bottom
0053                 && left == other.left && right == other.right;
0054     }
0055     inline bool operator !=(const CellRange &other) const
0056     {
0057         return top!=other.top || bottom!=other.bottom
0058                 || left != other.left || right != other.right;
0059     }
0060 private:
0061     void init(const QString &range);
0062 
0063     int top;
0064     int left;
0065     int bottom;
0066     int right;
0067 };
0068 
0069 QT_END_NAMESPACE_XLSX
0070 
0071 Q_DECLARE_TYPEINFO(QXlsx::CellRange, Q_MOVABLE_TYPE);
0072 
0073 #endif // QXLSX_XLSXCELLRANGE_H