- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

IWORKTable.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is part of the libetonyek project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10 #ifndef IWORKTABLE_H_INCLUDED
11 #define IWORKTABLE_H_INCLUDED
12
13 #include <boost/optional.hpp>
14
15 #include <deque>
16
17 #include "IWORKStyle_fwd.h"
18 #include "IWORKTypes.h"
19 #include "IWORKOutputElements.h"
20
21 namespace libetonyek
22 {
23
24 class IWORKTable
25 {
26 struct Cell
27 {
28 IWORKOutputElements m_content;
29 unsigned m_columnSpan;
30 unsigned m_rowSpan;
31 bool m_covered;
32 boost::optional<IWORKFormula> m_formula;
33 IWORKStylePtr_t m_style;
34 IWORKCellType m_type;
35 boost::optional<std::string> m_value;
36
37 Cell();
38 };
39
40 typedef std::deque<Cell> Row_t;
41 typedef std::deque<Row_t> Table_t;
42
43 public:
44 enum CellType
45 {
46 CELL_TYPE_BODY,
47 CELL_TYPE_ALTERNATE_BODY,
48 CELL_TYPE_COLUMN_HEADER,
49 CELL_TYPE_ROW_HEADER,
50 CELL_TYPE_ROW_FOOTER
51 };
52
53 public:
54 explicit IWORKTable(const IWORKTableNameMapPtr_t &tableNameMap);
55
56 void setSize(unsigned columns, unsigned rows);
57 void setHeaders(unsigned headerColumns, unsigned headerRows, unsigned footerRows);
58 void setBandedRows(bool banded = true);
59 void setRepeated(bool columns, bool rows);
60
61 void setStyle(const IWORKStylePtr_t &style);
62 void setSizes(const IWORKColumnSizes_t &columnSizes, const IWORKRowSizes_t &rowSizes);
63 void setBorders(const IWORKGridLineList_t &verticalLines, const IWORKGridLineList_t &horizontalLines);
64 void insertCell(unsigned column, unsigned row, const boost::optional<std::string> &value = boost::none, const IWORKOutputElements &content = IWORKOutputElements(), unsigned columnSpan = 1, unsigned rowSpan = 1, const boost::optional<IWORKFormula> &formula = boost::none, const IWORKStylePtr_t &style = IWORKStylePtr_t(), IWORKCellType type = IWORK_CELL_TYPE_TEXT);
65 void insertCoveredCell(unsigned column, unsigned row);
66
67 void draw(const librevenge::RVNGPropertyList &tableProps, IWORKOutputElements &elements);
68
69 void setDefaultCellStyle(CellType type, const IWORKStylePtr_t &style);
70 void setDefaultLayoutStyle(CellType type, const IWORKStylePtr_t &style);
71 void setDefaultParagraphStyle(CellType type, const IWORKStylePtr_t &style);
72
73 IWORKStylePtr_t getDefaultCellStyle(unsigned column, unsigned row) const;
74 IWORKStylePtr_t getDefaultLayoutStyle(unsigned column, unsigned row) const;
75 IWORKStylePtr_t getDefaultParagraphStyle(unsigned column, unsigned row) const;
76
77 private:
78 IWORKStylePtr_t getDefaultStyle(unsigned column, unsigned row, const IWORKStylePtr_t *group) const;
79
80 private:
81 const IWORKTableNameMapPtr_t m_tableNameMap;
82
83 Table_t m_table;
84 IWORKStylePtr_t m_style;
85 IWORKColumnSizes_t m_columnSizes;
86 IWORKRowSizes_t m_rowSizes;
87 IWORKGridLineList_t m_verticalLines;
88 IWORKGridLineList_t m_horizontalLines;
89
90 unsigned m_rows;
91 unsigned m_columns;
92 unsigned m_headerRows;
93 unsigned m_footerRows;
94 unsigned m_headerColumns;
95 bool m_bandedRows;
96 bool m_headerRowsRepeated;
97 bool m_headerColumnsRepeated;
98
99 IWORKStylePtr_t m_defaultCellStyles[5];
100 IWORKStylePtr_t m_defaultLayoutStyles[5];
101 IWORKStylePtr_t m_defaultParaStyles[5];
102 };
103
104 }
105
106 #endif // IWORKTABLE_H_INCLUDED
107
108 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libetonyek::IWORKTable::CellType
CellType
Definition: IWORKTable.h:44
libetonyek::IWORKTable::setHeaders
void setHeaders(unsigned headerColumns, unsigned headerRows, unsigned footerRows)
Definition: IWORKTable.cpp:229
IWORKStyle_fwd.h
libetonyek
Definition: IWORKBezierElement.cpp:18
libetonyek::IWORKOutputElements
Definition: IWORKOutputElements.h:30
libetonyek::IWORKTable::Cell::m_formula
boost::optional< IWORKFormula > m_formula
Definition: IWORKTable.h:32
libetonyek::IWORKTable::m_rowSizes
IWORKRowSizes_t m_rowSizes
Definition: IWORKTable.h:86
libetonyek::IWORKTable::m_headerRowsRepeated
bool m_headerRowsRepeated
Definition: IWORKTable.h:96
IWORKOutputElements.h
libetonyek::IWORKTable::m_headerColumnsRepeated
bool m_headerColumnsRepeated
Definition: IWORKTable.h:97
libetonyek::IWORKTable::getDefaultLayoutStyle
IWORKStylePtr_t getDefaultLayoutStyle(unsigned column, unsigned row) const
Definition: IWORKTable.cpp:393
libetonyek::IWORKStylePtr_t
boost::shared_ptr< IWORKStyle > IWORKStylePtr_t
Definition: IWORKStyle_fwd.h:21
libetonyek::IWORKTable::setSizes
void setSizes(const IWORKColumnSizes_t &columnSizes, const IWORKRowSizes_t &rowSizes)
Definition: IWORKTable.cpp:252
libetonyek::IWORKToken::content
Definition: IWORKToken.h:85
libetonyek::IWORKTable::Cell
Definition: IWORKTable.h:26
libetonyek::IWORKTable::setDefaultParagraphStyle
void setDefaultParagraphStyle(CellType type, const IWORKStylePtr_t &style)
Definition: IWORKTable.cpp:382
libetonyek::IWORKTable::setSize
void setSize(unsigned columns, unsigned rows)
Definition: IWORKTable.cpp:223
libetonyek::IWORKTable::CELL_TYPE_ROW_HEADER
Definition: IWORKTable.h:49
libetonyek::IWORKTable::Row_t
std::deque< Cell > Row_t
Definition: IWORKTable.h:40
libetonyek::IWORKTable::Table_t
std::deque< Row_t > Table_t
Definition: IWORKTable.h:41
libetonyek::IWORKTable::Cell::m_content
IWORKOutputElements m_content
Definition: IWORKTable.h:28
libetonyek::IWORKTable::setRepeated
void setRepeated(bool columns, bool rows)
Definition: IWORKTable.cpp:241
libetonyek::IWORKTable::m_headerColumns
unsigned m_headerColumns
Definition: IWORKTable.h:94
libetonyek::IWORKToken::group
Definition: IWORKToken.h:144
libetonyek::IWORKToken::style
Definition: IWORKToken.h:241
libetonyek::IWORKGridLineList_t
std::vector< IWORKGridLine_t > IWORKGridLineList_t
Definition: IWORKTypes.h:101
libetonyek::IWORKTable::getDefaultCellStyle
IWORKStylePtr_t getDefaultCellStyle(unsigned column, unsigned row) const
Definition: IWORKTable.cpp:388
libetonyek::IWORKTable::m_columnSizes
IWORKColumnSizes_t m_columnSizes
Definition: IWORKTable.h:85
libetonyek::IWORKToken::rows
Definition: IWORKToken.h:218
libetonyek::IWORKTable::setDefaultLayoutStyle
void setDefaultLayoutStyle(CellType type, const IWORKStylePtr_t &style)
Definition: IWORKTable.cpp:376
libetonyek::IWORK_CELL_TYPE_TEXT
Definition: IWORKEnum.h:73
libetonyek::IWORKTable::IWORKTable
IWORKTable(const IWORKTableNameMapPtr_t &tableNameMap)
Definition: IWORKTable.cpp:205
libetonyek::IWORKTable::m_horizontalLines
IWORKGridLineList_t m_horizontalLines
Definition: IWORKTable.h:88
libetonyek::IWORKTable::m_verticalLines
IWORKGridLineList_t m_verticalLines
Definition: IWORKTable.h:87
libetonyek::IWORKTable::m_table
Table_t m_table
Definition: IWORKTable.h:83
libetonyek::IWORKTable::draw
void draw(const librevenge::RVNGPropertyList &tableProps, IWORKOutputElements &elements)
Definition: IWORKTable.cpp:293
libetonyek::IWORKTable::Cell::m_rowSpan
unsigned m_rowSpan
Definition: IWORKTable.h:30
libetonyek::IWORKTable::m_columns
unsigned m_columns
Definition: IWORKTable.h:91
libetonyek::IWORKTable::Cell::m_columnSpan
unsigned m_columnSpan
Definition: IWORKTable.h:29
libetonyek::IWORKColumnSizes_t
std::deque< double > IWORKColumnSizes_t
Definition: IWORKTypes_fwd.h:23
libetonyek::IWORKRowSizes_t
std::deque< double > IWORKRowSizes_t
Definition: IWORKTypes_fwd.h:25
libetonyek::IWORKTable::CELL_TYPE_COLUMN_HEADER
Definition: IWORKTable.h:48
libetonyek::IWORKToken::columns
Definition: IWORKToken.h:79
libetonyek::IWORKTable::CELL_TYPE_ALTERNATE_BODY
Definition: IWORKTable.h:47
libetonyek::IWORKTableNameMapPtr_t
boost::shared_ptr< IWORKTableNameMap_t > IWORKTableNameMapPtr_t
Definition: IWORKTypes_fwd.h:33
libetonyek::IWORKTable::setDefaultCellStyle
void setDefaultCellStyle(CellType type, const IWORKStylePtr_t &style)
Definition: IWORKTable.cpp:370
libetonyek::IWORKTable::m_rows
unsigned m_rows
Definition: IWORKTable.h:90
libetonyek::IWORKTable::getDefaultStyle
IWORKStylePtr_t getDefaultStyle(unsigned column, unsigned row, const IWORKStylePtr_t *group) const
Definition: IWORKTable.cpp:403
libetonyek::IWORKTable::m_tableNameMap
const IWORKTableNameMapPtr_t m_tableNameMap
Definition: IWORKTable.h:81
libetonyek::IWORKTable::m_style
IWORKStylePtr_t m_style
Definition: IWORKTable.h:84
libetonyek::IWORKTable::m_defaultCellStyles
IWORKStylePtr_t m_defaultCellStyles[5]
Definition: IWORKTable.h:99
libetonyek::IWORKToken::column
Definition: IWORKToken.h:77
IWORKTypes.h
libetonyek::IWORKTable::insertCell
void insertCell(unsigned column, unsigned row, const boost::optional< std::string > &value=boost::none, const IWORKOutputElements &content=IWORKOutputElements(), unsigned columnSpan=1, unsigned rowSpan=1, const boost::optional< IWORKFormula > &formula=boost::none, const IWORKStylePtr_t &style=IWORKStylePtr_t(), IWORKCellType type=IWORK_CELL_TYPE_TEXT)
Definition: IWORKTable.cpp:267
libetonyek::IWORKTable
Definition: IWORKTable.h:24
libetonyek::IWORKTable::m_defaultLayoutStyles
IWORKStylePtr_t m_defaultLayoutStyles[5]
Definition: IWORKTable.h:100
libetonyek::IWORKTable::CELL_TYPE_BODY
Definition: IWORKTable.h:46
libetonyek::IWORKTable::Cell::m_style
IWORKStylePtr_t m_style
Definition: IWORKTable.h:33
libetonyek::IWORKTable::m_defaultParaStyles
IWORKStylePtr_t m_defaultParaStyles[5]
Definition: IWORKTable.h:101
libetonyek::IWORKToken::type
Definition: IWORKToken.h:266
libetonyek::IWORKTable::getDefaultParagraphStyle
IWORKStylePtr_t getDefaultParagraphStyle(unsigned column, unsigned row) const
Definition: IWORKTable.cpp:398
libetonyek::IWORKTable::setBandedRows
void setBandedRows(bool banded=true)
Definition: IWORKTable.cpp:236
libetonyek::IWORKTable::setBorders
void setBorders(const IWORKGridLineList_t &verticalLines, const IWORKGridLineList_t &horizontalLines)
Definition: IWORKTable.cpp:261
libetonyek::IWORKTable::Cell::m_type
IWORKCellType m_type
Definition: IWORKTable.h:34
libetonyek::IWORKTable::insertCoveredCell
void insertCoveredCell(unsigned column, unsigned row)
Definition: IWORKTable.cpp:283
libetonyek::IWORKCellType
IWORKCellType
Definition: IWORKEnum.h:70
libetonyek::IWORKTable::m_bandedRows
bool m_bandedRows
Definition: IWORKTable.h:95
libetonyek::IWORKTable::m_footerRows
unsigned m_footerRows
Definition: IWORKTable.h:93
libetonyek::IWORKTable::CELL_TYPE_ROW_FOOTER
Definition: IWORKTable.h:50
libetonyek::IWORKTable::Cell::m_value
boost::optional< std::string > m_value
Definition: IWORKTable.h:35
libetonyek::IWORKTable::setStyle
void setStyle(const IWORKStylePtr_t &style)
Definition: IWORKTable.cpp:247
libetonyek::IWORKTable::m_headerRows
unsigned m_headerRows
Definition: IWORKTable.h:92
libetonyek::IWORKTable::Cell::Cell
Cell()
Definition: IWORKTable.cpp:193
libetonyek::IWORKTable::Cell::m_covered
bool m_covered
Definition: IWORKTable.h:31