Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef MWAW_TABLE
00041 # define MWAW_TABLE
00042
00043 #include <iostream>
00044 #include <vector>
00045
00046 #include "libmwaw_internal.hxx"
00047
00048 #include "MWAWCell.hxx"
00049
00050 class MWAWTable;
00051
00053 class MWAWTable
00054 {
00055 public:
00057 enum DataSet {
00058 CellPositionBit=1, BoxBit=2, SizeBit=4, TableDimBit=8, TablePosToCellBit=0x10
00059 };
00063 enum Alignment {
00064 Paragraph, Left, Center, Right
00065 };
00067 MWAWTable(uint32_t givenData=BoxBit) :
00068 m_givenData(givenData), m_setData(givenData), m_mergeBorders(true), m_cellsList(),
00069 m_numRows(0), m_numCols(0), m_rowsSize(), m_colsSize(), m_alignment(Paragraph), m_leftMargin(0), m_rightMargin(0),
00070 m_posToCellId(), m_hasExtraLines(false) {}
00071
00073 virtual ~MWAWTable();
00074
00076 void add(shared_ptr<MWAWCell> cell) {
00077 if (!cell) {
00078 MWAW_DEBUG_MSG(("MWAWTable::add: must be called with a cell\n"));
00079 return;
00080 }
00081 m_cellsList.push_back(cell);
00082 }
00084 bool mergeBorders() const {
00085 return m_mergeBorders;
00086 }
00088 bool setMergeBorders(bool val) {
00089 return m_mergeBorders=val;
00090 }
00093 void setAlignment(Alignment align, float leftMargin=0, float rightMargin=0) {
00094 m_alignment = align;
00095 m_leftMargin = leftMargin;
00096 m_rightMargin = rightMargin;
00097 }
00099 int numCells() const {
00100 return int(m_cellsList.size());
00101 }
00103 std::vector<float> const &getRowsSize() const {
00104 return m_rowsSize;
00105 }
00107 void setRowsSize(std::vector<float> const &rSize) {
00108 m_rowsSize=rSize;
00109 }
00111 std::vector<float> const &getColsSize() const {
00112 return m_colsSize;
00113 }
00115 void setColsSize(std::vector<float> const &cSize) {
00116 m_colsSize=cSize;
00117 }
00118
00120 shared_ptr<MWAWCell> get(int id);
00121
00123 bool updateTable();
00125 bool hasExtraLines() {
00126 if (!updateTable()) return false;
00127 return m_hasExtraLines;
00128 }
00129
00134 bool sendTable(MWAWContentListenerPtr listener, bool inFrame=true);
00135
00137 bool sendAsText(MWAWContentListenerPtr listener);
00138
00139
00140
00142 void addTablePropertiesTo(WPXPropertyList &propList, WPXPropertyListVector &columns) const;
00143
00144 protected:
00146 int getCellIdPos(int col, int row) const {
00147 if (col<0||col>=int(m_numCols))
00148 return -1;
00149 if (row<0||row>=int(m_numRows))
00150 return -1;
00151 return col*int(m_numRows)+row;
00152 }
00154 bool buildStructures();
00156 bool buildDims();
00158 bool buildPosToCellId();
00160 void sendExtraLines(MWAWContentListenerPtr listener) const;
00161
00162 protected:
00164 uint32_t m_givenData;
00166 uint32_t m_setData;
00168 bool m_mergeBorders;
00170 std::vector<shared_ptr<MWAWCell> > m_cellsList;
00172 size_t m_numRows;
00174 size_t m_numCols;
00176 std::vector<float> m_rowsSize;
00178 std::vector<float> m_colsSize;
00180 Alignment m_alignment;
00182 float m_leftMargin;
00184 float m_rightMargin;
00185
00187 std::vector<int> m_posToCellId;
00189 bool m_hasExtraLines;
00190 };
00191
00192 #endif