WPXTable.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libwpd
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) 2002 William Lachance (wrlach@gmail.com)
11  * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
12  *
13  * For minor contributions see the git repository.
14  *
15  * Alternatively, the contents of this file may be used under the terms
16  * of the GNU Lesser General Public License Version 2.1 or later
17  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
18  * applicable instead of those above.
19  *
20  * For further information visit http://libwpd.sourceforge.net
21  */
22 
23 /* "This product is not manufactured, approved, or supported by
24  * Corel Corporation or Corel Corporation Limited."
25  */
26 
27 // WPXTable: an intermediate representation of a table, designed to be created
28 // "ahead of time". unlike wordperfect's table definition messages, this representation
29 // is _consistent_: we can always count on the messages being sent using this representation
30 // (once it is created and finalized) to be reliable (assuming no bugs in this code!) :-)
31 //
32 // example situation where this might be useful: WordPerfect allows two cells,
33 // side by side, one with border, one without-- creating a false ambiguity (none
34 // actually exists: if one cell does not have a border, the other doesn't either)
35 
36 #ifndef _WPXTABLE_H
37 #define _WPXTABLE_H
38 
39 #include <cstddef>
40 #include <vector>
41 
43 {
44  WPXTableCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits);
45  unsigned char m_colSpan;
46  unsigned char m_rowSpan;
47  unsigned char m_borderBits;
48 };
49 
50 class WPXTable
51 {
52 public:
54  ~WPXTable();
55  void insertRow();
56  void insertCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits);
57  const WPXTableCell *getCell(size_t i, size_t j)
58  {
59  return &(m_tableRows[i])[j];
60  }
61  void makeBordersConsistent();
62 
63  unsigned getRowCount() const
64  {
65  return m_tableRows.size();
66  }
67  unsigned getColumnCount(unsigned row) const
68  {
69  return m_tableRows[row].size();
70  }
71  bool isEmpty() const
72  {
73  return m_tableRows.empty();
74  }
75 
76 private:
77  void _makeCellBordersConsistent(WPXTableCell &cell, std::vector<WPXTableCell *> &adjacentCells,
78  int adjacencyBitCell, int adjacencyBitBoundCells);
79  std::vector<WPXTableCell *> _getCellsBottomAdjacent(int i, int j);
80  std::vector<WPXTableCell *> _getCellsRightAdjacent(int i, int j);
81 
82 private:
83  std::vector< std::vector<WPXTableCell> > m_tableRows;
84 };
85 
86 #endif /* _WPXTABLE_H */
87 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
unsigned char m_rowSpan
Definition: WPXTable.h:46
const WPXTableCell * getCell(size_t i, size_t j)
Definition: WPXTable.h:57
Definition: WPXTable.h:50
void insertCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits)
Definition: WPXTable.cpp:48
Definition: WPXTable.h:42
std::vector< WPXTableCell * > _getCellsRightAdjacent(int i, int j)
Definition: WPXTable.cpp:125
unsigned getColumnCount(unsigned row) const
Definition: WPXTable.h:67
unsigned char m_colSpan
Definition: WPXTable.h:45
void insertRow()
Definition: WPXTable.cpp:43
std::vector< std::vector< WPXTableCell > > m_tableRows
Definition: WPXTable.h:83
void makeBordersConsistent()
Definition: WPXTable.cpp:58
WPXTable()
Definition: WPXTable.h:53
void _makeCellBordersConsistent(WPXTableCell &cell, std::vector< WPXTableCell *> &adjacentCells, int adjacencyBitCell, int adjacencyBitBoundCells)
Definition: WPXTable.cpp:81
bool isEmpty() const
Definition: WPXTable.h:71
unsigned getRowCount() const
Definition: WPXTable.h:63
~WPXTable()
Definition: WPXTable.cpp:39
std::vector< WPXTableCell * > _getCellsBottomAdjacent(int i, int j)
Definition: WPXTable.cpp:105
WPXTableCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits)
Definition: WPXTable.cpp:32
unsigned char m_borderBits
Definition: WPXTable.h:47

Generated for libwpd by doxygen 1.8.14