STOFFTable.hxx Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

STOFFTable.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3 /* libstaroffice
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33
34 /*
35 * Structure to store and construct a table from an unstructured list
36 * of cell
37 *
38 */
39
40 #ifndef STOFF_TABLE
41 # define STOFF_TABLE
42
43 #include <iostream>
44 #include <vector>
45
46 #include "libstaroffice_internal.hxx"
47
48 #include "STOFFCell.hxx"
49
51 class STOFFTable
52 {
53 public:
55 enum DataSet {
56 CellPositionBit=1, BoxBit=2, SizeBit=4, TableDimBit=8, TablePosToCellBit=0x10
57 };
61 enum Alignment {
62 Paragraph, Left, Center, Right
63 };
65 explicit STOFFTable(uint32_t givenData=BoxBit) :
66 m_givenData(givenData), m_setData(givenData), m_mergeBorders(true), m_cellsList(),
67 m_numRows(0), m_numCols(0), m_rowsSize(), m_colsSize(), m_alignment(Paragraph), m_leftMargin(0), m_rightMargin(0),
68 m_posToCellId() {}
69
71 virtual ~STOFFTable();
72
74 void add(shared_ptr<STOFFCell> cell)
75 {
76 if (!cell) {
77 STOFF_DEBUG_MSG(("STOFFTable::add: must be called with a cell\n"));
78 return;
79 }
80 m_cellsList.push_back(cell);
81 }
83 bool mergeBorders() const
84 {
85 return m_mergeBorders;
86 }
88 bool setMergeBorders(bool val)
89 {
90 return m_mergeBorders=val;
91 }
94 void setAlignment(Alignment align, float leftMargin=0, float rightMargin=0)
95 {
96 m_alignment = align;
97 m_leftMargin = leftMargin;
98 m_rightMargin = rightMargin;
99 }
101 int numCells() const
102 {
103 return int(m_cellsList.size());
104 }
106 std::vector<float> const &getRowsSize() const
107 {
108 return m_rowsSize;
109 }
111 void setRowsSize(std::vector<float> const &rSize)
112 {
113 m_rowsSize=rSize;
114 }
116 std::vector<float> const &getColsSize() const
117 {
118 return m_colsSize;
119 }
121 void setColsSize(std::vector<float> const &cSize)
122 {
123 m_colsSize=cSize;
124 }
125
127 shared_ptr<STOFFCell> get(int id);
128
130 bool updateTable();
131
136 bool sendTable(STOFFListenerPtr listener);
137
139 bool sendAsText(STOFFListenerPtr listener);
140
141 // interface with the content listener
142
144 void addTablePropertiesTo(librevenge::RVNGPropertyList &propList) const;
145
146 protected:
148 int getCellIdPos(int col, int row) const
149 {
150 if (col<0||col>=int(m_numCols))
151 return -1;
152 if (row<0||row>=int(m_numRows))
153 return -1;
154 return col*int(m_numRows)+row;
155 }
157 bool buildStructures();
159 bool buildDims();
161 bool buildPosToCellId();
162
163 protected:
165 uint32_t m_givenData;
167 uint32_t m_setData;
169 bool m_mergeBorders;
171 std::vector<shared_ptr<STOFFCell> > m_cellsList;
173 size_t m_numRows;
175 size_t m_numCols;
177 std::vector<float> m_rowsSize;
179 std::vector<float> m_colsSize;
181 Alignment m_alignment;
183 float m_leftMargin;
185 float m_rightMargin;
186
188 std::vector<int> m_posToCellId;
189 };
190
191 #endif
192 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFTable::sendAsText
bool sendAsText(STOFFListenerPtr listener)
try to send the table as basic text
Definition: STOFFTable.cxx:433
STOFFTable::buildPosToCellId
bool buildPosToCellId()
a function which fills to posToCellId vector using the cell position
Definition: STOFFTable.cxx:247
STOFFTable::m_rowsSize
std::vector< float > m_rowsSize
the final row size (in point)
Definition: STOFFTable.hxx:177
STOFFTable::m_rightMargin
float m_rightMargin
the right margin in point
Definition: STOFFTable.hxx:185
STOFFTable::sendTable
bool sendTable(STOFFListenerPtr listener)
try to send the table
Definition: STOFFTable.cxx:404
STOFFTable::m_givenData
uint32_t m_givenData
a int to indicate what data are given in entries
Definition: STOFFTable.hxx:165
STOFFCell.hxx
Defines STOFFCell (cell content and format)
STOFFTable::STOFFTable
STOFFTable(uint32_t givenData=BoxBit)
the constructor
Definition: STOFFTable.hxx:65
STOFFTable::addTablePropertiesTo
void addTablePropertiesTo(librevenge::RVNGPropertyList &propList) const
adds the table properties to propList
Definition: STOFFTable.cxx:120
STOFFTable::numCells
int numCells() const
returns the number of cell
Definition: STOFFTable.hxx:101
STOFFTable::m_numRows
size_t m_numRows
the number of rows ( set by buildPosToCellId )
Definition: STOFFTable.hxx:173
STOFFTable::~STOFFTable
virtual ~STOFFTable()
the destructor
Definition: STOFFTable.cxx:107
STOFFTable::setAlignment
void setAlignment(Alignment align, float leftMargin=0, float rightMargin=0)
defines the current alignment
Definition: STOFFTable.hxx:94
STOFFTable::mergeBorders
bool mergeBorders() const
returns true if we need to merge borders
Definition: STOFFTable.hxx:83
STOFFTable::Alignment
Alignment
an enum do define the table alignment.
Definition: STOFFTable.hxx:61
STOFFTable::m_numCols
size_t m_numCols
the number of cols ( set by buildPosToCellId )
Definition: STOFFTable.hxx:175
STOFF_DEBUG_MSG
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:127
STOFFTable::m_colsSize
std::vector< float > m_colsSize
the final col size (in point)
Definition: STOFFTable.hxx:179
STOFFTable::Center
Definition: STOFFTable.hxx:62
STOFFTable::m_cellsList
std::vector< shared_ptr< STOFFCell > > m_cellsList
the list of cells
Definition: STOFFTable.hxx:171
STOFFTable
a class used to recreate the table structure using cell informations, ....
Definition: STOFFTable.hxx:51
STOFFTable::Right
Definition: STOFFTable.hxx:62
STOFFListenerPtr
shared_ptr< STOFFListener > STOFFListenerPtr
a smart pointer of STOFFListener
Definition: libstaroffice_internal.hxx:484
STOFFTable::BoxBit
Definition: STOFFTable.hxx:56
STOFFTable::CellPositionBit
Definition: STOFFTable.hxx:56
STOFFTable::TablePosToCellBit
Definition: STOFFTable.hxx:56
STOFFTable::Left
Definition: STOFFTable.hxx:62
STOFFTable::SizeBit
Definition: STOFFTable.hxx:56
STOFFTable::Paragraph
Definition: STOFFTable.hxx:62
STOFFTable::setMergeBorders
bool setMergeBorders(bool val)
sets the merge borders&#39; value
Definition: STOFFTable.hxx:88
STOFFTable::setColsSize
void setColsSize(std::vector< float > const &cSize)
define the columns size (in point)
Definition: STOFFTable.hxx:121
STOFFTable::m_posToCellId
std::vector< int > m_posToCellId
a vector used to store an id corresponding to each cell
Definition: STOFFTable.hxx:188
STOFFTable::m_alignment
Alignment m_alignment
the table alignment
Definition: STOFFTable.hxx:181
STOFFTable::getColsSize
std::vector< float > const & getColsSize() const
returns the columns size if defined (in point)
Definition: STOFFTable.hxx:116
STOFFTable::getRowsSize
std::vector< float > const & getRowsSize() const
returns the row size if defined (in point)
Definition: STOFFTable.hxx:106
STOFFTable::DataSet
DataSet
an enum used to indicate what the list of entries which are filled
Definition: STOFFTable.hxx:55
libstaroffice_internal.hxx
STOFFTable::add
void add(shared_ptr< STOFFCell > cell)
add a new cells
Definition: STOFFTable.hxx:74
STOFFTable::setRowsSize
void setRowsSize(std::vector< float > const &rSize)
define the row size (in point)
Definition: STOFFTable.hxx:111
STOFFTable::buildStructures
bool buildStructures()
create the correspondance list, ...
Definition: STOFFTable.cxx:157
STOFFTable::getCellIdPos
int getCellIdPos(int col, int row) const
convert a cell position in a posToCellId&#39;s position
Definition: STOFFTable.hxx:148
STOFFTable::updateTable
bool updateTable()
try to build the table structures
Definition: STOFFTable.cxx:391
STOFFTable::buildDims
bool buildDims()
compute the rows and the cells size
Definition: STOFFTable.cxx:301
STOFFTable::m_mergeBorders
bool m_mergeBorders
do we need to merge cell borders ( default yes)
Definition: STOFFTable.hxx:169
STOFFTable::m_setData
uint32_t m_setData
a int to indicate what data are been reconstruct
Definition: STOFFTable.hxx:167
STOFFTable::m_leftMargin
float m_leftMargin
the left margin in point
Definition: STOFFTable.hxx:183
STOFFTable::TableDimBit
Definition: STOFFTable.hxx:56