| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#ifndef WPS_TABLE |
| 27 |
# define WPS_TABLE |
| 28 |
|
| 29 |
#include <iostream> |
| 30 |
#include <vector> |
| 31 |
|
| 32 |
#include "libwps_internal.h" |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
struct WPSColumnFormat |
| 40 |
{ |
| 41 |
public: |
| 42 |
|
| 43 |
explicit WPSColumnFormat(float width=-1) |
| 44 |
: m_width(width) |
| 45 |
, m_isPercentWidth(false) |
| 46 |
, m_useOptimalWidth(false) |
| 47 |
, m_isHeader(false) |
| 48 |
, m_numRepeat(1) |
| 49 |
{ |
| 50 |
} |
| 51 |
|
| 52 |
void addTo(librevenge::RVNGPropertyList &propList) const; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
int compare(WPSColumnFormat const &col) const |
| 57 |
{ |
| 58 |
if (m_width<col.m_width) return 1; |
| 59 |
if (m_width>col.m_width) return -1; |
| 60 |
if (m_isPercentWidth!=col.m_isPercentWidth) return m_isPercentWidth ? 1 : -1; |
| 61 |
if (m_useOptimalWidth!=col.m_useOptimalWidth) return m_useOptimalWidth ? 1 : -1; |
| 62 |
if (m_isHeader!=col.m_isHeader) return m_isHeader ? 1 : -1; |
| 63 |
return 0; |
| 64 |
} |
| 65 |
|
| 66 |
bool operator==(WPSColumnFormat const &col) const |
| 67 |
{ |
| 68 |
return compare(col)==0; |
| 69 |
} |
| 70 |
|
| 71 |
bool operator!=(WPSColumnFormat const &col) const |
| 72 |
{ |
| 73 |
return compare(col)!=0; |
| 74 |
} |
| 75 |
|
| 76 |
bool operator<(WPSColumnFormat const &col) const |
| 77 |
{ |
| 78 |
return compare(col)<0; |
| 79 |
} |
| 80 |
|
| 81 |
friend std::ostream &operator<<(std::ostream &o, WPSColumnFormat const &col); |
| 82 |
|
| 83 |
|
| 84 |
float m_width; |
| 85 |
|
| 86 |
bool m_isPercentWidth; |
| 87 |
|
| 88 |
bool m_useOptimalWidth; |
| 89 |
|
| 90 |
bool m_isHeader; |
| 91 |
|
| 92 |
int m_numRepeat; |
| 93 |
}; |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
struct WPSRowFormat |
| 101 |
{ |
| 102 |
public: |
| 103 |
|
| 104 |
explicit WPSRowFormat(float height=-1) |
| 105 |
: m_height(height) |
| 106 |
, m_isMinimalHeight(false) |
| 107 |
, m_useOptimalHeight(false) |
| 108 |
, m_isHeader(false) |
| 109 |
{ |
| 110 |
} |
| 111 |
|
| 112 |
void addTo(librevenge::RVNGPropertyList &propList) const; |
| 113 |
|
| 114 |
int compare(WPSRowFormat const &row) const |
| 115 |
{ |
| 116 |
if (m_height<row.m_height) return 1; |
| 117 |
if (m_height>row.m_height) return -1; |
| 118 |
if (m_isMinimalHeight!=row.m_isMinimalHeight) return m_isMinimalHeight ? 1 : -1; |
| 119 |
if (m_useOptimalHeight!=row.m_useOptimalHeight) return m_useOptimalHeight ? 1 : -1; |
| 120 |
if (m_isHeader!=row.m_isHeader) return m_isHeader ? 1 : -1; |
| 121 |
return 0; |
| 122 |
} |
| 123 |
|
| 124 |
bool operator==(WPSRowFormat const &row) const |
| 125 |
{ |
| 126 |
return compare(row)==0; |
| 127 |
} |
| 128 |
|
| 129 |
bool operator!=(WPSRowFormat const &row) const |
| 130 |
{ |
| 131 |
return compare(row)!=0; |
| 132 |
} |
| 133 |
|
| 134 |
bool operator<(WPSRowFormat const &row) const |
| 135 |
{ |
| 136 |
return compare(row)<0; |
| 137 |
} |
| 138 |
|
| 139 |
friend std::ostream &operator<<(std::ostream &o, WPSRowFormat const &row); |
| 140 |
|
| 141 |
|
| 142 |
float m_height; |
| 143 |
|
| 144 |
bool m_isMinimalHeight; |
| 145 |
|
| 146 |
bool m_useOptimalHeight; |
| 147 |
|
| 148 |
bool m_isHeader; |
| 149 |
}; |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
class WPSTable |
| 157 |
{ |
| 158 |
public: |
| 159 |
|
| 160 |
WPSTable() |
| 161 |
: m_cellsList() |
| 162 |
, m_rowsSize() |
| 163 |
, m_colsSize() {} |
| 164 |
WPSTable &operator=(WPSTable const &)=default; |
| 165 |
|
| 166 |
virtual ~WPSTable(); |
| 167 |
|
| 168 |
|
| 169 |
void add(WPSCellPtr &cell); |
| 170 |
|
| 171 |
|
| 172 |
int numCells() const |
| 173 |
{ |
| 174 |
return int(m_cellsList.size()); |
| 175 |
} |
| 176 |
|
| 177 |
WPSCellPtr getCell(int id); |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
bool sendTable(WPSContentListenerPtr listener); |
| 184 |
|
| 185 |
|
| 186 |
bool sendAsText(WPSContentListenerPtr listener); |
| 187 |
|
| 188 |
protected: |
| 189 |
|
| 190 |
bool buildStructures(); |
| 191 |
|
| 192 |
|
| 193 |
std::vector<WPSCellPtr> m_cellsList; |
| 194 |
|
| 195 |
std::vector<float> m_rowsSize, m_colsSize; |
| 196 |
}; |
| 197 |
|
| 198 |
#endif |
| 199 |
|