File indexing completed on 2025-01-12 10:34:35
0001 /* 0002 * SPDX-FileCopyrightText: 2010 Carlos Licea <carlos@kdab.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #ifndef KOCELL_H 0008 #define KOCELL_H 0009 0010 #include "KoCellStyle.h" 0011 class KoCellChild; 0012 class KoCellValue; 0013 class KoTable; 0014 0015 class KoXmlWriter; 0016 class KoGenStyles; 0017 0018 #include "koodf2_export.h" 0019 0020 #include <QList> 0021 0022 /** 0023 * \class KoCell 0024 * @brief represents a cell inside a table. 0025 **/ 0026 class KOODF2_EXPORT KoCell 0027 { 0028 friend class KoTable; 0029 0030 KoCell(); 0031 KoCell& operator=(KoCell&); 0032 0033 public: 0034 ~KoCell(); 0035 0036 /** 0037 * Set the this Cell style to the given style. 0038 */ 0039 void setStyle(KoCellStyle::Ptr style); 0040 0041 /** 0042 * Returns the style assigned to this KoCell. 0043 * It's null if no style has been set. 0044 */ 0045 KoCellStyle::Ptr style() const; 0046 0047 /** 0048 * Sets the value as defined by element office:value of ODF. 0049 * \see ODF1.2 office:value §19.386. 0050 */ 0051 void setValue(KoCellValue* value); 0052 KoCellValue* value() const; 0053 0054 /** 0055 * A class KoCellChild represents all the items that can be 0056 * contained inside a KoCell. 0057 * \see ODF1.2 table:table-cell §9.1.4 0058 * 0059 * \note The cell takes ownership of the given KoCellChild. 0060 * \note The order in which the elements are written to ODF 0061 * is the same in which they were inserted. 0062 */ 0063 void appendChild(KoCellChild* child); 0064 0065 /** 0066 * Deletes the old list of children in favor of this one. 0067 */ 0068 void setChildren(QList<KoCellChild*> children); 0069 0070 /** 0071 * Returns all the children appended to the cell. 0072 * \note the cell is still the owner of those objects 0073 */ 0074 QList<KoCellChild*> children() const; 0075 0076 /** 0077 * \brief Sets the row span of the cell. 0078 * By default the span is 1. 0079 * Negative spans are not allowed, they are converted back to 1. 0080 * 0081 * \note the span is not checked to ensure not overlapping. 0082 * Also the covered cells can also be populated with data. 0083 */ 0084 void setRowSpan(int span); 0085 0086 /** 0087 * Gets the row span of the cell. 0088 * \see ODF1.2 table:number-rows-spanned §19.680 0089 */ 0090 int rowSpan() const; 0091 0092 /** 0093 * \brief Sets the column span of the cell. 0094 * By default the span is 1. 0095 * Negative spans are not allowed, they are converted back to 1. 0096 * 0097 * \note the span is not checked to ensure not overlapping. 0098 * Also the covered cells can also be populated with data. 0099 */ 0100 void setColumnSpan(int span); 0101 0102 /** 0103 * Gets the column span of the cell. 0104 * \see ODF1.2 table:number-columns-spanned §19.681 0105 */ 0106 int columnSpan() const; 0107 0108 /** 0109 * \brief Sets this cell to be <table:covered-table-cell> 0110 */ 0111 void setCovered(bool covered); 0112 0113 /** 0114 * Returns if the cell is covered or not. 0115 */ 0116 bool isCovered() const; 0117 0118 /** 0119 * Sets if the cell is protected. Protected cells cannot be edited by the user. 0120 */ 0121 void setProtected(bool protect); 0122 0123 /** 0124 * Returns if the cell is protected or not. 0125 * \see ODF1.2 table:protected §19.698.5 0126 */ 0127 bool isProtected() const; 0128 0129 private: 0130 void saveOdf(KoXmlWriter& writer, KoGenStyles& styles); 0131 0132 QList<KoCellChild*> m_children; 0133 KoCellValue* m_value; 0134 KoCellStyle::Ptr m_style; 0135 0136 int m_rowSpan; 0137 int m_columnSpan; 0138 bool m_protected; 0139 bool m_covered; 0140 }; 0141 0142 #endif