WPSTable.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2/* libwps
3 * Version: MPL 2.0 / LGPLv2.1+
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 * Major Contributor(s):
10 * Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr)
11 * Copyright (C) 2006, 2007 Andrew Ziem
12 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
13 * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
14 * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
15 *
16 * For minor contributions see the git repository.
17 *
18 * Alternatively, the contents of this file may be used under the terms
19 * of the GNU Lesser General Public License Version 2.1 or later
20 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
21 * applicable instead of those above.
22 *
23 * For further information visit http://libwps.sourceforge.net
24 */
25
26#ifndef WPS_TABLE
27# define WPS_TABLE
28
29#include <iostream>
30#include <vector>
31
32#include "libwps_internal.h"
33
34/*
35 * Structure to store the column properties
36 *
37 * \note use only to define sheet properties, to be changed
38 */
40{
41public:
43 explicit WPSColumnFormat(float width=-1)
44 : m_width(width)
45 , m_isPercentWidth(false)
46 , m_useOptimalWidth(false)
47 , m_isHeader(false)
48 , m_numRepeat(1)
49 , m_visible(true)
50 {
51 }
52
53 void addTo(librevenge::RVNGPropertyList &propList) const;
57 int compare(WPSColumnFormat const &col) const
58 {
59 if (m_width<col.m_width) return 1;
60 if (m_width>col.m_width) return -1;
61 if (m_isPercentWidth!=col.m_isPercentWidth) return m_isPercentWidth ? 1 : -1;
63 if (m_isHeader!=col.m_isHeader) return m_isHeader ? 1 : -1;
64 if (m_visible!=col.m_visible) return m_visible ? 1 : -1;
65 return 0;
66 }
67
68 bool operator==(WPSColumnFormat const &col) const
69 {
70 return compare(col)==0;
71 }
72
73 bool operator!=(WPSColumnFormat const &col) const
74 {
75 return compare(col)!=0;
76 }
77
78 bool operator<(WPSColumnFormat const &col) const
79 {
80 return compare(col)<0;
81 }
82
83 friend std::ostream &operator<<(std::ostream &o, WPSColumnFormat const &col);
84
86 float m_width;
97};
98
99/*
100 * Structure to store the row properties
101 *
102 * \note use only to define sheet properties, to be changed
103 */
105{
106public:
108 explicit WPSRowFormat(float height=-1)
109 : m_height(height)
110 , m_isMinimalHeight(false)
111 , m_useOptimalHeight(false)
112 , m_isHeader(false)
113 {
114 }
115
116 void addTo(librevenge::RVNGPropertyList &propList) const;
118 int compare(WPSRowFormat const &row) const
119 {
120 if (m_height<row.m_height) return 1;
121 if (m_height>row.m_height) return -1;
122 if (m_isMinimalHeight!=row.m_isMinimalHeight) return m_isMinimalHeight ? 1 : -1;
124 if (m_isHeader!=row.m_isHeader) return m_isHeader ? 1 : -1;
125 return 0;
126 }
127
128 bool operator==(WPSRowFormat const &row) const
129 {
130 return compare(row)==0;
131 }
132
133 bool operator!=(WPSRowFormat const &row) const
134 {
135 return compare(row)!=0;
136 }
137
138 bool operator<(WPSRowFormat const &row) const
139 {
140 return compare(row)<0;
141 }
142
143 friend std::ostream &operator<<(std::ostream &o, WPSRowFormat const &row);
144
146 float m_height;
153};
154
155/*
156 * Structure to store and construct a table from an unstructured list
157 * of cell
158 *
159 */
161{
162public:
165 : m_cellsList()
166 , m_rowsSize()
167 , m_colsSize() {}
168 WPSTable &operator=(WPSTable const &)=default;
170 virtual ~WPSTable();
171
173 void add(WPSCellPtr &cell);
174
176 int numCells() const
177 {
178 return int(m_cellsList.size());
179 }
180
181 WPSCellPtr getCell(int id);
182
187 bool sendTable(WPSContentListenerPtr listener);
188
190 bool sendAsText(WPSContentListenerPtr listener);
191
192protected:
194 bool buildStructures();
195
197 std::vector<WPSCellPtr> m_cellsList;
199 std::vector<float> m_rowsSize, m_colsSize;
200};
201
202#endif
203/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPSCellPtr getCell(int id)
returns the i^th cell
Definition WPSTable.cpp:113
bool sendAsText(WPSContentListenerPtr listener)
try to send the table as basic text
Definition WPSTable.cpp:317
WPSTable()
the constructor
Definition WPSTable.h:164
void add(WPSCellPtr &cell)
add a new cells
Definition WPSTable.cpp:108
bool sendTable(WPSContentListenerPtr listener)
try to send the table
Definition WPSTable.cpp:244
int numCells() const
returns the number of cell
Definition WPSTable.h:176
bool buildStructures()
create the correspondance list, ...
Definition WPSTable.cpp:125
std::vector< float > m_colsSize
Definition WPSTable.h:199
std::vector< float > m_rowsSize
the final row and col size (in point)
Definition WPSTable.h:199
WPSTable & operator=(WPSTable const &)=default
std::vector< WPSCellPtr > m_cellsList
the list of cells
Definition WPSTable.h:197
virtual ~WPSTable()
the destructor
Definition WPSTable.cpp:104
std::shared_ptr< WPSCell > WPSCellPtr
shared pointer to WPSCell
Definition libwps_internal.h:103
std::shared_ptr< WPSContentListener > WPSContentListenerPtr
shared pointer to WPSContentListener
Definition libwps_internal.h:107
Definition WPSTable.h:40
bool operator==(WPSColumnFormat const &col) const
operator==
Definition WPSTable.h:68
bool m_useOptimalWidth
a flag to know if we need to see use-optimal column width
Definition WPSTable.h:90
float m_width
the column width, if known
Definition WPSTable.h:86
bool m_isPercentWidth
a flag to know if the width is in percent (or in point)
Definition WPSTable.h:88
bool operator!=(WPSColumnFormat const &col) const
operator!=
Definition WPSTable.h:73
bool operator<(WPSColumnFormat const &col) const
operator<
Definition WPSTable.h:78
bool m_isHeader
a flag to know if the column is a header column
Definition WPSTable.h:92
int m_numRepeat
the number times a column is repeated
Definition WPSTable.h:94
bool m_visible
true if a column is visible
Definition WPSTable.h:96
WPSColumnFormat(float width=-1)
constructor
Definition WPSTable.h:43
void addTo(librevenge::RVNGPropertyList &propList) const
add to the propList
Definition WPSTable.cpp:58
int compare(WPSColumnFormat const &col) const
a comparison function
Definition WPSTable.h:57
friend std::ostream & operator<<(std::ostream &o, WPSColumnFormat const &col)
operator<<
Definition WPSTable.cpp:42
Definition WPSTable.h:105
bool operator!=(WPSRowFormat const &row) const
operator!=
Definition WPSTable.h:133
friend std::ostream & operator<<(std::ostream &o, WPSRowFormat const &row)
operator<<
Definition WPSTable.cpp:74
WPSRowFormat(float height=-1)
constructor
Definition WPSTable.h:108
bool operator==(WPSRowFormat const &row) const
operator==
Definition WPSTable.h:128
bool m_useOptimalHeight
a flag to know if we need to see use-optimal row height
Definition WPSTable.h:150
int compare(WPSRowFormat const &row) const
a comparison function
Definition WPSTable.h:118
void addTo(librevenge::RVNGPropertyList &propList) const
add to the propList
Definition WPSTable.cpp:88
float m_height
the row height, if known
Definition WPSTable.h:146
bool operator<(WPSRowFormat const &row) const
operator<
Definition WPSTable.h:138
bool m_isHeader
a flag to know if the row is a header row
Definition WPSTable.h:152
bool m_isMinimalHeight
a flag to know if the height is only a minimum
Definition WPSTable.h:148

Generated on for libwps by doxygen 1.17.0