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