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 
30 {
31  struct Cell
32  {
34  unsigned m_columnSpan;
35  unsigned m_rowSpan;
36  bool m_covered;
38  boost::optional<unsigned> m_formulaHC;
41  boost::optional<std::string> m_value;
42  boost::optional<IWORKDateTimeData> m_dateTime;
43 
44  Cell();
45  };
46 
47  typedef std::deque<Cell> Row_t;
48  typedef std::deque<Row_t> Table_t;
49 
50 public:
51  enum CellType
52  {
58  };
59 
60 public:
61  explicit IWORKTable(const IWORKTableNameMapPtr_t &tableNameMap, const IWORKLanguageManager &langManager);
62 
63  void setRecorder(const std::shared_ptr<IWORKTableRecorder> &recorder);
64  const std::shared_ptr<IWORKTableRecorder> &getRecorder() const;
65 
66  void setSize(unsigned columns, unsigned rows);
67  void setHeaders(unsigned headerColumns, unsigned headerRows, unsigned footerRows);
68  void setBandedRows(bool banded = true);
69  void setRepeated(bool columns, bool rows);
70 
71  void setOrder(int order);
72  void setStyle(const IWORKStylePtr_t &style);
73  void setSizes(const IWORKColumnSizes_t &columnSizes, const IWORKRowSizes_t &rowSizes);
74  void setBorders(const IWORKGridLineMap_t &verticalLines, const IWORKGridLineMap_t &horizontalLines);
75  void setBorders(const IWORKGridLineMap_t &verticalLeftLines, const IWORKGridLineMap_t &verticalRightLines,
76  const IWORKGridLineMap_t &horizontalTopLines, const IWORKGridLineMap_t &horizontalBottomLines);
77  void insertCell(unsigned column, unsigned row,
78  const boost::optional<std::string> &value = boost::none,
79  const std::shared_ptr<IWORKText> &text = std::shared_ptr<IWORKText>(),
80  const boost::optional<IWORKDateTimeData> &dateTime = boost::none,
81  unsigned columnSpan = 1, unsigned rowSpan = 1,
83  const boost::optional<unsigned> &formulaHC = boost::none,
86  void insertCoveredCell(unsigned column, unsigned row);
87 
88  void draw(const librevenge::RVNGPropertyList &tableProps, IWORKOutputElements &elements, bool drawAsSimpleTable);
89 
93 
94  boost::optional<int> getOrder() const;
95  IWORKStylePtr_t getStyle() const;
96  IWORKStylePtr_t getDefaultCellStyle(unsigned column, unsigned row) const;
97  IWORKStylePtr_t getDefaultLayoutStyle(unsigned column, unsigned row) const;
98  IWORKStylePtr_t getDefaultParagraphStyle(unsigned column, unsigned row) const;
99 
100 private:
101  IWORKStylePtr_t getDefaultStyle(unsigned column, unsigned row, const IWORKStylePtr_t *group) const;
102 
103 private:
106 
107  Table_t m_table;
109  boost::optional<int> m_order;
113  IWORKGridLineMap_t m_verticalRightLines; // if empty, m_verticalLines stores right/left line
115  IWORKGridLineMap_t m_horizontalBottomLines; // if empty, m_horizontalLines stores right/left line
116 
117  unsigned m_rows;
118  unsigned m_columns;
119  unsigned m_headerRows;
120  unsigned m_footerRows;
121  unsigned m_headerColumns;
125 
129 
130  std::shared_ptr<IWORKTableRecorder> m_recorder;
131 };
132 
133 }
134 
135 #endif // IWORKTABLE_H_INCLUDED
136 
137 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
CellType
Definition: IWORKTable.h:51
void setHeaders(unsigned headerColumns, unsigned headerRows, unsigned footerRows)
Definition: IWORKTable.cpp:370
Definition: IWORKBezierElement.cpp:20
Definition: IWORKOutputElements.h:32
boost::optional< IWORKDateTimeData > m_dateTime
Definition: IWORKTable.h:42
IWORKRowSizes_t m_rowSizes
Definition: IWORKTable.h:111
IWORKStylePtr_t getStyle() const
Definition: IWORKTable.cpp:682
bool m_headerRowsRepeated
Definition: IWORKTable.h:123
bool m_headerColumnsRepeated
Definition: IWORKTable.h:124
IWORKGridLineMap_t m_verticalRightLines
Definition: IWORKTable.h:113
void setSizes(const IWORKColumnSizes_t &columnSizes, const IWORKRowSizes_t &rowSizes)
Definition: IWORKTable.cpp:428
const IWORKLanguageManager & m_langManager
Definition: IWORKTable.h:105
IWORKStylePtr_t getDefaultParagraphStyle(unsigned column, unsigned row) const
Definition: IWORKTable.cpp:697
Definition: IWORKTable.h:31
void setDefaultParagraphStyle(CellType type, const IWORKStylePtr_t &style)
Definition: IWORKTable.cpp:665
void setSize(unsigned columns, unsigned rows)
Definition: IWORKTable.cpp:358
IWORKGridLineMap_t m_horizontalBottomLines
Definition: IWORKTable.h:115
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:470
std::shared_ptr< IWORKStyle > IWORKStylePtr_t
Definition: IWORKStyle_fwd.h:21
Definition: PAG1Token.h:43
Definition: IWORKToken.h:624
const std::shared_ptr< IWORKTableRecorder > & getRecorder() const
Definition: IWORKTable.cpp:353
std::deque< Cell > Row_t
Definition: IWORKTable.h:47
std::deque< Row_t > Table_t
Definition: IWORKTable.h:48
IWORKOutputElements m_content
Definition: IWORKTable.h:33
void setRepeated(bool columns, bool rows)
Definition: IWORKTable.cpp:394
Definition: IWORKToken.h:465
unsigned m_headerColumns
Definition: IWORKTable.h:121
Definition: IWORKToken.h:666
IWORKStylePtr_t getDefaultStyle(unsigned column, unsigned row, const IWORKStylePtr_t *group) const
Definition: IWORKTable.cpp:702
Definition: IWORKToken.h:244
std::deque< IWORKColumnRowSize > IWORKRowSizes_t
Definition: IWORKTypes_fwd.h:26
Definition: IWORKToken.h:414
void setBorders(const IWORKGridLineMap_t &verticalLines, const IWORKGridLineMap_t &horizontalLines)
Definition: IWORKTable.cpp:443
std::deque< IWORKColumnRowSize > IWORKColumnSizes_t
Definition: IWORKTypes_fwd.h:22
IWORKFormulaPtr_t m_formula
Definition: IWORKTable.h:37
IWORKColumnSizes_t m_columnSizes
Definition: IWORKTable.h:110
Definition: IWORKToken.h:385
void setDefaultLayoutStyle(CellType type, const IWORKStylePtr_t &style)
Definition: IWORKTable.cpp:653
Definition: IWORKEnum.h:82
IWORKGridLineMap_t m_verticalLines
Definition: IWORKTable.h:112
void draw(const librevenge::RVNGPropertyList &tableProps, IWORKOutputElements &elements, bool drawAsSimpleTable)
Definition: IWORKTable.cpp:525
std::shared_ptr< IWORKFormula > IWORKFormulaPtr_t
Definition: IWORKTypes.h:123
Table_t m_table
Definition: IWORKTable.h:107
unsigned m_rowSpan
Definition: IWORKTable.h:35
unsigned m_columns
Definition: IWORKTable.h:118
unsigned m_columnSpan
Definition: IWORKTable.h:34
void setOrder(int order)
Definition: IWORKTable.cpp:406
boost::optional< int > getOrder() const
Definition: IWORKTable.cpp:677
Definition: IWORKToken.h:154
IWORKStylePtr_t getDefaultCellStyle(unsigned column, unsigned row) const
Definition: IWORKTable.cpp:687
IWORKTable(const IWORKTableNameMapPtr_t &tableNameMap, const IWORKLanguageManager &langManager)
Definition: IWORKTable.cpp:324
std::shared_ptr< IWORKTableNameMap_t > IWORKTableNameMapPtr_t
Definition: IWORKTypes_fwd.h:34
std::map< unsigned, IWORKGridLine_t > IWORKGridLineMap_t
Definition: IWORKTypes.h:122
IWORKGridLineMap_t m_horizontalLines
Definition: IWORKTable.h:114
void setDefaultCellStyle(CellType type, const IWORKStylePtr_t &style)
Definition: IWORKTable.cpp:641
std::shared_ptr< IWORKTableRecorder > m_recorder
Definition: IWORKTable.h:130
Definition: IWORKLanguageManager.h:23
unsigned m_rows
Definition: IWORKTable.h:117
void setRecorder(const std::shared_ptr< IWORKTableRecorder > &recorder)
Definition: IWORKTable.cpp:348
const IWORKTableNameMapPtr_t m_tableNameMap
Definition: IWORKTable.h:104
Definition: IWORKToken.h:224
IWORKStylePtr_t m_style
Definition: IWORKTable.h:108
IWORKStylePtr_t m_defaultCellStyles[5]
Definition: IWORKTable.h:126
Definition: IWORKToken.h:152
Definition: IWORKTable.h:29
IWORKStylePtr_t m_defaultLayoutStyles[5]
Definition: IWORKTable.h:127
Definition: IWORKTable.h:53
boost::optional< int > m_order
Definition: IWORKTable.h:109
IWORKStylePtr_t m_style
Definition: IWORKTable.h:39
IWORKStylePtr_t m_defaultParaStyles[5]
Definition: IWORKTable.h:128
Definition: IWORKToken.h:486
void setBandedRows(bool banded=true)
Definition: IWORKTable.cpp:383
IWORKCellType m_type
Definition: IWORKTable.h:40
boost::optional< unsigned > m_formulaHC
Definition: IWORKTable.h:38
void insertCoveredCell(unsigned column, unsigned row)
Definition: IWORKTable.cpp:509
IWORKCellType
Definition: IWORKEnum.h:79
bool m_bandedRows
Definition: IWORKTable.h:122
Definition: IWORKToken.h:383
unsigned m_footerRows
Definition: IWORKTable.h:120
boost::optional< std::string > m_value
Definition: IWORKTable.h:41
IWORKStylePtr_t getDefaultLayoutStyle(unsigned column, unsigned row) const
Definition: IWORKTable.cpp:692
void setStyle(const IWORKStylePtr_t &style)
Definition: IWORKTable.cpp:417
unsigned m_headerRows
Definition: IWORKTable.h:119
Cell()
Definition: IWORKTable.cpp:310
bool m_covered
Definition: IWORKTable.h:36

Generated for libetonyek by doxygen 1.8.13