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 {
50 }
51
52 void addTo(librevenge::RVNGPropertyList &propList) const;
56 int compare(WPSColumnFormat const &col) const
57 {
58 if (m_width<col.m_width) return 1;
59 if (m_width>col.m_width) return -1;
60 if (m_isPercentWidth!=col.m_isPercentWidth) return m_isPercentWidth ? 1 : -1;
62 if (m_isHeader!=col.m_isHeader) return m_isHeader ? 1 : -1;
63 return 0;
64 }
65
66 bool operator==(WPSColumnFormat const &col) const
67 {
68 return compare(col)==0;
69 }
70
71 bool operator!=(WPSColumnFormat const &col) const
72 {
73 return compare(col)!=0;
74 }
75
76 bool operator<(WPSColumnFormat const &col) const
77 {
78 return compare(col)<0;
79 }
80
81 friend std::ostream &operator<<(std::ostream &o, WPSColumnFormat const &col);
82
84 float m_width;
93};
94
95/*
96 * Structure to store the row properties
97 *
98 * \note use only to define sheet properties, to be changed
99 */
101{
102public:
104 explicit WPSRowFormat(float height=-1)
105 : m_height(height)
106 , m_isMinimalHeight(false)
107 , m_useOptimalHeight(false)
108 , m_isHeader(false)
109 {
110 }
111
112 void addTo(librevenge::RVNGPropertyList &propList) const;
114 int compare(WPSRowFormat const &row) const
115 {
116 if (m_height<row.m_height) return 1;
117 if (m_height>row.m_height) return -1;
118 if (m_isMinimalHeight!=row.m_isMinimalHeight) return m_isMinimalHeight ? 1 : -1;
120 if (m_isHeader!=row.m_isHeader) return m_isHeader ? 1 : -1;
121 return 0;
122 }
123
124 bool operator==(WPSRowFormat const &row) const
125 {
126 return compare(row)==0;
127 }
128
129 bool operator!=(WPSRowFormat const &row) const
130 {
131 return compare(row)!=0;
132 }
133
134 bool operator<(WPSRowFormat const &row) const
135 {
136 return compare(row)<0;
137 }
138
139 friend std::ostream &operator<<(std::ostream &o, WPSRowFormat const &row);
140
142 float m_height;
149};
150
151/*
152 * Structure to store and construct a table from an unstructured list
153 * of cell
154 *
155 */
157{
158public:
161 : m_cellsList()
162 , m_rowsSize()
163 , m_colsSize() {}
164 WPSTable &operator=(WPSTable const &)=default;
166 virtual ~WPSTable();
167
169 void add(WPSCellPtr &cell);
170
172 int numCells() const
173 {
174 return int(m_cellsList.size());
175 }
176
177 WPSCellPtr getCell(int id);
178
183 bool sendTable(WPSContentListenerPtr listener);
184
186 bool sendAsText(WPSContentListenerPtr listener);
187
188protected:
190 bool buildStructures();
191
193 std::vector<WPSCellPtr> m_cellsList;
195 std::vector<float> m_rowsSize, m_colsSize;
196};
197
198#endif
199/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPSCellPtr getCell(int id)
returns the i^th cell
Definition WPSTable.cpp:110
bool sendAsText(WPSContentListenerPtr listener)
try to send the table as basic text
Definition WPSTable.cpp:314
WPSTable()
the constructor
Definition WPSTable.h:160
void add(WPSCellPtr &cell)
add a new cells
Definition WPSTable.cpp:105
bool sendTable(WPSContentListenerPtr listener)
try to send the table
Definition WPSTable.cpp:241
int numCells() const
returns the number of cell
Definition WPSTable.h:172
bool buildStructures()
create the correspondance list, ...
Definition WPSTable.cpp:122
std::vector< float > m_colsSize
Definition WPSTable.h:195
std::vector< float > m_rowsSize
the final row and col size (in point)
Definition WPSTable.h:195
WPSTable & operator=(WPSTable const &)=default
std::vector< WPSCellPtr > m_cellsList
the list of cells
Definition WPSTable.h:193
virtual ~WPSTable()
the destructor
Definition WPSTable.cpp:101
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:66
bool m_useOptimalWidth
a flag to know if we need to see use-optimal column width
Definition WPSTable.h:88
float m_width
the column width, if known
Definition WPSTable.h:84
bool m_isPercentWidth
a flag to know if the width is in percent (or in point)
Definition WPSTable.h:86
bool operator!=(WPSColumnFormat const &col) const
operator!=
Definition WPSTable.h:71
bool operator<(WPSColumnFormat const &col) const
operator<
Definition WPSTable.h:76
bool m_isHeader
a flag to know if the column is a header column
Definition WPSTable.h:90
int m_numRepeat
the number times a column is repeated
Definition WPSTable.h:92
WPSColumnFormat(float width=-1)
constructor
Definition WPSTable.h:43
void addTo(librevenge::RVNGPropertyList &propList) const
add to the propList
Definition WPSTable.cpp:57
int compare(WPSColumnFormat const &col) const
a comparison function
Definition WPSTable.h:56
friend std::ostream & operator<<(std::ostream &o, WPSColumnFormat const &col)
operator<<
Definition WPSTable.cpp:42
Definition WPSTable.h:101
bool operator!=(WPSRowFormat const &row) const
operator!=
Definition WPSTable.h:129
friend std::ostream & operator<<(std::ostream &o, WPSRowFormat const &row)
operator<<
Definition WPSTable.cpp:71
WPSRowFormat(float height=-1)
constructor
Definition WPSTable.h:104
bool operator==(WPSRowFormat const &row) const
operator==
Definition WPSTable.h:124
bool m_useOptimalHeight
a flag to know if we need to see use-optimal row height
Definition WPSTable.h:146
int compare(WPSRowFormat const &row) const
a comparison function
Definition WPSTable.h:114
void addTo(librevenge::RVNGPropertyList &propList) const
add to the propList
Definition WPSTable.cpp:85
float m_height
the row height, if known
Definition WPSTable.h:142
bool operator<(WPSRowFormat const &row) const
operator<
Definition WPSTable.h:134
bool m_isHeader
a flag to know if the row is a header row
Definition WPSTable.h:148
bool m_isMinimalHeight
a flag to know if the height is only a minimum
Definition WPSTable.h:144

Generated on Sat Jul 19 2025 05:24:40 for libwps by doxygen 1.14.0