- 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 #include <boost/shared_ptr.hpp>
15
16 #include <deque>
17
18 #include "IWORKStyle_fwd.h"
19 #include "IWORKTypes.h"
20 #include "IWORKOutputElements.h"
21
22 namespace libetonyek
23 {
24
25 class IWORKText;
26 class IWORKTableRecorder;
27
28 class IWORKTable
29 {
30 struct Cell
31 {
32 IWORKOutputElements m_content;
33 unsigned m_columnSpan;
34 unsigned m_rowSpan;
35 bool m_covered;
36 boost::optional<IWORKFormula> m_formula;
37 IWORKStylePtr_t m_style;
38 IWORKCellType m_type;
39 boost::optional<std::string> m_value;
40
41 Cell();
42 };
43
44 typedef std::deque<Cell> Row_t;
45 typedef std::deque<Row_t> Table_t;
46
47 public:
48 enum CellType
49 {
50 CELL_TYPE_BODY,
51 CELL_TYPE_ALTERNATE_BODY,
52 CELL_TYPE_COLUMN_HEADER,
53 CELL_TYPE_ROW_HEADER,
54 CELL_TYPE_ROW_FOOTER
55 };
56
57 public:
58 explicit IWORKTable(const IWORKTableNameMapPtr_t &tableNameMap);
59
60 void setRecorder(const boost::shared_ptr<IWORKTableRecorder> &recorder);
61 const boost::shared_ptr<IWORKTableRecorder> &getRecorder() const;
62
63 void setSize(unsigned columns, unsigned rows);
64 void setHeaders(unsigned headerColumns, unsigned headerRows, unsigned footerRows);
65 void setBandedRows(bool banded = true);
66 void setRepeated(bool columns, bool rows);
67
68 void setStyle(const IWORKStylePtr_t &style);
69 void setSizes(const IWORKColumnSizes_t &columnSizes, const IWORKRowSizes_t &rowSizes);
70 void setBorders(const IWORKGridLineList_t &verticalLines, const IWORKGridLineList_t &horizontalLines);
71 void insertCell(unsigned column, unsigned row,
72 const boost::optional<std::string> &value = boost::none,
73 const boost::shared_ptr<IWORKText> &text = boost::shared_ptr<IWORKText>(),
74 unsigned columnSpan = 1, unsigned rowSpan = 1,
75 const boost::optional<IWORKFormula> &formula = boost::none,
76 const IWORKStylePtr_t &style = IWORKStylePtr_t(),
77 IWORKCellType type = IWORK_CELL_TYPE_TEXT);
78 void insertCoveredCell(unsigned column, unsigned row);
79
80 void draw(const librevenge::RVNGPropertyList &tableProps, IWORKOutputElements &elements);
81
82 void setDefaultCellStyle(CellType type, const IWORKStylePtr_t &style);
83 void setDefaultLayoutStyle(CellType type, const IWORKStylePtr_t &style);
84 void setDefaultParagraphStyle(CellType type, const IWORKStylePtr_t &style);
85
86 IWORKStylePtr_t getDefaultCellStyle(unsigned column, unsigned row) const;
87 IWORKStylePtr_t getDefaultLayoutStyle(unsigned column, unsigned row) const;
88 IWORKStylePtr_t getDefaultParagraphStyle(unsigned column, unsigned row) const;
89
90 private:
91 IWORKStylePtr_t getDefaultStyle(unsigned column, unsigned row, const IWORKStylePtr_t *group) const;
92
93 private:
94 const IWORKTableNameMapPtr_t m_tableNameMap;
95
96 Table_t m_table;
97 IWORKStylePtr_t m_style;
98 IWORKColumnSizes_t m_columnSizes;
99 IWORKRowSizes_t m_rowSizes;
100 IWORKGridLineList_t m_verticalLines;
101 IWORKGridLineList_t m_horizontalLines;
102
103 unsigned m_rows;
104 unsigned m_columns;
105 unsigned m_headerRows;
106 unsigned m_footerRows;
107 unsigned m_headerColumns;
108 bool m_bandedRows;
109 bool m_headerRowsRepeated;
110 bool m_headerColumnsRepeated;
111
112 IWORKStylePtr_t m_defaultCellStyles[5];
113 IWORKStylePtr_t m_defaultLayoutStyles[5];
114 IWORKStylePtr_t m_defaultParaStyles[5];
115
116 boost::shared_ptr<IWORKTableRecorder> m_recorder;
117 };
118
119 }
120
121 #endif // IWORKTABLE_H_INCLUDED
122
123 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libetonyek::IWORKTable::CellType
CellType
Definition: IWORKTable.h:48
libetonyek::IWORKTable::setHeaders
void setHeaders(unsigned headerColumns, unsigned headerRows, unsigned footerRows)
Definition: IWORKTable.cpp:248
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:36
libetonyek::IWORKTable::m_rowSizes
IWORKRowSizes_t m_rowSizes
Definition: IWORKTable.h:99
libetonyek::IWORKTable::m_headerRowsRepeated
bool m_headerRowsRepeated
Definition: IWORKTable.h:109
IWORKOutputElements.h
libetonyek::IWORKTable::m_headerColumnsRepeated
bool m_headerColumnsRepeated
Definition: IWORKTable.h:110
libetonyek::IWORKTable::getDefaultLayoutStyle
IWORKStylePtr_t getDefaultLayoutStyle(unsigned column, unsigned row) const
Definition: IWORKTable.cpp:481
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:295
libetonyek::IWORKTable::Cell
Definition: IWORKTable.h:30
libetonyek::IWORKTable::setDefaultParagraphStyle
void setDefaultParagraphStyle(CellType type, const IWORKStylePtr_t &style)
Definition: IWORKTable.cpp:464
libetonyek::IWORKTable::setSize
void setSize(unsigned columns, unsigned rows)
Definition: IWORKTable.cpp:236
libetonyek::IWORKTable::CELL_TYPE_ROW_HEADER
Definition: IWORKTable.h:53
libetonyek::IWORKTable::Row_t
std::deque< Cell > Row_t
Definition: IWORKTable.h:44
libetonyek::IWORKTable::Table_t
std::deque< Row_t > Table_t
Definition: IWORKTable.h:45
libetonyek::IWORKTable::Cell::m_content
IWORKOutputElements m_content
Definition: IWORKTable.h:32
libetonyek::IWORKTable::setRepeated
void setRepeated(bool columns, bool rows)
Definition: IWORKTable.cpp:272
libetonyek::IWORKToken::text
Definition: IWORKToken.h:270
libetonyek::IWORKTable::m_headerColumns
unsigned m_headerColumns
Definition: IWORKTable.h:107
libetonyek::IWORKTable::m_recorder
boost::shared_ptr< IWORKTableRecorder > m_recorder
Definition: IWORKTable.h:116
libetonyek::IWORKToken::none
Definition: IWORKToken.h:380
libetonyek::IWORKTable::setRecorder
void setRecorder(const boost::shared_ptr< IWORKTableRecorder > &recorder)
Definition: IWORKTable.cpp:226
libetonyek::IWORKToken::group
Definition: IWORKToken.h:147
libetonyek::IWORKToken::style
Definition: IWORKToken.h:254
libetonyek::IWORKGridLineList_t
std::vector< IWORKGridLine_t > IWORKGridLineList_t
Definition: IWORKTypes.h:102
libetonyek::IWORKTable::getDefaultCellStyle
IWORKStylePtr_t getDefaultCellStyle(unsigned column, unsigned row) const
Definition: IWORKTable.cpp:476
libetonyek::IWORKTable::m_columnSizes
IWORKColumnSizes_t m_columnSizes
Definition: IWORKTable.h:98
libetonyek::IWORKToken::rows
Definition: IWORKToken.h:231
libetonyek::IWORKTable::setDefaultLayoutStyle
void setDefaultLayoutStyle(CellType type, const IWORKStylePtr_t &style)
Definition: IWORKTable.cpp:452
libetonyek::IWORK_CELL_TYPE_TEXT
Definition: IWORKEnum.h:73
libetonyek::IWORKTable::IWORKTable
IWORKTable(const IWORKTableNameMapPtr_t &tableNameMap)
Definition: IWORKTable.cpp:207
libetonyek::IWORKTable::getRecorder
const boost::shared_ptr< IWORKTableRecorder > & getRecorder() const
Definition: IWORKTable.cpp:231
libetonyek::IWORKTable::m_horizontalLines
IWORKGridLineList_t m_horizontalLines
Definition: IWORKTable.h:101
libetonyek::IWORKTable::m_verticalLines
IWORKGridLineList_t m_verticalLines
Definition: IWORKTable.h:100
libetonyek::IWORKTable::m_table
Table_t m_table
Definition: IWORKTable.h:96
libetonyek::IWORKTable::draw
void draw(const librevenge::RVNGPropertyList &tableProps, IWORKOutputElements &elements)
Definition: IWORKTable.cpp:361
libetonyek::IWORKTable::Cell::m_rowSpan
unsigned m_rowSpan
Definition: IWORKTable.h:34
libetonyek::IWORKTable::m_columns
unsigned m_columns
Definition: IWORKTable.h:104
libetonyek::IWORKTable::Cell::m_columnSpan
unsigned m_columnSpan
Definition: IWORKTable.h:33
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:52
libetonyek::IWORKToken::columns
Definition: IWORKToken.h:82
libetonyek::IWORKTable::CELL_TYPE_ALTERNATE_BODY
Definition: IWORKTable.h:51
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:440
libetonyek::IWORKTable::m_rows
unsigned m_rows
Definition: IWORKTable.h:103
libetonyek::IWORKTable::insertCell
void insertCell(unsigned column, unsigned row, const boost::optional< std::string > &value=boost::none, const boost::shared_ptr< IWORKText > &text=boost::shared_ptr< IWORKText >(), 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:322
libetonyek::IWORKTable::getDefaultStyle
IWORKStylePtr_t getDefaultStyle(unsigned column, unsigned row, const IWORKStylePtr_t *group) const
Definition: IWORKTable.cpp:491
libetonyek::IWORKTable::m_tableNameMap
const IWORKTableNameMapPtr_t m_tableNameMap
Definition: IWORKTable.h:94
libetonyek::IWORKTable::m_style
IWORKStylePtr_t m_style
Definition: IWORKTable.h:97
libetonyek::IWORKTable::m_defaultCellStyles
IWORKStylePtr_t m_defaultCellStyles[5]
Definition: IWORKTable.h:112
libetonyek::IWORKToken::column
Definition: IWORKToken.h:80
IWORKTypes.h
libetonyek::IWORKTable
Definition: IWORKTable.h:28
libetonyek::IWORKTable::m_defaultLayoutStyles
IWORKStylePtr_t m_defaultLayoutStyles[5]
Definition: IWORKTable.h:113
libetonyek::IWORKTable::CELL_TYPE_BODY
Definition: IWORKTable.h:50
libetonyek::IWORKTable::Cell::m_style
IWORKStylePtr_t m_style
Definition: IWORKTable.h:37
libetonyek::IWORKTable::m_defaultParaStyles
IWORKStylePtr_t m_defaultParaStyles[5]
Definition: IWORKTable.h:114
libetonyek::IWORKToken::type
Definition: IWORKToken.h:281
libetonyek::IWORKTable::getDefaultParagraphStyle
IWORKStylePtr_t getDefaultParagraphStyle(unsigned column, unsigned row) const
Definition: IWORKTable.cpp:486
libetonyek::IWORKTable::setBandedRows
void setBandedRows(bool banded=true)
Definition: IWORKTable.cpp:261
libetonyek::IWORKTable::setBorders
void setBorders(const IWORKGridLineList_t &verticalLines, const IWORKGridLineList_t &horizontalLines)
Definition: IWORKTable.cpp:310
libetonyek::IWORKTable::Cell::m_type
IWORKCellType m_type
Definition: IWORKTable.h:38
libetonyek::IWORKTable::insertCoveredCell
void insertCoveredCell(unsigned column, unsigned row)
Definition: IWORKTable.cpp:345
libetonyek::IWORKCellType
IWORKCellType
Definition: IWORKEnum.h:70
libetonyek::IWORKTable::m_bandedRows
bool m_bandedRows
Definition: IWORKTable.h:108
libetonyek::IWORKTable::m_footerRows
unsigned m_footerRows
Definition: IWORKTable.h:106
libetonyek::IWORKTable::CELL_TYPE_ROW_FOOTER
Definition: IWORKTable.h:54
libetonyek::IWORKTable::Cell::m_value
boost::optional< std::string > m_value
Definition: IWORKTable.h:39
libetonyek::IWORKTable::setStyle
void setStyle(const IWORKStylePtr_t &style)
Definition: IWORKTable.cpp:284
libetonyek::IWORKTable::m_headerRows
unsigned m_headerRows
Definition: IWORKTable.h:105
libetonyek::IWORKTable::Cell::Cell
Cell()
Definition: IWORKTable.cpp:195
libetonyek::IWORKTable::Cell::m_covered
bool m_covered
Definition: IWORKTable.h:35