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 STOFF_TABLE
00041 # define STOFF_TABLE
00042
00043 #include <iostream>
00044 #include <vector>
00045
00046 #include "libstaroffice_internal.hxx"
00047
00048 #include "STOFFCell.hxx"
00049
00051 class STOFFTable
00052 {
00053 public:
00055 enum DataSet {
00056 CellPositionBit=1, BoxBit=2, SizeBit=4, TableDimBit=8, TablePosToCellBit=0x10
00057 };
00061 enum Alignment {
00062 Paragraph, Left, Center, Right
00063 };
00065 explicit STOFFTable(uint32_t givenData=BoxBit) :
00066 m_givenData(givenData), m_setData(givenData), m_mergeBorders(true), m_cellsList(),
00067 m_numRows(0), m_numCols(0), m_rowsSize(), m_colsSize(), m_alignment(Paragraph), m_leftMargin(0), m_rightMargin(0),
00068 m_posToCellId() {}
00069
00071 virtual ~STOFFTable();
00072
00074 void add(shared_ptr<STOFFCell> cell)
00075 {
00076 if (!cell) {
00077 STOFF_DEBUG_MSG(("STOFFTable::add: must be called with a cell\n"));
00078 return;
00079 }
00080 m_cellsList.push_back(cell);
00081 }
00083 bool mergeBorders() const
00084 {
00085 return m_mergeBorders;
00086 }
00088 bool setMergeBorders(bool val)
00089 {
00090 return m_mergeBorders=val;
00091 }
00094 void setAlignment(Alignment align, float leftMargin=0, float rightMargin=0)
00095 {
00096 m_alignment = align;
00097 m_leftMargin = leftMargin;
00098 m_rightMargin = rightMargin;
00099 }
00101 int numCells() const
00102 {
00103 return int(m_cellsList.size());
00104 }
00106 std::vector<float> const &getRowsSize() const
00107 {
00108 return m_rowsSize;
00109 }
00111 void setRowsSize(std::vector<float> const &rSize)
00112 {
00113 m_rowsSize=rSize;
00114 }
00116 std::vector<float> const &getColsSize() const
00117 {
00118 return m_colsSize;
00119 }
00121 void setColsSize(std::vector<float> const &cSize)
00122 {
00123 m_colsSize=cSize;
00124 }
00125
00127 shared_ptr<STOFFCell> get(int id);
00128
00130 bool updateTable();
00131
00136 bool sendTable(STOFFListenerPtr listener);
00137
00139 bool sendAsText(STOFFListenerPtr listener);
00140
00141
00142
00144 void addTablePropertiesTo(librevenge::RVNGPropertyList &propList) const;
00145
00146 protected:
00148 int getCellIdPos(int col, int row) const
00149 {
00150 if (col<0||col>=int(m_numCols))
00151 return -1;
00152 if (row<0||row>=int(m_numRows))
00153 return -1;
00154 return col*int(m_numRows)+row;
00155 }
00157 bool buildStructures();
00159 bool buildDims();
00161 bool buildPosToCellId();
00162
00163 protected:
00165 uint32_t m_givenData;
00167 uint32_t m_setData;
00169 bool m_mergeBorders;
00171 std::vector<shared_ptr<STOFFCell> > m_cellsList;
00173 size_t m_numRows;
00175 size_t m_numCols;
00177 std::vector<float> m_rowsSize;
00179 std::vector<float> m_colsSize;
00181 Alignment m_alignment;
00183 float m_leftMargin;
00185 float m_rightMargin;
00186
00188 std::vector<int> m_posToCellId;
00189 };
00190
00191 #endif
00192