IWORKTable.h Source File documentation

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 <map>
15#include <memory>
16#include <utility>
17
18#include <boost/optional.hpp>
19
20#include "IWORKStyle_fwd.h"
21#include "IWORKTypes.h"
22#include "IWORKOutputElements.h"
23
24namespace libetonyek
25{
26
27class IWORKLanguageManager;
28class IWORKText;
29class IWORKTableRecorder;
30
31 class IWORKTable
32{
33 struct Cell
34 {
35 IWORKOutputElements m_content;
36 unsigned m_columnSpan;
37 unsigned m_rowSpan;
38 bool m_covered;
39 IWORKFormulaPtr_t m_formula;
40 boost::optional<unsigned> m_formulaHC;
41 IWORKStylePtr_t m_style;
42 IWORKCellType m_type;
43 boost::optional<std::string> m_value;
44 boost::optional<IWORKDateTimeData> m_dateTime;
45
46 Cell();
47 };
48
49 typedef std::deque<Cell> Row_t;
50 typedef std::deque<Row_t> Table_t;
51
52public:
53 enum CellType
54 {
55 CELL_TYPE_BODY,
56 CELL_TYPE_ALTERNATE_BODY,
57 CELL_TYPE_COLUMN_HEADER,
58 CELL_TYPE_ROW_HEADER,
59 CELL_TYPE_ROW_FOOTER
60 };
61
62public:
63 explicit IWORKTable(const IWORKTableNameMapPtr_t &tableNameMap, const IWORKLanguageManager &langManager);
64
65 void setRecorder(const std::shared_ptr<IWORKTableRecorder> &recorder);
66 const std::shared_ptr<IWORKTableRecorder> &getRecorder() const;
67
68 void setName(std::string const &name);
69 void setSize(unsigned columns, unsigned rows);
70 void setHeaders(unsigned headerColumns, unsigned headerRows, unsigned footerRows);
71 void setBandedRows(bool banded = true);
72 void setRepeated(bool columns, bool rows);
73
74 void setOrder(int order);
75 void setStyle(const IWORKStylePtr_t &style);
76 void setSizes(const IWORKColumnSizes_t &columnSizes, const IWORKRowSizes_t &rowSizes);
77 void setBorders(const IWORKGridLineMap_t &verticalLines, const IWORKGridLineMap_t &horizontalLines);
78 void setBorders(const IWORKGridLineMap_t &verticalLeftLines, const IWORKGridLineMap_t &verticalRightLines,
79 const IWORKGridLineMap_t &horizontalTopLines, const IWORKGridLineMap_t &horizontalBottomLines);
80 void setComment(unsigned column, unsigned row, IWORKOutputElements const &text);
81 void insertCell(unsigned column, unsigned row,
82 const boost::optional<std::string> &value = boost::none,
83 const std::shared_ptr<IWORKText> &text = std::shared_ptr<IWORKText>(),
84 const boost::optional<IWORKDateTimeData> &dateTime = boost::none,
85 unsigned columnSpan = 1, unsigned rowSpan = 1,
86 const IWORKFormulaPtr_t &formula = IWORKFormulaPtr_t(),
87 const boost::optional<unsigned> &formulaHC = boost::none,
88 const IWORKStylePtr_t &style = IWORKStylePtr_t(),
89 IWORKCellType type = IWORK_CELL_TYPE_TEXT);
90 void insertCoveredCell(unsigned column, unsigned row);
91
92 void draw(const librevenge::RVNGPropertyList &tableProps, IWORKOutputElements &elements, bool drawAsSimpleTable);
93
94 void setDefaultCellStyle(CellType type, const IWORKStylePtr_t &style);
95 void setDefaultLayoutStyle(CellType type, const IWORKStylePtr_t &style);
96 void setDefaultParagraphStyle(CellType type, const IWORKStylePtr_t &style);
97
98 boost::optional<int> getOrder() const;
99 IWORKStylePtr_t getStyle() const;
100 IWORKStylePtr_t getDefaultCellStyle(unsigned column, unsigned row) const;
101 IWORKStylePtr_t getDefaultLayoutStyle(unsigned column, unsigned row) const;
102 IWORKStylePtr_t getDefaultParagraphStyle(unsigned column, unsigned row) const;
103
104private:
105 IWORKStylePtr_t getDefaultStyle(unsigned column, unsigned row, const IWORKStylePtr_t *group) const;
106
107 boost::optional<std::string> writeFormat(IWORKOutputElements &elements, const IWORKStylePtr_t &style, const IWORKCellType type, boost::optional<std::string> &rvngValueType);
108
109private:
110 const IWORKTableNameMapPtr_t m_tableNameMap;
111 const IWORKLanguageManager &m_langManager;
112 std::map<librevenge::RVNGString,std::string> m_formatNameMap;
113 std::map<std::pair<unsigned, unsigned>, IWORKOutputElements> m_commentMap;
114
115 Table_t m_table;
116 IWORKStylePtr_t m_style;
117 boost::optional<std::string> m_name;
118 boost::optional<int> m_order;
119 IWORKColumnSizes_t m_columnSizes;
120 IWORKRowSizes_t m_rowSizes;
121 IWORKGridLineMap_t m_verticalLines;
122 IWORKGridLineMap_t m_verticalRightLines; // if empty, m_verticalLines stores right/left line
123 IWORKGridLineMap_t m_horizontalLines;
124 IWORKGridLineMap_t m_horizontalBottomLines; // if empty, m_horizontalLines stores right/left line
125
126 unsigned m_rows;
127 unsigned m_columns;
128 unsigned m_headerRows;
129 unsigned m_footerRows;
130 unsigned m_headerColumns;
131 bool m_bandedRows;
132 bool m_headerRowsRepeated;
133 bool m_headerColumnsRepeated;
134
135 IWORKStylePtr_t m_defaultCellStyles[5];
136 IWORKStylePtr_t m_defaultLayoutStyles[5];
137 IWORKStylePtr_t m_defaultParaStyles[5];
138
139 std::shared_ptr<IWORKTableRecorder> m_recorder;
140};
141
142}
143
144#endif // IWORKTABLE_H_INCLUDED
145
146/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
IWORKOutputElements.h
IWORKStyle_fwd.h
IWORKTypes.h
libetonyek::IWORKLanguageManager
Definition: IWORKLanguageManager.h:24
libetonyek::IWORKOutputElements
Definition: IWORKOutputElements.h:33
libetonyek::IWORKTable
Definition: IWORKTable.h:32
libetonyek::IWORKTable::m_langManager
const IWORKLanguageManager & m_langManager
Definition: IWORKTable.h:111
libetonyek::IWORKTable::m_defaultLayoutStyles
IWORKStylePtr_t m_defaultLayoutStyles[5]
Definition: IWORKTable.h:136
libetonyek::IWORKTable::writeFormat
boost::optional< std::string > writeFormat(IWORKOutputElements &elements, const IWORKStylePtr_t &style, const IWORKCellType type, boost::optional< std::string > &rvngValueType)
Definition: IWORKTable.cpp:664
libetonyek::IWORKTable::m_verticalRightLines
IWORKGridLineMap_t m_verticalRightLines
Definition: IWORKTable.h:122
libetonyek::IWORKTable::setDefaultCellStyle
void setDefaultCellStyle(CellType type, const IWORKStylePtr_t &style)
Definition: IWORKTable.cpp:944
libetonyek::IWORKTable::getOrder
boost::optional< int > getOrder() const
Definition: IWORKTable.cpp:980
libetonyek::IWORKTable::draw
void draw(const librevenge::RVNGPropertyList &tableProps, IWORKOutputElements &elements, bool drawAsSimpleTable)
Definition: IWORKTable.cpp:740
libetonyek::IWORKTable::m_columnSizes
IWORKColumnSizes_t m_columnSizes
Definition: IWORKTable.h:119
libetonyek::IWORKTable::m_bandedRows
bool m_bandedRows
Definition: IWORKTable.h:131
libetonyek::IWORKTable::setBandedRows
void setBandedRows(bool banded=true)
Definition: IWORKTable.cpp:512
libetonyek::IWORKTable::setDefaultLayoutStyle
void setDefaultLayoutStyle(CellType type, const IWORKStylePtr_t &style)
Definition: IWORKTable.cpp:956
libetonyek::IWORKTable::getStyle
IWORKStylePtr_t getStyle() const
Definition: IWORKTable.cpp:985
libetonyek::IWORKTable::setName
void setName(std::string const &name)
Definition: IWORKTable.cpp:482
libetonyek::IWORKTable::Row_t
std::deque< Cell > Row_t
Definition: IWORKTable.h:49
libetonyek::IWORKTable::m_footerRows
unsigned m_footerRows
Definition: IWORKTable.h:129
libetonyek::IWORKTable::m_formatNameMap
std::map< librevenge::RVNGString, std::string > m_formatNameMap
Definition: IWORKTable.h:112
libetonyek::IWORKTable::getRecorder
const std::shared_ptr< IWORKTableRecorder > & getRecorder() const
Definition: IWORKTable.cpp:477
libetonyek::IWORKTable::m_headerColumns
unsigned m_headerColumns
Definition: IWORKTable.h:130
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 >(), const boost::optional< IWORKDateTimeData > &dateTime=boost::none, unsigned columnSpan=1, unsigned rowSpan=1, const IWORKFormulaPtr_t &formula=IWORKFormulaPtr_t(), const boost::optional< unsigned > &formulaHC=boost::none, const IWORKStylePtr_t &style=IWORKStylePtr_t(), IWORKCellType type=IWORK_CELL_TYPE_TEXT)
Definition: IWORKTable.cpp:609
libetonyek::IWORKTable::m_rowSizes
IWORKRowSizes_t m_rowSizes
Definition: IWORKTable.h:120
libetonyek::IWORKTable::setStyle
void setStyle(const IWORKStylePtr_t &style)
Definition: IWORKTable.cpp:546
libetonyek::IWORKTable::m_table
Table_t m_table
Definition: IWORKTable.h:115
libetonyek::IWORKTable::m_horizontalLines
IWORKGridLineMap_t m_horizontalLines
Definition: IWORKTable.h:123
libetonyek::IWORKTable::m_headerColumnsRepeated
bool m_headerColumnsRepeated
Definition: IWORKTable.h:133
libetonyek::IWORKTable::getDefaultCellStyle
IWORKStylePtr_t getDefaultCellStyle(unsigned column, unsigned row) const
Definition: IWORKTable.cpp:990
libetonyek::IWORKTable::m_order
boost::optional< int > m_order
Definition: IWORKTable.h:118
libetonyek::IWORKTable::m_horizontalBottomLines
IWORKGridLineMap_t m_horizontalBottomLines
Definition: IWORKTable.h:124
libetonyek::IWORKTable::m_name
boost::optional< std::string > m_name
Definition: IWORKTable.h:117
libetonyek::IWORKTable::getDefaultParagraphStyle
IWORKStylePtr_t getDefaultParagraphStyle(unsigned column, unsigned row) const
Definition: IWORKTable.cpp:1000
libetonyek::IWORKTable::m_headerRows
unsigned m_headerRows
Definition: IWORKTable.h:128
libetonyek::IWORKTable::m_headerRowsRepeated
bool m_headerRowsRepeated
Definition: IWORKTable.h:132
libetonyek::IWORKTable::getDefaultLayoutStyle
IWORKStylePtr_t getDefaultLayoutStyle(unsigned column, unsigned row) const
Definition: IWORKTable.cpp:995
libetonyek::IWORKTable::m_defaultParaStyles
IWORKStylePtr_t m_defaultParaStyles[5]
Definition: IWORKTable.h:137
libetonyek::IWORKTable::m_rows
unsigned m_rows
Definition: IWORKTable.h:126
libetonyek::IWORKTable::setBorders
void setBorders(const IWORKGridLineMap_t &verticalLines, const IWORKGridLineMap_t &horizontalLines)
Definition: IWORKTable.cpp:572
libetonyek::IWORKTable::m_recorder
std::shared_ptr< IWORKTableRecorder > m_recorder
Definition: IWORKTable.h:139
libetonyek::IWORKTable::setSizes
void setSizes(const IWORKColumnSizes_t &columnSizes, const IWORKRowSizes_t &rowSizes)
Definition: IWORKTable.cpp:557
libetonyek::IWORKTable::setRepeated
void setRepeated(bool columns, bool rows)
Definition: IWORKTable.cpp:523
libetonyek::IWORKTable::setRecorder
void setRecorder(const std::shared_ptr< IWORKTableRecorder > &recorder)
Definition: IWORKTable.cpp:472
libetonyek::IWORKTable::m_columns
unsigned m_columns
Definition: IWORKTable.h:127
libetonyek::IWORKTable::m_verticalLines
IWORKGridLineMap_t m_verticalLines
Definition: IWORKTable.h:121
libetonyek::IWORKTable::getDefaultStyle
IWORKStylePtr_t getDefaultStyle(unsigned column, unsigned row, const IWORKStylePtr_t *group) const
Definition: IWORKTable.cpp:1005
libetonyek::IWORKTable::m_style
IWORKStylePtr_t m_style
Definition: IWORKTable.h:116
libetonyek::IWORKTable::setDefaultParagraphStyle
void setDefaultParagraphStyle(CellType type, const IWORKStylePtr_t &style)
Definition: IWORKTable.cpp:968
libetonyek::IWORKTable::m_tableNameMap
const IWORKTableNameMapPtr_t m_tableNameMap
Definition: IWORKTable.h:110
libetonyek::IWORKTable::setSize
void setSize(unsigned columns, unsigned rows)
Definition: IWORKTable.cpp:487
libetonyek::IWORKTable::setOrder
void setOrder(int order)
Definition: IWORKTable.cpp:535
libetonyek::IWORKTable::m_defaultCellStyles
IWORKStylePtr_t m_defaultCellStyles[5]
Definition: IWORKTable.h:135
libetonyek::IWORKTable::setHeaders
void setHeaders(unsigned headerColumns, unsigned headerRows, unsigned footerRows)
Definition: IWORKTable.cpp:499
libetonyek::IWORKTable::setComment
void setComment(unsigned column, unsigned row, IWORKOutputElements const &text)
Definition: IWORKTable.cpp:584
libetonyek::IWORKTable::Table_t
std::deque< Row_t > Table_t
Definition: IWORKTable.h:50
libetonyek::IWORKTable::CellType
CellType
Definition: IWORKTable.h:54
libetonyek::IWORKTable::CELL_TYPE_ROW_HEADER
@ CELL_TYPE_ROW_HEADER
Definition: IWORKTable.h:58
libetonyek::IWORKTable::CELL_TYPE_ROW_FOOTER
@ CELL_TYPE_ROW_FOOTER
Definition: IWORKTable.h:59
libetonyek::IWORKTable::CELL_TYPE_BODY
@ CELL_TYPE_BODY
Definition: IWORKTable.h:55
libetonyek::IWORKTable::CELL_TYPE_ALTERNATE_BODY
@ CELL_TYPE_ALTERNATE_BODY
Definition: IWORKTable.h:56
libetonyek::IWORKTable::CELL_TYPE_COLUMN_HEADER
@ CELL_TYPE_COLUMN_HEADER
Definition: IWORKTable.h:57
libetonyek::IWORKTable::m_commentMap
std::map< std::pair< unsigned, unsigned >, IWORKOutputElements > m_commentMap
Definition: IWORKTable.h:113
libetonyek::IWORKTable::insertCoveredCell
void insertCoveredCell(unsigned column, unsigned row)
Definition: IWORKTable.cpp:648
libetonyek
Definition: IWORKBezierElement.cpp:21
libetonyek::IWORKCellType
IWORKCellType
Definition: IWORKEnum.h:80
libetonyek::IWORK_CELL_TYPE_TEXT
@ IWORK_CELL_TYPE_TEXT
Definition: IWORKEnum.h:82
libetonyek::IWORKGridLineMap_t
std::map< unsigned, IWORKGridLine_t > IWORKGridLineMap_t
Definition: IWORKTypes.h:122
libetonyek::IWORKColumnSizes_t
std::deque< IWORKColumnRowSize > IWORKColumnSizes_t
Definition: IWORKTypes_fwd.h:24
libetonyek::IWORKFormulaPtr_t
std::shared_ptr< IWORKFormula > IWORKFormulaPtr_t
Definition: IWORKTypes.h:123
libetonyek::IWORKRowSizes_t
std::deque< IWORKColumnRowSize > IWORKRowSizes_t
Definition: IWORKTypes_fwd.h:26
libetonyek::IWORKStylePtr_t
std::shared_ptr< IWORKStyle > IWORKStylePtr_t
Definition: IWORKStyle_fwd.h:23
libetonyek::IWORKTableNameMapPtr_t
std::shared_ptr< IWORKTableNameMap_t > IWORKTableNameMapPtr_t
Definition: IWORKTypes_fwd.h:34
libetonyek::IWORKTable::Cell
Definition: IWORKTable.h:34
libetonyek::IWORKTable::Cell::m_type
IWORKCellType m_type
Definition: IWORKTable.h:42
libetonyek::IWORKTable::Cell::m_columnSpan
unsigned m_columnSpan
Definition: IWORKTable.h:36
libetonyek::IWORKTable::Cell::m_style
IWORKStylePtr_t m_style
Definition: IWORKTable.h:41
libetonyek::IWORKTable::Cell::m_rowSpan
unsigned m_rowSpan
Definition: IWORKTable.h:37
libetonyek::IWORKTable::Cell::m_formula
IWORKFormulaPtr_t m_formula
Definition: IWORKTable.h:39
libetonyek::IWORKTable::Cell::m_content
IWORKOutputElements m_content
Definition: IWORKTable.h:35
libetonyek::IWORKTable::Cell::m_dateTime
boost::optional< IWORKDateTimeData > m_dateTime
Definition: IWORKTable.h:44
libetonyek::IWORKTable::Cell::m_formulaHC
boost::optional< unsigned > m_formulaHC
Definition: IWORKTable.h:40
libetonyek::IWORKTable::Cell::Cell
Cell()
Definition: IWORKTable.cpp:431
libetonyek::IWORKTable::Cell::m_covered
bool m_covered
Definition: IWORKTable.h:38
libetonyek::IWORKTable::Cell::m_value
boost::optional< std::string > m_value
Definition: IWORKTable.h:43